Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 PropertyTreeState_h | 5 #ifndef PropertyTreeState_h |
| 6 #define PropertyTreeState_h | 6 #define PropertyTreeState_h |
| 7 | 7 |
| 8 #include "platform/graphics/paint/ClipPaintPropertyNode.h" | 8 #include "platform/graphics/paint/ClipPaintPropertyNode.h" |
| 9 #include "platform/graphics/paint/EffectPaintPropertyNode.h" | 9 #include "platform/graphics/paint/EffectPaintPropertyNode.h" |
| 10 #include "platform/graphics/paint/ScrollPaintPropertyNode.h" | 10 #include "platform/graphics/paint/ScrollPaintPropertyNode.h" |
| 11 #include "platform/graphics/paint/TransformPaintPropertyNode.h" | 11 #include "platform/graphics/paint/TransformPaintPropertyNode.h" |
| 12 #include "wtf/HashFunctions.h" | 12 #include "wtf/HashFunctions.h" |
| 13 #include "wtf/HashTraits.h" | 13 #include "wtf/HashTraits.h" |
| 14 | 14 |
| 15 namespace blink { | 15 namespace blink { |
| 16 | 16 |
| 17 // A complete set of paint properties including those that are inherited from | 17 // A complete set of paint properties including those that are inherited from |
| 18 // other objects. RefPtrs are used to guard against use-after-free bugs and | 18 // other objects. RefPtrs are used to guard against use-after-free bugs and |
| 19 // DCHECKs ensure PropertyTreeState never retains the last reference to a | 19 // DCHECKs ensure PropertyTreeState never retains the last reference to a |
| 20 // property tree node. | 20 // property tree node. |
| 21 class PropertyTreeState { | 21 class PLATFORM_EXPORT PropertyTreeState { |
| 22 public: | 22 public: |
| 23 PropertyTreeState(const TransformPaintPropertyNode* transform, | 23 PropertyTreeState(const TransformPaintPropertyNode* transform, |
| 24 const ClipPaintPropertyNode* clip, | 24 const ClipPaintPropertyNode* clip, |
| 25 const EffectPaintPropertyNode* effect, | 25 const EffectPaintPropertyNode* effect, |
| 26 const ScrollPaintPropertyNode* scroll) | 26 const ScrollPaintPropertyNode* scroll) |
| 27 : m_transform(transform), | 27 : m_transform(transform), |
| 28 m_clip(clip), | 28 m_clip(clip), |
| 29 m_effect(effect), | 29 m_effect(effect), |
| 30 m_scroll(scroll) { | 30 m_scroll(scroll) { |
| 31 DCHECK(!m_transform || !m_transform->hasOneRef()); | 31 DCHECK(!m_transform || !m_transform->hasOneRef()); |
| 32 DCHECK(!m_clip || !m_clip->hasOneRef()); | 32 DCHECK(!m_clip || !m_clip->hasOneRef()); |
| 33 DCHECK(!m_effect || !m_effect->hasOneRef()); | 33 DCHECK(!m_effect || !m_effect->hasOneRef()); |
| 34 DCHECK(!m_scroll || !m_scroll->hasOneRef()); | 34 DCHECK(!m_scroll || !m_scroll->hasOneRef()); |
| 35 } | 35 } |
| 36 | 36 |
| 37 bool hasDirectCompositingReasons() const; | |
| 38 | |
| 37 const TransformPaintPropertyNode* transform() const { | 39 const TransformPaintPropertyNode* transform() const { |
| 38 DCHECK(!m_transform || !m_transform->hasOneRef()); | 40 DCHECK(!m_transform || !m_transform->hasOneRef()); |
| 39 return m_transform.get(); | 41 return m_transform.get(); |
| 40 } | 42 } |
| 41 void setTransform(const TransformPaintPropertyNode* node) { | 43 void setTransform(const TransformPaintPropertyNode* node) { |
| 42 m_transform = node; | 44 m_transform = node; |
| 43 DCHECK(!node->hasOneRef()); | 45 DCHECK(!node->hasOneRef()); |
| 44 } | 46 } |
| 45 | 47 |
| 46 const ClipPaintPropertyNode* clip() const { | 48 const ClipPaintPropertyNode* clip() const { |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 63 | 65 |
| 64 const ScrollPaintPropertyNode* scroll() const { | 66 const ScrollPaintPropertyNode* scroll() const { |
| 65 DCHECK(!m_scroll || !m_scroll->hasOneRef()); | 67 DCHECK(!m_scroll || !m_scroll->hasOneRef()); |
| 66 return m_scroll.get(); | 68 return m_scroll.get(); |
| 67 } | 69 } |
| 68 void setScroll(const ScrollPaintPropertyNode* node) { | 70 void setScroll(const ScrollPaintPropertyNode* node) { |
| 69 m_scroll = node; | 71 m_scroll = node; |
| 70 DCHECK(!node->hasOneRef()); | 72 DCHECK(!node->hasOneRef()); |
| 71 } | 73 } |
| 72 | 74 |
| 75 enum InnermostNode { | |
| 76 None, // None means that all nodes are their root values | |
| 77 Transform, | |
| 78 Clip, | |
| 79 Effect, | |
| 80 }; | |
| 81 | |
| 82 InnermostNode innermostNode() const; | |
|
pdr.
2016/12/20 06:46:30
Please add a comment describing this and the itera
chrishtr
2016/12/20 23:36:32
Done.
The innermostNode is the first of the trans
trchen
2016/12/20 23:49:37
The canonical order is:
chunk.transform.screen_mat
chrishtr
2016/12/20 23:58:10
I'm not sure what your point is here. Is there a b
| |
| 83 | |
| 73 private: | 84 private: |
| 74 RefPtr<const TransformPaintPropertyNode> m_transform; | 85 RefPtr<const TransformPaintPropertyNode> m_transform; |
| 75 RefPtr<const ClipPaintPropertyNode> m_clip; | 86 RefPtr<const ClipPaintPropertyNode> m_clip; |
| 76 RefPtr<const EffectPaintPropertyNode> m_effect; | 87 RefPtr<const EffectPaintPropertyNode> m_effect; |
| 77 RefPtr<const ScrollPaintPropertyNode> m_scroll; | 88 RefPtr<const ScrollPaintPropertyNode> m_scroll; |
| 78 }; | 89 }; |
| 79 | 90 |
| 80 inline bool operator==(const PropertyTreeState& a, const PropertyTreeState& b) { | 91 inline bool operator==(const PropertyTreeState& a, const PropertyTreeState& b) { |
| 81 return a.transform() == b.transform() && a.clip() == b.clip() && | 92 return a.transform() == b.transform() && a.clip() == b.clip() && |
| 82 a.effect() == b.effect() && a.scroll() == b.scroll(); | 93 a.effect() == b.effect() && a.scroll() == b.scroll(); |
| 83 } | 94 } |
| 84 | 95 |
| 96 class PLATFORM_EXPORT PropertyTreeStateIterator { | |
|
pdr.
2016/12/20 22:50:58
Can you add a comment or file a bug about the inva
chrishtr
2016/12/20 23:48:31
These asserts are a good idea, will add them in an
| |
| 97 public: | |
| 98 PropertyTreeStateIterator(const PropertyTreeState& properties) | |
| 99 : m_properties(properties) {} | |
| 100 const PropertyTreeState* next(); | |
| 101 | |
| 102 private: | |
| 103 PropertyTreeState m_properties; | |
| 104 }; | |
| 105 | |
| 85 } // namespace blink | 106 } // namespace blink |
| 86 | 107 |
| 87 #endif // PropertyTreeState_h | 108 #endif // PropertyTreeState_h |
| OLD | NEW |