[SVG2] Add support for the buffered-rendering hint
authorpdr@google.com <pdr@google.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 1 Apr 2013 18:55:24 +0000 (18:55 +0000)
committerpdr@google.com <pdr@google.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 1 Apr 2013 18:55:24 +0000 (18:55 +0000)
commitefa630ef800fa5b35271dbafc775b7708983109c
tree21f4ce8cc067f3da89d4e089e933070f5ba40292
parent7065413582695c545213cd87c87cfac4132f643f
[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.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@147348 268f45cc-cd09-0410-ab3c-d52691b4dbfc
25 files changed:
LayoutTests/ChangeLog
LayoutTests/svg/css/buffered-rendering-expected.txt [new file with mode: 0644]
LayoutTests/svg/css/buffered-rendering.html [new file with mode: 0644]
LayoutTests/svg/repaint/buffered-rendering-dynamic-image-expected.html [new file with mode: 0644]
LayoutTests/svg/repaint/buffered-rendering-dynamic-image.html [new file with mode: 0644]
LayoutTests/svg/repaint/buffered-rendering-static-image-expected.html [new file with mode: 0644]
LayoutTests/svg/repaint/buffered-rendering-static-image.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/css/CSSComputedStyleDeclaration.cpp
Source/WebCore/css/CSSPrimitiveValueMappings.h
Source/WebCore/css/CSSProperty.cpp
Source/WebCore/css/SVGCSSComputedStyleDeclaration.cpp
Source/WebCore/css/SVGCSSParser.cpp
Source/WebCore/css/SVGCSSPropertyNames.in
Source/WebCore/css/SVGCSSStyleSelector.cpp
Source/WebCore/css/SVGCSSValueKeywords.in
Source/WebCore/rendering/style/SVGRenderStyle.cpp
Source/WebCore/rendering/style/SVGRenderStyle.h
Source/WebCore/rendering/style/SVGRenderStyleDefs.h
Source/WebCore/rendering/svg/RenderSVGImage.cpp
Source/WebCore/rendering/svg/RenderSVGImage.h
Source/WebCore/rendering/svg/SVGRenderingContext.cpp
Source/WebCore/rendering/svg/SVGRenderingContext.h
Source/WebCore/svg/SVGStyledElement.cpp
Source/WebCore/svg/svgattrs.in