Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(172)

Side by Side Diff: cc/layers/layer_impl.h

Issue 1866203004: Convert //cc from scoped_ptr to std::unique_ptr. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 102
102 // Tree structure. 103 // Tree structure.
103 LayerImpl* parent() { return parent_; } 104 LayerImpl* parent() { return parent_; }
104 LayerImplList& children() { return children_; } 105 LayerImplList& children() { return children_; }
105 LayerImpl* child_at(size_t index) const { return children_[index]; } 106 LayerImpl* child_at(size_t index) const { return children_[index]; }
106 void AddChild(scoped_ptr<LayerImpl> child); 107 void AddChild(std::unique_ptr<LayerImpl> child);
107 scoped_ptr<LayerImpl> RemoveChildForTesting(LayerImpl* child); 108 std::unique_ptr<LayerImpl> RemoveChildForTesting(LayerImpl* child);
108 void SetParent(LayerImpl* parent); 109 void SetParent(LayerImpl* parent);
109 110
110 void SetScrollParent(LayerImpl* parent); 111 void SetScrollParent(LayerImpl* parent);
111 112
112 LayerImpl* scroll_parent() { return scroll_parent_; } 113 LayerImpl* scroll_parent() { return scroll_parent_; }
113 const LayerImpl* scroll_parent() const { return scroll_parent_; } 114 const LayerImpl* scroll_parent() const { return scroll_parent_; }
114 115
115 void SetScrollChildren(std::set<LayerImpl*>* children); 116 void SetScrollChildren(std::set<LayerImpl*>* children);
116 117
117 std::set<LayerImpl*>* scroll_children() { return scroll_children_.get(); } 118 std::set<LayerImpl*>* scroll_children() { return scroll_children_.get(); }
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 return clip_parent_; 173 return clip_parent_;
173 } 174 }
174 175
175 void SetClipChildren(std::set<LayerImpl*>* children); 176 void SetClipChildren(std::set<LayerImpl*>* children);
176 177
177 std::set<LayerImpl*>* clip_children() { return clip_children_.get(); } 178 std::set<LayerImpl*>* clip_children() { return clip_children_.get(); }
178 const std::set<LayerImpl*>* clip_children() const { 179 const std::set<LayerImpl*>* clip_children() const {
179 return clip_children_.get(); 180 return clip_children_.get();
180 } 181 }
181 182
182 void PassCopyRequests(std::vector<scoped_ptr<CopyOutputRequest>>* requests); 183 void PassCopyRequests(
184 std::vector<std::unique_ptr<CopyOutputRequest>>* requests);
183 // Can only be called when the layer has a copy request. 185 // Can only be called when the layer has a copy request.
184 void TakeCopyRequestsAndTransformToTarget( 186 void TakeCopyRequestsAndTransformToTarget(
185 std::vector<scoped_ptr<CopyOutputRequest>>* request); 187 std::vector<std::unique_ptr<CopyOutputRequest>>* request);
186 bool HasCopyRequest() const { return !copy_requests_.empty(); } 188 bool HasCopyRequest() const { return !copy_requests_.empty(); }
187 bool InsideCopyRequest() const; 189 bool InsideCopyRequest() const;
188 190
189 void SetMaskLayer(scoped_ptr<LayerImpl> mask_layer); 191 void SetMaskLayer(std::unique_ptr<LayerImpl> mask_layer);
190 LayerImpl* mask_layer() { return mask_layer_; } 192 LayerImpl* mask_layer() { return mask_layer_; }
191 const LayerImpl* mask_layer() const { return mask_layer_; } 193 const LayerImpl* mask_layer() const { return mask_layer_; }
192 scoped_ptr<LayerImpl> TakeMaskLayer(); 194 std::unique_ptr<LayerImpl> TakeMaskLayer();
193 195
194 void SetReplicaLayer(scoped_ptr<LayerImpl> replica_layer); 196 void SetReplicaLayer(std::unique_ptr<LayerImpl> replica_layer);
195 LayerImpl* replica_layer() { return replica_layer_; } 197 LayerImpl* replica_layer() { return replica_layer_; }
196 const LayerImpl* replica_layer() const { return replica_layer_; } 198 const LayerImpl* replica_layer() const { return replica_layer_; }
197 scoped_ptr<LayerImpl> TakeReplicaLayer(); 199 std::unique_ptr<LayerImpl> TakeReplicaLayer();
198 200
199 bool has_mask() const { return !!mask_layer_; } 201 bool has_mask() const { return !!mask_layer_; }
200 bool has_replica() const { return !!replica_layer_; } 202 bool has_replica() const { return !!replica_layer_; }
201 bool replica_has_mask() const { 203 bool replica_has_mask() const {
202 return replica_layer_ && (mask_layer_ || replica_layer_->mask_layer_); 204 return replica_layer_ && (mask_layer_ || replica_layer_->mask_layer_);
203 } 205 }
204 206
205 LayerTreeImpl* layer_tree_impl() const { return layer_tree_impl_; } 207 LayerTreeImpl* layer_tree_impl() const { return layer_tree_impl_; }
206 208
207 void PopulateSharedQuadState(SharedQuadState* state) const; 209 void PopulateSharedQuadState(SharedQuadState* state) const;
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after
514 virtual void DidBeginTracing(); 516 virtual void DidBeginTracing();
515 517
516 // Release resources held by this layer. Called when the output surface 518 // Release resources held by this layer. Called when the output surface
517 // that rendered this layer was lost or a rendering mode switch has occured. 519 // that rendered this layer was lost or a rendering mode switch has occured.
518 virtual void ReleaseResources(); 520 virtual void ReleaseResources();
519 521
520 // Recreate resources that are required after they were released by a 522 // Recreate resources that are required after they were released by a
521 // ReleaseResources call. 523 // ReleaseResources call.
522 virtual void RecreateResources(); 524 virtual void RecreateResources();
523 525
524 virtual scoped_ptr<LayerImpl> CreateLayerImpl(LayerTreeImpl* tree_impl); 526 virtual std::unique_ptr<LayerImpl> CreateLayerImpl(LayerTreeImpl* tree_impl);
525 virtual void PushPropertiesTo(LayerImpl* layer); 527 virtual void PushPropertiesTo(LayerImpl* layer);
526 528
527 virtual void GetAllPrioritizedTilesForTracing( 529 virtual void GetAllPrioritizedTilesForTracing(
528 std::vector<PrioritizedTile>* prioritized_tiles) const; 530 std::vector<PrioritizedTile>* prioritized_tiles) const;
529 virtual void AsValueInto(base::trace_event::TracedValue* dict) const; 531 virtual void AsValueInto(base::trace_event::TracedValue* dict) const;
530 532
531 virtual size_t GPUMemoryUsageInBytes() const; 533 virtual size_t GPUMemoryUsageInBytes() const;
532 534
533 void SetNeedsPushProperties(); 535 void SetNeedsPushProperties();
534 536
535 virtual void RunMicroBenchmark(MicroBenchmarkImpl* benchmark); 537 virtual void RunMicroBenchmark(MicroBenchmarkImpl* benchmark);
536 538
537 void SetDebugInfo( 539 void SetDebugInfo(
538 scoped_ptr<base::trace_event::ConvertableToTraceFormat> debug_info); 540 std::unique_ptr<base::trace_event::ConvertableToTraceFormat> debug_info);
539 541
540 bool IsDrawnRenderSurfaceLayerListMember() const; 542 bool IsDrawnRenderSurfaceLayerListMember() const;
541 543
542 void Set3dSortingContextId(int id); 544 void Set3dSortingContextId(int id);
543 int sorting_context_id() { return sorting_context_id_; } 545 int sorting_context_id() { return sorting_context_id_; }
544 546
545 void SetFrameTimingRequests( 547 void SetFrameTimingRequests(
546 const std::vector<FrameTimingRequest>& frame_timing_requests); 548 const std::vector<FrameTimingRequest>& frame_timing_requests);
547 const std::vector<FrameTimingRequest>& frame_timing_requests() const { 549 const std::vector<FrameTimingRequest>& frame_timing_requests() const {
548 return frame_timing_requests_; 550 return frame_timing_requests_;
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
634 // Properties internal to LayerImpl 636 // Properties internal to LayerImpl
635 LayerImpl* parent_; 637 LayerImpl* parent_;
636 LayerImplList children_; 638 LayerImplList children_;
637 639
638 LayerImpl* scroll_parent_; 640 LayerImpl* scroll_parent_;
639 641
640 // Storing a pointer to a set rather than a set since this will be rarely 642 // Storing a pointer to a set rather than a set since this will be rarely
641 // used. If this pointer turns out to be too heavy, we could have this (and 643 // used. If this pointer turns out to be too heavy, we could have this (and
642 // the scroll parent above) be stored in a LayerImpl -> scroll_info 644 // the scroll parent above) be stored in a LayerImpl -> scroll_info
643 // map somewhere. 645 // map somewhere.
644 scoped_ptr<std::set<LayerImpl*>> scroll_children_; 646 std::unique_ptr<std::set<LayerImpl*>> scroll_children_;
645 647
646 LayerImpl* clip_parent_; 648 LayerImpl* clip_parent_;
647 scoped_ptr<std::set<LayerImpl*>> clip_children_; 649 std::unique_ptr<std::set<LayerImpl*>> clip_children_;
648 650
649 // mask_layer_ can be temporarily stolen during tree sync, we need this ID to 651 // mask_layer_ can be temporarily stolen during tree sync, we need this ID to
650 // confirm newly assigned layer is still the previous one 652 // confirm newly assigned layer is still the previous one
651 int mask_layer_id_; 653 int mask_layer_id_;
652 LayerImpl* mask_layer_; 654 LayerImpl* mask_layer_;
653 int replica_layer_id_; // ditto 655 int replica_layer_id_; // ditto
654 LayerImpl* replica_layer_; 656 LayerImpl* replica_layer_;
655 int layer_id_; 657 int layer_id_;
656 LayerTreeImpl* layer_tree_impl_; 658 LayerTreeImpl* layer_tree_impl_;
657 659
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
741 uint32_t mutable_properties_; 743 uint32_t mutable_properties_;
742 // Rect indicating what was repainted/updated during update. 744 // Rect indicating what was repainted/updated during update.
743 // Note that plugin layers bypass this and leave it empty. 745 // Note that plugin layers bypass this and leave it empty.
744 // This is in the layer's space. 746 // This is in the layer's space.
745 gfx::Rect update_rect_; 747 gfx::Rect update_rect_;
746 748
747 // Denotes an area that is damaged and needs redraw. This is in the layer's 749 // Denotes an area that is damaged and needs redraw. This is in the layer's
748 // space. 750 // space.
749 gfx::Rect damage_rect_; 751 gfx::Rect damage_rect_;
750 752
751 std::vector<scoped_ptr<CopyOutputRequest>> copy_requests_; 753 std::vector<std::unique_ptr<CopyOutputRequest>> copy_requests_;
752 754
753 // Group of properties that need to be computed based on the layer tree 755 // Group of properties that need to be computed based on the layer tree
754 // hierarchy before layers can be drawn. 756 // hierarchy before layers can be drawn.
755 DrawProperties draw_properties_; 757 DrawProperties draw_properties_;
756 PerformanceProperties<LayerImpl> performance_properties_; 758 PerformanceProperties<LayerImpl> performance_properties_;
757 759
758 scoped_ptr<base::trace_event::ConvertableToTraceFormat> owned_debug_info_; 760 std::unique_ptr<base::trace_event::ConvertableToTraceFormat>
761 owned_debug_info_;
759 base::trace_event::ConvertableToTraceFormat* debug_info_; 762 base::trace_event::ConvertableToTraceFormat* debug_info_;
760 scoped_ptr<RenderSurfaceImpl> render_surface_; 763 std::unique_ptr<RenderSurfaceImpl> render_surface_;
761 764
762 bool force_render_surface_; 765 bool force_render_surface_;
763 766
764 std::vector<FrameTimingRequest> frame_timing_requests_; 767 std::vector<FrameTimingRequest> frame_timing_requests_;
765 bool frame_timing_requests_dirty_; 768 bool frame_timing_requests_dirty_;
766 bool layer_or_descendant_is_drawn_; 769 bool layer_or_descendant_is_drawn_;
767 // If true, the layer or one of its descendants has a touch handler. 770 // If true, the layer or one of its descendants has a touch handler.
768 bool layer_or_descendant_has_touch_handler_; 771 bool layer_or_descendant_has_touch_handler_;
769 772
770 DISALLOW_COPY_AND_ASSIGN(LayerImpl); 773 DISALLOW_COPY_AND_ASSIGN(LayerImpl);
771 }; 774 };
772 775
773 } // namespace cc 776 } // namespace cc
774 777
775 #endif // CC_LAYERS_LAYER_IMPL_H_ 778 #endif // CC_LAYERS_LAYER_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698