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

Side by Side Diff: third_party/WebKit/Source/core/paint/FindPropertiesNeedingUpdate.h

Issue 2495893002: Implement incremental paint property tree rebuilding (Closed)
Patch Set: Suppress main thread scrolling invalidation failures 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
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef FindPropertiesNeedingUpdate_h
6 #define FindPropertiesNeedingUpdate_h
7
8 #if DCHECK_IS_ON()
9 namespace blink {
10
11 #define DCHECK_PTR_VAL_EQ(ptrA, ptrB) \
12 DCHECK((!!ptrA == !!ptrB) && ((!ptrA && !ptrB) || (*ptrA == *ptrB)));
13
14 // This file contains two scope classes for catching cases where paint
15 // properties need an update but where not marked as such. If paint properties
16 // will change, the object must be marked as needing a paint property update
17 // using {FrameView, LayoutObject}::setNeedsPaintPropertyUpdate().
18 //
19 // Both scope classes work by recording the paint property state of an object
20 // before rebuilding properties, forcing the properties to get updated, then
21 // checking that the updated properties match the original properties.
22
23 class FindFrameViewPropertiesNeedingUpdateScope {
24 public:
25 FindFrameViewPropertiesNeedingUpdateScope(FrameView* frameView)
26 : m_frameView(frameView),
27 m_neededPaintPropertyUpdate(frameView->needsPaintPropertyUpdate()) {
28 // No need to check when already marked as needing an update.
29 if (m_neededPaintPropertyUpdate)
30 return;
31
32 // Mark the properties as needing an update to ensure they are rebuilt.
33 m_frameView->setNeedsPaintPropertyUpdate();
34 if (auto* preTranslation = m_frameView->preTranslation())
35 m_preTranslation = preTranslation->clone();
36 if (auto* contentClip = m_frameView->contentClip())
37 m_contentClip = contentClip->clone();
38 if (auto* scrollTranslation = m_frameView->scrollTranslation())
39 m_scrollTranslation = scrollTranslation->clone();
40 if (auto* scroll = m_frameView->scroll())
41 m_scroll = scroll->clone();
42 }
43
44 ~FindFrameViewPropertiesNeedingUpdateScope() {
45 // No need to check when already marked as needing an update.
46 if (m_neededPaintPropertyUpdate)
47 return;
48
49 // If paint properties are not marked as needing an update but still change,
50 // we are missing a call to FrameView::setNeedsPaintPropertyUpdate().
51 DCHECK_PTR_VAL_EQ(m_preTranslation, m_frameView->preTranslation());
52 DCHECK_PTR_VAL_EQ(m_contentClip, m_frameView->contentClip());
53 DCHECK_PTR_VAL_EQ(m_scrollTranslation, m_frameView->scrollTranslation());
54 DCHECK_PTR_VAL_EQ(m_scroll, m_frameView->scroll());
55 // Restore original clean bit.
56 m_frameView->clearNeedsPaintPropertyUpdate();
57 }
58
59 private:
60 Persistent<FrameView> m_frameView;
61 bool m_neededPaintPropertyUpdate;
62 RefPtr<TransformPaintPropertyNode> m_preTranslation;
63 RefPtr<ClipPaintPropertyNode> m_contentClip;
64 RefPtr<TransformPaintPropertyNode> m_scrollTranslation;
65 RefPtr<ScrollPaintPropertyNode> m_scroll;
66 };
67
68 class FindObjectPropertiesNeedingUpdateScope {
69 public:
70 FindObjectPropertiesNeedingUpdateScope(const LayoutObject& object)
71 : m_object(object),
72 m_neededPaintPropertyUpdate(object.needsPaintPropertyUpdate()) {
73 // No need to check when already marked as needing an update.
74 if (m_neededPaintPropertyUpdate)
75 return;
76
77 // Mark the properties as needing an update to ensure they are rebuilt.
78 const_cast<LayoutObject&>(m_object).setNeedsPaintPropertyUpdate();
79 if (const auto* properties = m_object.paintProperties())
80 m_properties = properties->clone();
81 }
82
83 ~FindObjectPropertiesNeedingUpdateScope() {
84 // No need to check when already marked as needing an update.
85 if (m_neededPaintPropertyUpdate)
86 return;
87
88 // If paint properties are not marked as needing an update but still change,
89 // we are missing a call to LayoutObject::setNeedsPaintPropertyUpdate().
90 const auto* objectProperties = m_object.paintProperties();
91 if (m_properties && objectProperties) {
92 DCHECK_PTR_VAL_EQ(m_properties->paintOffsetTranslation(),
93 objectProperties->paintOffsetTranslation());
94 DCHECK_PTR_VAL_EQ(m_properties->transform(),
95 objectProperties->transform());
96 DCHECK_PTR_VAL_EQ(m_properties->effect(), objectProperties->effect());
97 DCHECK_PTR_VAL_EQ(m_properties->cssClip(), objectProperties->cssClip());
98 DCHECK_PTR_VAL_EQ(m_properties->cssClipFixedPosition(),
99 objectProperties->cssClipFixedPosition());
100 DCHECK_PTR_VAL_EQ(m_properties->innerBorderRadiusClip(),
101 objectProperties->innerBorderRadiusClip());
102 DCHECK_PTR_VAL_EQ(m_properties->overflowClip(),
103 objectProperties->overflowClip());
104 DCHECK_PTR_VAL_EQ(m_properties->perspective(),
105 objectProperties->perspective());
106 DCHECK_PTR_VAL_EQ(m_properties->svgLocalToBorderBoxTransform(),
107 objectProperties->svgLocalToBorderBoxTransform());
108 DCHECK_PTR_VAL_EQ(m_properties->scrollTranslation(),
109 objectProperties->scrollTranslation());
110 DCHECK_PTR_VAL_EQ(m_properties->scrollbarPaintOffset(),
111 objectProperties->scrollbarPaintOffset());
112 const auto* borderBox = m_properties->localBorderBoxProperties();
113 const auto* objectBorderBox =
114 objectProperties->localBorderBoxProperties();
115 if (borderBox && objectBorderBox) {
116 DCHECK(borderBox->paintOffset == objectBorderBox->paintOffset);
117 DCHECK_EQ(borderBox->propertyTreeState.transform(),
118 objectBorderBox->propertyTreeState.transform());
119 DCHECK_EQ(borderBox->propertyTreeState.clip(),
120 objectBorderBox->propertyTreeState.clip());
121 DCHECK_EQ(borderBox->propertyTreeState.effect(),
122 objectBorderBox->propertyTreeState.effect());
123 DCHECK_EQ(borderBox->propertyTreeState.scroll(),
124 objectBorderBox->propertyTreeState.scroll());
125 } else {
126 DCHECK_EQ(!!borderBox, !!objectBorderBox);
127 }
128 } else {
129 DCHECK_EQ(!!m_properties, !!objectProperties);
130 }
131 // Restore original clean bit.
132 const_cast<LayoutObject&>(m_object).clearNeedsPaintPropertyUpdate();
133 }
134
135 private:
136 const LayoutObject& m_object;
137 bool m_neededPaintPropertyUpdate;
138 std::unique_ptr<const ObjectPaintProperties> m_properties;
139 };
140
141 } // namespace blink
142 #endif // DCHECK_IS_ON()
143
144 #endif // FindPropertiesNeedingUpdate_h
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/paint/BUILD.gn ('k') | third_party/WebKit/Source/core/paint/ObjectPaintProperties.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698