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

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: Fix windows compile failure Created 4 years, 9 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 own transform is uninvertible
3527 // uninvertible, not when its draw transform is invertible, since CDP makes 3531 EXPECT_EQ(gfx::Rect(), grand_child->visible_layer_rect());
3528 // skipping decisions before computing a layer's draw transform. Property
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 } 3532 }
3535 3533
3536 TEST_F(LayerTreeHostCommonTest, 3534 TEST_F(LayerTreeHostCommonTest,
3537 OcclusionForLayerWithUninvertibleDrawTransform) { 3535 OcclusionForLayerWithUninvertibleDrawTransform) {
3538 FakeImplTaskRunnerProvider task_runner_provider; 3536 FakeImplTaskRunnerProvider task_runner_provider;
3539 TestSharedBitmapManager shared_bitmap_manager; 3537 TestSharedBitmapManager shared_bitmap_manager;
3540 TestTaskGraphRunner task_graph_runner; 3538 TestTaskGraphRunner task_graph_runner;
3541 scoped_ptr<OutputSurface> output_surface = FakeOutputSurface::Create3d(); 3539 scoped_ptr<OutputSurface> output_surface = FakeOutputSurface::Create3d();
3542 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &shared_bitmap_manager, 3540 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &shared_bitmap_manager,
3543 &task_graph_runner); 3541 &task_graph_runner);
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
3582 host_impl.InitializeRenderer(output_surface.get()); 3580 host_impl.InitializeRenderer(output_surface.get());
3583 host_impl.active_tree()->BuildPropertyTreesForTesting(); 3581 host_impl.active_tree()->BuildPropertyTreesForTesting();
3584 bool update_lcd_text = false; 3582 bool update_lcd_text = false;
3585 host_impl.active_tree()->UpdateDrawProperties(update_lcd_text); 3583 host_impl.active_tree()->UpdateDrawProperties(update_lcd_text);
3586 3584
3587 LayerImpl* grand_child_ptr = 3585 LayerImpl* grand_child_ptr =
3588 host_impl.active_tree()->root_layer()->children()[0]->children()[0]; 3586 host_impl.active_tree()->root_layer()->children()[0]->children()[0];
3589 3587
3590 // Though all layers have invertible transforms, matrix multiplication using 3588 // Though all layers have invertible transforms, matrix multiplication using
3591 // floating-point math makes the draw transform uninvertible. 3589 // floating-point math makes the draw transform uninvertible.
3592 EXPECT_FALSE(grand_child_ptr->DrawTransform().IsInvertible()); 3590 EXPECT_FALSE(
3591 host_impl.active_tree()
3592 ->property_trees()
3593 ->transform_tree.Node(grand_child_ptr->transform_tree_index())
3594 ->data.ancestors_are_invertible);
ajuma 2016/03/24 15:11:59 Hmm. I think what's going wrong here is that we're
3593 3595
3594 // Since |grand_child| has an uninvertible draw transform, it is treated as 3596 // Since |grand_child| has an uninvertible draw transform, it is treated as
3595 // unoccluded (even though |occluding_child| comes later in draw order, and 3597 // unoccluded (even though |occluding_child| comes later in draw order, and
3596 // hence potentially occludes it). 3598 // hence potentially occludes it).
3597 gfx::Rect layer_bounds = gfx::Rect(grand_child_ptr->bounds()); 3599 gfx::Rect layer_bounds = gfx::Rect();
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 881 matching lines...) Expand 10 before | Expand all | Expand 10 after
4489 EXPECT_FALSE(back_facing_child->has_render_surface()); 4491 EXPECT_FALSE(back_facing_child->has_render_surface());
4490 EXPECT_TRUE(front_facing_surface->has_render_surface()); 4492 EXPECT_TRUE(front_facing_surface->has_render_surface());
4491 // We expect that a has_render_surface was created but not used. 4493 // We expect that a has_render_surface was created but not used.
4492 EXPECT_TRUE(back_facing_surface->has_render_surface()); 4494 EXPECT_TRUE(back_facing_surface->has_render_surface());
4493 EXPECT_FALSE( 4495 EXPECT_FALSE(
4494 front_facing_child_of_front_facing_surface->has_render_surface()); 4496 front_facing_child_of_front_facing_surface->has_render_surface());
4495 EXPECT_FALSE(back_facing_child_of_front_facing_surface->has_render_surface()); 4497 EXPECT_FALSE(back_facing_child_of_front_facing_surface->has_render_surface());
4496 EXPECT_FALSE(front_facing_child_of_back_facing_surface->has_render_surface()); 4498 EXPECT_FALSE(front_facing_child_of_back_facing_surface->has_render_surface());
4497 EXPECT_FALSE(back_facing_child_of_back_facing_surface->has_render_surface()); 4499 EXPECT_FALSE(back_facing_child_of_back_facing_surface->has_render_surface());
4498 4500
4499 EXPECT_EQ(3u, update_layer_list_impl()->size()); 4501 EXPECT_EQ(4u, update_layer_list_impl()->size());
4500 4502
4501 EXPECT_TRUE(UpdateLayerListImplContains(front_facing_child->id())); 4503 EXPECT_TRUE(UpdateLayerListImplContains(front_facing_child->id()));
4502 EXPECT_TRUE(UpdateLayerListImplContains(front_facing_surface->id())); 4504 EXPECT_TRUE(UpdateLayerListImplContains(front_facing_surface->id()));
4503 EXPECT_TRUE(UpdateLayerListImplContains( 4505 EXPECT_TRUE(UpdateLayerListImplContains(
4504 front_facing_child_of_front_facing_surface->id())); 4506 front_facing_child_of_front_facing_surface->id()));
4505 } 4507 }
4506 4508
4507 TEST_F(LayerTreeHostCommonTest, BackFaceCullingWithAnimatingTransforms) { 4509 TEST_F(LayerTreeHostCommonTest, BackFaceCullingWithAnimatingTransforms) {
4508 // Verify that layers are appropriately culled when their back face is showing 4510 // Verify that layers are appropriately culled when their back face is showing
4509 // and they are not double sided, while animations are going on. 4511 // and they are not double sided, while animations are going on.
(...skipping 1332 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_tree_impl()->SetRootLayer(std::move(root));
ajuma 2016/03/24 15:11:59 This changes (renaming root_ptr and so on) seem co
sunxd 2016/03/29 14:26:34 Ah, yes, it is a result of rebasing. Because in ot
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_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 873 matching lines...) Expand 10 before | Expand all | Expand 10 after
7344 AnimationScaleFactorTrackingLayerImpl::Create(host_impl.active_tree(), 4); 7346 AnimationScaleFactorTrackingLayerImpl::Create(host_impl.active_tree(), 4);
7345 7347
7346 AnimationScaleFactorTrackingLayerImpl* parent_raw = parent.get(); 7348 AnimationScaleFactorTrackingLayerImpl* parent_raw = parent.get();
7347 AnimationScaleFactorTrackingLayerImpl* child_raw = child.get(); 7349 AnimationScaleFactorTrackingLayerImpl* child_raw = child.get();
7348 AnimationScaleFactorTrackingLayerImpl* grand_child_raw = grand_child.get(); 7350 AnimationScaleFactorTrackingLayerImpl* grand_child_raw = grand_child.get();
7349 AnimationScaleFactorTrackingLayerImpl* grand_parent_raw = grand_parent.get(); 7351 AnimationScaleFactorTrackingLayerImpl* grand_parent_raw = grand_parent.get();
7350 7352
7351 child->AddChild(std::move(grand_child)); 7353 child->AddChild(std::move(grand_child));
7352 parent->AddChild(std::move(child)); 7354 parent->AddChild(std::move(child));
7353 grand_parent->AddChild(std::move(parent)); 7355 grand_parent->AddChild(std::move(parent));
7354 host_impl.active_tree()->SetRootLayer(std::move(grand_parent));
7355 7356
7356 SetLayerPropertiesForTesting(grand_parent_raw, identity_matrix, 7357 SetLayerPropertiesForTesting(grand_parent_raw, identity_matrix,
7357 gfx::Point3F(), gfx::PointF(), gfx::Size(1, 2), 7358 gfx::Point3F(), gfx::PointF(), gfx::Size(1, 2),
7358 true, false, true); 7359 true, false, true);
7359 SetLayerPropertiesForTesting(parent_raw, identity_matrix, gfx::Point3F(), 7360 SetLayerPropertiesForTesting(parent_raw, identity_matrix, gfx::Point3F(),
7360 gfx::PointF(), gfx::Size(1, 2), true, false, 7361 gfx::PointF(), gfx::Size(1, 2), true, false,
7361 false); 7362 false);
7362 SetLayerPropertiesForTesting(child_raw, identity_matrix, gfx::Point3F(), 7363 SetLayerPropertiesForTesting(child_raw, identity_matrix, gfx::Point3F(),
7363 gfx::PointF(), gfx::Size(1, 2), true, false, 7364 gfx::PointF(), gfx::Size(1, 2), true, false,
7364 false); 7365 false);
7365 7366
7366 SetLayerPropertiesForTesting(grand_child_raw, identity_matrix, gfx::Point3F(), 7367 SetLayerPropertiesForTesting(grand_child_raw, identity_matrix, gfx::Point3F(),
7367 gfx::PointF(), gfx::Size(1, 2), true, false, 7368 gfx::PointF(), gfx::Size(1, 2), true, false,
7368 false); 7369 false);
7369 7370
7371 host_impl.active_tree()->SetRootLayer(std::move(grand_parent));
7372
7370 ExecuteCalculateDrawProperties(grand_parent_raw); 7373 ExecuteCalculateDrawProperties(grand_parent_raw);
7371 7374
7372 // No layers have animations. 7375 // No layers have animations.
7373 EXPECT_EQ( 7376 EXPECT_EQ(
7374 0.f, 7377 0.f,
7375 grand_parent_raw->draw_properties().maximum_animation_contents_scale); 7378 grand_parent_raw->draw_properties().maximum_animation_contents_scale);
7376 EXPECT_EQ(0.f, 7379 EXPECT_EQ(0.f,
7377 parent_raw->draw_properties().maximum_animation_contents_scale); 7380 parent_raw->draw_properties().maximum_animation_contents_scale);
7378 EXPECT_EQ(0.f, child_raw->draw_properties().maximum_animation_contents_scale); 7381 EXPECT_EQ(0.f, child_raw->draw_properties().maximum_animation_contents_scale);
7379 EXPECT_EQ( 7382 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)), 8881 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)),
8879 animation_id, 1, TargetProperty::OPACITY); 8882 animation_id, 1, TargetProperty::OPACITY);
8880 animation->set_fill_mode(Animation::FILL_MODE_NONE); 8883 animation->set_fill_mode(Animation::FILL_MODE_NONE);
8881 animation->set_time_offset(base::TimeDelta::FromMilliseconds(-1000)); 8884 animation->set_time_offset(base::TimeDelta::FromMilliseconds(-1000));
8882 AddAnimationToLayerWithExistingPlayer(child->id(), timeline(), 8885 AddAnimationToLayerWithExistingPlayer(child->id(), timeline(),
8883 std::move(animation)); 8886 std::move(animation));
8884 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); 8887 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get());
8885 EXPECT_EQ(gfx::Rect(10, 10), grandchild->visible_layer_rect()); 8888 EXPECT_EQ(gfx::Rect(10, 10), grandchild->visible_layer_rect());
8886 } 8889 }
8887 8890
8888 TEST_F(LayerTreeHostCommonTest, SkippingSubtreeImpl) { 8891 TEST_F(LayerTreeHostCommonTest, SkippingLayerImpl) {
8889 FakeImplTaskRunnerProvider task_runner_provider; 8892 FakeImplTaskRunnerProvider task_runner_provider;
8890 TestSharedBitmapManager shared_bitmap_manager; 8893 TestSharedBitmapManager shared_bitmap_manager;
8891 TestTaskGraphRunner task_graph_runner; 8894 TestTaskGraphRunner task_graph_runner;
8892 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &shared_bitmap_manager, 8895 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &shared_bitmap_manager,
8893 &task_graph_runner); 8896 &task_graph_runner);
8894 8897
8895 gfx::Transform identity; 8898 gfx::Transform identity;
8896 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl.active_tree(), 1); 8899 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl.active_tree(), 1);
8897 scoped_ptr<LayerImpl> child = LayerImpl::Create(host_impl.active_tree(), 2); 8900 scoped_ptr<LayerImpl> child = LayerImpl::Create(host_impl.active_tree(), 2);
8898 scoped_ptr<LayerImpl> grandchild = 8901 scoped_ptr<LayerImpl> grandchild =
(...skipping 28 matching lines...) Expand all
8927 ExecuteCalculateDrawPropertiesWithPropertyTrees(root_ptr); 8930 ExecuteCalculateDrawPropertiesWithPropertyTrees(root_ptr);
8928 EXPECT_EQ(gfx::Rect(10, 10), grandchild_ptr->visible_layer_rect()); 8931 EXPECT_EQ(gfx::Rect(10, 10), grandchild_ptr->visible_layer_rect());
8929 8932
8930 // Now we will reset the visible rect from property trees for the grandchild, 8933 // 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 8934 // 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, 8935 // to be skipped. The visible content rect for |grandchild| should, therefore,
8933 // remain empty. 8936 // remain empty.
8934 grandchild_ptr->set_visible_layer_rect(gfx::Rect()); 8937 grandchild_ptr->set_visible_layer_rect(gfx::Rect());
8935 gfx::Transform singular; 8938 gfx::Transform singular;
8936 singular.matrix().set(0, 0, 0); 8939 singular.matrix().set(0, 0, 0);
8940 singular.matrix().set(0, 1, 1);
ajuma 2016/03/24 15:11:59 Is this needed? It looks like the matrix is non-in
sunxd 2016/03/29 14:26:34 The problem here is that a transform matrix 0 0 0
8937 8941
8938 child_ptr->SetTransform(singular); 8942 child_ptr->SetTransform(singular);
8943 host_impl.active_tree()->property_trees()->needs_rebuild = true;
8939 ExecuteCalculateDrawPropertiesWithPropertyTrees(root_ptr); 8944 ExecuteCalculateDrawPropertiesWithPropertyTrees(root_ptr);
8940 EXPECT_EQ(gfx::Rect(0, 0), grandchild_ptr->visible_layer_rect()); 8945 EXPECT_EQ(gfx::Rect(0, 0), grandchild_ptr->visible_layer_rect());
8941 child_ptr->SetTransform(identity); 8946 child_ptr->SetTransform(identity);
8942 8947
8943 child_ptr->SetHideLayerAndSubtree(true); 8948 child_ptr->SetHideLayerAndSubtree(true);
8944 ExecuteCalculateDrawPropertiesWithPropertyTrees(root_ptr); 8949 ExecuteCalculateDrawPropertiesWithPropertyTrees(root_ptr);
8945 EXPECT_EQ(gfx::Rect(0, 0), grandchild_ptr->visible_layer_rect()); 8950 EXPECT_EQ(gfx::Rect(0, 0), grandchild_ptr->visible_layer_rect());
8946 child_ptr->SetHideLayerAndSubtree(false); 8951 child_ptr->SetHideLayerAndSubtree(false);
8947 8952
8948 child_ptr->SetOpacity(0.f); 8953 child_ptr->SetOpacity(0.f);
8949 ExecuteCalculateDrawPropertiesWithPropertyTrees(root_ptr); 8954 ExecuteCalculateDrawPropertiesWithPropertyTrees(root_ptr);
8950 EXPECT_EQ(gfx::Rect(0, 0), grandchild_ptr->visible_layer_rect()); 8955 EXPECT_EQ(gfx::Rect(0, 0), grandchild_ptr->visible_layer_rect());
8956 child_ptr->SetOpacity(1.f);
8951 8957
8958 root_ptr->SetTransform(singular);
sunxd 2016/03/30 15:21:34 Add comment
8959 child_ptr->SetScrollClipLayer(root_ptr->id());
ajuma 2016/03/24 15:11:59 This test doesn't seem to involve scrolling at all
sunxd 2016/03/29 14:26:34 This is for creating a transform_node for child, o
8960 host_impl.active_tree()->property_trees()->needs_rebuild = true;
8961 ExecuteCalculateDrawPropertiesWithPropertyTrees(root_ptr);
8962 EXPECT_EQ(gfx::Rect(0, 0), grandchild_ptr->visible_layer_rect());
8963 root_ptr->SetTransform(identity);
8964 child_ptr->SetScrollClipLayer(-1);
8965
8966 root_ptr->SetOpacity(0.f);
8967 child_ptr->SetOpacity(0.7f);
8968 host_impl.active_tree()->property_trees()->needs_rebuild = true;
8969 ExecuteCalculateDrawPropertiesWithPropertyTrees(root_ptr);
8970 EXPECT_EQ(gfx::Rect(0, 0), grandchild_ptr->visible_layer_rect());
8971 root_ptr->SetOpacity(1.f);
8972
8973 child_ptr->SetOpacity(0.f);
8952 // Now, even though child has zero opacity, we will configure |grandchild| and 8974 // Now, even though child has zero opacity, we will configure |grandchild| and
8953 // |greatgrandchild| in several ways that should force the subtree to be 8975 // |greatgrandchild| in several ways that should force the subtree to be
8954 // processed anyhow. 8976 // processed anyhow.
8955 std::vector<scoped_ptr<CopyOutputRequest>> requests; 8977 std::vector<scoped_ptr<CopyOutputRequest>> requests;
8956 requests.push_back(CopyOutputRequest::CreateEmptyRequest()); 8978 requests.push_back(CopyOutputRequest::CreateEmptyRequest());
8957 8979
8958 grandchild_ptr->PassCopyRequests(&requests); 8980 grandchild_ptr->PassCopyRequests(&requests);
8959 root_ptr->layer_tree_impl()->property_trees()->needs_rebuild = true; 8981 root_ptr->layer_tree_impl()->property_trees()->needs_rebuild = true;
8960 ExecuteCalculateDrawPropertiesWithPropertyTrees(root_ptr); 8982 ExecuteCalculateDrawPropertiesWithPropertyTrees(root_ptr);
8961 EXPECT_EQ(gfx::Rect(10, 10), grandchild_ptr->visible_layer_rect()); 8983 EXPECT_EQ(gfx::Rect(10, 10), grandchild_ptr->visible_layer_rect());
8984
8985 scoped_ptr<KeyframedTransformAnimationCurve> curve(
8986 KeyframedTransformAnimationCurve::Create());
8987 TransformOperations start;
8988 start.AppendTranslate(1.f, 2.f, 3.f);
8989 gfx::Transform transform;
8990 transform.Scale3d(1.0, 2.0, 3.0);
8991 TransformOperations operation;
8992 operation.AppendMatrix(transform);
8993 curve->AddKeyframe(
8994 TransformKeyframe::Create(base::TimeDelta(), start, nullptr));
8995 curve->AddKeyframe(TransformKeyframe::Create(
8996 base::TimeDelta::FromSecondsD(1.0), operation, nullptr));
8997 scoped_ptr<Animation> transform_animation(
8998 Animation::Create(std::move(curve), 3, 3, TargetProperty::TRANSFORM));
8999 scoped_refptr<AnimationPlayer> player(AnimationPlayer::Create(1));
9000 host_impl.active_tree()->animation_host()->RegisterPlayerForLayer(
9001 root_ptr->id(), player.get());
9002 host_impl.active_tree()
9003 ->animation_host()
9004 ->GetControllerForLayerId(root_ptr->id())
9005 ->AddAnimation(std::move(transform_animation));
9006 grandchild_ptr->set_visible_layer_rect(gfx::Rect());
9007 child_ptr->SetScrollClipLayer(root_ptr->id());
9008 root_ptr->SetTransform(singular);
9009 child_ptr->SetTransform(singular);
9010 root_ptr->layer_tree_impl()->property_trees()->needs_rebuild = true;
9011 ExecuteCalculateDrawPropertiesWithPropertyTrees(root_ptr);
9012 EXPECT_EQ(gfx::Rect(10, 10), grandchild_ptr->visible_layer_rect());
9013
9014 host_impl.active_tree()->animation_host()->UnregisterPlayerForLayer(
9015 root_ptr->id(), player.get());
9016 }
9017
9018 TEST_F(LayerTreeHostCommonTest, SkippingPendingLayerImpl) {
9019 FakeImplTaskRunnerProvider task_runner_provider;
9020 TestSharedBitmapManager shared_bitmap_manager;
9021 TestTaskGraphRunner task_graph_runner;
9022 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &shared_bitmap_manager,
9023 &task_graph_runner);
9024
9025 gfx::Transform identity;
9026 host_impl.CreatePendingTree();
9027 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl.pending_tree(), 1);
9028 scoped_ptr<LayerImpl> child = LayerImpl::Create(host_impl.pending_tree(), 2);
9029 scoped_ptr<LayerImpl> grandchild =
9030 LayerImpl::Create(host_impl.pending_tree(), 3);
9031
9032 scoped_ptr<FakePictureLayerImpl> greatgrandchild(
9033 FakePictureLayerImpl::Create(host_impl.pending_tree(), 4));
9034
9035 child->SetDrawsContent(true);
9036 grandchild->SetDrawsContent(true);
9037 greatgrandchild->SetDrawsContent(true);
9038
9039 SetLayerPropertiesForTesting(root.get(), identity, gfx::Point3F(),
9040 gfx::PointF(), gfx::Size(100, 100), true, false,
9041 true);
9042 SetLayerPropertiesForTesting(child.get(), identity, gfx::Point3F(),
9043 gfx::PointF(), gfx::Size(10, 10), true, false,
9044 false);
9045 SetLayerPropertiesForTesting(grandchild.get(), identity, gfx::Point3F(),
9046 gfx::PointF(), gfx::Size(10, 10), true, false,
9047 false);
9048
9049 LayerImpl* root_ptr = root.get();
9050 LayerImpl* grandchild_ptr = grandchild.get();
9051
9052 child->AddChild(std::move(grandchild));
9053 root->AddChild(std::move(child));
9054
9055 host_impl.pending_tree()->SetRootLayer(std::move(root));
9056
9057 // Check the non-skipped case.
9058 ExecuteCalculateDrawPropertiesWithPropertyTrees(root_ptr);
9059 EXPECT_EQ(gfx::Rect(10, 10), grandchild_ptr->visible_layer_rect());
9060
9061 scoped_ptr<KeyframedFloatAnimationCurve> curve(
9062 KeyframedFloatAnimationCurve::Create());
9063 scoped_ptr<TimingFunction> func = EaseTimingFunction::Create();
9064 curve->AddKeyframe(
9065 FloatKeyframe::Create(base::TimeDelta(), 0.9f, std::move(func)));
9066 curve->AddKeyframe(
9067 FloatKeyframe::Create(base::TimeDelta::FromSecondsD(1.0), 0.3f, nullptr));
9068 scoped_ptr<Animation> animation(
9069 Animation::Create(std::move(curve), 3, 3, TargetProperty::OPACITY));
9070 scoped_refptr<AnimationPlayer> player(AnimationPlayer::Create(1));
9071 host_impl.active_tree()->animation_host()->RegisterPlayerForLayer(
9072 root_ptr->id(), player.get());
9073 host_impl.active_tree()
9074 ->animation_host()
9075 ->GetControllerForLayerId(root_ptr->id())
9076 ->AddAnimation(std::move(animation));
9077 grandchild_ptr->set_visible_layer_rect(gfx::Rect());
9078 root_ptr->layer_tree_impl()->property_trees()->needs_rebuild = true;
9079 ExecuteCalculateDrawPropertiesWithPropertyTrees(root_ptr);
9080 EXPECT_EQ(gfx::Rect(10, 10), grandchild_ptr->visible_layer_rect());
9081
9082 host_impl.active_tree()->animation_host()->UnregisterPlayerForLayer(
9083 root_ptr->id(), player.get());
8962 } 9084 }
8963 9085
8964 TEST_F(LayerTreeHostCommonTest, SkippingLayer) { 9086 TEST_F(LayerTreeHostCommonTest, SkippingLayer) {
8965 gfx::Transform identity; 9087 gfx::Transform identity;
8966 scoped_refptr<Layer> root = Layer::Create(); 9088 scoped_refptr<Layer> root = Layer::Create();
8967 FakeContentLayerClient client; 9089 FakeContentLayerClient client;
8968 client.set_bounds(root->bounds()); 9090 client.set_bounds(root->bounds());
8969 scoped_refptr<LayerWithForcedDrawsContent> child = 9091 scoped_refptr<LayerWithForcedDrawsContent> child =
8970 make_scoped_refptr(new LayerWithForcedDrawsContent()); 9092 make_scoped_refptr(new LayerWithForcedDrawsContent());
8971 SetLayerPropertiesForTesting(root.get(), identity, gfx::Point3F(), 9093 SetLayerPropertiesForTesting(root.get(), identity, gfx::Point3F(),
(...skipping 1027 matching lines...) Expand 10 before | Expand all | Expand 10 after
9999 EXPECT_EQ(scroll_child6.id, grand_child10->scroll_tree_index()); 10121 EXPECT_EQ(scroll_child6.id, grand_child10->scroll_tree_index());
10000 EXPECT_EQ(scroll_root1.id, parent3->scroll_tree_index()); 10122 EXPECT_EQ(scroll_root1.id, parent3->scroll_tree_index());
10001 EXPECT_EQ(scroll_child7.id, child8->scroll_tree_index()); 10123 EXPECT_EQ(scroll_child7.id, child8->scroll_tree_index());
10002 EXPECT_EQ(scroll_root1.id, parent4->scroll_tree_index()); 10124 EXPECT_EQ(scroll_root1.id, parent4->scroll_tree_index());
10003 EXPECT_EQ(scroll_root1.id, child9->scroll_tree_index()); 10125 EXPECT_EQ(scroll_root1.id, child9->scroll_tree_index());
10004 EXPECT_EQ(scroll_root1.id, grand_child12->scroll_tree_index()); 10126 EXPECT_EQ(scroll_root1.id, grand_child12->scroll_tree_index());
10005 } 10127 }
10006 10128
10007 } // namespace 10129 } // namespace
10008 } // namespace cc 10130 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698