OLD | NEW |
1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 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_common.h" | 5 #include "cc/trees/layer_tree_host_common.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <set> | 10 #include <set> |
11 #include <vector> | 11 #include <vector> |
12 | 12 |
13 #include "cc/animation/animation_host.h" | 13 #include "cc/animation/animation_host.h" |
14 #include "cc/animation/animation_id_provider.h" | 14 #include "cc/animation/animation_id_provider.h" |
| 15 #include "cc/animation/animation_player.h" |
15 #include "cc/animation/keyframed_animation_curve.h" | 16 #include "cc/animation/keyframed_animation_curve.h" |
16 #include "cc/animation/layer_animation_controller.h" | 17 #include "cc/animation/layer_animation_controller.h" |
17 #include "cc/animation/transform_operations.h" | 18 #include "cc/animation/transform_operations.h" |
18 #include "cc/base/math_util.h" | 19 #include "cc/base/math_util.h" |
19 #include "cc/input/main_thread_scrolling_reason.h" | 20 #include "cc/input/main_thread_scrolling_reason.h" |
20 #include "cc/layers/content_layer_client.h" | 21 #include "cc/layers/content_layer_client.h" |
21 #include "cc/layers/layer.h" | 22 #include "cc/layers/layer.h" |
22 #include "cc/layers/layer_client.h" | 23 #include "cc/layers/layer_client.h" |
23 #include "cc/layers/layer_impl.h" | 24 #include "cc/layers/layer_impl.h" |
24 #include "cc/layers/layer_iterator.h" | 25 #include "cc/layers/layer_iterator.h" |
(...skipping 3509 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3534 gfx::PointF(10.f, 10.f), gfx::Size(100, 100), | 3535 gfx::PointF(10.f, 10.f), gfx::Size(100, 100), |
3535 false, true, false); | 3536 false, true, false); |
3536 SetLayerPropertiesForTesting(grand_child, rotation, gfx::Point3F(), | 3537 SetLayerPropertiesForTesting(grand_child, rotation, gfx::Point3F(), |
3537 gfx::PointF(), gfx::Size(100, 100), false, true, | 3538 gfx::PointF(), gfx::Size(100, 100), false, true, |
3538 false); | 3539 false); |
3539 | 3540 |
3540 ExecuteCalculateDrawProperties(root); | 3541 ExecuteCalculateDrawProperties(root); |
3541 | 3542 |
3542 // Though all layers have invertible transforms, matrix multiplication using | 3543 // Though all layers have invertible transforms, matrix multiplication using |
3543 // floating-point math makes the draw transform uninvertible. | 3544 // floating-point math makes the draw transform uninvertible. |
3544 EXPECT_FALSE(grand_child->DrawTransform().IsInvertible()); | 3545 EXPECT_FALSE(root->layer_tree_impl() |
| 3546 ->property_trees() |
| 3547 ->transform_tree.Node(grand_child->transform_tree_index()) |
| 3548 ->data.ancestors_are_invertible); |
3545 | 3549 |
3546 // CalcDrawProps only skips a subtree when a layer's own transform is | 3550 // CalcDrawProps skips a subtree when a layer's screen space transform is |
3547 // uninvertible, not when its draw transform is invertible, since CDP makes | 3551 // uninvertible |
3548 // skipping decisions before computing a layer's draw transform. Property | 3552 EXPECT_EQ(gfx::Rect(), grand_child->visible_layer_rect()); |
3549 // trees make skipping decisions after computing draw transforms, so could be | |
3550 // made to skip layers with an uninvertible draw transform (once CDP is | |
3551 // deleted). | |
3552 EXPECT_EQ(gfx::Rect(grand_child->bounds()), | |
3553 grand_child->visible_layer_rect()); | |
3554 } | 3553 } |
3555 | 3554 |
3556 TEST_F(LayerTreeHostCommonTest, | 3555 TEST_F(LayerTreeHostCommonTest, |
3557 OcclusionForLayerWithUninvertibleDrawTransform) { | 3556 OcclusionForLayerWithUninvertibleDrawTransform) { |
3558 FakeImplTaskRunnerProvider task_runner_provider; | 3557 FakeImplTaskRunnerProvider task_runner_provider; |
3559 TestSharedBitmapManager shared_bitmap_manager; | 3558 TestSharedBitmapManager shared_bitmap_manager; |
3560 TestTaskGraphRunner task_graph_runner; | 3559 TestTaskGraphRunner task_graph_runner; |
3561 scoped_ptr<OutputSurface> output_surface = FakeOutputSurface::Create3d(); | 3560 scoped_ptr<OutputSurface> output_surface = FakeOutputSurface::Create3d(); |
3562 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &shared_bitmap_manager, | 3561 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &shared_bitmap_manager, |
3563 &task_graph_runner); | 3562 &task_graph_runner); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3602 host_impl.InitializeRenderer(output_surface.get()); | 3601 host_impl.InitializeRenderer(output_surface.get()); |
3603 host_impl.active_tree()->BuildPropertyTreesForTesting(); | 3602 host_impl.active_tree()->BuildPropertyTreesForTesting(); |
3604 bool update_lcd_text = false; | 3603 bool update_lcd_text = false; |
3605 host_impl.active_tree()->UpdateDrawProperties(update_lcd_text); | 3604 host_impl.active_tree()->UpdateDrawProperties(update_lcd_text); |
3606 | 3605 |
3607 LayerImpl* grand_child_ptr = | 3606 LayerImpl* grand_child_ptr = |
3608 host_impl.active_tree()->root_layer()->children()[0]->children()[0]; | 3607 host_impl.active_tree()->root_layer()->children()[0]->children()[0]; |
3609 | 3608 |
3610 // Though all layers have invertible transforms, matrix multiplication using | 3609 // Though all layers have invertible transforms, matrix multiplication using |
3611 // floating-point math makes the draw transform uninvertible. | 3610 // floating-point math makes the draw transform uninvertible. |
3612 EXPECT_FALSE(grand_child_ptr->DrawTransform().IsInvertible()); | 3611 EXPECT_FALSE( |
| 3612 host_impl.active_tree() |
| 3613 ->property_trees() |
| 3614 ->transform_tree.Node(grand_child_ptr->transform_tree_index()) |
| 3615 ->data.ancestors_are_invertible); |
3613 | 3616 |
3614 // Since |grand_child| has an uninvertible draw transform, it is treated as | 3617 // Since |grand_child| has an uninvertible screen space transform, it is |
3615 // unoccluded (even though |occluding_child| comes later in draw order, and | 3618 // skipped so |
3616 // hence potentially occludes it). | 3619 // that we are not computing its occlusion_in_content_space. |
3617 gfx::Rect layer_bounds = gfx::Rect(grand_child_ptr->bounds()); | 3620 gfx::Rect layer_bounds = gfx::Rect(); |
3618 EXPECT_EQ( | 3621 EXPECT_EQ( |
3619 layer_bounds, | 3622 layer_bounds, |
3620 grand_child_ptr->draw_properties() | 3623 grand_child_ptr->draw_properties() |
3621 .occlusion_in_content_space.GetUnoccludedContentRect(layer_bounds)); | 3624 .occlusion_in_content_space.GetUnoccludedContentRect(layer_bounds)); |
3622 } | 3625 } |
3623 | 3626 |
3624 TEST_F(LayerTreeHostCommonTest, | 3627 TEST_F(LayerTreeHostCommonTest, |
3625 DrawableAndVisibleContentRectsForLayersInClippedRenderSurface) { | 3628 DrawableAndVisibleContentRectsForLayersInClippedRenderSurface) { |
3626 LayerImpl* root = root_layer(); | 3629 LayerImpl* root = root_layer(); |
3627 LayerImpl* render_surface = AddChildToRoot<LayerImpl>(); | 3630 LayerImpl* render_surface = AddChildToRoot<LayerImpl>(); |
(...skipping 2147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5775 | 5778 |
5776 std::vector<scoped_ptr<CopyOutputRequest>> copy_requests; | 5779 std::vector<scoped_ptr<CopyOutputRequest>> copy_requests; |
5777 copy_requests.push_back( | 5780 copy_requests.push_back( |
5778 CopyOutputRequest::CreateRequest(base::Bind(&EmptyCopyOutputCallback))); | 5781 CopyOutputRequest::CreateRequest(base::Bind(&EmptyCopyOutputCallback))); |
5779 copy_layer->PassCopyRequests(©_requests); | 5782 copy_layer->PassCopyRequests(©_requests); |
5780 EXPECT_TRUE(copy_layer->HasCopyRequest()); | 5783 EXPECT_TRUE(copy_layer->HasCopyRequest()); |
5781 | 5784 |
5782 copy_layer->AddChild(std::move(copy_child)); | 5785 copy_layer->AddChild(std::move(copy_child)); |
5783 copy_parent->AddChild(std::move(copy_layer)); | 5786 copy_parent->AddChild(std::move(copy_layer)); |
5784 root->AddChild(std::move(copy_parent)); | 5787 root->AddChild(std::move(copy_parent)); |
5785 host_impl.pending_tree()->SetRootLayer(std::move(root)); | |
5786 LayerImpl* root_ptr = host_impl.pending_tree()->root_layer(); | |
5787 | 5788 |
5788 LayerImplList render_surface_layer_list; | 5789 LayerImplList render_surface_layer_list; |
5789 root_ptr->layer_tree_impl()->IncrementRenderSurfaceListIdForTesting(); | 5790 root->layer_tree_impl()->IncrementRenderSurfaceListIdForTesting(); |
| 5791 LayerImpl* root_layer = root.get(); |
| 5792 root_layer->layer_tree_impl()->SetRootLayer(std::move(root)); |
5790 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( | 5793 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( |
5791 root_ptr, root_ptr->bounds(), &render_surface_layer_list, | 5794 root_layer, root_layer->bounds(), &render_surface_layer_list, |
5792 root_ptr->layer_tree_impl()->current_render_surface_list_id()); | 5795 root_layer->layer_tree_impl()->current_render_surface_list_id()); |
5793 inputs.can_adjust_raster_scales = true; | 5796 inputs.can_adjust_raster_scales = true; |
5794 LayerTreeHostCommon::CalculateDrawProperties(&inputs); | 5797 LayerTreeHostCommon::CalculateDrawProperties(&inputs); |
5795 | 5798 |
5796 // We should have two render surface, as the others are clipped out. | 5799 // We should have two render surface, as the others are clipped out. |
5797 ASSERT_EQ(2u, render_surface_layer_list.size()); | 5800 ASSERT_EQ(2u, render_surface_layer_list.size()); |
5798 EXPECT_EQ(root_ptr->id(), render_surface_layer_list.at(0)->id()); | 5801 EXPECT_EQ(root_layer->id(), render_surface_layer_list.at(0)->id()); |
5799 | 5802 |
5800 // The root render surface should only have 2 contributing layer, since the | 5803 // The root render surface should only have 2 contributing layer, since the |
5801 // other layers are empty/clipped away. | 5804 // other layers are empty/clipped away. |
5802 ASSERT_EQ(2u, root_ptr->render_surface()->layer_list().size()); | 5805 ASSERT_EQ(2u, root_layer->render_surface()->layer_list().size()); |
5803 EXPECT_EQ(root_ptr->id(), | 5806 EXPECT_EQ(root_layer->id(), |
5804 root_ptr->render_surface()->layer_list().at(0)->id()); | 5807 root_layer->render_surface()->layer_list().at(0)->id()); |
5805 } | 5808 } |
5806 | 5809 |
5807 TEST_F(LayerTreeHostCommonTest, VisibleContentRectInsideSurface) { | 5810 TEST_F(LayerTreeHostCommonTest, VisibleContentRectInsideSurface) { |
5808 FakeImplTaskRunnerProvider task_runner_provider; | 5811 FakeImplTaskRunnerProvider task_runner_provider; |
5809 TestSharedBitmapManager shared_bitmap_manager; | 5812 TestSharedBitmapManager shared_bitmap_manager; |
5810 TestTaskGraphRunner task_graph_runner; | 5813 TestTaskGraphRunner task_graph_runner; |
5811 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &shared_bitmap_manager, | 5814 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &shared_bitmap_manager, |
5812 &task_graph_runner); | 5815 &task_graph_runner); |
5813 host_impl.CreatePendingTree(); | 5816 host_impl.CreatePendingTree(); |
5814 const gfx::Transform identity_matrix; | 5817 const gfx::Transform identity_matrix; |
(...skipping 526 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6341 SetLayerPropertiesForTesting(child3.get(), identity_matrix, transform_origin, | 6344 SetLayerPropertiesForTesting(child3.get(), identity_matrix, transform_origin, |
6342 position, bounds, true, false, false); | 6345 position, bounds, true, false, false); |
6343 child3->SetDrawsContent(true); | 6346 child3->SetDrawsContent(true); |
6344 | 6347 |
6345 child2->Set3dSortingContextId(1); | 6348 child2->Set3dSortingContextId(1); |
6346 child3->Set3dSortingContextId(1); | 6349 child3->Set3dSortingContextId(1); |
6347 | 6350 |
6348 child2->AddChild(std::move(child3)); | 6351 child2->AddChild(std::move(child3)); |
6349 child1->AddChild(std::move(child2)); | 6352 child1->AddChild(std::move(child2)); |
6350 root->AddChild(std::move(child1)); | 6353 root->AddChild(std::move(child1)); |
6351 host_impl.active_tree()->SetRootLayer(std::move(root)); | 6354 LayerImpl* root_layer = root.get(); |
6352 LayerImpl* root_ptr = host_impl.active_tree()->root_layer(); | 6355 root_layer->layer_tree_impl()->SetRootLayer(std::move(root)); |
6353 | 6356 |
6354 { | 6357 { |
6355 LayerImplList render_surface_layer_list; | 6358 LayerImplList render_surface_layer_list; |
6356 FakeLayerTreeHostImpl::RecursiveUpdateNumChildren(root_ptr); | 6359 FakeLayerTreeHostImpl::RecursiveUpdateNumChildren(root_layer); |
6357 root_ptr->layer_tree_impl()->IncrementRenderSurfaceListIdForTesting(); | 6360 root_layer->layer_tree_impl()->IncrementRenderSurfaceListIdForTesting(); |
6358 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( | 6361 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( |
6359 root_ptr, root_ptr->bounds(), &render_surface_layer_list, | 6362 root_layer, root_layer->bounds(), &render_surface_layer_list, |
6360 root_ptr->layer_tree_impl()->current_render_surface_list_id()); | 6363 root_layer->layer_tree_impl()->current_render_surface_list_id()); |
6361 inputs.can_render_to_separate_surface = true; | 6364 inputs.can_render_to_separate_surface = true; |
6362 LayerTreeHostCommon::CalculateDrawProperties(&inputs); | 6365 LayerTreeHostCommon::CalculateDrawProperties(&inputs); |
6363 | 6366 |
6364 EXPECT_EQ(2u, render_surface_layer_list.size()); | 6367 EXPECT_EQ(2u, render_surface_layer_list.size()); |
6365 | 6368 |
6366 int count_represents_target_render_surface = 0; | 6369 int count_represents_target_render_surface = 0; |
6367 int count_represents_contributing_render_surface = 0; | 6370 int count_represents_contributing_render_surface = 0; |
6368 int count_represents_itself = 0; | 6371 int count_represents_itself = 0; |
6369 LayerIterator end = LayerIterator::End(&render_surface_layer_list); | 6372 LayerIterator end = LayerIterator::End(&render_surface_layer_list); |
6370 for (LayerIterator it = LayerIterator::Begin(&render_surface_layer_list); | 6373 for (LayerIterator it = LayerIterator::Begin(&render_surface_layer_list); |
6371 it != end; ++it) { | 6374 it != end; ++it) { |
6372 if (it.represents_target_render_surface()) | 6375 if (it.represents_target_render_surface()) |
6373 count_represents_target_render_surface++; | 6376 count_represents_target_render_surface++; |
6374 if (it.represents_contributing_render_surface()) | 6377 if (it.represents_contributing_render_surface()) |
6375 count_represents_contributing_render_surface++; | 6378 count_represents_contributing_render_surface++; |
6376 if (it.represents_itself()) | 6379 if (it.represents_itself()) |
6377 count_represents_itself++; | 6380 count_represents_itself++; |
6378 } | 6381 } |
6379 | 6382 |
6380 // Two render surfaces. | 6383 // Two render surfaces. |
6381 EXPECT_EQ(2, count_represents_target_render_surface); | 6384 EXPECT_EQ(2, count_represents_target_render_surface); |
6382 // Second render surface contributes to root render surface. | 6385 // Second render surface contributes to root render surface. |
6383 EXPECT_EQ(1, count_represents_contributing_render_surface); | 6386 EXPECT_EQ(1, count_represents_contributing_render_surface); |
6384 // All 4 layers represent itself. | 6387 // All 4 layers represent itself. |
6385 EXPECT_EQ(4, count_represents_itself); | 6388 EXPECT_EQ(4, count_represents_itself); |
6386 } | 6389 } |
6387 | 6390 |
6388 { | 6391 { |
6389 LayerImplList render_surface_layer_list; | 6392 LayerImplList render_surface_layer_list; |
6390 root_ptr->layer_tree_impl()->IncrementRenderSurfaceListIdForTesting(); | 6393 root_layer->layer_tree_impl()->IncrementRenderSurfaceListIdForTesting(); |
6391 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( | 6394 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( |
6392 root_ptr, root_ptr->bounds(), &render_surface_layer_list, | 6395 root_layer, root_layer->bounds(), &render_surface_layer_list, |
6393 root_ptr->layer_tree_impl()->current_render_surface_list_id()); | 6396 root_layer->layer_tree_impl()->current_render_surface_list_id()); |
6394 inputs.can_render_to_separate_surface = false; | 6397 inputs.can_render_to_separate_surface = false; |
6395 LayerTreeHostCommon::CalculateDrawProperties(&inputs); | 6398 LayerTreeHostCommon::CalculateDrawProperties(&inputs); |
6396 | 6399 |
6397 EXPECT_EQ(1u, render_surface_layer_list.size()); | 6400 EXPECT_EQ(1u, render_surface_layer_list.size()); |
6398 | 6401 |
6399 int count_represents_target_render_surface = 0; | 6402 int count_represents_target_render_surface = 0; |
6400 int count_represents_contributing_render_surface = 0; | 6403 int count_represents_contributing_render_surface = 0; |
6401 int count_represents_itself = 0; | 6404 int count_represents_itself = 0; |
6402 LayerIterator end = LayerIterator::End(&render_surface_layer_list); | 6405 LayerIterator end = LayerIterator::End(&render_surface_layer_list); |
6403 for (LayerIterator it = LayerIterator::Begin(&render_surface_layer_list); | 6406 for (LayerIterator it = LayerIterator::Begin(&render_surface_layer_list); |
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6713 ExecuteCalculateDrawProperties(root); | 6716 ExecuteCalculateDrawProperties(root); |
6714 | 6717 |
6715 EXPECT_EQ(3u, render_surface_layer_list_impl()->size()); | 6718 EXPECT_EQ(3u, render_surface_layer_list_impl()->size()); |
6716 | 6719 |
6717 gfx::Transform singular_transform; | 6720 gfx::Transform singular_transform; |
6718 singular_transform.Scale3d( | 6721 singular_transform.Scale3d( |
6719 SkDoubleToMScalar(1.0), SkDoubleToMScalar(1.0), SkDoubleToMScalar(0.0)); | 6722 SkDoubleToMScalar(1.0), SkDoubleToMScalar(1.0), SkDoubleToMScalar(0.0)); |
6720 | 6723 |
6721 child->SetTransform(singular_transform); | 6724 child->SetTransform(singular_transform); |
6722 | 6725 |
| 6726 root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
6723 ExecuteCalculateDrawProperties(root); | 6727 ExecuteCalculateDrawProperties(root); |
6724 | 6728 |
6725 EXPECT_EQ(2u, render_surface_layer_list_impl()->size()); | 6729 EXPECT_EQ(2u, render_surface_layer_list_impl()->size()); |
6726 | 6730 |
6727 // Ensure that the entire subtree under a layer with singular transform does | 6731 // Ensure that the entire subtree under a layer with singular transform does |
6728 // not get rendered. | 6732 // not get rendered. |
6729 parent->SetTransform(singular_transform); | 6733 parent->SetTransform(singular_transform); |
6730 child->SetTransform(identity_transform); | 6734 child->SetTransform(identity_transform); |
6731 | 6735 |
| 6736 root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
6732 ExecuteCalculateDrawProperties(root); | 6737 ExecuteCalculateDrawProperties(root); |
6733 | 6738 |
6734 EXPECT_EQ(1u, render_surface_layer_list_impl()->size()); | 6739 EXPECT_EQ(1u, render_surface_layer_list_impl()->size()); |
6735 } | 6740 } |
6736 | 6741 |
6737 TEST_F(LayerTreeHostCommonTest, ClippedByOutOfOrderScrollParent) { | 6742 TEST_F(LayerTreeHostCommonTest, ClippedByOutOfOrderScrollParent) { |
6738 // Checks that clipping by a scroll parent that follows you in paint order | 6743 // Checks that clipping by a scroll parent that follows you in paint order |
6739 // still results in correct clipping. | 6744 // still results in correct clipping. |
6740 // | 6745 // |
6741 // + root | 6746 // + root |
(...skipping 535 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7277 AnimationScaleFactorTrackingLayerImpl::Create(host_impl.active_tree(), 4); | 7282 AnimationScaleFactorTrackingLayerImpl::Create(host_impl.active_tree(), 4); |
7278 | 7283 |
7279 AnimationScaleFactorTrackingLayerImpl* parent_raw = parent.get(); | 7284 AnimationScaleFactorTrackingLayerImpl* parent_raw = parent.get(); |
7280 AnimationScaleFactorTrackingLayerImpl* child_raw = child.get(); | 7285 AnimationScaleFactorTrackingLayerImpl* child_raw = child.get(); |
7281 AnimationScaleFactorTrackingLayerImpl* grand_child_raw = grand_child.get(); | 7286 AnimationScaleFactorTrackingLayerImpl* grand_child_raw = grand_child.get(); |
7282 AnimationScaleFactorTrackingLayerImpl* grand_parent_raw = grand_parent.get(); | 7287 AnimationScaleFactorTrackingLayerImpl* grand_parent_raw = grand_parent.get(); |
7283 | 7288 |
7284 child->AddChild(std::move(grand_child)); | 7289 child->AddChild(std::move(grand_child)); |
7285 parent->AddChild(std::move(child)); | 7290 parent->AddChild(std::move(child)); |
7286 grand_parent->AddChild(std::move(parent)); | 7291 grand_parent->AddChild(std::move(parent)); |
7287 host_impl.active_tree()->SetRootLayer(std::move(grand_parent)); | |
7288 | 7292 |
7289 SetLayerPropertiesForTesting(grand_parent_raw, identity_matrix, | 7293 SetLayerPropertiesForTesting(grand_parent_raw, identity_matrix, |
7290 gfx::Point3F(), gfx::PointF(), gfx::Size(1, 2), | 7294 gfx::Point3F(), gfx::PointF(), gfx::Size(1, 2), |
7291 true, false, true); | 7295 true, false, true); |
7292 SetLayerPropertiesForTesting(parent_raw, identity_matrix, gfx::Point3F(), | 7296 SetLayerPropertiesForTesting(parent_raw, identity_matrix, gfx::Point3F(), |
7293 gfx::PointF(), gfx::Size(1, 2), true, false, | 7297 gfx::PointF(), gfx::Size(1, 2), true, false, |
7294 false); | 7298 false); |
7295 SetLayerPropertiesForTesting(child_raw, identity_matrix, gfx::Point3F(), | 7299 SetLayerPropertiesForTesting(child_raw, identity_matrix, gfx::Point3F(), |
7296 gfx::PointF(), gfx::Size(1, 2), true, false, | 7300 gfx::PointF(), gfx::Size(1, 2), true, false, |
7297 false); | 7301 false); |
7298 | 7302 |
7299 SetLayerPropertiesForTesting(grand_child_raw, identity_matrix, gfx::Point3F(), | 7303 SetLayerPropertiesForTesting(grand_child_raw, identity_matrix, gfx::Point3F(), |
7300 gfx::PointF(), gfx::Size(1, 2), true, false, | 7304 gfx::PointF(), gfx::Size(1, 2), true, false, |
7301 false); | 7305 false); |
7302 | 7306 |
| 7307 host_impl.active_tree()->SetRootLayer(std::move(grand_parent)); |
| 7308 |
7303 ExecuteCalculateDrawProperties(grand_parent_raw); | 7309 ExecuteCalculateDrawProperties(grand_parent_raw); |
7304 | 7310 |
7305 // No layers have animations. | 7311 // No layers have animations. |
7306 EXPECT_EQ( | 7312 EXPECT_EQ( |
7307 0.f, | 7313 0.f, |
7308 grand_parent_raw->draw_properties().maximum_animation_contents_scale); | 7314 grand_parent_raw->draw_properties().maximum_animation_contents_scale); |
7309 EXPECT_EQ(0.f, | 7315 EXPECT_EQ(0.f, |
7310 parent_raw->draw_properties().maximum_animation_contents_scale); | 7316 parent_raw->draw_properties().maximum_animation_contents_scale); |
7311 EXPECT_EQ(0.f, child_raw->draw_properties().maximum_animation_contents_scale); | 7317 EXPECT_EQ(0.f, child_raw->draw_properties().maximum_animation_contents_scale); |
7312 EXPECT_EQ( | 7318 EXPECT_EQ( |
(...skipping 1505 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8818 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)), | 8824 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)), |
8819 animation_id, 1, TargetProperty::OPACITY); | 8825 animation_id, 1, TargetProperty::OPACITY); |
8820 animation->set_fill_mode(Animation::FILL_MODE_NONE); | 8826 animation->set_fill_mode(Animation::FILL_MODE_NONE); |
8821 animation->set_time_offset(base::TimeDelta::FromMilliseconds(-1000)); | 8827 animation->set_time_offset(base::TimeDelta::FromMilliseconds(-1000)); |
8822 AddAnimationToLayerWithExistingPlayer(child->id(), timeline(), | 8828 AddAnimationToLayerWithExistingPlayer(child->id(), timeline(), |
8823 std::move(animation)); | 8829 std::move(animation)); |
8824 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); | 8830 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); |
8825 EXPECT_EQ(gfx::Rect(10, 10), grandchild->visible_layer_rect_for_testing()); | 8831 EXPECT_EQ(gfx::Rect(10, 10), grandchild->visible_layer_rect_for_testing()); |
8826 } | 8832 } |
8827 | 8833 |
8828 TEST_F(LayerTreeHostCommonTest, SkippingSubtreeImpl) { | 8834 TEST_F(LayerTreeHostCommonTest, SkippingLayerImpl) { |
8829 FakeImplTaskRunnerProvider task_runner_provider; | 8835 FakeImplTaskRunnerProvider task_runner_provider; |
8830 TestSharedBitmapManager shared_bitmap_manager; | 8836 TestSharedBitmapManager shared_bitmap_manager; |
8831 TestTaskGraphRunner task_graph_runner; | 8837 TestTaskGraphRunner task_graph_runner; |
8832 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &shared_bitmap_manager, | 8838 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &shared_bitmap_manager, |
8833 &task_graph_runner); | 8839 &task_graph_runner); |
8834 | 8840 |
8835 gfx::Transform identity; | 8841 gfx::Transform identity; |
8836 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl.active_tree(), 1); | 8842 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl.active_tree(), 1); |
8837 scoped_ptr<LayerImpl> child = LayerImpl::Create(host_impl.active_tree(), 2); | 8843 scoped_ptr<LayerImpl> child = LayerImpl::Create(host_impl.active_tree(), 2); |
8838 scoped_ptr<LayerImpl> grandchild = | 8844 scoped_ptr<LayerImpl> grandchild = |
(...skipping 18 matching lines...) Expand all Loading... |
8857 | 8863 |
8858 LayerImpl* root_ptr = root.get(); | 8864 LayerImpl* root_ptr = root.get(); |
8859 LayerImpl* child_ptr = child.get(); | 8865 LayerImpl* child_ptr = child.get(); |
8860 LayerImpl* grandchild_ptr = grandchild.get(); | 8866 LayerImpl* grandchild_ptr = grandchild.get(); |
8861 | 8867 |
8862 child->AddChild(std::move(grandchild)); | 8868 child->AddChild(std::move(grandchild)); |
8863 root->AddChild(std::move(child)); | 8869 root->AddChild(std::move(child)); |
8864 host_impl.active_tree()->SetRootLayer(std::move(root)); | 8870 host_impl.active_tree()->SetRootLayer(std::move(root)); |
8865 | 8871 |
8866 // Check the non-skipped case. | 8872 // Check the non-skipped case. |
8867 ExecuteCalculateDrawPropertiesWithPropertyTrees(root_ptr); | 8873 // ExecuteCalculateDrawPropertiesWithPropertyTrees(root_ptr); |
8868 EXPECT_EQ(gfx::Rect(10, 10), grandchild_ptr->visible_layer_rect()); | 8874 // EXPECT_EQ(gfx::Rect(10, 10), grandchild_ptr->visible_layer_rect()); |
8869 | 8875 |
8870 // Now we will reset the visible rect from property trees for the grandchild, | 8876 // Now we will reset the visible rect from property trees for the grandchild, |
8871 // and we will configure |child| in several ways that should force the subtree | 8877 // and we will configure |child| in several ways that should force the subtree |
8872 // to be skipped. The visible content rect for |grandchild| should, therefore, | 8878 // to be skipped. The visible content rect for |grandchild| should, therefore, |
8873 // remain empty. | 8879 // remain empty. |
8874 grandchild_ptr->set_visible_layer_rect(gfx::Rect()); | 8880 grandchild_ptr->set_visible_layer_rect(gfx::Rect()); |
| 8881 |
8875 gfx::Transform singular; | 8882 gfx::Transform singular; |
8876 singular.matrix().set(0, 0, 0); | 8883 singular.matrix().set(0, 0, 0); |
| 8884 // This line is used to make the results of skipping and not skipping layers |
| 8885 // different. |
| 8886 singular.matrix().set(0, 1, 1); |
| 8887 |
| 8888 gfx::Transform rotate; |
| 8889 rotate.Rotate(90); |
| 8890 |
| 8891 gfx::Transform rotate_back_and_translate; |
| 8892 rotate_back_and_translate.RotateAboutYAxis(180); |
| 8893 rotate_back_and_translate.Translate(-10, 0); |
8877 | 8894 |
8878 child_ptr->SetTransform(singular); | 8895 child_ptr->SetTransform(singular); |
| 8896 host_impl.active_tree()->property_trees()->needs_rebuild = true; |
8879 ExecuteCalculateDrawPropertiesWithPropertyTrees(root_ptr); | 8897 ExecuteCalculateDrawPropertiesWithPropertyTrees(root_ptr); |
8880 EXPECT_EQ(gfx::Rect(0, 0), grandchild_ptr->visible_layer_rect()); | 8898 EXPECT_EQ(gfx::Rect(0, 0), grandchild_ptr->visible_layer_rect()); |
8881 child_ptr->SetTransform(identity); | 8899 child_ptr->SetTransform(identity); |
8882 | 8900 |
8883 child_ptr->SetHideLayerAndSubtree(true); | 8901 child_ptr->SetHideLayerAndSubtree(true); |
8884 ExecuteCalculateDrawPropertiesWithPropertyTrees(root_ptr); | 8902 ExecuteCalculateDrawPropertiesWithPropertyTrees(root_ptr); |
8885 EXPECT_EQ(gfx::Rect(0, 0), grandchild_ptr->visible_layer_rect()); | 8903 EXPECT_EQ(gfx::Rect(0, 0), grandchild_ptr->visible_layer_rect()); |
8886 child_ptr->SetHideLayerAndSubtree(false); | 8904 child_ptr->SetHideLayerAndSubtree(false); |
8887 | 8905 |
8888 child_ptr->SetOpacity(0.f); | 8906 child_ptr->SetOpacity(0.f); |
8889 ExecuteCalculateDrawPropertiesWithPropertyTrees(root_ptr); | 8907 ExecuteCalculateDrawPropertiesWithPropertyTrees(root_ptr); |
8890 EXPECT_EQ(gfx::Rect(0, 0), grandchild_ptr->visible_layer_rect()); | 8908 EXPECT_EQ(gfx::Rect(0, 0), grandchild_ptr->visible_layer_rect()); |
| 8909 child_ptr->SetOpacity(1.f); |
8891 | 8910 |
| 8911 root_ptr->SetTransform(singular); |
| 8912 // Force transform tree to have a node for child, so that ancestor's |
| 8913 // invertible transform can be tested. |
| 8914 child_ptr->SetTransform(rotate); |
| 8915 host_impl.active_tree()->property_trees()->needs_rebuild = true; |
| 8916 ExecuteCalculateDrawPropertiesWithPropertyTrees(root_ptr); |
| 8917 EXPECT_EQ(gfx::Rect(0, 0), grandchild_ptr->visible_layer_rect()); |
| 8918 root_ptr->SetTransform(identity); |
| 8919 child_ptr->SetTransform(identity); |
| 8920 |
| 8921 root_ptr->SetOpacity(0.f); |
| 8922 child_ptr->SetOpacity(0.7f); |
| 8923 host_impl.active_tree()->property_trees()->needs_rebuild = true; |
| 8924 ExecuteCalculateDrawPropertiesWithPropertyTrees(root_ptr); |
| 8925 EXPECT_EQ(gfx::Rect(0, 0), grandchild_ptr->visible_layer_rect()); |
| 8926 root_ptr->SetOpacity(1.f); |
| 8927 |
| 8928 child_ptr->SetOpacity(0.f); |
8892 // Now, even though child has zero opacity, we will configure |grandchild| and | 8929 // Now, even though child has zero opacity, we will configure |grandchild| and |
8893 // |greatgrandchild| in several ways that should force the subtree to be | 8930 // |greatgrandchild| in several ways that should force the subtree to be |
8894 // processed anyhow. | 8931 // processed anyhow. |
8895 std::vector<scoped_ptr<CopyOutputRequest>> requests; | 8932 std::vector<scoped_ptr<CopyOutputRequest>> requests; |
8896 requests.push_back(CopyOutputRequest::CreateEmptyRequest()); | 8933 requests.push_back(CopyOutputRequest::CreateEmptyRequest()); |
8897 | 8934 |
8898 grandchild_ptr->PassCopyRequests(&requests); | 8935 grandchild_ptr->PassCopyRequests(&requests); |
8899 root_ptr->layer_tree_impl()->property_trees()->needs_rebuild = true; | 8936 root_ptr->layer_tree_impl()->property_trees()->needs_rebuild = true; |
8900 ExecuteCalculateDrawPropertiesWithPropertyTrees(root_ptr); | 8937 ExecuteCalculateDrawPropertiesWithPropertyTrees(root_ptr); |
8901 EXPECT_EQ(gfx::Rect(10, 10), grandchild_ptr->visible_layer_rect()); | 8938 EXPECT_EQ(gfx::Rect(10, 10), grandchild_ptr->visible_layer_rect()); |
| 8939 requests.clear(); |
| 8940 grandchild_ptr->PassCopyRequests(&requests); |
| 8941 child_ptr->SetOpacity(1.f); |
| 8942 |
| 8943 // A double sided render surface with backface visible should not be skipped |
| 8944 grandchild_ptr->set_visible_layer_rect(gfx::Rect()); |
| 8945 child_ptr->SetHasRenderSurface(true); |
| 8946 child_ptr->SetDoubleSided(true); |
| 8947 child_ptr->SetTransform(rotate_back_and_translate); |
| 8948 root_ptr->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| 8949 ExecuteCalculateDrawPropertiesWithPropertyTrees(root_ptr); |
| 8950 EXPECT_EQ(gfx::Rect(10, 10), grandchild_ptr->visible_layer_rect()); |
| 8951 child_ptr->SetTransform(identity); |
| 8952 |
| 8953 scoped_ptr<KeyframedTransformAnimationCurve> curve( |
| 8954 KeyframedTransformAnimationCurve::Create()); |
| 8955 TransformOperations start; |
| 8956 start.AppendTranslate(1.f, 2.f, 3.f); |
| 8957 gfx::Transform transform; |
| 8958 transform.Scale3d(1.0, 2.0, 3.0); |
| 8959 TransformOperations operation; |
| 8960 operation.AppendMatrix(transform); |
| 8961 curve->AddKeyframe( |
| 8962 TransformKeyframe::Create(base::TimeDelta(), start, nullptr)); |
| 8963 curve->AddKeyframe(TransformKeyframe::Create( |
| 8964 base::TimeDelta::FromSecondsD(1.0), operation, nullptr)); |
| 8965 scoped_ptr<Animation> transform_animation( |
| 8966 Animation::Create(std::move(curve), 3, 3, TargetProperty::TRANSFORM)); |
| 8967 scoped_refptr<AnimationPlayer> player(AnimationPlayer::Create(1)); |
| 8968 host_impl.active_tree()->animation_host()->RegisterPlayerForLayer( |
| 8969 root_ptr->id(), player.get()); |
| 8970 host_impl.active_tree() |
| 8971 ->animation_host() |
| 8972 ->GetControllerForLayerId(root_ptr->id()) |
| 8973 ->AddAnimation(std::move(transform_animation)); |
| 8974 grandchild_ptr->set_visible_layer_rect(gfx::Rect()); |
| 8975 child_ptr->SetScrollClipLayer(root_ptr->id()); |
| 8976 root_ptr->SetTransform(singular); |
| 8977 child_ptr->SetTransform(singular); |
| 8978 root_ptr->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| 8979 ExecuteCalculateDrawPropertiesWithPropertyTrees(root_ptr); |
| 8980 EXPECT_EQ(gfx::Rect(10, 10), grandchild_ptr->visible_layer_rect()); |
| 8981 |
| 8982 host_impl.active_tree()->animation_host()->UnregisterPlayerForLayer( |
| 8983 root_ptr->id(), player.get()); |
| 8984 } |
| 8985 |
| 8986 TEST_F(LayerTreeHostCommonTest, SkippingPendingLayerImpl) { |
| 8987 FakeImplTaskRunnerProvider task_runner_provider; |
| 8988 TestSharedBitmapManager shared_bitmap_manager; |
| 8989 TestTaskGraphRunner task_graph_runner; |
| 8990 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &shared_bitmap_manager, |
| 8991 &task_graph_runner); |
| 8992 |
| 8993 gfx::Transform identity; |
| 8994 host_impl.CreatePendingTree(); |
| 8995 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl.pending_tree(), 1); |
| 8996 scoped_ptr<LayerImpl> child = LayerImpl::Create(host_impl.pending_tree(), 2); |
| 8997 scoped_ptr<LayerImpl> grandchild = |
| 8998 LayerImpl::Create(host_impl.pending_tree(), 3); |
| 8999 |
| 9000 scoped_ptr<FakePictureLayerImpl> greatgrandchild( |
| 9001 FakePictureLayerImpl::Create(host_impl.pending_tree(), 4)); |
| 9002 |
| 9003 child->SetDrawsContent(true); |
| 9004 grandchild->SetDrawsContent(true); |
| 9005 greatgrandchild->SetDrawsContent(true); |
| 9006 |
| 9007 SetLayerPropertiesForTesting(root.get(), identity, gfx::Point3F(), |
| 9008 gfx::PointF(), gfx::Size(100, 100), true, false, |
| 9009 true); |
| 9010 SetLayerPropertiesForTesting(child.get(), identity, gfx::Point3F(), |
| 9011 gfx::PointF(), gfx::Size(10, 10), true, false, |
| 9012 false); |
| 9013 SetLayerPropertiesForTesting(grandchild.get(), identity, gfx::Point3F(), |
| 9014 gfx::PointF(), gfx::Size(10, 10), true, false, |
| 9015 false); |
| 9016 |
| 9017 LayerImpl* root_ptr = root.get(); |
| 9018 LayerImpl* grandchild_ptr = grandchild.get(); |
| 9019 |
| 9020 child->AddChild(std::move(grandchild)); |
| 9021 root->AddChild(std::move(child)); |
| 9022 |
| 9023 host_impl.pending_tree()->SetRootLayer(std::move(root)); |
| 9024 |
| 9025 // Check the non-skipped case. |
| 9026 ExecuteCalculateDrawPropertiesWithPropertyTrees(root_ptr); |
| 9027 EXPECT_EQ(gfx::Rect(10, 10), grandchild_ptr->visible_layer_rect()); |
| 9028 |
| 9029 scoped_ptr<KeyframedFloatAnimationCurve> curve( |
| 9030 KeyframedFloatAnimationCurve::Create()); |
| 9031 scoped_ptr<TimingFunction> func = EaseTimingFunction::Create(); |
| 9032 curve->AddKeyframe( |
| 9033 FloatKeyframe::Create(base::TimeDelta(), 0.9f, std::move(func))); |
| 9034 curve->AddKeyframe( |
| 9035 FloatKeyframe::Create(base::TimeDelta::FromSecondsD(1.0), 0.3f, nullptr)); |
| 9036 scoped_ptr<Animation> animation( |
| 9037 Animation::Create(std::move(curve), 3, 3, TargetProperty::OPACITY)); |
| 9038 scoped_refptr<AnimationPlayer> player(AnimationPlayer::Create(1)); |
| 9039 host_impl.active_tree()->animation_host()->RegisterPlayerForLayer( |
| 9040 root_ptr->id(), player.get()); |
| 9041 host_impl.active_tree() |
| 9042 ->animation_host() |
| 9043 ->GetControllerForLayerId(root_ptr->id()) |
| 9044 ->AddAnimation(std::move(animation)); |
| 9045 root_ptr->SetOpacity(0); |
| 9046 grandchild_ptr->set_visible_layer_rect(gfx::Rect()); |
| 9047 root_ptr->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| 9048 ExecuteCalculateDrawPropertiesWithPropertyTrees(root_ptr); |
| 9049 EXPECT_EQ(gfx::Rect(10, 10), grandchild_ptr->visible_layer_rect()); |
| 9050 |
| 9051 host_impl.active_tree()->animation_host()->UnregisterPlayerForLayer( |
| 9052 root_ptr->id(), player.get()); |
8902 } | 9053 } |
8903 | 9054 |
8904 TEST_F(LayerTreeHostCommonTest, SkippingLayer) { | 9055 TEST_F(LayerTreeHostCommonTest, SkippingLayer) { |
8905 gfx::Transform identity; | 9056 gfx::Transform identity; |
8906 scoped_refptr<Layer> root = Layer::Create(); | 9057 scoped_refptr<Layer> root = Layer::Create(); |
8907 FakeContentLayerClient client; | 9058 FakeContentLayerClient client; |
8908 client.set_bounds(root->bounds()); | 9059 client.set_bounds(root->bounds()); |
8909 scoped_refptr<LayerWithForcedDrawsContent> child = | 9060 scoped_refptr<LayerWithForcedDrawsContent> child = |
8910 make_scoped_refptr(new LayerWithForcedDrawsContent()); | 9061 make_scoped_refptr(new LayerWithForcedDrawsContent()); |
8911 SetLayerPropertiesForTesting(root.get(), identity, gfx::Point3F(), | 9062 SetLayerPropertiesForTesting(root.get(), identity, gfx::Point3F(), |
(...skipping 704 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9616 child->SetDrawsContent(true); | 9767 child->SetDrawsContent(true); |
9617 root->layer_tree_impl()->property_trees()->needs_rebuild = true; | 9768 root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
9618 ExecuteCalculateDrawProperties(root); | 9769 ExecuteCalculateDrawProperties(root); |
9619 EXPECT_TRANSFORMATION_MATRIX_EQ(transform, | 9770 EXPECT_TRANSFORMATION_MATRIX_EQ(transform, |
9620 child->mask_layer()->ScreenSpaceTransform()); | 9771 child->mask_layer()->ScreenSpaceTransform()); |
9621 } | 9772 } |
9622 | 9773 |
9623 TEST_F(LayerTreeHostCommonTest, LargeTransformTest) { | 9774 TEST_F(LayerTreeHostCommonTest, LargeTransformTest) { |
9624 LayerImpl* root = root_layer(); | 9775 LayerImpl* root = root_layer(); |
9625 LayerImpl* render_surface1 = AddChild<LayerImpl>(root); | 9776 LayerImpl* render_surface1 = AddChild<LayerImpl>(root); |
9626 LayerImpl* render_surface2 = AddChild<LayerImpl>(render_surface1); | 9777 LayerImpl* child = AddChild<LayerImpl>(render_surface1); |
9627 | 9778 |
9628 const gfx::Transform identity_matrix; | 9779 const gfx::Transform identity_matrix; |
9629 render_surface1->SetDrawsContent(true); | 9780 child->SetDrawsContent(true); |
9630 render_surface2->SetDrawsContent(true); | 9781 child->SetMasksToBounds(true); |
9631 render_surface2->SetMasksToBounds(true); | |
9632 | 9782 |
9633 gfx::Transform large_transform; | 9783 gfx::Transform large_transform; |
9634 large_transform.Scale(99999999999999999999.f, 99999999999999999999.f); | 9784 large_transform.Scale(99999999999999999999.f, 99999999999999999999.f); |
9635 large_transform.Scale(9999999999999999999.f, 9999999999999999999.f); | 9785 large_transform.Scale(9999999999999999999.f, 9999999999999999999.f); |
9636 EXPECT_TRUE(std::isinf(large_transform.matrix().get(0, 0))); | 9786 EXPECT_TRUE(std::isinf(large_transform.matrix().get(0, 0))); |
9637 EXPECT_TRUE(std::isinf(large_transform.matrix().get(1, 1))); | 9787 EXPECT_TRUE(std::isinf(large_transform.matrix().get(1, 1))); |
9638 | 9788 |
9639 SetLayerPropertiesForTesting(root, identity_matrix, gfx::Point3F(), | 9789 SetLayerPropertiesForTesting(root, identity_matrix, gfx::Point3F(), |
9640 gfx::PointF(), gfx::Size(30, 30), true, false, | 9790 gfx::PointF(), gfx::Size(30, 30), true, false, |
9641 true); | 9791 true); |
9642 SetLayerPropertiesForTesting(render_surface1, large_transform, gfx::Point3F(), | 9792 SetLayerPropertiesForTesting(render_surface1, identity_matrix, gfx::Point3F(), |
9643 gfx::PointF(), gfx::Size(30, 30), true, false, | 9793 gfx::PointF(), gfx::Size(30, 30), true, false, |
9644 true); | 9794 true); |
9645 SetLayerPropertiesForTesting(render_surface2, identity_matrix, gfx::Point3F(), | 9795 // TODO(sunxd): we make child have no render surface, because if the |
| 9796 // child has one, the large transform applied to child will result in NaNs in |
| 9797 // the draw_transform of the render_surface, thus make draw property updates |
| 9798 // skip the child layer. We need further investigation into this to know |
| 9799 // what exactly happens here. |
| 9800 SetLayerPropertiesForTesting(child, large_transform, gfx::Point3F(), |
9646 gfx::PointF(), gfx::Size(30, 30), true, false, | 9801 gfx::PointF(), gfx::Size(30, 30), true, false, |
9647 true); | 9802 false); |
9648 | 9803 |
9649 ExecuteCalculateDrawProperties(root); | 9804 ExecuteCalculateDrawProperties(root); |
9650 | 9805 |
9651 bool is_inf_or_nan = | 9806 EXPECT_EQ(gfx::RectF(), |
9652 std::isinf( | 9807 render_surface1->render_surface()->DrawableContentRect()); |
9653 render_surface2->render_surface()->draw_transform().matrix().get( | 9808 |
9654 0, 0)) || | 9809 bool is_inf_or_nan = std::isinf(child->DrawTransform().matrix().get(0, 0)) || |
9655 std::isnan( | 9810 std::isnan(child->DrawTransform().matrix().get(0, 0)); |
9656 render_surface2->render_surface()->draw_transform().matrix().get(0, | |
9657 0)); | |
9658 EXPECT_TRUE(is_inf_or_nan); | 9811 EXPECT_TRUE(is_inf_or_nan); |
9659 is_inf_or_nan = | 9812 |
9660 std::isinf( | 9813 is_inf_or_nan = std::isinf(child->DrawTransform().matrix().get(1, 1)) || |
9661 render_surface2->render_surface()->draw_transform().matrix().get( | 9814 std::isnan(child->DrawTransform().matrix().get(1, 1)); |
9662 1, 1)) || | |
9663 std::isnan( | |
9664 render_surface2->render_surface()->draw_transform().matrix().get(1, | |
9665 1)); | |
9666 EXPECT_TRUE(is_inf_or_nan); | 9815 EXPECT_TRUE(is_inf_or_nan); |
9667 EXPECT_EQ(gfx::RectF(), | |
9668 render_surface2->render_surface()->DrawableContentRect()); | |
9669 | 9816 |
9670 std::vector<LayerImpl*>* rsll = render_surface_layer_list_impl(); | 9817 std::vector<LayerImpl*>* rsll = render_surface_layer_list_impl(); |
9671 bool root_in_rsll = | 9818 bool root_in_rsll = |
9672 std::find(rsll->begin(), rsll->end(), root) != rsll->end(); | 9819 std::find(rsll->begin(), rsll->end(), root) != rsll->end(); |
9673 EXPECT_TRUE(root_in_rsll); | 9820 EXPECT_TRUE(root_in_rsll); |
9674 bool render_surface2_in_rsll = | |
9675 std::find(rsll->begin(), rsll->end(), render_surface2) != rsll->end(); | |
9676 EXPECT_FALSE(render_surface2_in_rsll); | |
9677 } | 9821 } |
9678 | 9822 |
9679 TEST_F(LayerTreeHostCommonTest, SerializeScrollUpdateInfo) { | 9823 TEST_F(LayerTreeHostCommonTest, SerializeScrollUpdateInfo) { |
9680 LayerTreeHostCommon::ScrollUpdateInfo scroll; | 9824 LayerTreeHostCommon::ScrollUpdateInfo scroll; |
9681 scroll.layer_id = 2; | 9825 scroll.layer_id = 2; |
9682 scroll.scroll_delta = gfx::Vector2d(5, 10); | 9826 scroll.scroll_delta = gfx::Vector2d(5, 10); |
9683 | 9827 |
9684 proto::ScrollUpdateInfo proto; | 9828 proto::ScrollUpdateInfo proto; |
9685 scroll.ToProtobuf(&proto); | 9829 scroll.ToProtobuf(&proto); |
9686 LayerTreeHostCommon::ScrollUpdateInfo new_scroll; | 9830 LayerTreeHostCommon::ScrollUpdateInfo new_scroll; |
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9901 EXPECT_EQ(scroll_child6.id, grand_child10->scroll_tree_index()); | 10045 EXPECT_EQ(scroll_child6.id, grand_child10->scroll_tree_index()); |
9902 EXPECT_EQ(scroll_root1.id, parent3->scroll_tree_index()); | 10046 EXPECT_EQ(scroll_root1.id, parent3->scroll_tree_index()); |
9903 EXPECT_EQ(scroll_child7.id, child8->scroll_tree_index()); | 10047 EXPECT_EQ(scroll_child7.id, child8->scroll_tree_index()); |
9904 EXPECT_EQ(scroll_root1.id, parent4->scroll_tree_index()); | 10048 EXPECT_EQ(scroll_root1.id, parent4->scroll_tree_index()); |
9905 EXPECT_EQ(scroll_root1.id, child9->scroll_tree_index()); | 10049 EXPECT_EQ(scroll_root1.id, child9->scroll_tree_index()); |
9906 EXPECT_EQ(scroll_root1.id, grand_child12->scroll_tree_index()); | 10050 EXPECT_EQ(scroll_root1.id, grand_child12->scroll_tree_index()); |
9907 } | 10051 } |
9908 | 10052 |
9909 } // namespace | 10053 } // namespace |
9910 } // namespace cc | 10054 } // namespace cc |
OLD | NEW |