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

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

Issue 2732573003: Skip paint property update and visual rect update if no geometry change (Closed)
Patch Set: - Created 3 years, 8 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 2016 The Chromium Authors. All rights reserved. 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 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 #ifndef FindPropertiesNeedingUpdate_h 5 #ifndef FindPropertiesNeedingUpdate_h
6 #define FindPropertiesNeedingUpdate_h 6 #define FindPropertiesNeedingUpdate_h
7 7
8 #if DCHECK_IS_ON() 8 #if DCHECK_IS_ON()
9
10 #include "core/frame/FrameView.h"
11 #include "core/layout/LayoutObject.h"
12 #include "core/paint/ObjectPaintProperties.h"
13 #include "core/paint/PaintPropertyTreeBuilder.h"
14
9 namespace blink { 15 namespace blink {
10 16
11 // This file contains two scope classes for catching cases where paint 17 // This file contains two scope classes for catching cases where paint
12 // properties needed an update but were not marked as such. If paint properties 18 // properties needed an update but were not marked as such. If paint properties
13 // will change, the object must be marked as needing a paint property update 19 // will change, the object must be marked as needing a paint property update
14 // using {FrameView, LayoutObject}::setNeedsPaintPropertyUpdate() or by forcing 20 // using {FrameView, LayoutObject}::setNeedsPaintPropertyUpdate() or by forcing
15 // a subtree update (see: PaintPropertyTreeBuilderContext::forceSubtreeUpdate). 21 // a subtree update (see: PaintPropertyTreeBuilderContext::forceSubtreeUpdate).
16 // 22 //
17 // Both scope classes work by recording the paint property state of an object 23 // Both scope classes work by recording the paint property state of an object
18 // before rebuilding properties, forcing the properties to get updated, then 24 // before rebuilding properties, forcing the properties to get updated, then
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 m_frameView->scrollTranslation()); 89 m_frameView->scrollTranslation());
84 90
85 // Restore original clean bit. 91 // Restore original clean bit.
86 m_frameView->clearNeedsPaintPropertyUpdate(); 92 m_frameView->clearNeedsPaintPropertyUpdate();
87 } 93 }
88 94
89 private: 95 private:
90 Persistent<FrameView> m_frameView; 96 Persistent<FrameView> m_frameView;
91 bool m_neededPaintPropertyUpdate; 97 bool m_neededPaintPropertyUpdate;
92 bool m_neededForcedSubtreeUpdate; 98 bool m_neededForcedSubtreeUpdate;
93 RefPtr<TransformPaintPropertyNode> m_originalPreTranslation; 99 RefPtr<const TransformPaintPropertyNode> m_originalPreTranslation;
94 RefPtr<ClipPaintPropertyNode> m_originalContentClip; 100 RefPtr<const ClipPaintPropertyNode> m_originalContentClip;
95 RefPtr<TransformPaintPropertyNode> m_originalScrollTranslation; 101 RefPtr<const TransformPaintPropertyNode> m_originalScrollTranslation;
96 }; 102 };
97 103
98 #define DCHECK_OBJECT_PROPERTY_EQ(object, original, updated) \ 104 #define DCHECK_OBJECT_PROPERTY_EQ(object, original, updated) \
99 CHECK_PROPERTY_EQ("the layout object (" << object.debugName() << ")", \ 105 CHECK_PROPERTY_EQ("the layout object (" << object.debugName() << ")", \
100 original, updated) 106 original, updated)
101 107
102 class FindObjectPropertiesNeedingUpdateScope { 108 class FindObjectPropertiesNeedingUpdateScope {
103 public: 109 public:
104 FindObjectPropertiesNeedingUpdateScope( 110 FindObjectPropertiesNeedingUpdateScope(
105 const LayoutObject& object, 111 const LayoutObject& object,
(...skipping 13 matching lines...) Expand all
119 if (const auto* properties = m_object.paintProperties()) 125 if (const auto* properties = m_object.paintProperties())
120 m_originalProperties = properties->clone(); 126 m_originalProperties = properties->clone();
121 127
122 if (const auto* localBorderBox = m_object.localBorderBoxProperties()) { 128 if (const auto* localBorderBox = m_object.localBorderBoxProperties()) {
123 m_originalLocalBorderBoxProperties = 129 m_originalLocalBorderBoxProperties =
124 WTF::wrapUnique(new PropertyTreeState(*localBorderBox)); 130 WTF::wrapUnique(new PropertyTreeState(*localBorderBox));
125 } 131 }
126 } 132 }
127 133
128 ~FindObjectPropertiesNeedingUpdateScope() { 134 ~FindObjectPropertiesNeedingUpdateScope() {
135 // Paint offset and paintOffsetTranslation should not change under
136 // FindObjectPropertiesNeedingUpdateScope no matter if we needed paint
137 // property update.
138 DCHECK_OBJECT_PROPERTY_EQ(m_object, &m_originalPaintOffset,
139 &m_object.paintOffset());
140 const auto* objectProperties = m_object.paintProperties();
141 if (m_originalProperties && objectProperties) {
142 DCHECK_OBJECT_PROPERTY_EQ(m_object,
143 m_originalProperties->paintOffsetTranslation(),
144 objectProperties->paintOffsetTranslation());
145 }
146
129 // No need to check if an update was already needed. 147 // No need to check if an update was already needed.
130 if (m_neededPaintPropertyUpdate || m_neededForcedSubtreeUpdate) 148 if (m_neededPaintPropertyUpdate || m_neededForcedSubtreeUpdate)
131 return; 149 return;
132 150
133 // If these checks fail, the paint properties changed unexpectedly. This is 151 // If these checks fail, the paint properties changed unexpectedly. This is
134 // due to missing one of these paint property invalidations: 152 // due to missing one of these paint property invalidations:
135 // 1) The LayoutObject should have been marked as needing an update with 153 // 1) The LayoutObject should have been marked as needing an update with
136 // LayoutObject::setNeedsPaintPropertyUpdate(). 154 // LayoutObject::setNeedsPaintPropertyUpdate().
137 // 2) The PrePaintTreeWalk should have had a forced subtree update (see: 155 // 2) The PrePaintTreeWalk should have had a forced subtree update (see:
138 // PaintPropertyTreeBuilderContext::forceSubtreeUpdate). 156 // PaintPropertyTreeBuilderContext::forceSubtreeUpdate).
139 DCHECK_OBJECT_PROPERTY_EQ(m_object, &m_originalPaintOffset,
140 &m_object.paintOffset());
141 const auto* objectProperties = m_object.paintProperties();
142 if (m_originalProperties && objectProperties) { 157 if (m_originalProperties && objectProperties) {
143 DCHECK_OBJECT_PROPERTY_EQ(m_object,
144 m_originalProperties->paintOffsetTranslation(),
145 objectProperties->paintOffsetTranslation());
146 DCHECK_OBJECT_PROPERTY_EQ(m_object, m_originalProperties->transform(), 158 DCHECK_OBJECT_PROPERTY_EQ(m_object, m_originalProperties->transform(),
147 objectProperties->transform()); 159 objectProperties->transform());
148 DCHECK_OBJECT_PROPERTY_EQ(m_object, m_originalProperties->effect(), 160 DCHECK_OBJECT_PROPERTY_EQ(m_object, m_originalProperties->effect(),
149 objectProperties->effect()); 161 objectProperties->effect());
150 DCHECK_OBJECT_PROPERTY_EQ(m_object, m_originalProperties->filter(), 162 DCHECK_OBJECT_PROPERTY_EQ(m_object, m_originalProperties->filter(),
151 objectProperties->filter()); 163 objectProperties->filter());
152 DCHECK_OBJECT_PROPERTY_EQ(m_object, m_originalProperties->mask(), 164 DCHECK_OBJECT_PROPERTY_EQ(m_object, m_originalProperties->mask(),
153 objectProperties->mask()); 165 objectProperties->mask());
154 DCHECK_OBJECT_PROPERTY_EQ(m_object, m_originalProperties->maskClip(), 166 DCHECK_OBJECT_PROPERTY_EQ(m_object, m_originalProperties->maskClip(),
155 objectProperties->maskClip()); 167 objectProperties->maskClip());
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 bool m_neededForcedSubtreeUpdate; 220 bool m_neededForcedSubtreeUpdate;
209 LayoutPoint m_originalPaintOffset; 221 LayoutPoint m_originalPaintOffset;
210 std::unique_ptr<const ObjectPaintProperties> m_originalProperties; 222 std::unique_ptr<const ObjectPaintProperties> m_originalProperties;
211 std::unique_ptr<const PropertyTreeState> m_originalLocalBorderBoxProperties; 223 std::unique_ptr<const PropertyTreeState> m_originalLocalBorderBoxProperties;
212 }; 224 };
213 225
214 } // namespace blink 226 } // namespace blink
215 #endif // DCHECK_IS_ON() 227 #endif // DCHECK_IS_ON()
216 228
217 #endif // FindPropertiesNeedingUpdate_h 229 #endif // FindPropertiesNeedingUpdate_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698