haikuwebkit/LayoutTests/svg/repaint/buffered-rendering-static-i...

35 lines
2.7 KiB
HTML
Raw Permalink Normal View History

[SVG2] Add support for the buffered-rendering hint https://bugs.webkit.org/show_bug.cgi?id=104207 Reviewed by Stephen Chenney. Source/WebCore: This patch adds the SVG2 buffered-rendering property and implements it for the image element. For reference, the spec can be found at: https://svgwg.org/svg2-draft/single-page.html#painting-BufferedRendering The buffered-rendering hint causes our implementation to create a temporary image buffer for caching an element's foreground rendering. This behavior has been designed to support other graphical and container elements in followup patches (such as the use and g elements). This patch should not affect rendering, and a test has been added showing the image results are unchanged. The performance aspects of this patch can be tested using the following test: http://philbit.com/bouncingTigers.html Without the patch, rendering is below 1fps. With the patch, rendering is fluid. Tests: svg/css/buffered-rendering.html svg/repaint/buffered-rendering-dynamic-image.html svg/repaint/buffered-rendering-static-image.html Other than the changes to RenderSVGImage and SVGRenderingContext, the changes below are to support the new buffered-rendering property: * css/CSSComputedStyleDeclaration.cpp: (WebCore::CSSComputedStyleDeclaration::getPropertyCSSValue): * css/CSSPrimitiveValueMappings.h: (WebCore::CSSPrimitiveValue::CSSPrimitiveValue): (WebCore): (WebCore::CSSPrimitiveValue::operator EBufferedRendering): * css/CSSProperty.cpp: (WebCore::CSSProperty::isInheritedProperty): * css/SVGCSSComputedStyleDeclaration.cpp: (WebCore::CSSComputedStyleDeclaration::getSVGPropertyCSSValue): * css/SVGCSSParser.cpp: (WebCore::CSSParser::parseSVGValue): * css/SVGCSSPropertyNames.in: * css/SVGCSSStyleSelector.cpp: (WebCore::StyleResolver::applySVGProperty): * css/SVGCSSValueKeywords.in: * rendering/style/SVGRenderStyle.cpp: (WebCore::SVGRenderStyle::diff): * rendering/style/SVGRenderStyle.h: (WebCore::SVGRenderStyle::initialBufferedRendering): (WebCore::SVGRenderStyle::setBufferedRendering): (WebCore::SVGRenderStyle::bufferedRendering): (WebCore::SVGRenderStyle::setBitDefaults): * rendering/style/SVGRenderStyleDefs.h: * rendering/svg/RenderSVGImage.cpp: (WebCore::RenderSVGImage::paint): The foreground painting has been extracted out into a separate function. This has also been changed so that if the buffered-rendering hint is present, bufferForeground is used. (WebCore::RenderSVGImage::paintForeground): (WebCore): (WebCore::RenderSVGImage::invalidateBufferedForeground): This function could be replaced with "m_bufferedForeground.clear()" but other renderers (such as container elements) will require more complex invalidation logic. To maintain consistency with this future code, invalidateBufferedForeground has been used. (WebCore::RenderSVGImage::imageChanged): * rendering/svg/RenderSVGImage.h: (RenderSVGImage): * rendering/svg/SVGRenderingContext.cpp: (WebCore::SVGRenderingContext::bufferForeground): (WebCore): * rendering/svg/SVGRenderingContext.h: (SVGRenderingContext): * svg/SVGStyledElement.cpp: (WebCore::SVGStyledElement::cssPropertyIdForSVGAttributeName): (WebCore::cssPropertyToTypeMap): * svg/svgattrs.in: LayoutTests: * svg/css/buffered-rendering-expected.txt: Added. * svg/css/buffered-rendering.html: Added. * svg/repaint/buffered-rendering-dynamic-image-expected.html: Added. * svg/repaint/buffered-rendering-dynamic-image.html: Added. * svg/repaint/buffered-rendering-static-image-expected.html: Added. * svg/repaint/buffered-rendering-static-image.html: Added. Canonical link: https://commits.webkit.org/132035@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@147348 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2013-04-01 18:55:24 +00:00
<!DOCTYPE html>
<html>
<head>
<script src="../../fast/repaint/resources/repaint.js"></script>
<script>
function repaintTest() {
document.getElementById('behindStatic').setAttribute('fill', 'green');
document.getElementById('translateStatic').setAttribute('x', '0');
document.getElementById('transformStatic').setAttribute('transform', 'translate(0 0)');
document.getElementById('scaleStatic').setAttribute('transform', 'scale(1)');
}
</script>
</head>
<body onload="runRepaintTest()">
Test for WK104207: This test passes if there are 4 green squares each with a smooth black circle in the top-left corner.<br/>
<svg xmlns="http://www.w3.org/2000/svg" width="400" height="450">
<!-- Test invalidating content behind the static content. -->
<rect id="behindStatic" x="40" y="10" width="20" height="80" fill="red"/>
<image x="0" y="0" width="100" height="100" buffered-rendering="static" xlink:href="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' width='100' height='100'><rect x='10' y='10' width='30' height='80' fill='green'/><rect x='60' y='10' width='30' height='80' fill='green'/><circle cx='25' cy='25' r='10' fill='green' stroke='black' stroke-width='1'/></svg>"/>
<!-- Test translating static content -->
<rect x="20" y="140" width="30" height="30" fill="red"/>
<image id="translateStatic" x="50" y="120" width="100" height="100" buffered-rendering="static" xlink:href="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' width='100' height='100'><rect x='10%' y='10%' width='80%' height='80%' fill='green'/><circle cx='25' cy='25' r='10' fill='green' stroke='black' stroke-width='1'/></svg>"/>
<!-- Test transforming static content -->
<rect x="20" y="260" width="30" height="30" fill="red"/>
<image id="transformStatic" transform="skewX(30)" x="0" y="240" width="100" height="100" buffered-rendering="static" xlink:href="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' width='100' height='100'><rect x='10%' y='10%' width='80%' height='80%' fill='green'/><circle cx='25' cy='25' r='10' fill='green' stroke='black' stroke-width='1'/></svg>"/>
<!-- Test scaling static content -->
<rect x="20" y="380" width="30" height="30" fill="red"/>
<image id="scaleStatic" transform="scale(0.1)" x="0" y="360" width="100" height="100" buffered-rendering="static" xlink:href="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' width='100' height='100'><rect x='10%' y='10%' width='80%' height='80%' fill='green'/><circle cx='25' cy='25' r='10' fill='green' stroke='black' stroke-width='1'/></svg>"/>
</svg>
</body>
</html>