| 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 <memory> | 8 #include <memory> |
| 9 | |
| 10 #include <unordered_map> | 9 #include <unordered_map> |
| 11 #include <unordered_set> | 10 #include <unordered_set> |
| 11 |
| 12 #include "base/macros.h" | 12 #include "base/macros.h" |
| 13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
| 14 #include "cc/base/cc_export.h" | 14 #include "cc/base/cc_export.h" |
| 15 #include "cc/input/event_listener_properties.h" | 15 #include "cc/input/event_listener_properties.h" |
| 16 #include "cc/input/layer_selection_bound.h" | 16 #include "cc/input/layer_selection_bound.h" |
| 17 #include "cc/layers/layer_collections.h" | 17 #include "cc/layers/layer_collections.h" |
| 18 #include "cc/layers/layer_list_iterator.h" |
| 19 #include "cc/trees/mutator_host_client.h" |
| 18 #include "cc/trees/property_tree.h" | 20 #include "cc/trees/property_tree.h" |
| 19 #include "third_party/skia/include/core/SkColor.h" | 21 #include "third_party/skia/include/core/SkColor.h" |
| 20 #include "ui/gfx/geometry/size.h" | 22 #include "ui/gfx/geometry/size.h" |
| 21 | 23 |
| 22 namespace base { | 24 namespace base { |
| 23 class TimeDelta; | 25 class TimeDelta; |
| 24 } // namespace base | 26 } // namespace base |
| 25 | 27 |
| 26 namespace cc { | 28 namespace cc { |
| 27 | 29 |
| 28 namespace proto { | 30 namespace proto { |
| 29 class LayerTree; | 31 class LayerTree; |
| 30 class LayerUpdate; | 32 class LayerUpdate; |
| 31 } // namespace proto | 33 } // namespace proto |
| 32 | 34 |
| 33 class AnimationHost; | 35 class AnimationHost; |
| 34 class HeadsUpDisplayLayer; | 36 class HeadsUpDisplayLayer; |
| 35 class Layer; | 37 class Layer; |
| 36 class LayerTreeHost; | 38 class LayerTreeHost; |
| 37 class LayerTreeImpl; | 39 class LayerTreeImpl; |
| 38 struct PendingPageScaleAnimation; | 40 struct PendingPageScaleAnimation; |
| 39 | 41 |
| 40 class CC_EXPORT LayerTree { | 42 class CC_EXPORT LayerTree : public MutatorHostClient { |
| 41 public: | 43 public: |
| 42 using LayerSet = std::unordered_set<Layer*>; | 44 using LayerSet = std::unordered_set<Layer*>; |
| 43 using LayerIdMap = std::unordered_map<int, Layer*>; | 45 using LayerIdMap = std::unordered_map<int, Layer*>; |
| 44 | 46 |
| 45 LayerTree(std::unique_ptr<AnimationHost> animation_host, | 47 LayerTree(std::unique_ptr<AnimationHost> animation_host, |
| 46 LayerTreeHost* layer_tree_host); | 48 LayerTreeHost* layer_tree_host); |
| 47 virtual ~LayerTree(); | 49 virtual ~LayerTree(); |
| 48 | 50 |
| 49 void SetRootLayer(scoped_refptr<Layer> root_layer); | 51 void SetRootLayer(scoped_refptr<Layer> root_layer); |
| 50 Layer* root_layer() { return inputs_.root_layer.get(); } | 52 Layer* root_layer() { return inputs_.root_layer.get(); } |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 bool use_anchor, | 106 bool use_anchor, |
| 105 float scale, | 107 float scale, |
| 106 base::TimeDelta duration); | 108 base::TimeDelta duration); |
| 107 bool HasPendingPageScaleAnimation() const; | 109 bool HasPendingPageScaleAnimation() const; |
| 108 | 110 |
| 109 void SetDeviceScaleFactor(float device_scale_factor); | 111 void SetDeviceScaleFactor(float device_scale_factor); |
| 110 float device_scale_factor() const { return inputs_.device_scale_factor; } | 112 float device_scale_factor() const { return inputs_.device_scale_factor; } |
| 111 | 113 |
| 112 void SetPaintedDeviceScaleFactor(float painted_device_scale_factor); | 114 void SetPaintedDeviceScaleFactor(float painted_device_scale_factor); |
| 113 | 115 |
| 114 AnimationHost* animation_host() const { return animation_host_.get(); } | |
| 115 | |
| 116 gfx::Vector2dF elastic_overscroll() const { return elastic_overscroll_; } | 116 gfx::Vector2dF elastic_overscroll() const { return elastic_overscroll_; } |
| 117 | 117 |
| 118 // Used externally by blink for setting the PropertyTrees when | 118 // Used externally by blink for setting the PropertyTrees when |
| 119 // |settings_.use_layer_lists| is true. This is a SPV2 setting. | 119 // |settings_.use_layer_lists| is true. This is a SPV2 setting. |
| 120 PropertyTrees* property_trees() { return &property_trees_; } | 120 PropertyTrees* property_trees() { return &property_trees_; } |
| 121 | 121 |
| 122 bool in_paint_layer_contents() const { return in_paint_layer_contents_; } |
| 123 |
| 122 // Methods which should only be used internally in cc ------------------ | 124 // Methods which should only be used internally in cc ------------------ |
| 123 void RegisterLayer(Layer* layer); | 125 void RegisterLayer(Layer* layer); |
| 124 void UnregisterLayer(Layer* layer); | 126 void UnregisterLayer(Layer* layer); |
| 125 Layer* LayerById(int id) const; | 127 Layer* LayerById(int id) const; |
| 126 bool UpdateLayers(const LayerList& update_layer_list, | 128 bool UpdateLayers(const LayerList& update_layer_list, |
| 127 bool* content_is_suitable_for_gpu); | 129 bool* content_is_suitable_for_gpu); |
| 128 | 130 |
| 129 void AddLayerShouldPushProperties(Layer* layer); | 131 void AddLayerShouldPushProperties(Layer* layer); |
| 130 void RemoveLayerShouldPushProperties(Layer* layer); | 132 void RemoveLayerShouldPushProperties(Layer* layer); |
| 131 std::unordered_set<Layer*>& LayersThatShouldPushProperties(); | 133 std::unordered_set<Layer*>& LayersThatShouldPushProperties(); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 147 bool needs_full_tree_sync() const { return needs_full_tree_sync_; } | 149 bool needs_full_tree_sync() const { return needs_full_tree_sync_; } |
| 148 | 150 |
| 149 void SetNeedsCommit(); | 151 void SetNeedsCommit(); |
| 150 void SetPropertyTreesNeedRebuild(); | 152 void SetPropertyTreesNeedRebuild(); |
| 151 | 153 |
| 152 void PushPropertiesTo(LayerTreeImpl* tree_impl); | 154 void PushPropertiesTo(LayerTreeImpl* tree_impl); |
| 153 | 155 |
| 154 void ToProtobuf(proto::LayerTree* proto); | 156 void ToProtobuf(proto::LayerTree* proto); |
| 155 void FromProtobuf(const proto::LayerTree& proto); | 157 void FromProtobuf(const proto::LayerTree& proto); |
| 156 | 158 |
| 157 bool in_paint_layer_contents() const { return in_paint_layer_contents_; } | 159 AnimationHost* animation_host() const { return animation_host_.get(); } |
| 160 |
| 161 Layer* LayerByElementId(ElementId element_id) const; |
| 162 void RegisterElement(ElementId element_id, |
| 163 ElementListType list_type, |
| 164 Layer* layer); |
| 165 void UnregisterElement(ElementId element_id, |
| 166 ElementListType list_type, |
| 167 Layer* layer); |
| 168 void SetElementIdsForTesting(); |
| 169 |
| 170 // Layer iterators. |
| 171 LayerListIterator<Layer> begin() const; |
| 172 LayerListIterator<Layer> end() const; |
| 173 LayerListReverseIterator<Layer> rbegin(); |
| 174 LayerListReverseIterator<Layer> rend(); |
| 175 |
| 176 void SetNeedsDisplayOnAllLayers(); |
| 158 // --------------------------------------------------------------------- | 177 // --------------------------------------------------------------------- |
| 159 | 178 |
| 160 private: | 179 private: |
| 161 friend class LayerTreeHostSerializationTest; | 180 friend class LayerTreeHostSerializationTest; |
| 162 | 181 |
| 182 // MutatorHostClient implementation. |
| 183 bool IsElementInList(ElementId element_id, |
| 184 ElementListType list_type) const override; |
| 185 void SetMutatorsNeedCommit() override; |
| 186 void SetMutatorsNeedRebuildPropertyTrees() override; |
| 187 void SetElementFilterMutated(ElementId element_id, |
| 188 ElementListType list_type, |
| 189 const FilterOperations& filters) override; |
| 190 void SetElementOpacityMutated(ElementId element_id, |
| 191 ElementListType list_type, |
| 192 float opacity) override; |
| 193 void SetElementTransformMutated(ElementId element_id, |
| 194 ElementListType list_type, |
| 195 const gfx::Transform& transform) override; |
| 196 void SetElementScrollOffsetMutated( |
| 197 ElementId element_id, |
| 198 ElementListType list_type, |
| 199 const gfx::ScrollOffset& scroll_offset) override; |
| 200 void ElementTransformIsAnimatingChanged(ElementId element_id, |
| 201 ElementListType list_type, |
| 202 AnimationChangeType change_type, |
| 203 bool is_animating) override; |
| 204 void ElementOpacityIsAnimatingChanged(ElementId element_id, |
| 205 ElementListType list_type, |
| 206 AnimationChangeType change_type, |
| 207 bool is_animating) override; |
| 208 void ElementFilterIsAnimatingChanged(ElementId element_id, |
| 209 ElementListType list_type, |
| 210 AnimationChangeType change_type, |
| 211 bool is_animating) override; |
| 212 void ScrollOffsetAnimationFinished() override {} |
| 213 gfx::ScrollOffset GetScrollOffsetForAnimation( |
| 214 ElementId element_id) const override; |
| 215 |
| 163 // Encapsulates the data, callbacks, interfaces received from the embedder. | 216 // Encapsulates the data, callbacks, interfaces received from the embedder. |
| 164 struct Inputs { | 217 struct Inputs { |
| 165 Inputs(); | 218 Inputs(); |
| 166 ~Inputs(); | 219 ~Inputs(); |
| 167 | 220 |
| 168 scoped_refptr<Layer> root_layer; | 221 scoped_refptr<Layer> root_layer; |
| 169 | 222 |
| 170 scoped_refptr<Layer> overscroll_elasticity_layer; | 223 scoped_refptr<Layer> overscroll_elasticity_layer; |
| 171 scoped_refptr<Layer> page_scale_layer; | 224 scoped_refptr<Layer> page_scale_layer; |
| 172 scoped_refptr<Layer> inner_viewport_scroll_layer; | 225 scoped_refptr<Layer> inner_viewport_scroll_layer; |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 206 gfx::Vector2dF elastic_overscroll_; | 259 gfx::Vector2dF elastic_overscroll_; |
| 207 | 260 |
| 208 scoped_refptr<HeadsUpDisplayLayer> hud_layer_; | 261 scoped_refptr<HeadsUpDisplayLayer> hud_layer_; |
| 209 | 262 |
| 210 // Set of layers that need to push properties. | 263 // Set of layers that need to push properties. |
| 211 LayerSet layers_that_should_push_properties_; | 264 LayerSet layers_that_should_push_properties_; |
| 212 | 265 |
| 213 // Layer id to Layer map. | 266 // Layer id to Layer map. |
| 214 LayerIdMap layer_id_map_; | 267 LayerIdMap layer_id_map_; |
| 215 | 268 |
| 269 using ElementLayersMap = std::unordered_map<ElementId, Layer*, ElementIdHash>; |
| 270 ElementLayersMap element_layers_map_; |
| 271 |
| 216 bool in_paint_layer_contents_; | 272 bool in_paint_layer_contents_; |
| 217 | 273 |
| 218 std::unique_ptr<AnimationHost> animation_host_; | 274 std::unique_ptr<AnimationHost> animation_host_; |
| 219 LayerTreeHost* layer_tree_host_; | 275 LayerTreeHost* layer_tree_host_; |
| 220 | 276 |
| 221 DISALLOW_COPY_AND_ASSIGN(LayerTree); | 277 DISALLOW_COPY_AND_ASSIGN(LayerTree); |
| 222 }; | 278 }; |
| 223 | 279 |
| 224 } // namespace cc | 280 } // namespace cc |
| 225 | 281 |
| 226 #endif // CC_TREES_LAYER_TREE_H_ | 282 #endif // CC_TREES_LAYER_TREE_H_ |
| OLD | NEW |