Chromium Code Reviews| 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 <stddef.h> | 8 #include <stddef.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 | 10 |
| 11 #include <set> | 11 #include <set> |
| 12 #include <string> | 12 #include <string> |
| 13 #include <unordered_map> | 13 #include <unordered_map> |
| 14 #include <vector> | 14 #include <vector> |
| 15 | 15 |
| 16 #include "base/callback.h" | 16 #include "base/callback.h" |
| 17 #include "base/macros.h" | 17 #include "base/macros.h" |
| 18 #include "base/memory/ref_counted.h" | 18 #include "base/memory/ref_counted.h" |
| 19 #include "base/observer_list.h" | 19 #include "base/observer_list.h" |
| 20 #include "cc/animation/layer_animation_controller.h" | 20 #include "cc/animation/target_property.h" |
| 21 #include "cc/animation/layer_animation_value_observer.h" | |
| 22 #include "cc/animation/layer_animation_value_provider.h" | |
| 23 #include "cc/base/cc_export.h" | 21 #include "cc/base/cc_export.h" |
| 24 #include "cc/base/region.h" | 22 #include "cc/base/region.h" |
| 25 #include "cc/debug/frame_timing_request.h" | 23 #include "cc/debug/frame_timing_request.h" |
| 26 #include "cc/debug/micro_benchmark.h" | 24 #include "cc/debug/micro_benchmark.h" |
| 27 #include "cc/input/input_handler.h" | 25 #include "cc/input/input_handler.h" |
| 28 #include "cc/layers/layer_lists.h" | 26 #include "cc/layers/layer_lists.h" |
| 29 #include "cc/layers/layer_position_constraint.h" | 27 #include "cc/layers/layer_position_constraint.h" |
| 30 #include "cc/layers/paint_properties.h" | 28 #include "cc/layers/paint_properties.h" |
| 31 #include "cc/output/filter_operations.h" | 29 #include "cc/output/filter_operations.h" |
| 32 #include "cc/trees/property_tree.h" | 30 #include "cc/trees/property_tree.h" |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 46 } | 44 } |
| 47 | 45 |
| 48 namespace base { | 46 namespace base { |
| 49 namespace trace_event { | 47 namespace trace_event { |
| 50 class ConvertableToTraceFormat; | 48 class ConvertableToTraceFormat; |
| 51 } | 49 } |
| 52 } | 50 } |
| 53 | 51 |
| 54 namespace cc { | 52 namespace cc { |
| 55 | 53 |
| 56 class Animation; | |
| 57 class AnimationDelegate; | |
| 58 struct AnimationEvent; | |
| 59 class CopyOutputRequest; | 54 class CopyOutputRequest; |
| 60 class LayerAnimationEventObserver; | 55 class LayerAnimationEventObserver; |
| 61 class LayerClient; | 56 class LayerClient; |
| 62 class LayerImpl; | 57 class LayerImpl; |
| 63 class LayerSettings; | 58 class LayerSettings; |
| 64 class LayerTreeHost; | 59 class LayerTreeHost; |
| 65 class LayerTreeHostCommon; | 60 class LayerTreeHostCommon; |
| 66 class LayerTreeImpl; | 61 class LayerTreeImpl; |
| 67 class LayerTreeSettings; | 62 class LayerTreeSettings; |
| 68 class RenderingStatsInstrumentation; | 63 class RenderingStatsInstrumentation; |
| 69 class ResourceUpdateQueue; | 64 class ResourceUpdateQueue; |
| 70 class ScrollbarLayerInterface; | 65 class ScrollbarLayerInterface; |
| 71 class SimpleEnclosedRegion; | 66 class SimpleEnclosedRegion; |
| 72 struct AnimationEvent; | |
| 73 | 67 |
| 74 namespace proto { | 68 namespace proto { |
| 75 class LayerNode; | 69 class LayerNode; |
| 76 class LayerProperties; | 70 class LayerProperties; |
| 77 class LayerUpdate; | 71 class LayerUpdate; |
| 78 } // namespace proto | 72 } // namespace proto |
| 79 | 73 |
| 80 // Base class for composited layers. Special layer types are derived from | 74 // Base class for composited layers. Special layer types are derived from |
| 81 // this class. | 75 // this class. |
| 82 class CC_EXPORT Layer : public base::RefCounted<Layer>, | 76 class CC_EXPORT Layer : public base::RefCounted<Layer> { |
| 83 public LayerAnimationValueObserver, | |
| 84 public LayerAnimationValueProvider { | |
| 85 public: | 77 public: |
| 86 using LayerListType = LayerList; | 78 using LayerListType = LayerList; |
| 87 using LayerIdMap = std::unordered_map<int, scoped_refptr<Layer>>; | 79 using LayerIdMap = std::unordered_map<int, scoped_refptr<Layer>>; |
| 88 | 80 |
| 89 enum LayerIdLabels { | 81 enum LayerIdLabels { |
| 90 INVALID_ID = -1, | 82 INVALID_ID = -1, |
| 91 }; | 83 }; |
| 92 | 84 |
| 93 static scoped_refptr<Layer> Create(const LayerSettings& settings); | 85 static scoped_refptr<Layer> Create(const LayerSettings& settings); |
| 94 | 86 |
| (...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 408 | 400 |
| 409 // Read all property values from the given LayerProperties object and update | 401 // Read all property values from the given LayerProperties object and update |
| 410 // the current layer. The values for |needs_push_properties_| and | 402 // the current layer. The values for |needs_push_properties_| and |
| 411 // |num_dependents_need_push_properties_| are always updated, but the rest | 403 // |num_dependents_need_push_properties_| are always updated, but the rest |
| 412 // of |proto| is only read if |needs_push_properties_| is set. | 404 // of |proto| is only read if |needs_push_properties_| is set. |
| 413 void FromLayerPropertiesProto(const proto::LayerProperties& proto); | 405 void FromLayerPropertiesProto(const proto::LayerProperties& proto); |
| 414 | 406 |
| 415 LayerTreeHost* layer_tree_host() { return layer_tree_host_; } | 407 LayerTreeHost* layer_tree_host() { return layer_tree_host_; } |
| 416 const LayerTreeHost* layer_tree_host() const { return layer_tree_host_; } | 408 const LayerTreeHost* layer_tree_host() const { return layer_tree_host_; } |
| 417 | 409 |
| 418 bool AddAnimation(scoped_ptr<Animation> animation); | |
| 419 void PauseAnimation(int animation_id, double time_offset); | |
| 420 void RemoveAnimation(int animation_id); | |
| 421 void AbortAnimation(int animation_id); | |
| 422 LayerAnimationController* layer_animation_controller() const { | |
| 423 return layer_animation_controller_.get(); | |
| 424 } | |
| 425 void SetLayerAnimationControllerForTest( | |
| 426 scoped_refptr<LayerAnimationController> controller); | |
| 427 | |
| 428 void set_layer_animation_delegate(AnimationDelegate* delegate) { | |
| 429 DCHECK(layer_animation_controller_); | |
| 430 layer_animation_controller_->set_layer_animation_delegate(delegate); | |
| 431 } | |
| 432 | |
| 433 bool HasActiveAnimation() const; | 410 bool HasActiveAnimation() const; |
|
loyso (OOO)
2016/03/09 06:11:04
My todo: Rename it to HasActiveAnimationForTesting
| |
| 434 void RegisterForAnimations(AnimationRegistrar* registrar); | |
| 435 | |
| 436 void AddLayerAnimationEventObserver( | |
| 437 LayerAnimationEventObserver* animation_observer); | |
| 438 void RemoveLayerAnimationEventObserver( | |
| 439 LayerAnimationEventObserver* animation_observer); | |
| 440 | 411 |
| 441 virtual ScrollbarLayerInterface* ToScrollbarLayer(); | 412 virtual ScrollbarLayerInterface* ToScrollbarLayer(); |
| 442 | 413 |
| 443 virtual skia::RefPtr<SkPicture> GetPicture() const; | 414 virtual skia::RefPtr<SkPicture> GetPicture() const; |
| 444 | 415 |
| 445 // Constructs a LayerImpl of the correct runtime type for this Layer type. | 416 // Constructs a LayerImpl of the correct runtime type for this Layer type. |
| 446 virtual scoped_ptr<LayerImpl> CreateLayerImpl(LayerTreeImpl* tree_impl); | 417 virtual scoped_ptr<LayerImpl> CreateLayerImpl(LayerTreeImpl* tree_impl); |
| 447 | 418 |
| 448 bool NeedsDisplayForTesting() const { return !update_rect_.IsEmpty(); } | 419 bool NeedsDisplayForTesting() const { return !update_rect_.IsEmpty(); } |
| 449 void ResetNeedsDisplayForTesting() { update_rect_ = gfx::Rect(); } | 420 void ResetNeedsDisplayForTesting() { update_rect_ = gfx::Rect(); } |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 544 void SetMutableProperties(uint32_t properties); | 515 void SetMutableProperties(uint32_t properties); |
| 545 uint32_t mutable_properties() const { return mutable_properties_; } | 516 uint32_t mutable_properties() const { return mutable_properties_; } |
| 546 | 517 |
| 547 void set_visited(bool visited); | 518 void set_visited(bool visited); |
| 548 bool visited(); | 519 bool visited(); |
| 549 void set_layer_or_descendant_is_drawn(bool layer_or_descendant_is_drawn); | 520 void set_layer_or_descendant_is_drawn(bool layer_or_descendant_is_drawn); |
| 550 bool layer_or_descendant_is_drawn(); | 521 bool layer_or_descendant_is_drawn(); |
| 551 void set_sorted_for_recursion(bool sorted_for_recursion); | 522 void set_sorted_for_recursion(bool sorted_for_recursion); |
| 552 bool sorted_for_recursion(); | 523 bool sorted_for_recursion(); |
| 553 | 524 |
| 554 // LayerAnimationValueProvider implementation. | 525 // Interactions with attached animations. |
| 555 gfx::ScrollOffset ScrollOffsetForAnimation() const override; | 526 gfx::ScrollOffset ScrollOffsetForAnimation() const; |
| 556 | 527 void OnFilterAnimated(const FilterOperations& filters); |
| 557 // LayerAnimationValueObserver implementation. | 528 void OnOpacityAnimated(float opacity); |
| 558 void OnFilterAnimated(const FilterOperations& filters) override; | 529 void OnTransformAnimated(const gfx::Transform& transform); |
| 559 void OnOpacityAnimated(float opacity) override; | 530 void OnScrollOffsetAnimated(const gfx::ScrollOffset& scroll_offset); |
| 560 void OnTransformAnimated(const gfx::Transform& transform) override; | 531 void OnTransformIsPotentiallyAnimatingChanged(bool is_animating); |
| 561 void OnScrollOffsetAnimated(const gfx::ScrollOffset& scroll_offset) override; | 532 bool IsActive() const; |
| 562 void OnAnimationWaitingForDeletion() override; | |
| 563 void OnTransformIsPotentiallyAnimatingChanged(bool is_animating) override; | |
| 564 bool IsActive() const override; | |
| 565 | 533 |
| 566 protected: | 534 protected: |
| 567 friend class LayerImpl; | 535 friend class LayerImpl; |
| 568 friend class TreeSynchronizer; | 536 friend class TreeSynchronizer; |
| 569 ~Layer() override; | 537 virtual ~Layer(); |
| 570 | 538 |
| 571 explicit Layer(const LayerSettings& settings); | 539 explicit Layer(const LayerSettings& settings); |
| 572 | 540 |
| 573 // These SetNeeds functions are in order of severity of update: | 541 // These SetNeeds functions are in order of severity of update: |
| 574 // | 542 // |
| 575 // Called when this layer has been modified in some way, but isn't sure | 543 // Called when this layer has been modified in some way, but isn't sure |
| 576 // that it needs a commit yet. It needs CalcDrawProperties and UpdateLayers | 544 // that it needs a commit yet. It needs CalcDrawProperties and UpdateLayers |
| 577 // before it knows whether or not a commit is required. | 545 // before it knows whether or not a commit is required. |
| 578 void SetNeedsUpdate(); | 546 void SetNeedsUpdate(); |
| 579 // Called when a property has been modified in a way that the layer | 547 // Called when a property has been modified in a way that the layer |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 679 void InvalidatePropertyTreesIndices(); | 647 void InvalidatePropertyTreesIndices(); |
| 680 | 648 |
| 681 LayerList children_; | 649 LayerList children_; |
| 682 Layer* parent_; | 650 Layer* parent_; |
| 683 | 651 |
| 684 // Layer instances have a weak pointer to their LayerTreeHost. | 652 // Layer instances have a weak pointer to their LayerTreeHost. |
| 685 // This pointer value is nil when a Layer is not in a tree and is | 653 // This pointer value is nil when a Layer is not in a tree and is |
| 686 // updated via SetLayerTreeHost() if a layer moves between trees. | 654 // updated via SetLayerTreeHost() if a layer moves between trees. |
| 687 LayerTreeHost* layer_tree_host_; | 655 LayerTreeHost* layer_tree_host_; |
| 688 | 656 |
| 689 scoped_refptr<LayerAnimationController> layer_animation_controller_; | |
| 690 | |
| 691 // Layer properties. | 657 // Layer properties. |
| 692 gfx::Size bounds_; | 658 gfx::Size bounds_; |
| 693 | 659 |
| 694 gfx::ScrollOffset scroll_offset_; | 660 gfx::ScrollOffset scroll_offset_; |
| 695 gfx::Vector2dF scroll_compensation_adjustment_; | 661 gfx::Vector2dF scroll_compensation_adjustment_; |
| 696 // This variable indicates which ancestor layer (if any) whose size, | 662 // This variable indicates which ancestor layer (if any) whose size, |
| 697 // transformed relative to this layer, defines the maximum scroll offset for | 663 // transformed relative to this layer, defines the maximum scroll offset for |
| 698 // this layer. | 664 // this layer. |
| 699 int scroll_clip_layer_id_; | 665 int scroll_clip_layer_id_; |
| 700 int num_descendants_that_draw_content_; | 666 int num_descendants_that_draw_content_; |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 773 | 739 |
| 774 std::vector<FrameTimingRequest> frame_timing_requests_; | 740 std::vector<FrameTimingRequest> frame_timing_requests_; |
| 775 bool frame_timing_requests_dirty_; | 741 bool frame_timing_requests_dirty_; |
| 776 | 742 |
| 777 DISALLOW_COPY_AND_ASSIGN(Layer); | 743 DISALLOW_COPY_AND_ASSIGN(Layer); |
| 778 }; | 744 }; |
| 779 | 745 |
| 780 } // namespace cc | 746 } // namespace cc |
| 781 | 747 |
| 782 #endif // CC_LAYERS_LAYER_H_ | 748 #endif // CC_LAYERS_LAYER_H_ |
| OLD | NEW |