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

Unified Diff: third_party/WebKit/Source/core/paint/PaintInvalidator.cpp

Issue 2238853005: Use GeometryMapper in PaintInvalidator (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@GeometryMapperMore
Patch Set: - Created 4 years, 4 months 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
Index: third_party/WebKit/Source/core/paint/PaintInvalidator.cpp
diff --git a/third_party/WebKit/Source/core/paint/PaintInvalidator.cpp b/third_party/WebKit/Source/core/paint/PaintInvalidator.cpp
index f5c326788aeb94a6b27ecc824f1da301c56cdf16..0662c31b307f972ce00a1facc2076fd15880f056 100644
--- a/third_party/WebKit/Source/core/paint/PaintInvalidator.cpp
+++ b/third_party/WebKit/Source/core/paint/PaintInvalidator.cpp
@@ -11,59 +11,71 @@
#include "core/layout/LayoutObject.h"
#include "core/layout/LayoutTable.h"
#include "core/layout/svg/SVGLayoutSupport.h"
+#include "core/paint/ObjectPaintProperties.h"
#include "core/paint/PaintLayer.h"
#include "core/paint/PaintLayerScrollableArea.h"
+#include "core/paint/PaintPropertyTreeBuilder.h"
+#include "core/paint/PaintPropertyTreePrinter.h"
chrishtr 2016/08/12 18:20:53 Remove
Xianzhu 2016/08/12 18:37:51 Done. (BTW do you know how to make the functions
+#include "platform/graphics/paint/GeometryMapper.h"
namespace blink {
-void PaintInvalidatorContext::mapLocalRectToPaintInvalidationBacking(const LayoutObject& object, LayoutRect& rect) const
+static LayoutRect mapLocalRectToPaintInvalidationBacking(const LayoutObject& object, const FloatRect& localRect, const PaintInvalidatorContext& context)
{
- // TODO(wangxianzhu): For now this is the same as the slow path in PaintInvalidationState.cpp
- // (slowMapToVisualRectInAncestorSpace()). Should implement this with GeometryMapper.
+ // TODO(wkorman): The flip below is required because visual rects are
+ // currently in "physical coordinates with flipped block-flow direction"
+ // (see LayoutBoxModelObject.h) but we need them to be in physical
+ // coordinates.
+ FloatRect rect = localRect;
if (object.isBox())
toLayoutBox(object).flipForWritingMode(rect);
- if (object.isLayoutView())
- toLayoutView(object).mapToVisualRectInAncestorSpace(paintInvalidationContainer, rect, InputIsInFrameCoordinates, DefaultVisualRectFlags);
- else
- object.mapToVisualRectInAncestorSpace(paintInvalidationContainer, rect);
+ LayoutRect result;
+ if (object == context.paintInvalidationContainer) {
+ result = LayoutRect(rect);
+ } else {
+ rect.moveBy(FloatPoint(context.treeBuilderContext.current.paintOffset));
+
+ bool success = false;
+ PropertyTreeState currentTreeState(context.treeBuilderContext.current.transform, context.treeBuilderContext.current.clip, context.treeBuilderContext.currentEffect);
+ const PropertyTreeState& containerTreeState = context.paintInvalidationContainer->objectPaintProperties()->localBorderBoxProperties()->propertyTreeState;
+ result = LayoutRect(GeometryMapper().mapToVisualRectInDestinationSpace(rect, currentTreeState, containerTreeState, success));
chrishtr 2016/08/12 18:20:53 This does use GeometryMapper, but it's not efficie
Xianzhu 2016/08/12 18:37:51 Oh I didn't think this is an intermediate step. Wh
chrishtr 2016/08/12 18:40:28 All of the caching in GeometryMapper is stored as
Xianzhu 2016/08/12 19:16:29 Done.
+ DCHECK(success);
+ }
+
+ if (context.paintInvalidationContainer->layer()->groupedMapping())
+ PaintLayer::mapRectInPaintInvalidationContainerToBacking(*context.paintInvalidationContainer, result);
+ return result;
+}
+
+void PaintInvalidatorContext::mapLocalRectToPaintInvalidationBacking(const LayoutObject& object, LayoutRect& rect) const
+{
+ rect = blink::mapLocalRectToPaintInvalidationBacking(object, FloatRect(rect), *this);
chrishtr 2016/08/12 18:20:53 What's the point of not inlining blink::mapLocalRe
Xianzhu 2016/08/12 18:37:51 Two reasons: 1. This method is for non-SVG path o
chrishtr 2016/08/12 18:40:28 ok
}
static LayoutRect computePaintInvalidationRectInBacking(const LayoutObject& object, const PaintInvalidatorContext& context)
{
- if (object.isSVG() && !object.isSVGRoot()) {
- // TODO(wangxianzhu): For now this is the same as the slow path in PaintInvalidationState.cpp
- // (PaintInvalidationState::computePaintInvalidationRectInBackingForSVG()). Should implement this with GeometryMapper.
- LayoutRect rect = SVGLayoutSupport::clippedOverflowRectForPaintInvalidation(object, *context.paintInvalidationContainer);
- if (context.paintInvalidationContainer->layer()->groupedMapping())
- PaintLayer::mapRectInPaintInvalidationContainerToBacking(*context.paintInvalidationContainer, rect);
- return rect;
- }
+ FloatRect localRect;
+ if (object.isSVG() && !object.isSVGRoot())
+ localRect = SVGLayoutSupport::localOverflowRectForPaintInvalidation(object);
+ else
+ localRect = FloatRect(object.localOverflowRectForPaintInvalidation());
- LayoutRect rect = object.localOverflowRectForPaintInvalidation();
- context.mapLocalRectToPaintInvalidationBacking(object, rect);
- return rect;
+ return mapLocalRectToPaintInvalidationBacking(object, localRect, context);
}
static LayoutPoint computeLocationFromPaintInvalidationBacking(const LayoutObject& object, const PaintInvalidatorContext& context)
{
- // TODO(wangxianzhu): For now this is the same as the slow path in PaintInvalidationState.cpp
- // (slowLocalToAncestorPoint()). Should implement this with GeometryMapper.
FloatPoint point;
if (object != context.paintInvalidationContainer) {
- if (object.isLayoutView()) {
- point = toLayoutView(object).localToAncestorPoint(point, context.paintInvalidationContainer, TraverseDocumentBoundaries | InputIsInFrameCoordinates);
- } else {
- point = object.localToAncestorPoint(point, context.paintInvalidationContainer, TraverseDocumentBoundaries);
- // Paint invalidation does not include scroll of paintInvalidationContainer.
- if (context.paintInvalidationContainer->isBox()) {
- const LayoutBox* box = toLayoutBox(context.paintInvalidationContainer);
- if (box->hasOverflowClip())
- point.move(box->scrolledContentOffset());
- }
- }
- }
+ point.moveBy(FloatPoint(context.treeBuilderContext.current.paintOffset));
+ bool success = false;
+ PropertyTreeState currentTreeState(context.treeBuilderContext.current.transform, context.treeBuilderContext.current.clip, context.treeBuilderContext.currentEffect);
+ const PropertyTreeState& containerTreeState = context.paintInvalidationContainer->objectPaintProperties()->localBorderBoxProperties()->propertyTreeState;
+ point = GeometryMapper().mapRectToDestinationSpace(FloatRect(point, FloatSize()), currentTreeState, containerTreeState, success).location();
+ DCHECK(success);
+ }
if (context.paintInvalidationContainer->layer()->groupedMapping())
PaintLayer::mapPointInPaintInvalidationContainerToBacking(*context.paintInvalidationContainer, point);

Powered by Google App Engine
This is Rietveld 408576698