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

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

Issue 2621193006: Reduce PropertyTreeState construction and copies (Closed)
Patch Set: Created 3 years, 11 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
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/paint/ObjectPaintProperties.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #ifndef ObjectPaintProperties_h 5 #ifndef ObjectPaintProperties_h
6 #define ObjectPaintProperties_h 6 #define ObjectPaintProperties_h
7 7
8 #include "core/CoreExport.h" 8 #include "core/CoreExport.h"
9 #include "platform/geometry/LayoutPoint.h" 9 #include "platform/geometry/LayoutPoint.h"
10 #include "platform/graphics/paint/ClipPaintPropertyNode.h" 10 #include "platform/graphics/paint/ClipPaintPropertyNode.h"
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 // instead point to the transform space setup by div's ancestors. 127 // instead point to the transform space setup by div's ancestors.
128 const PropertyTreeState* localBorderBoxProperties() const { 128 const PropertyTreeState* localBorderBoxProperties() const {
129 return m_localBorderBoxProperties.get(); 129 return m_localBorderBoxProperties.get();
130 } 130 }
131 131
132 // This is the complete set of property nodes and paint offset that can be 132 // This is the complete set of property nodes and paint offset that can be
133 // used to paint the contents of this object. It is similar to 133 // used to paint the contents of this object. It is similar to
134 // localBorderBoxProperties but includes properties (e.g., overflow clip, 134 // localBorderBoxProperties but includes properties (e.g., overflow clip,
135 // scroll translation) that apply to contents. This is suitable for paint 135 // scroll translation) that apply to contents. This is suitable for paint
136 // invalidation. 136 // invalidation.
137 PropertyTreeState contentsProperties() const; 137 const PropertyTreeState* contentsProperties() const {
138 if (!m_contentsProperties) {
139 if (!m_localBorderBoxProperties)
140 return nullptr;
141 updateContentsProperties();
142 } else {
143 #if DCHECK_IS_ON()
144 // Check if the cached m_contentsProperties is valid.
145 DCHECK(m_localBorderBoxProperties);
146 std::unique_ptr<PropertyTreeState> oldProperties =
147 std::move(m_contentsProperties);
148 updateContentsProperties();
149 DCHECK(*m_contentsProperties == *oldProperties);
150 #endif
151 }
152 return m_contentsProperties.get();
153 };
138 154
139 void updateLocalBorderBoxProperties( 155 void updateLocalBorderBoxProperties(
140 const TransformPaintPropertyNode* transform, 156 const TransformPaintPropertyNode* transform,
141 const ClipPaintPropertyNode* clip, 157 const ClipPaintPropertyNode* clip,
142 const EffectPaintPropertyNode* effect, 158 const EffectPaintPropertyNode* effect,
143 const ScrollPaintPropertyNode* scroll) { 159 const ScrollPaintPropertyNode* scroll) {
144 if (m_localBorderBoxProperties) { 160 if (m_localBorderBoxProperties) {
145 m_localBorderBoxProperties->setTransform(transform); 161 m_localBorderBoxProperties->setTransform(transform);
146 m_localBorderBoxProperties->setClip(clip); 162 m_localBorderBoxProperties->setClip(clip);
147 m_localBorderBoxProperties->setEffect(effect); 163 m_localBorderBoxProperties->setEffect(effect);
148 m_localBorderBoxProperties->setScroll(scroll); 164 m_localBorderBoxProperties->setScroll(scroll);
149 } else { 165 } else {
150 m_localBorderBoxProperties = WTF::wrapUnique(new PropertyTreeState( 166 m_localBorderBoxProperties = WTF::wrapUnique(new PropertyTreeState(
151 PropertyTreeState(transform, clip, effect, scroll))); 167 PropertyTreeState(transform, clip, effect, scroll)));
152 } 168 }
169 m_contentsProperties = nullptr;
153 } 170 }
154 void clearLocalBorderBoxProperties() { m_localBorderBoxProperties = nullptr; } 171 void clearLocalBorderBoxProperties() {
172 m_localBorderBoxProperties = nullptr;
173 m_contentsProperties = nullptr;
174 }
155 175
156 // The following clear* functions return true if the property tree structure 176 // The following clear* functions return true if the property tree structure
157 // changes (an existing node was deleted), and false otherwise. See the 177 // changes (an existing node was deleted), and false otherwise. See the
158 // class-level comment ("update & clear implementation note") for details 178 // class-level comment ("update & clear implementation note") for details
159 // about why this is needed for efficient updates. 179 // about why this is needed for efficient updates.
160 bool clearPaintOffsetTranslation() { return clear(m_paintOffsetTranslation); } 180 bool clearPaintOffsetTranslation() { return clear(m_paintOffsetTranslation); }
161 bool clearTransform() { return clear(m_transform); } 181 bool clearTransform() { return clear(m_transform); }
162 bool clearEffect() { return clear(m_effect); } 182 bool clearEffect() { return clear(m_effect); }
163 bool clearCssClip() { return clear(m_cssClip); } 183 bool clearCssClip() { return clear(m_cssClip); }
164 bool clearCssClipFixedPosition() { return clear(m_cssClipFixedPosition); } 184 bool clearCssClipFixedPosition() { return clear(m_cssClipFixedPosition); }
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
290 template <typename PaintPropertyNode, typename... Args> 310 template <typename PaintPropertyNode, typename... Args>
291 bool update(RefPtr<PaintPropertyNode>& field, Args&&... args) { 311 bool update(RefPtr<PaintPropertyNode>& field, Args&&... args) {
292 if (field) { 312 if (field) {
293 field->update(std::forward<Args>(args)...); 313 field->update(std::forward<Args>(args)...);
294 return false; 314 return false;
295 } 315 }
296 field = PaintPropertyNode::create(std::forward<Args>(args)...); 316 field = PaintPropertyNode::create(std::forward<Args>(args)...);
297 return true; 317 return true;
298 } 318 }
299 319
320 void updateContentsProperties() const;
321
300 RefPtr<TransformPaintPropertyNode> m_paintOffsetTranslation; 322 RefPtr<TransformPaintPropertyNode> m_paintOffsetTranslation;
301 RefPtr<TransformPaintPropertyNode> m_transform; 323 RefPtr<TransformPaintPropertyNode> m_transform;
302 RefPtr<EffectPaintPropertyNode> m_effect; 324 RefPtr<EffectPaintPropertyNode> m_effect;
303 RefPtr<ClipPaintPropertyNode> m_cssClip; 325 RefPtr<ClipPaintPropertyNode> m_cssClip;
304 RefPtr<ClipPaintPropertyNode> m_cssClipFixedPosition; 326 RefPtr<ClipPaintPropertyNode> m_cssClipFixedPosition;
305 RefPtr<ClipPaintPropertyNode> m_innerBorderRadiusClip; 327 RefPtr<ClipPaintPropertyNode> m_innerBorderRadiusClip;
306 RefPtr<ClipPaintPropertyNode> m_overflowClip; 328 RefPtr<ClipPaintPropertyNode> m_overflowClip;
307 RefPtr<TransformPaintPropertyNode> m_perspective; 329 RefPtr<TransformPaintPropertyNode> m_perspective;
308 // TODO(pdr): Only LayoutSVGRoot needs this and it should be moved there. 330 // TODO(pdr): Only LayoutSVGRoot needs this and it should be moved there.
309 RefPtr<TransformPaintPropertyNode> m_svgLocalToBorderBoxTransform; 331 RefPtr<TransformPaintPropertyNode> m_svgLocalToBorderBoxTransform;
310 RefPtr<TransformPaintPropertyNode> m_scrollTranslation; 332 RefPtr<TransformPaintPropertyNode> m_scrollTranslation;
311 RefPtr<TransformPaintPropertyNode> m_scrollbarPaintOffset; 333 RefPtr<TransformPaintPropertyNode> m_scrollbarPaintOffset;
312 RefPtr<ScrollPaintPropertyNode> m_scroll; 334 RefPtr<ScrollPaintPropertyNode> m_scroll;
313 335
314 std::unique_ptr<PropertyTreeState> m_localBorderBoxProperties; 336 std::unique_ptr<PropertyTreeState> m_localBorderBoxProperties;
337 mutable std::unique_ptr<PropertyTreeState> m_contentsProperties;
315 }; 338 };
316 339
317 } // namespace blink 340 } // namespace blink
318 341
319 #endif // ObjectPaintProperties_h 342 #endif // ObjectPaintProperties_h
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/paint/ObjectPaintProperties.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698