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 <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include "cc/animation/animation_host.h" | 9 #include "cc/animation/animation_host.h" |
10 #include "cc/base/filter_operation.h" | 10 #include "cc/base/filter_operation.h" |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
183 TestContentLayerImpl* layer = | 183 TestContentLayerImpl* layer = |
184 CreateDrawingLayer(parent, transform, position, bounds, opaque); | 184 CreateDrawingLayer(parent, transform, position, bounds, opaque); |
185 layer->test_properties()->force_render_surface = true; | 185 layer->test_properties()->force_render_surface = true; |
186 return layer; | 186 return layer; |
187 } | 187 } |
188 | 188 |
189 void DestroyLayers() { | 189 void DestroyLayers() { |
190 host_->host_impl()->active_tree()->SetRootLayerForTesting(nullptr); | 190 host_->host_impl()->active_tree()->SetRootLayerForTesting(nullptr); |
191 render_surface_layer_list_impl_.clear(); | 191 render_surface_layer_list_impl_.clear(); |
192 mask_layers_.clear(); | 192 mask_layers_.clear(); |
193 ResetLayerIterator(); | 193 layer_iterator_.reset(); |
194 } | 194 } |
195 | 195 |
196 void CopyOutputCallback(std::unique_ptr<CopyOutputResult> result) {} | 196 void CopyOutputCallback(std::unique_ptr<CopyOutputResult> result) {} |
197 | 197 |
198 void AddCopyRequest(Layer* layer) { | 198 void AddCopyRequest(Layer* layer) { |
199 layer->RequestCopyOfOutput(CopyOutputRequest::CreateBitmapRequest( | 199 layer->RequestCopyOfOutput(CopyOutputRequest::CreateBitmapRequest( |
200 base::Bind(&OcclusionTrackerTest::CopyOutputCallback, | 200 base::Bind(&OcclusionTrackerTest::CopyOutputCallback, |
201 base::Unretained(this)))); | 201 base::Unretained(this)))); |
202 } | 202 } |
203 | 203 |
(...skipping 12 matching lines...) Expand all Loading... |
216 // iterations, so rebuild property trees every time. | 216 // iterations, so rebuild property trees every time. |
217 root->layer_tree_impl()->property_trees()->needs_rebuild = true; | 217 root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
218 | 218 |
219 FakeLayerTreeHostImpl::RecursiveUpdateNumChildren(root); | 219 FakeLayerTreeHostImpl::RecursiveUpdateNumChildren(root); |
220 | 220 |
221 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( | 221 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( |
222 root, root->bounds(), &render_surface_layer_list_impl_); | 222 root, root->bounds(), &render_surface_layer_list_impl_); |
223 inputs.can_adjust_raster_scales = true; | 223 inputs.can_adjust_raster_scales = true; |
224 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); | 224 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); |
225 | 225 |
226 layer_iterator_ = layer_iterator_begin_ = | 226 layer_iterator_ = base::MakeUnique<EffectTreeLayerListIterator>( |
227 LayerIterator::Begin(&render_surface_layer_list_impl_); | 227 host_->host_impl()->active_tree()); |
228 } | 228 } |
229 | 229 |
230 void EnterLayer(LayerImpl* layer, OcclusionTracker* occlusion) { | 230 void EnterLayer(LayerImpl* layer, OcclusionTracker* occlusion) { |
231 ASSERT_EQ(*layer_iterator_, layer); | 231 ASSERT_EQ(layer_iterator_->current_layer(), layer); |
232 ASSERT_TRUE(layer_iterator_.represents_itself()); | 232 ASSERT_TRUE(layer_iterator_->state() == |
233 occlusion->EnterLayer(layer_iterator_); | 233 EffectTreeLayerListIterator::State::LAYER); |
| 234 occlusion->EnterLayer(*layer_iterator_); |
234 } | 235 } |
235 | 236 |
236 void LeaveLayer(LayerImpl* layer, OcclusionTracker* occlusion) { | 237 void LeaveLayer(LayerImpl* layer, OcclusionTracker* occlusion) { |
237 ASSERT_EQ(*layer_iterator_, layer); | 238 ASSERT_EQ(layer_iterator_->current_layer(), layer); |
238 ASSERT_TRUE(layer_iterator_.represents_itself()); | 239 ASSERT_TRUE(layer_iterator_->state() == |
239 occlusion->LeaveLayer(layer_iterator_); | 240 EffectTreeLayerListIterator::State::LAYER); |
240 ++layer_iterator_; | 241 occlusion->LeaveLayer(*layer_iterator_); |
| 242 ++(*layer_iterator_); |
241 } | 243 } |
242 | 244 |
243 void VisitLayer(LayerImpl* layer, OcclusionTracker* occlusion) { | 245 void VisitLayer(LayerImpl* layer, OcclusionTracker* occlusion) { |
244 EnterLayer(layer, occlusion); | 246 EnterLayer(layer, occlusion); |
245 LeaveLayer(layer, occlusion); | 247 LeaveLayer(layer, occlusion); |
246 } | 248 } |
247 | 249 |
248 void EnterContributingSurface(LayerImpl* layer, OcclusionTracker* occlusion) { | 250 void EnterContributingSurface(LayerImpl* layer, OcclusionTracker* occlusion) { |
249 ASSERT_EQ(*layer_iterator_, layer); | 251 ASSERT_EQ(layer_iterator_->target_render_surface(), |
250 ASSERT_TRUE(layer_iterator_.represents_target_render_surface()); | 252 layer->GetRenderSurface()); |
251 occlusion->EnterLayer(layer_iterator_); | 253 ASSERT_TRUE(layer_iterator_->state() == |
252 occlusion->LeaveLayer(layer_iterator_); | 254 EffectTreeLayerListIterator::State::TARGET_SURFACE); |
253 ++layer_iterator_; | 255 occlusion->EnterLayer(*layer_iterator_); |
254 ASSERT_TRUE(layer_iterator_.represents_contributing_render_surface()); | 256 occlusion->LeaveLayer(*layer_iterator_); |
255 occlusion->EnterLayer(layer_iterator_); | 257 ++(*layer_iterator_); |
| 258 ASSERT_TRUE(layer_iterator_->state() == |
| 259 EffectTreeLayerListIterator::State::CONTRIBUTING_SURFACE); |
| 260 occlusion->EnterLayer(*layer_iterator_); |
256 } | 261 } |
257 | 262 |
258 void LeaveContributingSurface(LayerImpl* layer, OcclusionTracker* occlusion) { | 263 void LeaveContributingSurface(LayerImpl* layer, OcclusionTracker* occlusion) { |
259 ASSERT_EQ(*layer_iterator_, layer); | 264 ASSERT_EQ(layer_iterator_->current_render_surface(), |
260 ASSERT_TRUE(layer_iterator_.represents_contributing_render_surface()); | 265 layer->GetRenderSurface()); |
261 occlusion->LeaveLayer(layer_iterator_); | 266 ASSERT_TRUE(layer_iterator_->state() == |
262 ++layer_iterator_; | 267 EffectTreeLayerListIterator::State::CONTRIBUTING_SURFACE); |
| 268 occlusion->LeaveLayer(*layer_iterator_); |
| 269 ++(*layer_iterator_); |
263 } | 270 } |
264 | 271 |
265 void VisitContributingSurface(LayerImpl* layer, OcclusionTracker* occlusion) { | 272 void VisitContributingSurface(LayerImpl* layer, OcclusionTracker* occlusion) { |
266 EnterContributingSurface(layer, occlusion); | 273 EnterContributingSurface(layer, occlusion); |
267 LeaveContributingSurface(layer, occlusion); | 274 LeaveContributingSurface(layer, occlusion); |
268 } | 275 } |
269 | 276 |
270 void ResetLayerIterator() { layer_iterator_ = layer_iterator_begin_; } | 277 void ResetLayerIterator() { |
| 278 *layer_iterator_ = |
| 279 EffectTreeLayerListIterator(host_->host_impl()->active_tree()); |
| 280 } |
271 | 281 |
272 const gfx::Transform identity_matrix; | 282 const gfx::Transform identity_matrix; |
273 | 283 |
274 private: | 284 private: |
275 void SetRootLayerOnMainThread(Layer* root) { | 285 void SetRootLayerOnMainThread(Layer* root) { |
276 host_->SetRootLayer(scoped_refptr<Layer>(root)); | 286 host_->SetRootLayer(scoped_refptr<Layer>(root)); |
277 } | 287 } |
278 | 288 |
279 void SetRootLayerOnMainThread(LayerImpl* root) {} | 289 void SetRootLayerOnMainThread(LayerImpl* root) {} |
280 | 290 |
(...skipping 10 matching lines...) Expand all Loading... |
291 owning_layer->test_properties()->SetMaskLayer(std::move(layer)); | 301 owning_layer->test_properties()->SetMaskLayer(std::move(layer)); |
292 } | 302 } |
293 | 303 |
294 bool opaque_layers_; | 304 bool opaque_layers_; |
295 FakeLayerTreeHostClient client_; | 305 FakeLayerTreeHostClient client_; |
296 TestTaskGraphRunner task_graph_runner_; | 306 TestTaskGraphRunner task_graph_runner_; |
297 std::unique_ptr<AnimationHost> animation_host_; | 307 std::unique_ptr<AnimationHost> animation_host_; |
298 std::unique_ptr<FakeLayerTreeHost> host_; | 308 std::unique_ptr<FakeLayerTreeHost> host_; |
299 // These hold ownership of the layers for the duration of the test. | 309 // These hold ownership of the layers for the duration of the test. |
300 LayerImplList render_surface_layer_list_impl_; | 310 LayerImplList render_surface_layer_list_impl_; |
301 LayerIterator layer_iterator_begin_; | 311 std::unique_ptr<EffectTreeLayerListIterator> layer_iterator_; |
302 LayerIterator layer_iterator_; | |
303 LayerList mask_layers_; | 312 LayerList mask_layers_; |
304 int next_layer_impl_id_; | 313 int next_layer_impl_id_; |
305 }; | 314 }; |
306 | 315 |
307 #define RUN_TEST_IMPL_THREAD_OPAQUE_LAYERS(ClassName) \ | 316 #define RUN_TEST_IMPL_THREAD_OPAQUE_LAYERS(ClassName) \ |
308 class ClassName##ImplThreadOpaqueLayers : public ClassName { \ | 317 class ClassName##ImplThreadOpaqueLayers : public ClassName { \ |
309 public: /* NOLINT(whitespace/indent) */ \ | 318 public: /* NOLINT(whitespace/indent) */ \ |
310 ClassName##ImplThreadOpaqueLayers() : ClassName(true) {} \ | 319 ClassName##ImplThreadOpaqueLayers() : ClassName(true) {} \ |
311 }; \ | 320 }; \ |
312 TEST_F(ClassName##ImplThreadOpaqueLayers, RunTest) { RunMyTest(); } | 321 TEST_F(ClassName##ImplThreadOpaqueLayers, RunTest) { RunMyTest(); } |
(...skipping 2112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2425 EXPECT_EQ(gfx::Rect(), | 2434 EXPECT_EQ(gfx::Rect(), |
2426 occlusion.UnoccludedSurfaceContentRect( | 2435 occlusion.UnoccludedSurfaceContentRect( |
2427 surface, gfx::Rect(80, 70, 50, 50))); | 2436 surface, gfx::Rect(80, 70, 50, 50))); |
2428 } | 2437 } |
2429 }; | 2438 }; |
2430 | 2439 |
2431 ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestUnoccludedSurfaceQuery) | 2440 ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestUnoccludedSurfaceQuery) |
2432 | 2441 |
2433 } // namespace | 2442 } // namespace |
2434 } // namespace cc | 2443 } // namespace cc |
OLD | NEW |