本文整理汇总了C++中AffineTransform::mapRect方法的典型用法代码示例。如果您正苦于以下问题:C++ AffineTransform::mapRect方法的具体用法?C++ AffineTransform::mapRect怎么用?C++ AffineTransform::mapRect使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AffineTransform
的用法示例。
在下文中一共展示了AffineTransform::mapRect方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: createMaskAndSwapContextForTextGradient
static inline bool createMaskAndSwapContextForTextGradient(GraphicsContext*& context,
GraphicsContext*& savedContext,
OwnPtr<ImageBuffer>& imageBuffer,
const RenderObject* object)
{
const RenderObject* textRootBlock = findTextRootObject(object);
AffineTransform transform = absoluteTransformForRenderer(textRootBlock);
FloatRect maskAbsoluteBoundingBox = transform.mapRect(textRootBlock->repaintRectInLocalCoordinates());
IntRect maskImageRect = enclosingIntRect(maskAbsoluteBoundingBox);
if (maskImageRect.isEmpty())
return false;
// Allocate an image buffer as big as the absolute unclipped size of the object
OwnPtr<ImageBuffer> maskImage = ImageBuffer::create(maskImageRect.size());
if (!maskImage)
return false;
GraphicsContext* maskImageContext = maskImage->context();
// Transform the mask image coordinate system to absolute screen coordinates
maskImageContext->translate(-maskAbsoluteBoundingBox.x(), -maskAbsoluteBoundingBox.y());
maskImageContext->concatCTM(transform);
imageBuffer.set(maskImage.release());
savedContext = context;
context = maskImageContext;
return true;
}
示例2: resourceBoundingBox
FloatRect LayoutSVGResourceMasker::resourceBoundingBox(const LayoutObject* object)
{
SVGMaskElement* maskElement = toSVGMaskElement(element());
ASSERT(maskElement);
FloatRect objectBoundingBox = object->objectBoundingBox();
FloatRect maskBoundaries = SVGLengthContext::resolveRectangle<SVGMaskElement>(maskElement, maskElement->maskUnits()->currentValue()->enumValue(), objectBoundingBox);
// Resource was not layouted yet. Give back clipping rect of the mask.
if (selfNeedsLayout())
return maskBoundaries;
if (m_maskContentBoundaries.isEmpty())
calculateMaskContentPaintInvalidationRect();
FloatRect maskRect = m_maskContentBoundaries;
if (maskElement->maskContentUnits()->currentValue()->value() == SVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX) {
AffineTransform transform;
transform.translate(objectBoundingBox.x(), objectBoundingBox.y());
transform.scaleNonUniform(objectBoundingBox.width(), objectBoundingBox.height());
maskRect = transform.mapRect(maskRect);
}
maskRect.intersect(maskBoundaries);
return maskRect;
}
示例3: localSelectionRect
LayoutRect SVGInlineTextBox::localSelectionRect(unsigned startPosition, unsigned endPosition) const
{
startPosition = clampedOffset(startPosition);
endPosition = clampedOffset(endPosition);
if (startPosition >= endPosition)
return LayoutRect();
auto& style = renderer().style();
AffineTransform fragmentTransform;
FloatRect selectionRect;
unsigned fragmentStartPosition = 0;
unsigned fragmentEndPosition = 0;
unsigned textFragmentsSize = m_textFragments.size();
for (unsigned i = 0; i < textFragmentsSize; ++i) {
const SVGTextFragment& fragment = m_textFragments.at(i);
fragmentStartPosition = startPosition;
fragmentEndPosition = endPosition;
if (!mapStartEndPositionsIntoFragmentCoordinates(fragment, fragmentStartPosition, fragmentEndPosition))
continue;
FloatRect fragmentRect = selectionRectForTextFragment(fragment, fragmentStartPosition, fragmentEndPosition, &style);
fragment.buildFragmentTransform(fragmentTransform);
if (!fragmentTransform.isIdentity())
fragmentRect = fragmentTransform.mapRect(fragmentRect);
selectionRect.unite(fragmentRect);
}
return enclosingIntRect(selectionRect);
}
示例4: calculateBoundaries
FloatRect SVGInlineTextBox::calculateBoundaries() const
{
FloatRect textRect;
RenderSVGInlineText* textRenderer = toRenderSVGInlineText(this->textRenderer());
ASSERT(textRenderer);
float scalingFactor = textRenderer->scalingFactor();
ASSERT(scalingFactor);
float baseline = textRenderer->scaledFont().fontMetrics().floatAscent() / scalingFactor;
AffineTransform fragmentTransform;
unsigned textFragmentsSize = m_textFragments.size();
for (unsigned i = 0; i < textFragmentsSize; ++i) {
const SVGTextFragment& fragment = m_textFragments.at(i);
FloatRect fragmentRect(fragment.x, fragment.y - baseline, fragment.width, fragment.height);
fragment.buildFragmentTransform(fragmentTransform);
if (!fragmentTransform.isIdentity())
fragmentRect = fragmentTransform.mapRect(fragmentRect);
textRect.unite(fragmentRect);
}
return textRect;
}
示例5: resourceBoundingBox
FloatRect RenderSVGResourceMasker::resourceBoundingBox(RenderObject* object)
{
// Save the reference to the calling object for relayouting it on changing resource properties.
if (!m_masker.contains(object))
m_masker.set(object, new MaskerData);
// Resource was not layouted yet. Give back clipping rect of the mask.
SVGMaskElement* maskElement = static_cast<SVGMaskElement*>(node());
FloatRect objectBoundingBox = object->objectBoundingBox();
FloatRect maskBoundaries = maskElement->maskBoundingBox(objectBoundingBox);
if (selfNeedsLayout())
return maskBoundaries;
if (m_maskBoundaries.isEmpty())
calculateMaskContentRepaintRect();
if (!maskElement)
return FloatRect();
FloatRect maskRect = m_maskBoundaries;
if (maskElement->maskContentUnits() == SVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX) {
AffineTransform transform;
transform.translate(objectBoundingBox.x(), objectBoundingBox.y());
transform.scaleNonUniform(objectBoundingBox.width(), objectBoundingBox.height());
maskRect = transform.mapRect(maskRect);
}
maskRect.intersect(maskBoundaries);
return maskRect;
}
示例6: resourceBoundingBox
FloatRect RenderSVGResourceMasker::resourceBoundingBox(RenderObject* object)
{
SVGMaskElement* maskElement = static_cast<SVGMaskElement*>(node());
ASSERT(maskElement);
FloatRect objectBoundingBox = object->objectBoundingBox();
FloatRect maskBoundaries = maskElement->maskBoundingBox(objectBoundingBox);
// Resource was not layouted yet. Give back clipping rect of the mask.
if (selfNeedsLayout())
return maskBoundaries;
if (m_maskContentBoundaries.isEmpty())
calculateMaskContentRepaintRect();
FloatRect maskRect = m_maskContentBoundaries;
if (maskElement->maskContentUnits() == SVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX) {
AffineTransform transform;
transform.translate(objectBoundingBox.x(), objectBoundingBox.y());
transform.scaleNonUniform(objectBoundingBox.width(), objectBoundingBox.height());
maskRect = transform.mapRect(maskRect);
}
maskRect.intersect(maskBoundaries);
return maskRect;
}
示例7: createMaskAndSwapContextForTextGradient
static inline bool createMaskAndSwapContextForTextGradient(GraphicsContext*& context,
GraphicsContext*& savedContext,
OwnPtr<ImageBuffer>& imageBuffer,
RenderObject* object)
{
RenderObject* textRootBlock = RenderSVGText::locateRenderSVGTextAncestor(object);
ASSERT(textRootBlock);
AffineTransform absoluteTransform;
SVGImageBufferTools::calculateTransformationToOutermostSVGCoordinateSystem(textRootBlock, absoluteTransform);
FloatRect absoluteTargetRect = absoluteTransform.mapRect(textRootBlock->repaintRectInLocalCoordinates());
FloatRect clampedAbsoluteTargetRect = SVGImageBufferTools::clampedAbsoluteTargetRectForRenderer(textRootBlock, absoluteTargetRect);
if (clampedAbsoluteTargetRect.isEmpty())
return false;
OwnPtr<ImageBuffer> maskImage;
if (!SVGImageBufferTools::createImageBuffer(absoluteTargetRect, clampedAbsoluteTargetRect, maskImage, ColorSpaceDeviceRGB))
return false;
GraphicsContext* maskImageContext = maskImage->context();
ASSERT(maskImageContext);
maskImageContext->translate(-clampedAbsoluteTargetRect.x(), -clampedAbsoluteTargetRect.y());
maskImageContext->concatCTM(absoluteTransform);
ASSERT(maskImage);
savedContext = context;
context = maskImageContext;
imageBuffer = maskImage.release();
return true;
}
示例8: resourceBoundingBox
FloatRect RenderSVGResourceClipper::resourceBoundingBox(const FloatRect& objectBoundingBox) const
{
FloatRect clipRect;
for (Node* childNode = node()->firstChild(); childNode; childNode = childNode->nextSibling()) {
if (!childNode->isSVGElement() || !static_cast<SVGElement*>(childNode)->isStyledTransformable())
continue;
SVGStyledTransformableElement* styled = static_cast<SVGStyledTransformableElement*>(childNode);
RenderStyle* style = styled->renderer() ? styled->renderer()->style() : 0;
if (!style || style->display() == NONE)
continue;
clipRect.unite(styled->renderer()->objectBoundingBox());
}
if (clipRect.isEmpty())
return FloatRect();
if (static_cast<SVGClipPathElement*>(node())->clipPathUnits() == SVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX) {
AffineTransform obbTransform;
obbTransform.translate(objectBoundingBox.x(), objectBoundingBox.y());
obbTransform.scaleNonUniform(objectBoundingBox.width(), objectBoundingBox.height());
return obbTransform.mapRect(clipRect);
}
return clipRect;
}
示例9: clipToTextMask
static inline AffineTransform clipToTextMask(GraphicsContext* context,
OwnPtr<ImageBuffer>& imageBuffer,
FloatRect& targetRect,
RenderObject* object,
bool boundingBoxMode,
const AffineTransform& gradientTransform)
{
RenderObject* textRootBlock = RenderSVGText::locateRenderSVGTextAncestor(object);
ASSERT(textRootBlock);
targetRect = textRootBlock->repaintRectInLocalCoordinates();
AffineTransform absoluteTransform;
SVGImageBufferTools::calculateTransformationToOutermostSVGCoordinateSystem(textRootBlock, absoluteTransform);
FloatRect absoluteTargetRect = absoluteTransform.mapRect(targetRect);
FloatRect clampedAbsoluteTargetRect = SVGImageBufferTools::clampedAbsoluteTargetRectForRenderer(textRootBlock, absoluteTargetRect);
SVGImageBufferTools::clipToImageBuffer(context, absoluteTransform, clampedAbsoluteTargetRect, imageBuffer);
AffineTransform matrix;
if (boundingBoxMode) {
FloatRect maskBoundingBox = textRootBlock->objectBoundingBox();
matrix.translate(maskBoundingBox.x(), maskBoundingBox.y());
matrix.scaleNonUniform(maskBoundingBox.width(), maskBoundingBox.height());
}
matrix *= gradientTransform;
return matrix;
}
示例10: computeAbsoluteRepaintRect
void RenderForeignObject::computeAbsoluteRepaintRect(IntRect& r, bool f)
{
AffineTransform transform = translationForAttributes() * localTransform();
r = transform.mapRect(r);
RenderBlock::computeAbsoluteRepaintRect(r, f);
}
示例11: clippedOverflowRectForPaintInvalidation
LayoutRect SVGRenderSupport::clippedOverflowRectForPaintInvalidation(const RenderObject* object, const RenderLayerModelObject* paintInvalidationContainer, const PaintInvalidationState* paintInvalidationState)
{
// Return early for any cases where we don't actually paint
if (object->style()->visibility() != VISIBLE && !object->enclosingLayer()->hasVisibleContent())
return LayoutRect();
// Pass our local paint rect to computeRectForPaintInvalidation() which will
// map to parent coords and recurse up the parent chain.
FloatRect paintInvalidationRect = object->paintInvalidationRectInLocalCoordinates();
paintInvalidationRect.inflate(object->style()->outlineWidth());
if (paintInvalidationState && paintInvalidationState->canMapToContainer(paintInvalidationContainer)) {
// Compute accumulated SVG transform and apply to local paint rect.
AffineTransform transform = paintInvalidationState->svgTransform() * object->localToParentTransform();
paintInvalidationRect = transform.mapRect(paintInvalidationRect);
// FIXME: These are quirks carried forward from the old paint invalidation infrastructure.
LayoutRect rect = enclosingIntRectIfNotEmpty(paintInvalidationRect);
// Offset by SVG root paint offset and apply clipping as needed.
rect.move(paintInvalidationState->paintOffset());
if (paintInvalidationState->isClipped())
rect.intersect(paintInvalidationState->clipRect());
return rect;
}
LayoutRect rect;
const RenderSVGRoot& svgRoot = mapRectToSVGRootForPaintInvalidation(object, paintInvalidationRect, rect);
svgRoot.mapRectToPaintInvalidationBacking(paintInvalidationContainer, rect, paintInvalidationState);
return rect;
}
示例12: calculatePatternBoundariesIncludingOverflow
FloatRect RenderSVGResourcePattern::calculatePatternBoundariesIncludingOverflow(PatternAttributes& attributes,
const FloatRect& objectBoundingBox,
const AffineTransform& viewBoxCTM,
const FloatRect& patternBoundaries) const
{
// Eventually calculate the pattern content boundaries (only needed with overflow="visible").
FloatRect patternContentBoundaries;
const RenderStyle* style = this->style();
if (style->overflowX() == OVISIBLE && style->overflowY() == OVISIBLE) {
for (Node* node = attributes.patternContentElement()->firstChild(); node; node = node->nextSibling()) {
if (!node->isSVGElement() || !static_cast<SVGElement*>(node)->isStyledTransformable() || !node->renderer())
continue;
patternContentBoundaries.unite(node->renderer()->repaintRectInLocalCoordinates());
}
}
if (patternContentBoundaries.isEmpty())
return patternBoundaries;
FloatRect patternBoundariesIncludingOverflow = patternBoundaries;
// Respect objectBoundingBoxMode for patternContentUnits, if viewBox is not set.
if (!viewBoxCTM.isIdentity())
patternContentBoundaries = viewBoxCTM.mapRect(patternContentBoundaries);
else if (attributes.boundingBoxModeContent())
patternContentBoundaries = FloatRect(patternContentBoundaries.x() * objectBoundingBox.width(),
patternContentBoundaries.y() * objectBoundingBox.height(),
patternContentBoundaries.width() * objectBoundingBox.width(),
patternContentBoundaries.height() * objectBoundingBox.height());
patternBoundariesIncludingOverflow.unite(patternContentBoundaries);
return patternBoundariesIncludingOverflow;
}
示例13: glyphSize
static inline void calculateGlyphBoundaries(const QueryData* queryData, const SVGTextFragment& fragment, int startPosition, FloatRect& extent)
{
float scalingFactor = queryData->textLayoutObject->scalingFactor();
ASSERT(scalingFactor);
FloatPoint glyphPosition = calculateGlyphPositionWithoutTransform(queryData, fragment, startPosition);
glyphPosition.move(0, -queryData->textLayoutObject->scaledFont().fontMetrics().floatAscent() / scalingFactor);
extent.setLocation(glyphPosition);
// Use the SVGTextMetrics computed by SVGTextMetricsBuilder (which spends
// time attempting to compute more correct glyph bounds already, handling
// cursive scripts to some degree.)
const Vector<SVGTextMetrics>& textMetricsValues = queryData->textLayoutObject->layoutAttributes()->textMetricsValues();
const SVGTextMetrics& metrics = findMetricsForCharacter(textMetricsValues, fragment, startPosition);
// TODO(fs): Negative glyph extents seems kind of weird to have, but
// presently it can occur in some cases (like Arabic.)
FloatSize glyphSize(std::max<float>(metrics.width(), 0), std::max<float>(metrics.height(), 0));
extent.setSize(glyphSize);
// If RTL, adjust the starting point to align with the LHS of the glyph bounding box.
if (!queryData->textBox->isLeftToRightDirection()) {
if (queryData->isVerticalText)
extent.move(0, -glyphSize.height());
else
extent.move(-glyphSize.width(), 0);
}
AffineTransform fragmentTransform;
fragment.buildFragmentTransform(fragmentTransform, SVGTextFragment::TransformIgnoringTextLength);
extent = fragmentTransform.mapRect(extent);
}
示例14: paintContents
void OpaqueRectTrackingContentLayerDelegate::paintContents(SkCanvas* canvas, const WebRect& clip, bool canPaintLCDText, WebFloatRect& opaque)
{
static const unsigned char* annotationsEnabled = 0;
if (UNLIKELY(!annotationsEnabled))
annotationsEnabled = EventTracer::getTraceCategoryEnabledFlag(TRACE_DISABLED_BY_DEFAULT("blink.graphics_context_annotations"));
GraphicsContext context(canvas);
context.setTrackOpaqueRegion(!m_opaque);
context.setCertainlyOpaque(m_opaque);
context.setShouldSmoothFonts(canPaintLCDText);
if (*annotationsEnabled)
context.setAnnotationMode(AnnotateAll);
// Record transform prior to painting, as all opaque tracking will be
// relative to this current value.
AffineTransform canvasToContentTransform = context.getCTM().inverse();
m_painter->paint(context, clip);
// Transform tracked opaque paints back to our layer's content space.
ASSERT(canvasToContentTransform.isInvertible());
ASSERT(canvasToContentTransform.preservesAxisAlignment());
opaque = canvasToContentTransform.mapRect(context.opaqueRegion().asRect());
}
示例15: shadowRect
void CanvasRenderingContext2D::willDraw(const FloatRect& r, unsigned options)
{
GraphicsContext* c = drawingContext();
if (!c)
return;
if (!state().m_invertibleCTM)
return;
FloatRect dirtyRect = r;
if (options & CanvasWillDrawApplyTransform) {
AffineTransform ctm = state().m_transform;
dirtyRect = ctm.mapRect(r);
}
if (options & CanvasWillDrawApplyShadow) {
// The shadow gets applied after transformation
FloatRect shadowRect(dirtyRect);
shadowRect.move(state().m_shadowOffset);
shadowRect.inflate(state().m_shadowBlur);
dirtyRect.unite(shadowRect);
}
if (options & CanvasWillDrawApplyClip) {
// FIXME: apply the current clip to the rectangle. Unfortunately we can't get the clip
// back out of the GraphicsContext, so to take clip into account for incremental painting,
// we'd have to keep the clip path around.
}
canvas()->willDraw(dirtyRect);
}