本文整理汇总了C++中FloatRect::scale方法的典型用法代码示例。如果您正苦于以下问题:C++ FloatRect::scale方法的具体用法?C++ FloatRect::scale怎么用?C++ FloatRect::scale使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FloatRect
的用法示例。
在下文中一共展示了FloatRect::scale方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: drawPatternForContainer
void SVGImage::drawPatternForContainer(GraphicsContext* context, const FloatSize containerSize, float zoom, const FloatRect& srcRect,
const AffineTransform& patternTransform, const FloatPoint& phase, ColorSpace colorSpace, CompositeOperator compositeOp, const FloatRect& dstRect)
{
FloatRect zoomedContainerRect = FloatRect(FloatPoint(), containerSize);
zoomedContainerRect.scale(zoom);
// The ImageBuffer size needs to be scaled to match the final resolution.
AffineTransform transform = context->getCTM();
FloatSize imageBufferScale = FloatSize(transform.xScale(), transform.yScale());
ASSERT(imageBufferScale.width());
ASSERT(imageBufferScale.height());
FloatRect imageBufferSize = zoomedContainerRect;
imageBufferSize.scale(imageBufferScale.width(), imageBufferScale.height());
OwnPtr<ImageBuffer> buffer = ImageBuffer::create(expandedIntSize(imageBufferSize.size()), 1);
if (!buffer) // Failed to allocate buffer.
return;
drawForContainer(buffer->context(), containerSize, zoom, imageBufferSize, zoomedContainerRect, ColorSpaceDeviceRGB, CompositeSourceOver, BlendModeNormal);
RefPtr<Image> image = buffer->copyImage(DontCopyBackingStore, Unscaled);
// Adjust the source rect and transform due to the image buffer's scaling.
FloatRect scaledSrcRect = srcRect;
scaledSrcRect.scale(imageBufferScale.width(), imageBufferScale.height());
AffineTransform unscaledPatternTransform(patternTransform);
unscaledPatternTransform.scale(1 / imageBufferScale.width(), 1 / imageBufferScale.height());
image->drawPattern(context, scaledSrcRect, unscaledPatternTransform, phase, colorSpace, compositeOp, dstRect);
}
示例2: drawPatternForContainer
void SVGImage::drawPatternForContainer(GraphicsContext& context, const FloatSize& containerSize, float zoom, const FloatRect& srcRect,
const AffineTransform& patternTransform, const FloatPoint& phase, const FloatSize& spacing, CompositeOperator compositeOp, const FloatRect& dstRect, BlendMode blendMode)
{
FloatRect zoomedContainerRect = FloatRect(FloatPoint(), containerSize);
zoomedContainerRect.scale(zoom);
// The ImageBuffer size needs to be scaled to match the final resolution.
AffineTransform transform = context.getCTM();
FloatSize imageBufferScale = FloatSize(transform.xScale(), transform.yScale());
ASSERT(imageBufferScale.width());
ASSERT(imageBufferScale.height());
FloatRect imageBufferSize = zoomedContainerRect;
imageBufferSize.scale(imageBufferScale.width(), imageBufferScale.height());
std::unique_ptr<ImageBuffer> buffer = ImageBuffer::createCompatibleBuffer(expandedIntSize(imageBufferSize.size()), 1, ColorSpaceSRGB, context, true);
if (!buffer) // Failed to allocate buffer.
return;
drawForContainer(buffer->context(), containerSize, zoom, imageBufferSize, zoomedContainerRect, CompositeSourceOver, BlendModeNormal);
if (context.drawLuminanceMask())
buffer->convertToLuminanceMask();
RefPtr<Image> image = ImageBuffer::sinkIntoImage(WTFMove(buffer), Unscaled);
if (!image)
return;
// Adjust the source rect and transform due to the image buffer's scaling.
FloatRect scaledSrcRect = srcRect;
scaledSrcRect.scale(imageBufferScale.width(), imageBufferScale.height());
AffineTransform unscaledPatternTransform(patternTransform);
unscaledPatternTransform.scale(1 / imageBufferScale.width(), 1 / imageBufferScale.height());
context.setDrawLuminanceMask(false);
image->drawPattern(context, scaledSrcRect, unscaledPatternTransform, phase, spacing, compositeOp, dstRect, blendMode);
}
示例3: drawPatternForContainer
void SVGImage::drawPatternForContainer(GraphicsContext* context, const FloatSize containerSize, float zoom, const FloatRect& srcRect,
const FloatSize& scale, const FloatPoint& phase, CompositeOperator compositeOp, const FloatRect& dstRect, blink::WebBlendMode blendMode, const IntSize& repeatSpacing)
{
FloatRect zoomedContainerRect = FloatRect(FloatPoint(), containerSize);
zoomedContainerRect.scale(zoom);
// The ImageBuffer size needs to be scaled to match the final resolution.
// FIXME: No need to get the full CTM here, we just need the scale.
AffineTransform transform = context->getCTM();
FloatSize imageBufferScale = FloatSize(transform.xScale(), transform.yScale());
ASSERT(imageBufferScale.width());
ASSERT(imageBufferScale.height());
FloatSize scaleWithoutCTM(scale.width() / imageBufferScale.width(), scale.height() / imageBufferScale.height());
FloatRect imageBufferSize = zoomedContainerRect;
imageBufferSize.scale(imageBufferScale.width(), imageBufferScale.height());
OwnPtr<ImageBuffer> buffer = ImageBuffer::create(expandedIntSize(imageBufferSize.size()));
if (!buffer) // Failed to allocate buffer.
return;
drawForContainer(buffer->context(), containerSize, zoom, imageBufferSize, zoomedContainerRect, CompositeSourceOver, blink::WebBlendModeNormal);
RefPtr<Image> image = buffer->copyImage(DontCopyBackingStore, Unscaled);
// Adjust the source rect and transform due to the image buffer's scaling.
FloatRect scaledSrcRect = srcRect;
scaledSrcRect.scale(imageBufferScale.width(), imageBufferScale.height());
image->drawPattern(context, scaledSrcRect, scaleWithoutCTM, phase, compositeOp, dstRect, blendMode, repeatSpacing);
}
示例4: blitFromContents
bool Surface::blitFromContents(Tile* tile)
{
if (!singleLayer() || !tile || !getFirstLayer() || !getFirstLayer()->content())
return false;
LayerContent* content = getFirstLayer()->content();
// Extract the dirty rect from the region. Note that this is *NOT* constrained
// to this tile
IntRect dirtyRect = tile->dirtyArea().getBounds();
IntRect tileRect = IntRect(tile->x() * TilesManager::tileWidth(),
tile->y() * TilesManager::tileHeight(),
TilesManager::tileWidth(),
TilesManager::tileHeight());
FloatRect tileRectInDoc = tileRect;
tileRectInDoc.scale(1 / tile->scale());
dirtyRect.intersect(enclosingIntRect(tileRectInDoc));
PrerenderedInval* prerenderedInval = content->prerenderForRect(dirtyRect);
if (!prerenderedInval || prerenderedInval->bitmap.isNull())
return false;
SkBitmap sourceBitmap = prerenderedInval->bitmap;
// Calculate the screen rect that is dirty, then intersect it with the
// tile's screen rect so that we end up with the pixels we need to blit
FloatRect screenDirty = dirtyRect;
screenDirty.scale(tile->scale());
IntRect enclosingScreenDirty = enclosingIntRect(screenDirty);
enclosingScreenDirty.intersect(tileRect);
if (enclosingScreenDirty.isEmpty())
return false;
// Make sure the screen area we want to blit is contained by the
// prerendered screen area
if (!prerenderedInval->screenArea.contains(enclosingScreenDirty)) {
ALOGD("prerendered->screenArea " INT_RECT_FORMAT " doesn't contain "
"enclosingScreenDirty " INT_RECT_FORMAT,
INT_RECT_ARGS(prerenderedInval->screenArea),
INT_RECT_ARGS(enclosingScreenDirty));
return false;
}
IntPoint origin = prerenderedInval->screenArea.location();
SkBitmap subset;
subset.setConfig(sourceBitmap.config(), enclosingScreenDirty.width(),
enclosingScreenDirty.height());
subset.allocPixels();
int topOffset = enclosingScreenDirty.y() - prerenderedInval->screenArea.y();
int leftOffset = enclosingScreenDirty.x() - prerenderedInval->screenArea.x();
if (!GLUtils::deepCopyBitmapSubset(sourceBitmap, subset, leftOffset, topOffset))
return false;
// Now upload
SkIRect textureInval = SkIRect::MakeXYWH(enclosingScreenDirty.x() - tileRect.x(),
enclosingScreenDirty.y() - tileRect.y(),
enclosingScreenDirty.width(),
enclosingScreenDirty.height());
GLUtils::updateTextureWithBitmap(tile->frontTexture()->m_ownTextureId,
subset, textureInval);
tile->onBlitUpdate();
return true;
}
示例5: update
void TileCoverageMap::update()
{
FloatRect containerBounds = m_controller.bounds();
FloatRect visibleRect = m_controller.visibleRect();
FloatRect coverageRect = m_controller.coverageRect();
visibleRect.contract(4, 4); // Layer is positioned 2px from top and left edges.
float widthScale = 1;
float scale = 1;
if (!containerBounds.isEmpty()) {
widthScale = std::min<float>(visibleRect.width() / containerBounds.width(), 0.1);
float visibleHeight = visibleRect.height() - std::min(m_controller.topContentInset(), visibleRect.y());
scale = std::min(widthScale, visibleHeight / containerBounds.height());
}
float indicatorScale = scale * m_controller.tileGrid().scale();
FloatRect mapBounds = containerBounds;
mapBounds.scale(indicatorScale, indicatorScale);
m_layer.get().setPosition(m_position + FloatPoint(2, 2));
m_layer.get().setBounds(mapBounds);
m_layer.get().setNeedsDisplay();
visibleRect.scale(indicatorScale, indicatorScale);
visibleRect.expand(2, 2);
m_visibleRectIndicatorLayer->setPosition(visibleRect.location());
m_visibleRectIndicatorLayer->setBounds(FloatRect(FloatPoint(), visibleRect.size()));
coverageRect.scale(indicatorScale, indicatorScale);
coverageRect.expand(2, 2);
m_coverageRectIndicatorLayer->setPosition(coverageRect.location());
m_coverageRectIndicatorLayer->setBounds(FloatRect(FloatPoint(), coverageRect.size()));
Color visibleRectIndicatorColor;
switch (m_controller.indicatorMode()) {
case SynchronousScrollingBecauseOfStyleIndication:
visibleRectIndicatorColor = Color(255, 0, 0);
break;
case SynchronousScrollingBecauseOfEventHandlersIndication:
visibleRectIndicatorColor = Color(255, 255, 0);
break;
case AsyncScrollingIndication:
visibleRectIndicatorColor = Color(0, 200, 0);
break;
}
m_visibleRectIndicatorLayer.get().setBorderColor(visibleRectIndicatorColor);
}
示例6: drawPattern
void GeneratorGeneratedImage::drawPattern(GraphicsContext* destContext, const FloatRect& srcRect, const AffineTransform& patternTransform,
const FloatPoint& phase, ColorSpace styleColorSpace, CompositeOperator compositeOp, const FloatRect& destRect)
{
// Allow the generator to provide visually-equivalent tiling parameters for better performance.
IntSize adjustedSize = m_size;
FloatRect adjustedSrcRect = srcRect;
m_generator->adjustParametersForTiledDrawing(adjustedSize, adjustedSrcRect);
// Factor in the destination context's scale to generate at the best resolution
AffineTransform destContextCTM = destContext->getCTM();
double xScale = fabs(destContextCTM.xScale());
double yScale = fabs(destContextCTM.yScale());
AffineTransform adjustedPatternCTM = patternTransform;
adjustedPatternCTM.scale(1.0 / xScale, 1.0 / yScale);
adjustedSrcRect.scale(xScale, yScale);
// Create a BitmapImage and call drawPattern on it.
OwnPtr<ImageBuffer> imageBuffer = destContext->createCompatibleBuffer(adjustedSize);
if (!imageBuffer)
return;
// Fill with the generated image.
GraphicsContext* graphicsContext = imageBuffer->context();
graphicsContext->fillRect(FloatRect(FloatPoint(), adjustedSize), *m_generator.get());
// Tile the image buffer into the context.
imageBuffer->drawPattern(destContext, adjustedSrcRect, adjustedPatternCTM, phase, styleColorSpace, compositeOp, destRect);
}
示例7: apply
void FEOffset::apply(Filter* filter)
{
m_in->apply(filter);
if (!m_in->resultImage())
return;
GraphicsContext* filterContext = getEffectContext();
if (!filterContext)
return;
setIsAlphaImage(m_in->isAlphaImage());
FloatRect sourceImageRect = filter->sourceImageRect();
sourceImageRect.scale(filter->filterResolution().width(), filter->filterResolution().height());
if (filter->effectBoundingBoxMode()) {
m_dx *= sourceImageRect.width();
m_dy *= sourceImageRect.height();
}
m_dx *= filter->filterResolution().width();
m_dy *= filter->filterResolution().height();
FloatRect dstRect = FloatRect(m_dx + m_in->scaledSubRegion().x() - scaledSubRegion().x(),
m_dy + m_in->scaledSubRegion().y() - scaledSubRegion().y(),
m_in->scaledSubRegion().width(),
m_in->scaledSubRegion().height());
filterContext->drawImageBuffer(m_in->resultImage(), DeviceColorSpace, dstRect);
}
示例8: drawPattern
void GeneratorGeneratedImage::drawPattern(GraphicsContext* destContext, const FloatRect& srcRect, const FloatSize& scale,
const FloatPoint& phase, CompositeOperator compositeOp, const FloatRect& destRect, BlendMode)
{
// Allow the generator to provide visually-equivalent tiling parameters for better performance.
IntSize adjustedSize = m_size;
FloatRect adjustedSrcRect = srcRect;
m_gradient->adjustParametersForTiledDrawing(adjustedSize, adjustedSrcRect);
// Factor in the destination context's scale to generate at the best resolution.
// FIXME: No need to get the full CTM here, we just need the scale.
AffineTransform destContextCTM = destContext->getCTM(GraphicsContext::DefinitelyIncludeDeviceScale);
float xScale = fabs(destContextCTM.xScale());
float yScale = fabs(destContextCTM.yScale());
FloatSize scaleWithoutCTM(scale.width() / xScale, scale.height() / yScale);
adjustedSrcRect.scale(xScale, yScale);
unsigned generatorHash = m_gradient->hash();
if (!m_cachedImageBuffer || m_cachedGeneratorHash != generatorHash || m_cachedAdjustedSize != adjustedSize || !destContext->isCompatibleWithBuffer(m_cachedImageBuffer.get())) {
m_cachedImageBuffer = destContext->createCompatibleBuffer(adjustedSize, m_gradient->hasAlpha());
if (!m_cachedImageBuffer)
return;
// Fill with the generated image.
m_cachedImageBuffer->context()->setFillGradient(m_gradient);
m_cachedImageBuffer->context()->fillRect(FloatRect(FloatPoint(), adjustedSize));
m_cachedGeneratorHash = generatorHash;
m_cachedAdjustedSize = adjustedSize;
}
// Tile the image buffer into the context.
m_cachedImageBuffer->drawPattern(destContext, adjustedSrcRect, scaleWithoutCTM, phase, compositeOp, destRect);
m_cacheTimer.restart();
}
示例9: rootFrameToViewport
FloatRect VisualViewport::rootFrameToViewport(
const FloatRect& rectInRootFrame) const {
FloatRect rectInViewport = rectInRootFrame;
rectInViewport.move(-getScrollOffset());
rectInViewport.scale(scale());
return rectInViewport;
}
示例10: viewportToRootFrame
FloatRect VisualViewport::viewportToRootFrame(
const FloatRect& rectInViewport) const {
FloatRect rectInRootFrame = rectInViewport;
rectInRootFrame.scale(1 / scale());
rectInRootFrame.move(getScrollOffset());
return rectInRootFrame;
}
示例11: drawPattern
void GeneratorGeneratedImage::drawPattern(GraphicsContext* destContext, const FloatRect& srcRect, const AffineTransform& patternTransform,
const FloatPoint& phase, ColorSpace styleColorSpace, CompositeOperator compositeOp, const FloatRect& destRect, BlendMode)
{
// Allow the generator to provide visually-equivalent tiling parameters for better performance.
IntSize adjustedSize = m_size;
FloatRect adjustedSrcRect = srcRect;
m_gradient->adjustParametersForTiledDrawing(adjustedSize, adjustedSrcRect);
// Factor in the destination context's scale to generate at the best resolution
AffineTransform destContextCTM = destContext->getCTM(GraphicsContext::DefinitelyIncludeDeviceScale);
double xScale = fabs(destContextCTM.xScale());
double yScale = fabs(destContextCTM.yScale());
AffineTransform adjustedPatternCTM = patternTransform;
adjustedPatternCTM.scale(1.0 / xScale, 1.0 / yScale);
adjustedSrcRect.scale(xScale, yScale);
unsigned generatorHash = m_gradient->hash();
if (!m_cachedImageBuffer || m_cachedGeneratorHash != generatorHash || m_cachedAdjustedSize != adjustedSize || !destContext->isCompatibleWithBuffer(m_cachedImageBuffer.get())) {
m_cachedImageBuffer = destContext->createCompatibleBuffer(adjustedSize, m_gradient->hasAlpha());
if (!m_cachedImageBuffer)
return;
// Fill with the generated image.
m_cachedImageBuffer->context()->fillRect(FloatRect(FloatPoint(), adjustedSize), *m_gradient);
m_cachedGeneratorHash = generatorHash;
m_cachedAdjustedSize = adjustedSize;
}
m_cachedImageBuffer->setSpaceSize(spaceSize());
// Tile the image buffer into the context.
m_cachedImageBuffer->drawPattern(destContext, adjustedSrcRect, adjustedPatternCTM, phase, styleColorSpace, compositeOp, destRect);
}
示例12: rootFrameToViewport
FloatRect VisualViewport::rootFrameToViewport(const FloatRect& rectInRootFrame) const
{
FloatRect rectInViewport = rectInRootFrame;
rectInViewport.moveBy(-location());
rectInViewport.scale(scale());
return rectInViewport;
}
示例13: selectionRectForTextFragment
FloatRect SVGInlineTextBox::selectionRectForTextFragment(const SVGTextFragment& fragment, int startPosition, int endPosition, RenderStyle* style)
{
ASSERT(startPosition < endPosition);
ASSERT(style);
FontCachePurgePreventer fontCachePurgePreventer;
RenderSVGInlineText* textRenderer = toRenderSVGInlineText(this->textRenderer());
ASSERT(textRenderer);
float scalingFactor = textRenderer->scalingFactor();
ASSERT(scalingFactor);
const Font& scaledFont = textRenderer->scaledFont();
const FontMetrics& scaledFontMetrics = scaledFont.fontMetrics();
FloatPoint textOrigin(fragment.x, fragment.y);
if (scalingFactor != 1)
textOrigin.scale(scalingFactor, scalingFactor);
textOrigin.move(0, -scaledFontMetrics.floatAscent());
FloatRect selectionRect = scaledFont.selectionRectForText(constructTextRun(style, fragment), textOrigin, fragment.height * scalingFactor, startPosition, endPosition);
if (scalingFactor == 1)
return selectionRect;
selectionRect.scale(1 / scalingFactor);
return selectionRect;
}
示例14: selectionRectForTextFragment
FloatRect SVGInlineTextBox::selectionRectForTextFragment(const SVGTextFragment& fragment, int startPosition, int endPosition, RenderStyle* style) const
{
ASSERT_WITH_SECURITY_IMPLICATION(startPosition < endPosition);
ASSERT(style);
float scalingFactor = renderer().scalingFactor();
ASSERT(scalingFactor);
const FontCascade& scaledFont = renderer().scaledFont();
const FontMetrics& scaledFontMetrics = scaledFont.fontMetrics();
FloatPoint textOrigin(fragment.x, fragment.y);
if (scalingFactor != 1)
textOrigin.scale(scalingFactor, scalingFactor);
textOrigin.move(0, -scaledFontMetrics.floatAscent());
LayoutRect selectionRect = LayoutRect(textOrigin, LayoutSize(0, fragment.height * scalingFactor));
TextRun run = constructTextRun(style, fragment);
scaledFont.adjustSelectionRectForText(run, selectionRect, startPosition, endPosition);
FloatRect snappedSelectionRect = snapRectToDevicePixelsWithWritingDirection(selectionRect, renderer().document().deviceScaleFactor(), run.ltr());
if (scalingFactor == 1)
return snappedSelectionRect;
snappedSelectionRect.scale(1 / scalingFactor);
return snappedSelectionRect;
}
示例15: determineAbsolutePaintRect
void SourceGraphic::determineAbsolutePaintRect()
{
Filter* filter = this->filter();
FloatRect paintRect = filter->sourceImageRect();
paintRect.scale(filter->filterResolution().width(), filter->filterResolution().height());
setAbsolutePaintRect(enclosingIntRect(paintRect));
}