Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(165)

Side by Side Diff: cc/trees/layer_tree_host_common_unittest.cc

Issue 1811423002: SubtreeShouldBeSkipped uses information from property trees (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Resolve comments Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 3489 matching lines...) Expand 10 before | Expand all | Expand 10 after
3514 gfx::PointF(10.f, 10.f), gfx::Size(100, 100), 3515 gfx::PointF(10.f, 10.f), gfx::Size(100, 100),
3515 false, true, false); 3516 false, true, false);
3516 SetLayerPropertiesForTesting(grand_child, rotation, gfx::Point3F(), 3517 SetLayerPropertiesForTesting(grand_child, rotation, gfx::Point3F(),
3517 gfx::PointF(), gfx::Size(100, 100), false, true, 3518 gfx::PointF(), gfx::Size(100, 100), false, true,
3518 false); 3519 false);
3519 3520
3520 ExecuteCalculateDrawProperties(root); 3521 ExecuteCalculateDrawProperties(root);
3521 3522
3522 // Though all layers have invertible transforms, matrix multiplication using 3523 // Though all layers have invertible transforms, matrix multiplication using
3523 // floating-point math makes the draw transform uninvertible. 3524 // floating-point math makes the draw transform uninvertible.
3524 EXPECT_FALSE(grand_child->DrawTransform().IsInvertible()); 3525 EXPECT_FALSE(root->layer_tree_impl()
3526 ->property_trees()
3527 ->transform_tree.Node(grand_child->transform_tree_index())
3528 ->data.ancestors_are_invertible);
3525 3529
3526 // CalcDrawProps only skips a subtree when a layer's own transform is 3530 // CalcDrawProps skips a subtree when a layer's screen space transform is
3527 // uninvertible, not when its draw transform is invertible, since CDP makes 3531 // uninvertible
3528 // skipping decisions before computing a layer's draw transform. Property 3532 EXPECT_EQ(gfx::Rect(), grand_child->visible_layer_rect());
3529 // trees make skipping decisions after computing draw transforms, so could be
3530 // made to skip layers with an uninvertible draw transform (once CDP is
3531 // deleted).
3532 EXPECT_EQ(gfx::Rect(grand_child->bounds()),
3533 grand_child->visible_layer_rect());
3534 } 3533 }
3535 3534
3536 TEST_F(LayerTreeHostCommonTest, 3535 TEST_F(LayerTreeHostCommonTest,
3537 OcclusionForLayerWithUninvertibleDrawTransform) { 3536 OcclusionForLayerWithUninvertibleDrawTransform) {
3538 FakeImplTaskRunnerProvider task_runner_provider; 3537 FakeImplTaskRunnerProvider task_runner_provider;
3539 TestSharedBitmapManager shared_bitmap_manager; 3538 TestSharedBitmapManager shared_bitmap_manager;
3540 TestTaskGraphRunner task_graph_runner; 3539 TestTaskGraphRunner task_graph_runner;
3541 scoped_ptr<OutputSurface> output_surface = FakeOutputSurface::Create3d(); 3540 scoped_ptr<OutputSurface> output_surface = FakeOutputSurface::Create3d();
3542 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &shared_bitmap_manager, 3541 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &shared_bitmap_manager,
3543 &task_graph_runner); 3542 &task_graph_runner);
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
3582 host_impl.InitializeRenderer(output_surface.get()); 3581 host_impl.InitializeRenderer(output_surface.get());
3583 host_impl.active_tree()->BuildPropertyTreesForTesting(); 3582 host_impl.active_tree()->BuildPropertyTreesForTesting();
3584 bool update_lcd_text = false; 3583 bool update_lcd_text = false;
3585 host_impl.active_tree()->UpdateDrawProperties(update_lcd_text); 3584 host_impl.active_tree()->UpdateDrawProperties(update_lcd_text);
3586 3585
3587 LayerImpl* grand_child_ptr = 3586 LayerImpl* grand_child_ptr =
3588 host_impl.active_tree()->root_layer()->children()[0]->children()[0]; 3587 host_impl.active_tree()->root_layer()->children()[0]->children()[0];
3589 3588
3590 // Though all layers have invertible transforms, matrix multiplication using 3589 // Though all layers have invertible transforms, matrix multiplication using
3591 // floating-point math makes the draw transform uninvertible. 3590 // floating-point math makes the draw transform uninvertible.
3592 EXPECT_FALSE(grand_child_ptr->DrawTransform().IsInvertible()); 3591 EXPECT_FALSE(
3592 host_impl.active_tree()
3593 ->property_trees()
3594 ->transform_tree.Node(grand_child_ptr->transform_tree_index())
3595 ->data.ancestors_are_invertible);
3593 3596
3594 // Since |grand_child| has an uninvertible draw transform, it is treated as 3597 // Since |grand_child| has an univertible draw transform, it is skipped so
ajuma 2016/03/31 19:22:32 uninvertible (missing 'n') Also, replace "draw tra
sunxd 2016/04/01 17:57:45 Done.
3595 // unoccluded (even though |occluding_child| comes later in draw order, and 3598 // that we are not computing its occlusion_in_content_space.
3596 // hence potentially occludes it). 3599 gfx::Rect layer_bounds = gfx::Rect();
3597 gfx::Rect layer_bounds = gfx::Rect(grand_child_ptr->bounds());
3598 EXPECT_EQ( 3600 EXPECT_EQ(
3599 layer_bounds, 3601 layer_bounds,
3600 grand_child_ptr->draw_properties() 3602 grand_child_ptr->draw_properties()
3601 .occlusion_in_content_space.GetUnoccludedContentRect(layer_bounds)); 3603 .occlusion_in_content_space.GetUnoccludedContentRect(layer_bounds));
3602 } 3604 }
3603 3605
3604 TEST_F(LayerTreeHostCommonTest, 3606 TEST_F(LayerTreeHostCommonTest,
3605 SingularTransformDoesNotPreventClearingDrawProperties) { 3607 SingularTransformDoesNotPreventClearingDrawProperties) {
3606 scoped_refptr<Layer> root = Layer::Create(); 3608 scoped_refptr<Layer> root = Layer::Create();
3607 scoped_refptr<LayerWithForcedDrawsContent> child = 3609 scoped_refptr<LayerWithForcedDrawsContent> child =
(...skipping 2234 matching lines...) Expand 10 before | Expand all | Expand 10 after
5842 5844
5843 std::vector<scoped_ptr<CopyOutputRequest>> copy_requests; 5845 std::vector<scoped_ptr<CopyOutputRequest>> copy_requests;
5844 copy_requests.push_back( 5846 copy_requests.push_back(
5845 CopyOutputRequest::CreateRequest(base::Bind(&EmptyCopyOutputCallback))); 5847 CopyOutputRequest::CreateRequest(base::Bind(&EmptyCopyOutputCallback)));
5846 copy_layer->PassCopyRequests(&copy_requests); 5848 copy_layer->PassCopyRequests(&copy_requests);
5847 EXPECT_TRUE(copy_layer->HasCopyRequest()); 5849 EXPECT_TRUE(copy_layer->HasCopyRequest());
5848 5850
5849 copy_layer->AddChild(std::move(copy_child)); 5851 copy_layer->AddChild(std::move(copy_child));
5850 copy_parent->AddChild(std::move(copy_layer)); 5852 copy_parent->AddChild(std::move(copy_layer));
5851 root->AddChild(std::move(copy_parent)); 5853 root->AddChild(std::move(copy_parent));
5852 host_impl.pending_tree()->SetRootLayer(std::move(root));
5853 LayerImpl* root_ptr = host_impl.pending_tree()->root_layer();
5854 5854
5855 LayerImplList render_surface_layer_list; 5855 LayerImplList render_surface_layer_list;
5856 root_ptr->layer_tree_impl()->IncrementRenderSurfaceListIdForTesting(); 5856 root->layer_tree_impl()->IncrementRenderSurfaceListIdForTesting();
5857 LayerImpl* root_layer = root.get();
5858 root_layer->layer_tree_impl()->SetRootLayer(std::move(root));
5857 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( 5859 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs(
5858 root_ptr, root_ptr->bounds(), &render_surface_layer_list, 5860 root_layer, root_layer->bounds(), &render_surface_layer_list,
5859 root_ptr->layer_tree_impl()->current_render_surface_list_id()); 5861 root_layer->layer_tree_impl()->current_render_surface_list_id());
5860 inputs.can_adjust_raster_scales = true; 5862 inputs.can_adjust_raster_scales = true;
5861 LayerTreeHostCommon::CalculateDrawProperties(&inputs); 5863 LayerTreeHostCommon::CalculateDrawProperties(&inputs);
5862 5864
5863 // We should have two render surface, as the others are clipped out. 5865 // We should have two render surface, as the others are clipped out.
5864 ASSERT_EQ(2u, render_surface_layer_list.size()); 5866 ASSERT_EQ(2u, render_surface_layer_list.size());
5865 EXPECT_EQ(root_ptr->id(), render_surface_layer_list.at(0)->id()); 5867 EXPECT_EQ(root_layer->id(), render_surface_layer_list.at(0)->id());
5866 5868
5867 // The root render surface should only have 2 contributing layer, since the 5869 // The root render surface should only have 2 contributing layer, since the
5868 // other layers are empty/clipped away. 5870 // other layers are empty/clipped away.
5869 ASSERT_EQ(2u, root_ptr->render_surface()->layer_list().size()); 5871 ASSERT_EQ(2u, root_layer->render_surface()->layer_list().size());
5870 EXPECT_EQ(root_ptr->id(), 5872 EXPECT_EQ(root_layer->id(),
5871 root_ptr->render_surface()->layer_list().at(0)->id()); 5873 root_layer->render_surface()->layer_list().at(0)->id());
5872 } 5874 }
5873 5875
5874 TEST_F(LayerTreeHostCommonTest, VisibleContentRectInsideSurface) { 5876 TEST_F(LayerTreeHostCommonTest, VisibleContentRectInsideSurface) {
5875 FakeImplTaskRunnerProvider task_runner_provider; 5877 FakeImplTaskRunnerProvider task_runner_provider;
5876 TestSharedBitmapManager shared_bitmap_manager; 5878 TestSharedBitmapManager shared_bitmap_manager;
5877 TestTaskGraphRunner task_graph_runner; 5879 TestTaskGraphRunner task_graph_runner;
5878 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &shared_bitmap_manager, 5880 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &shared_bitmap_manager,
5879 &task_graph_runner); 5881 &task_graph_runner);
5880 host_impl.CreatePendingTree(); 5882 host_impl.CreatePendingTree();
5881 const gfx::Transform identity_matrix; 5883 const gfx::Transform identity_matrix;
(...skipping 526 matching lines...) Expand 10 before | Expand all | Expand 10 after
6408 SetLayerPropertiesForTesting(child3.get(), identity_matrix, transform_origin, 6410 SetLayerPropertiesForTesting(child3.get(), identity_matrix, transform_origin,
6409 position, bounds, true, false, false); 6411 position, bounds, true, false, false);
6410 child3->SetDrawsContent(true); 6412 child3->SetDrawsContent(true);
6411 6413
6412 child2->Set3dSortingContextId(1); 6414 child2->Set3dSortingContextId(1);
6413 child3->Set3dSortingContextId(1); 6415 child3->Set3dSortingContextId(1);
6414 6416
6415 child2->AddChild(std::move(child3)); 6417 child2->AddChild(std::move(child3));
6416 child1->AddChild(std::move(child2)); 6418 child1->AddChild(std::move(child2));
6417 root->AddChild(std::move(child1)); 6419 root->AddChild(std::move(child1));
6418 host_impl.active_tree()->SetRootLayer(std::move(root)); 6420 LayerImpl* root_layer = root.get();
6419 LayerImpl* root_ptr = host_impl.active_tree()->root_layer(); 6421 root_layer->layer_tree_impl()->SetRootLayer(std::move(root));
6420 6422
6421 { 6423 {
6422 LayerImplList render_surface_layer_list; 6424 LayerImplList render_surface_layer_list;
6423 FakeLayerTreeHostImpl::RecursiveUpdateNumChildren(root_ptr); 6425 FakeLayerTreeHostImpl::RecursiveUpdateNumChildren(root_layer);
6424 root_ptr->layer_tree_impl()->IncrementRenderSurfaceListIdForTesting(); 6426 root_layer->layer_tree_impl()->IncrementRenderSurfaceListIdForTesting();
6425 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( 6427 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs(
6426 root_ptr, root_ptr->bounds(), &render_surface_layer_list, 6428 root_layer, root_layer->bounds(), &render_surface_layer_list,
6427 root_ptr->layer_tree_impl()->current_render_surface_list_id()); 6429 root_layer->layer_tree_impl()->current_render_surface_list_id());
6428 inputs.can_render_to_separate_surface = true; 6430 inputs.can_render_to_separate_surface = true;
6429 LayerTreeHostCommon::CalculateDrawProperties(&inputs); 6431 LayerTreeHostCommon::CalculateDrawProperties(&inputs);
6430 6432
6431 EXPECT_EQ(2u, render_surface_layer_list.size()); 6433 EXPECT_EQ(2u, render_surface_layer_list.size());
6432 6434
6433 int count_represents_target_render_surface = 0; 6435 int count_represents_target_render_surface = 0;
6434 int count_represents_contributing_render_surface = 0; 6436 int count_represents_contributing_render_surface = 0;
6435 int count_represents_itself = 0; 6437 int count_represents_itself = 0;
6436 LayerIterator end = LayerIterator::End(&render_surface_layer_list); 6438 LayerIterator end = LayerIterator::End(&render_surface_layer_list);
6437 for (LayerIterator it = LayerIterator::Begin(&render_surface_layer_list); 6439 for (LayerIterator it = LayerIterator::Begin(&render_surface_layer_list);
6438 it != end; ++it) { 6440 it != end; ++it) {
6439 if (it.represents_target_render_surface()) 6441 if (it.represents_target_render_surface())
6440 count_represents_target_render_surface++; 6442 count_represents_target_render_surface++;
6441 if (it.represents_contributing_render_surface()) 6443 if (it.represents_contributing_render_surface())
6442 count_represents_contributing_render_surface++; 6444 count_represents_contributing_render_surface++;
6443 if (it.represents_itself()) 6445 if (it.represents_itself())
6444 count_represents_itself++; 6446 count_represents_itself++;
6445 } 6447 }
6446 6448
6447 // Two render surfaces. 6449 // Two render surfaces.
6448 EXPECT_EQ(2, count_represents_target_render_surface); 6450 EXPECT_EQ(2, count_represents_target_render_surface);
6449 // Second render surface contributes to root render surface. 6451 // Second render surface contributes to root render surface.
6450 EXPECT_EQ(1, count_represents_contributing_render_surface); 6452 EXPECT_EQ(1, count_represents_contributing_render_surface);
6451 // All 4 layers represent itself. 6453 // All 4 layers represent itself.
6452 EXPECT_EQ(4, count_represents_itself); 6454 EXPECT_EQ(4, count_represents_itself);
6453 } 6455 }
6454 6456
6455 { 6457 {
6456 LayerImplList render_surface_layer_list; 6458 LayerImplList render_surface_layer_list;
6457 root_ptr->layer_tree_impl()->IncrementRenderSurfaceListIdForTesting(); 6459 root_layer->layer_tree_impl()->IncrementRenderSurfaceListIdForTesting();
6458 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( 6460 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs(
6459 root_ptr, root_ptr->bounds(), &render_surface_layer_list, 6461 root_layer, root_layer->bounds(), &render_surface_layer_list,
6460 root_ptr->layer_tree_impl()->current_render_surface_list_id()); 6462 root_layer->layer_tree_impl()->current_render_surface_list_id());
6461 inputs.can_render_to_separate_surface = false; 6463 inputs.can_render_to_separate_surface = false;
6462 LayerTreeHostCommon::CalculateDrawProperties(&inputs); 6464 LayerTreeHostCommon::CalculateDrawProperties(&inputs);
6463 6465
6464 EXPECT_EQ(1u, render_surface_layer_list.size()); 6466 EXPECT_EQ(1u, render_surface_layer_list.size());
6465 6467
6466 int count_represents_target_render_surface = 0; 6468 int count_represents_target_render_surface = 0;
6467 int count_represents_contributing_render_surface = 0; 6469 int count_represents_contributing_render_surface = 0;
6468 int count_represents_itself = 0; 6470 int count_represents_itself = 0;
6469 LayerIterator end = LayerIterator::End(&render_surface_layer_list); 6471 LayerIterator end = LayerIterator::End(&render_surface_layer_list);
6470 for (LayerIterator it = LayerIterator::Begin(&render_surface_layer_list); 6472 for (LayerIterator it = LayerIterator::Begin(&render_surface_layer_list);
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after
6780 ExecuteCalculateDrawProperties(root); 6782 ExecuteCalculateDrawProperties(root);
6781 6783
6782 EXPECT_EQ(3u, render_surface_layer_list_impl()->size()); 6784 EXPECT_EQ(3u, render_surface_layer_list_impl()->size());
6783 6785
6784 gfx::Transform singular_transform; 6786 gfx::Transform singular_transform;
6785 singular_transform.Scale3d( 6787 singular_transform.Scale3d(
6786 SkDoubleToMScalar(1.0), SkDoubleToMScalar(1.0), SkDoubleToMScalar(0.0)); 6788 SkDoubleToMScalar(1.0), SkDoubleToMScalar(1.0), SkDoubleToMScalar(0.0));
6787 6789
6788 child->SetTransform(singular_transform); 6790 child->SetTransform(singular_transform);
6789 6791
6792 root->layer_tree_impl()->property_trees()->needs_rebuild = true;
6790 ExecuteCalculateDrawProperties(root); 6793 ExecuteCalculateDrawProperties(root);
6791 6794
6792 EXPECT_EQ(2u, render_surface_layer_list_impl()->size()); 6795 EXPECT_EQ(2u, render_surface_layer_list_impl()->size());
6793 6796
6794 // Ensure that the entire subtree under a layer with singular transform does 6797 // Ensure that the entire subtree under a layer with singular transform does
6795 // not get rendered. 6798 // not get rendered.
6796 parent->SetTransform(singular_transform); 6799 parent->SetTransform(singular_transform);
6797 child->SetTransform(identity_transform); 6800 child->SetTransform(identity_transform);
6798 6801
6802 root->layer_tree_impl()->property_trees()->needs_rebuild = true;
6799 ExecuteCalculateDrawProperties(root); 6803 ExecuteCalculateDrawProperties(root);
6800 6804
6801 EXPECT_EQ(1u, render_surface_layer_list_impl()->size()); 6805 EXPECT_EQ(1u, render_surface_layer_list_impl()->size());
6802 } 6806 }
6803 6807
6804 TEST_F(LayerTreeHostCommonTest, ClippedByOutOfOrderScrollParent) { 6808 TEST_F(LayerTreeHostCommonTest, ClippedByOutOfOrderScrollParent) {
6805 // Checks that clipping by a scroll parent that follows you in paint order 6809 // Checks that clipping by a scroll parent that follows you in paint order
6806 // still results in correct clipping. 6810 // still results in correct clipping.
6807 // 6811 //
6808 // + root 6812 // + root
(...skipping 535 matching lines...) Expand 10 before | Expand all | Expand 10 after
7344 AnimationScaleFactorTrackingLayerImpl::Create(host_impl.active_tree(), 4); 7348 AnimationScaleFactorTrackingLayerImpl::Create(host_impl.active_tree(), 4);
7345 7349
7346 AnimationScaleFactorTrackingLayerImpl* parent_raw = parent.get(); 7350 AnimationScaleFactorTrackingLayerImpl* parent_raw = parent.get();
7347 AnimationScaleFactorTrackingLayerImpl* child_raw = child.get(); 7351 AnimationScaleFactorTrackingLayerImpl* child_raw = child.get();
7348 AnimationScaleFactorTrackingLayerImpl* grand_child_raw = grand_child.get(); 7352 AnimationScaleFactorTrackingLayerImpl* grand_child_raw = grand_child.get();
7349 AnimationScaleFactorTrackingLayerImpl* grand_parent_raw = grand_parent.get(); 7353 AnimationScaleFactorTrackingLayerImpl* grand_parent_raw = grand_parent.get();
7350 7354
7351 child->AddChild(std::move(grand_child)); 7355 child->AddChild(std::move(grand_child));
7352 parent->AddChild(std::move(child)); 7356 parent->AddChild(std::move(child));
7353 grand_parent->AddChild(std::move(parent)); 7357 grand_parent->AddChild(std::move(parent));
7354 host_impl.active_tree()->SetRootLayer(std::move(grand_parent));
7355 7358
7356 SetLayerPropertiesForTesting(grand_parent_raw, identity_matrix, 7359 SetLayerPropertiesForTesting(grand_parent_raw, identity_matrix,
7357 gfx::Point3F(), gfx::PointF(), gfx::Size(1, 2), 7360 gfx::Point3F(), gfx::PointF(), gfx::Size(1, 2),
7358 true, false, true); 7361 true, false, true);
7359 SetLayerPropertiesForTesting(parent_raw, identity_matrix, gfx::Point3F(), 7362 SetLayerPropertiesForTesting(parent_raw, identity_matrix, gfx::Point3F(),
7360 gfx::PointF(), gfx::Size(1, 2), true, false, 7363 gfx::PointF(), gfx::Size(1, 2), true, false,
7361 false); 7364 false);
7362 SetLayerPropertiesForTesting(child_raw, identity_matrix, gfx::Point3F(), 7365 SetLayerPropertiesForTesting(child_raw, identity_matrix, gfx::Point3F(),
7363 gfx::PointF(), gfx::Size(1, 2), true, false, 7366 gfx::PointF(), gfx::Size(1, 2), true, false,
7364 false); 7367 false);
7365 7368
7366 SetLayerPropertiesForTesting(grand_child_raw, identity_matrix, gfx::Point3F(), 7369 SetLayerPropertiesForTesting(grand_child_raw, identity_matrix, gfx::Point3F(),
7367 gfx::PointF(), gfx::Size(1, 2), true, false, 7370 gfx::PointF(), gfx::Size(1, 2), true, false,
7368 false); 7371 false);
7369 7372
7373 host_impl.active_tree()->SetRootLayer(std::move(grand_parent));
7374
7370 ExecuteCalculateDrawProperties(grand_parent_raw); 7375 ExecuteCalculateDrawProperties(grand_parent_raw);
7371 7376
7372 // No layers have animations. 7377 // No layers have animations.
7373 EXPECT_EQ( 7378 EXPECT_EQ(
7374 0.f, 7379 0.f,
7375 grand_parent_raw->draw_properties().maximum_animation_contents_scale); 7380 grand_parent_raw->draw_properties().maximum_animation_contents_scale);
7376 EXPECT_EQ(0.f, 7381 EXPECT_EQ(0.f,
7377 parent_raw->draw_properties().maximum_animation_contents_scale); 7382 parent_raw->draw_properties().maximum_animation_contents_scale);
7378 EXPECT_EQ(0.f, child_raw->draw_properties().maximum_animation_contents_scale); 7383 EXPECT_EQ(0.f, child_raw->draw_properties().maximum_animation_contents_scale);
7379 EXPECT_EQ( 7384 EXPECT_EQ(
(...skipping 1498 matching lines...) Expand 10 before | Expand all | Expand 10 after
8878 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)), 8883 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)),
8879 animation_id, 1, TargetProperty::OPACITY); 8884 animation_id, 1, TargetProperty::OPACITY);
8880 animation->set_fill_mode(Animation::FILL_MODE_NONE); 8885 animation->set_fill_mode(Animation::FILL_MODE_NONE);
8881 animation->set_time_offset(base::TimeDelta::FromMilliseconds(-1000)); 8886 animation->set_time_offset(base::TimeDelta::FromMilliseconds(-1000));
8882 AddAnimationToLayerWithExistingPlayer(child->id(), timeline(), 8887 AddAnimationToLayerWithExistingPlayer(child->id(), timeline(),
8883 std::move(animation)); 8888 std::move(animation));
8884 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); 8889 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get());
8885 EXPECT_EQ(gfx::Rect(10, 10), grandchild->visible_layer_rect()); 8890 EXPECT_EQ(gfx::Rect(10, 10), grandchild->visible_layer_rect());
8886 } 8891 }
8887 8892
8888 TEST_F(LayerTreeHostCommonTest, SkippingSubtreeImpl) { 8893 TEST_F(LayerTreeHostCommonTest, SkippingLayerImpl) {
8889 FakeImplTaskRunnerProvider task_runner_provider; 8894 FakeImplTaskRunnerProvider task_runner_provider;
8890 TestSharedBitmapManager shared_bitmap_manager; 8895 TestSharedBitmapManager shared_bitmap_manager;
8891 TestTaskGraphRunner task_graph_runner; 8896 TestTaskGraphRunner task_graph_runner;
8892 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &shared_bitmap_manager, 8897 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &shared_bitmap_manager,
8893 &task_graph_runner); 8898 &task_graph_runner);
8894 8899
8895 gfx::Transform identity; 8900 gfx::Transform identity;
8896 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl.active_tree(), 1); 8901 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl.active_tree(), 1);
8897 scoped_ptr<LayerImpl> child = LayerImpl::Create(host_impl.active_tree(), 2); 8902 scoped_ptr<LayerImpl> child = LayerImpl::Create(host_impl.active_tree(), 2);
8898 scoped_ptr<LayerImpl> grandchild = 8903 scoped_ptr<LayerImpl> grandchild =
(...skipping 18 matching lines...) Expand all
8917 8922
8918 LayerImpl* root_ptr = root.get(); 8923 LayerImpl* root_ptr = root.get();
8919 LayerImpl* child_ptr = child.get(); 8924 LayerImpl* child_ptr = child.get();
8920 LayerImpl* grandchild_ptr = grandchild.get(); 8925 LayerImpl* grandchild_ptr = grandchild.get();
8921 8926
8922 child->AddChild(std::move(grandchild)); 8927 child->AddChild(std::move(grandchild));
8923 root->AddChild(std::move(child)); 8928 root->AddChild(std::move(child));
8924 host_impl.active_tree()->SetRootLayer(std::move(root)); 8929 host_impl.active_tree()->SetRootLayer(std::move(root));
8925 8930
8926 // Check the non-skipped case. 8931 // Check the non-skipped case.
8927 ExecuteCalculateDrawPropertiesWithPropertyTrees(root_ptr); 8932 // ExecuteCalculateDrawPropertiesWithPropertyTrees(root_ptr);
8928 EXPECT_EQ(gfx::Rect(10, 10), grandchild_ptr->visible_layer_rect()); 8933 // EXPECT_EQ(gfx::Rect(10, 10), grandchild_ptr->visible_layer_rect());
8929 8934
8930 // Now we will reset the visible rect from property trees for the grandchild, 8935 // Now we will reset the visible rect from property trees for the grandchild,
8931 // and we will configure |child| in several ways that should force the subtree 8936 // and we will configure |child| in several ways that should force the subtree
8932 // to be skipped. The visible content rect for |grandchild| should, therefore, 8937 // to be skipped. The visible content rect for |grandchild| should, therefore,
8933 // remain empty. 8938 // remain empty.
8934 grandchild_ptr->set_visible_layer_rect(gfx::Rect()); 8939 grandchild_ptr->set_visible_layer_rect(gfx::Rect());
8940
8935 gfx::Transform singular; 8941 gfx::Transform singular;
8936 singular.matrix().set(0, 0, 0); 8942 singular.matrix().set(0, 0, 0);
8943 // This line is used to make the results of skipping and not skipping layers
8944 // different.
8945 singular.matrix().set(0, 1, 1);
8946
8947 gfx::Transform rotate;
8948 rotate.Rotate(90);
8949
8950 gfx::Transform rotate_back_and_translate;
8951 rotate_back_and_translate.RotateAboutYAxis(180);
8952 rotate_back_and_translate.Translate(-10, 0);
8937 8953
8938 child_ptr->SetTransform(singular); 8954 child_ptr->SetTransform(singular);
8955 host_impl.active_tree()->property_trees()->needs_rebuild = true;
8939 ExecuteCalculateDrawPropertiesWithPropertyTrees(root_ptr); 8956 ExecuteCalculateDrawPropertiesWithPropertyTrees(root_ptr);
8940 EXPECT_EQ(gfx::Rect(0, 0), grandchild_ptr->visible_layer_rect()); 8957 EXPECT_EQ(gfx::Rect(0, 0), grandchild_ptr->visible_layer_rect());
8941 child_ptr->SetTransform(identity); 8958 child_ptr->SetTransform(identity);
8942 8959
8943 child_ptr->SetHideLayerAndSubtree(true); 8960 child_ptr->SetHideLayerAndSubtree(true);
8944 ExecuteCalculateDrawPropertiesWithPropertyTrees(root_ptr); 8961 ExecuteCalculateDrawPropertiesWithPropertyTrees(root_ptr);
8945 EXPECT_EQ(gfx::Rect(0, 0), grandchild_ptr->visible_layer_rect()); 8962 EXPECT_EQ(gfx::Rect(0, 0), grandchild_ptr->visible_layer_rect());
8946 child_ptr->SetHideLayerAndSubtree(false); 8963 child_ptr->SetHideLayerAndSubtree(false);
8947 8964
8948 child_ptr->SetOpacity(0.f); 8965 child_ptr->SetOpacity(0.f);
8949 ExecuteCalculateDrawPropertiesWithPropertyTrees(root_ptr); 8966 ExecuteCalculateDrawPropertiesWithPropertyTrees(root_ptr);
8950 EXPECT_EQ(gfx::Rect(0, 0), grandchild_ptr->visible_layer_rect()); 8967 EXPECT_EQ(gfx::Rect(0, 0), grandchild_ptr->visible_layer_rect());
8968 child_ptr->SetOpacity(1.f);
8951 8969
8970 root_ptr->SetTransform(singular);
8971 // Force transform tree to have a node for child, so that ancestor's
8972 // invertible transform can be tested.
8973 child_ptr->SetTransform(rotate);
8974 host_impl.active_tree()->property_trees()->needs_rebuild = true;
8975 ExecuteCalculateDrawPropertiesWithPropertyTrees(root_ptr);
8976 EXPECT_EQ(gfx::Rect(0, 0), grandchild_ptr->visible_layer_rect());
8977 root_ptr->SetTransform(identity);
8978 child_ptr->SetTransform(identity);
8979
8980 root_ptr->SetOpacity(0.f);
8981 child_ptr->SetOpacity(0.7f);
8982 host_impl.active_tree()->property_trees()->needs_rebuild = true;
8983 ExecuteCalculateDrawPropertiesWithPropertyTrees(root_ptr);
8984 EXPECT_EQ(gfx::Rect(0, 0), grandchild_ptr->visible_layer_rect());
8985 root_ptr->SetOpacity(1.f);
8986
8987 child_ptr->SetOpacity(0.f);
8952 // Now, even though child has zero opacity, we will configure |grandchild| and 8988 // Now, even though child has zero opacity, we will configure |grandchild| and
8953 // |greatgrandchild| in several ways that should force the subtree to be 8989 // |greatgrandchild| in several ways that should force the subtree to be
8954 // processed anyhow. 8990 // processed anyhow.
8955 std::vector<scoped_ptr<CopyOutputRequest>> requests; 8991 std::vector<scoped_ptr<CopyOutputRequest>> requests;
8956 requests.push_back(CopyOutputRequest::CreateEmptyRequest()); 8992 requests.push_back(CopyOutputRequest::CreateEmptyRequest());
8957 8993
8958 grandchild_ptr->PassCopyRequests(&requests); 8994 grandchild_ptr->PassCopyRequests(&requests);
8959 root_ptr->layer_tree_impl()->property_trees()->needs_rebuild = true; 8995 root_ptr->layer_tree_impl()->property_trees()->needs_rebuild = true;
8960 ExecuteCalculateDrawPropertiesWithPropertyTrees(root_ptr); 8996 ExecuteCalculateDrawPropertiesWithPropertyTrees(root_ptr);
8961 EXPECT_EQ(gfx::Rect(10, 10), grandchild_ptr->visible_layer_rect()); 8997 EXPECT_EQ(gfx::Rect(10, 10), grandchild_ptr->visible_layer_rect());
8998 requests.clear();
8999 grandchild_ptr->PassCopyRequests(&requests);
9000 child_ptr->SetOpacity(1.f);
9001
9002 // A double sided render surface with backface visible should not be skipped
9003 grandchild_ptr->set_visible_layer_rect(gfx::Rect());
9004 child_ptr->SetHasRenderSurface(true);
9005 child_ptr->SetDoubleSided(true);
9006 child_ptr->SetTransform(rotate_back_and_translate);
9007 root_ptr->layer_tree_impl()->property_trees()->needs_rebuild = true;
9008 ExecuteCalculateDrawPropertiesWithPropertyTrees(root_ptr);
9009 EXPECT_EQ(gfx::Rect(10, 10), grandchild_ptr->visible_layer_rect());
9010 child_ptr->ClearRenderSurfaceLayerList();
ajuma 2016/03/31 19:22:33 Is this line needed? We don't normally call this d
sunxd 2016/04/01 17:57:45 Hmm, the test can still pass without this line. I
9011 child_ptr->SetTransform(identity);
9012
9013 scoped_ptr<KeyframedTransformAnimationCurve> curve(
9014 KeyframedTransformAnimationCurve::Create());
9015 TransformOperations start;
9016 start.AppendTranslate(1.f, 2.f, 3.f);
9017 gfx::Transform transform;
9018 transform.Scale3d(1.0, 2.0, 3.0);
9019 TransformOperations operation;
9020 operation.AppendMatrix(transform);
9021 curve->AddKeyframe(
9022 TransformKeyframe::Create(base::TimeDelta(), start, nullptr));
9023 curve->AddKeyframe(TransformKeyframe::Create(
9024 base::TimeDelta::FromSecondsD(1.0), operation, nullptr));
9025 scoped_ptr<Animation> transform_animation(
9026 Animation::Create(std::move(curve), 3, 3, TargetProperty::TRANSFORM));
9027 scoped_refptr<AnimationPlayer> player(AnimationPlayer::Create(1));
9028 host_impl.active_tree()->animation_host()->RegisterPlayerForLayer(
9029 root_ptr->id(), player.get());
9030 host_impl.active_tree()
9031 ->animation_host()
9032 ->GetControllerForLayerId(root_ptr->id())
9033 ->AddAnimation(std::move(transform_animation));
9034 grandchild_ptr->set_visible_layer_rect(gfx::Rect());
9035 child_ptr->SetScrollClipLayer(root_ptr->id());
9036 root_ptr->SetTransform(singular);
9037 child_ptr->SetTransform(singular);
9038 root_ptr->layer_tree_impl()->property_trees()->needs_rebuild = true;
9039 ExecuteCalculateDrawPropertiesWithPropertyTrees(root_ptr);
9040 EXPECT_EQ(gfx::Rect(10, 10), grandchild_ptr->visible_layer_rect());
9041
9042 host_impl.active_tree()->animation_host()->UnregisterPlayerForLayer(
9043 root_ptr->id(), player.get());
9044 }
9045
9046 TEST_F(LayerTreeHostCommonTest, SkippingPendingLayerImpl) {
9047 FakeImplTaskRunnerProvider task_runner_provider;
9048 TestSharedBitmapManager shared_bitmap_manager;
9049 TestTaskGraphRunner task_graph_runner;
9050 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &shared_bitmap_manager,
9051 &task_graph_runner);
9052
9053 gfx::Transform identity;
9054 host_impl.CreatePendingTree();
9055 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl.pending_tree(), 1);
9056 scoped_ptr<LayerImpl> child = LayerImpl::Create(host_impl.pending_tree(), 2);
9057 scoped_ptr<LayerImpl> grandchild =
9058 LayerImpl::Create(host_impl.pending_tree(), 3);
9059
9060 scoped_ptr<FakePictureLayerImpl> greatgrandchild(
9061 FakePictureLayerImpl::Create(host_impl.pending_tree(), 4));
9062
9063 child->SetDrawsContent(true);
9064 grandchild->SetDrawsContent(true);
9065 greatgrandchild->SetDrawsContent(true);
9066
9067 SetLayerPropertiesForTesting(root.get(), identity, gfx::Point3F(),
9068 gfx::PointF(), gfx::Size(100, 100), true, false,
9069 true);
9070 SetLayerPropertiesForTesting(child.get(), identity, gfx::Point3F(),
9071 gfx::PointF(), gfx::Size(10, 10), true, false,
9072 false);
9073 SetLayerPropertiesForTesting(grandchild.get(), identity, gfx::Point3F(),
9074 gfx::PointF(), gfx::Size(10, 10), true, false,
9075 false);
9076
9077 LayerImpl* root_ptr = root.get();
9078 LayerImpl* grandchild_ptr = grandchild.get();
9079
9080 child->AddChild(std::move(grandchild));
9081 root->AddChild(std::move(child));
9082
9083 host_impl.pending_tree()->SetRootLayer(std::move(root));
9084
9085 // Check the non-skipped case.
9086 ExecuteCalculateDrawPropertiesWithPropertyTrees(root_ptr);
9087 EXPECT_EQ(gfx::Rect(10, 10), grandchild_ptr->visible_layer_rect());
9088
9089 scoped_ptr<KeyframedFloatAnimationCurve> curve(
9090 KeyframedFloatAnimationCurve::Create());
9091 scoped_ptr<TimingFunction> func = EaseTimingFunction::Create();
9092 curve->AddKeyframe(
9093 FloatKeyframe::Create(base::TimeDelta(), 0.9f, std::move(func)));
9094 curve->AddKeyframe(
9095 FloatKeyframe::Create(base::TimeDelta::FromSecondsD(1.0), 0.3f, nullptr));
9096 scoped_ptr<Animation> animation(
9097 Animation::Create(std::move(curve), 3, 3, TargetProperty::OPACITY));
9098 scoped_refptr<AnimationPlayer> player(AnimationPlayer::Create(1));
9099 host_impl.active_tree()->animation_host()->RegisterPlayerForLayer(
9100 root_ptr->id(), player.get());
9101 host_impl.active_tree()
9102 ->animation_host()
9103 ->GetControllerForLayerId(root_ptr->id())
9104 ->AddAnimation(std::move(animation));
9105 root_ptr->SetOpacity(0);
9106 grandchild_ptr->set_visible_layer_rect(gfx::Rect());
9107 root_ptr->layer_tree_impl()->property_trees()->needs_rebuild = true;
9108 ExecuteCalculateDrawPropertiesWithPropertyTrees(root_ptr);
9109 EXPECT_EQ(gfx::Rect(10, 10), grandchild_ptr->visible_layer_rect());
9110
9111 host_impl.active_tree()->animation_host()->UnregisterPlayerForLayer(
9112 root_ptr->id(), player.get());
8962 } 9113 }
8963 9114
8964 TEST_F(LayerTreeHostCommonTest, SkippingLayer) { 9115 TEST_F(LayerTreeHostCommonTest, SkippingLayer) {
8965 gfx::Transform identity; 9116 gfx::Transform identity;
8966 scoped_refptr<Layer> root = Layer::Create(); 9117 scoped_refptr<Layer> root = Layer::Create();
8967 FakeContentLayerClient client; 9118 FakeContentLayerClient client;
8968 client.set_bounds(root->bounds()); 9119 client.set_bounds(root->bounds());
8969 scoped_refptr<LayerWithForcedDrawsContent> child = 9120 scoped_refptr<LayerWithForcedDrawsContent> child =
8970 make_scoped_refptr(new LayerWithForcedDrawsContent()); 9121 make_scoped_refptr(new LayerWithForcedDrawsContent());
8971 SetLayerPropertiesForTesting(root.get(), identity, gfx::Point3F(), 9122 SetLayerPropertiesForTesting(root.get(), identity, gfx::Point3F(),
(...skipping 767 matching lines...) Expand 10 before | Expand all | Expand 10 after
9739 true); 9890 true);
9740 SetLayerPropertiesForTesting(render_surface1, large_transform, gfx::Point3F(), 9891 SetLayerPropertiesForTesting(render_surface1, large_transform, gfx::Point3F(),
9741 gfx::PointF(), gfx::Size(30, 30), true, false, 9892 gfx::PointF(), gfx::Size(30, 30), true, false,
9742 true); 9893 true);
9743 SetLayerPropertiesForTesting(render_surface2, identity_matrix, gfx::Point3F(), 9894 SetLayerPropertiesForTesting(render_surface2, identity_matrix, gfx::Point3F(),
9744 gfx::PointF(), gfx::Size(30, 30), true, false, 9895 gfx::PointF(), gfx::Size(30, 30), true, false,
9745 true); 9896 true);
9746 9897
9747 ExecuteCalculateDrawProperties(root); 9898 ExecuteCalculateDrawProperties(root);
9748 9899
9749 bool is_inf_or_nan = 9900 // render_surface2 is skipped because of singular transform
9750 std::isinf( 9901 EXPECT_EQ(identity_matrix,
jaydasika 2016/03/31 18:32:56 Why was it not skipped before this CL ? In any cas
sunxd 2016/04/01 17:57:45 None of the transforms of the layer and its ancest
jaydasika 2016/04/01 19:10:11 That's weird because only one layer has non-identi
9751 render_surface2->render_surface()->draw_transform().matrix().get( 9902 render_surface2->render_surface()->draw_transform());
9752 0, 0)) ||
9753 std::isnan(
9754 render_surface2->render_surface()->draw_transform().matrix().get(0,
9755 0));
9756 EXPECT_TRUE(is_inf_or_nan);
9757 is_inf_or_nan =
9758 std::isinf(
9759 render_surface2->render_surface()->draw_transform().matrix().get(
9760 1, 1)) ||
9761 std::isnan(
9762 render_surface2->render_surface()->draw_transform().matrix().get(1,
9763 1));
9764 EXPECT_TRUE(is_inf_or_nan);
9765 EXPECT_EQ(gfx::RectF(), 9903 EXPECT_EQ(gfx::RectF(),
9766 render_surface2->render_surface()->DrawableContentRect()); 9904 render_surface2->render_surface()->DrawableContentRect());
9767 9905
9768 std::vector<LayerImpl*>* rsll = render_surface_layer_list_impl(); 9906 std::vector<LayerImpl*>* rsll = render_surface_layer_list_impl();
9769 bool root_in_rsll = 9907 bool root_in_rsll =
9770 std::find(rsll->begin(), rsll->end(), root) != rsll->end(); 9908 std::find(rsll->begin(), rsll->end(), root) != rsll->end();
9771 EXPECT_TRUE(root_in_rsll); 9909 EXPECT_TRUE(root_in_rsll);
9772 bool render_surface2_in_rsll = 9910 bool render_surface2_in_rsll =
9773 std::find(rsll->begin(), rsll->end(), render_surface2) != rsll->end(); 9911 std::find(rsll->begin(), rsll->end(), render_surface2) != rsll->end();
9774 EXPECT_FALSE(render_surface2_in_rsll); 9912 EXPECT_FALSE(render_surface2_in_rsll);
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
9999 EXPECT_EQ(scroll_child6.id, grand_child10->scroll_tree_index()); 10137 EXPECT_EQ(scroll_child6.id, grand_child10->scroll_tree_index());
10000 EXPECT_EQ(scroll_root1.id, parent3->scroll_tree_index()); 10138 EXPECT_EQ(scroll_root1.id, parent3->scroll_tree_index());
10001 EXPECT_EQ(scroll_child7.id, child8->scroll_tree_index()); 10139 EXPECT_EQ(scroll_child7.id, child8->scroll_tree_index());
10002 EXPECT_EQ(scroll_root1.id, parent4->scroll_tree_index()); 10140 EXPECT_EQ(scroll_root1.id, parent4->scroll_tree_index());
10003 EXPECT_EQ(scroll_root1.id, child9->scroll_tree_index()); 10141 EXPECT_EQ(scroll_root1.id, child9->scroll_tree_index());
10004 EXPECT_EQ(scroll_root1.id, grand_child12->scroll_tree_index()); 10142 EXPECT_EQ(scroll_root1.id, grand_child12->scroll_tree_index());
10005 } 10143 }
10006 10144
10007 } // namespace 10145 } // namespace
10008 } // namespace cc 10146 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698