haikuwebkit/LayoutTests/svg/custom/transformed-pattern-clamp-s...

16 lines
718 B
XML
Raw Permalink Normal View History

REGRESSION(65665): Pattern size being clamped to SVG size can prevent transformed elements from being fully covered by userSpaceOnUse patterns https://bugs.webkit.org/show_bug.cgi?id=67700 <rdar://problem/10125102> Reviewed by Darin Adler. Clamp all resources to the same size, 4096x4096 (arbitrarily chosen), instead of to the size of the <svg> element. This fixes the case where a transformed element displays part of a resource outside of the size of the <svg> element. When drawing an oversized pattern into its tile image, scale the content down to fit. When drawing the tile image to the screen, scale it back up to fit the expected area. This will cause pixelation when patterns are over the 4k limit. Tests: svg/custom/transformed-pattern-clamp-svg-root.svg, svg/custom/oversized-pattern-scale.svg * rendering/svg/RenderSVGResourceClipper.cpp: (WebCore::RenderSVGResourceClipper::applyClippingToContext): * rendering/svg/RenderSVGResourceGradient.cpp: (WebCore::createMaskAndSwapContextForTextGradient): (WebCore::clipToTextMask): * rendering/svg/RenderSVGResourceMasker.cpp: (WebCore::RenderSVGResourceMasker::applyResource): * rendering/svg/RenderSVGResourcePattern.cpp: (WebCore::RenderSVGResourcePattern::applyResource): (WebCore::RenderSVGResourcePattern::createTileImage): * rendering/svg/RenderSVGResourcePattern.h: * rendering/svg/SVGImageBufferTools.cpp: (WebCore::SVGImageBufferTools::clampedAbsoluteTargetRect): * rendering/svg/SVGImageBufferTools.h: pattern-excessive-malloc is so excessive that it runs into the floating point precision barrier when determining the scale to draw the pattern at; drop the size two orders of magnitude, which is still very excessive but easier to draw with. Add a test (transformed-pattern-clamp-svg-root.svg) that ensures that patterns on transformed elements are displayed correctly, instead of being clamped to the size of the <svg> element. Add a test (oversized-pattern-scale.svg) that ensures that oversized patterns are correctly drawn into the pattern tile scaled down and then are scaled back up when drawn to the screen. * platform/mac/svg/custom/js-late-gradient-and-object-creation-expected.png: * platform/mac/svg/custom/pattern-excessive-malloc-expected.txt: * platform/qt/svg/custom/pattern-excessive-malloc-expected.txt: * svg/custom/pattern-excessive-malloc-expected.txt: * svg/custom/pattern-excessive-malloc.svg: * svg/custom/oversized-pattern-scale-expected.png: Added. * svg/custom/oversized-pattern-scale-expected.txt: Added. * svg/custom/oversized-pattern-scale.svg: Added. * svg/custom/transformed-pattern-clamp-svg-root.svg: Added. * svg/custom/transformed-pattern-clamp-svg-root-expected.png: Added. * svg/custom/transformed-pattern-clamp-svg-root-expected.txt: Added. Canonical link: https://commits.webkit.org/84924@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@96155 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2011-09-27 21:06:17 +00:00
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" height="200" width="200">
<title>The rectangle should be split; white on the top, green on the bottom.</title>
REGRESSION(65665): Pattern size being clamped to SVG size can prevent transformed elements from being fully covered by userSpaceOnUse patterns https://bugs.webkit.org/show_bug.cgi?id=67700 <rdar://problem/10125102> Reviewed by Darin Adler. Clamp all resources to the same size, 4096x4096 (arbitrarily chosen), instead of to the size of the <svg> element. This fixes the case where a transformed element displays part of a resource outside of the size of the <svg> element. When drawing an oversized pattern into its tile image, scale the content down to fit. When drawing the tile image to the screen, scale it back up to fit the expected area. This will cause pixelation when patterns are over the 4k limit. Tests: svg/custom/transformed-pattern-clamp-svg-root.svg, svg/custom/oversized-pattern-scale.svg * rendering/svg/RenderSVGResourceClipper.cpp: (WebCore::RenderSVGResourceClipper::applyClippingToContext): * rendering/svg/RenderSVGResourceGradient.cpp: (WebCore::createMaskAndSwapContextForTextGradient): (WebCore::clipToTextMask): * rendering/svg/RenderSVGResourceMasker.cpp: (WebCore::RenderSVGResourceMasker::applyResource): * rendering/svg/RenderSVGResourcePattern.cpp: (WebCore::RenderSVGResourcePattern::applyResource): (WebCore::RenderSVGResourcePattern::createTileImage): * rendering/svg/RenderSVGResourcePattern.h: * rendering/svg/SVGImageBufferTools.cpp: (WebCore::SVGImageBufferTools::clampedAbsoluteTargetRect): * rendering/svg/SVGImageBufferTools.h: pattern-excessive-malloc is so excessive that it runs into the floating point precision barrier when determining the scale to draw the pattern at; drop the size two orders of magnitude, which is still very excessive but easier to draw with. Add a test (transformed-pattern-clamp-svg-root.svg) that ensures that patterns on transformed elements are displayed correctly, instead of being clamped to the size of the <svg> element. Add a test (oversized-pattern-scale.svg) that ensures that oversized patterns are correctly drawn into the pattern tile scaled down and then are scaled back up when drawn to the screen. * platform/mac/svg/custom/js-late-gradient-and-object-creation-expected.png: * platform/mac/svg/custom/pattern-excessive-malloc-expected.txt: * platform/qt/svg/custom/pattern-excessive-malloc-expected.txt: * svg/custom/pattern-excessive-malloc-expected.txt: * svg/custom/pattern-excessive-malloc.svg: * svg/custom/oversized-pattern-scale-expected.png: Added. * svg/custom/oversized-pattern-scale-expected.txt: Added. * svg/custom/oversized-pattern-scale.svg: Added. * svg/custom/transformed-pattern-clamp-svg-root.svg: Added. * svg/custom/transformed-pattern-clamp-svg-root-expected.png: Added. * svg/custom/transformed-pattern-clamp-svg-root-expected.txt: Added. Canonical link: https://commits.webkit.org/84924@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@96155 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2011-09-27 21:06:17 +00:00
<defs>
<linearGradient id="gradient" x2="0%" y2="100%">
<stop offset="0" stop-color="white"/>
<stop offset="0.5" stop-color="white"/>
<stop offset="0.5" stop-color="green"/>
<stop offset="1" stop-color="green"/>
REGRESSION(65665): Pattern size being clamped to SVG size can prevent transformed elements from being fully covered by userSpaceOnUse patterns https://bugs.webkit.org/show_bug.cgi?id=67700 <rdar://problem/10125102> Reviewed by Darin Adler. Clamp all resources to the same size, 4096x4096 (arbitrarily chosen), instead of to the size of the <svg> element. This fixes the case where a transformed element displays part of a resource outside of the size of the <svg> element. When drawing an oversized pattern into its tile image, scale the content down to fit. When drawing the tile image to the screen, scale it back up to fit the expected area. This will cause pixelation when patterns are over the 4k limit. Tests: svg/custom/transformed-pattern-clamp-svg-root.svg, svg/custom/oversized-pattern-scale.svg * rendering/svg/RenderSVGResourceClipper.cpp: (WebCore::RenderSVGResourceClipper::applyClippingToContext): * rendering/svg/RenderSVGResourceGradient.cpp: (WebCore::createMaskAndSwapContextForTextGradient): (WebCore::clipToTextMask): * rendering/svg/RenderSVGResourceMasker.cpp: (WebCore::RenderSVGResourceMasker::applyResource): * rendering/svg/RenderSVGResourcePattern.cpp: (WebCore::RenderSVGResourcePattern::applyResource): (WebCore::RenderSVGResourcePattern::createTileImage): * rendering/svg/RenderSVGResourcePattern.h: * rendering/svg/SVGImageBufferTools.cpp: (WebCore::SVGImageBufferTools::clampedAbsoluteTargetRect): * rendering/svg/SVGImageBufferTools.h: pattern-excessive-malloc is so excessive that it runs into the floating point precision barrier when determining the scale to draw the pattern at; drop the size two orders of magnitude, which is still very excessive but easier to draw with. Add a test (transformed-pattern-clamp-svg-root.svg) that ensures that patterns on transformed elements are displayed correctly, instead of being clamped to the size of the <svg> element. Add a test (oversized-pattern-scale.svg) that ensures that oversized patterns are correctly drawn into the pattern tile scaled down and then are scaled back up when drawn to the screen. * platform/mac/svg/custom/js-late-gradient-and-object-creation-expected.png: * platform/mac/svg/custom/pattern-excessive-malloc-expected.txt: * platform/qt/svg/custom/pattern-excessive-malloc-expected.txt: * svg/custom/pattern-excessive-malloc-expected.txt: * svg/custom/pattern-excessive-malloc.svg: * svg/custom/oversized-pattern-scale-expected.png: Added. * svg/custom/oversized-pattern-scale-expected.txt: Added. * svg/custom/oversized-pattern-scale.svg: Added. * svg/custom/transformed-pattern-clamp-svg-root.svg: Added. * svg/custom/transformed-pattern-clamp-svg-root-expected.png: Added. * svg/custom/transformed-pattern-clamp-svg-root-expected.txt: Added. Canonical link: https://commits.webkit.org/84924@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@96155 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2011-09-27 21:06:17 +00:00
</linearGradient>
<pattern id="shot" patternUnits="userSpaceOnUse" width="400" height="400">
<rect height="400" width="400" fill="url(#gradient)"/>
</pattern>
</defs>
<rect transform="translate(0,-100)" x="0" y="100" width="200" height="200" fill="url(#shot)" stroke="black"/>
REGRESSION(65665): Pattern size being clamped to SVG size can prevent transformed elements from being fully covered by userSpaceOnUse patterns https://bugs.webkit.org/show_bug.cgi?id=67700 <rdar://problem/10125102> Reviewed by Darin Adler. Clamp all resources to the same size, 4096x4096 (arbitrarily chosen), instead of to the size of the <svg> element. This fixes the case where a transformed element displays part of a resource outside of the size of the <svg> element. When drawing an oversized pattern into its tile image, scale the content down to fit. When drawing the tile image to the screen, scale it back up to fit the expected area. This will cause pixelation when patterns are over the 4k limit. Tests: svg/custom/transformed-pattern-clamp-svg-root.svg, svg/custom/oversized-pattern-scale.svg * rendering/svg/RenderSVGResourceClipper.cpp: (WebCore::RenderSVGResourceClipper::applyClippingToContext): * rendering/svg/RenderSVGResourceGradient.cpp: (WebCore::createMaskAndSwapContextForTextGradient): (WebCore::clipToTextMask): * rendering/svg/RenderSVGResourceMasker.cpp: (WebCore::RenderSVGResourceMasker::applyResource): * rendering/svg/RenderSVGResourcePattern.cpp: (WebCore::RenderSVGResourcePattern::applyResource): (WebCore::RenderSVGResourcePattern::createTileImage): * rendering/svg/RenderSVGResourcePattern.h: * rendering/svg/SVGImageBufferTools.cpp: (WebCore::SVGImageBufferTools::clampedAbsoluteTargetRect): * rendering/svg/SVGImageBufferTools.h: pattern-excessive-malloc is so excessive that it runs into the floating point precision barrier when determining the scale to draw the pattern at; drop the size two orders of magnitude, which is still very excessive but easier to draw with. Add a test (transformed-pattern-clamp-svg-root.svg) that ensures that patterns on transformed elements are displayed correctly, instead of being clamped to the size of the <svg> element. Add a test (oversized-pattern-scale.svg) that ensures that oversized patterns are correctly drawn into the pattern tile scaled down and then are scaled back up when drawn to the screen. * platform/mac/svg/custom/js-late-gradient-and-object-creation-expected.png: * platform/mac/svg/custom/pattern-excessive-malloc-expected.txt: * platform/qt/svg/custom/pattern-excessive-malloc-expected.txt: * svg/custom/pattern-excessive-malloc-expected.txt: * svg/custom/pattern-excessive-malloc.svg: * svg/custom/oversized-pattern-scale-expected.png: Added. * svg/custom/oversized-pattern-scale-expected.txt: Added. * svg/custom/oversized-pattern-scale.svg: Added. * svg/custom/transformed-pattern-clamp-svg-root.svg: Added. * svg/custom/transformed-pattern-clamp-svg-root-expected.png: Added. * svg/custom/transformed-pattern-clamp-svg-root-expected.txt: Added. Canonical link: https://commits.webkit.org/84924@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@96155 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2011-09-27 21:06:17 +00:00
</svg>