| OLD | NEW |
| (Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef PropertyTreeManager_h |
| 6 #define PropertyTreeManager_h |
| 7 |
| 8 #include "wtf/HashMap.h" |
| 9 #include "wtf/HashSet.h" |
| 10 #include "wtf/Noncopyable.h" |
| 11 #include "wtf/Vector.h" |
| 12 |
| 13 namespace cc { |
| 14 class ClipTree; |
| 15 class EffectTree; |
| 16 class Layer; |
| 17 class PropertyTrees; |
| 18 class ScrollTree; |
| 19 class TransformTree; |
| 20 } |
| 21 |
| 22 namespace blink { |
| 23 |
| 24 class ClipPaintPropertyNode; |
| 25 class EffectPaintPropertyNode; |
| 26 class ScrollPaintPropertyNode; |
| 27 class TransformPaintPropertyNode; |
| 28 |
| 29 // Mutates a cc property tree to reflect Blink paint property tree |
| 30 // state. Intended for use by PaintArtifactCompositor. |
| 31 class PropertyTreeManager { |
| 32 WTF_MAKE_NONCOPYABLE(PropertyTreeManager); |
| 33 |
| 34 public: |
| 35 PropertyTreeManager(cc::PropertyTrees&, cc::Layer* rootLayer); |
| 36 |
| 37 static constexpr int kPropertyTreeSequenceNumber = 1; |
| 38 |
| 39 void setupRootTransformNode(); |
| 40 void setupRootClipNode(); |
| 41 void setupRootEffectNode(); |
| 42 void setupRootScrollNode(); |
| 43 |
| 44 // A brief discourse on cc property tree nodes, identifiers, and current and |
| 45 // future design evolution envisioned: |
| 46 // |
| 47 // cc property trees identify nodes by their |id|, which implementation-wise |
| 48 // is actually its index in the property tree's vector of its node type. More |
| 49 // recent cc code now refers to these as 'node indices', or 'property tree |
| 50 // indices'. |parent_id| is the same sort of 'node index' of that node's |
| 51 // parent. |
| 52 // |
| 53 // Note there are two other primary types of 'ids' referenced in cc property |
| 54 // tree related logic: (1) ElementId, also known Blink-side as |
| 55 // CompositorElementId, used by the animation system to allow tying an element |
| 56 // to its respective layer, and (2) layer ids. There are other ancillary ids |
| 57 // not relevant to any of the above, such as |
| 58 // cc::TransformNode::sorting_context_id |
| 59 // (a.k.a. blink::TransformPaintPropertyNode::renderingContextId()). |
| 60 // |
| 61 // There is a vision to move toward a world where cc property nodes have no |
| 62 // association with layers and instead have a |stable_id|. The id could come |
| 63 // from an ElementId in turn derived from the layout object responsible for |
| 64 // creating the property node. |
| 65 // |
| 66 // We would also like to explore moving to use a single shared property tree |
| 67 // representation across both cc and Blink. See |
| 68 // platform/graphics/paint/README.md for more. |
| 69 // |
| 70 // With the above as background, we can now state more clearly a description |
| 71 // of the below set of compositor node methods: they take Blink paint property |
| 72 // tree nodes as input, create a corresponding compositor property tree node |
| 73 // if none yet exists, and return the compositor node's 'node id', a.k.a., |
| 74 // 'node index'. |
| 75 |
| 76 int ensureCompositorTransformNode(const TransformPaintPropertyNode*); |
| 77 int ensureCompositorClipNode(const ClipPaintPropertyNode*); |
| 78 int ensureCompositorScrollNode(const ScrollPaintPropertyNode*); |
| 79 |
| 80 int switchToEffectNode(const EffectPaintPropertyNode& nextEffect); |
| 81 int getCurrentCompositorEffectNodeIndex() const { |
| 82 return m_effectStack.back().id; |
| 83 } |
| 84 |
| 85 // Scroll offset has special treatment in the transform and scroll trees. |
| 86 void updateScrollOffset(int layerId, int scrollId); |
| 87 |
| 88 private: |
| 89 void buildEffectNodesRecursively(const EffectPaintPropertyNode* nextEffect); |
| 90 |
| 91 cc::TransformTree& transformTree(); |
| 92 cc::ClipTree& clipTree(); |
| 93 cc::EffectTree& effectTree(); |
| 94 cc::ScrollTree& scrollTree(); |
| 95 |
| 96 const EffectPaintPropertyNode* currentEffectNode() const; |
| 97 |
| 98 // Property trees which should be updated by the manager. |
| 99 cc::PropertyTrees& m_propertyTrees; |
| 100 |
| 101 // Layer to which transform "owner" layers should be added. These will not |
| 102 // have any actual children, but at present must exist in the tree. |
| 103 cc::Layer* m_rootLayer; |
| 104 |
| 105 // Maps from Blink-side property tree nodes to cc property node indices. |
| 106 HashMap<const TransformPaintPropertyNode*, int> m_transformNodeMap; |
| 107 HashMap<const ClipPaintPropertyNode*, int> m_clipNodeMap; |
| 108 HashMap<const ScrollPaintPropertyNode*, int> m_scrollNodeMap; |
| 109 |
| 110 struct BlinkEffectAndCcIdPair { |
| 111 const EffectPaintPropertyNode* effect; |
| 112 // The cc property tree effect node id, or 'node index', for the cc effect |
| 113 // node corresponding to the above Blink effect paint property node. |
| 114 int id; |
| 115 }; |
| 116 Vector<BlinkEffectAndCcIdPair> m_effectStack; |
| 117 |
| 118 #if DCHECK_IS_ON() |
| 119 HashSet<const EffectPaintPropertyNode*> m_effectNodesConverted; |
| 120 #endif |
| 121 }; |
| 122 |
| 123 } // namespace blink |
| 124 |
| 125 #endif // PropertyTreeManager_h |
| OLD | NEW |