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

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

Issue 2183403002: cc: Move data to LayerTree from LayerTreeHost. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@layer_tree_change
Patch Set: .. 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 <memory>
9
8 #include <unordered_map> 10 #include <unordered_map>
9 #include <unordered_set> 11 #include <unordered_set>
12 #include "base/macros.h"
13 #include "base/memory/ref_counted.h"
14 #include "cc/base/cc_export.h"
15 #include "cc/input/event_listener_properties.h"
16 #include "cc/input/layer_selection_bound.h"
17 #include "cc/layers/layer_collections.h"
18 #include "cc/trees/property_tree.h"
19 #include "third_party/skia/include/core/SkColor.h"
20 #include "ui/gfx/geometry/size.h"
10 21
11 #include "base/macros.h" 22 namespace base {
12 #include "cc/base/cc_export.h" 23 class TimeDelta;
24 } // namespace base
13 25
14 namespace cc { 26 namespace cc {
15 27
16 namespace proto { 28 namespace proto {
17 class LayerTree; 29 class LayerTree;
18 class LayerUpdate; 30 class LayerUpdate;
19 } 31 } // namespace proto
20 32
21 class AnimationHost; 33 class AnimationHost;
34 class HeadsUpDisplayLayer;
22 class Layer; 35 class Layer;
36 class LayerTreeHost;
37 class LayerTreeImpl;
38 struct PendingPageScaleAnimation;
23 39
24 class CC_EXPORT LayerTree { 40 class CC_EXPORT LayerTree {
25 public: 41 public:
26 using LayerSet = std::unordered_set<Layer*>; 42 using LayerSet = std::unordered_set<Layer*>;
27 using LayerIdMap = std::unordered_map<int, Layer*>; 43 using LayerIdMap = std::unordered_map<int, Layer*>;
28 44
29 explicit LayerTree(std::unique_ptr<AnimationHost> animation_host); 45 LayerTree(std::unique_ptr<AnimationHost> animation_host,
46 LayerTreeHost* layer_tree_host);
30 ~LayerTree(); 47 ~LayerTree();
31 48
49 void SetRootLayer(scoped_refptr<Layer> root_layer);
50 Layer* root_layer() { return inputs_.root_layer.get(); }
51 const Layer* root_layer() const { return inputs_.root_layer.get(); }
52
53 void RegisterViewportLayers(scoped_refptr<Layer> overscroll_elasticity_layer,
54 scoped_refptr<Layer> page_scale_layer,
55 scoped_refptr<Layer> inner_viewport_scroll_layer,
56 scoped_refptr<Layer> outer_viewport_scroll_layer);
57
58 Layer* overscroll_elasticity_layer() const {
59 return inputs_.overscroll_elasticity_layer.get();
60 }
61 Layer* page_scale_layer() const { return inputs_.page_scale_layer.get(); }
62 Layer* inner_viewport_scroll_layer() const {
63 return inputs_.inner_viewport_scroll_layer.get();
64 }
65 Layer* outer_viewport_scroll_layer() const {
66 return inputs_.outer_viewport_scroll_layer.get();
67 }
68
69 void RegisterSelection(const LayerSelection& selection);
70
71 void SetHaveScrollEventHandlers(bool have_event_handlers);
72 bool have_scroll_event_handlers() const {
73 return inputs_.have_scroll_event_handlers;
74 }
75
76 void SetEventListenerProperties(EventListenerClass event_class,
77 EventListenerProperties event_properties);
78 EventListenerProperties event_listener_properties(
79 EventListenerClass event_class) const {
80 return inputs_.event_listener_properties[static_cast<size_t>(event_class)];
81 }
82
83 void SetViewportSize(const gfx::Size& device_viewport_size);
84 gfx::Size device_viewport_size() const {
85 return inputs_.device_viewport_size;
86 }
87
88 void SetTopControlsHeight(float height, bool shrink);
89 void SetTopControlsShownRatio(float ratio);
90
91 void SetPageScaleFactorAndLimits(float page_scale_factor,
92 float min_page_scale_factor,
93 float max_page_scale_factor);
94 float page_scale_factor() const { return inputs_.page_scale_factor; }
95
96 void set_background_color(SkColor color) { inputs_.background_color = color; }
97 SkColor background_color() const { return inputs_.background_color; }
98
99 void set_has_transparent_background(bool transparent) {
100 inputs_.has_transparent_background = transparent;
101 }
102
103 void StartPageScaleAnimation(const gfx::Vector2d& target_offset,
104 bool use_anchor,
105 float scale,
106 base::TimeDelta duration);
107 bool HasPendingPageScaleAnimation() const;
108
109 void SetDeviceScaleFactor(float device_scale_factor);
110 float device_scale_factor() const { return inputs_.device_scale_factor; }
111
112 void SetPaintedDeviceScaleFactor(float painted_device_scale_factor);
113
114 AnimationHost* animation_host() const { return animation_host_.get(); }
115
116 // Used externally by blink for setting the PropertyTrees when
117 // |settings_.use_layer_lists| is true. This is a SPV2 setting.
118 PropertyTrees* property_trees() { return &property_trees_; }
119
120 // Methods which should only be used internally in cc ------------------
32 void RegisterLayer(Layer* layer); 121 void RegisterLayer(Layer* layer);
33 void UnregisterLayer(Layer* layer); 122 void UnregisterLayer(Layer* layer);
34 Layer* LayerById(int id) const; 123 Layer* LayerById(int id) const;
35 bool UpdateLayers(const LayerList& update_layer_list, 124 bool UpdateLayers(const LayerList& update_layer_list,
36 bool* content_is_suitable_for_gpu); 125 bool* content_is_suitable_for_gpu);
37 126
38 void AddLayerShouldPushProperties(Layer* layer); 127 void AddLayerShouldPushProperties(Layer* layer);
39 void RemoveLayerShouldPushProperties(Layer* layer); 128 void RemoveLayerShouldPushProperties(Layer* layer);
40 std::unordered_set<Layer*>& LayersThatShouldPushProperties(); 129 std::unordered_set<Layer*>& LayersThatShouldPushProperties();
41 bool LayerNeedsPushPropertiesForTesting(Layer* layer) const; 130 bool LayerNeedsPushPropertiesForTesting(Layer* layer) const;
42 131
132 virtual void SetNeedsMetaInfoRecomputation(
133 bool needs_meta_info_recomputation);
134 bool needs_meta_info_recomputation() const {
135 return needs_meta_info_recomputation_;
136 }
137
138 void SetPageScaleFromImplSide(float page_scale);
139
140 void UpdateHudLayer(bool show_hud_info);
141 HeadsUpDisplayLayer* hud_layer() const { return hud_layer_.get(); }
142
143 virtual void SetNeedsFullTreeSync();
144 bool needs_full_tree_sync() const { return needs_full_tree_sync_; }
145
146 void SetNeedsCommit();
147 void SetPropertyTreesNeedRebuild();
148
149 void PushPropertiesTo(LayerTreeImpl* tree_impl);
150
43 void ToProtobuf(proto::LayerTree* proto); 151 void ToProtobuf(proto::LayerTree* proto);
44 void FromProtobuf(const proto::LayerTree& proto); 152 void FromProtobuf(const proto::LayerTree& proto);
45 153
46 AnimationHost* animation_host() const { return animation_host_.get(); }
47
48 bool in_paint_layer_contents() const { return in_paint_layer_contents_; } 154 bool in_paint_layer_contents() const { return in_paint_layer_contents_; }
155 // ---------------------------------------------------------------------
49 156
50 private: 157 private:
51 friend class LayerTreeHostSerializationTest; 158 friend class LayerTreeHostSerializationTest;
52 159
160 // Encapsulates the data, callbacks, interfaces received from the embedder.
161 struct Inputs {
162 Inputs();
163 ~Inputs();
164
165 scoped_refptr<Layer> root_layer;
166
167 scoped_refptr<Layer> overscroll_elasticity_layer;
168 scoped_refptr<Layer> page_scale_layer;
169 scoped_refptr<Layer> inner_viewport_scroll_layer;
170 scoped_refptr<Layer> outer_viewport_scroll_layer;
171
172 float top_controls_height;
173 float top_controls_shown_ratio;
174 bool top_controls_shrink_blink_size;
175
176 float device_scale_factor;
177 float painted_device_scale_factor;
178 float page_scale_factor;
179 float min_page_scale_factor;
180 float max_page_scale_factor;
181
182 SkColor background_color;
183 bool has_transparent_background;
184
185 LayerSelection selection;
186
187 gfx::Size device_viewport_size;
188
189 bool have_scroll_event_handlers;
190 EventListenerProperties event_listener_properties[static_cast<size_t>(
191 EventListenerClass::kNumClasses)];
192
193 std::unique_ptr<PendingPageScaleAnimation> pending_page_scale_animation;
194 };
195
196 Inputs inputs_;
197
198 PropertyTrees property_trees_;
199
200 bool needs_full_tree_sync_;
201 bool needs_meta_info_recomputation_;
202
203 scoped_refptr<HeadsUpDisplayLayer> hud_layer_;
204
53 // Set of layers that need to push properties. 205 // Set of layers that need to push properties.
54 LayerSet layers_that_should_push_properties_; 206 LayerSet layers_that_should_push_properties_;
55 207
56 // Layer id to Layer map. 208 // Layer id to Layer map.
57 LayerIdMap layer_id_map_; 209 LayerIdMap layer_id_map_;
58 210
59 bool in_paint_layer_contents_; 211 bool in_paint_layer_contents_;
60 212
61 std::unique_ptr<AnimationHost> animation_host_; 213 std::unique_ptr<AnimationHost> animation_host_;
214 LayerTreeHost* layer_tree_host_;
62 215
63 DISALLOW_COPY_AND_ASSIGN(LayerTree); 216 DISALLOW_COPY_AND_ASSIGN(LayerTree);
64 }; 217 };
65 218
66 } // namespace cc 219 } // namespace cc
67 220
68 #endif // CC_TREES_LAYER_TREE_H_ 221 #endif // CC_TREES_LAYER_TREE_H_
OLDNEW
« no previous file with comments | « cc/test/layer_tree_test.cc ('k') | cc/trees/layer_tree.cc » ('j') | cc/trees/layer_tree_host.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698