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

Side by Side Diff: third_party/WebKit/Source/core/layout/PaintInvalidationState.cpp

Issue 1774193002: New paint invalidation using paint property tree walk (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "core/layout/PaintInvalidationState.h" 5 #include "core/layout/PaintInvalidationState.h"
6 6
7 #include "core/layout/LayoutInline.h" 7 #include "core/layout/LayoutInline.h"
8 #include "core/layout/LayoutView.h" 8 #include "core/layout/LayoutView.h"
9 #include "core/layout/svg/LayoutSVGModelObject.h" 9 #include "core/layout/svg/LayoutSVGModelObject.h"
10 #include "core/layout/svg/LayoutSVGRoot.h" 10 #include "core/layout/svg/LayoutSVGRoot.h"
11 #include "core/paint/PaintLayer.h" 11 #include "core/paint/PaintLayer.h"
12 12
13 namespace blink { 13 namespace blink {
14 14
15 PaintInvalidationState::PaintInvalidationState(const PaintInvalidationState* par ent, const LayoutObject& layoutObject, const LayoutBoxModelObject& paintInvalida tionContainer, const LayoutPoint& paintOffset)
16 : m_clipped(false)
17 , m_cachedOffsetsEnabled(true)
18 , m_forcedSubtreeInvalidationWithinContainer(parent && parent->m_forcedSubtr eeInvalidationWithinContainer)
19 , m_forcedSubtreeInvalidationRectUpdateWithinContainer(parent && parent->m_f orcedSubtreeInvalidationRectUpdateWithinContainer)
20 , m_viewClippingAndScrollOffsetDisabled(false)
21 , m_paintOffset(toSize(paintOffset))
22 , m_paintInvalidationContainer(paintInvalidationContainer)
23 , m_pendingDelayedPaintInvalidations(nullptr)
24 , m_enclosingSelfPaintingLayer(parent ? parent->enclosingSelfPaintingLayer(l ayoutObject) : *paintInvalidationContainer.layer())
25 {
26 ASSERT(RuntimeEnabledFeatures::slimmingPaintInvalidationEnabled());
27
28 if (layoutObject == paintInvalidationContainer) {
29 // When we hit a new paint invalidation container, we don't need to
30 // continue forcing a check for paint invalidation, since we're
31 // descending into a different invalidation container. (For instance if
32 // our parents were moved, the entire container will just move.)
33 m_forcedSubtreeInvalidationWithinContainer = false;
34 }
35
36 // TODO(wangxianzhu): Handle transform, clipping, scrolling, etc.
37 }
38
15 PaintInvalidationState::PaintInvalidationState(const LayoutView& layoutView, Vec tor<LayoutObject*>& pendingDelayedPaintInvalidations, PaintInvalidationState* ow nerPaintInvalidationState) 39 PaintInvalidationState::PaintInvalidationState(const LayoutView& layoutView, Vec tor<LayoutObject*>& pendingDelayedPaintInvalidations, PaintInvalidationState* ow nerPaintInvalidationState)
16 : m_clipped(false) 40 : m_clipped(false)
17 , m_cachedOffsetsEnabled(true) 41 , m_cachedOffsetsEnabled(true)
18 , m_forcedSubtreeInvalidationWithinContainer(false) 42 , m_forcedSubtreeInvalidationWithinContainer(false)
19 , m_forcedSubtreeInvalidationRectUpdateWithinContainer(false) 43 , m_forcedSubtreeInvalidationRectUpdateWithinContainer(false)
20 , m_viewClippingAndScrollOffsetDisabled(false) 44 , m_viewClippingAndScrollOffsetDisabled(false)
21 , m_paintInvalidationContainer(layoutView.containerForPaintInvalidation()) 45 , m_paintInvalidationContainer(layoutView.containerForPaintInvalidation())
22 , m_pendingDelayedPaintInvalidations(pendingDelayedPaintInvalidations) 46 , m_pendingDelayedPaintInvalidations(&pendingDelayedPaintInvalidations)
23 , m_enclosingSelfPaintingLayer(*layoutView.layer()) 47 , m_enclosingSelfPaintingLayer(*layoutView.layer())
24 { 48 {
49 ASSERT(!RuntimeEnabledFeatures::slimmingPaintInvalidationEnabled());
50
25 bool establishesPaintInvalidationContainer = layoutView == m_paintInvalidati onContainer; 51 bool establishesPaintInvalidationContainer = layoutView == m_paintInvalidati onContainer;
26 if (!establishesPaintInvalidationContainer) { 52 if (!establishesPaintInvalidationContainer) {
27 if ((ownerPaintInvalidationState && !ownerPaintInvalidationState->m_cach edOffsetsEnabled) 53 if ((ownerPaintInvalidationState && !ownerPaintInvalidationState->m_cach edOffsetsEnabled)
28 || !layoutView.supportsPaintInvalidationStateCachedOffsets()) { 54 || !layoutView.supportsPaintInvalidationStateCachedOffsets()) {
29 m_cachedOffsetsEnabled = false; 55 m_cachedOffsetsEnabled = false;
30 return; 56 return;
31 } 57 }
32 if (ownerPaintInvalidationState && ownerPaintInvalidationState->m_forced SubtreeInvalidationWithinContainer) 58 if (ownerPaintInvalidationState && ownerPaintInvalidationState->m_forced SubtreeInvalidationWithinContainer)
33 m_forcedSubtreeInvalidationWithinContainer = true; 59 m_forcedSubtreeInvalidationWithinContainer = true;
34 FloatPoint point = layoutView.localToAncestorPoint(FloatPoint(), &m_pain tInvalidationContainer, TraverseDocumentBoundaries); 60 FloatPoint point = layoutView.localToAncestorPoint(FloatPoint(), &m_pain tInvalidationContainer, TraverseDocumentBoundaries);
35 m_paintOffset = LayoutSize(point.x(), point.y()); 61 m_paintOffset = LayoutSize(point.x(), point.y());
36 } 62 }
37 m_clipRect = layoutView.viewRect(); 63 m_clipRect = layoutView.viewRect();
38 m_clipRect.move(m_paintOffset); 64 m_clipRect.move(m_paintOffset);
39 m_clipped = true; 65 m_clipped = true;
40 } 66 }
41 67
42 PaintInvalidationState::PaintInvalidationState(PaintInvalidationState& next, Lay outBoxModelObject& layoutObject, const LayoutBoxModelObject& paintInvalidationCo ntainer) 68 PaintInvalidationState::PaintInvalidationState(PaintInvalidationState& next, con st LayoutBoxModelObject& layoutObject, const LayoutBoxModelObject& paintInvalida tionContainer)
43 : m_clipped(false) 69 : m_clipped(false)
44 , m_cachedOffsetsEnabled(true) 70 , m_cachedOffsetsEnabled(true)
45 , m_forcedSubtreeInvalidationWithinContainer(next.m_forcedSubtreeInvalidatio nWithinContainer) 71 , m_forcedSubtreeInvalidationWithinContainer(next.m_forcedSubtreeInvalidatio nWithinContainer)
46 , m_forcedSubtreeInvalidationRectUpdateWithinContainer(next.m_forcedSubtreeI nvalidationRectUpdateWithinContainer) 72 , m_forcedSubtreeInvalidationRectUpdateWithinContainer(next.m_forcedSubtreeI nvalidationRectUpdateWithinContainer)
47 , m_viewClippingAndScrollOffsetDisabled(false) 73 , m_viewClippingAndScrollOffsetDisabled(false)
48 , m_paintInvalidationContainer(paintInvalidationContainer) 74 , m_paintInvalidationContainer(paintInvalidationContainer)
49 , m_pendingDelayedPaintInvalidations(next.pendingDelayedPaintInvalidationTar gets()) 75 , m_pendingDelayedPaintInvalidations(&next.pendingDelayedPaintInvalidationTa rgets())
50 , m_enclosingSelfPaintingLayer(next.enclosingSelfPaintingLayer(layoutObject) ) 76 , m_enclosingSelfPaintingLayer(next.enclosingSelfPaintingLayer(layoutObject) )
51 { 77 {
78 ASSERT(!RuntimeEnabledFeatures::slimmingPaintInvalidationEnabled());
79
52 // FIXME: SVG could probably benefit from a stack-based optimization like ht ml does. crbug.com/391054 80 // FIXME: SVG could probably benefit from a stack-based optimization like ht ml does. crbug.com/391054
53 bool establishesPaintInvalidationContainer = layoutObject == m_paintInvalida tionContainer; 81 bool establishesPaintInvalidationContainer = layoutObject == m_paintInvalida tionContainer;
54 bool fixed = layoutObject.style()->position() == FixedPosition; 82 bool fixed = layoutObject.style()->position() == FixedPosition;
55 83
56 if (!layoutObject.supportsPaintInvalidationStateCachedOffsets() || !next.m_c achedOffsetsEnabled) 84 if (!layoutObject.supportsPaintInvalidationStateCachedOffsets() || !next.m_c achedOffsetsEnabled)
57 m_cachedOffsetsEnabled = false; 85 m_cachedOffsetsEnabled = false;
58 if (establishesPaintInvalidationContainer) { 86 if (establishesPaintInvalidationContainer) {
59 // When we hit a new paint invalidation container, we don't need to 87 // When we hit a new paint invalidation container, we don't need to
60 // continue forcing a check for paint invalidation, since we're 88 // continue forcing a check for paint invalidation, since we're
61 // descending into a different invalidation container. (For instance if 89 // descending into a different invalidation container. (For instance if
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 129
102 PaintInvalidationState::PaintInvalidationState(PaintInvalidationState& next, con st LayoutSVGModelObject& layoutObject) 130 PaintInvalidationState::PaintInvalidationState(PaintInvalidationState& next, con st LayoutSVGModelObject& layoutObject)
103 : m_clipped(next.m_clipped) 131 : m_clipped(next.m_clipped)
104 , m_cachedOffsetsEnabled(next.m_cachedOffsetsEnabled) 132 , m_cachedOffsetsEnabled(next.m_cachedOffsetsEnabled)
105 , m_forcedSubtreeInvalidationWithinContainer(next.m_forcedSubtreeInvalidatio nWithinContainer) 133 , m_forcedSubtreeInvalidationWithinContainer(next.m_forcedSubtreeInvalidatio nWithinContainer)
106 , m_forcedSubtreeInvalidationRectUpdateWithinContainer(next.m_forcedSubtreeI nvalidationRectUpdateWithinContainer) 134 , m_forcedSubtreeInvalidationRectUpdateWithinContainer(next.m_forcedSubtreeI nvalidationRectUpdateWithinContainer)
107 , m_viewClippingAndScrollOffsetDisabled(false) 135 , m_viewClippingAndScrollOffsetDisabled(false)
108 , m_clipRect(next.m_clipRect) 136 , m_clipRect(next.m_clipRect)
109 , m_paintOffset(next.m_paintOffset) 137 , m_paintOffset(next.m_paintOffset)
110 , m_paintInvalidationContainer(next.m_paintInvalidationContainer) 138 , m_paintInvalidationContainer(next.m_paintInvalidationContainer)
111 , m_pendingDelayedPaintInvalidations(next.pendingDelayedPaintInvalidationTar gets()) 139 , m_pendingDelayedPaintInvalidations(&next.pendingDelayedPaintInvalidationTa rgets())
112 , m_enclosingSelfPaintingLayer(next.enclosingSelfPaintingLayer(layoutObject) ) 140 , m_enclosingSelfPaintingLayer(next.enclosingSelfPaintingLayer(layoutObject) )
113 { 141 {
114 ASSERT(layoutObject != m_paintInvalidationContainer); 142 ASSERT(layoutObject != m_paintInvalidationContainer);
115 143
116 if (m_cachedOffsetsEnabled) 144 if (m_cachedOffsetsEnabled)
117 m_svgTransform = AffineTransform(next.svgTransform() * layoutObject.loca lToParentTransform()); 145 m_svgTransform = AffineTransform(next.svgTransform() * layoutObject.loca lToParentTransform());
118 } 146 }
119 147
120 void PaintInvalidationState::addClipRectRelativeToPaintOffset(const LayoutSize& clipSize) 148 void PaintInvalidationState::addClipRectRelativeToPaintOffset(const LayoutSize& clipSize)
121 { 149 {
(...skipping 25 matching lines...) Expand all
147 175
148 PaintLayer& PaintInvalidationState::enclosingSelfPaintingLayer(const LayoutObjec t& layoutObject) const 176 PaintLayer& PaintInvalidationState::enclosingSelfPaintingLayer(const LayoutObjec t& layoutObject) const
149 { 177 {
150 if (layoutObject.hasLayer() && toLayoutBoxModelObject(layoutObject).hasSelfP aintingLayer()) 178 if (layoutObject.hasLayer() && toLayoutBoxModelObject(layoutObject).hasSelfP aintingLayer())
151 return *toLayoutBoxModelObject(layoutObject).layer(); 179 return *toLayoutBoxModelObject(layoutObject).layer();
152 180
153 return m_enclosingSelfPaintingLayer; 181 return m_enclosingSelfPaintingLayer;
154 } 182 }
155 183
156 } // namespace blink 184 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698