Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(415)

Side by Side Diff: cc/trees/layer_tree.h

Issue 2216203002: Refactor MutatorHostClient from LayerTreeHost to LayerTree. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixes according to code review. Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 RegisterElement(ElementId element_id,
56 ElementListType list_type,
57 Layer* layer);
58 void UnregisterElement(ElementId element_id,
59 ElementListType list_type,
60 Layer* layer);
61 void SetElementIdsForTesting();
62
63 // MutatorHostClient implementation.
64 bool IsElementInList(ElementId element_id,
65 ElementListType list_type) const override;
66 void SetMutatorsNeedCommit() override;
67 void SetMutatorsNeedRebuildPropertyTrees() override;
68 void SetElementFilterMutated(ElementId element_id,
69 ElementListType list_type,
70 const FilterOperations& filters) override;
71 void SetElementOpacityMutated(ElementId element_id,
72 ElementListType list_type,
73 float opacity) override;
74 void SetElementTransformMutated(ElementId element_id,
75 ElementListType list_type,
76 const gfx::Transform& transform) override;
77 void SetElementScrollOffsetMutated(
78 ElementId element_id,
79 ElementListType list_type,
80 const gfx::ScrollOffset& scroll_offset) override;
81 void ElementTransformIsAnimatingChanged(ElementId element_id,
82 ElementListType list_type,
83 AnimationChangeType change_type,
84 bool is_animating) override;
85 void ElementOpacityIsAnimatingChanged(ElementId element_id,
86 ElementListType list_type,
87 AnimationChangeType change_type,
88 bool is_animating) override;
89 void ElementFilterIsAnimatingChanged(ElementId element_id,
90 ElementListType list_type,
91 AnimationChangeType change_type,
92 bool is_animating) override;
93 void ScrollOffsetAnimationFinished() override {}
94 gfx::ScrollOffset GetScrollOffsetForAnimation(
95 ElementId element_id) const override;
96
97 // Layer iterators.
98 LayerListIterator<Layer> begin() const;
99 LayerListIterator<Layer> end() const;
100 LayerListReverseIterator<Layer> rbegin();
101 LayerListReverseIterator<Layer> rend();
102
103 void SetNeedsDisplayOnAllLayers();
104
50 private: 105 private:
51 friend class LayerTreeHostSerializationTest; 106 friend class LayerTreeHostSerializationTest;
52 107
53 // Set of layers that need to push properties. 108 // Set of layers that need to push properties.
54 LayerSet layers_that_should_push_properties_; 109 LayerSet layers_that_should_push_properties_;
55 110
56 // Layer id to Layer map. 111 // Layer id to Layer map.
57 LayerIdMap layer_id_map_; 112 LayerIdMap layer_id_map_;
58 113
114 using ElementLayersMap = std::unordered_map<ElementId, Layer*, ElementIdHash>;
115 ElementLayersMap element_layers_map_;
116
59 bool in_paint_layer_contents_; 117 bool in_paint_layer_contents_;
60 118
61 std::unique_ptr<AnimationHost> animation_host_; 119 std::unique_ptr<AnimationHost> animation_host_;
120 LayerTreeHost* layer_tree_host_;
62 121
63 DISALLOW_COPY_AND_ASSIGN(LayerTree); 122 DISALLOW_COPY_AND_ASSIGN(LayerTree);
64 }; 123 };
65 124
66 } // namespace cc 125 } // namespace cc
67 126
68 #endif // CC_TREES_LAYER_TREE_H_ 127 #endif // CC_TREES_LAYER_TREE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698