| 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 "cc/animation/mutable_properties.h" | 8 #include "cc/animation/mutable_properties.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 22 matching lines...) Expand all Loading... |
| 33 LayerTreeImplTest() : impl_test_(LayerTreeImplTestSettings()) {} | 33 LayerTreeImplTest() : impl_test_(LayerTreeImplTestSettings()) {} |
| 34 | 34 |
| 35 FakeLayerTreeHostImpl& host_impl() const { return *impl_test_.host_impl(); } | 35 FakeLayerTreeHostImpl& host_impl() const { return *impl_test_.host_impl(); } |
| 36 | 36 |
| 37 LayerImpl* root_layer() { return impl_test_.root_layer_for_testing(); } | 37 LayerImpl* root_layer() { return impl_test_.root_layer_for_testing(); } |
| 38 | 38 |
| 39 const LayerImplList& RenderSurfaceLayerList() const { | 39 const LayerImplList& RenderSurfaceLayerList() const { |
| 40 return host_impl().active_tree()->RenderSurfaceLayerList(); | 40 return host_impl().active_tree()->RenderSurfaceLayerList(); |
| 41 } | 41 } |
| 42 | 42 |
| 43 void ExecuteCalculateDrawProperties(LayerImpl* root_layer) { | 43 void ExecuteCalculateDrawProperties( |
| 44 LayerImpl* root_layer, |
| 45 bool skip_verify_visible_rect_calculations = false) { |
| 44 // We are probably not testing what is intended if the root_layer bounds are | 46 // We are probably not testing what is intended if the root_layer bounds are |
| 45 // empty. | 47 // empty. |
| 46 DCHECK(!root_layer->bounds().IsEmpty()); | 48 DCHECK(!root_layer->bounds().IsEmpty()); |
| 47 | 49 |
| 48 render_surface_layer_list_impl_.clear(); | 50 render_surface_layer_list_impl_.clear(); |
| 49 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( | 51 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( |
| 50 root_layer, root_layer->bounds(), &render_surface_layer_list_impl_); | 52 root_layer, root_layer->bounds(), &render_surface_layer_list_impl_); |
| 51 inputs.can_adjust_raster_scales = true; | 53 inputs.can_adjust_raster_scales = true; |
| 54 if (skip_verify_visible_rect_calculations) |
| 55 inputs.verify_visible_rect_calculations = false; |
| 52 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); | 56 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); |
| 53 } | 57 } |
| 54 | 58 |
| 55 int HitTestSimpleTree(int root_id, | 59 int HitTestSimpleTree(int root_id, |
| 56 int left_child_id, | 60 int left_child_id, |
| 57 int right_child_id, | 61 int right_child_id, |
| 58 int root_sorting_context, | 62 int root_sorting_context, |
| 59 int left_child_sorting_context, | 63 int left_child_sorting_context, |
| 60 int right_child_sorting_context, | 64 int right_child_sorting_context, |
| 61 float root_depth, | 65 float root_depth, |
| (...skipping 551 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 613 // | 617 // |
| 614 // The child and grand_child layers are both initialized to clip the | 618 // The child and grand_child layers are both initialized to clip the |
| 615 // rotated_leaf. The child layer is rotated about the top-left corner, so that | 619 // rotated_leaf. The child layer is rotated about the top-left corner, so that |
| 616 // the root + child clips combined create a triangle. The rotated_leaf will | 620 // the root + child clips combined create a triangle. The rotated_leaf will |
| 617 // only be visible where it overlaps this triangle. | 621 // only be visible where it overlaps this triangle. |
| 618 // | 622 // |
| 619 LayerImpl* root = root_layer(); | 623 LayerImpl* root = root_layer(); |
| 620 | 624 |
| 621 root->SetBounds(gfx::Size(100, 100)); | 625 root->SetBounds(gfx::Size(100, 100)); |
| 622 root->SetMasksToBounds(true); | 626 root->SetMasksToBounds(true); |
| 627 // Visible rects computed by combinig clips in target space and root space |
| 628 // don't match because of rotation transforms. So, we skip |
| 629 // verify_visible_rect_calculations. |
| 630 bool skip_verify_visible_rect_calculations = true; |
| 623 { | 631 { |
| 624 std::unique_ptr<LayerImpl> child = | 632 std::unique_ptr<LayerImpl> child = |
| 625 LayerImpl::Create(host_impl().active_tree(), 456); | 633 LayerImpl::Create(host_impl().active_tree(), 456); |
| 626 std::unique_ptr<LayerImpl> grand_child = | 634 std::unique_ptr<LayerImpl> grand_child = |
| 627 LayerImpl::Create(host_impl().active_tree(), 789); | 635 LayerImpl::Create(host_impl().active_tree(), 789); |
| 628 std::unique_ptr<LayerImpl> rotated_leaf = | 636 std::unique_ptr<LayerImpl> rotated_leaf = |
| 629 LayerImpl::Create(host_impl().active_tree(), 2468); | 637 LayerImpl::Create(host_impl().active_tree(), 2468); |
| 630 | 638 |
| 631 child->SetPosition(gfx::PointF(10.f, 10.f)); | 639 child->SetPosition(gfx::PointF(10.f, 10.f)); |
| 632 child->SetBounds(gfx::Size(80, 80)); | 640 child->SetBounds(gfx::Size(80, 80)); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 652 rotated_leaf_transform.RotateAboutZAxis(45.0); | 660 rotated_leaf_transform.RotateAboutZAxis(45.0); |
| 653 rotated_leaf_transform.Translate(-50.0, -50.0); | 661 rotated_leaf_transform.Translate(-50.0, -50.0); |
| 654 rotated_leaf->SetBounds(gfx::Size(100, 100)); | 662 rotated_leaf->SetBounds(gfx::Size(100, 100)); |
| 655 rotated_leaf->test_properties()->transform = rotated_leaf_transform; | 663 rotated_leaf->test_properties()->transform = rotated_leaf_transform; |
| 656 rotated_leaf->SetDrawsContent(true); | 664 rotated_leaf->SetDrawsContent(true); |
| 657 | 665 |
| 658 grand_child->test_properties()->AddChild(std::move(rotated_leaf)); | 666 grand_child->test_properties()->AddChild(std::move(rotated_leaf)); |
| 659 child->test_properties()->AddChild(std::move(grand_child)); | 667 child->test_properties()->AddChild(std::move(grand_child)); |
| 660 root->test_properties()->AddChild(std::move(child)); | 668 root->test_properties()->AddChild(std::move(child)); |
| 661 | 669 |
| 662 ExecuteCalculateDrawProperties(root); | 670 ExecuteCalculateDrawProperties(root, skip_verify_visible_rect_calculations); |
| 663 } | 671 } |
| 664 | 672 |
| 665 host_impl().SetViewportSize(root->bounds()); | 673 host_impl().SetViewportSize(root->bounds()); |
| 666 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); | 674 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree( |
| 675 skip_verify_visible_rect_calculations); |
| 667 // (11, 89) is close to the the bottom left corner within the clip, but it is | 676 // (11, 89) is close to the the bottom left corner within the clip, but it is |
| 668 // not inside the layer. | 677 // not inside the layer. |
| 669 gfx::PointF test_point(11.f, 89.f); | 678 gfx::PointF test_point(11.f, 89.f); |
| 670 LayerImpl* result_layer = | 679 LayerImpl* result_layer = |
| 671 host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); | 680 host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); |
| 672 EXPECT_FALSE(result_layer); | 681 EXPECT_FALSE(result_layer); |
| 673 | 682 |
| 674 // Closer inwards from the bottom left will overlap the layer. | 683 // Closer inwards from the bottom left will overlap the layer. |
| 675 test_point = gfx::PointF(25.f, 75.f); | 684 test_point = gfx::PointF(25.f, 75.f); |
| 676 result_layer = | 685 result_layer = |
| (...skipping 1694 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2371 auto weak_promise = promise->AsWeakPtr(); | 2380 auto weak_promise = promise->AsWeakPtr(); |
| 2372 host_impl().active_tree()->QueueSwapPromise(std::move(promise)); | 2381 host_impl().active_tree()->QueueSwapPromise(std::move(promise)); |
| 2373 host_impl().active_tree()->BreakSwapPromises( | 2382 host_impl().active_tree()->BreakSwapPromises( |
| 2374 SwapPromise::DidNotSwapReason::SWAP_FAILS); | 2383 SwapPromise::DidNotSwapReason::SWAP_FAILS); |
| 2375 EXPECT_FALSE(weak_promise); | 2384 EXPECT_FALSE(weak_promise); |
| 2376 } | 2385 } |
| 2377 } | 2386 } |
| 2378 | 2387 |
| 2379 } // namespace | 2388 } // namespace |
| 2380 } // namespace cc | 2389 } // namespace cc |
| OLD | NEW |