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

Side by Side Diff: cc/trees/occlusion_tracker_unittest.cc

Issue 1866203004: Convert //cc from scoped_ptr to std::unique_ptr. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: scopedptrcc: rebase 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
« no previous file with comments | « cc/trees/occlusion_tracker_perftest.cc ('k') | cc/trees/proxy.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 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 #include "cc/trees/occlusion_tracker.h" 5 #include "cc/trees/occlusion_tracker.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "cc/animation/layer_animation_controller.h" 9 #include "cc/animation/layer_animation_controller.h"
10 #include "cc/base/math_util.h" 10 #include "cc/base/math_util.h"
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 94
95 virtual void RunMyTest() = 0; 95 virtual void RunMyTest() = 0;
96 96
97 void TearDown() override { DestroyLayers(); } 97 void TearDown() override { DestroyLayers(); }
98 98
99 TestContentLayerImpl* CreateRoot(const gfx::Transform& transform, 99 TestContentLayerImpl* CreateRoot(const gfx::Transform& transform,
100 const gfx::PointF& position, 100 const gfx::PointF& position,
101 const gfx::Size& bounds) { 101 const gfx::Size& bounds) {
102 LayerTreeImpl* tree = host_->host_impl()->active_tree(); 102 LayerTreeImpl* tree = host_->host_impl()->active_tree();
103 int id = next_layer_impl_id_++; 103 int id = next_layer_impl_id_++;
104 scoped_ptr<TestContentLayerImpl> layer(new TestContentLayerImpl(tree, id)); 104 std::unique_ptr<TestContentLayerImpl> layer(
105 new TestContentLayerImpl(tree, id));
105 TestContentLayerImpl* layer_ptr = layer.get(); 106 TestContentLayerImpl* layer_ptr = layer.get();
106 SetProperties(layer_ptr, transform, position, bounds); 107 SetProperties(layer_ptr, transform, position, bounds);
107 108
108 host_->host_impl()->active_tree()->SetRootLayer(std::move(layer)); 109 host_->host_impl()->active_tree()->SetRootLayer(std::move(layer));
109 110
110 layer_ptr->SetForceRenderSurface(true); 111 layer_ptr->SetForceRenderSurface(true);
111 SetRootLayerOnMainThread(layer_ptr); 112 SetRootLayerOnMainThread(layer_ptr);
112 113
113 return layer_ptr; 114 return layer_ptr;
114 } 115 }
115 116
116 LayerImpl* CreateLayer(LayerImpl* parent, 117 LayerImpl* CreateLayer(LayerImpl* parent,
117 const gfx::Transform& transform, 118 const gfx::Transform& transform,
118 const gfx::PointF& position, 119 const gfx::PointF& position,
119 const gfx::Size& bounds) { 120 const gfx::Size& bounds) {
120 LayerTreeImpl* tree = host_->host_impl()->active_tree(); 121 LayerTreeImpl* tree = host_->host_impl()->active_tree();
121 int id = next_layer_impl_id_++; 122 int id = next_layer_impl_id_++;
122 scoped_ptr<LayerImpl> layer = LayerImpl::Create(tree, id); 123 std::unique_ptr<LayerImpl> layer = LayerImpl::Create(tree, id);
123 LayerImpl* layer_ptr = layer.get(); 124 LayerImpl* layer_ptr = layer.get();
124 SetProperties(layer_ptr, transform, position, bounds); 125 SetProperties(layer_ptr, transform, position, bounds);
125 parent->AddChild(std::move(layer)); 126 parent->AddChild(std::move(layer));
126 return layer_ptr; 127 return layer_ptr;
127 } 128 }
128 129
129 LayerImpl* CreateSurface(LayerImpl* parent, 130 LayerImpl* CreateSurface(LayerImpl* parent,
130 const gfx::Transform& transform, 131 const gfx::Transform& transform,
131 const gfx::PointF& position, 132 const gfx::PointF& position,
132 const gfx::Size& bounds) { 133 const gfx::Size& bounds) {
133 LayerImpl* layer = CreateLayer(parent, transform, position, bounds); 134 LayerImpl* layer = CreateLayer(parent, transform, position, bounds);
134 layer->SetForceRenderSurface(true); 135 layer->SetForceRenderSurface(true);
135 return layer; 136 return layer;
136 } 137 }
137 138
138 TestContentLayerImpl* CreateDrawingLayer(LayerImpl* parent, 139 TestContentLayerImpl* CreateDrawingLayer(LayerImpl* parent,
139 const gfx::Transform& transform, 140 const gfx::Transform& transform,
140 const gfx::PointF& position, 141 const gfx::PointF& position,
141 const gfx::Size& bounds, 142 const gfx::Size& bounds,
142 bool opaque) { 143 bool opaque) {
143 LayerTreeImpl* tree = host_->host_impl()->active_tree(); 144 LayerTreeImpl* tree = host_->host_impl()->active_tree();
144 int id = next_layer_impl_id_++; 145 int id = next_layer_impl_id_++;
145 scoped_ptr<TestContentLayerImpl> layer(new TestContentLayerImpl(tree, id)); 146 std::unique_ptr<TestContentLayerImpl> layer(
147 new TestContentLayerImpl(tree, id));
146 TestContentLayerImpl* layer_ptr = layer.get(); 148 TestContentLayerImpl* layer_ptr = layer.get();
147 SetProperties(layer_ptr, transform, position, bounds); 149 SetProperties(layer_ptr, transform, position, bounds);
148 150
149 if (opaque_layers_) { 151 if (opaque_layers_) {
150 layer_ptr->SetContentsOpaque(opaque); 152 layer_ptr->SetContentsOpaque(opaque);
151 } else { 153 } else {
152 layer_ptr->SetContentsOpaque(false); 154 layer_ptr->SetContentsOpaque(false);
153 if (opaque) 155 if (opaque)
154 layer_ptr->SetOpaqueContentsRect(gfx::Rect(bounds)); 156 layer_ptr->SetOpaqueContentsRect(gfx::Rect(bounds));
155 else 157 else
156 layer_ptr->SetOpaqueContentsRect(gfx::Rect()); 158 layer_ptr->SetOpaqueContentsRect(gfx::Rect());
157 } 159 }
158 160
159 parent->AddChild(std::move(layer)); 161 parent->AddChild(std::move(layer));
160 return layer_ptr; 162 return layer_ptr;
161 } 163 }
162 164
163 LayerImpl* CreateReplicaLayer(LayerImpl* owning_layer, 165 LayerImpl* CreateReplicaLayer(LayerImpl* owning_layer,
164 const gfx::Transform& transform, 166 const gfx::Transform& transform,
165 const gfx::PointF& position, 167 const gfx::PointF& position,
166 const gfx::Size& bounds) { 168 const gfx::Size& bounds) {
167 LayerTreeImpl* tree = host_->host_impl()->active_tree(); 169 LayerTreeImpl* tree = host_->host_impl()->active_tree();
168 int id = next_layer_impl_id_++; 170 int id = next_layer_impl_id_++;
169 scoped_ptr<TestContentLayerImpl> layer(new TestContentLayerImpl(tree, id)); 171 std::unique_ptr<TestContentLayerImpl> layer(
172 new TestContentLayerImpl(tree, id));
170 TestContentLayerImpl* layer_ptr = layer.get(); 173 TestContentLayerImpl* layer_ptr = layer.get();
171 SetProperties(layer_ptr, transform, position, bounds); 174 SetProperties(layer_ptr, transform, position, bounds);
172 SetReplica(owning_layer, std::move(layer)); 175 SetReplica(owning_layer, std::move(layer));
173 return layer_ptr; 176 return layer_ptr;
174 } 177 }
175 178
176 LayerImpl* CreateMaskLayer(LayerImpl* owning_layer, const gfx::Size& bounds) { 179 LayerImpl* CreateMaskLayer(LayerImpl* owning_layer, const gfx::Size& bounds) {
177 LayerTreeImpl* tree = host_->host_impl()->active_tree(); 180 LayerTreeImpl* tree = host_->host_impl()->active_tree();
178 int id = next_layer_impl_id_++; 181 int id = next_layer_impl_id_++;
179 scoped_ptr<TestContentLayerImpl> layer(new TestContentLayerImpl(tree, id)); 182 std::unique_ptr<TestContentLayerImpl> layer(
183 new TestContentLayerImpl(tree, id));
180 TestContentLayerImpl* layer_ptr = layer.get(); 184 TestContentLayerImpl* layer_ptr = layer.get();
181 SetProperties(layer_ptr, identity_matrix, gfx::PointF(), bounds); 185 SetProperties(layer_ptr, identity_matrix, gfx::PointF(), bounds);
182 SetMask(owning_layer, std::move(layer)); 186 SetMask(owning_layer, std::move(layer));
183 return layer_ptr; 187 return layer_ptr;
184 } 188 }
185 189
186 TestContentLayerImpl* CreateDrawingSurface(LayerImpl* parent, 190 TestContentLayerImpl* CreateDrawingSurface(LayerImpl* parent,
187 const gfx::Transform& transform, 191 const gfx::Transform& transform,
188 const gfx::PointF& position, 192 const gfx::PointF& position,
189 const gfx::Size& bounds, 193 const gfx::Size& bounds,
190 bool opaque) { 194 bool opaque) {
191 TestContentLayerImpl* layer = 195 TestContentLayerImpl* layer =
192 CreateDrawingLayer(parent, transform, position, bounds, opaque); 196 CreateDrawingLayer(parent, transform, position, bounds, opaque);
193 layer->SetForceRenderSurface(true); 197 layer->SetForceRenderSurface(true);
194 return layer; 198 return layer;
195 } 199 }
196 200
197 void DestroyLayers() { 201 void DestroyLayers() {
198 host_->host_impl()->active_tree()->SetRootLayer(nullptr); 202 host_->host_impl()->active_tree()->SetRootLayer(nullptr);
199 render_surface_layer_list_impl_.clear(); 203 render_surface_layer_list_impl_.clear();
200 replica_layers_.clear(); 204 replica_layers_.clear();
201 mask_layers_.clear(); 205 mask_layers_.clear();
202 ResetLayerIterator(); 206 ResetLayerIterator();
203 } 207 }
204 208
205 void CopyOutputCallback(scoped_ptr<CopyOutputResult> result) {} 209 void CopyOutputCallback(std::unique_ptr<CopyOutputResult> result) {}
206 210
207 void AddCopyRequest(Layer* layer) { 211 void AddCopyRequest(Layer* layer) {
208 layer->RequestCopyOfOutput(CopyOutputRequest::CreateBitmapRequest( 212 layer->RequestCopyOfOutput(CopyOutputRequest::CreateBitmapRequest(
209 base::Bind(&OcclusionTrackerTest::CopyOutputCallback, 213 base::Bind(&OcclusionTrackerTest::CopyOutputCallback,
210 base::Unretained(this)))); 214 base::Unretained(this))));
211 } 215 }
212 216
213 void AddCopyRequest(LayerImpl* layer) { 217 void AddCopyRequest(LayerImpl* layer) {
214 std::vector<scoped_ptr<CopyOutputRequest>> requests; 218 std::vector<std::unique_ptr<CopyOutputRequest>> requests;
215 requests.push_back(CopyOutputRequest::CreateBitmapRequest(base::Bind( 219 requests.push_back(CopyOutputRequest::CreateBitmapRequest(base::Bind(
216 &OcclusionTrackerTest::CopyOutputCallback, base::Unretained(this)))); 220 &OcclusionTrackerTest::CopyOutputCallback, base::Unretained(this))));
217 layer->PassCopyRequests(&requests); 221 layer->PassCopyRequests(&requests);
218 } 222 }
219 223
220 void CalcDrawEtc(TestContentLayerImpl* root) { 224 void CalcDrawEtc(TestContentLayerImpl* root) {
221 DCHECK(root == root->layer_tree_impl()->root_layer()); 225 DCHECK(root == root->layer_tree_impl()->root_layer());
222 226
223 // These occlusion tests attach and detach layers in multiple 227 // These occlusion tests attach and detach layers in multiple
224 // iterations, so rebuild property trees every time. 228 // iterations, so rebuild property trees every time.
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
290 294
291 void SetProperties(LayerImpl* layer, 295 void SetProperties(LayerImpl* layer,
292 const gfx::Transform& transform, 296 const gfx::Transform& transform,
293 const gfx::PointF& position, 297 const gfx::PointF& position,
294 const gfx::Size& bounds) { 298 const gfx::Size& bounds) {
295 layer->SetTransform(transform); 299 layer->SetTransform(transform);
296 layer->SetPosition(position); 300 layer->SetPosition(position);
297 layer->SetBounds(bounds); 301 layer->SetBounds(bounds);
298 } 302 }
299 303
300 void SetReplica(LayerImpl* owning_layer, scoped_ptr<LayerImpl> layer) { 304 void SetReplica(LayerImpl* owning_layer, std::unique_ptr<LayerImpl> layer) {
301 // We need to set parent on replica layer for property tree building. 305 // We need to set parent on replica layer for property tree building.
302 layer->SetParent(owning_layer); 306 layer->SetParent(owning_layer);
303 owning_layer->SetReplicaLayer(std::move(layer)); 307 owning_layer->SetReplicaLayer(std::move(layer));
304 } 308 }
305 309
306 void SetMask(LayerImpl* owning_layer, scoped_ptr<LayerImpl> layer) { 310 void SetMask(LayerImpl* owning_layer, std::unique_ptr<LayerImpl> layer) {
307 owning_layer->SetMaskLayer(std::move(layer)); 311 owning_layer->SetMaskLayer(std::move(layer));
308 } 312 }
309 313
310 bool opaque_layers_; 314 bool opaque_layers_;
311 FakeLayerTreeHostClient client_; 315 FakeLayerTreeHostClient client_;
312 TestTaskGraphRunner task_graph_runner_; 316 TestTaskGraphRunner task_graph_runner_;
313 scoped_ptr<FakeLayerTreeHost> host_; 317 std::unique_ptr<FakeLayerTreeHost> host_;
314 // These hold ownership of the layers for the duration of the test. 318 // These hold ownership of the layers for the duration of the test.
315 LayerImplList render_surface_layer_list_impl_; 319 LayerImplList render_surface_layer_list_impl_;
316 LayerIterator layer_iterator_begin_; 320 LayerIterator layer_iterator_begin_;
317 LayerIterator layer_iterator_; 321 LayerIterator layer_iterator_;
318 LayerList replica_layers_; 322 LayerList replica_layers_;
319 LayerList mask_layers_; 323 LayerList mask_layers_;
320 int next_layer_impl_id_; 324 int next_layer_impl_id_;
321 }; 325 };
322 326
323 #define RUN_TEST_IMPL_THREAD_OPAQUE_LAYERS(ClassName) \ 327 #define RUN_TEST_IMPL_THREAD_OPAQUE_LAYERS(ClassName) \
(...skipping 2189 matching lines...) Expand 10 before | Expand all | Expand 10 after
2513 EXPECT_EQ(gfx::Rect(), 2517 EXPECT_EQ(gfx::Rect(),
2514 occlusion.UnoccludedSurfaceContentRect( 2518 occlusion.UnoccludedSurfaceContentRect(
2515 surface, gfx::Rect(80, 70, 50, 50))); 2519 surface, gfx::Rect(80, 70, 50, 50)));
2516 } 2520 }
2517 }; 2521 };
2518 2522
2519 ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestUnoccludedSurfaceQuery) 2523 ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestUnoccludedSurfaceQuery)
2520 2524
2521 } // namespace 2525 } // namespace
2522 } // namespace cc 2526 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/occlusion_tracker_perftest.cc ('k') | cc/trees/proxy.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698