| 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/layer_tree_host.h" | 5 #include "cc/trees/layer_tree_host.h" |
| 6 | 6 |
| 7 #include "cc/layers/layer.h" | 7 #include "cc/layers/layer.h" |
| 8 #include "cc/test/layer_tree_test.h" | 8 #include "cc/test/layer_tree_test.h" |
| 9 #include "cc/test/occlusion_tracker_test_common.h" | 9 #include "cc/test/occlusion_tracker_test_common.h" |
| 10 | 10 |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 scoped_refptr<TestLayer> mask_; | 104 scoped_refptr<TestLayer> mask_; |
| 105 | 105 |
| 106 gfx::Transform identity_matrix_; | 106 gfx::Transform identity_matrix_; |
| 107 }; | 107 }; |
| 108 | 108 |
| 109 | 109 |
| 110 class LayerTreeHostOcclusionTestOcclusionSurfaceClipping : | 110 class LayerTreeHostOcclusionTestOcclusionSurfaceClipping : |
| 111 public LayerTreeHostOcclusionTest { | 111 public LayerTreeHostOcclusionTest { |
| 112 public: | 112 public: |
| 113 virtual void SetupTree() OVERRIDE { | 113 virtual void SetupTree() OVERRIDE { |
| 114 // The child layer is a surface and the grandChild is opaque, but clipped to | 114 // The child layer is a surface and the grand_child is opaque, but clipped |
| 115 // the child and root | 115 // to the child and root |
| 116 SetLayerPropertiesForTesting( | 116 SetLayerPropertiesForTesting( |
| 117 root_.get(), NULL, identity_matrix_, | 117 root_.get(), NULL, identity_matrix_, |
| 118 gfx::PointF(0.f, 0.f), gfx::Size(200, 200), true); | 118 gfx::PointF(0.f, 0.f), gfx::Size(200, 200), true); |
| 119 SetLayerPropertiesForTesting( | 119 SetLayerPropertiesForTesting( |
| 120 child_.get(), root_.get(), identity_matrix_, | 120 child_.get(), root_.get(), identity_matrix_, |
| 121 gfx::PointF(10.f, 10.f), gfx::Size(500, 500), false); | 121 gfx::PointF(10.f, 10.f), gfx::Size(500, 500), false); |
| 122 SetLayerPropertiesForTesting( | 122 SetLayerPropertiesForTesting( |
| 123 grand_child_.get(), child_.get(), identity_matrix_, | 123 grand_child_.get(), child_.get(), identity_matrix_, |
| 124 gfx::PointF(-10.f, -10.f), gfx::Size(20, 500), true); | 124 gfx::PointF(-10.f, -10.f), gfx::Size(20, 500), true); |
| 125 | 125 |
| (...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 335 } | 335 } |
| 336 }; | 336 }; |
| 337 | 337 |
| 338 SINGLE_AND_MULTI_THREAD_TEST_F( | 338 SINGLE_AND_MULTI_THREAD_TEST_F( |
| 339 LayerTreeHostOcclusionTestOcclusionOpacityBelowOcclusion) | 339 LayerTreeHostOcclusionTestOcclusionOpacityBelowOcclusion) |
| 340 | 340 |
| 341 class LayerTreeHostOcclusionTestOcclusionOpacityFilter : | 341 class LayerTreeHostOcclusionTestOcclusionOpacityFilter : |
| 342 public LayerTreeHostOcclusionTest { | 342 public LayerTreeHostOcclusionTest { |
| 343 public: | 343 public: |
| 344 virtual void SetupTree() OVERRIDE { | 344 virtual void SetupTree() OVERRIDE { |
| 345 gfx::Transform childTransform; | 345 gfx::Transform child_transform; |
| 346 childTransform.Translate(250.0, 250.0); | 346 child_transform.Translate(250.0, 250.0); |
| 347 childTransform.Rotate(90.0); | 347 child_transform.Rotate(90.0); |
| 348 childTransform.Translate(-250.0, -250.0); | 348 child_transform.Translate(-250.0, -250.0); |
| 349 | 349 |
| 350 WebKit::WebFilterOperations filters; | 350 WebKit::WebFilterOperations filters; |
| 351 filters.append(WebKit::WebFilterOperation::createOpacityFilter(0.5)); | 351 filters.append(WebKit::WebFilterOperation::createOpacityFilter(0.5)); |
| 352 | 352 |
| 353 // If the child layer has a filter that changes alpha values, and is below | 353 // If the child layer has a filter that changes alpha values, and is below |
| 354 // child2, then child2 should contribute to occlusion on everything, | 354 // child2, then child2 should contribute to occlusion on everything, |
| 355 // and child shouldn't contribute to the root | 355 // and child shouldn't contribute to the root |
| 356 SetLayerPropertiesForTesting( | 356 SetLayerPropertiesForTesting( |
| 357 root_.get(), NULL, identity_matrix_, | 357 root_.get(), NULL, identity_matrix_, |
| 358 gfx::PointF(0.f, 0.f), gfx::Size(200, 200), true); | 358 gfx::PointF(0.f, 0.f), gfx::Size(200, 200), true); |
| 359 SetLayerPropertiesForTesting( | 359 SetLayerPropertiesForTesting( |
| 360 child_.get(), root_.get(), childTransform, | 360 child_.get(), root_.get(), child_transform, |
| 361 gfx::PointF(30.f, 30.f), gfx::Size(500, 500), true); | 361 gfx::PointF(30.f, 30.f), gfx::Size(500, 500), true); |
| 362 SetLayerPropertiesForTesting( | 362 SetLayerPropertiesForTesting( |
| 363 grand_child_.get(), child_.get(), identity_matrix_, | 363 grand_child_.get(), child_.get(), identity_matrix_, |
| 364 gfx::PointF(10.f, 10.f), gfx::Size(500, 500), true); | 364 gfx::PointF(10.f, 10.f), gfx::Size(500, 500), true); |
| 365 SetLayerPropertiesForTesting( | 365 SetLayerPropertiesForTesting( |
| 366 child2_.get(), root_.get(), identity_matrix_, | 366 child2_.get(), root_.get(), identity_matrix_, |
| 367 gfx::PointF(10.f, 70.f), gfx::Size(500, 500), true); | 367 gfx::PointF(10.f, 70.f), gfx::Size(500, 500), true); |
| 368 | 368 |
| 369 child_->SetMasksToBounds(true); | 369 child_->SetMasksToBounds(true); |
| 370 child_->SetFilters(filters); | 370 child_->SetFilters(filters); |
| 371 | 371 |
| 372 grand_child_->set_expected_occlusion(gfx::Rect(40, 330, 130, 190)); | 372 grand_child_->set_expected_occlusion(gfx::Rect(40, 330, 130, 190)); |
| 373 child_->set_expected_occlusion(UnionRegions( | 373 child_->set_expected_occlusion(UnionRegions( |
| 374 gfx::Rect(10, 330, 160, 170), gfx::Rect(40, 500, 130, 20))); | 374 gfx::Rect(10, 330, 160, 170), gfx::Rect(40, 500, 130, 20))); |
| 375 root_->set_expected_occlusion(gfx::Rect(10, 70, 190, 130)); | 375 root_->set_expected_occlusion(gfx::Rect(10, 70, 190, 130)); |
| 376 | 376 |
| 377 layer_tree_host()->SetRootLayer(root_); | 377 layer_tree_host()->SetRootLayer(root_); |
| 378 LayerTreeTest::SetupTree(); | 378 LayerTreeTest::SetupTree(); |
| 379 } | 379 } |
| 380 }; | 380 }; |
| 381 | 381 |
| 382 SINGLE_AND_MULTI_THREAD_TEST_F( | 382 SINGLE_AND_MULTI_THREAD_TEST_F( |
| 383 LayerTreeHostOcclusionTestOcclusionOpacityFilter) | 383 LayerTreeHostOcclusionTestOcclusionOpacityFilter) |
| 384 | 384 |
| 385 class LayerTreeHostOcclusionTestOcclusionBlurFilter : | 385 class LayerTreeHostOcclusionTestOcclusionBlurFilter : |
| 386 public LayerTreeHostOcclusionTest { | 386 public LayerTreeHostOcclusionTest { |
| 387 public: | 387 public: |
| 388 virtual void SetupTree() OVERRIDE { | 388 virtual void SetupTree() OVERRIDE { |
| 389 gfx::Transform childTransform; | 389 gfx::Transform child_transform; |
| 390 childTransform.Translate(250.0, 250.0); | 390 child_transform.Translate(250.0, 250.0); |
| 391 childTransform.Rotate(90.0); | 391 child_transform.Rotate(90.0); |
| 392 childTransform.Translate(-250.0, -250.0); | 392 child_transform.Translate(-250.0, -250.0); |
| 393 | 393 |
| 394 WebKit::WebFilterOperations filters; | 394 WebKit::WebFilterOperations filters; |
| 395 filters.append(WebKit::WebFilterOperation::createBlurFilter(10)); | 395 filters.append(WebKit::WebFilterOperation::createBlurFilter(10)); |
| 396 | 396 |
| 397 // If the child layer has a filter that moves pixels/changes alpha, and is | 397 // If the child layer has a filter that moves pixels/changes alpha, and is |
| 398 // below child2, then child should not inherit occlusion from outside its | 398 // below child2, then child should not inherit occlusion from outside its |
| 399 // subtree, and should not contribute to the root | 399 // subtree, and should not contribute to the root |
| 400 SetLayerPropertiesForTesting( | 400 SetLayerPropertiesForTesting( |
| 401 root_.get(), NULL, identity_matrix_, | 401 root_.get(), NULL, identity_matrix_, |
| 402 gfx::PointF(0.f, 0.f), gfx::Size(200, 200), true); | 402 gfx::PointF(0.f, 0.f), gfx::Size(200, 200), true); |
| 403 SetLayerPropertiesForTesting( | 403 SetLayerPropertiesForTesting( |
| 404 child_.get(), root_.get(), childTransform, | 404 child_.get(), root_.get(), child_transform, |
| 405 gfx::PointF(30.f, 30.f), gfx::Size(500, 500), true); | 405 gfx::PointF(30.f, 30.f), gfx::Size(500, 500), true); |
| 406 SetLayerPropertiesForTesting( | 406 SetLayerPropertiesForTesting( |
| 407 grand_child_.get(), child_.get(), identity_matrix_, | 407 grand_child_.get(), child_.get(), identity_matrix_, |
| 408 gfx::PointF(10.f, 10.f), gfx::Size(500, 500), true); | 408 gfx::PointF(10.f, 10.f), gfx::Size(500, 500), true); |
| 409 SetLayerPropertiesForTesting( | 409 SetLayerPropertiesForTesting( |
| 410 child2_.get(), root_.get(), identity_matrix_, | 410 child2_.get(), root_.get(), identity_matrix_, |
| 411 gfx::PointF(10.f, 70.f), gfx::Size(500, 500), true); | 411 gfx::PointF(10.f, 70.f), gfx::Size(500, 500), true); |
| 412 | 412 |
| 413 child_->SetMasksToBounds(true); | 413 child_->SetMasksToBounds(true); |
| 414 child_->SetFilters(filters); | 414 child_->SetFilters(filters); |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 467 | 467 |
| 468 layer_tree_host()->SetRootLayer(layers[0]); | 468 layer_tree_host()->SetRootLayer(layers[0]); |
| 469 LayerTreeTest::SetupTree(); | 469 LayerTreeTest::SetupTree(); |
| 470 } | 470 } |
| 471 }; | 471 }; |
| 472 | 472 |
| 473 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostOcclusionTestManySurfaces) | 473 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostOcclusionTestManySurfaces) |
| 474 | 474 |
| 475 } // namespace | 475 } // namespace |
| 476 } // namespace cc | 476 } // namespace cc |
| OLD | NEW |