Changeset 106108 in webkit
- Timestamp:
- Jan 27, 2012 4:38:57 AM (12 years ago)
- Location:
- trunk
- Files:
-
- 13 added
- 3 deleted
- 97 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r106107 r106108 1 2012-01-27 Branimir Lambov <blambov@google.com> 2 3 SVG filters incorrectly move elements 4 https://bugs.webkit.org/show_bug.cgi?id=73643 5 6 Reviewed by Nikolas Zimmermann. 7 8 New tests and updated expectations. 9 10 * platform/chromium-linux/svg/W3C-SVG-1.1/filters-color-01-b-expected.png: 11 * platform/chromium-linux/svg/W3C-SVG-1.1/filters-comptran-01-b-expected.png: 12 * platform/chromium-linux/svg/W3C-SVG-1.1/filters-example-01-b-expected.png: 13 * platform/chromium-linux/svg/W3C-SVG-1.1/filters-morph-01-f-expected.png: 14 * platform/chromium-linux/svg/W3C-SVG-1.1/fonts-elem-04-b-expected.png: Removed. 15 * platform/chromium-linux/svg/W3C-SVG-1.1/fonts-elem-04-b-expected.txt: Removed. 16 * platform/chromium-linux/svg/W3C-SVG-1.1/masking-path-01-b-expected.png: 17 * platform/chromium-linux/svg/batik/filters/feTile-expected.png: 18 * platform/chromium-linux/svg/clip-path/clipper-placement-issue-expected.png: Added. 19 * platform/chromium-linux/svg/clip-path/deep-nested-clip-in-mask-different-unitTypes-expected.png: 20 * platform/chromium-linux/svg/custom/feComponentTransfer-Discrete-expected.png: 21 * platform/chromium-linux/svg/custom/feComponentTransfer-Gamma-expected.png: 22 * platform/chromium-linux/svg/custom/feComponentTransfer-Linear-expected.png: 23 * platform/chromium-linux/svg/custom/feComponentTransfer-Table-expected.png: 24 * platform/chromium-linux/svg/dynamic-updates/SVGFEColorMatrixElement-dom-in-attr-expected.png: 25 * platform/chromium-linux/svg/dynamic-updates/SVGFEColorMatrixElement-dom-type-attr-expected.png: 26 * platform/chromium-linux/svg/dynamic-updates/SVGFEColorMatrixElement-dom-values-attr-expected.png: 27 * platform/chromium-linux/svg/dynamic-updates/SVGFEColorMatrixElement-svgdom-in-prop-expected.png: 28 * platform/chromium-linux/svg/dynamic-updates/SVGMaskElement-dom-height-attr-expected.png: 29 * platform/chromium-linux/svg/dynamic-updates/SVGMaskElement-dom-maskContentUnits-attr-expected.png: 30 * platform/chromium-linux/svg/dynamic-updates/SVGMaskElement-dom-width-attr-expected.png: 31 * platform/chromium-linux/svg/dynamic-updates/SVGMaskElement-dom-x-attr-expected.png: 32 * platform/chromium-linux/svg/dynamic-updates/SVGMaskElement-dom-y-attr-expected.png: 33 * platform/chromium-linux/svg/dynamic-updates/SVGMaskElement-svgdom-height-prop-expected.png: 34 * platform/chromium-linux/svg/dynamic-updates/SVGMaskElement-svgdom-maskContentUnits-prop-expected.png: 35 * platform/chromium-linux/svg/dynamic-updates/SVGMaskElement-svgdom-width-prop-expected.png: 36 * platform/chromium-linux/svg/dynamic-updates/SVGMaskElement-svgdom-x-prop-expected.png: 37 * platform/chromium-linux/svg/dynamic-updates/SVGMaskElement-svgdom-y-prop-expected.png: 38 * platform/chromium-linux/svg/filters/big-sized-filter-expected.png: Added. 39 * platform/chromium-linux/svg/filters/feDropShadow-expected.png: 40 * platform/chromium-linux/svg/filters/filter-placement-issue-expected.png: Added. 41 * platform/chromium-linux/svg/filters/filterRes-expected.png: 42 * platform/chromium-linux/svg/filters/filterRes-expected.txt: Removed. 43 * platform/chromium-linux/svg/filters/filterRes2-expected.png: Added. 44 * platform/chromium-linux/svg/wicd/test-scalable-background-image1-expected.png: 45 * platform/chromium-win/svg/as-background-image/svg-as-background-2-expected.png: 46 * platform/chromium-win/svg/filters/big-sized-filter-expected.png: 47 * platform/chromium/test_expectations.txt: 48 * platform/mac-snowleopard/svg/W3C-SVG-1.1/filters-color-01-b-expected.png: 49 * platform/mac-snowleopard/svg/W3C-SVG-1.1/filters-comptran-01-b-expected.png: 50 * platform/mac-snowleopard/svg/W3C-SVG-1.1/filters-morph-01-f-expected.png: 51 * platform/mac-snowleopard/svg/custom/absolute-sized-content-with-resources-expected.png: 52 * platform/mac-snowleopard/svg/custom/feComponentTransfer-Discrete-expected.png: 53 * platform/mac-snowleopard/svg/custom/feComponentTransfer-Gamma-expected.png: 54 * platform/mac-snowleopard/svg/custom/feComponentTransfer-Linear-expected.png: 55 * platform/mac-snowleopard/svg/custom/feComponentTransfer-Table-expected.png: 56 * platform/mac-snowleopard/svg/dynamic-updates/SVGFEColorMatrixElement-dom-in-attr-expected.png: 57 * platform/mac-snowleopard/svg/dynamic-updates/SVGFEColorMatrixElement-dom-type-attr-expected.png: 58 * platform/mac-snowleopard/svg/dynamic-updates/SVGFEColorMatrixElement-dom-values-attr-expected.png: 59 * platform/mac-snowleopard/svg/dynamic-updates/SVGFEColorMatrixElement-svgdom-in-prop-expected.png: 60 * platform/mac-snowleopard/svg/dynamic-updates/SVGFEColorMatrixElement-svgdom-type-prop-expected.png: 61 * platform/mac-snowleopard/svg/dynamic-updates/SVGFEColorMatrixElement-svgdom-values-prop-expected.png: 62 * platform/mac/svg/W3C-SVG-1.1/filters-color-01-b-expected.png: 63 * platform/mac/svg/W3C-SVG-1.1/filters-comptran-01-b-expected.png: 64 * platform/mac/svg/W3C-SVG-1.1/filters-example-01-b-expected.png: 65 * platform/mac/svg/W3C-SVG-1.1/filters-morph-01-f-expected.png: 66 * platform/mac/svg/W3C-SVG-1.1/masking-path-01-b-expected.png: 67 * platform/mac/svg/W3C-SVG-1.1/pservers-grad-08-b-expected.png: 68 * platform/mac/svg/as-background-image/svg-as-background-6-expected.png: 69 * platform/mac/svg/batik/filters/feTile-expected.png: 70 * platform/mac/svg/batik/masking/maskRegions-expected.png: 71 * platform/mac/svg/clip-path/clip-in-clip-expected.png: Added. 72 * platform/mac/svg/clip-path/clip-in-clip-expected.txt: Added. 73 * platform/mac/svg/clip-path/clipper-placement-issue-expected.png: Added. 74 * platform/mac/svg/clip-path/clipper-placement-issue-expected.txt: Added. 75 * platform/mac/svg/custom/absolute-sized-content-with-resources-expected.png: 76 * platform/mac/svg/custom/feComponentTransfer-Discrete-expected.png: 77 * platform/mac/svg/custom/feComponentTransfer-Gamma-expected.png: 78 * platform/mac/svg/custom/feComponentTransfer-Linear-expected.png: 79 * platform/mac/svg/custom/feComponentTransfer-Table-expected.png: 80 * platform/mac/svg/custom/grayscale-gradient-mask-2-expected.png: 81 * platform/mac/svg/custom/grayscale-gradient-mask-expected.png: 82 * platform/mac/svg/custom/js-late-gradient-and-object-creation-expected.png: 83 * platform/mac/svg/custom/js-late-gradient-creation-expected.png: 84 * platform/mac/svg/custom/text-rotated-gradient-expected.png: 85 * platform/mac/svg/dynamic-updates/SVGFEColorMatrixElement-dom-in-attr-expected.png: 86 * platform/mac/svg/dynamic-updates/SVGFEColorMatrixElement-dom-type-attr-expected.png: 87 * platform/mac/svg/dynamic-updates/SVGFEColorMatrixElement-dom-values-attr-expected.png: 88 * platform/mac/svg/dynamic-updates/SVGFEColorMatrixElement-svgdom-in-prop-expected.png: 89 * platform/mac/svg/dynamic-updates/SVGFEColorMatrixElement-svgdom-type-prop-expected.png: 90 * platform/mac/svg/dynamic-updates/SVGFEColorMatrixElement-svgdom-values-prop-expected.png: 91 * platform/mac/svg/dynamic-updates/SVGMaskElement-dom-height-attr-expected.png: 92 * platform/mac/svg/dynamic-updates/SVGMaskElement-dom-maskContentUnits-attr-expected.png: 93 * platform/mac/svg/dynamic-updates/SVGMaskElement-dom-width-attr-expected.png: 94 * platform/mac/svg/dynamic-updates/SVGMaskElement-dom-x-attr-expected.png: 95 * platform/mac/svg/dynamic-updates/SVGMaskElement-dom-y-attr-expected.png: 96 * platform/mac/svg/dynamic-updates/SVGMaskElement-svgdom-height-prop-expected.png: 97 * platform/mac/svg/dynamic-updates/SVGMaskElement-svgdom-maskContentUnits-prop-expected.png: 98 * platform/mac/svg/dynamic-updates/SVGMaskElement-svgdom-width-prop-expected.png: 99 * platform/mac/svg/dynamic-updates/SVGMaskElement-svgdom-x-prop-expected.png: 100 * platform/mac/svg/dynamic-updates/SVGMaskElement-svgdom-y-prop-expected.png: 101 * platform/mac/svg/filters/big-sized-filter-expected.png: 102 * platform/mac/svg/filters/feDropShadow-expected.png: 103 * platform/mac/svg/filters/filter-placement-issue-expected.png: Added. 104 * platform/mac/svg/filters/filter-placement-issue-expected.txt: Added. 105 * platform/mac/svg/filters/filterRes-expected.png: 106 * platform/mac/svg/filters/filterRes2-expected.png: 107 * platform/mac/svg/text/selection-background-color-expected.png: 108 * platform/mac/svg/transforms/text-with-mask-with-svg-transform-expected.png: 109 * platform/mac/svg/zoom/page/zoom-mask-with-percentages-expected.png: 110 * svg/clip-path/clip-in-clip.svg: Added. 111 * svg/clip-path/clipper-placement-issue.svg: Added. 112 * svg/filters/filter-placement-issue.svg: Added. 113 1 114 2012-01-27 Nikolas Zimmermann <nzimmermann@rim.com> 2 115 -
trunk/LayoutTests/platform/chromium/test_expectations.txt
r106107 r106108 40 40 BUGCR24182 SLOW SNOWLEOPARD DEBUG : fast/dom/Window/window-postmessage-clone-deep-array.html = PASS 41 41 BUGCR24182 SLOW SNOWLEOPARD DEBUG : fast/frames/calculate-percentage.html = PASS 42 BUGCR24182 SLOW DEBUG : svg/filters/big-sized-filter.svg = PASS42 // BUGCR24182 SLOW DEBUG : svg/filters/big-sized-filter.svg = PASS 43 43 // See BUGCR104797 44 44 … … 3696 3696 BUGWK73607 GPU LINUX DEBUG : fast/canvas/canvas-overloads-strokeText.html = TIMEOUT TEXT PASS 3697 3697 3698 // Tests needing rebaseline after bug 73643 patch 3699 BUGWK73643 WIN MAC : svg/W3C-SVG-1.1/filters-color-01-b.svg = IMAGE 3700 BUGWK73643 WIN MAC : svg/W3C-SVG-1.1/filters-comptran-01-b.svg = IMAGE 3701 //BUGWK73643 WIN MAC : svg/W3C-SVG-1.1/filters-example-01-b.svg = IMAGE 3702 BUGWK73643 WIN MAC : svg/W3C-SVG-1.1/filters-morph-01-f.svg = IMAGE 3703 BUGWK73643 WIN MAC : svg/W3C-SVG-1.1/masking-path-01-b.svg = IMAGE 3704 //BUGWK73643 WIN MAC : svg/batik/filters/feTile.svg = IMAGE 3705 BUGWK73643 MAC : svg/batik/filters/feTile.svg = IMAGE 3706 BUGWK73643 WIN MAC : svg/clip-path/clipper-placement-issue.svg = IMAGE 3707 //BUGWK73643 WIN MAC : svg/clip-path/deep-nested-clip-in-mask-different-unitTypes.svg = IMAGE 3708 BUGWK73643 WIN MAC : svg/custom/feComponentTransfer-Discrete.svg = IMAGE 3709 BUGWK73643 WIN MAC : svg/custom/feComponentTransfer-Gamma.svg = IMAGE 3710 BUGWK73643 WIN MAC : svg/custom/feComponentTransfer-Linear.svg = IMAGE 3711 BUGWK73643 WIN MAC : svg/custom/feComponentTransfer-Table.svg = IMAGE 3712 BUGWK73643 WIN MAC : svg/dynamic-updates/SVGFEColorMatrixElement-dom-in-attr.html = IMAGE 3713 BUGWK73643 WIN MAC : svg/dynamic-updates/SVGFEColorMatrixElement-dom-type-attr.html = IMAGE 3714 BUGWK73643 WIN MAC : svg/dynamic-updates/SVGFEColorMatrixElement-dom-values-attr.html = IMAGE 3715 BUGWK73643 WIN MAC : svg/dynamic-updates/SVGFEColorMatrixElement-svgdom-in-prop.html = IMAGE 3716 BUGWK73643 WIN MAC : svg/dynamic-updates/SVGMaskElement-dom-height-attr.html = IMAGE 3717 BUGWK73643 WIN MAC : svg/dynamic-updates/SVGMaskElement-dom-maskContentUnits-attr.html = IMAGE 3718 BUGWK73643 WIN MAC : svg/dynamic-updates/SVGMaskElement-dom-width-attr.html = IMAGE 3719 BUGWK73643 WIN MAC : svg/dynamic-updates/SVGMaskElement-dom-x-attr.html = IMAGE 3720 BUGWK73643 WIN MAC : svg/dynamic-updates/SVGMaskElement-dom-y-attr.html = IMAGE 3721 BUGWK73643 WIN MAC : svg/dynamic-updates/SVGMaskElement-svgdom-height-prop.html = IMAGE 3722 BUGWK73643 WIN MAC : svg/dynamic-updates/SVGMaskElement-svgdom-maskContentUnits-prop.html = IMAGE 3723 BUGWK73643 WIN MAC : svg/dynamic-updates/SVGMaskElement-svgdom-width-prop.html = IMAGE 3724 BUGWK73643 WIN MAC : svg/dynamic-updates/SVGMaskElement-svgdom-x-prop.html = IMAGE 3725 BUGWK73643 WIN MAC : svg/dynamic-updates/SVGMaskElement-svgdom-y-prop.html = IMAGE 3726 BUGWK73643 WIN MAC : svg/filters/feDropShadow.svg = IMAGE 3727 BUGWK73643 WIN MAC : svg/filters/filterRes.svg = IMAGE 3728 BUGWK73643 SLOW DEBUG WIN MAC : svg/filters/big-sized-filter.svg = IMAGE 3729 BUGWK73643 SLOW DEBUG LINUX : svg/filters/big-sized-filter.svg = PASS 3730 BUGWK73643 RELEASE WIN MAC : svg/filters/big-sized-filter.svg = IMAGE 3731 BUGWK73643 WIN MAC : svg/filters/filter-placement-issue.svg = IMAGE 3732 //BUGWK73643 WIN MAC : svg/filters/filterRes.svg = IMAGE 3733 BUGWK73643 WIN MAC : svg/filters/filterRes2.svg = IMAGE 3734 BUGWK73643 WIN MAC : svg/as-background-image/svg-as-background-2.html = IMAGE 3735 BUGWK73643 WIN MAC : svg/wicd/test-scalable-background-image1.xhtml = IMAGE 3736 3698 3737 BUGWK73681 : http/tests/appcache/video.html = TIMEOUT PASS 3699 3738 -
trunk/Source/WebCore/ChangeLog
r106101 r106108 1 2012-01-27 Branimir Lambov <blambov@google.com> 2 3 SVG filters incorrectly move elements 4 https://bugs.webkit.org/show_bug.cgi?id=73643 5 6 Reviewed by Nikolas Zimmermann. 7 8 Fixes SVG image buffer creation to use the enclosing integer rect 9 instead of unstable rounded coordinates with scaling which was causing 10 animated images to jump around under filters. The image buffer was not 11 aligned on a pixel boundary, and thus the positions and sizes of anything 12 drawn under that filter changed by 1-2 pixels compared to the same 13 elements drawn without an intermediate buffer, or drawn with a buffer 14 with a different target rectangle. 15 16 The change improves the positioning of clip paths, masks and filters. 17 18 Tests: svg/clip-path/clip-in-clip.svg 19 svg/clip-path/clipper-placement-issue.svg 20 svg/filters/filter-placement-issue.svg 21 22 * platform/graphics/filters/FETile.cpp: 23 (WebCore::FETile::platformApplySoftware): 24 * rendering/svg/RenderSVGResourceClipper.cpp: 25 (WebCore::RenderSVGResourceClipper::applyClippingToContext): 26 * rendering/svg/RenderSVGResourceFilter.cpp: 27 (WebCore::RenderSVGResourceFilter::applyResource): 28 * rendering/svg/RenderSVGResourceGradient.cpp: 29 (WebCore::createMaskAndSwapContextForTextGradient): 30 (WebCore::clipToTextMask): 31 * rendering/svg/RenderSVGResourceMasker.cpp: 32 (WebCore::RenderSVGResourceMasker::applyResource): 33 (WebCore::RenderSVGResourceMasker::drawContentIntoMaskImage): 34 * rendering/svg/RenderSVGResourcePattern.cpp: 35 (WebCore::RenderSVGResourcePattern::createTileImage): 36 * rendering/svg/SVGImageBufferTools.cpp: 37 (WebCore::SVGImageBufferTools::createImageBuffer): 38 (WebCore::SVGImageBufferTools::createImageBufferForPattern): 39 (WebCore::SVGImageBufferTools::clipToImageBuffer): 40 (WebCore::SVGImageBufferTools::clampedAbsoluteTargetRect): 41 (WebCore::SVGImageBufferTools::clampedAbsoluteSize): 42 * rendering/svg/SVGImageBufferTools.h: 43 (WebCore::SVGImageBufferTools::calcImageBufferRect): 44 1 45 2012-01-25 Yury Semikhatsky <yurys@chromium.org> 2 46 -
trunk/Source/WebCore/platform/graphics/filters/FETile.cpp
r102088 r106108 68 68 69 69 OwnPtr<ImageBuffer> tileImage; 70 if (!SVGImageBufferTools::createImageBuffer (tileRect, tileRect, tileImage, ColorSpaceDeviceRGB, filter()->renderingMode()))70 if (!SVGImageBufferTools::createImageBufferForPattern(tileRect, tileRect, tileImage, ColorSpaceDeviceRGB, filter()->renderingMode())) 71 71 return; 72 72 -
trunk/Source/WebCore/rendering/svg/RenderSVGResourceClipper.cpp
r105986 r106108 171 171 SVGImageBufferTools::calculateTransformationToOutermostSVGCoordinateSystem(object, absoluteTransform); 172 172 173 FloatRect absoluteTargetRect = absoluteTransform.mapRect(repaintRect); 174 FloatRect clampedAbsoluteTargetRect = SVGImageBufferTools::clampedAbsoluteTargetRect(absoluteTargetRect); 175 176 if (shouldCreateClipData && !clampedAbsoluteTargetRect.isEmpty()) { 177 if (!SVGImageBufferTools::createImageBuffer(absoluteTargetRect, clampedAbsoluteTargetRect, clipperData->clipMaskImage, ColorSpaceDeviceRGB, Unaccelerated)) 173 if (shouldCreateClipData && !repaintRect.isEmpty()) { 174 if (!SVGImageBufferTools::createImageBuffer(repaintRect, absoluteTransform, clipperData->clipMaskImage, ColorSpaceDeviceRGB, Unaccelerated)) 178 175 return false; 179 176 … … 181 178 ASSERT(maskContext); 182 179 183 // The save/restore pair is needed for clipToImageBuffer - it doesn't work without it on non-Cg platforms.184 GraphicsContextStateSaver stateSaver(*maskContext);185 maskContext->translate(-clampedAbsoluteTargetRect.x(), -clampedAbsoluteTargetRect.y());186 180 maskContext->concatCTM(animatedLocalTransform); 187 maskContext->concatCTM(absoluteTransform);188 181 189 182 // clipPath can also be clipped by another clipPath. 190 if (SVGResources* resources = SVGResourcesCache::cachedResourcesForRenderObject(this)) { 191 if (RenderSVGResourceClipper* clipper = resources->clipper()) { 192 if (!clipper->applyClippingToContext(this, objectBoundingBox, repaintRect, maskContext)) 193 return false; 194 } 195 } 196 197 if (!drawContentIntoMaskImage(clipperData, objectBoundingBox)) { 198 stateSaver.restore(); 183 SVGResources* resources = SVGResourcesCache::cachedResourcesForRenderObject(this); 184 RenderSVGResourceClipper* clipper; 185 bool succeeded; 186 if (resources && (clipper = resources->clipper())) { 187 GraphicsContextStateSaver stateSaver(*maskContext); 188 189 if (!clipper->applyClippingToContext(this, objectBoundingBox, repaintRect, maskContext)) 190 return false; 191 192 succeeded = drawContentIntoMaskImage(clipperData, objectBoundingBox); 193 // The context restore applies the clipping on non-CG platforms. 194 } else 195 succeeded = drawContentIntoMaskImage(clipperData, objectBoundingBox); 196 197 if (!succeeded) 199 198 clipperData->clipMaskImage.clear(); 200 }201 199 } 202 200 … … 204 202 return false; 205 203 206 SVGImageBufferTools::clipToImageBuffer(context, absoluteTransform, clampedAbsoluteTargetRect, clipperData->clipMaskImage);204 SVGImageBufferTools::clipToImageBuffer(context, absoluteTransform, repaintRect, clipperData->clipMaskImage); 207 205 return true; 208 206 } -
trunk/Source/WebCore/rendering/svg/RenderSVGResourceFilter.cpp
r102088 r106108 229 229 } 230 230 231 absoluteDrawingRegion.scale(scale.width(), scale.height()); 231 // Change the coordinate transformation applied to the filtered element to reflect the resolution of the filter. 232 AffineTransform effectiveTransform; 233 effectiveTransform.scale(scale.width(), scale.height()); 234 effectiveTransform.multiply(filterData->shearFreeAbsoluteTransform); 232 235 233 236 OwnPtr<ImageBuffer> sourceGraphic; 234 237 RenderingMode renderingMode = object->document()->page()->settings()->acceleratedFiltersEnabled() ? Accelerated : Unaccelerated; 235 if (!SVGImageBufferTools::createImageBuffer( absoluteDrawingRegion, absoluteDrawingRegion, sourceGraphic, ColorSpaceLinearRGB, renderingMode)) {238 if (!SVGImageBufferTools::createImageBuffer(drawingRegion, effectiveTransform, sourceGraphic, ColorSpaceLinearRGB, renderingMode)) { 236 239 ASSERT(!m_filter.contains(object)); 237 240 filterData->savedContext = context; … … 246 249 ASSERT(sourceGraphicContext); 247 250 248 sourceGraphicContext->translate(-absoluteDrawingRegion.x(), -absoluteDrawingRegion.y());249 if (scale.width() != 1 || scale.height() != 1)250 sourceGraphicContext->scale(scale);251 252 sourceGraphicContext->concatCTM(filterData->shearFreeAbsoluteTransform);253 sourceGraphicContext->clearRect(FloatRect(FloatPoint(), absoluteDrawingRegion.size()));254 251 filterData->sourceGraphicBuffer = sourceGraphic.release(); 255 252 filterData->savedContext = context; -
trunk/Source/WebCore/rendering/svg/RenderSVGResourceGradient.cpp
r103907 r106108 71 71 SVGImageBufferTools::calculateTransformationToOutermostSVGCoordinateSystem(textRootBlock, absoluteTransform); 72 72 73 FloatRect absoluteTargetRect = absoluteTransform.mapRect(textRootBlock->repaintRectInLocalCoordinates()); 74 FloatRect clampedAbsoluteTargetRect = SVGImageBufferTools::clampedAbsoluteTargetRect(absoluteTargetRect); 75 if (clampedAbsoluteTargetRect.isEmpty()) 76 return false; 77 73 FloatRect repaintRect = textRootBlock->repaintRectInLocalCoordinates(); 78 74 OwnPtr<ImageBuffer> maskImage; 79 if (!SVGImageBufferTools::createImageBuffer( absoluteTargetRect, clampedAbsoluteTargetRect, maskImage, ColorSpaceDeviceRGB, Unaccelerated))75 if (!SVGImageBufferTools::createImageBuffer(repaintRect, absoluteTransform, maskImage, ColorSpaceDeviceRGB, Unaccelerated)) 80 76 return false; 81 77 82 78 GraphicsContext* maskImageContext = maskImage->context(); 83 79 ASSERT(maskImageContext); 84 85 maskImageContext->translate(-clampedAbsoluteTargetRect.x(), -clampedAbsoluteTargetRect.y());86 maskImageContext->concatCTM(absoluteTransform);87 88 80 ASSERT(maskImage); 89 81 savedContext = context; … … 103 95 ASSERT(textRootBlock); 104 96 105 targetRect = textRootBlock->repaintRectInLocalCoordinates();106 107 97 AffineTransform absoluteTransform; 108 98 SVGImageBufferTools::calculateTransformationToOutermostSVGCoordinateSystem(textRootBlock, absoluteTransform); 109 99 110 FloatRect absoluteTargetRect = absoluteTransform.mapRect(targetRect); 111 FloatRect clampedAbsoluteTargetRect = SVGImageBufferTools::clampedAbsoluteTargetRect(absoluteTargetRect); 112 113 SVGImageBufferTools::clipToImageBuffer(context, absoluteTransform, clampedAbsoluteTargetRect, imageBuffer); 100 targetRect = textRootBlock->repaintRectInLocalCoordinates(); 101 SVGImageBufferTools::clipToImageBuffer(context, absoluteTransform, targetRect, imageBuffer); 114 102 115 103 AffineTransform matrix; -
trunk/Source/WebCore/rendering/svg/RenderSVGResourceMasker.cpp
r105978 r106108 95 95 SVGImageBufferTools::calculateTransformationToOutermostSVGCoordinateSystem(object, absoluteTransform); 96 96 97 FloatRect absoluteTargetRect = absoluteTransform.mapRect(object->repaintRectInLocalCoordinates()); 98 FloatRect clampedAbsoluteTargetRect = SVGImageBufferTools::clampedAbsoluteTargetRect(absoluteTargetRect); 99 100 if (!maskerData->maskImage && !clampedAbsoluteTargetRect.isEmpty()) { 97 FloatRect repaintRect = object->repaintRectInLocalCoordinates(); 98 99 if (!maskerData->maskImage && !repaintRect.isEmpty()) { 101 100 SVGMaskElement* maskElement = static_cast<SVGMaskElement*>(node()); 102 101 if (!maskElement) … … 107 106 ASSERT(svgStyle); 108 107 ColorSpace colorSpace = svgStyle->colorInterpolation() == CI_LINEARRGB ? ColorSpaceLinearRGB : ColorSpaceDeviceRGB; 109 if (!SVGImageBufferTools::createImageBuffer( absoluteTargetRect, clampedAbsoluteTargetRect, maskerData->maskImage, colorSpace, Unaccelerated))108 if (!SVGImageBufferTools::createImageBuffer(repaintRect, absoluteTransform, maskerData->maskImage, colorSpace, Unaccelerated)) 110 109 return false; 111 110 112 GraphicsContext* maskImageContext = maskerData->maskImage->context();113 ASSERT(maskImageContext);114 115 // The save/restore pair is needed for clipToImageBuffer - it doesn't work without it on non-Cg platforms.116 maskImageContext->save();117 maskImageContext->translate(-clampedAbsoluteTargetRect.x(), -clampedAbsoluteTargetRect.y());118 maskImageContext->concatCTM(absoluteTransform);119 120 111 if (!drawContentIntoMaskImage(maskerData, colorSpace, maskElement, object)) { 121 maskImageContext->restore();122 112 maskerData->maskImage.clear(); 123 113 } … … 127 117 return false; 128 118 129 SVGImageBufferTools::clipToImageBuffer(context, absoluteTransform, clampedAbsoluteTargetRect, maskerData->maskImage);119 SVGImageBufferTools::clipToImageBuffer(context, absoluteTransform, repaintRect, maskerData->maskImage); 130 120 return true; 131 121 } … … 158 148 } 159 149 160 maskImageContext->restore();161 162 150 #if !USE(CG) 163 151 maskerData->maskImage->transformColorSpace(ColorSpaceDeviceRGB, colorSpace); -
trunk/Source/WebCore/rendering/svg/RenderSVGResourcePattern.cpp
r105978 r106108 237 237 OwnPtr<ImageBuffer> tileImage; 238 238 239 if (!SVGImageBufferTools::createImageBuffer (absoluteTileBoundaries, clampedAbsoluteTileBoundaries, tileImage, ColorSpaceDeviceRGB, Unaccelerated))239 if (!SVGImageBufferTools::createImageBufferForPattern(absoluteTileBoundaries, clampedAbsoluteTileBoundaries, tileImage, ColorSpaceDeviceRGB, Unaccelerated)) 240 240 return nullptr; 241 241 -
trunk/Source/WebCore/rendering/svg/SVGImageBufferTools.cpp
r105978 r106108 29 29 #include "RenderSVGRoot.h" 30 30 31 static float kMaxImageBufferSize = 4096;31 static int kMaxImageBufferSize = 4096; 32 32 33 33 namespace WebCore { … … 53 53 } 54 54 55 bool SVGImageBufferTools::createImageBuffer(const FloatRect& absoluteTargetRect, const FloatRect& clampedAbsoluteTargetRect, OwnPtr<ImageBuffer>& imageBuffer, ColorSpace colorSpace, RenderingMode renderingMode)55 bool SVGImageBufferTools::createImageBuffer(const FloatRect& targetRect, const AffineTransform& absoluteTransform, OwnPtr<ImageBuffer>& imageBuffer, ColorSpace colorSpace, RenderingMode renderingMode) 56 56 { 57 IntSize imageSize(roundedImageBufferSize(clampedAbsoluteTargetRect.size())); 58 IntSize unclampedImageSize(SVGImageBufferTools::roundedImageBufferSize(absoluteTargetRect.size())); 57 IntRect paintRect = calculateImageBufferRect(targetRect, absoluteTransform); 58 // Don't create empty ImageBuffers. 59 if (paintRect.isEmpty()) 60 return false; 61 62 IntSize clampedSize = clampedAbsoluteSize(paintRect.size()); 63 OwnPtr<ImageBuffer> image = ImageBuffer::create(clampedSize, colorSpace, renderingMode); 64 if (!image) 65 return false; 66 67 GraphicsContext* imageContext = image->context(); 68 ASSERT(imageContext); 69 70 // This is done in absolute coordinates. 71 imageContext->translate(-paintRect.x(), -paintRect.y()); 72 73 imageContext->concatCTM(absoluteTransform); 74 75 // This happens in local coordinates. 76 imageContext->scale(FloatSize(static_cast<float>(clampedSize.width()) / paintRect.width(), 77 static_cast<float>(clampedSize.height()) / paintRect.height())); 78 79 imageBuffer = image.release(); 80 return true; 81 } 82 83 bool SVGImageBufferTools::createImageBufferForPattern(const FloatRect& absoluteTargetRect, const FloatRect& clampedAbsoluteTargetRect, OwnPtr<ImageBuffer>& imageBuffer, ColorSpace colorSpace, RenderingMode renderingMode) 84 { 85 IntSize imageSize(roundedIntSize(clampedAbsoluteTargetRect.size())); 86 IntSize unclampedImageSize(roundedIntSize(absoluteTargetRect.size())); 59 87 60 88 // Don't create empty ImageBuffers. … … 94 122 } 95 123 96 void SVGImageBufferTools::clipToImageBuffer(GraphicsContext* context, const AffineTransform& absoluteTransform, const FloatRect& clampedAbsoluteTargetRect, OwnPtr<ImageBuffer>& imageBuffer)124 void SVGImageBufferTools::clipToImageBuffer(GraphicsContext* context, const AffineTransform& absoluteTransform, const FloatRect& targetRect, OwnPtr<ImageBuffer>& imageBuffer) 97 125 { 98 126 ASSERT(context); 99 127 ASSERT(imageBuffer); 100 128 129 FloatRect absoluteTargetRect = calculateImageBufferRect(targetRect, absoluteTransform); 130 101 131 // The mask image has been created in the absolute coordinate space, as the image should not be scaled. 102 132 // So the actual masking process has to be done in the absolute coordinate space as well. 103 133 context->concatCTM(absoluteTransform.inverse()); 104 context->clipToImageBuffer(imageBuffer.get(), clampedAbsoluteTargetRect);134 context->clipToImageBuffer(imageBuffer.get(), absoluteTargetRect); 105 135 context->concatCTM(absoluteTransform); 106 136 … … 111 141 } 112 142 113 IntSize SVGImageBufferTools::roundedImageBufferSize(const FloatSize& size)143 FloatRect SVGImageBufferTools::clampedAbsoluteTargetRect(const FloatRect& absoluteTargetRect) 114 144 { 115 return IntSize(static_cast<int>(lroundf(size.width())), static_cast<int>(lroundf(size.height()))); 145 const FloatSize maxImageBufferSize(kMaxImageBufferSize, kMaxImageBufferSize); 146 return FloatRect(absoluteTargetRect.location(), absoluteTargetRect.size().shrunkTo(maxImageBufferSize)); 116 147 } 117 148 118 FloatRect SVGImageBufferTools::clampedAbsoluteTargetRect(const FloatRect& absoluteTargetRect)149 IntSize SVGImageBufferTools::clampedAbsoluteSize(const IntSize& absoluteSize) 119 150 { 120 FloatRect clampedAbsoluteTargetRect = absoluteTargetRect; 121 122 if (clampedAbsoluteTargetRect.width() > kMaxImageBufferSize) 123 clampedAbsoluteTargetRect.setWidth(kMaxImageBufferSize); 124 125 if (clampedAbsoluteTargetRect.height() > kMaxImageBufferSize) 126 clampedAbsoluteTargetRect.setHeight(kMaxImageBufferSize); 127 128 return clampedAbsoluteTargetRect; 151 const IntSize maxImageBufferSize(kMaxImageBufferSize, kMaxImageBufferSize); 152 return absoluteSize.shrunkTo(maxImageBufferSize); 129 153 } 130 154 -
trunk/Source/WebCore/rendering/svg/SVGImageBufferTools.h
r102088 r106108 35 35 class SVGImageBufferTools { 36 36 WTF_MAKE_NONCOPYABLE(SVGImageBufferTools); 37 37 38 public: 38 static bool createImageBuffer(const FloatRect& absoluteTargetRect, const FloatRect& clampedAbsoluteTargetRect, OwnPtr<ImageBuffer>&, ColorSpace, RenderingMode); 39 static bool createImageBuffer(const FloatRect& paintRect, const AffineTransform& absoluteTransform, OwnPtr<ImageBuffer>&, ColorSpace, RenderingMode); 40 // Patterns need a different float-to-integer coordinate mapping. 41 static bool createImageBufferForPattern(const FloatRect& absoluteTargetRect, const FloatRect& clampedAbsoluteTargetRect, OwnPtr<ImageBuffer>&, ColorSpace, RenderingMode); 42 39 43 static void renderSubtreeToImageBuffer(ImageBuffer*, RenderObject*, const AffineTransform&); 40 static void clipToImageBuffer(GraphicsContext*, const AffineTransform& absoluteTransform, const FloatRect& clampedAbsoluteTargetRect, OwnPtr<ImageBuffer>&);44 static void clipToImageBuffer(GraphicsContext*, const AffineTransform& absoluteTransform, const FloatRect& targetRect, OwnPtr<ImageBuffer>&); 41 45 42 46 static void calculateTransformationToOutermostSVGCoordinateSystem(const RenderObject*, AffineTransform& absoluteTransform); 47 static IntSize clampedAbsoluteSize(const IntSize&); 43 48 static FloatRect clampedAbsoluteTargetRect(const FloatRect& absoluteTargetRect); 44 static IntSize roundedImageBufferSize(const FloatSize&);45 49 static void clear2DRotation(AffineTransform&); 50 51 static IntRect calculateImageBufferRect(const FloatRect& targetRect, const AffineTransform& absoluteTransform) 52 { 53 return enclosingIntRect(absoluteTransform.mapRect(targetRect)); 54 } 46 55 47 56 private:
Note: See TracChangeset
for help on using the changeset viewer.