REGRESSION(65665): Pattern size being clamped to SVG size can prevent transformed...
authortimothy_horton@apple.com <timothy_horton@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 27 Sep 2011 21:06:17 +0000 (21:06 +0000)
committertimothy_horton@apple.com <timothy_horton@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 27 Sep 2011 21:06:17 +0000 (21:06 +0000)
commit30c87058d43bb213fbe66fb76856e947087ce13e
treef927fbe11d9c60cfe14ce719660ed18a1e3924bb
parent71844dfc54c94ae59ef206c4a546f8641e61eb36
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.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@96155 268f45cc-cd09-0410-ab3c-d52691b4dbfc
20 files changed:
LayoutTests/ChangeLog
LayoutTests/platform/mac/svg/custom/js-late-gradient-and-object-creation-expected.png
LayoutTests/platform/mac/svg/custom/pattern-excessive-malloc-expected.txt
LayoutTests/platform/qt/svg/custom/pattern-excessive-malloc-expected.txt
LayoutTests/svg/custom/oversized-pattern-scale-expected.png [new file with mode: 0644]
LayoutTests/svg/custom/oversized-pattern-scale-expected.txt [new file with mode: 0644]
LayoutTests/svg/custom/oversized-pattern-scale.svg [new file with mode: 0644]
LayoutTests/svg/custom/pattern-excessive-malloc-expected.txt
LayoutTests/svg/custom/pattern-excessive-malloc.svg
LayoutTests/svg/custom/transformed-pattern-clamp-svg-root-expected.png [new file with mode: 0644]
LayoutTests/svg/custom/transformed-pattern-clamp-svg-root-expected.txt [new file with mode: 0644]
LayoutTests/svg/custom/transformed-pattern-clamp-svg-root.svg [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/rendering/svg/RenderSVGResourceClipper.cpp
Source/WebCore/rendering/svg/RenderSVGResourceGradient.cpp
Source/WebCore/rendering/svg/RenderSVGResourceMasker.cpp
Source/WebCore/rendering/svg/RenderSVGResourcePattern.cpp
Source/WebCore/rendering/svg/RenderSVGResourcePattern.h
Source/WebCore/rendering/svg/SVGImageBufferTools.cpp
Source/WebCore/rendering/svg/SVGImageBufferTools.h