From e458d70a0d18538346f41b503114c9ebe6b2ce12 Mon Sep 17 00:00:00 2001 From: Leon Clarke Date: Thu, 15 Jul 2010 12:03:35 +0100 Subject: Merge WebKit at r63173 : Initial merge by git. Change-Id: Ife5af0c7c6261fbbc8ae6bc08c390efa9ef10b44 --- WebCore/rendering/RenderSVGResourceGradient.cpp | 27 +++++++++++++------------ 1 file changed, 14 insertions(+), 13 deletions(-) (limited to 'WebCore/rendering/RenderSVGResourceGradient.cpp') diff --git a/WebCore/rendering/RenderSVGResourceGradient.cpp b/WebCore/rendering/RenderSVGResourceGradient.cpp index 7ea70d2..74f5b13 100644 --- a/WebCore/rendering/RenderSVGResourceGradient.cpp +++ b/WebCore/rendering/RenderSVGResourceGradient.cpp @@ -73,17 +73,12 @@ void RenderSVGResourceGradient::invalidateClient(RenderObject* object) } #if PLATFORM(CG) -static inline AffineTransform absoluteTransformForRenderer(const RenderObject* object) +static inline AffineTransform absoluteTransformFromContext(GraphicsContext* context) { - AffineTransform absoluteTransform; - - const RenderObject* currentObject = object; - while (currentObject) { - absoluteTransform = currentObject->localToParentTransform() * absoluteTransform; - currentObject = currentObject->parent(); - } - - return absoluteTransform; + // Extract current transformation matrix used in the original context. Note that this coordinate + // system is flipped compared to SVGs internal coordinate system, done in WebKit level. Fix + // this transformation by flipping the y component. + return context->getCTM() * AffineTransform().flipY(); } static inline bool createMaskAndSwapContextForTextGradient(GraphicsContext*& context, @@ -93,7 +88,7 @@ static inline bool createMaskAndSwapContextForTextGradient(GraphicsContext*& con { const RenderObject* textRootBlock = SVGRenderSupport::findTextRootObject(object); - AffineTransform transform = absoluteTransformForRenderer(textRootBlock); + AffineTransform transform(absoluteTransformFromContext(context)); FloatRect maskAbsoluteBoundingBox = transform.mapRect(textRootBlock->repaintRectInLocalCoordinates()); IntRect maskImageRect = enclosingIntRect(maskAbsoluteBoundingBox); @@ -111,7 +106,7 @@ static inline bool createMaskAndSwapContextForTextGradient(GraphicsContext*& con maskImageContext->translate(-maskAbsoluteBoundingBox.x(), -maskAbsoluteBoundingBox.y()); maskImageContext->concatCTM(transform); - imageBuffer.set(maskImage.release()); + imageBuffer = maskImage.release(); savedContext = context; context = maskImageContext; @@ -124,7 +119,13 @@ static inline AffineTransform clipToTextMask(GraphicsContext* context, GradientData* gradientData) { const RenderObject* textRootBlock = SVGRenderSupport::findTextRootObject(object); - context->clipToImageBuffer(textRootBlock->repaintRectInLocalCoordinates(), imageBuffer.get()); + + // The mask image has been created in the device coordinate space, as the image should not be scaled. + // So the actual masking process has to be done in the device coordinate space as well. + AffineTransform transform(absoluteTransformFromContext(context)); + context->concatCTM(transform.inverse()); + context->clipToImageBuffer(transform.mapRect(textRootBlock->repaintRectInLocalCoordinates()), imageBuffer.get()); + context->concatCTM(transform); AffineTransform matrix; if (gradientData->boundingBoxMode) { -- cgit v1.1