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