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

Side by Side Diff: third_party/WebKit/Source/core/paint/PrePaintTreeWalk.cpp

Issue 2404213004: Implement incremental paint property tree rebuilding (Closed)
Patch Set: Rebase, re-implement updateTransform and updateEffect Created 4 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/paint/PrePaintTreeWalk.h" 5 #include "core/paint/PrePaintTreeWalk.h"
6 6
7 #include "core/dom/DocumentLifecycle.h" 7 #include "core/dom/DocumentLifecycle.h"
8 #include "core/frame/FrameView.h" 8 #include "core/frame/FrameView.h"
9 #include "core/frame/LocalFrame.h" 9 #include "core/frame/LocalFrame.h"
10 #include "core/layout/LayoutMultiColumnSpannerPlaceholder.h" 10 #include "core/layout/LayoutMultiColumnSpannerPlaceholder.h"
11 #include "core/layout/LayoutPart.h" 11 #include "core/layout/LayoutPart.h"
12 #include "core/layout/LayoutView.h" 12 #include "core/layout/LayoutView.h"
13 13
14 namespace blink { 14 namespace blink {
15 15
16 struct PrePaintTreeWalkContext { 16 struct PrePaintTreeWalkContext {
17 PrePaintTreeWalkContext() : paintInvalidatorContext(treeBuilderContext) {} 17 PrePaintTreeWalkContext() : paintInvalidatorContext(treeBuilderContext) {}
18 PrePaintTreeWalkContext(const PrePaintTreeWalkContext& parentContext) 18 PrePaintTreeWalkContext(const PrePaintTreeWalkContext& parentContext)
19 : treeBuilderContext(parentContext.treeBuilderContext), 19 : treeBuilderContext(parentContext.treeBuilderContext),
20 paintInvalidatorContext(treeBuilderContext, 20 paintInvalidatorContext(treeBuilderContext,
21 parentContext.paintInvalidatorContext) {} 21 parentContext.paintInvalidatorContext) {}
22 22
23 bool needToUpdatePaintPropertySubtree = false;
23 PaintPropertyTreeBuilderContext treeBuilderContext; 24 PaintPropertyTreeBuilderContext treeBuilderContext;
24 PaintInvalidatorContext paintInvalidatorContext; 25 PaintInvalidatorContext paintInvalidatorContext;
25 }; 26 };
26 27
27 void PrePaintTreeWalk::walk(FrameView& rootFrame) { 28 void PrePaintTreeWalk::walk(FrameView& rootFrame) {
28 DCHECK(rootFrame.frame().document()->lifecycle().state() == 29 DCHECK(rootFrame.frame().document()->lifecycle().state() ==
29 DocumentLifecycle::InPrePaint); 30 DocumentLifecycle::InPrePaint);
30 31
31 PrePaintTreeWalkContext initialContext; 32 PrePaintTreeWalkContext initialContext;
32 initialContext.treeBuilderContext = 33 initialContext.treeBuilderContext =
33 m_propertyTreeBuilder.setupInitialContext(); 34 m_propertyTreeBuilder.setupInitialContext();
34 walk(rootFrame, initialContext); 35 walk(rootFrame, initialContext);
35 m_paintInvalidator.processPendingDelayedPaintInvalidations(); 36 m_paintInvalidator.processPendingDelayedPaintInvalidations();
36 } 37 }
37 38
38 void PrePaintTreeWalk::walk(FrameView& frameView, 39 void PrePaintTreeWalk::walk(FrameView& frameView,
39 const PrePaintTreeWalkContext& context) { 40 const PrePaintTreeWalkContext& context) {
40 if (frameView.shouldThrottleRendering()) 41 if (frameView.shouldThrottleRendering())
41 return; 42 return;
42 43
43 PrePaintTreeWalkContext localContext(context); 44 PrePaintTreeWalkContext localContext(context);
44 m_propertyTreeBuilder.buildTreeNodes(frameView, 45
45 localContext.treeBuilderContext); 46 // Check whether we need to update the paint property trees.
47 if (!localContext.needToUpdatePaintPropertySubtree) {
48 if (context.paintInvalidatorContext.forcedSubtreeInvalidationFlags) {
49 // forcedSubtreeInvalidationFlags will be true if locations have changed
50 // which will affect paint properties (e.g., PaintOffset).
51 localContext.needToUpdatePaintPropertySubtree = true;
52 } else if (frameView.needsPaintPropertyUpdate()) {
53 // Paint properties can depend on their ancestor properties so ensure
54 // the entire subtree is rebuilt on any changes.
55 // TODO(pdr): Add additional granularity to the needs update approach
56 // such as the ability to do local updates that don't change the subtree.
57 localContext.needToUpdatePaintPropertySubtree = true;
58 }
59 }
60 if (localContext.needToUpdatePaintPropertySubtree)
61 frameView.setNeedsPaintPropertyUpdate();
62
63 m_propertyTreeBuilder.updateProperties(frameView,
64 localContext.treeBuilderContext);
46 65
47 if (RuntimeEnabledFeatures::slimmingPaintInvalidationEnabled()) { 66 if (RuntimeEnabledFeatures::slimmingPaintInvalidationEnabled()) {
48 m_paintInvalidator.invalidatePaintIfNeeded( 67 m_paintInvalidator.invalidatePaintIfNeeded(
49 frameView, localContext.paintInvalidatorContext); 68 frameView, localContext.paintInvalidatorContext);
50 } 69 }
51 70
52 if (LayoutView* layoutView = frameView.layoutView()) 71 if (LayoutView* layoutView = frameView.layoutView())
53 walk(*layoutView, localContext); 72 walk(*layoutView, localContext);
54 73
55 #if DCHECK_IS_ON() 74 #if DCHECK_IS_ON()
56 if (RuntimeEnabledFeatures::slimmingPaintInvalidationEnabled()) 75 if (RuntimeEnabledFeatures::slimmingPaintInvalidationEnabled())
57 frameView.layoutView()->assertSubtreeClearedPaintInvalidationFlags(); 76 frameView.layoutView()->assertSubtreeClearedPaintInvalidationFlags();
58 #endif 77 #endif
78
79 frameView.clearNeedsPaintPropertyUpdate();
59 } 80 }
60 81
61 void PrePaintTreeWalk::walk(const LayoutObject& object, 82 void PrePaintTreeWalk::walk(const LayoutObject& object,
62 const PrePaintTreeWalkContext& context) { 83 const PrePaintTreeWalkContext& context) {
63 PrePaintTreeWalkContext localContext(context); 84 PrePaintTreeWalkContext localContext(context);
64 85
86 // Check whether we need to update the paint property trees.
87 if (!localContext.needToUpdatePaintPropertySubtree) {
88 if (context.paintInvalidatorContext.forcedSubtreeInvalidationFlags) {
89 // forcedSubtreeInvalidationFlags will be true if locations have changed
90 // which will affect paint properties (e.g., PaintOffset).
91 localContext.needToUpdatePaintPropertySubtree = true;
92 } else if (object.needsPaintPropertyUpdate()) {
93 // Paint properties can depend on their ancestor properties so ensure
94 // the entire subtree is rebuilt on any changes.
95 // TODO(pdr): Add additional granularity to the needs update approach
96 // such as the ability to do local updates that don't change the subtree.
97 localContext.needToUpdatePaintPropertySubtree = true;
98 } else if (
99 object
100 .shouldCheckForPaintInvalidationRegardlessOfPaintInvalidationState() ) {
101 // TODO(pdr): Better document the exact reason we need to check this
102 // paint invalidation state.
103 localContext.needToUpdatePaintPropertySubtree = true;
Xianzhu 2016/10/26 19:21:51 I think we don't need to set needToUpdatePaintProp
pdr. 2016/10/26 23:10:19 Initially I'd like to rebuild entire subtrees anyt
Xianzhu 2016/10/26 23:19:40 SGTM. (I overlooked the previous needToUpdatePain
104 }
105 }
106 if (localContext.needToUpdatePaintPropertySubtree)
107 object.getMutableForPainting().setNeedsPaintPropertyUpdate();
108
109 // TODO(pdr): Ensure multi column works with incremental property tree
110 // construction.
65 if (object.isLayoutMultiColumnSpannerPlaceholder()) { 111 if (object.isLayoutMultiColumnSpannerPlaceholder()) {
66 // Walk multi-column spanner as if it replaces the placeholder. 112 // Walk multi-column spanner as if it replaces the placeholder.
67 // Set the flag so that the tree builder can specially handle out-of-flow 113 // Set the flag so that the tree builder can specially handle out-of-flow
68 // positioned descendants if their containers are between the multi-column 114 // positioned descendants if their containers are between the multi-column
69 // container and the spanner. See PaintPropertyTreeBuilder for details. 115 // container and the spanner. See PaintPropertyTreeBuilder for details.
70 localContext.treeBuilderContext.isUnderMultiColumnSpanner = true; 116 localContext.treeBuilderContext.isUnderMultiColumnSpanner = true;
71 object.getMutableForPainting().clearPaintInvalidationFlags(); 117 object.getMutableForPainting().clearPaintInvalidationFlags();
72 walk(*toLayoutMultiColumnSpannerPlaceholder(object) 118 walk(*toLayoutMultiColumnSpannerPlaceholder(object)
73 .layoutObjectInFlowThread(), 119 .layoutObjectInFlowThread(),
74 localContext); 120 localContext);
75 return; 121 return;
76 } 122 }
77 123
78 m_propertyTreeBuilder.buildTreeNodesForSelf(object, 124 m_propertyTreeBuilder.updatePropertiesForSelf(
79 localContext.treeBuilderContext); 125 object, localContext.treeBuilderContext);
126
80 if (RuntimeEnabledFeatures::slimmingPaintInvalidationEnabled()) 127 if (RuntimeEnabledFeatures::slimmingPaintInvalidationEnabled())
81 m_paintInvalidator.invalidatePaintIfNeeded( 128 m_paintInvalidator.invalidatePaintIfNeeded(
82 object, localContext.paintInvalidatorContext); 129 object, localContext.paintInvalidatorContext);
83 m_propertyTreeBuilder.buildTreeNodesForChildren( 130
131 m_propertyTreeBuilder.updatePropertiesForChildren(
84 object, localContext.treeBuilderContext); 132 object, localContext.treeBuilderContext);
85 133
86 for (const LayoutObject* child = object.slowFirstChild(); child; 134 for (const LayoutObject* child = object.slowFirstChild(); child;
87 child = child->nextSibling()) { 135 child = child->nextSibling()) {
88 // Column spanners are walked through their placeholders. See above. 136 // Column spanners are walked through their placeholders. See above.
89 if (child->isColumnSpanAll()) 137 if (child->isColumnSpanAll())
90 continue; 138 continue;
91 walk(*child, localContext); 139 walk(*child, localContext);
92 } 140 }
93 141
94 if (object.isLayoutPart()) { 142 if (object.isLayoutPart()) {
95 const LayoutPart& layoutPart = toLayoutPart(object); 143 const LayoutPart& layoutPart = toLayoutPart(object);
96 Widget* widget = layoutPart.widget(); 144 Widget* widget = layoutPart.widget();
97 if (widget && widget->isFrameView()) { 145 if (widget && widget->isFrameView()) {
98 localContext.treeBuilderContext.current.paintOffset += 146 localContext.treeBuilderContext.current.paintOffset +=
99 layoutPart.replacedContentRect().location() - 147 layoutPart.replacedContentRect().location() -
100 widget->frameRect().location(); 148 widget->frameRect().location();
101 localContext.treeBuilderContext.current.paintOffset = 149 localContext.treeBuilderContext.current.paintOffset =
102 roundedIntPoint(localContext.treeBuilderContext.current.paintOffset); 150 roundedIntPoint(localContext.treeBuilderContext.current.paintOffset);
103 walk(*toFrameView(widget), localContext); 151 walk(*toFrameView(widget), localContext);
104 } 152 }
105 // TODO(pdr): Investigate RemoteFrameView (crbug.com/579281). 153 // TODO(pdr): Investigate RemoteFrameView (crbug.com/579281).
106 } 154 }
155
156 object.getMutableForPainting().clearNeedsPaintPropertyUpdate();
107 } 157 }
108 158
109 } // namespace blink 159 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698