Add new renderer for SVGRectElement.
authorreni@webkit.org <reni@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 19 Oct 2011 14:59:55 +0000 (14:59 +0000)
committerreni@webkit.org <reni@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 19 Oct 2011 14:59:55 +0000 (14:59 +0000)
commitea44b8725507b36359b5bf55c952d0687f8e6449
tree7e6e3db733d69983645ad901fd8be8b3f652da9c
parent018d8ce30e1ed1c93cbdf25cbe020ea356232258
Add new renderer for SVGRectElement.
https://bugs.webkit.org/show_bug.cgi?id=65769

Source/WebCore:

Patch by Renata Hodovan <reni@webkit.org> on 2011-10-19
Reviewed by Dirk Schulze.

This patch introduces a new common base class called RenderSVGShape which
replaces the RenderSVGPath. This new base class has the same purpose
as the replaced class and has specialized descendants for common
shapes (like Rectangles and Circles), which allows faster painting
of these shapes when certain conditions are fulfilled. On some
benchmark programs we have seen 5% speedup.

The biggest motivation of this refactor is taking advantage
of faster primitive drawing in the most common and frequent
cases. However in some rare cases, like painting rounded
rects, we need to fallback to the original code path, which
is fully kept in the RenderSVGShape base class. Some other
cases, like dashed strokes, can be painted but mouse pointer
events cannot be handled by the descendant classes. A different
fallback mechanism is used in such cases which redirects
only the pointer event handling to the base class.

Tests: svg/custom/pointer-events-on-rounded-rect.xhtml
       svg/custom/pointer-events-with-linecaps-and-miterlimits.xhtml

* CMakeLists.txt:
* GNUmakefile.list.am:
* WebCore.gypi:
* WebCore.pro:
* WebCore.vcproj/WebCore.vcproj:
* platform/graphics/FloatRect.cpp:
(WebCore::FloatRect::contains):
* platform/graphics/FloatRect.h:
(WebCore::FloatRect::contains):
* rendering/RenderObject.h:
(WebCore::RenderObject::isSVGRect):
(WebCore::RenderObject::isSVGShape):
* rendering/RenderTreeAsText.cpp:
(WebCore::write):
* rendering/svg/RenderSVGAllInOne.cpp:
* rendering/svg/RenderSVGModelObject.cpp:
(WebCore::isGraphicsElement):
* rendering/svg/RenderSVGPath.cpp:
(WebCore::RenderSVGPath::RenderSVGPath):
(WebCore::RenderSVGPath::inflateWithMarkerBounds): Unite the markerBounds with strokeBoundingBox.
* rendering/svg/RenderSVGPath.h:
* rendering/svg/RenderSVGRect.cpp: Added.
(WebCore::RenderSVGRect::RenderSVGRect):
(WebCore::RenderSVGRect::~RenderSVGRect):
(WebCore::RenderSVGRect::createShape):
(WebCore::RenderSVGRect::objectBoundingBox):
(WebCore::RenderSVGRect::strokeBoundingBox):
(WebCore::RenderSVGRect::fillShape):
(WebCore::RenderSVGRect::strokeShape):
(WebCore::RenderSVGRect::shapeDependentStrokeContains):
(WebCore::RenderSVGRect::shapeDependentFillContains):
* rendering/svg/RenderSVGRect.h: Added.
(WebCore::RenderSVGRect::isSVGRect):
(WebCore::RenderSVGRect::renderName):
(WebCore::RenderSVGRect::isEmpty):
* rendering/svg/RenderSVGResource.h:
(WebCore::RenderSVGResource::postApplyResource): A new shape argument was added to allow shape specific faster painting.
* rendering/svg/RenderSVGResourceClipper.cpp:
(WebCore::RenderSVGResourceClipper::drawContentIntoMaskImage):
(WebCore::RenderSVGResourceClipper::calculateClipContentRepaintRect):
(WebCore::RenderSVGResourceClipper::hitTestClipContent):
* rendering/svg/RenderSVGResourceContainer.cpp:
(WebCore::RenderSVGResourceContainer::transformOnNonScalingStroke):
* rendering/svg/RenderSVGResourceFilter.cpp:
(WebCore::RenderSVGResourceFilter::postApplyResource):
* rendering/svg/RenderSVGResourceFilter.h:
* rendering/svg/RenderSVGResourceGradient.cpp:
(WebCore::RenderSVGResourceGradient::applyResource):
* rendering/svg/RenderSVGResourceGradient.h:
* rendering/svg/RenderSVGResourcePattern.cpp:
(WebCore::RenderSVGResourcePattern::postApplyResource):
* rendering/svg/RenderSVGResourcePattern.h:
* rendering/svg/RenderSVGResourceSolidColor.cpp:
(WebCore::RenderSVGResourceSolidColor::postApplyResource):
* rendering/svg/RenderSVGResourceSolidColor.h:
* rendering/svg/RenderSVGShape.cpp: Copied from Source/WebCore/rendering/svg/RenderSVGPath.cpp.
(WebCore::RenderSVGShape::RenderSVGShape):
(WebCore::RenderSVGShape::~RenderSVGShape):
(WebCore::RenderSVGShape::createShape):
(WebCore::RenderSVGShape::isEmpty):
(WebCore::RenderSVGShape::fillShape):
(WebCore::RenderSVGShape::objectBoundingBox):
(WebCore::RenderSVGShape::strokeBoundingBox):
(WebCore::RenderSVGShape::strokeShape):
(WebCore::RenderSVGShape::shapeDependentStrokeContains):
The purpose of this virtual function allows decendants to use their own fast checks.
(WebCore::RenderSVGShape::shapeDependentFillContains):
The purpose of this virtual function allows decendants to use their own fast checks.
(WebCore::RenderSVGShape::fillContains):
(WebCore::RenderSVGShape::strokeContains):
(WebCore::RenderSVGShape::layout):
(WebCore::RenderSVGShape::shouldStrokeZeroLengthSubpath):
(WebCore::RenderSVGShape::zeroLengthSubpathRect):
(WebCore::RenderSVGShape::setupSquareCapPath):
(WebCore::RenderSVGShape::setupNonScalingStrokePath):
(WebCore::RenderSVGShape::fillAndStrokePath):
(WebCore::RenderSVGShape::paint):
(WebCore::RenderSVGShape::addFocusRingRects):
(WebCore::RenderSVGShape::nodeAtFloatPoint):
(WebCore::RenderSVGShape::calculateMarkerBoundsIfNeeded):
(WebCore::RenderSVGShape::updateCachedBoundaries):
(WebCore::RenderSVGShape::strokeWidth):
* rendering/svg/RenderSVGShape.h: Copied from Source/WebCore/rendering/svg/RenderSVGPath.h.
(WebCore::BoundingRectStrokeStyleApplier::BoundingRectStrokeStyleApplier):
(WebCore::BoundingRectStrokeStyleApplier::strokeStyle):
(WebCore::RenderSVGShape::setNeedsShapeUpdate):
(WebCore::RenderSVGShape::setNeedsBoundariesUpdate):
(WebCore::RenderSVGShape::setNeedsTransformUpdate):
(WebCore::RenderSVGShape::isPaintingFallback):
(WebCore::RenderSVGShape::path):
(WebCore::RenderSVGShape::setIsPaintingFallback):
(WebCore::RenderSVGShape::setStrokeAndMarkerBoundingBox):
(WebCore::RenderSVGShape::hasPath):
(WebCore::RenderSVGShape::repaintRectInLocalCoordinates):
(WebCore::RenderSVGShape::localToParentTransform):
(WebCore::RenderSVGShape::localTransform):
(WebCore::RenderSVGShape::isSVGShape):
(WebCore::RenderSVGShape::renderName):
(WebCore::RenderSVGShape::isRoundedRect):
(WebCore::RenderSVGShape::inflateWithMarkerBounds):
(WebCore::toRenderSVGShape):
* rendering/svg/SVGInlineTextBox.cpp:
(WebCore::SVGInlineTextBox::releasePaintingResource):
* rendering/svg/SVGRenderSupport.cpp:
(WebCore::SVGRenderSupport::finishRenderSVGContent):
(WebCore::SVGRenderSupport::layoutChildren):
* rendering/svg/SVGRenderTreeAsText.cpp:
(WebCore::writeStyle):
(WebCore::operator<<):
(WebCore::write):
* rendering/svg/SVGRenderTreeAsText.h:
* rendering/svg/SVGTextRunRenderingContext.cpp:
(WebCore::SVGTextRunRenderingContext::drawSVGGlyphs):
* svg/SVGCircleElement.cpp:
(WebCore::SVGCircleElement::svgAttributeChanged):
* svg/SVGEllipseElement.cpp:
(WebCore::SVGEllipseElement::svgAttributeChanged):
* svg/SVGLineElement.cpp:
(WebCore::SVGLineElement::svgAttributeChanged):
* svg/SVGPathElement.cpp:
(WebCore::SVGPathElement::svgAttributeChanged):
(WebCore::SVGPathElement::pathSegListChanged):
(WebCore::SVGPathElement::createRenderer):
* svg/SVGPathElement.h:
* svg/SVGPolyElement.cpp:
(WebCore::SVGPolyElement::svgAttributeChanged):
* svg/SVGRectElement.cpp:
(WebCore::SVGRectElement::svgAttributeChanged):
(WebCore::SVGRectElement::createRenderer):
* svg/SVGRectElement.h:

LayoutTests:

Add new tests to check the new shape based rendering mechanism of SVGRectElement.

Patch by Renata Hodovan <reni@webkit.org> on 2011-10-19
Reviewed by Dirk Schulze.

* svg/custom/pointer-events-on-rounded-rect-expected.txt: Added.
* svg/custom/pointer-events-on-rounded-rect.xhtml: Added.
* svg/custom/pointer-events-with-linecaps-and-miterlimits-expected.txt: Added.
* svg/custom/pointer-events-with-linecaps-and-miterlimits.xhtml: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@97863 268f45cc-cd09-0410-ab3c-d52691b4dbfc
48 files changed:
LayoutTests/ChangeLog
LayoutTests/svg/custom/pointer-events-on-rounded-rect-expected.txt [new file with mode: 0644]
LayoutTests/svg/custom/pointer-events-on-rounded-rect.xhtml [new file with mode: 0644]
LayoutTests/svg/custom/pointer-events-with-linecaps-and-miterlimits-expected.txt [new file with mode: 0644]
LayoutTests/svg/custom/pointer-events-with-linecaps-and-miterlimits.xhtml [new file with mode: 0644]
Source/WebCore/CMakeLists.txt
Source/WebCore/ChangeLog
Source/WebCore/GNUmakefile.list.am
Source/WebCore/WebCore.gypi
Source/WebCore/WebCore.pro
Source/WebCore/WebCore.vcproj/WebCore.vcproj
Source/WebCore/platform/graphics/FloatRect.cpp
Source/WebCore/platform/graphics/FloatRect.h
Source/WebCore/rendering/RenderObject.h
Source/WebCore/rendering/RenderTreeAsText.cpp
Source/WebCore/rendering/svg/RenderSVGAllInOne.cpp
Source/WebCore/rendering/svg/RenderSVGModelObject.cpp
Source/WebCore/rendering/svg/RenderSVGPath.cpp
Source/WebCore/rendering/svg/RenderSVGPath.h
Source/WebCore/rendering/svg/RenderSVGRect.cpp [new file with mode: 0644]
Source/WebCore/rendering/svg/RenderSVGRect.h [new file with mode: 0644]
Source/WebCore/rendering/svg/RenderSVGResource.h
Source/WebCore/rendering/svg/RenderSVGResourceClipper.cpp
Source/WebCore/rendering/svg/RenderSVGResourceContainer.cpp
Source/WebCore/rendering/svg/RenderSVGResourceFilter.cpp
Source/WebCore/rendering/svg/RenderSVGResourceFilter.h
Source/WebCore/rendering/svg/RenderSVGResourceGradient.cpp
Source/WebCore/rendering/svg/RenderSVGResourceGradient.h
Source/WebCore/rendering/svg/RenderSVGResourcePattern.cpp
Source/WebCore/rendering/svg/RenderSVGResourcePattern.h
Source/WebCore/rendering/svg/RenderSVGResourceSolidColor.cpp
Source/WebCore/rendering/svg/RenderSVGResourceSolidColor.h
Source/WebCore/rendering/svg/RenderSVGRoot.cpp
Source/WebCore/rendering/svg/RenderSVGShape.cpp [new file with mode: 0644]
Source/WebCore/rendering/svg/RenderSVGShape.h [new file with mode: 0644]
Source/WebCore/rendering/svg/SVGInlineTextBox.cpp
Source/WebCore/rendering/svg/SVGRenderSupport.cpp
Source/WebCore/rendering/svg/SVGRenderTreeAsText.cpp
Source/WebCore/rendering/svg/SVGRenderTreeAsText.h
Source/WebCore/rendering/svg/SVGTextRunRenderingContext.cpp
Source/WebCore/svg/SVGCircleElement.cpp
Source/WebCore/svg/SVGEllipseElement.cpp
Source/WebCore/svg/SVGLineElement.cpp
Source/WebCore/svg/SVGPathElement.cpp
Source/WebCore/svg/SVGPathElement.h
Source/WebCore/svg/SVGPolyElement.cpp
Source/WebCore/svg/SVGRectElement.cpp
Source/WebCore/svg/SVGRectElement.h