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 <stddef.h> | 8 #include <stddef.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 | 10 |
11 #include <map> | 11 #include <map> |
| 12 #include <memory> |
12 #include <set> | 13 #include <set> |
13 #include <string> | 14 #include <string> |
14 #include <vector> | 15 #include <vector> |
15 | 16 |
16 #include "base/logging.h" | 17 #include "base/logging.h" |
17 #include "base/macros.h" | 18 #include "base/macros.h" |
18 #include "base/memory/scoped_ptr.h" | 19 #include "base/memory/ptr_util.h" |
19 #include "base/values.h" | 20 #include "base/values.h" |
20 #include "cc/animation/target_property.h" | 21 #include "cc/animation/target_property.h" |
21 #include "cc/base/cc_export.h" | 22 #include "cc/base/cc_export.h" |
22 #include "cc/base/region.h" | 23 #include "cc/base/region.h" |
23 #include "cc/base/synced_property.h" | 24 #include "cc/base/synced_property.h" |
24 #include "cc/debug/frame_timing_request.h" | 25 #include "cc/debug/frame_timing_request.h" |
25 #include "cc/input/input_handler.h" | 26 #include "cc/input/input_handler.h" |
26 #include "cc/layers/draw_properties.h" | 27 #include "cc/layers/draw_properties.h" |
27 #include "cc/layers/layer_collections.h" | 28 #include "cc/layers/layer_collections.h" |
28 #include "cc/layers/layer_position_constraint.h" | 29 #include "cc/layers/layer_position_constraint.h" |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 }; | 76 }; |
76 | 77 |
77 class CC_EXPORT LayerImpl { | 78 class CC_EXPORT LayerImpl { |
78 public: | 79 public: |
79 typedef LayerImplList RenderSurfaceListType; | 80 typedef LayerImplList RenderSurfaceListType; |
80 typedef LayerImplList LayerListType; | 81 typedef LayerImplList LayerListType; |
81 typedef RenderSurfaceImpl RenderSurfaceType; | 82 typedef RenderSurfaceImpl RenderSurfaceType; |
82 | 83 |
83 enum RenderingContextConstants { NO_RENDERING_CONTEXT = 0 }; | 84 enum RenderingContextConstants { NO_RENDERING_CONTEXT = 0 }; |
84 | 85 |
85 static scoped_ptr<LayerImpl> Create(LayerTreeImpl* tree_impl, int id) { | 86 static std::unique_ptr<LayerImpl> Create(LayerTreeImpl* tree_impl, int id) { |
86 return make_scoped_ptr(new LayerImpl(tree_impl, id)); | 87 return base::WrapUnique(new LayerImpl(tree_impl, id)); |
87 } | 88 } |
88 | 89 |
89 virtual ~LayerImpl(); | 90 virtual ~LayerImpl(); |
90 | 91 |
91 int id() const { return layer_id_; } | 92 int id() const { return layer_id_; } |
92 | 93 |
93 // Interactions with attached animations. | 94 // Interactions with attached animations. |
94 gfx::ScrollOffset ScrollOffsetForAnimation() const; | 95 gfx::ScrollOffset ScrollOffsetForAnimation() const; |
95 void OnFilterAnimated(const FilterOperations& filters); | 96 void OnFilterAnimated(const FilterOperations& filters); |
96 void OnOpacityAnimated(float opacity); | 97 void OnOpacityAnimated(float opacity); |
97 void OnTransformAnimated(const gfx::Transform& transform); | 98 void OnTransformAnimated(const gfx::Transform& transform); |
98 void OnScrollOffsetAnimated(const gfx::ScrollOffset& scroll_offset); | 99 void OnScrollOffsetAnimated(const gfx::ScrollOffset& scroll_offset); |
99 void OnTransformIsPotentiallyAnimatingChanged(bool is_animating); | 100 void OnTransformIsPotentiallyAnimatingChanged(bool is_animating); |
100 bool IsActive() const; | 101 bool IsActive() const; |
101 bool OpacityCanAnimateOnImplThread() const { return false; } | 102 bool OpacityCanAnimateOnImplThread() const { return false; } |
102 | 103 |
103 // Tree structure. | 104 // Tree structure. |
104 LayerImpl* parent() { return parent_; } | 105 LayerImpl* parent() { return parent_; } |
105 LayerImplList& children() { return children_; } | 106 LayerImplList& children() { return children_; } |
106 LayerImpl* child_at(size_t index) const { return children_[index]; } | 107 LayerImpl* child_at(size_t index) const { return children_[index]; } |
107 void AddChild(scoped_ptr<LayerImpl> child); | 108 void AddChild(std::unique_ptr<LayerImpl> child); |
108 scoped_ptr<LayerImpl> RemoveChildForTesting(LayerImpl* child); | 109 std::unique_ptr<LayerImpl> RemoveChildForTesting(LayerImpl* child); |
109 void SetParent(LayerImpl* parent); | 110 void SetParent(LayerImpl* parent); |
110 | 111 |
111 void SetScrollParent(LayerImpl* parent); | 112 void SetScrollParent(LayerImpl* parent); |
112 | 113 |
113 LayerImpl* scroll_parent() { return scroll_parent_; } | 114 LayerImpl* scroll_parent() { return scroll_parent_; } |
114 const LayerImpl* scroll_parent() const { return scroll_parent_; } | 115 const LayerImpl* scroll_parent() const { return scroll_parent_; } |
115 | 116 |
116 void SetScrollChildren(std::set<LayerImpl*>* children); | 117 void SetScrollChildren(std::set<LayerImpl*>* children); |
117 | 118 |
118 std::set<LayerImpl*>* scroll_children() { return scroll_children_.get(); } | 119 std::set<LayerImpl*>* scroll_children() { return scroll_children_.get(); } |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 return clip_parent_; | 174 return clip_parent_; |
174 } | 175 } |
175 | 176 |
176 void SetClipChildren(std::set<LayerImpl*>* children); | 177 void SetClipChildren(std::set<LayerImpl*>* children); |
177 | 178 |
178 std::set<LayerImpl*>* clip_children() { return clip_children_.get(); } | 179 std::set<LayerImpl*>* clip_children() { return clip_children_.get(); } |
179 const std::set<LayerImpl*>* clip_children() const { | 180 const std::set<LayerImpl*>* clip_children() const { |
180 return clip_children_.get(); | 181 return clip_children_.get(); |
181 } | 182 } |
182 | 183 |
183 void PassCopyRequests(std::vector<scoped_ptr<CopyOutputRequest>>* requests); | 184 void PassCopyRequests( |
| 185 std::vector<std::unique_ptr<CopyOutputRequest>>* requests); |
184 // Can only be called when the layer has a copy request. | 186 // Can only be called when the layer has a copy request. |
185 void TakeCopyRequestsAndTransformToTarget( | 187 void TakeCopyRequestsAndTransformToTarget( |
186 std::vector<scoped_ptr<CopyOutputRequest>>* request); | 188 std::vector<std::unique_ptr<CopyOutputRequest>>* request); |
187 bool HasCopyRequest() const { return !copy_requests_.empty(); } | 189 bool HasCopyRequest() const { return !copy_requests_.empty(); } |
188 bool InsideCopyRequest() const; | 190 bool InsideCopyRequest() const; |
189 | 191 |
190 void SetMaskLayer(scoped_ptr<LayerImpl> mask_layer); | 192 void SetMaskLayer(std::unique_ptr<LayerImpl> mask_layer); |
191 LayerImpl* mask_layer() { return mask_layer_; } | 193 LayerImpl* mask_layer() { return mask_layer_; } |
192 const LayerImpl* mask_layer() const { return mask_layer_; } | 194 const LayerImpl* mask_layer() const { return mask_layer_; } |
193 scoped_ptr<LayerImpl> TakeMaskLayer(); | 195 std::unique_ptr<LayerImpl> TakeMaskLayer(); |
194 | 196 |
195 void SetReplicaLayer(scoped_ptr<LayerImpl> replica_layer); | 197 void SetReplicaLayer(std::unique_ptr<LayerImpl> replica_layer); |
196 LayerImpl* replica_layer() { return replica_layer_; } | 198 LayerImpl* replica_layer() { return replica_layer_; } |
197 const LayerImpl* replica_layer() const { return replica_layer_; } | 199 const LayerImpl* replica_layer() const { return replica_layer_; } |
198 scoped_ptr<LayerImpl> TakeReplicaLayer(); | 200 std::unique_ptr<LayerImpl> TakeReplicaLayer(); |
199 | 201 |
200 bool has_mask() const { return !!mask_layer_; } | 202 bool has_mask() const { return !!mask_layer_; } |
201 bool has_replica() const { return !!replica_layer_; } | 203 bool has_replica() const { return !!replica_layer_; } |
202 bool replica_has_mask() const { | 204 bool replica_has_mask() const { |
203 return replica_layer_ && (mask_layer_ || replica_layer_->mask_layer_); | 205 return replica_layer_ && (mask_layer_ || replica_layer_->mask_layer_); |
204 } | 206 } |
205 | 207 |
206 LayerTreeImpl* layer_tree_impl() const { return layer_tree_impl_; } | 208 LayerTreeImpl* layer_tree_impl() const { return layer_tree_impl_; } |
207 | 209 |
208 void PopulateSharedQuadState(SharedQuadState* state) const; | 210 void PopulateSharedQuadState(SharedQuadState* state) const; |
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
515 virtual void DidBeginTracing(); | 517 virtual void DidBeginTracing(); |
516 | 518 |
517 // Release resources held by this layer. Called when the output surface | 519 // Release resources held by this layer. Called when the output surface |
518 // that rendered this layer was lost or a rendering mode switch has occured. | 520 // that rendered this layer was lost or a rendering mode switch has occured. |
519 virtual void ReleaseResources(); | 521 virtual void ReleaseResources(); |
520 | 522 |
521 // Recreate resources that are required after they were released by a | 523 // Recreate resources that are required after they were released by a |
522 // ReleaseResources call. | 524 // ReleaseResources call. |
523 virtual void RecreateResources(); | 525 virtual void RecreateResources(); |
524 | 526 |
525 virtual scoped_ptr<LayerImpl> CreateLayerImpl(LayerTreeImpl* tree_impl); | 527 virtual std::unique_ptr<LayerImpl> CreateLayerImpl(LayerTreeImpl* tree_impl); |
526 virtual void PushPropertiesTo(LayerImpl* layer); | 528 virtual void PushPropertiesTo(LayerImpl* layer); |
527 | 529 |
528 virtual void GetAllPrioritizedTilesForTracing( | 530 virtual void GetAllPrioritizedTilesForTracing( |
529 std::vector<PrioritizedTile>* prioritized_tiles) const; | 531 std::vector<PrioritizedTile>* prioritized_tiles) const; |
530 virtual void AsValueInto(base::trace_event::TracedValue* dict) const; | 532 virtual void AsValueInto(base::trace_event::TracedValue* dict) const; |
531 | 533 |
532 virtual size_t GPUMemoryUsageInBytes() const; | 534 virtual size_t GPUMemoryUsageInBytes() const; |
533 | 535 |
534 void SetNeedsPushProperties(); | 536 void SetNeedsPushProperties(); |
535 | 537 |
536 virtual void RunMicroBenchmark(MicroBenchmarkImpl* benchmark); | 538 virtual void RunMicroBenchmark(MicroBenchmarkImpl* benchmark); |
537 | 539 |
538 void SetDebugInfo( | 540 void SetDebugInfo( |
539 scoped_ptr<base::trace_event::ConvertableToTraceFormat> debug_info); | 541 std::unique_ptr<base::trace_event::ConvertableToTraceFormat> debug_info); |
540 | 542 |
541 bool IsDrawnRenderSurfaceLayerListMember() const; | 543 bool IsDrawnRenderSurfaceLayerListMember() const; |
542 | 544 |
543 void Set3dSortingContextId(int id); | 545 void Set3dSortingContextId(int id); |
544 int sorting_context_id() { return sorting_context_id_; } | 546 int sorting_context_id() { return sorting_context_id_; } |
545 | 547 |
546 void SetFrameTimingRequests( | 548 void SetFrameTimingRequests( |
547 const std::vector<FrameTimingRequest>& frame_timing_requests); | 549 const std::vector<FrameTimingRequest>& frame_timing_requests); |
548 const std::vector<FrameTimingRequest>& frame_timing_requests() const { | 550 const std::vector<FrameTimingRequest>& frame_timing_requests() const { |
549 return frame_timing_requests_; | 551 return frame_timing_requests_; |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
635 // Properties internal to LayerImpl | 637 // Properties internal to LayerImpl |
636 LayerImpl* parent_; | 638 LayerImpl* parent_; |
637 LayerImplList children_; | 639 LayerImplList children_; |
638 | 640 |
639 LayerImpl* scroll_parent_; | 641 LayerImpl* scroll_parent_; |
640 | 642 |
641 // Storing a pointer to a set rather than a set since this will be rarely | 643 // Storing a pointer to a set rather than a set since this will be rarely |
642 // used. If this pointer turns out to be too heavy, we could have this (and | 644 // used. If this pointer turns out to be too heavy, we could have this (and |
643 // the scroll parent above) be stored in a LayerImpl -> scroll_info | 645 // the scroll parent above) be stored in a LayerImpl -> scroll_info |
644 // map somewhere. | 646 // map somewhere. |
645 scoped_ptr<std::set<LayerImpl*>> scroll_children_; | 647 std::unique_ptr<std::set<LayerImpl*>> scroll_children_; |
646 | 648 |
647 LayerImpl* clip_parent_; | 649 LayerImpl* clip_parent_; |
648 scoped_ptr<std::set<LayerImpl*>> clip_children_; | 650 std::unique_ptr<std::set<LayerImpl*>> clip_children_; |
649 | 651 |
650 // mask_layer_ can be temporarily stolen during tree sync, we need this ID to | 652 // mask_layer_ can be temporarily stolen during tree sync, we need this ID to |
651 // confirm newly assigned layer is still the previous one | 653 // confirm newly assigned layer is still the previous one |
652 int mask_layer_id_; | 654 int mask_layer_id_; |
653 LayerImpl* mask_layer_; | 655 LayerImpl* mask_layer_; |
654 int replica_layer_id_; // ditto | 656 int replica_layer_id_; // ditto |
655 LayerImpl* replica_layer_; | 657 LayerImpl* replica_layer_; |
656 int layer_id_; | 658 int layer_id_; |
657 LayerTreeImpl* layer_tree_impl_; | 659 LayerTreeImpl* layer_tree_impl_; |
658 | 660 |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
742 uint32_t mutable_properties_; | 744 uint32_t mutable_properties_; |
743 // Rect indicating what was repainted/updated during update. | 745 // Rect indicating what was repainted/updated during update. |
744 // Note that plugin layers bypass this and leave it empty. | 746 // Note that plugin layers bypass this and leave it empty. |
745 // This is in the layer's space. | 747 // This is in the layer's space. |
746 gfx::Rect update_rect_; | 748 gfx::Rect update_rect_; |
747 | 749 |
748 // Denotes an area that is damaged and needs redraw. This is in the layer's | 750 // Denotes an area that is damaged and needs redraw. This is in the layer's |
749 // space. | 751 // space. |
750 gfx::Rect damage_rect_; | 752 gfx::Rect damage_rect_; |
751 | 753 |
752 std::vector<scoped_ptr<CopyOutputRequest>> copy_requests_; | 754 std::vector<std::unique_ptr<CopyOutputRequest>> copy_requests_; |
753 | 755 |
754 // Group of properties that need to be computed based on the layer tree | 756 // Group of properties that need to be computed based on the layer tree |
755 // hierarchy before layers can be drawn. | 757 // hierarchy before layers can be drawn. |
756 DrawProperties draw_properties_; | 758 DrawProperties draw_properties_; |
757 PerformanceProperties<LayerImpl> performance_properties_; | 759 PerformanceProperties<LayerImpl> performance_properties_; |
758 | 760 |
759 scoped_ptr<base::trace_event::ConvertableToTraceFormat> owned_debug_info_; | 761 std::unique_ptr<base::trace_event::ConvertableToTraceFormat> |
| 762 owned_debug_info_; |
760 base::trace_event::ConvertableToTraceFormat* debug_info_; | 763 base::trace_event::ConvertableToTraceFormat* debug_info_; |
761 scoped_ptr<RenderSurfaceImpl> render_surface_; | 764 std::unique_ptr<RenderSurfaceImpl> render_surface_; |
762 | 765 |
763 bool force_render_surface_; | 766 bool force_render_surface_; |
764 | 767 |
765 std::vector<FrameTimingRequest> frame_timing_requests_; | 768 std::vector<FrameTimingRequest> frame_timing_requests_; |
766 bool frame_timing_requests_dirty_; | 769 bool frame_timing_requests_dirty_; |
767 bool layer_or_descendant_is_drawn_; | 770 bool layer_or_descendant_is_drawn_; |
768 // If true, the layer or one of its descendants has a touch handler. | 771 // If true, the layer or one of its descendants has a touch handler. |
769 bool layer_or_descendant_has_touch_handler_; | 772 bool layer_or_descendant_has_touch_handler_; |
770 | 773 |
771 DISALLOW_COPY_AND_ASSIGN(LayerImpl); | 774 DISALLOW_COPY_AND_ASSIGN(LayerImpl); |
772 }; | 775 }; |
773 | 776 |
774 } // namespace cc | 777 } // namespace cc |
775 | 778 |
776 #endif // CC_LAYERS_LAYER_IMPL_H_ | 779 #endif // CC_LAYERS_LAYER_IMPL_H_ |
OLD | NEW |