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 CC_TREES_LAYER_TREE_H_ | 5 #ifndef CC_TREES_LAYER_TREE_H_ |
6 #define CC_TREES_LAYER_TREE_H_ | 6 #define CC_TREES_LAYER_TREE_H_ |
7 | 7 |
8 #include <unordered_map> | 8 #include <unordered_map> |
9 #include <unordered_set> | 9 #include <unordered_set> |
10 | 10 |
11 #include "base/macros.h" | 11 #include "base/macros.h" |
12 #include "cc/base/cc_export.h" | 12 #include "cc/base/cc_export.h" |
13 #include "cc/layers/layer_list_iterator.h" | |
14 #include "cc/trees/mutator_host_client.h" | |
13 | 15 |
14 namespace cc { | 16 namespace cc { |
15 | 17 |
16 namespace proto { | 18 namespace proto { |
17 class LayerTree; | 19 class LayerTree; |
18 class LayerUpdate; | 20 class LayerUpdate; |
19 } | 21 } |
20 | 22 |
21 class AnimationHost; | 23 class AnimationHost; |
22 class Layer; | 24 class Layer; |
25 class LayerTreeHost; | |
23 | 26 |
24 class CC_EXPORT LayerTree { | 27 class CC_EXPORT LayerTree : public MutatorHostClient { |
25 public: | 28 public: |
26 using LayerSet = std::unordered_set<Layer*>; | 29 using LayerSet = std::unordered_set<Layer*>; |
27 using LayerIdMap = std::unordered_map<int, Layer*>; | 30 using LayerIdMap = std::unordered_map<int, Layer*>; |
28 | 31 |
29 explicit LayerTree(std::unique_ptr<AnimationHost> animation_host); | 32 LayerTree(std::unique_ptr<AnimationHost> animation_host, |
33 LayerTreeHost* layer_tree_host); | |
30 ~LayerTree(); | 34 ~LayerTree(); |
31 | 35 |
32 void RegisterLayer(Layer* layer); | 36 void RegisterLayer(Layer* layer); |
33 void UnregisterLayer(Layer* layer); | 37 void UnregisterLayer(Layer* layer); |
34 Layer* LayerById(int id) const; | 38 Layer* LayerById(int id) const; |
35 bool UpdateLayers(const LayerList& update_layer_list, | 39 bool UpdateLayers(const LayerList& update_layer_list, |
36 bool* content_is_suitable_for_gpu); | 40 bool* content_is_suitable_for_gpu); |
37 | 41 |
38 void AddLayerShouldPushProperties(Layer* layer); | 42 void AddLayerShouldPushProperties(Layer* layer); |
39 void RemoveLayerShouldPushProperties(Layer* layer); | 43 void RemoveLayerShouldPushProperties(Layer* layer); |
40 std::unordered_set<Layer*>& LayersThatShouldPushProperties(); | 44 std::unordered_set<Layer*>& LayersThatShouldPushProperties(); |
41 bool LayerNeedsPushPropertiesForTesting(Layer* layer) const; | 45 bool LayerNeedsPushPropertiesForTesting(Layer* layer) const; |
42 | 46 |
43 void ToProtobuf(proto::LayerTree* proto); | 47 void ToProtobuf(proto::LayerTree* proto); |
44 void FromProtobuf(const proto::LayerTree& proto); | 48 void FromProtobuf(const proto::LayerTree& proto); |
45 | 49 |
46 AnimationHost* animation_host() const { return animation_host_.get(); } | 50 AnimationHost* animation_host() const { return animation_host_.get(); } |
47 | 51 |
48 bool in_paint_layer_contents() const { return in_paint_layer_contents_; } | 52 bool in_paint_layer_contents() const { return in_paint_layer_contents_; } |
49 | 53 |
54 Layer* LayerByElementId(ElementId element_id) const; | |
55 void AddToElementMap(Layer* layer); | |
56 void RemoveFromElementMap(Layer* layer); | |
57 | |
58 // MutatorHostClient implementation. | |
Khushal
2016/08/15 17:46:39
Can this be implemented privately instead?
xingliu
2016/08/15 21:29:12
The interface functions are mainly called from cc/
Khushal
2016/08/16 05:37:17
You can still make the implementation here private
xingliu
2016/08/16 16:45:15
Oh, this is cool, fixed.
| |
59 bool IsElementInList(ElementId element_id, | |
60 ElementListType list_type) const override; | |
61 void SetMutatorsNeedCommit() override; | |
62 void SetMutatorsNeedRebuildPropertyTrees() override; | |
63 void SetElementFilterMutated(ElementId element_id, | |
64 ElementListType list_type, | |
65 const FilterOperations& filters) override; | |
66 void SetElementOpacityMutated(ElementId element_id, | |
67 ElementListType list_type, | |
68 float opacity) override; | |
69 void SetElementTransformMutated(ElementId element_id, | |
70 ElementListType list_type, | |
71 const gfx::Transform& transform) override; | |
72 void SetElementScrollOffsetMutated( | |
73 ElementId element_id, | |
74 ElementListType list_type, | |
75 const gfx::ScrollOffset& scroll_offset) override; | |
76 void ElementTransformIsAnimatingChanged(ElementId element_id, | |
77 ElementListType list_type, | |
78 AnimationChangeType change_type, | |
79 bool is_animating) override; | |
80 void ElementOpacityIsAnimatingChanged(ElementId element_id, | |
81 ElementListType list_type, | |
82 AnimationChangeType change_type, | |
83 bool is_animating) override; | |
84 void ElementFilterIsAnimatingChanged(ElementId element_id, | |
85 ElementListType list_type, | |
86 AnimationChangeType change_type, | |
87 bool is_animating) override; | |
88 void ScrollOffsetAnimationFinished() override {} | |
89 gfx::ScrollOffset GetScrollOffsetForAnimation( | |
90 ElementId element_id) const override; | |
91 | |
92 // Layer iterators. | |
93 LayerListIterator<Layer> begin() const; | |
94 LayerListIterator<Layer> end() const; | |
95 LayerListReverseIterator<Layer> rbegin(); | |
96 LayerListReverseIterator<Layer> rend(); | |
97 | |
50 private: | 98 private: |
51 friend class LayerTreeHostSerializationTest; | 99 friend class LayerTreeHostSerializationTest; |
52 | 100 |
53 // Set of layers that need to push properties. | 101 // Set of layers that need to push properties. |
54 LayerSet layers_that_should_push_properties_; | 102 LayerSet layers_that_should_push_properties_; |
55 | 103 |
56 // Layer id to Layer map. | 104 // Layer id to Layer map. |
57 LayerIdMap layer_id_map_; | 105 LayerIdMap layer_id_map_; |
58 | 106 |
107 using ElementLayersMap = std::unordered_map<ElementId, Layer*, ElementIdHash>; | |
108 ElementLayersMap element_layers_map_; | |
109 | |
59 bool in_paint_layer_contents_; | 110 bool in_paint_layer_contents_; |
60 | 111 |
61 std::unique_ptr<AnimationHost> animation_host_; | 112 std::unique_ptr<AnimationHost> animation_host_; |
113 LayerTreeHost* layer_tree_host_; | |
62 | 114 |
63 DISALLOW_COPY_AND_ASSIGN(LayerTree); | 115 DISALLOW_COPY_AND_ASSIGN(LayerTree); |
64 }; | 116 }; |
65 | 117 |
66 } // namespace cc | 118 } // namespace cc |
67 | 119 |
68 #endif // CC_TREES_LAYER_TREE_H_ | 120 #endif // CC_TREES_LAYER_TREE_H_ |
OLD | NEW |