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

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

Issue 609663003: cc: Remove use of PassAs() and constructor-casting with scoped_ptr. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: cc-passas: PassAs-presubmit-warning Created 6 years, 2 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/single_thread_proxy.cc » ('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 "cc/animation/layer_animation_controller.h" 7 #include "cc/animation/layer_animation_controller.h"
8 #include "cc/base/math_util.h" 8 #include "cc/base/math_util.h"
9 #include "cc/layers/layer.h" 9 #include "cc/layers/layer.h"
10 #include "cc/layers/layer_impl.h" 10 #include "cc/layers/layer_impl.h"
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 typedef scoped_refptr<Layer> LayerPtrType; 114 typedef scoped_refptr<Layer> LayerPtrType;
115 typedef scoped_refptr<ContentLayerType> ContentLayerPtrType; 115 typedef scoped_refptr<ContentLayerType> ContentLayerPtrType;
116 typedef LayerIterator<Layer> TestLayerIterator; 116 typedef LayerIterator<Layer> TestLayerIterator;
117 typedef OcclusionTracker<Layer> OcclusionTrackerType; 117 typedef OcclusionTracker<Layer> OcclusionTrackerType;
118 118
119 static LayerPtrType CreateLayer(HostType* host) { return Layer::Create(); } 119 static LayerPtrType CreateLayer(HostType* host) { return Layer::Create(); }
120 static ContentLayerPtrType CreateContentLayer(HostType* host) { 120 static ContentLayerPtrType CreateContentLayer(HostType* host) {
121 return make_scoped_refptr(new ContentLayerType()); 121 return make_scoped_refptr(new ContentLayerType());
122 } 122 }
123 123
124 static LayerPtrType PassLayerPtr(ContentLayerPtrType* layer) { 124 template <typename T>
125 static LayerPtrType PassLayerPtr(T* layer) {
125 LayerPtrType ref(*layer); 126 LayerPtrType ref(*layer);
126 *layer = NULL; 127 *layer = NULL;
127 return ref; 128 return ref;
128 }
129
130 static LayerPtrType PassLayerPtr(LayerPtrType* layer) {
131 LayerPtrType ref(*layer);
132 *layer = NULL;
133 return ref;
134 } 129 }
135 130
136 static void DestroyLayer(LayerPtrType* layer) { *layer = NULL; } 131 static void DestroyLayer(LayerPtrType* layer) { *layer = NULL; }
137 132
138 static void RecursiveUpdateNumChildren(LayerType* layerType) {} 133 static void RecursiveUpdateNumChildren(LayerType* layerType) {}
139 }; 134 };
140 135
141 struct OcclusionTrackerTestImplThreadTypes { 136 struct OcclusionTrackerTestImplThreadTypes {
142 typedef LayerImpl LayerType; 137 typedef LayerImpl LayerType;
143 typedef LayerTreeImpl HostType; 138 typedef LayerTreeImpl HostType;
144 typedef RenderSurfaceImpl RenderSurfaceType; 139 typedef RenderSurfaceImpl RenderSurfaceType;
145 typedef TestContentLayerImpl ContentLayerType; 140 typedef TestContentLayerImpl ContentLayerType;
146 typedef scoped_ptr<LayerImpl> LayerPtrType; 141 typedef scoped_ptr<LayerImpl> LayerPtrType;
147 typedef scoped_ptr<ContentLayerType> ContentLayerPtrType; 142 typedef scoped_ptr<ContentLayerType> ContentLayerPtrType;
148 typedef LayerIterator<LayerImpl> TestLayerIterator; 143 typedef LayerIterator<LayerImpl> TestLayerIterator;
149 typedef OcclusionTracker<LayerImpl> OcclusionTrackerType; 144 typedef OcclusionTracker<LayerImpl> OcclusionTrackerType;
150 145
151 static LayerPtrType CreateLayer(HostType* host) { 146 static LayerPtrType CreateLayer(HostType* host) {
152 return LayerImpl::Create(host, next_layer_impl_id++); 147 return LayerImpl::Create(host, next_layer_impl_id++);
153 } 148 }
154 static ContentLayerPtrType CreateContentLayer(HostType* host) { 149 static ContentLayerPtrType CreateContentLayer(HostType* host) {
155 return make_scoped_ptr(new ContentLayerType(host, next_layer_impl_id++)); 150 return make_scoped_ptr(new ContentLayerType(host, next_layer_impl_id++));
156 } 151 }
157 static int next_layer_impl_id; 152 static int next_layer_impl_id;
158 153
159 static LayerPtrType PassLayerPtr(LayerPtrType* layer) { 154 template <typename T>
155 static LayerPtrType PassLayerPtr(T* layer) {
160 return layer->Pass(); 156 return layer->Pass();
161 } 157 }
162 158
163 static LayerPtrType PassLayerPtr(ContentLayerPtrType* layer) {
164 return layer->PassAs<LayerType>();
165 }
166
167 static void DestroyLayer(LayerPtrType* layer) { layer->reset(); } 159 static void DestroyLayer(LayerPtrType* layer) { layer->reset(); }
168 160
169 static void RecursiveUpdateNumChildren(LayerType* layer) { 161 static void RecursiveUpdateNumChildren(LayerType* layer) {
170 FakeLayerTreeHostImpl::RecursiveUpdateNumChildren(layer); 162 FakeLayerTreeHostImpl::RecursiveUpdateNumChildren(layer);
171 } 163 }
172 }; 164 };
173 165
174 int OcclusionTrackerTestImplThreadTypes::next_layer_impl_id = 1; 166 int OcclusionTrackerTestImplThreadTypes::next_layer_impl_id = 1;
175 167
176 template <typename Types> class OcclusionTrackerTest : public testing::Test { 168 template <typename Types> class OcclusionTrackerTest : public testing::Test {
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
279 const gfx::Size& bounds, 271 const gfx::Size& bounds,
280 bool opaque) { 272 bool opaque) {
281 typename Types::ContentLayerType* layer = 273 typename Types::ContentLayerType* layer =
282 CreateDrawingLayer(parent, transform, position, bounds, opaque); 274 CreateDrawingLayer(parent, transform, position, bounds, opaque);
283 layer->SetForceRenderSurface(true); 275 layer->SetForceRenderSurface(true);
284 return layer; 276 return layer;
285 } 277 }
286 278
287 void DestroyLayers() { 279 void DestroyLayers() {
288 Types::DestroyLayer(&root_); 280 Types::DestroyLayer(&root_);
289 render_surface_layer_list_.reset(); 281 render_surface_layer_list_ = nullptr;
290 render_surface_layer_list_impl_.clear(); 282 render_surface_layer_list_impl_.clear();
291 replica_layers_.clear(); 283 replica_layers_.clear();
292 mask_layers_.clear(); 284 mask_layers_.clear();
293 ResetLayerIterator(); 285 ResetLayerIterator();
294 } 286 }
295 287
296 void CopyOutputCallback(scoped_ptr<CopyOutputResult> result) {} 288 void CopyOutputCallback(scoped_ptr<CopyOutputResult> result) {}
297 289
298 void AddCopyRequest(Layer* layer) { 290 void AddCopyRequest(Layer* layer) {
299 layer->RequestCopyOfOutput( 291 layer->RequestCopyOfOutput(
(...skipping 3009 matching lines...) Expand 10 before | Expand all | Expand 10 after
3309 EXPECT_EQ(gfx::Rect(), 3301 EXPECT_EQ(gfx::Rect(),
3310 occlusion.UnoccludedSurfaceContentRect( 3302 occlusion.UnoccludedSurfaceContentRect(
3311 surface, gfx::Rect(80, 70, 50, 50))); 3303 surface, gfx::Rect(80, 70, 50, 50)));
3312 } 3304 }
3313 }; 3305 };
3314 3306
3315 ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestUnoccludedSurfaceQuery) 3307 ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestUnoccludedSurfaceQuery)
3316 3308
3317 } // namespace 3309 } // namespace
3318 } // namespace cc 3310 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/occlusion_tracker_perftest.cc ('k') | cc/trees/single_thread_proxy.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698