haikuwebkit/LayoutTests/svg/as-background-image/svg-transformed-background....

38 lines
965 B
HTML
Raw Permalink Normal View History

Account for transform in SVG background images https://bugs.webkit.org/show_bug.cgi?id=110295 Reviewed by Dirk Schulze. Source/WebCore: Tiled SVG background images are rendererd by drawing the SVG content into a temporary image buffer, then stamping out a tiled pattern using this buffer. Previously the image buffer did not account for CSS transforms which could result in pixelated backgrounds. This patch takes advantage of the context's transform when sizing the temporary tiling image buffer. Because the context's transform also includes scale, this patch simplifies the SVG image code to no longer track scale. Test: svg/as-background-image/svg-transformed-background.html * loader/cache/CachedImage.cpp: (WebCore): (WebCore::CachedImage::imageForRenderer): CachedImage::lookupOrCreateImageForRenderer no longer creates images so it has been refactored into just "imageForRenderer". Previously there were two versions of lookupOrCreateImageForRenderer; these have been folded into imageForRenderer. * loader/cache/CachedImage.h: * svg/graphics/SVGImage.cpp: (WebCore::SVGImage::drawPatternForContainer): To create the temporary tiling image buffer, the final size in screen coordinates is needed. This is now computed using the current context's CTM. Because the CTM already includes the page scale, all page scale tracking can be removed. The adjustments to srcRect and the pattern transform are the same as before, just refactored to use imageBufferScale which has x and y components. * svg/graphics/SVGImage.h: * svg/graphics/SVGImageCache.cpp: (WebCore::SVGImageCache::setContainerSizeForRenderer): Because the page scale needed to be cached between calls to setContainerSizeForRenderer, this function was written to modify an existing cache entry. Because the page scale no longer needs to be tracked, this code has been simplified to re-write any existing cache entry. (WebCore::SVGImageCache::imageSizeForRenderer): This function has been simplified by calling SVGImageForContainer::size() instead of computing this value manually. The value returned remains the same, containing the container size multiplied by zoom. (WebCore::SVGImageCache::imageForRenderer): Previously we set the page scale on every call to imageForRenderer. Because page scale no longer needs to be tracked, this function has been simplified to simply return the cached SVGImageForContainer. * svg/graphics/SVGImageForContainer.cpp: (WebCore::SVGImageForContainer::drawPattern): * svg/graphics/SVGImageForContainer.h: (WebCore::SVGImageForContainer::create): (WebCore::SVGImageForContainer::SVGImageForContainer): (SVGImageForContainer): LayoutTests: * svg/as-background-image/svg-transformed-background-expected.html: Added. * svg/as-background-image/svg-transformed-background.html: Added. Canonical link: https://commits.webkit.org/128693@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@143541 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2013-02-21 01:19:25 +00:00
<!DOCTYPE html>
<html>
<head>
<style>
#circle {
position: absolute;
left: 10px;
top: 40px;
width: 40px;
height: 20px;
background-image:url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' width='20' height='20'><circle cx='10' cy='10' r='10' fill='green' /></svg>");
transform:scale(5);
transform-origin:0 0;
-webkit-transform:scale(5);
-webkit-transform-origin:0 0;
}
#ellipse {
position: absolute;
left: 210px;
top: 40px;
width: 80px;
height: 10px;
background-image:url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' width='40' height='10'><ellipse cx='20' cy='5' rx='20' ry='5' fill='green' /></svg>");
transform:scale(2.5, 10);
transform-origin:0 0;
-webkit-transform:scale(2.5, 10);
-webkit-transform-origin:0 0;
}
</style>
</head>
<body>
Test for WK110295: This test passes if there are four green circles with sharp edges.<br/>
<div id="circle"></div>
<div id="ellipse"></div>
</body>
</html>