Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1650)

Unified Diff: Source/core/rendering/svg/SVGRenderSupport.cpp

Issue 741123002: Get rid of computeFloatRectForPaintInvalidation (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Return reference; Fixup references in comments. Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/rendering/svg/SVGRenderSupport.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/rendering/svg/SVGRenderSupport.cpp
diff --git a/Source/core/rendering/svg/SVGRenderSupport.cpp b/Source/core/rendering/svg/SVGRenderSupport.cpp
index e9bd6c5d8d6d1a2a1d223494d23d04c746d2e009..2a9dce5ba2f7bb25e68816b91396b6fcb18ee3dc 100644
--- a/Source/core/rendering/svg/SVGRenderSupport.cpp
+++ b/Source/core/rendering/svg/SVGRenderSupport.cpp
@@ -44,6 +44,13 @@
namespace blink {
+static inline LayoutRect enclosingIntRectIfNotEmpty(const FloatRect& rect)
+{
+ if (rect.isEmpty())
+ return LayoutRect();
+ return enclosingIntRect(rect);
+}
+
LayoutRect SVGRenderSupport::clippedOverflowRectForPaintInvalidation(const RenderObject* object, const RenderLayerModelObject* paintInvalidationContainer, const PaintInvalidationState* paintInvalidationState)
{
// Return early for any cases where we don't actually paint
@@ -59,10 +66,8 @@ LayoutRect SVGRenderSupport::clippedOverflowRectForPaintInvalidation(const Rende
// Compute accumulated SVG transform and apply to local paint rect.
AffineTransform transform = paintInvalidationState->svgTransform() * object->localToParentTransform();
paintInvalidationRect = transform.mapRect(paintInvalidationRect);
- // FIXME: These are quirks carried forward from RenderSVGRoot::computeFloatRectForPaintInvalidation.
- LayoutRect rect;
- if (!paintInvalidationRect.isEmpty())
- rect = enclosingIntRect(paintInvalidationRect);
+ // FIXME: These are quirks carried forward from the old paint invalidation infrastructure.
+ LayoutRect rect = enclosingIntRectIfNotEmpty(paintInvalidationRect);
// Offset by SVG root paint offset and apply clipping as needed.
rect.move(paintInvalidationState->paintOffset());
if (paintInvalidationState->isClipped())
@@ -70,15 +75,32 @@ LayoutRect SVGRenderSupport::clippedOverflowRectForPaintInvalidation(const Rende
return rect;
}
- object->computeFloatRectForPaintInvalidation(paintInvalidationContainer, paintInvalidationRect, paintInvalidationState);
- return enclosingLayoutRect(paintInvalidationRect);
+ LayoutRect rect;
+ const RenderSVGRoot& svgRoot = mapRectToSVGRootForPaintInvalidation(object, paintInvalidationRect, rect);
+ svgRoot.mapRectToPaintInvalidationBacking(paintInvalidationContainer, rect, paintInvalidationState);
+ return rect;
}
-void SVGRenderSupport::computeFloatRectForPaintInvalidation(const RenderObject* object, const RenderLayerModelObject* paintInvalidationContainer, FloatRect& paintInvalidationRect, const PaintInvalidationState* paintInvalidationState)
+const RenderSVGRoot& SVGRenderSupport::mapRectToSVGRootForPaintInvalidation(const RenderObject* object, const FloatRect& localPaintInvalidationRect, LayoutRect& rect)
{
- // Translate to coords in our parent renderer, and then call computeFloatRectForPaintInvalidation() on our parent.
- paintInvalidationRect = object->localToParentTransform().mapRect(paintInvalidationRect);
- object->parent()->computeFloatRectForPaintInvalidation(paintInvalidationContainer, paintInvalidationRect, paintInvalidationState);
+ ASSERT(object && object->isSVG() && !object->isSVGRoot());
+
+ FloatRect paintInvalidationRect = localPaintInvalidationRect;
+ // FIXME: Building the transform to the SVG root border box and then doing
+ // mapRect() with that would be slightly more efficient, but requires some
+ // additions to AffineTransform (preMultiply, preTranslate) to avoid
+ // excessive copying and to get a similar fast-path for translations.
+ const RenderObject* parent = object;
+ do {
+ paintInvalidationRect = parent->localToParentTransform().mapRect(paintInvalidationRect);
+ parent = parent->parent();
+ } while (!parent->isSVGRoot());
+
+ const RenderSVGRoot& svgRoot = toRenderSVGRoot(*parent);
+
+ paintInvalidationRect = svgRoot.localToBorderBoxTransform().mapRect(paintInvalidationRect);
+ rect = enclosingIntRectIfNotEmpty(paintInvalidationRect);
+ return svgRoot;
}
void SVGRenderSupport::mapLocalToContainer(const RenderObject* object, const RenderLayerModelObject* paintInvalidationContainer, TransformState& transformState, bool* wasFixed, const PaintInvalidationState* paintInvalidationState)
« no previous file with comments | « Source/core/rendering/svg/SVGRenderSupport.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698