| 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" | |
| 11 #include "platform/graphics/paint/TransformPaintPropertyNode.h" | 10 #include "platform/graphics/paint/TransformPaintPropertyNode.h" |
| 12 #include "wtf/HashFunctions.h" | 11 #include "wtf/HashFunctions.h" |
| 13 #include "wtf/HashTraits.h" | 12 #include "wtf/HashTraits.h" |
| 14 #include "wtf/text/StringBuilder.h" | 13 #include "wtf/text/StringBuilder.h" |
| 15 | 14 |
| 16 namespace blink { | 15 namespace blink { |
| 17 | 16 |
| 18 // 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 |
| 19 // 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 |
| 20 // DCHECKs ensure PropertyTreeState never retains the last reference to a | 19 // DCHECKs ensure PropertyTreeState never retains the last reference to a |
| 21 // property tree node. | 20 // property tree node. |
| 22 class PLATFORM_EXPORT PropertyTreeState { | 21 class PLATFORM_EXPORT PropertyTreeState { |
| 23 public: | 22 public: |
| 24 PropertyTreeState(const TransformPaintPropertyNode* transform, | 23 PropertyTreeState(const TransformPaintPropertyNode* transform, |
| 25 const ClipPaintPropertyNode* clip, | 24 const ClipPaintPropertyNode* clip, |
| 26 const EffectPaintPropertyNode* effect, | 25 const EffectPaintPropertyNode* effect) |
| 27 const ScrollPaintPropertyNode* scroll) | 26 : m_transform(transform), m_clip(clip), m_effect(effect) { |
| 28 : m_transform(transform), | |
| 29 m_clip(clip), | |
| 30 m_effect(effect), | |
| 31 m_scroll(scroll) { | |
| 32 DCHECK(!m_transform || !m_transform->hasOneRef()); | 27 DCHECK(!m_transform || !m_transform->hasOneRef()); |
| 33 DCHECK(!m_clip || !m_clip->hasOneRef()); | 28 DCHECK(!m_clip || !m_clip->hasOneRef()); |
| 34 DCHECK(!m_effect || !m_effect->hasOneRef()); | 29 DCHECK(!m_effect || !m_effect->hasOneRef()); |
| 35 DCHECK(!m_scroll || !m_scroll->hasOneRef()); | |
| 36 } | 30 } |
| 37 | 31 |
| 38 bool hasDirectCompositingReasons() const; | 32 bool hasDirectCompositingReasons() const; |
| 39 | 33 |
| 40 const TransformPaintPropertyNode* transform() const { | 34 const TransformPaintPropertyNode* transform() const { |
| 41 DCHECK(!m_transform || !m_transform->hasOneRef()); | 35 DCHECK(!m_transform || !m_transform->hasOneRef()); |
| 42 return m_transform.get(); | 36 return m_transform.get(); |
| 43 } | 37 } |
| 44 void setTransform(RefPtr<const TransformPaintPropertyNode> node) { | 38 void setTransform(RefPtr<const TransformPaintPropertyNode> node) { |
| 45 m_transform = std::move(node); | 39 m_transform = std::move(node); |
| 46 } | 40 } |
| 47 | 41 |
| 48 const ClipPaintPropertyNode* clip() const { | 42 const ClipPaintPropertyNode* clip() const { |
| 49 DCHECK(!m_clip || !m_clip->hasOneRef()); | 43 DCHECK(!m_clip || !m_clip->hasOneRef()); |
| 50 return m_clip.get(); | 44 return m_clip.get(); |
| 51 } | 45 } |
| 52 void setClip(RefPtr<const ClipPaintPropertyNode> node) { | 46 void setClip(RefPtr<const ClipPaintPropertyNode> node) { |
| 53 m_clip = std::move(node); | 47 m_clip = std::move(node); |
| 54 } | 48 } |
| 55 | 49 |
| 56 const EffectPaintPropertyNode* effect() const { | 50 const EffectPaintPropertyNode* effect() const { |
| 57 DCHECK(!m_effect || !m_effect->hasOneRef()); | 51 DCHECK(!m_effect || !m_effect->hasOneRef()); |
| 58 return m_effect.get(); | 52 return m_effect.get(); |
| 59 } | 53 } |
| 60 void setEffect(RefPtr<const EffectPaintPropertyNode> node) { | 54 void setEffect(RefPtr<const EffectPaintPropertyNode> node) { |
| 61 m_effect = std::move(node); | 55 m_effect = std::move(node); |
| 62 } | 56 } |
| 63 | 57 |
| 64 const ScrollPaintPropertyNode* scroll() const { | 58 // Returns the compositor element id, if any, for this property state. If |
| 65 DCHECK(!m_scroll || !m_scroll->hasOneRef()); | 59 // neither the effect nor transform nodes have a compositor element id then a |
| 66 return m_scroll.get(); | 60 // default instance is returned. |
| 67 } | |
| 68 void setScroll(RefPtr<const ScrollPaintPropertyNode> node) { | |
| 69 m_scroll = std::move(node); | |
| 70 } | |
| 71 | |
| 72 // Returns the compositor element id, if any, for this property state. If none | |
| 73 // of the scroll, effect or transform nodes for this state have a compositor | |
| 74 // element id then a default instance is returned. | |
| 75 const CompositorElementId compositorElementId() const; | 61 const CompositorElementId compositorElementId() const; |
| 76 | 62 |
| 77 enum InnermostNode { | 63 enum InnermostNode { |
| 78 None, // None means that all nodes are their root values | 64 None, // None means that all nodes are their root values |
| 79 Transform, | 65 Transform, |
| 80 Clip, | 66 Clip, |
| 81 Effect, | 67 Effect, |
| 82 }; | 68 }; |
| 83 | 69 |
| 84 // There is always a well-defined order in which the transform, clip | 70 // There is always a well-defined order in which the transform, clip |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 | 106 |
| 121 #if DCHECK_IS_ON() | 107 #if DCHECK_IS_ON() |
| 122 // Dumps the tree from this state up to the root as a string. | 108 // Dumps the tree from this state up to the root as a string. |
| 123 String toTreeString() const; | 109 String toTreeString() const; |
| 124 #endif | 110 #endif |
| 125 | 111 |
| 126 private: | 112 private: |
| 127 RefPtr<const TransformPaintPropertyNode> m_transform; | 113 RefPtr<const TransformPaintPropertyNode> m_transform; |
| 128 RefPtr<const ClipPaintPropertyNode> m_clip; | 114 RefPtr<const ClipPaintPropertyNode> m_clip; |
| 129 RefPtr<const EffectPaintPropertyNode> m_effect; | 115 RefPtr<const EffectPaintPropertyNode> m_effect; |
| 130 // TODO(pdr): Remove the scroll node from PropertyTreeState. | |
| 131 RefPtr<const ScrollPaintPropertyNode> m_scroll; | |
| 132 }; | 116 }; |
| 133 | 117 |
| 134 inline bool operator==(const PropertyTreeState& a, const PropertyTreeState& b) { | 118 inline bool operator==(const PropertyTreeState& a, const PropertyTreeState& b) { |
| 135 return a.transform() == b.transform() && a.clip() == b.clip() && | 119 return a.transform() == b.transform() && a.clip() == b.clip() && |
| 136 a.effect() == b.effect() && a.scroll() == b.scroll(); | 120 a.effect() == b.effect(); |
| 137 } | 121 } |
| 138 | 122 |
| 139 // Iterates over the sequence transforms, clips and effects for a | 123 // Iterates over the sequence transforms, clips and effects for a |
| 140 // PropertyTreeState between that state and the "root" state (all nodes equal | 124 // PropertyTreeState between that state and the "root" state (all nodes equal |
| 141 // to *::Root()), in the order that they apply. | 125 // to *::Root()), in the order that they apply. |
| 142 // | 126 // |
| 143 // See also PropertyTreeState::innermostNode for a more detailed example. | 127 // See also PropertyTreeState::innermostNode for a more detailed example. |
| 144 class PLATFORM_EXPORT PropertyTreeStateIterator { | 128 class PLATFORM_EXPORT PropertyTreeStateIterator { |
| 145 public: | 129 public: |
| 146 PropertyTreeStateIterator(const PropertyTreeState& properties) | 130 PropertyTreeStateIterator(const PropertyTreeState& properties) |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 192 } | 176 } |
| 193 | 177 |
| 194 HashMap<const PropertyTreeNode*, String> m_nodeToDebugString; | 178 HashMap<const PropertyTreeNode*, String> m_nodeToDebugString; |
| 195 }; | 179 }; |
| 196 | 180 |
| 197 #endif | 181 #endif |
| 198 | 182 |
| 199 } // namespace blink | 183 } // namespace blink |
| 200 | 184 |
| 201 #endif // PropertyTreeState_h | 185 #endif // PropertyTreeState_h |
| OLD | NEW |