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

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

Issue 2792833002: Revert of Optimize the pre-paint tree walk and ClipRects (Closed)
Patch Set: Created 3 years, 9 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
« no previous file with comments | « third_party/WebKit/Source/core/paint/PrePaintTreeWalk.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/paint/PrePaintTreeWalk.cpp
diff --git a/third_party/WebKit/Source/core/paint/PrePaintTreeWalk.cpp b/third_party/WebKit/Source/core/paint/PrePaintTreeWalk.cpp
index 60b3765eb9acdeb320ecf1f18f69cff03ef69a41..3286c5641fe8d8d3d7be6e9171b7f25271eb7a63 100644
--- a/third_party/WebKit/Source/core/paint/PrePaintTreeWalk.cpp
+++ b/third_party/WebKit/Source/core/paint/PrePaintTreeWalk.cpp
@@ -111,13 +111,31 @@
context.ancestorOverflowPaintLayer = paintLayer;
}
+// Returns whether |a| is an ancestor of or equal to |b|.
+static bool isAncestorOfOrEqualTo(const ClipPaintPropertyNode* a,
+ const ClipPaintPropertyNode* b) {
+ while (b && b != a) {
+ b = b->parent();
+ }
+ return b == a;
+}
+
void PrePaintTreeWalk::computeClipRectForContext(
const PaintPropertyTreeBuilderContext::ContainingBlockContext& context,
const EffectPaintPropertyNode* effect,
const PropertyTreeState& ancestorState,
const LayoutPoint& ancestorPaintOffset,
+ bool& hasClip,
FloatClipRect& clipRect) {
+ // Only return a non-infinite clip if clips differ, or the "ancestor" state is
+ // actually an ancestor clip. This ensures no accuracy issues due to
+ // transforms applied to infinite rects.
+ if (isAncestorOfOrEqualTo(context.clip, ancestorState.clip()))
+ clipRect = FloatClipRect();
+
+ hasClip = true;
PropertyTreeState localState(context.transform, context.clip, effect);
+
clipRect =
m_geometryMapper.sourceToDestinationClipRect(localState, ancestorState);
clipRect.moveBy(-FloatPoint(ancestorPaintOffset));
@@ -160,7 +178,8 @@
respectOverflowClip, LayoutSize());
#endif
- ClipRects clipRects;
+ bool hasClip = false;
+ RefPtr<ClipRects> clipRects = ClipRects::create();
const LayoutPoint& ancestorPaintOffset =
context.ancestorTransformedOrRootPaintLayer->layoutObject().paintOffset();
@@ -168,32 +187,36 @@
const EffectPaintPropertyNode* effect =
context.treeBuilderContext->currentEffect;
computeClipRectForContext(context.treeBuilderContext->current, effect,
- ancestorState, ancestorPaintOffset, clipRect);
- clipRects.setOverflowClipRect(clipRect);
-#ifdef CHECK_CLIP_RECTS
- CHECK(clipRects->overflowClipRect() == oldClipRects.overflowClipRect())
+ ancestorState, ancestorPaintOffset, hasClip,
+ clipRect);
+ clipRects->setOverflowClipRect(clipRect);
+#ifdef CHECK_CLIP_RECTS
+ CHECK(!hasClip ||
+ clipRects->overflowClipRect() == oldClipRects.overflowClipRect())
<< "rect= " << clipRects->overflowClipRect().toString();
#endif
computeClipRectForContext(context.treeBuilderContext->fixedPosition, effect,
- ancestorState, ancestorPaintOffset, clipRect);
- clipRects.setFixedClipRect(clipRect);
-#ifdef CHECK_CLIP_RECTS
- CHECK(clipRects->fixedClipRect() == oldClipRects.fixedClipRect())
+ ancestorState, ancestorPaintOffset, hasClip,
+ clipRect);
+ clipRects->setFixedClipRect(clipRect);
+#ifdef CHECK_CLIP_RECTS
+ CHECK(hasClip || clipRects->fixedClipRect() == oldClipRects.fixedClipRect())
<< " fixed=" << clipRects->fixedClipRect().toString();
#endif
computeClipRectForContext(context.treeBuilderContext->absolutePosition,
- effect, ancestorState, ancestorPaintOffset,
+ effect, ancestorState, ancestorPaintOffset, hasClip,
clipRect);
- clipRects.setPosClipRect(clipRect);
-#ifdef CHECK_CLIP_RECTS
- CHECK(clipRects->posClipRect() == oldClipRects.posClipRect())
+ clipRects->setPosClipRect(clipRect);
+#ifdef CHECK_CLIP_RECTS
+ CHECK(!hasClip || clipRects->posClipRect() == oldClipRects.posClipRect())
<< " abs=" << clipRects->posClipRect().toString();
#endif
- if (!paintLayer.hasPreviousPaintingClipRects() ||
- clipRects != paintLayer.previousPaintingClipRects()) {
+ ClipRects* previousClipRects = paintLayer.previousPaintingClipRects();
+
+ if (!previousClipRects || *clipRects != *previousClipRects) {
paintLayer.setNeedsRepaint();
paintLayer.setPreviousPaintPhaseDescendantOutlinesEmpty(false);
paintLayer.setPreviousPaintPhaseFloatEmpty(false);
@@ -204,7 +227,7 @@
PaintInvalidatorContext::ForcedSubtreeInvalidationRectUpdate;
}
- paintLayer.setPreviousPaintingClipRects(clipRects);
+ paintLayer.setPreviousPaintingClipRects(*clipRects);
}
bool PrePaintTreeWalk::shouldEndWalkBefore(
« no previous file with comments | « third_party/WebKit/Source/core/paint/PrePaintTreeWalk.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698