OLD | NEW |
1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 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_IMPL_H_ | 5 #ifndef CC_LAYERS_LAYER_IMPL_H_ |
6 #define CC_LAYERS_LAYER_IMPL_H_ | 6 #define CC_LAYERS_LAYER_IMPL_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <set> | 9 #include <set> |
10 #include <string> | 10 #include <string> |
11 #include <vector> | 11 #include <vector> |
12 | 12 |
13 #include "base/logging.h" | 13 #include "base/logging.h" |
14 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
15 #include "base/values.h" | 15 #include "base/values.h" |
16 #include "cc/animation/animation_delegate.h" | |
17 #include "cc/animation/layer_animation_controller.h" | |
18 #include "cc/animation/layer_animation_value_observer.h" | |
19 #include "cc/animation/layer_animation_value_provider.h" | |
20 #include "cc/base/cc_export.h" | 16 #include "cc/base/cc_export.h" |
21 #include "cc/base/region.h" | 17 #include "cc/base/region.h" |
22 #include "cc/base/scoped_ptr_vector.h" | 18 #include "cc/base/scoped_ptr_vector.h" |
23 #include "cc/base/synced_property.h" | 19 #include "cc/base/synced_property.h" |
24 #include "cc/debug/frame_timing_request.h" | 20 #include "cc/debug/frame_timing_request.h" |
25 #include "cc/input/input_handler.h" | 21 #include "cc/input/input_handler.h" |
26 #include "cc/input/scrollbar.h" | 22 #include "cc/input/scrollbar.h" |
27 #include "cc/layers/draw_properties.h" | 23 #include "cc/layers/draw_properties.h" |
28 #include "cc/layers/layer_lists.h" | 24 #include "cc/layers/layer_lists.h" |
29 #include "cc/layers/layer_position_constraint.h" | 25 #include "cc/layers/layer_position_constraint.h" |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 | 67 |
72 struct AppendQuadsData; | 68 struct AppendQuadsData; |
73 | 69 |
74 enum DrawMode { | 70 enum DrawMode { |
75 DRAW_MODE_NONE, | 71 DRAW_MODE_NONE, |
76 DRAW_MODE_HARDWARE, | 72 DRAW_MODE_HARDWARE, |
77 DRAW_MODE_SOFTWARE, | 73 DRAW_MODE_SOFTWARE, |
78 DRAW_MODE_RESOURCELESS_SOFTWARE | 74 DRAW_MODE_RESOURCELESS_SOFTWARE |
79 }; | 75 }; |
80 | 76 |
81 class CC_EXPORT LayerImpl : public LayerAnimationValueObserver, | 77 class CC_EXPORT LayerImpl { |
82 public LayerAnimationValueProvider, | |
83 public AnimationDelegate { | |
84 public: | 78 public: |
85 typedef SyncedProperty<AdditionGroup<gfx::ScrollOffset>> SyncedScrollOffset; | 79 typedef SyncedProperty<AdditionGroup<gfx::ScrollOffset>> SyncedScrollOffset; |
86 typedef LayerImplList RenderSurfaceListType; | 80 typedef LayerImplList RenderSurfaceListType; |
87 typedef LayerImplList LayerListType; | 81 typedef LayerImplList LayerListType; |
88 typedef RenderSurfaceImpl RenderSurfaceType; | 82 typedef RenderSurfaceImpl RenderSurfaceType; |
89 | 83 |
90 enum RenderingContextConstants { NO_RENDERING_CONTEXT = 0 }; | 84 enum RenderingContextConstants { NO_RENDERING_CONTEXT = 0 }; |
91 | 85 |
92 static scoped_ptr<LayerImpl> Create( | 86 static scoped_ptr<LayerImpl> Create( |
93 LayerTreeImpl* tree_impl, | 87 LayerTreeImpl* tree_impl, |
94 int id, | 88 int id, |
95 scoped_refptr<SyncedScrollOffset> scroll_offset) { | 89 scoped_refptr<SyncedScrollOffset> scroll_offset) { |
96 return make_scoped_ptr(new LayerImpl(tree_impl, id, scroll_offset)); | 90 return make_scoped_ptr(new LayerImpl(tree_impl, id, scroll_offset)); |
97 } | 91 } |
98 | 92 |
99 static scoped_ptr<LayerImpl> Create(LayerTreeImpl* tree_impl, int id) { | 93 static scoped_ptr<LayerImpl> Create(LayerTreeImpl* tree_impl, int id) { |
100 return make_scoped_ptr(new LayerImpl(tree_impl, id)); | 94 return make_scoped_ptr(new LayerImpl(tree_impl, id)); |
101 } | 95 } |
102 | 96 |
103 ~LayerImpl() override; | 97 virtual ~LayerImpl(); |
104 | 98 |
105 int id() const { return layer_id_; } | 99 int id() const { return layer_id_; } |
106 | 100 |
107 // LayerAnimationValueProvider implementation. | 101 gfx::ScrollOffset ScrollOffsetForAnimation() const; |
108 gfx::ScrollOffset ScrollOffsetForAnimation() const override; | |
109 | 102 |
110 // LayerAnimationValueObserver implementation. | 103 void OnFilterAnimated(const FilterOperations& filters); |
111 void OnFilterAnimated(const FilterOperations& filters) override; | 104 void OnOpacityAnimated(float opacity); |
112 void OnOpacityAnimated(float opacity) override; | 105 void OnTransformAnimated(const gfx::Transform& transform); |
113 void OnTransformAnimated(const gfx::Transform& transform) override; | 106 void OnScrollOffsetAnimated(const gfx::ScrollOffset& scroll_offset); |
114 void OnScrollOffsetAnimated(const gfx::ScrollOffset& scroll_offset) override; | 107 bool IsActive() const; |
115 void OnAnimationWaitingForDeletion() override; | |
116 bool IsActive() const override; | |
117 | |
118 // AnimationDelegate implementation. | |
119 void NotifyAnimationStarted(base::TimeTicks monotonic_time, | |
120 Animation::TargetProperty target_property, | |
121 int group) override{}; | |
122 void NotifyAnimationFinished(base::TimeTicks monotonic_time, | |
123 Animation::TargetProperty target_property, | |
124 int group) override; | |
125 | 108 |
126 // Tree structure. | 109 // Tree structure. |
127 LayerImpl* parent() { return parent_; } | 110 LayerImpl* parent() { return parent_; } |
128 const LayerImpl* parent() const { return parent_; } | 111 const LayerImpl* parent() const { return parent_; } |
129 const OwnedLayerImplList& children() const { return children_; } | 112 const OwnedLayerImplList& children() const { return children_; } |
130 OwnedLayerImplList& children() { return children_; } | 113 OwnedLayerImplList& children() { return children_; } |
131 LayerImpl* child_at(size_t index) const { return children_[index]; } | 114 LayerImpl* child_at(size_t index) const { return children_[index]; } |
132 void AddChild(scoped_ptr<LayerImpl> child); | 115 void AddChild(scoped_ptr<LayerImpl> child); |
133 scoped_ptr<LayerImpl> RemoveChild(LayerImpl* child); | 116 scoped_ptr<LayerImpl> RemoveChild(LayerImpl* child); |
134 void SetParent(LayerImpl* parent); | 117 void SetParent(LayerImpl* parent); |
(...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
567 const gfx::RectF& damage_rect() const { return damage_rect_; } | 550 const gfx::RectF& damage_rect() const { return damage_rect_; } |
568 | 551 |
569 virtual base::DictionaryValue* LayerTreeAsJson() const; | 552 virtual base::DictionaryValue* LayerTreeAsJson() const; |
570 | 553 |
571 void SetStackingOrderChanged(bool stacking_order_changed); | 554 void SetStackingOrderChanged(bool stacking_order_changed); |
572 | 555 |
573 bool LayerPropertyChanged() const { return layer_property_changed_; } | 556 bool LayerPropertyChanged() const { return layer_property_changed_; } |
574 | 557 |
575 void ResetAllChangeTrackingForSubtree(); | 558 void ResetAllChangeTrackingForSubtree(); |
576 | 559 |
577 LayerAnimationController* layer_animation_controller() { | |
578 return layer_animation_controller_.get(); | |
579 } | |
580 | |
581 const LayerAnimationController* layer_animation_controller() const { | |
582 return layer_animation_controller_.get(); | |
583 } | |
584 | |
585 virtual SimpleEnclosedRegion VisibleContentOpaqueRegion() const; | 560 virtual SimpleEnclosedRegion VisibleContentOpaqueRegion() const; |
586 | 561 |
587 virtual void DidBecomeActive(); | 562 virtual void DidBecomeActive(); |
588 | 563 |
589 virtual void DidBeginTracing(); | 564 virtual void DidBeginTracing(); |
590 | 565 |
591 // Release resources held by this layer. Called when the output surface | 566 // Release resources held by this layer. Called when the output surface |
592 // that rendered this layer was lost or a rendering mode switch has occured. | 567 // that rendered this layer was lost or a rendering mode switch has occured. |
593 virtual void ReleaseResources(); | 568 virtual void ReleaseResources(); |
594 | 569 |
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
817 | 792 |
818 private: | 793 private: |
819 // Rect indicating what was repainted/updated during update. | 794 // Rect indicating what was repainted/updated during update. |
820 // Note that plugin layers bypass this and leave it empty. | 795 // Note that plugin layers bypass this and leave it empty. |
821 // Uses layer (not content) space. | 796 // Uses layer (not content) space. |
822 gfx::Rect update_rect_; | 797 gfx::Rect update_rect_; |
823 | 798 |
824 // This rect is in layer space. | 799 // This rect is in layer space. |
825 gfx::RectF damage_rect_; | 800 gfx::RectF damage_rect_; |
826 | 801 |
827 // Manages animations for this layer. | |
828 scoped_refptr<LayerAnimationController> layer_animation_controller_; | |
829 | |
830 // Manages scrollbars for this layer | 802 // Manages scrollbars for this layer |
831 scoped_ptr<ScrollbarAnimationController> scrollbar_animation_controller_; | 803 scoped_ptr<ScrollbarAnimationController> scrollbar_animation_controller_; |
832 | 804 |
833 scoped_ptr<ScrollbarSet> scrollbars_; | 805 scoped_ptr<ScrollbarSet> scrollbars_; |
834 | 806 |
835 ScopedPtrVector<CopyOutputRequest> copy_requests_; | 807 ScopedPtrVector<CopyOutputRequest> copy_requests_; |
836 | 808 |
837 // Group of properties that need to be computed based on the layer tree | 809 // Group of properties that need to be computed based on the layer tree |
838 // hierarchy before layers can be drawn. | 810 // hierarchy before layers can be drawn. |
839 DrawProperties<LayerImpl> draw_properties_; | 811 DrawProperties<LayerImpl> draw_properties_; |
840 | 812 |
841 scoped_refptr<base::trace_event::ConvertableToTraceFormat> debug_info_; | 813 scoped_refptr<base::trace_event::ConvertableToTraceFormat> debug_info_; |
842 scoped_ptr<RenderSurfaceImpl> render_surface_; | 814 scoped_ptr<RenderSurfaceImpl> render_surface_; |
843 | 815 |
844 std::vector<FrameTimingRequest> frame_timing_requests_; | 816 std::vector<FrameTimingRequest> frame_timing_requests_; |
845 bool frame_timing_requests_dirty_; | 817 bool frame_timing_requests_dirty_; |
846 | 818 |
847 DISALLOW_COPY_AND_ASSIGN(LayerImpl); | 819 DISALLOW_COPY_AND_ASSIGN(LayerImpl); |
848 }; | 820 }; |
849 | 821 |
850 } // namespace cc | 822 } // namespace cc |
851 | 823 |
852 #endif // CC_LAYERS_LAYER_IMPL_H_ | 824 #endif // CC_LAYERS_LAYER_IMPL_H_ |
OLD | NEW |