OLD | NEW |
1 // Copyright 2010 The Chromium Authors. All rights reserved. | 1 // Copyright 2010 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_LAYERS_LAYER_H_ | 5 #ifndef CC_LAYERS_LAYER_H_ |
6 #define CC_LAYERS_LAYER_H_ | 6 #define CC_LAYERS_LAYER_H_ |
7 | 7 |
8 #include <set> | 8 #include <set> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 class LayerTreeImpl; | 62 class LayerTreeImpl; |
63 class LayerTreeSettings; | 63 class LayerTreeSettings; |
64 class RenderingStatsInstrumentation; | 64 class RenderingStatsInstrumentation; |
65 class ResourceUpdateQueue; | 65 class ResourceUpdateQueue; |
66 class ScrollbarLayerInterface; | 66 class ScrollbarLayerInterface; |
67 class SimpleEnclosedRegion; | 67 class SimpleEnclosedRegion; |
68 struct AnimationEvent; | 68 struct AnimationEvent; |
69 | 69 |
70 namespace proto { | 70 namespace proto { |
71 class LayerNode; | 71 class LayerNode; |
| 72 class LayerProperties; |
| 73 class LayerUpdate; |
72 } // namespace proto | 74 } // namespace proto |
73 | 75 |
74 // Base class for composited layers. Special layer types are derived from | 76 // Base class for composited layers. Special layer types are derived from |
75 // this class. | 77 // this class. |
76 class CC_EXPORT Layer : public base::RefCounted<Layer>, | 78 class CC_EXPORT Layer : public base::RefCounted<Layer>, |
77 public LayerAnimationValueObserver, | 79 public LayerAnimationValueObserver, |
78 public LayerAnimationValueProvider { | 80 public LayerAnimationValueProvider { |
79 public: | 81 public: |
80 typedef LayerList LayerListType; | 82 typedef LayerList LayerListType; |
81 typedef base::hash_map<int, scoped_refptr<Layer>> LayerIdMap; | 83 typedef base::hash_map<int, scoped_refptr<Layer>> LayerIdMap; |
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
380 // construction of the correct layer on the client. | 382 // construction of the correct layer on the client. |
381 void ToLayerNodeProto(proto::LayerNode* proto) const; | 383 void ToLayerNodeProto(proto::LayerNode* proto) const; |
382 | 384 |
383 // Recursively iterate over the given LayerNode proto and read the structure | 385 // Recursively iterate over the given LayerNode proto and read the structure |
384 // into this node and its children. The |layer_map| should be used to look | 386 // into this node and its children. The |layer_map| should be used to look |
385 // for previously existing Layers, since they should be re-used between each | 387 // for previously existing Layers, since they should be re-used between each |
386 // hierarchy update. | 388 // hierarchy update. |
387 void FromLayerNodeProto(const proto::LayerNode& proto, | 389 void FromLayerNodeProto(const proto::LayerNode& proto, |
388 const LayerIdMap& layer_map); | 390 const LayerIdMap& layer_map); |
389 | 391 |
| 392 // This method is similar to PushPropertiesTo, but instead of pushing to |
| 393 // a LayerImpl, it pushes the properties to proto::LayerProperties. It adds |
| 394 // this layer to the proto::LayerUpdate if it or any of its descendants |
| 395 // have changed properties. If this layer contains changed properties, the |
| 396 // properties themselves will also be pushed the proto::LayerProperties. |
| 397 // Similarly to PushPropertiesTo, this method also resets |
| 398 // |needs_push_properties_| and |num_dependents_need_push_properties_|. |
| 399 // Returns whether any of the descendants have changed properties. |
| 400 bool ToLayerPropertiesProto(proto::LayerUpdate* layer_update); |
| 401 |
| 402 // Read all property values from the given LayerProperties object and update |
| 403 // the current layer. The values for |needs_push_properties_| and |
| 404 // |num_dependents_need_push_properties_| are always updated, but the rest |
| 405 // of |proto| is only read if |needs_push_properties_| is set. |
| 406 void FromLayerPropertiesProto(const proto::LayerProperties& proto); |
| 407 |
390 LayerTreeHost* layer_tree_host() { return layer_tree_host_; } | 408 LayerTreeHost* layer_tree_host() { return layer_tree_host_; } |
391 const LayerTreeHost* layer_tree_host() const { return layer_tree_host_; } | 409 const LayerTreeHost* layer_tree_host() const { return layer_tree_host_; } |
392 | 410 |
393 bool AddAnimation(scoped_ptr<Animation> animation); | 411 bool AddAnimation(scoped_ptr<Animation> animation); |
394 void PauseAnimation(int animation_id, double time_offset); | 412 void PauseAnimation(int animation_id, double time_offset); |
395 void RemoveAnimation(int animation_id); | 413 void RemoveAnimation(int animation_id); |
396 void RemoveAnimation(int animation_id, Animation::TargetProperty property); | 414 void RemoveAnimation(int animation_id, Animation::TargetProperty property); |
397 LayerAnimationController* layer_animation_controller() const { | 415 LayerAnimationController* layer_animation_controller() const { |
398 return layer_animation_controller_.get(); | 416 return layer_animation_controller_.get(); |
399 } | 417 } |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
582 void AddDrawableDescendants(int num); | 600 void AddDrawableDescendants(int num); |
583 | 601 |
584 void AddDependentNeedsPushProperties(); | 602 void AddDependentNeedsPushProperties(); |
585 void RemoveDependentNeedsPushProperties(); | 603 void RemoveDependentNeedsPushProperties(); |
586 bool parent_should_know_need_push_properties() const { | 604 bool parent_should_know_need_push_properties() const { |
587 return needs_push_properties() || descendant_needs_push_properties(); | 605 return needs_push_properties() || descendant_needs_push_properties(); |
588 } | 606 } |
589 | 607 |
590 bool IsPropertyChangeAllowed() const; | 608 bool IsPropertyChangeAllowed() const; |
591 | 609 |
| 610 // Serialize all the necessary properties to be able to reconstruct this Layer |
| 611 // into proto::LayerProperties. This function must not set values for |
| 612 // |needs_push_properties_| or |num_dependents_need_push_properties_| as they |
| 613 // are dealt with at a higher level. This is only called if |
| 614 // |needs_push_properties_| is set. For descendants of Layer, implementations |
| 615 // must first call their parent class. |
| 616 virtual void LayerSpecificPropertiesToProto(proto::LayerProperties* proto); |
| 617 |
| 618 // Deserialize all the necessary properties from proto::LayerProperties into |
| 619 // this Layer. This function must not set values for |needs_push_properties_| |
| 620 // or |num_dependents_need_push_properties_| as they are dealt with at a |
| 621 // higher level. This is only called if |needs_push_properties_| is set. For |
| 622 // descendants of Layer, implementations must first call their parent class. |
| 623 virtual void FromLayerSpecificPropertiesProto( |
| 624 const proto::LayerProperties& proto); |
| 625 |
592 // This flag is set when the layer needs to push properties to the impl | 626 // This flag is set when the layer needs to push properties to the impl |
593 // side. | 627 // side. |
594 bool needs_push_properties_; | 628 bool needs_push_properties_; |
595 | 629 |
596 // The number of direct children or dependent layers that need to be recursed | 630 // The number of direct children or dependent layers that need to be recursed |
597 // to in order for them or a descendent of them to push properties to the impl | 631 // to in order for them or a descendent of them to push properties to the impl |
598 // side. | 632 // side. |
599 int num_dependents_need_push_properties_; | 633 int num_dependents_need_push_properties_; |
600 | 634 |
601 // Tracks whether this layer may have changed stacking order with its | 635 // Tracks whether this layer may have changed stacking order with its |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
742 | 776 |
743 std::vector<FrameTimingRequest> frame_timing_requests_; | 777 std::vector<FrameTimingRequest> frame_timing_requests_; |
744 bool frame_timing_requests_dirty_; | 778 bool frame_timing_requests_dirty_; |
745 | 779 |
746 DISALLOW_COPY_AND_ASSIGN(Layer); | 780 DISALLOW_COPY_AND_ASSIGN(Layer); |
747 }; | 781 }; |
748 | 782 |
749 } // namespace cc | 783 } // namespace cc |
750 | 784 |
751 #endif // CC_LAYERS_LAYER_H_ | 785 #endif // CC_LAYERS_LAYER_H_ |
OLD | NEW |