OLD | NEW |
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 Loading... |
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 template <typename T> | 124 static LayerPtrType PassLayerPtr(ContentLayerPtrType* layer) { |
125 static LayerPtrType PassLayerPtr(T* layer) { | |
126 LayerPtrType ref(*layer); | 125 LayerPtrType ref(*layer); |
127 *layer = NULL; | 126 *layer = NULL; |
128 return ref; | 127 return ref; |
| 128 } |
| 129 |
| 130 static LayerPtrType PassLayerPtr(LayerPtrType* layer) { |
| 131 LayerPtrType ref(*layer); |
| 132 *layer = NULL; |
| 133 return ref; |
129 } | 134 } |
130 | 135 |
131 static void DestroyLayer(LayerPtrType* layer) { *layer = NULL; } | 136 static void DestroyLayer(LayerPtrType* layer) { *layer = NULL; } |
132 | 137 |
133 static void RecursiveUpdateNumChildren(LayerType* layerType) {} | 138 static void RecursiveUpdateNumChildren(LayerType* layerType) {} |
134 }; | 139 }; |
135 | 140 |
136 struct OcclusionTrackerTestImplThreadTypes { | 141 struct OcclusionTrackerTestImplThreadTypes { |
137 typedef LayerImpl LayerType; | 142 typedef LayerImpl LayerType; |
138 typedef LayerTreeImpl HostType; | 143 typedef LayerTreeImpl HostType; |
139 typedef RenderSurfaceImpl RenderSurfaceType; | 144 typedef RenderSurfaceImpl RenderSurfaceType; |
140 typedef TestContentLayerImpl ContentLayerType; | 145 typedef TestContentLayerImpl ContentLayerType; |
141 typedef scoped_ptr<LayerImpl> LayerPtrType; | 146 typedef scoped_ptr<LayerImpl> LayerPtrType; |
142 typedef scoped_ptr<ContentLayerType> ContentLayerPtrType; | 147 typedef scoped_ptr<ContentLayerType> ContentLayerPtrType; |
143 typedef LayerIterator<LayerImpl> TestLayerIterator; | 148 typedef LayerIterator<LayerImpl> TestLayerIterator; |
144 typedef OcclusionTracker<LayerImpl> OcclusionTrackerType; | 149 typedef OcclusionTracker<LayerImpl> OcclusionTrackerType; |
145 | 150 |
146 static LayerPtrType CreateLayer(HostType* host) { | 151 static LayerPtrType CreateLayer(HostType* host) { |
147 return LayerImpl::Create(host, next_layer_impl_id++); | 152 return LayerImpl::Create(host, next_layer_impl_id++); |
148 } | 153 } |
149 static ContentLayerPtrType CreateContentLayer(HostType* host) { | 154 static ContentLayerPtrType CreateContentLayer(HostType* host) { |
150 return make_scoped_ptr(new ContentLayerType(host, next_layer_impl_id++)); | 155 return make_scoped_ptr(new ContentLayerType(host, next_layer_impl_id++)); |
151 } | 156 } |
152 static int next_layer_impl_id; | 157 static int next_layer_impl_id; |
153 | 158 |
154 template <typename T> | 159 static LayerPtrType PassLayerPtr(LayerPtrType* layer) { |
155 static LayerPtrType PassLayerPtr(T* layer) { | |
156 return layer->Pass(); | 160 return layer->Pass(); |
157 } | 161 } |
158 | 162 |
| 163 static LayerPtrType PassLayerPtr(ContentLayerPtrType* layer) { |
| 164 return layer->PassAs<LayerType>(); |
| 165 } |
| 166 |
159 static void DestroyLayer(LayerPtrType* layer) { layer->reset(); } | 167 static void DestroyLayer(LayerPtrType* layer) { layer->reset(); } |
160 | 168 |
161 static void RecursiveUpdateNumChildren(LayerType* layer) { | 169 static void RecursiveUpdateNumChildren(LayerType* layer) { |
162 FakeLayerTreeHostImpl::RecursiveUpdateNumChildren(layer); | 170 FakeLayerTreeHostImpl::RecursiveUpdateNumChildren(layer); |
163 } | 171 } |
164 }; | 172 }; |
165 | 173 |
166 int OcclusionTrackerTestImplThreadTypes::next_layer_impl_id = 1; | 174 int OcclusionTrackerTestImplThreadTypes::next_layer_impl_id = 1; |
167 | 175 |
168 template <typename Types> class OcclusionTrackerTest : public testing::Test { | 176 template <typename Types> class OcclusionTrackerTest : public testing::Test { |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
271 const gfx::Size& bounds, | 279 const gfx::Size& bounds, |
272 bool opaque) { | 280 bool opaque) { |
273 typename Types::ContentLayerType* layer = | 281 typename Types::ContentLayerType* layer = |
274 CreateDrawingLayer(parent, transform, position, bounds, opaque); | 282 CreateDrawingLayer(parent, transform, position, bounds, opaque); |
275 layer->SetForceRenderSurface(true); | 283 layer->SetForceRenderSurface(true); |
276 return layer; | 284 return layer; |
277 } | 285 } |
278 | 286 |
279 void DestroyLayers() { | 287 void DestroyLayers() { |
280 Types::DestroyLayer(&root_); | 288 Types::DestroyLayer(&root_); |
281 render_surface_layer_list_ = nullptr; | 289 render_surface_layer_list_.reset(); |
282 render_surface_layer_list_impl_.clear(); | 290 render_surface_layer_list_impl_.clear(); |
283 replica_layers_.clear(); | 291 replica_layers_.clear(); |
284 mask_layers_.clear(); | 292 mask_layers_.clear(); |
285 ResetLayerIterator(); | 293 ResetLayerIterator(); |
286 } | 294 } |
287 | 295 |
288 void CopyOutputCallback(scoped_ptr<CopyOutputResult> result) {} | 296 void CopyOutputCallback(scoped_ptr<CopyOutputResult> result) {} |
289 | 297 |
290 void AddCopyRequest(Layer* layer) { | 298 void AddCopyRequest(Layer* layer) { |
291 layer->RequestCopyOfOutput( | 299 layer->RequestCopyOfOutput( |
(...skipping 3009 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3301 EXPECT_EQ(gfx::Rect(), | 3309 EXPECT_EQ(gfx::Rect(), |
3302 occlusion.UnoccludedSurfaceContentRect( | 3310 occlusion.UnoccludedSurfaceContentRect( |
3303 surface, gfx::Rect(80, 70, 50, 50))); | 3311 surface, gfx::Rect(80, 70, 50, 50))); |
3304 } | 3312 } |
3305 }; | 3313 }; |
3306 | 3314 |
3307 ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestUnoccludedSurfaceQuery) | 3315 ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestUnoccludedSurfaceQuery) |
3308 | 3316 |
3309 } // namespace | 3317 } // namespace |
3310 } // namespace cc | 3318 } // namespace cc |
OLD | NEW |