OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_impl.h" | 5 #include "cc/trees/layer_tree_impl.h" |
6 | 6 |
7 #include "base/macros.h" | 7 #include "base/macros.h" |
8 #include "base/memory/ptr_util.h" | 8 #include "base/memory/ptr_util.h" |
9 #include "cc/layers/heads_up_display_layer_impl.h" | 9 #include "cc/layers/heads_up_display_layer_impl.h" |
10 #include "cc/test/fake_layer_tree_host_impl.h" | 10 #include "cc/test/fake_layer_tree_host_impl.h" |
(...skipping 23 matching lines...) Expand all Loading... |
34 LayerTreeImplTest() : impl_test_(LayerTreeImplTestSettings()) {} | 34 LayerTreeImplTest() : impl_test_(LayerTreeImplTestSettings()) {} |
35 | 35 |
36 FakeLayerTreeHostImpl& host_impl() const { return *impl_test_.host_impl(); } | 36 FakeLayerTreeHostImpl& host_impl() const { return *impl_test_.host_impl(); } |
37 | 37 |
38 LayerImpl* root_layer() { return impl_test_.root_layer_for_testing(); } | 38 LayerImpl* root_layer() { return impl_test_.root_layer_for_testing(); } |
39 | 39 |
40 const LayerImplList& RenderSurfaceLayerList() const { | 40 const LayerImplList& RenderSurfaceLayerList() const { |
41 return host_impl().active_tree()->RenderSurfaceLayerList(); | 41 return host_impl().active_tree()->RenderSurfaceLayerList(); |
42 } | 42 } |
43 | 43 |
44 void ExecuteCalculateDrawProperties( | 44 void ExecuteCalculateDrawProperties(LayerImpl* root_layer) { |
45 LayerImpl* root_layer, | |
46 bool skip_verify_visible_rect_calculations = false) { | |
47 // We are probably not testing what is intended if the root_layer bounds are | 45 // We are probably not testing what is intended if the root_layer bounds are |
48 // empty. | 46 // empty. |
49 DCHECK(!root_layer->bounds().IsEmpty()); | 47 DCHECK(!root_layer->bounds().IsEmpty()); |
50 | 48 |
51 render_surface_layer_list_impl_.clear(); | 49 render_surface_layer_list_impl_.clear(); |
52 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( | 50 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( |
53 root_layer, root_layer->bounds(), &render_surface_layer_list_impl_); | 51 root_layer, root_layer->bounds(), &render_surface_layer_list_impl_); |
54 inputs.can_adjust_raster_scales = true; | 52 inputs.can_adjust_raster_scales = true; |
55 if (skip_verify_visible_rect_calculations) | |
56 inputs.verify_visible_rect_calculations = false; | |
57 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); | 53 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); |
58 } | 54 } |
59 | 55 |
60 int HitTestSimpleTree(int root_id, | 56 int HitTestSimpleTree(int root_id, |
61 int left_child_id, | 57 int left_child_id, |
62 int right_child_id, | 58 int right_child_id, |
63 int root_sorting_context, | 59 int root_sorting_context, |
64 int left_child_sorting_context, | 60 int left_child_sorting_context, |
65 int right_child_sorting_context, | 61 int right_child_sorting_context, |
66 float root_depth, | 62 float root_depth, |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
245 root->test_properties()->transform = uninvertible_transform; | 241 root->test_properties()->transform = uninvertible_transform; |
246 root->SetBounds(gfx::Size(100, 100)); | 242 root->SetBounds(gfx::Size(100, 100)); |
247 root->SetDrawsContent(true); | 243 root->SetDrawsContent(true); |
248 | 244 |
249 host_impl().SetViewportSize(root->bounds()); | 245 host_impl().SetViewportSize(root->bounds()); |
250 // While computing visible rects by combining clips in screen space, we set | 246 // While computing visible rects by combining clips in screen space, we set |
251 // the entire layer as visible if the screen space transform is singular. This | 247 // the entire layer as visible if the screen space transform is singular. This |
252 // is not always true when we combine clips in target space because if the | 248 // is not always true when we combine clips in target space because if the |
253 // intersection of combined_clip in taret space with layer_rect projected to | 249 // intersection of combined_clip in taret space with layer_rect projected to |
254 // target space is empty, we set it to an empty rect. | 250 // target space is empty, we set it to an empty rect. |
255 bool skip_verify_visible_rect_calculations = true; | 251 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); |
256 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree( | |
257 skip_verify_visible_rect_calculations); | |
258 // Sanity check the scenario we just created. | 252 // Sanity check the scenario we just created. |
259 ASSERT_EQ(1u, RenderSurfaceLayerList().size()); | 253 ASSERT_EQ(1u, RenderSurfaceLayerList().size()); |
260 ASSERT_EQ(1u, root_layer()->render_surface()->layer_list().size()); | 254 ASSERT_EQ(1u, root_layer()->render_surface()->layer_list().size()); |
261 ASSERT_FALSE(root_layer()->ScreenSpaceTransform().IsInvertible()); | 255 ASSERT_FALSE(root_layer()->ScreenSpaceTransform().IsInvertible()); |
262 | 256 |
263 // Hit testing any point should not hit the layer. If the invertible matrix is | 257 // Hit testing any point should not hit the layer. If the invertible matrix is |
264 // accidentally ignored and treated like an identity, then the hit testing | 258 // accidentally ignored and treated like an identity, then the hit testing |
265 // will incorrectly hit the layer when it shouldn't. | 259 // will incorrectly hit the layer when it shouldn't. |
266 gfx::PointF test_point(1.f, 1.f); | 260 gfx::PointF test_point(1.f, 1.f); |
267 LayerImpl* result_layer = | 261 LayerImpl* result_layer = |
(...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
630 // the root + child clips combined create a triangle. The rotated_leaf will | 624 // the root + child clips combined create a triangle. The rotated_leaf will |
631 // only be visible where it overlaps this triangle. | 625 // only be visible where it overlaps this triangle. |
632 // | 626 // |
633 LayerImpl* root = root_layer(); | 627 LayerImpl* root = root_layer(); |
634 | 628 |
635 root->SetBounds(gfx::Size(100, 100)); | 629 root->SetBounds(gfx::Size(100, 100)); |
636 root->SetMasksToBounds(true); | 630 root->SetMasksToBounds(true); |
637 // Visible rects computed by combinig clips in target space and root space | 631 // Visible rects computed by combinig clips in target space and root space |
638 // don't match because of rotation transforms. So, we skip | 632 // don't match because of rotation transforms. So, we skip |
639 // verify_visible_rect_calculations. | 633 // verify_visible_rect_calculations. |
640 bool skip_verify_visible_rect_calculations = true; | |
641 { | 634 { |
642 std::unique_ptr<LayerImpl> child = | 635 std::unique_ptr<LayerImpl> child = |
643 LayerImpl::Create(host_impl().active_tree(), 456); | 636 LayerImpl::Create(host_impl().active_tree(), 456); |
644 std::unique_ptr<LayerImpl> grand_child = | 637 std::unique_ptr<LayerImpl> grand_child = |
645 LayerImpl::Create(host_impl().active_tree(), 789); | 638 LayerImpl::Create(host_impl().active_tree(), 789); |
646 std::unique_ptr<LayerImpl> rotated_leaf = | 639 std::unique_ptr<LayerImpl> rotated_leaf = |
647 LayerImpl::Create(host_impl().active_tree(), 2468); | 640 LayerImpl::Create(host_impl().active_tree(), 2468); |
648 | 641 |
649 child->SetPosition(gfx::PointF(10.f, 10.f)); | 642 child->SetPosition(gfx::PointF(10.f, 10.f)); |
650 child->SetBounds(gfx::Size(80, 80)); | 643 child->SetBounds(gfx::Size(80, 80)); |
(...skipping 19 matching lines...) Expand all Loading... |
670 rotated_leaf_transform.RotateAboutZAxis(45.0); | 663 rotated_leaf_transform.RotateAboutZAxis(45.0); |
671 rotated_leaf_transform.Translate(-50.0, -50.0); | 664 rotated_leaf_transform.Translate(-50.0, -50.0); |
672 rotated_leaf->SetBounds(gfx::Size(100, 100)); | 665 rotated_leaf->SetBounds(gfx::Size(100, 100)); |
673 rotated_leaf->test_properties()->transform = rotated_leaf_transform; | 666 rotated_leaf->test_properties()->transform = rotated_leaf_transform; |
674 rotated_leaf->SetDrawsContent(true); | 667 rotated_leaf->SetDrawsContent(true); |
675 | 668 |
676 grand_child->test_properties()->AddChild(std::move(rotated_leaf)); | 669 grand_child->test_properties()->AddChild(std::move(rotated_leaf)); |
677 child->test_properties()->AddChild(std::move(grand_child)); | 670 child->test_properties()->AddChild(std::move(grand_child)); |
678 root->test_properties()->AddChild(std::move(child)); | 671 root->test_properties()->AddChild(std::move(child)); |
679 | 672 |
680 ExecuteCalculateDrawProperties(root, skip_verify_visible_rect_calculations); | 673 ExecuteCalculateDrawProperties(root); |
681 } | 674 } |
682 | 675 |
683 host_impl().SetViewportSize(root->bounds()); | 676 host_impl().SetViewportSize(root->bounds()); |
684 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree( | 677 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); |
685 skip_verify_visible_rect_calculations); | |
686 // (11, 89) is close to the the bottom left corner within the clip, but it is | 678 // (11, 89) is close to the the bottom left corner within the clip, but it is |
687 // not inside the layer. | 679 // not inside the layer. |
688 gfx::PointF test_point(11.f, 89.f); | 680 gfx::PointF test_point(11.f, 89.f); |
689 LayerImpl* result_layer = | 681 LayerImpl* result_layer = |
690 host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); | 682 host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); |
691 EXPECT_FALSE(result_layer); | 683 EXPECT_FALSE(result_layer); |
692 | 684 |
693 // Closer inwards from the bottom left will overlap the layer. | 685 // Closer inwards from the bottom left will overlap the layer. |
694 test_point = gfx::PointF(25.f, 75.f); | 686 test_point = gfx::PointF(25.f, 75.f); |
695 result_layer = | 687 result_layer = |
(...skipping 645 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1341 root->SetBounds(gfx::Size(100, 100)); | 1333 root->SetBounds(gfx::Size(100, 100)); |
1342 root->SetDrawsContent(true); | 1334 root->SetDrawsContent(true); |
1343 root->SetTouchEventHandlerRegion(touch_handler_region); | 1335 root->SetTouchEventHandlerRegion(touch_handler_region); |
1344 | 1336 |
1345 host_impl().SetViewportSize(root->bounds()); | 1337 host_impl().SetViewportSize(root->bounds()); |
1346 // While computing visible rects by combining clips in screen space, we set | 1338 // While computing visible rects by combining clips in screen space, we set |
1347 // the entire layer as visible if the screen space transform is singular. This | 1339 // the entire layer as visible if the screen space transform is singular. This |
1348 // is not always true when we combine clips in target space because if the | 1340 // is not always true when we combine clips in target space because if the |
1349 // intersection of combined_clip in taret space with layer_rect projected to | 1341 // intersection of combined_clip in taret space with layer_rect projected to |
1350 // target space is empty, we set it to an empty rect. | 1342 // target space is empty, we set it to an empty rect. |
1351 bool skip_verify_visible_rect_calculations = true; | 1343 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); |
1352 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree( | |
1353 skip_verify_visible_rect_calculations); | |
1354 | 1344 |
1355 // Sanity check the scenario we just created. | 1345 // Sanity check the scenario we just created. |
1356 ASSERT_EQ(1u, RenderSurfaceLayerList().size()); | 1346 ASSERT_EQ(1u, RenderSurfaceLayerList().size()); |
1357 ASSERT_EQ(1u, root->render_surface()->layer_list().size()); | 1347 ASSERT_EQ(1u, root->render_surface()->layer_list().size()); |
1358 ASSERT_FALSE(root->ScreenSpaceTransform().IsInvertible()); | 1348 ASSERT_FALSE(root->ScreenSpaceTransform().IsInvertible()); |
1359 | 1349 |
1360 // Hit checking any point should not hit the touch handler region on the | 1350 // Hit checking any point should not hit the touch handler region on the |
1361 // layer. If the invertible matrix is accidentally ignored and treated like an | 1351 // layer. If the invertible matrix is accidentally ignored and treated like an |
1362 // identity, then the hit testing will incorrectly hit the layer when it | 1352 // identity, then the hit testing will incorrectly hit the layer when it |
1363 // shouldn't. | 1353 // shouldn't. |
(...skipping 1045 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2409 auto weak_promise = promise->AsWeakPtr(); | 2399 auto weak_promise = promise->AsWeakPtr(); |
2410 host_impl().active_tree()->QueueSwapPromise(std::move(promise)); | 2400 host_impl().active_tree()->QueueSwapPromise(std::move(promise)); |
2411 host_impl().active_tree()->BreakSwapPromises( | 2401 host_impl().active_tree()->BreakSwapPromises( |
2412 SwapPromise::DidNotSwapReason::SWAP_FAILS); | 2402 SwapPromise::DidNotSwapReason::SWAP_FAILS); |
2413 EXPECT_FALSE(weak_promise); | 2403 EXPECT_FALSE(weak_promise); |
2414 } | 2404 } |
2415 } | 2405 } |
2416 | 2406 |
2417 } // namespace | 2407 } // namespace |
2418 } // namespace cc | 2408 } // namespace cc |
OLD | NEW |