| 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 <memory> | 10 #include <memory> |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 #include "testing/gtest/include/gtest/gtest.h" | 48 #include "testing/gtest/include/gtest/gtest.h" |
| 49 #include "ui/gfx/geometry/quad_f.h" | 49 #include "ui/gfx/geometry/quad_f.h" |
| 50 #include "ui/gfx/geometry/vector2d_conversions.h" | 50 #include "ui/gfx/geometry/vector2d_conversions.h" |
| 51 #include "ui/gfx/transform.h" | 51 #include "ui/gfx/transform.h" |
| 52 | 52 |
| 53 namespace cc { | 53 namespace cc { |
| 54 namespace { | 54 namespace { |
| 55 | 55 |
| 56 class LayerWithForcedDrawsContent : public Layer { | 56 class LayerWithForcedDrawsContent : public Layer { |
| 57 public: | 57 public: |
| 58 LayerWithForcedDrawsContent() {} | 58 LayerWithForcedDrawsContent() { SetElementId(NextElementId()); } |
| 59 | 59 |
| 60 bool DrawsContent() const override; | 60 bool DrawsContent() const override; |
| 61 | 61 |
| 62 private: | 62 private: |
| 63 ~LayerWithForcedDrawsContent() override {} | 63 ~LayerWithForcedDrawsContent() override {} |
| 64 }; | 64 }; |
| 65 | 65 |
| 66 bool LayerWithForcedDrawsContent::DrawsContent() const { return true; } | 66 bool LayerWithForcedDrawsContent::DrawsContent() const { return true; } |
| 67 | 67 |
| 68 class MockContentLayerClient : public ContentLayerClient { | 68 class MockContentLayerClient : public ContentLayerClient { |
| (...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 296 const float kDeviceScale = 1.666f; | 296 const float kDeviceScale = 1.666f; |
| 297 | 297 |
| 298 FakeImplTaskRunnerProvider task_runner_provider; | 298 FakeImplTaskRunnerProvider task_runner_provider; |
| 299 TestSharedBitmapManager shared_bitmap_manager; | 299 TestSharedBitmapManager shared_bitmap_manager; |
| 300 TestTaskGraphRunner task_graph_runner; | 300 TestTaskGraphRunner task_graph_runner; |
| 301 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &shared_bitmap_manager, | 301 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &shared_bitmap_manager, |
| 302 &task_graph_runner); | 302 &task_graph_runner); |
| 303 | 303 |
| 304 gfx::Transform identity_matrix; | 304 gfx::Transform identity_matrix; |
| 305 std::unique_ptr<LayerImpl> sublayer_scoped_ptr( | 305 std::unique_ptr<LayerImpl> sublayer_scoped_ptr( |
| 306 LayerImpl::Create(host_impl.active_tree(), 1)); | 306 CreateTestLayerImpl(host_impl.active_tree(), 1)); |
| 307 LayerImpl* sublayer = sublayer_scoped_ptr.get(); | 307 LayerImpl* sublayer = sublayer_scoped_ptr.get(); |
| 308 sublayer->SetDrawsContent(true); | 308 sublayer->SetDrawsContent(true); |
| 309 SetLayerPropertiesForTesting(sublayer, identity_matrix, gfx::Point3F(), | 309 SetLayerPropertiesForTesting(sublayer, identity_matrix, gfx::Point3F(), |
| 310 gfx::PointF(), gfx::Size(500, 500), true, false, | 310 gfx::PointF(), gfx::Size(500, 500), true, false, |
| 311 false); | 311 false); |
| 312 | 312 |
| 313 std::unique_ptr<LayerImpl> scroll_layer_scoped_ptr( | 313 std::unique_ptr<LayerImpl> scroll_layer_scoped_ptr( |
| 314 LayerImpl::Create(host_impl.active_tree(), 2)); | 314 CreateTestLayerImpl(host_impl.active_tree(), 2)); |
| 315 LayerImpl* scroll_layer = scroll_layer_scoped_ptr.get(); | 315 LayerImpl* scroll_layer = scroll_layer_scoped_ptr.get(); |
| 316 SetLayerPropertiesForTesting(scroll_layer, identity_matrix, gfx::Point3F(), | 316 SetLayerPropertiesForTesting(scroll_layer, identity_matrix, gfx::Point3F(), |
| 317 gfx::PointF(), gfx::Size(10, 20), true, false, | 317 gfx::PointF(), gfx::Size(10, 20), true, false, |
| 318 false); | 318 false); |
| 319 std::unique_ptr<LayerImpl> clip_layer_scoped_ptr( | 319 std::unique_ptr<LayerImpl> clip_layer_scoped_ptr( |
| 320 LayerImpl::Create(host_impl.active_tree(), 4)); | 320 CreateTestLayerImpl(host_impl.active_tree(), 4)); |
| 321 LayerImpl* clip_layer = clip_layer_scoped_ptr.get(); | 321 LayerImpl* clip_layer = clip_layer_scoped_ptr.get(); |
| 322 | 322 |
| 323 scroll_layer->SetScrollClipLayer(clip_layer->id()); | 323 scroll_layer->SetScrollClipLayer(clip_layer->id()); |
| 324 clip_layer->SetBounds( | 324 clip_layer->SetBounds( |
| 325 gfx::Size(scroll_layer->bounds().width() + kMaxScrollOffset.x(), | 325 gfx::Size(scroll_layer->bounds().width() + kMaxScrollOffset.x(), |
| 326 scroll_layer->bounds().height() + kMaxScrollOffset.y())); | 326 scroll_layer->bounds().height() + kMaxScrollOffset.y())); |
| 327 scroll_layer->SetScrollClipLayer(clip_layer->id()); | 327 scroll_layer->SetScrollClipLayer(clip_layer->id()); |
| 328 SetScrollOffsetDelta(scroll_layer, kScrollDelta); | 328 SetScrollOffsetDelta(scroll_layer, kScrollDelta); |
| 329 gfx::Transform impl_transform; | 329 gfx::Transform impl_transform; |
| 330 scroll_layer->AddChild(std::move(sublayer_scoped_ptr)); | 330 scroll_layer->AddChild(std::move(sublayer_scoped_ptr)); |
| 331 LayerImpl* scroll_layer_raw_ptr = scroll_layer_scoped_ptr.get(); | 331 LayerImpl* scroll_layer_raw_ptr = scroll_layer_scoped_ptr.get(); |
| 332 clip_layer->AddChild(std::move(scroll_layer_scoped_ptr)); | 332 clip_layer->AddChild(std::move(scroll_layer_scoped_ptr)); |
| 333 scroll_layer_raw_ptr->layer_tree_impl() | 333 scroll_layer_raw_ptr->layer_tree_impl() |
| 334 ->property_trees() | 334 ->property_trees() |
| 335 ->scroll_tree.UpdateScrollOffsetBaseForTesting(scroll_layer_raw_ptr->id(), | 335 ->scroll_tree.UpdateScrollOffsetBaseForTesting(scroll_layer_raw_ptr->id(), |
| 336 kScrollOffset); | 336 kScrollOffset); |
| 337 | 337 |
| 338 std::unique_ptr<LayerImpl> root( | 338 std::unique_ptr<LayerImpl> root( |
| 339 LayerImpl::Create(host_impl.active_tree(), 3)); | 339 CreateTestLayerImpl(host_impl.active_tree(), 3)); |
| 340 SetLayerPropertiesForTesting(root.get(), identity_matrix, gfx::Point3F(), | 340 SetLayerPropertiesForTesting(root.get(), identity_matrix, gfx::Point3F(), |
| 341 gfx::PointF(), gfx::Size(3, 4), true, false, | 341 gfx::PointF(), gfx::Size(3, 4), true, false, |
| 342 false); | 342 false); |
| 343 root->AddChild(std::move(clip_layer_scoped_ptr)); | 343 root->AddChild(std::move(clip_layer_scoped_ptr)); |
| 344 root->SetHasRenderSurface(true); | 344 root->SetHasRenderSurface(true); |
| 345 LayerImpl* root_layer = root.get(); | 345 LayerImpl* root_layer = root.get(); |
| 346 host_impl.active_tree()->SetRootLayer(std::move(root)); | 346 host_impl.active_tree()->SetRootLayer(std::move(root)); |
| 347 | 347 |
| 348 ExecuteCalculateDrawProperties(root_layer, kDeviceScale, page_scale, | 348 ExecuteCalculateDrawProperties(root_layer, kDeviceScale, page_scale, |
| 349 scroll_layer->parent()); | 349 scroll_layer->parent()); |
| (...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 620 grand_child->ScreenSpaceTransform()); | 620 grand_child->ScreenSpaceTransform()); |
| 621 } | 621 } |
| 622 | 622 |
| 623 TEST_F(LayerTreeHostCommonTest, TransformsForReplica) { | 623 TEST_F(LayerTreeHostCommonTest, TransformsForReplica) { |
| 624 LayerImpl* root = root_layer(); | 624 LayerImpl* root = root_layer(); |
| 625 LayerImpl* parent = AddChildToRoot<LayerImpl>(); | 625 LayerImpl* parent = AddChildToRoot<LayerImpl>(); |
| 626 LayerImpl* child = AddChild<LayerImpl>(parent); | 626 LayerImpl* child = AddChild<LayerImpl>(parent); |
| 627 LayerImpl* grand_child = AddChild<LayerImpl>(child); | 627 LayerImpl* grand_child = AddChild<LayerImpl>(child); |
| 628 grand_child->SetDrawsContent(true); | 628 grand_child->SetDrawsContent(true); |
| 629 std::unique_ptr<LayerImpl> child_replica = | 629 std::unique_ptr<LayerImpl> child_replica = |
| 630 LayerImpl::Create(host_impl()->active_tree(), 100); | 630 CreateTestLayerImpl(host_impl()->active_tree(), 100); |
| 631 | 631 |
| 632 // One-time setup of root layer | 632 // One-time setup of root layer |
| 633 gfx::Transform identity_matrix; | 633 gfx::Transform identity_matrix; |
| 634 SetLayerPropertiesForTesting(root, identity_matrix, gfx::Point3F(), | 634 SetLayerPropertiesForTesting(root, identity_matrix, gfx::Point3F(), |
| 635 gfx::PointF(), gfx::Size(1, 2), true, false, | 635 gfx::PointF(), gfx::Size(1, 2), true, false, |
| 636 true); | 636 true); |
| 637 | 637 |
| 638 // Child is set up so that a new render surface should be created. | 638 // Child is set up so that a new render surface should be created. |
| 639 child->SetOpacity(0.5f); | 639 child->SetOpacity(0.5f); |
| 640 | 640 |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 716 LayerImpl* child_of_rs2 = AddChild<LayerImpl>(render_surface2); | 716 LayerImpl* child_of_rs2 = AddChild<LayerImpl>(render_surface2); |
| 717 child_of_rs2->SetDrawsContent(true); | 717 child_of_rs2->SetDrawsContent(true); |
| 718 LayerImpl* grand_child_of_root = AddChild<LayerImpl>(child_of_root); | 718 LayerImpl* grand_child_of_root = AddChild<LayerImpl>(child_of_root); |
| 719 grand_child_of_root->SetDrawsContent(true); | 719 grand_child_of_root->SetDrawsContent(true); |
| 720 LayerImpl* grand_child_of_rs1 = AddChild<LayerImpl>(child_of_rs1); | 720 LayerImpl* grand_child_of_rs1 = AddChild<LayerImpl>(child_of_rs1); |
| 721 grand_child_of_rs1->SetDrawsContent(true); | 721 grand_child_of_rs1->SetDrawsContent(true); |
| 722 LayerImpl* grand_child_of_rs2 = AddChild<LayerImpl>(child_of_rs2); | 722 LayerImpl* grand_child_of_rs2 = AddChild<LayerImpl>(child_of_rs2); |
| 723 grand_child_of_rs2->SetDrawsContent(true); | 723 grand_child_of_rs2->SetDrawsContent(true); |
| 724 | 724 |
| 725 std::unique_ptr<LayerImpl> replica_of_rs1 = | 725 std::unique_ptr<LayerImpl> replica_of_rs1 = |
| 726 LayerImpl::Create(host_impl()->active_tree(), 101); | 726 CreateTestLayerImpl(host_impl()->active_tree(), 101); |
| 727 std::unique_ptr<LayerImpl> replica_of_rs2 = | 727 std::unique_ptr<LayerImpl> replica_of_rs2 = |
| 728 LayerImpl::Create(host_impl()->active_tree(), 102); | 728 CreateTestLayerImpl(host_impl()->active_tree(), 102); |
| 729 | 729 |
| 730 // In combination with descendant draws content, opacity != 1 forces the layer | 730 // In combination with descendant draws content, opacity != 1 forces the layer |
| 731 // to have a new render surface. | 731 // to have a new render surface. |
| 732 render_surface1->SetOpacity(0.5f); | 732 render_surface1->SetOpacity(0.5f); |
| 733 render_surface2->SetOpacity(0.33f); | 733 render_surface2->SetOpacity(0.33f); |
| 734 | 734 |
| 735 // One-time setup of root layer | 735 // One-time setup of root layer |
| 736 gfx::Transform identity_matrix; | 736 gfx::Transform identity_matrix; |
| 737 SetLayerPropertiesForTesting(root, identity_matrix, gfx::Point3F(), | 737 SetLayerPropertiesForTesting(root, identity_matrix, gfx::Point3F(), |
| 738 gfx::PointF(), gfx::Size(1, 2), true, false, | 738 gfx::PointF(), gfx::Size(1, 2), true, false, |
| (...skipping 1807 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2546 grand_child_of_root, layer_transform, gfx::Point3F(0.25f, 0.f, 0.f), | 2546 grand_child_of_root, layer_transform, gfx::Point3F(0.25f, 0.f, 0.f), |
| 2547 gfx::PointF(2.5f, 0.f), gfx::Size(10, 10), true, false, false); | 2547 gfx::PointF(2.5f, 0.f), gfx::Size(10, 10), true, false, false); |
| 2548 SetLayerPropertiesForTesting( | 2548 SetLayerPropertiesForTesting( |
| 2549 grand_child_of_rs1, layer_transform, gfx::Point3F(0.25f, 0.f, 0.f), | 2549 grand_child_of_rs1, layer_transform, gfx::Point3F(0.25f, 0.f, 0.f), |
| 2550 gfx::PointF(2.5f, 0.f), gfx::Size(10, 10), true, false, false); | 2550 gfx::PointF(2.5f, 0.f), gfx::Size(10, 10), true, false, false); |
| 2551 SetLayerPropertiesForTesting( | 2551 SetLayerPropertiesForTesting( |
| 2552 grand_child_of_rs2, layer_transform, gfx::Point3F(0.25f, 0.f, 0.f), | 2552 grand_child_of_rs2, layer_transform, gfx::Point3F(0.25f, 0.f, 0.f), |
| 2553 gfx::PointF(2.5f, 0.f), gfx::Size(10, 10), true, false, false); | 2553 gfx::PointF(2.5f, 0.f), gfx::Size(10, 10), true, false, false); |
| 2554 | 2554 |
| 2555 // Put an animated opacity on the render surface. | 2555 // Put an animated opacity on the render surface. |
| 2556 AddOpacityTransitionToLayerWithPlayer(render_surface1->id(), timeline_impl(), | 2556 AddOpacityTransitionToElementWithPlayer( |
| 2557 10.0, 1.f, 0.f, false); | 2557 render_surface1->element_id(), timeline_impl(), 10.0, 1.f, 0.f, false); |
| 2558 | 2558 |
| 2559 // Also put an animated opacity on a layer without descendants. | 2559 // Also put an animated opacity on a layer without descendants. |
| 2560 AddOpacityTransitionToLayerWithPlayer(grand_child_of_root->id(), | 2560 AddOpacityTransitionToElementWithPlayer(grand_child_of_root->element_id(), |
| 2561 timeline_impl(), 10.0, 1.f, 0.f, false); | 2561 timeline_impl(), 10.0, 1.f, 0.f, |
| 2562 false); |
| 2562 | 2563 |
| 2563 // Put a transform animation on the render surface. | 2564 // Put a transform animation on the render surface. |
| 2564 AddAnimatedTransformToLayerWithPlayer(render_surface2->id(), timeline_impl(), | 2565 AddAnimatedTransformToElementWithPlayer(render_surface2->element_id(), |
| 2565 10.0, 30, 0); | 2566 timeline_impl(), 10.0, 30, 0); |
| 2566 | 2567 |
| 2567 // Also put transform animations on grand_child_of_root, and | 2568 // Also put transform animations on grand_child_of_root, and |
| 2568 // grand_child_of_rs2 | 2569 // grand_child_of_rs2 |
| 2569 AddAnimatedTransformToLayerWithPlayer(grand_child_of_root->id(), | 2570 AddAnimatedTransformToElementWithPlayer(grand_child_of_root->element_id(), |
| 2570 timeline_impl(), 10.0, 30, 0); | 2571 timeline_impl(), 10.0, 30, 0); |
| 2571 AddAnimatedTransformToLayerWithPlayer(grand_child_of_rs2->id(), | 2572 AddAnimatedTransformToElementWithPlayer(grand_child_of_rs2->element_id(), |
| 2572 timeline_impl(), 10.0, 30, 0); | 2573 timeline_impl(), 10.0, 30, 0); |
| 2573 | 2574 |
| 2574 ExecuteCalculateDrawProperties(parent); | 2575 ExecuteCalculateDrawProperties(parent); |
| 2575 | 2576 |
| 2576 // Only layers that are associated with render surfaces should have an actual | 2577 // Only layers that are associated with render surfaces should have an actual |
| 2577 // RenderSurface() value. | 2578 // RenderSurface() value. |
| 2578 ASSERT_TRUE(parent->render_surface()); | 2579 ASSERT_TRUE(parent->render_surface()); |
| 2579 ASSERT_FALSE(child_of_root->render_surface()); | 2580 ASSERT_FALSE(child_of_root->render_surface()); |
| 2580 ASSERT_FALSE(grand_child_of_root->render_surface()); | 2581 ASSERT_FALSE(grand_child_of_root->render_surface()); |
| 2581 | 2582 |
| 2582 ASSERT_TRUE(render_surface1->render_surface()); | 2583 ASSERT_TRUE(render_surface1->render_surface()); |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2686 SetLayerPropertiesForTesting(great_grand_child, identity, gfx::Point3F(), | 2687 SetLayerPropertiesForTesting(great_grand_child, identity, gfx::Point3F(), |
| 2687 gfx::PointF(), gfx::Size(10, 10), true, false, | 2688 gfx::PointF(), gfx::Size(10, 10), true, false, |
| 2688 false); | 2689 false); |
| 2689 | 2690 |
| 2690 // Add a transform animation with a start delay to |grand_child|. | 2691 // Add a transform animation with a start delay to |grand_child|. |
| 2691 std::unique_ptr<Animation> animation = Animation::Create( | 2692 std::unique_ptr<Animation> animation = Animation::Create( |
| 2692 std::unique_ptr<AnimationCurve>(new FakeTransformTransition(1.0)), 0, 1, | 2693 std::unique_ptr<AnimationCurve>(new FakeTransformTransition(1.0)), 0, 1, |
| 2693 TargetProperty::TRANSFORM); | 2694 TargetProperty::TRANSFORM); |
| 2694 animation->set_fill_mode(Animation::FILL_MODE_NONE); | 2695 animation->set_fill_mode(Animation::FILL_MODE_NONE); |
| 2695 animation->set_time_offset(base::TimeDelta::FromMilliseconds(-1000)); | 2696 animation->set_time_offset(base::TimeDelta::FromMilliseconds(-1000)); |
| 2696 AddAnimationToLayerWithPlayer(grand_child->id(), timeline_impl(), | 2697 AddAnimationToElementWithPlayer(grand_child->element_id(), timeline_impl(), |
| 2697 std::move(animation)); | 2698 std::move(animation)); |
| 2698 ExecuteCalculateDrawProperties(parent); | 2699 ExecuteCalculateDrawProperties(parent); |
| 2699 | 2700 |
| 2700 EXPECT_FALSE(parent->screen_space_transform_is_animating()); | 2701 EXPECT_FALSE(parent->screen_space_transform_is_animating()); |
| 2701 EXPECT_FALSE(child->screen_space_transform_is_animating()); | 2702 EXPECT_FALSE(child->screen_space_transform_is_animating()); |
| 2702 | 2703 |
| 2703 EXPECT_FALSE(grand_child->TransformIsAnimating()); | 2704 EXPECT_FALSE(grand_child->TransformIsAnimating()); |
| 2704 EXPECT_TRUE(grand_child->HasPotentiallyRunningTransformAnimation()); | 2705 EXPECT_TRUE(grand_child->HasPotentiallyRunningTransformAnimation()); |
| 2705 EXPECT_TRUE(grand_child->screen_space_transform_is_animating()); | 2706 EXPECT_TRUE(grand_child->screen_space_transform_is_animating()); |
| 2706 EXPECT_TRUE(great_grand_child->screen_space_transform_is_animating()); | 2707 EXPECT_TRUE(great_grand_child->screen_space_transform_is_animating()); |
| 2707 } | 2708 } |
| (...skipping 842 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3550 | 3551 |
| 3551 TEST_F(LayerTreeHostCommonTest, | 3552 TEST_F(LayerTreeHostCommonTest, |
| 3552 OcclusionForLayerWithUninvertibleDrawTransform) { | 3553 OcclusionForLayerWithUninvertibleDrawTransform) { |
| 3553 FakeImplTaskRunnerProvider task_runner_provider; | 3554 FakeImplTaskRunnerProvider task_runner_provider; |
| 3554 TestSharedBitmapManager shared_bitmap_manager; | 3555 TestSharedBitmapManager shared_bitmap_manager; |
| 3555 TestTaskGraphRunner task_graph_runner; | 3556 TestTaskGraphRunner task_graph_runner; |
| 3556 std::unique_ptr<OutputSurface> output_surface = FakeOutputSurface::Create3d(); | 3557 std::unique_ptr<OutputSurface> output_surface = FakeOutputSurface::Create3d(); |
| 3557 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &shared_bitmap_manager, | 3558 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &shared_bitmap_manager, |
| 3558 &task_graph_runner); | 3559 &task_graph_runner); |
| 3559 std::unique_ptr<LayerImpl> root = | 3560 std::unique_ptr<LayerImpl> root = |
| 3560 LayerImpl::Create(host_impl.active_tree(), 1); | 3561 CreateTestLayerImpl(host_impl.active_tree(), 1); |
| 3561 std::unique_ptr<LayerImpl> child = | 3562 std::unique_ptr<LayerImpl> child = |
| 3562 LayerImpl::Create(host_impl.active_tree(), 2); | 3563 CreateTestLayerImpl(host_impl.active_tree(), 2); |
| 3563 std::unique_ptr<LayerImpl> grand_child = | 3564 std::unique_ptr<LayerImpl> grand_child = |
| 3564 LayerImpl::Create(host_impl.active_tree(), 3); | 3565 CreateTestLayerImpl(host_impl.active_tree(), 3); |
| 3565 std::unique_ptr<LayerImpl> occluding_child = | 3566 std::unique_ptr<LayerImpl> occluding_child = |
| 3566 LayerImpl::Create(host_impl.active_tree(), 4); | 3567 CreateTestLayerImpl(host_impl.active_tree(), 4); |
| 3567 child->SetDrawsContent(true); | 3568 child->SetDrawsContent(true); |
| 3568 grand_child->SetDrawsContent(true); | 3569 grand_child->SetDrawsContent(true); |
| 3569 occluding_child->SetDrawsContent(true); | 3570 occluding_child->SetDrawsContent(true); |
| 3570 occluding_child->SetContentsOpaque(true); | 3571 occluding_child->SetContentsOpaque(true); |
| 3571 | 3572 |
| 3572 gfx::Transform identity_matrix; | 3573 gfx::Transform identity_matrix; |
| 3573 gfx::Transform perspective; | 3574 gfx::Transform perspective; |
| 3574 perspective.ApplyPerspectiveDepth(SkDoubleToMScalar(1e-12)); | 3575 perspective.ApplyPerspectiveDepth(SkDoubleToMScalar(1e-12)); |
| 3575 | 3576 |
| 3576 gfx::Transform rotation; | 3577 gfx::Transform rotation; |
| (...skipping 617 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4194 EXPECT_EQ(gfx::Rect(0, 0, 50, 50), child2->visible_layer_rect()); | 4195 EXPECT_EQ(gfx::Rect(0, 0, 50, 50), child2->visible_layer_rect()); |
| 4195 EXPECT_EQ(gfx::Rect(0, 0, 50, 50), child3->visible_layer_rect()); | 4196 EXPECT_EQ(gfx::Rect(0, 0, 50, 50), child3->visible_layer_rect()); |
| 4196 } | 4197 } |
| 4197 | 4198 |
| 4198 TEST_F(LayerTreeHostCommonTest, BackFaceCullingWithoutPreserves3d) { | 4199 TEST_F(LayerTreeHostCommonTest, BackFaceCullingWithoutPreserves3d) { |
| 4199 // Verify the behavior of back-face culling when there are no preserve-3d | 4200 // Verify the behavior of back-face culling when there are no preserve-3d |
| 4200 // layers. Note that 3d transforms still apply in this case, but they are | 4201 // layers. Note that 3d transforms still apply in this case, but they are |
| 4201 // "flattened" to each parent layer according to current W3C spec. | 4202 // "flattened" to each parent layer according to current W3C spec. |
| 4202 | 4203 |
| 4203 const gfx::Transform identity_matrix; | 4204 const gfx::Transform identity_matrix; |
| 4204 scoped_refptr<Layer> parent = Layer::Create(); | 4205 scoped_refptr<Layer> parent = CreateTestLayer(); |
| 4205 scoped_refptr<LayerWithForcedDrawsContent> front_facing_child = | 4206 scoped_refptr<LayerWithForcedDrawsContent> front_facing_child = |
| 4206 make_scoped_refptr(new LayerWithForcedDrawsContent()); | 4207 make_scoped_refptr(new LayerWithForcedDrawsContent()); |
| 4207 scoped_refptr<LayerWithForcedDrawsContent> back_facing_child = | 4208 scoped_refptr<LayerWithForcedDrawsContent> back_facing_child = |
| 4208 make_scoped_refptr(new LayerWithForcedDrawsContent()); | 4209 make_scoped_refptr(new LayerWithForcedDrawsContent()); |
| 4209 scoped_refptr<LayerWithForcedDrawsContent> front_facing_surface = | 4210 scoped_refptr<LayerWithForcedDrawsContent> front_facing_surface = |
| 4210 make_scoped_refptr(new LayerWithForcedDrawsContent()); | 4211 make_scoped_refptr(new LayerWithForcedDrawsContent()); |
| 4211 scoped_refptr<LayerWithForcedDrawsContent> back_facing_surface = | 4212 scoped_refptr<LayerWithForcedDrawsContent> back_facing_surface = |
| 4212 make_scoped_refptr(new LayerWithForcedDrawsContent()); | 4213 make_scoped_refptr(new LayerWithForcedDrawsContent()); |
| 4213 scoped_refptr<LayerWithForcedDrawsContent> | 4214 scoped_refptr<LayerWithForcedDrawsContent> |
| 4214 front_facing_child_of_front_facing_surface = | 4215 front_facing_child_of_front_facing_surface = |
| (...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4457 } | 4458 } |
| 4458 | 4459 |
| 4459 TEST_F(LayerTreeHostCommonTest, BackFaceCullingWithAnimatingTransforms) { | 4460 TEST_F(LayerTreeHostCommonTest, BackFaceCullingWithAnimatingTransforms) { |
| 4460 // Verify that layers are appropriately culled when their back face is showing | 4461 // Verify that layers are appropriately culled when their back face is showing |
| 4461 // and they are not double sided, while animations are going on. | 4462 // and they are not double sided, while animations are going on. |
| 4462 // | 4463 // |
| 4463 // Layers that are animating do not get culled on the main thread, as their | 4464 // Layers that are animating do not get culled on the main thread, as their |
| 4464 // transforms should be treated as "unknown" so we can not be sure that their | 4465 // transforms should be treated as "unknown" so we can not be sure that their |
| 4465 // back face is really showing. | 4466 // back face is really showing. |
| 4466 const gfx::Transform identity_matrix; | 4467 const gfx::Transform identity_matrix; |
| 4467 scoped_refptr<Layer> parent = Layer::Create(); | 4468 scoped_refptr<Layer> parent = CreateTestLayer(); |
| 4468 scoped_refptr<LayerWithForcedDrawsContent> child = | 4469 scoped_refptr<LayerWithForcedDrawsContent> child = |
| 4469 make_scoped_refptr(new LayerWithForcedDrawsContent()); | 4470 make_scoped_refptr(new LayerWithForcedDrawsContent()); |
| 4470 scoped_refptr<LayerWithForcedDrawsContent> animating_surface = | 4471 scoped_refptr<LayerWithForcedDrawsContent> animating_surface = |
| 4471 make_scoped_refptr(new LayerWithForcedDrawsContent()); | 4472 make_scoped_refptr(new LayerWithForcedDrawsContent()); |
| 4472 scoped_refptr<LayerWithForcedDrawsContent> child_of_animating_surface = | 4473 scoped_refptr<LayerWithForcedDrawsContent> child_of_animating_surface = |
| 4473 make_scoped_refptr(new LayerWithForcedDrawsContent()); | 4474 make_scoped_refptr(new LayerWithForcedDrawsContent()); |
| 4474 scoped_refptr<LayerWithForcedDrawsContent> animating_child = | 4475 scoped_refptr<LayerWithForcedDrawsContent> animating_child = |
| 4475 make_scoped_refptr(new LayerWithForcedDrawsContent()); | 4476 make_scoped_refptr(new LayerWithForcedDrawsContent()); |
| 4476 scoped_refptr<LayerWithForcedDrawsContent> child2 = | 4477 scoped_refptr<LayerWithForcedDrawsContent> child2 = |
| 4477 make_scoped_refptr(new LayerWithForcedDrawsContent()); | 4478 make_scoped_refptr(new LayerWithForcedDrawsContent()); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 4493 | 4494 |
| 4494 gfx::Transform backface_matrix; | 4495 gfx::Transform backface_matrix; |
| 4495 backface_matrix.Translate(50.0, 50.0); | 4496 backface_matrix.Translate(50.0, 50.0); |
| 4496 backface_matrix.RotateAboutYAxis(180.0); | 4497 backface_matrix.RotateAboutYAxis(180.0); |
| 4497 backface_matrix.Translate(-50.0, -50.0); | 4498 backface_matrix.Translate(-50.0, -50.0); |
| 4498 | 4499 |
| 4499 // Make our render surface. | 4500 // Make our render surface. |
| 4500 animating_surface->SetForceRenderSurfaceForTesting(true); | 4501 animating_surface->SetForceRenderSurfaceForTesting(true); |
| 4501 | 4502 |
| 4502 // Animate the transform on the render surface. | 4503 // Animate the transform on the render surface. |
| 4503 AddAnimatedTransformToLayerWithPlayer(animating_surface->id(), timeline(), | 4504 AddAnimatedTransformToElementWithPlayer(animating_surface->element_id(), |
| 4504 10.0, 30, 0); | 4505 timeline(), 10.0, 30, 0); |
| 4505 // This is just an animating layer, not a surface. | 4506 // This is just an animating layer, not a surface. |
| 4506 AddAnimatedTransformToLayerWithPlayer(animating_child->id(), timeline(), 10.0, | 4507 AddAnimatedTransformToElementWithPlayer(animating_child->element_id(), |
| 4507 30, 0); | 4508 timeline(), 10.0, 30, 0); |
| 4508 | 4509 |
| 4509 SetLayerPropertiesForTesting(parent.get(), | 4510 SetLayerPropertiesForTesting(parent.get(), |
| 4510 identity_matrix, | 4511 identity_matrix, |
| 4511 gfx::Point3F(), | 4512 gfx::Point3F(), |
| 4512 gfx::PointF(), | 4513 gfx::PointF(), |
| 4513 gfx::Size(100, 100), | 4514 gfx::Size(100, 100), |
| 4514 true, | 4515 true, |
| 4515 false); | 4516 false); |
| 4516 SetLayerPropertiesForTesting(child.get(), | 4517 SetLayerPropertiesForTesting(child.get(), |
| 4517 backface_matrix, | 4518 backface_matrix, |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4583 EXPECT_EQ(child_of_animating_surface->visible_layer_rect_for_testing(), | 4584 EXPECT_EQ(child_of_animating_surface->visible_layer_rect_for_testing(), |
| 4584 gfx::Rect(child_of_animating_surface->bounds())); | 4585 gfx::Rect(child_of_animating_surface->bounds())); |
| 4585 } | 4586 } |
| 4586 | 4587 |
| 4587 TEST_F(LayerTreeHostCommonTest, | 4588 TEST_F(LayerTreeHostCommonTest, |
| 4588 BackFaceCullingWithPreserves3dForFlatteningSurface) { | 4589 BackFaceCullingWithPreserves3dForFlatteningSurface) { |
| 4589 // Verify the behavior of back-face culling for a render surface that is | 4590 // Verify the behavior of back-face culling for a render surface that is |
| 4590 // created when it flattens its subtree, and its parent has preserves-3d. | 4591 // created when it flattens its subtree, and its parent has preserves-3d. |
| 4591 | 4592 |
| 4592 const gfx::Transform identity_matrix; | 4593 const gfx::Transform identity_matrix; |
| 4593 scoped_refptr<Layer> parent = Layer::Create(); | 4594 scoped_refptr<Layer> parent = CreateTestLayer(); |
| 4594 scoped_refptr<LayerWithForcedDrawsContent> front_facing_surface = | 4595 scoped_refptr<LayerWithForcedDrawsContent> front_facing_surface = |
| 4595 make_scoped_refptr(new LayerWithForcedDrawsContent()); | 4596 make_scoped_refptr(new LayerWithForcedDrawsContent()); |
| 4596 scoped_refptr<LayerWithForcedDrawsContent> back_facing_surface = | 4597 scoped_refptr<LayerWithForcedDrawsContent> back_facing_surface = |
| 4597 make_scoped_refptr(new LayerWithForcedDrawsContent()); | 4598 make_scoped_refptr(new LayerWithForcedDrawsContent()); |
| 4598 scoped_refptr<LayerWithForcedDrawsContent> child1 = | 4599 scoped_refptr<LayerWithForcedDrawsContent> child1 = |
| 4599 make_scoped_refptr(new LayerWithForcedDrawsContent()); | 4600 make_scoped_refptr(new LayerWithForcedDrawsContent()); |
| 4600 scoped_refptr<LayerWithForcedDrawsContent> child2 = | 4601 scoped_refptr<LayerWithForcedDrawsContent> child2 = |
| 4601 make_scoped_refptr(new LayerWithForcedDrawsContent()); | 4602 make_scoped_refptr(new LayerWithForcedDrawsContent()); |
| 4602 | 4603 |
| 4603 parent->AddChild(front_facing_surface); | 4604 parent->AddChild(front_facing_surface); |
| (...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4943 LayerImpl* child = AddChildToRoot<LayerImpl>(); | 4944 LayerImpl* child = AddChildToRoot<LayerImpl>(); |
| 4944 child->SetDrawsContent(true); | 4945 child->SetDrawsContent(true); |
| 4945 SetLayerPropertiesForTesting(child, identity_matrix, gfx::Point3F(), | 4946 SetLayerPropertiesForTesting(child, identity_matrix, gfx::Point3F(), |
| 4946 gfx::PointF(2.f, 2.f), gfx::Size(10, 10), false, | 4947 gfx::PointF(2.f, 2.f), gfx::Size(10, 10), false, |
| 4947 true, true); | 4948 true, true); |
| 4948 | 4949 |
| 4949 gfx::Transform replica_transform; | 4950 gfx::Transform replica_transform; |
| 4950 replica_transform.Scale(1.0, -1.0); | 4951 replica_transform.Scale(1.0, -1.0); |
| 4951 | 4952 |
| 4952 std::unique_ptr<LayerImpl> replica = | 4953 std::unique_ptr<LayerImpl> replica = |
| 4953 LayerImpl::Create(host_impl()->active_tree(), 7); | 4954 CreateTestLayerImpl(host_impl()->active_tree(), 7); |
| 4954 SetLayerPropertiesForTesting(replica.get(), replica_transform, gfx::Point3F(), | 4955 SetLayerPropertiesForTesting(replica.get(), replica_transform, gfx::Point3F(), |
| 4955 gfx::PointF(2.f, 2.f), gfx::Size(10, 10), false, | 4956 gfx::PointF(2.f, 2.f), gfx::Size(10, 10), false, |
| 4956 true, false); | 4957 true, false); |
| 4957 // We need to set parent on replica layer for property tree building. | 4958 // We need to set parent on replica layer for property tree building. |
| 4958 replica->SetParent(child); | 4959 replica->SetParent(child); |
| 4959 child->SetReplicaLayer(std::move(replica)); | 4960 child->SetReplicaLayer(std::move(replica)); |
| 4960 | 4961 |
| 4961 // This layer should end up in the same surface as child, with the same draw | 4962 // This layer should end up in the same surface as child, with the same draw |
| 4962 // and screen space transforms. | 4963 // and screen space transforms. |
| 4963 LayerImpl* duplicate_child_non_owner = AddChild<LayerImpl>(child); | 4964 LayerImpl* duplicate_child_non_owner = AddChild<LayerImpl>(child); |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5056 | 5057 |
| 5057 LayerImpl* child = AddChildToRoot<LayerImpl>(); | 5058 LayerImpl* child = AddChildToRoot<LayerImpl>(); |
| 5058 child->SetDrawsContent(true); | 5059 child->SetDrawsContent(true); |
| 5059 SetLayerPropertiesForTesting(child, identity_matrix, gfx::Point3F(), | 5060 SetLayerPropertiesForTesting(child, identity_matrix, gfx::Point3F(), |
| 5060 gfx::PointF(), gfx::Size(13, 11), false, true, | 5061 gfx::PointF(), gfx::Size(13, 11), false, true, |
| 5061 true); | 5062 true); |
| 5062 | 5063 |
| 5063 gfx::Transform replica_transform; | 5064 gfx::Transform replica_transform; |
| 5064 replica_transform.Scale(1.0, -1.0); | 5065 replica_transform.Scale(1.0, -1.0); |
| 5065 std::unique_ptr<LayerImpl> replica = | 5066 std::unique_ptr<LayerImpl> replica = |
| 5066 LayerImpl::Create(host_impl()->active_tree(), 7); | 5067 CreateTestLayerImpl(host_impl()->active_tree(), 7); |
| 5067 SetLayerPropertiesForTesting(replica.get(), replica_transform, gfx::Point3F(), | 5068 SetLayerPropertiesForTesting(replica.get(), replica_transform, gfx::Point3F(), |
| 5068 gfx::PointF(), gfx::Size(13, 11), false, true, | 5069 gfx::PointF(), gfx::Size(13, 11), false, true, |
| 5069 false); | 5070 false); |
| 5070 child->SetReplicaLayer(std::move(replica)); | 5071 child->SetReplicaLayer(std::move(replica)); |
| 5071 | 5072 |
| 5072 float device_scale_factor = 1.7f; | 5073 float device_scale_factor = 1.7f; |
| 5073 ExecuteCalculateDrawProperties(parent, device_scale_factor); | 5074 ExecuteCalculateDrawProperties(parent, device_scale_factor); |
| 5074 | 5075 |
| 5075 // We should have two render surfaces. The root's render surface and child's | 5076 // We should have two render surfaces. The root's render surface and child's |
| 5076 // render surface (it needs one because it has a replica layer). | 5077 // render surface (it needs one because it has a replica layer). |
| (...skipping 14 matching lines...) Expand all Loading... |
| 5091 child->render_surface()->replica_draw_transform()); | 5092 child->render_surface()->replica_draw_transform()); |
| 5092 | 5093 |
| 5093 gfx::Transform expected_replica_screen_space_transform; | 5094 gfx::Transform expected_replica_screen_space_transform; |
| 5094 expected_replica_screen_space_transform.matrix().set(1, 1, -1.0); | 5095 expected_replica_screen_space_transform.matrix().set(1, 1, -1.0); |
| 5095 EXPECT_TRANSFORMATION_MATRIX_EQ( | 5096 EXPECT_TRANSFORMATION_MATRIX_EQ( |
| 5096 expected_replica_screen_space_transform, | 5097 expected_replica_screen_space_transform, |
| 5097 child->render_surface()->replica_screen_space_transform()); | 5098 child->render_surface()->replica_screen_space_transform()); |
| 5098 } | 5099 } |
| 5099 | 5100 |
| 5100 TEST_F(LayerTreeHostCommonTest, LayerSearch) { | 5101 TEST_F(LayerTreeHostCommonTest, LayerSearch) { |
| 5101 scoped_refptr<Layer> root = Layer::Create(); | 5102 scoped_refptr<Layer> root = CreateTestLayer(); |
| 5102 scoped_refptr<Layer> child = Layer::Create(); | 5103 scoped_refptr<Layer> child = CreateTestLayer(); |
| 5103 scoped_refptr<Layer> grand_child = Layer::Create(); | 5104 scoped_refptr<Layer> grand_child = CreateTestLayer(); |
| 5104 scoped_refptr<Layer> mask_layer = Layer::Create(); | 5105 scoped_refptr<Layer> mask_layer = CreateTestLayer(); |
| 5105 scoped_refptr<Layer> replica_layer = Layer::Create(); | 5106 scoped_refptr<Layer> replica_layer = CreateTestLayer(); |
| 5106 | 5107 |
| 5107 grand_child->SetReplicaLayer(replica_layer.get()); | 5108 grand_child->SetReplicaLayer(replica_layer.get()); |
| 5108 child->AddChild(grand_child.get()); | 5109 child->AddChild(grand_child.get()); |
| 5109 child->SetMaskLayer(mask_layer.get()); | 5110 child->SetMaskLayer(mask_layer.get()); |
| 5110 root->AddChild(child.get()); | 5111 root->AddChild(child.get()); |
| 5111 | 5112 |
| 5112 host()->SetRootLayer(root); | 5113 host()->SetRootLayer(root); |
| 5113 | 5114 |
| 5114 int nonexistent_id = -1; | 5115 int nonexistent_id = -1; |
| 5115 EXPECT_EQ(root.get(), host()->LayerById(root->id())); | 5116 EXPECT_EQ(root.get(), host()->LayerById(root->id())); |
| 5116 EXPECT_EQ(child.get(), host()->LayerById(child->id())); | 5117 EXPECT_EQ(child.get(), host()->LayerById(child->id())); |
| 5117 EXPECT_EQ(grand_child.get(), host()->LayerById(grand_child->id())); | 5118 EXPECT_EQ(grand_child.get(), host()->LayerById(grand_child->id())); |
| 5118 EXPECT_EQ(mask_layer.get(), host()->LayerById(mask_layer->id())); | 5119 EXPECT_EQ(mask_layer.get(), host()->LayerById(mask_layer->id())); |
| 5119 EXPECT_EQ(replica_layer.get(), host()->LayerById(replica_layer->id())); | 5120 EXPECT_EQ(replica_layer.get(), host()->LayerById(replica_layer->id())); |
| 5120 EXPECT_FALSE(host()->LayerById(nonexistent_id)); | 5121 EXPECT_FALSE(host()->LayerById(nonexistent_id)); |
| 5121 } | 5122 } |
| 5122 | 5123 |
| 5123 TEST_F(LayerTreeHostCommonTest, TransparentChildRenderSurfaceCreation) { | 5124 TEST_F(LayerTreeHostCommonTest, TransparentChildRenderSurfaceCreation) { |
| 5124 scoped_refptr<Layer> root = Layer::Create(); | 5125 scoped_refptr<Layer> root = CreateTestLayer(); |
| 5125 scoped_refptr<Layer> child = Layer::Create(); | 5126 scoped_refptr<Layer> child = CreateTestLayer(); |
| 5126 scoped_refptr<LayerWithForcedDrawsContent> grand_child = | 5127 scoped_refptr<LayerWithForcedDrawsContent> grand_child = |
| 5127 make_scoped_refptr(new LayerWithForcedDrawsContent()); | 5128 make_scoped_refptr(new LayerWithForcedDrawsContent()); |
| 5128 | 5129 |
| 5129 const gfx::Transform identity_matrix; | 5130 const gfx::Transform identity_matrix; |
| 5130 SetLayerPropertiesForTesting(root.get(), | 5131 SetLayerPropertiesForTesting(root.get(), |
| 5131 identity_matrix, | 5132 identity_matrix, |
| 5132 gfx::Point3F(), | 5133 gfx::Point3F(), |
| 5133 gfx::PointF(), | 5134 gfx::PointF(), |
| 5134 gfx::Size(100, 100), | 5135 gfx::Size(100, 100), |
| 5135 true, | 5136 true, |
| (...skipping 25 matching lines...) Expand all Loading... |
| 5161 } | 5162 } |
| 5162 | 5163 |
| 5163 TEST_F(LayerTreeHostCommonTest, OpacityAnimatingOnPendingTree) { | 5164 TEST_F(LayerTreeHostCommonTest, OpacityAnimatingOnPendingTree) { |
| 5164 FakeImplTaskRunnerProvider task_runner_provider; | 5165 FakeImplTaskRunnerProvider task_runner_provider; |
| 5165 TestSharedBitmapManager shared_bitmap_manager; | 5166 TestSharedBitmapManager shared_bitmap_manager; |
| 5166 TestTaskGraphRunner task_graph_runner; | 5167 TestTaskGraphRunner task_graph_runner; |
| 5167 FakeLayerTreeHostImpl host_impl(host()->settings(), &task_runner_provider, | 5168 FakeLayerTreeHostImpl host_impl(host()->settings(), &task_runner_provider, |
| 5168 &shared_bitmap_manager, &task_graph_runner); | 5169 &shared_bitmap_manager, &task_graph_runner); |
| 5169 host_impl.CreatePendingTree(); | 5170 host_impl.CreatePendingTree(); |
| 5170 std::unique_ptr<LayerImpl> root = | 5171 std::unique_ptr<LayerImpl> root = |
| 5171 LayerImpl::Create(host_impl.pending_tree(), 1); | 5172 CreateTestLayerImpl(host_impl.pending_tree(), 1); |
| 5172 | 5173 |
| 5173 const gfx::Transform identity_matrix; | 5174 const gfx::Transform identity_matrix; |
| 5174 SetLayerPropertiesForTesting(root.get(), identity_matrix, gfx::Point3F(), | 5175 SetLayerPropertiesForTesting(root.get(), identity_matrix, gfx::Point3F(), |
| 5175 gfx::PointF(), gfx::Size(100, 100), true, false, | 5176 gfx::PointF(), gfx::Size(100, 100), true, false, |
| 5176 false); | 5177 false); |
| 5177 root->SetDrawsContent(true); | 5178 root->SetDrawsContent(true); |
| 5178 | 5179 |
| 5179 std::unique_ptr<LayerImpl> child = | 5180 std::unique_ptr<LayerImpl> child = |
| 5180 LayerImpl::Create(host_impl.pending_tree(), 2); | 5181 CreateTestLayerImpl(host_impl.pending_tree(), 2); |
| 5181 SetLayerPropertiesForTesting(child.get(), identity_matrix, gfx::Point3F(), | 5182 SetLayerPropertiesForTesting(child.get(), identity_matrix, gfx::Point3F(), |
| 5182 gfx::PointF(), gfx::Size(50, 50), true, false, | 5183 gfx::PointF(), gfx::Size(50, 50), true, false, |
| 5183 false); | 5184 false); |
| 5184 child->SetDrawsContent(true); | 5185 child->SetDrawsContent(true); |
| 5185 child->SetOpacity(0.0f); | 5186 child->SetOpacity(0.0f); |
| 5186 | 5187 |
| 5187 // Add opacity animation. | 5188 // Add opacity animation. |
| 5188 scoped_refptr<AnimationTimeline> timeline = | 5189 scoped_refptr<AnimationTimeline> timeline = |
| 5189 AnimationTimeline::Create(AnimationIdProvider::NextTimelineId()); | 5190 AnimationTimeline::Create(AnimationIdProvider::NextTimelineId()); |
| 5190 host_impl.animation_host()->AddAnimationTimeline(timeline); | 5191 host_impl.animation_host()->AddAnimationTimeline(timeline); |
| 5191 | 5192 |
| 5192 AddOpacityTransitionToLayerWithPlayer(child->id(), timeline, 10.0, 0.0f, 1.0f, | 5193 AddOpacityTransitionToElementWithPlayer(child->element_id(), timeline, 10.0, |
| 5193 false); | 5194 0.0f, 1.0f, false); |
| 5194 | 5195 |
| 5195 root->AddChild(std::move(child)); | 5196 root->AddChild(std::move(child)); |
| 5196 root->SetHasRenderSurface(true); | 5197 root->SetHasRenderSurface(true); |
| 5197 LayerImpl* root_layer = root.get(); | 5198 LayerImpl* root_layer = root.get(); |
| 5198 host_impl.pending_tree()->SetRootLayer(std::move(root)); | 5199 host_impl.pending_tree()->SetRootLayer(std::move(root)); |
| 5199 | 5200 |
| 5200 LayerImplList render_surface_layer_list; | 5201 LayerImplList render_surface_layer_list; |
| 5201 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( | 5202 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( |
| 5202 root_layer, root_layer->bounds(), &render_surface_layer_list); | 5203 root_layer, root_layer->bounds(), &render_surface_layer_list); |
| 5203 inputs.can_adjust_raster_scales = true; | 5204 inputs.can_adjust_raster_scales = true; |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5277 protected: | 5278 protected: |
| 5278 void SetUp() override { | 5279 void SetUp() override { |
| 5279 timeline_ = | 5280 timeline_ = |
| 5280 AnimationTimeline::Create(AnimationIdProvider::NextTimelineId()); | 5281 AnimationTimeline::Create(AnimationIdProvider::NextTimelineId()); |
| 5281 host_impl_.animation_host()->AddAnimationTimeline(timeline_); | 5282 host_impl_.animation_host()->AddAnimationTimeline(timeline_); |
| 5282 | 5283 |
| 5283 can_use_lcd_text_ = std::tr1::get<0>(GetParam()); | 5284 can_use_lcd_text_ = std::tr1::get<0>(GetParam()); |
| 5284 layers_always_allowed_lcd_text_ = std::tr1::get<1>(GetParam()); | 5285 layers_always_allowed_lcd_text_ = std::tr1::get<1>(GetParam()); |
| 5285 | 5286 |
| 5286 std::unique_ptr<LayerImpl> root_ptr = | 5287 std::unique_ptr<LayerImpl> root_ptr = |
| 5287 LayerImpl::Create(host_impl_.active_tree(), 1); | 5288 CreateTestLayerImpl(host_impl_.active_tree(), 1); |
| 5288 std::unique_ptr<LayerImpl> child_ptr = | 5289 std::unique_ptr<LayerImpl> child_ptr = |
| 5289 LayerImpl::Create(host_impl_.active_tree(), 2); | 5290 CreateTestLayerImpl(host_impl_.active_tree(), 2); |
| 5290 std::unique_ptr<LayerImpl> grand_child_ptr = | 5291 std::unique_ptr<LayerImpl> grand_child_ptr = |
| 5291 LayerImpl::Create(host_impl_.active_tree(), 3); | 5292 CreateTestLayerImpl(host_impl_.active_tree(), 3); |
| 5292 | 5293 |
| 5293 // Stash raw pointers to look at later. | 5294 // Stash raw pointers to look at later. |
| 5294 root_ = root_ptr.get(); | 5295 root_ = root_ptr.get(); |
| 5295 child_ = child_ptr.get(); | 5296 child_ = child_ptr.get(); |
| 5296 grand_child_ = grand_child_ptr.get(); | 5297 grand_child_ = grand_child_ptr.get(); |
| 5297 | 5298 |
| 5298 child_->AddChild(std::move(grand_child_ptr)); | 5299 child_->AddChild(std::move(grand_child_ptr)); |
| 5299 root_->AddChild(std::move(child_ptr)); | 5300 root_->AddChild(std::move(child_ptr)); |
| 5300 host_impl_.active_tree()->SetRootLayer(std::move(root_ptr)); | 5301 host_impl_.active_tree()->SetRootLayer(std::move(root_ptr)); |
| 5301 | 5302 |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5444 // Sanity check: Make sure can_use_lcd_text_ is set on each node. | 5445 // Sanity check: Make sure can_use_lcd_text_ is set on each node. |
| 5445 ExecuteCalculateDrawProperties(root_, 1.f, 1.f, NULL, can_use_lcd_text_, | 5446 ExecuteCalculateDrawProperties(root_, 1.f, 1.f, NULL, can_use_lcd_text_, |
| 5446 layers_always_allowed_lcd_text_); | 5447 layers_always_allowed_lcd_text_); |
| 5447 EXPECT_EQ(expect_lcd_text, root_->can_use_lcd_text()); | 5448 EXPECT_EQ(expect_lcd_text, root_->can_use_lcd_text()); |
| 5448 EXPECT_EQ(expect_lcd_text, child_->can_use_lcd_text()); | 5449 EXPECT_EQ(expect_lcd_text, child_->can_use_lcd_text()); |
| 5449 EXPECT_EQ(expect_lcd_text, grand_child_->can_use_lcd_text()); | 5450 EXPECT_EQ(expect_lcd_text, grand_child_->can_use_lcd_text()); |
| 5450 | 5451 |
| 5451 // Add opacity animation. | 5452 // Add opacity animation. |
| 5452 child_->SetOpacity(0.9f); | 5453 child_->SetOpacity(0.9f); |
| 5453 child_->layer_tree_impl()->property_trees()->needs_rebuild = true; | 5454 child_->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| 5454 AddOpacityTransitionToLayerWithPlayer(child_->id(), timeline(), 10.0, 0.9f, | 5455 AddOpacityTransitionToElementWithPlayer(child_->element_id(), timeline(), |
| 5455 0.1f, false); | 5456 10.0, 0.9f, 0.1f, false); |
| 5456 ExecuteCalculateDrawProperties(root_, 1.f, 1.f, NULL, can_use_lcd_text_, | 5457 ExecuteCalculateDrawProperties(root_, 1.f, 1.f, NULL, can_use_lcd_text_, |
| 5457 layers_always_allowed_lcd_text_); | 5458 layers_always_allowed_lcd_text_); |
| 5458 // Text LCD should be adjusted while animation is active. | 5459 // Text LCD should be adjusted while animation is active. |
| 5459 EXPECT_EQ(expect_lcd_text, root_->can_use_lcd_text()); | 5460 EXPECT_EQ(expect_lcd_text, root_->can_use_lcd_text()); |
| 5460 EXPECT_EQ(expect_not_lcd_text, child_->can_use_lcd_text()); | 5461 EXPECT_EQ(expect_not_lcd_text, child_->can_use_lcd_text()); |
| 5461 EXPECT_EQ(expect_not_lcd_text, grand_child_->can_use_lcd_text()); | 5462 EXPECT_EQ(expect_not_lcd_text, grand_child_->can_use_lcd_text()); |
| 5462 } | 5463 } |
| 5463 | 5464 |
| 5464 TEST_P(LCDTextTest, CanUseLCDTextWithAnimationContentsOpaque) { | 5465 TEST_P(LCDTextTest, CanUseLCDTextWithAnimationContentsOpaque) { |
| 5465 bool expect_lcd_text = can_use_lcd_text_ || layers_always_allowed_lcd_text_; | 5466 bool expect_lcd_text = can_use_lcd_text_ || layers_always_allowed_lcd_text_; |
| 5466 bool expect_not_lcd_text = layers_always_allowed_lcd_text_; | 5467 bool expect_not_lcd_text = layers_always_allowed_lcd_text_; |
| 5467 | 5468 |
| 5468 // Sanity check: Make sure can_use_lcd_text_ is set on each node. | 5469 // Sanity check: Make sure can_use_lcd_text_ is set on each node. |
| 5469 ExecuteCalculateDrawProperties(root_, 1.f, 1.f, NULL, can_use_lcd_text_, | 5470 ExecuteCalculateDrawProperties(root_, 1.f, 1.f, NULL, can_use_lcd_text_, |
| 5470 layers_always_allowed_lcd_text_); | 5471 layers_always_allowed_lcd_text_); |
| 5471 EXPECT_EQ(expect_lcd_text, root_->can_use_lcd_text()); | 5472 EXPECT_EQ(expect_lcd_text, root_->can_use_lcd_text()); |
| 5472 EXPECT_EQ(expect_lcd_text, child_->can_use_lcd_text()); | 5473 EXPECT_EQ(expect_lcd_text, child_->can_use_lcd_text()); |
| 5473 EXPECT_EQ(expect_lcd_text, grand_child_->can_use_lcd_text()); | 5474 EXPECT_EQ(expect_lcd_text, grand_child_->can_use_lcd_text()); |
| 5474 | 5475 |
| 5475 // Mark contents non-opaque within the first animation frame. | 5476 // Mark contents non-opaque within the first animation frame. |
| 5476 child_->SetContentsOpaque(false); | 5477 child_->SetContentsOpaque(false); |
| 5477 AddOpacityTransitionToLayerWithPlayer(child_->id(), timeline(), 10.0, 0.9f, | 5478 AddOpacityTransitionToElementWithPlayer(child_->element_id(), timeline(), |
| 5478 0.1f, false); | 5479 10.0, 0.9f, 0.1f, false); |
| 5479 ExecuteCalculateDrawProperties(root_, 1.f, 1.f, NULL, can_use_lcd_text_, | 5480 ExecuteCalculateDrawProperties(root_, 1.f, 1.f, NULL, can_use_lcd_text_, |
| 5480 layers_always_allowed_lcd_text_); | 5481 layers_always_allowed_lcd_text_); |
| 5481 // LCD text should be disabled for non-opaque layers even during animations. | 5482 // LCD text should be disabled for non-opaque layers even during animations. |
| 5482 EXPECT_EQ(expect_lcd_text, root_->can_use_lcd_text()); | 5483 EXPECT_EQ(expect_lcd_text, root_->can_use_lcd_text()); |
| 5483 EXPECT_EQ(expect_not_lcd_text, child_->can_use_lcd_text()); | 5484 EXPECT_EQ(expect_not_lcd_text, child_->can_use_lcd_text()); |
| 5484 EXPECT_EQ(expect_lcd_text, grand_child_->can_use_lcd_text()); | 5485 EXPECT_EQ(expect_lcd_text, grand_child_->can_use_lcd_text()); |
| 5485 } | 5486 } |
| 5486 | 5487 |
| 5487 INSTANTIATE_TEST_CASE_P(LayerTreeHostCommonTest, | 5488 INSTANTIATE_TEST_CASE_P(LayerTreeHostCommonTest, |
| 5488 LCDTextTest, | 5489 LCDTextTest, |
| 5489 testing::Combine(testing::Bool(), | 5490 testing::Combine(testing::Bool(), |
| 5490 testing::Bool(), | 5491 testing::Bool(), |
| 5491 testing::Bool())); | 5492 testing::Bool())); |
| 5492 | 5493 |
| 5493 TEST_F(LayerTreeHostCommonTest, SubtreeHidden_SingleLayerImpl) { | 5494 TEST_F(LayerTreeHostCommonTest, SubtreeHidden_SingleLayerImpl) { |
| 5494 FakeImplTaskRunnerProvider task_runner_provider; | 5495 FakeImplTaskRunnerProvider task_runner_provider; |
| 5495 TestSharedBitmapManager shared_bitmap_manager; | 5496 TestSharedBitmapManager shared_bitmap_manager; |
| 5496 TestTaskGraphRunner task_graph_runner; | 5497 TestTaskGraphRunner task_graph_runner; |
| 5497 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &shared_bitmap_manager, | 5498 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &shared_bitmap_manager, |
| 5498 &task_graph_runner); | 5499 &task_graph_runner); |
| 5499 host_impl.CreatePendingTree(); | 5500 host_impl.CreatePendingTree(); |
| 5500 const gfx::Transform identity_matrix; | 5501 const gfx::Transform identity_matrix; |
| 5501 | 5502 |
| 5502 std::unique_ptr<LayerImpl> root = | 5503 std::unique_ptr<LayerImpl> root = |
| 5503 LayerImpl::Create(host_impl.pending_tree(), 1); | 5504 CreateTestLayerImpl(host_impl.pending_tree(), 1); |
| 5504 LayerImpl* root_layer = root.get(); | 5505 LayerImpl* root_layer = root.get(); |
| 5505 SetLayerPropertiesForTesting(root.get(), identity_matrix, gfx::Point3F(), | 5506 SetLayerPropertiesForTesting(root.get(), identity_matrix, gfx::Point3F(), |
| 5506 gfx::PointF(), gfx::Size(50, 50), true, false, | 5507 gfx::PointF(), gfx::Size(50, 50), true, false, |
| 5507 false); | 5508 false); |
| 5508 root->SetDrawsContent(true); | 5509 root->SetDrawsContent(true); |
| 5509 | 5510 |
| 5510 std::unique_ptr<LayerImpl> child = | 5511 std::unique_ptr<LayerImpl> child = |
| 5511 LayerImpl::Create(host_impl.pending_tree(), 2); | 5512 CreateTestLayerImpl(host_impl.pending_tree(), 2); |
| 5512 SetLayerPropertiesForTesting(child.get(), identity_matrix, gfx::Point3F(), | 5513 SetLayerPropertiesForTesting(child.get(), identity_matrix, gfx::Point3F(), |
| 5513 gfx::PointF(), gfx::Size(40, 40), true, false, | 5514 gfx::PointF(), gfx::Size(40, 40), true, false, |
| 5514 false); | 5515 false); |
| 5515 child->SetDrawsContent(true); | 5516 child->SetDrawsContent(true); |
| 5516 | 5517 |
| 5517 std::unique_ptr<LayerImpl> grand_child = | 5518 std::unique_ptr<LayerImpl> grand_child = |
| 5518 LayerImpl::Create(host_impl.pending_tree(), 3); | 5519 CreateTestLayerImpl(host_impl.pending_tree(), 3); |
| 5519 SetLayerPropertiesForTesting(grand_child.get(), identity_matrix, | 5520 SetLayerPropertiesForTesting(grand_child.get(), identity_matrix, |
| 5520 gfx::Point3F(), gfx::PointF(), gfx::Size(30, 30), | 5521 gfx::Point3F(), gfx::PointF(), gfx::Size(30, 30), |
| 5521 true, false, false); | 5522 true, false, false); |
| 5522 grand_child->SetDrawsContent(true); | 5523 grand_child->SetDrawsContent(true); |
| 5523 grand_child->SetHideLayerAndSubtree(true); | 5524 grand_child->SetHideLayerAndSubtree(true); |
| 5524 | 5525 |
| 5525 child->AddChild(std::move(grand_child)); | 5526 child->AddChild(std::move(grand_child)); |
| 5526 root->AddChild(std::move(child)); | 5527 root->AddChild(std::move(child)); |
| 5527 root->SetHasRenderSurface(true); | 5528 root->SetHasRenderSurface(true); |
| 5528 host_impl.pending_tree()->SetRootLayer(std::move(root)); | 5529 host_impl.pending_tree()->SetRootLayer(std::move(root)); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 5544 TEST_F(LayerTreeHostCommonTest, SubtreeHidden_TwoLayersImpl) { | 5545 TEST_F(LayerTreeHostCommonTest, SubtreeHidden_TwoLayersImpl) { |
| 5545 FakeImplTaskRunnerProvider task_runner_provider; | 5546 FakeImplTaskRunnerProvider task_runner_provider; |
| 5546 TestSharedBitmapManager shared_bitmap_manager; | 5547 TestSharedBitmapManager shared_bitmap_manager; |
| 5547 TestTaskGraphRunner task_graph_runner; | 5548 TestTaskGraphRunner task_graph_runner; |
| 5548 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &shared_bitmap_manager, | 5549 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &shared_bitmap_manager, |
| 5549 &task_graph_runner); | 5550 &task_graph_runner); |
| 5550 host_impl.CreatePendingTree(); | 5551 host_impl.CreatePendingTree(); |
| 5551 const gfx::Transform identity_matrix; | 5552 const gfx::Transform identity_matrix; |
| 5552 | 5553 |
| 5553 std::unique_ptr<LayerImpl> root = | 5554 std::unique_ptr<LayerImpl> root = |
| 5554 LayerImpl::Create(host_impl.pending_tree(), 1); | 5555 CreateTestLayerImpl(host_impl.pending_tree(), 1); |
| 5555 SetLayerPropertiesForTesting(root.get(), identity_matrix, gfx::Point3F(), | 5556 SetLayerPropertiesForTesting(root.get(), identity_matrix, gfx::Point3F(), |
| 5556 gfx::PointF(), gfx::Size(50, 50), true, false, | 5557 gfx::PointF(), gfx::Size(50, 50), true, false, |
| 5557 true); | 5558 true); |
| 5558 root->SetDrawsContent(true); | 5559 root->SetDrawsContent(true); |
| 5559 LayerImpl* root_layer = root.get(); | 5560 LayerImpl* root_layer = root.get(); |
| 5560 | 5561 |
| 5561 std::unique_ptr<LayerImpl> child = | 5562 std::unique_ptr<LayerImpl> child = |
| 5562 LayerImpl::Create(host_impl.pending_tree(), 2); | 5563 CreateTestLayerImpl(host_impl.pending_tree(), 2); |
| 5563 SetLayerPropertiesForTesting(child.get(), identity_matrix, gfx::Point3F(), | 5564 SetLayerPropertiesForTesting(child.get(), identity_matrix, gfx::Point3F(), |
| 5564 gfx::PointF(), gfx::Size(40, 40), true, false, | 5565 gfx::PointF(), gfx::Size(40, 40), true, false, |
| 5565 false); | 5566 false); |
| 5566 child->SetDrawsContent(true); | 5567 child->SetDrawsContent(true); |
| 5567 child->SetHideLayerAndSubtree(true); | 5568 child->SetHideLayerAndSubtree(true); |
| 5568 | 5569 |
| 5569 std::unique_ptr<LayerImpl> grand_child = | 5570 std::unique_ptr<LayerImpl> grand_child = |
| 5570 LayerImpl::Create(host_impl.pending_tree(), 3); | 5571 CreateTestLayerImpl(host_impl.pending_tree(), 3); |
| 5571 SetLayerPropertiesForTesting(grand_child.get(), identity_matrix, | 5572 SetLayerPropertiesForTesting(grand_child.get(), identity_matrix, |
| 5572 gfx::Point3F(), gfx::PointF(), gfx::Size(30, 30), | 5573 gfx::Point3F(), gfx::PointF(), gfx::Size(30, 30), |
| 5573 true, false, false); | 5574 true, false, false); |
| 5574 grand_child->SetDrawsContent(true); | 5575 grand_child->SetDrawsContent(true); |
| 5575 | 5576 |
| 5576 child->AddChild(std::move(grand_child)); | 5577 child->AddChild(std::move(grand_child)); |
| 5577 root->AddChild(std::move(child)); | 5578 root->AddChild(std::move(child)); |
| 5578 host_impl.pending_tree()->SetRootLayer(std::move(root)); | 5579 host_impl.pending_tree()->SetRootLayer(std::move(root)); |
| 5579 | 5580 |
| 5580 LayerImplList render_surface_layer_list; | 5581 LayerImplList render_surface_layer_list; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 5595 TEST_F(LayerTreeHostCommonTest, SubtreeHiddenWithCopyRequest) { | 5596 TEST_F(LayerTreeHostCommonTest, SubtreeHiddenWithCopyRequest) { |
| 5596 FakeImplTaskRunnerProvider task_runner_provider; | 5597 FakeImplTaskRunnerProvider task_runner_provider; |
| 5597 TestSharedBitmapManager shared_bitmap_manager; | 5598 TestSharedBitmapManager shared_bitmap_manager; |
| 5598 TestTaskGraphRunner task_graph_runner; | 5599 TestTaskGraphRunner task_graph_runner; |
| 5599 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &shared_bitmap_manager, | 5600 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &shared_bitmap_manager, |
| 5600 &task_graph_runner); | 5601 &task_graph_runner); |
| 5601 host_impl.CreatePendingTree(); | 5602 host_impl.CreatePendingTree(); |
| 5602 const gfx::Transform identity_matrix; | 5603 const gfx::Transform identity_matrix; |
| 5603 | 5604 |
| 5604 std::unique_ptr<LayerImpl> root = | 5605 std::unique_ptr<LayerImpl> root = |
| 5605 LayerImpl::Create(host_impl.pending_tree(), 1); | 5606 CreateTestLayerImpl(host_impl.pending_tree(), 1); |
| 5606 SetLayerPropertiesForTesting(root.get(), identity_matrix, gfx::Point3F(), | 5607 SetLayerPropertiesForTesting(root.get(), identity_matrix, gfx::Point3F(), |
| 5607 gfx::PointF(), gfx::Size(50, 50), true, false, | 5608 gfx::PointF(), gfx::Size(50, 50), true, false, |
| 5608 true); | 5609 true); |
| 5609 root->SetDrawsContent(true); | 5610 root->SetDrawsContent(true); |
| 5610 LayerImpl* root_layer = root.get(); | 5611 LayerImpl* root_layer = root.get(); |
| 5611 | 5612 |
| 5612 std::unique_ptr<LayerImpl> copy_grand_parent = | 5613 std::unique_ptr<LayerImpl> copy_grand_parent = |
| 5613 LayerImpl::Create(host_impl.pending_tree(), 2); | 5614 CreateTestLayerImpl(host_impl.pending_tree(), 2); |
| 5614 SetLayerPropertiesForTesting(copy_grand_parent.get(), identity_matrix, | 5615 SetLayerPropertiesForTesting(copy_grand_parent.get(), identity_matrix, |
| 5615 gfx::Point3F(), gfx::PointF(), gfx::Size(40, 40), | 5616 gfx::Point3F(), gfx::PointF(), gfx::Size(40, 40), |
| 5616 true, false, false); | 5617 true, false, false); |
| 5617 copy_grand_parent->SetDrawsContent(true); | 5618 copy_grand_parent->SetDrawsContent(true); |
| 5618 LayerImpl* copy_grand_parent_layer = copy_grand_parent.get(); | 5619 LayerImpl* copy_grand_parent_layer = copy_grand_parent.get(); |
| 5619 | 5620 |
| 5620 std::unique_ptr<LayerImpl> copy_parent = | 5621 std::unique_ptr<LayerImpl> copy_parent = |
| 5621 LayerImpl::Create(host_impl.pending_tree(), 3); | 5622 CreateTestLayerImpl(host_impl.pending_tree(), 3); |
| 5622 SetLayerPropertiesForTesting(copy_parent.get(), identity_matrix, | 5623 SetLayerPropertiesForTesting(copy_parent.get(), identity_matrix, |
| 5623 gfx::Point3F(), gfx::PointF(), gfx::Size(30, 30), | 5624 gfx::Point3F(), gfx::PointF(), gfx::Size(30, 30), |
| 5624 true, false, true); | 5625 true, false, true); |
| 5625 copy_parent->SetDrawsContent(true); | 5626 copy_parent->SetDrawsContent(true); |
| 5626 LayerImpl* copy_parent_layer = copy_parent.get(); | 5627 LayerImpl* copy_parent_layer = copy_parent.get(); |
| 5627 | 5628 |
| 5628 std::unique_ptr<LayerImpl> copy_request = | 5629 std::unique_ptr<LayerImpl> copy_request = |
| 5629 LayerImpl::Create(host_impl.pending_tree(), 4); | 5630 CreateTestLayerImpl(host_impl.pending_tree(), 4); |
| 5630 SetLayerPropertiesForTesting(copy_request.get(), identity_matrix, | 5631 SetLayerPropertiesForTesting(copy_request.get(), identity_matrix, |
| 5631 gfx::Point3F(), gfx::PointF(), gfx::Size(20, 20), | 5632 gfx::Point3F(), gfx::PointF(), gfx::Size(20, 20), |
| 5632 true, false, true); | 5633 true, false, true); |
| 5633 copy_request->SetDrawsContent(true); | 5634 copy_request->SetDrawsContent(true); |
| 5634 LayerImpl* copy_layer = copy_request.get(); | 5635 LayerImpl* copy_layer = copy_request.get(); |
| 5635 | 5636 |
| 5636 std::unique_ptr<LayerImpl> copy_child = | 5637 std::unique_ptr<LayerImpl> copy_child = |
| 5637 LayerImpl::Create(host_impl.pending_tree(), 5); | 5638 CreateTestLayerImpl(host_impl.pending_tree(), 5); |
| 5638 SetLayerPropertiesForTesting(copy_child.get(), identity_matrix, | 5639 SetLayerPropertiesForTesting(copy_child.get(), identity_matrix, |
| 5639 gfx::Point3F(), gfx::PointF(), gfx::Size(20, 20), | 5640 gfx::Point3F(), gfx::PointF(), gfx::Size(20, 20), |
| 5640 true, false, false); | 5641 true, false, false); |
| 5641 copy_child->SetDrawsContent(true); | 5642 copy_child->SetDrawsContent(true); |
| 5642 LayerImpl* copy_child_layer = copy_child.get(); | 5643 LayerImpl* copy_child_layer = copy_child.get(); |
| 5643 | 5644 |
| 5644 std::unique_ptr<LayerImpl> copy_grand_child = | 5645 std::unique_ptr<LayerImpl> copy_grand_child = |
| 5645 LayerImpl::Create(host_impl.pending_tree(), 6); | 5646 CreateTestLayerImpl(host_impl.pending_tree(), 6); |
| 5646 SetLayerPropertiesForTesting(copy_grand_child.get(), identity_matrix, | 5647 SetLayerPropertiesForTesting(copy_grand_child.get(), identity_matrix, |
| 5647 gfx::Point3F(), gfx::PointF(), gfx::Size(20, 20), | 5648 gfx::Point3F(), gfx::PointF(), gfx::Size(20, 20), |
| 5648 true, false, false); | 5649 true, false, false); |
| 5649 copy_child->SetDrawsContent(true); | 5650 copy_child->SetDrawsContent(true); |
| 5650 LayerImpl* copy_grand_child_layer = copy_grand_child.get(); | 5651 LayerImpl* copy_grand_child_layer = copy_grand_child.get(); |
| 5651 | 5652 |
| 5652 std::unique_ptr<LayerImpl> copy_grand_parent_sibling_before = | 5653 std::unique_ptr<LayerImpl> copy_grand_parent_sibling_before = |
| 5653 LayerImpl::Create(host_impl.pending_tree(), 7); | 5654 CreateTestLayerImpl(host_impl.pending_tree(), 7); |
| 5654 SetLayerPropertiesForTesting(copy_grand_parent_sibling_before.get(), | 5655 SetLayerPropertiesForTesting(copy_grand_parent_sibling_before.get(), |
| 5655 identity_matrix, gfx::Point3F(), gfx::PointF(), | 5656 identity_matrix, gfx::Point3F(), gfx::PointF(), |
| 5656 gfx::Size(40, 40), true, false, false); | 5657 gfx::Size(40, 40), true, false, false); |
| 5657 copy_grand_parent_sibling_before->SetDrawsContent(true); | 5658 copy_grand_parent_sibling_before->SetDrawsContent(true); |
| 5658 LayerImpl* copy_grand_parent_sibling_before_layer = | 5659 LayerImpl* copy_grand_parent_sibling_before_layer = |
| 5659 copy_grand_parent_sibling_before.get(); | 5660 copy_grand_parent_sibling_before.get(); |
| 5660 | 5661 |
| 5661 std::unique_ptr<LayerImpl> copy_grand_parent_sibling_after = | 5662 std::unique_ptr<LayerImpl> copy_grand_parent_sibling_after = |
| 5662 LayerImpl::Create(host_impl.pending_tree(), 8); | 5663 CreateTestLayerImpl(host_impl.pending_tree(), 8); |
| 5663 SetLayerPropertiesForTesting(copy_grand_parent_sibling_after.get(), | 5664 SetLayerPropertiesForTesting(copy_grand_parent_sibling_after.get(), |
| 5664 identity_matrix, gfx::Point3F(), gfx::PointF(), | 5665 identity_matrix, gfx::Point3F(), gfx::PointF(), |
| 5665 gfx::Size(40, 40), true, false, false); | 5666 gfx::Size(40, 40), true, false, false); |
| 5666 copy_grand_parent_sibling_after->SetDrawsContent(true); | 5667 copy_grand_parent_sibling_after->SetDrawsContent(true); |
| 5667 LayerImpl* copy_grand_parent_sibling_after_layer = | 5668 LayerImpl* copy_grand_parent_sibling_after_layer = |
| 5668 copy_grand_parent_sibling_after.get(); | 5669 copy_grand_parent_sibling_after.get(); |
| 5669 | 5670 |
| 5670 copy_child->AddChild(std::move(copy_grand_child)); | 5671 copy_child->AddChild(std::move(copy_grand_child)); |
| 5671 copy_request->AddChild(std::move(copy_child)); | 5672 copy_request->AddChild(std::move(copy_child)); |
| 5672 copy_parent->AddChild(std::move(copy_request)); | 5673 copy_parent->AddChild(std::move(copy_request)); |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5756 TEST_F(LayerTreeHostCommonTest, ClippedOutCopyRequest) { | 5757 TEST_F(LayerTreeHostCommonTest, ClippedOutCopyRequest) { |
| 5757 FakeImplTaskRunnerProvider task_runner_provider; | 5758 FakeImplTaskRunnerProvider task_runner_provider; |
| 5758 TestSharedBitmapManager shared_bitmap_manager; | 5759 TestSharedBitmapManager shared_bitmap_manager; |
| 5759 TestTaskGraphRunner task_graph_runner; | 5760 TestTaskGraphRunner task_graph_runner; |
| 5760 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &shared_bitmap_manager, | 5761 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &shared_bitmap_manager, |
| 5761 &task_graph_runner); | 5762 &task_graph_runner); |
| 5762 host_impl.CreatePendingTree(); | 5763 host_impl.CreatePendingTree(); |
| 5763 const gfx::Transform identity_matrix; | 5764 const gfx::Transform identity_matrix; |
| 5764 | 5765 |
| 5765 std::unique_ptr<LayerImpl> root = | 5766 std::unique_ptr<LayerImpl> root = |
| 5766 LayerImpl::Create(host_impl.pending_tree(), 1); | 5767 CreateTestLayerImpl(host_impl.pending_tree(), 1); |
| 5767 SetLayerPropertiesForTesting(root.get(), identity_matrix, gfx::Point3F(), | 5768 SetLayerPropertiesForTesting(root.get(), identity_matrix, gfx::Point3F(), |
| 5768 gfx::PointF(), gfx::Size(50, 50), true, false, | 5769 gfx::PointF(), gfx::Size(50, 50), true, false, |
| 5769 true); | 5770 true); |
| 5770 root->SetDrawsContent(true); | 5771 root->SetDrawsContent(true); |
| 5771 | 5772 |
| 5772 std::unique_ptr<LayerImpl> copy_parent = | 5773 std::unique_ptr<LayerImpl> copy_parent = |
| 5773 LayerImpl::Create(host_impl.pending_tree(), 2); | 5774 CreateTestLayerImpl(host_impl.pending_tree(), 2); |
| 5774 SetLayerPropertiesForTesting(copy_parent.get(), identity_matrix, | 5775 SetLayerPropertiesForTesting(copy_parent.get(), identity_matrix, |
| 5775 gfx::Point3F(), gfx::PointF(), gfx::Size(), true, | 5776 gfx::Point3F(), gfx::PointF(), gfx::Size(), true, |
| 5776 false, false); | 5777 false, false); |
| 5777 copy_parent->SetDrawsContent(true); | 5778 copy_parent->SetDrawsContent(true); |
| 5778 copy_parent->SetMasksToBounds(true); | 5779 copy_parent->SetMasksToBounds(true); |
| 5779 | 5780 |
| 5780 std::unique_ptr<LayerImpl> copy_layer = | 5781 std::unique_ptr<LayerImpl> copy_layer = |
| 5781 LayerImpl::Create(host_impl.pending_tree(), 3); | 5782 CreateTestLayerImpl(host_impl.pending_tree(), 3); |
| 5782 SetLayerPropertiesForTesting(copy_layer.get(), identity_matrix, | 5783 SetLayerPropertiesForTesting(copy_layer.get(), identity_matrix, |
| 5783 gfx::Point3F(), gfx::PointF(), gfx::Size(30, 30), | 5784 gfx::Point3F(), gfx::PointF(), gfx::Size(30, 30), |
| 5784 true, false, true); | 5785 true, false, true); |
| 5785 copy_layer->SetDrawsContent(true); | 5786 copy_layer->SetDrawsContent(true); |
| 5786 | 5787 |
| 5787 std::unique_ptr<LayerImpl> copy_child = | 5788 std::unique_ptr<LayerImpl> copy_child = |
| 5788 LayerImpl::Create(host_impl.pending_tree(), 4); | 5789 CreateTestLayerImpl(host_impl.pending_tree(), 4); |
| 5789 SetLayerPropertiesForTesting(copy_child.get(), identity_matrix, | 5790 SetLayerPropertiesForTesting(copy_child.get(), identity_matrix, |
| 5790 gfx::Point3F(), gfx::PointF(), gfx::Size(20, 20), | 5791 gfx::Point3F(), gfx::PointF(), gfx::Size(20, 20), |
| 5791 true, false, false); | 5792 true, false, false); |
| 5792 copy_child->SetDrawsContent(true); | 5793 copy_child->SetDrawsContent(true); |
| 5793 | 5794 |
| 5794 std::vector<std::unique_ptr<CopyOutputRequest>> copy_requests; | 5795 std::vector<std::unique_ptr<CopyOutputRequest>> copy_requests; |
| 5795 copy_requests.push_back( | 5796 copy_requests.push_back( |
| 5796 CopyOutputRequest::CreateRequest(base::Bind(&EmptyCopyOutputCallback))); | 5797 CopyOutputRequest::CreateRequest(base::Bind(&EmptyCopyOutputCallback))); |
| 5797 copy_layer->PassCopyRequests(©_requests); | 5798 copy_layer->PassCopyRequests(©_requests); |
| 5798 EXPECT_TRUE(copy_layer->HasCopyRequest()); | 5799 EXPECT_TRUE(copy_layer->HasCopyRequest()); |
| (...skipping 480 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6279 } | 6280 } |
| 6280 | 6281 |
| 6281 TEST_F(LayerTreeHostCommonTest, CanRenderToSeparateSurface) { | 6282 TEST_F(LayerTreeHostCommonTest, CanRenderToSeparateSurface) { |
| 6282 FakeImplTaskRunnerProvider task_runner_provider; | 6283 FakeImplTaskRunnerProvider task_runner_provider; |
| 6283 TestSharedBitmapManager shared_bitmap_manager; | 6284 TestSharedBitmapManager shared_bitmap_manager; |
| 6284 TestTaskGraphRunner task_graph_runner; | 6285 TestTaskGraphRunner task_graph_runner; |
| 6285 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &shared_bitmap_manager, | 6286 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &shared_bitmap_manager, |
| 6286 &task_graph_runner); | 6287 &task_graph_runner); |
| 6287 | 6288 |
| 6288 std::unique_ptr<LayerImpl> root = | 6289 std::unique_ptr<LayerImpl> root = |
| 6289 LayerImpl::Create(host_impl.active_tree(), 12345); | 6290 CreateTestLayerImpl(host_impl.active_tree(), 12345); |
| 6290 std::unique_ptr<LayerImpl> child1 = | 6291 std::unique_ptr<LayerImpl> child1 = |
| 6291 LayerImpl::Create(host_impl.active_tree(), 123456); | 6292 CreateTestLayerImpl(host_impl.active_tree(), 123456); |
| 6292 std::unique_ptr<LayerImpl> child2 = | 6293 std::unique_ptr<LayerImpl> child2 = |
| 6293 LayerImpl::Create(host_impl.active_tree(), 1234567); | 6294 CreateTestLayerImpl(host_impl.active_tree(), 1234567); |
| 6294 std::unique_ptr<LayerImpl> child3 = | 6295 std::unique_ptr<LayerImpl> child3 = |
| 6295 LayerImpl::Create(host_impl.active_tree(), 12345678); | 6296 CreateTestLayerImpl(host_impl.active_tree(), 12345678); |
| 6296 | 6297 |
| 6297 gfx::Transform identity_matrix; | 6298 gfx::Transform identity_matrix; |
| 6298 gfx::Point3F transform_origin; | 6299 gfx::Point3F transform_origin; |
| 6299 gfx::PointF position; | 6300 gfx::PointF position; |
| 6300 gfx::Size bounds(100, 100); | 6301 gfx::Size bounds(100, 100); |
| 6301 SetLayerPropertiesForTesting(root.get(), identity_matrix, transform_origin, | 6302 SetLayerPropertiesForTesting(root.get(), identity_matrix, transform_origin, |
| 6302 position, bounds, true, false, true); | 6303 position, bounds, true, false, true); |
| 6303 root->SetDrawsContent(true); | 6304 root->SetDrawsContent(true); |
| 6304 | 6305 |
| 6305 // This layer structure normally forces render surface due to preserves3d | 6306 // This layer structure normally forces render surface due to preserves3d |
| (...skipping 712 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7018 // + scroller | 7019 // + scroller |
| 7019 // + fixed | 7020 // + fixed |
| 7020 // | 7021 // |
| 7021 FakeImplTaskRunnerProvider task_runner_provider; | 7022 FakeImplTaskRunnerProvider task_runner_provider; |
| 7022 TestSharedBitmapManager shared_bitmap_manager; | 7023 TestSharedBitmapManager shared_bitmap_manager; |
| 7023 TestTaskGraphRunner task_graph_runner; | 7024 TestTaskGraphRunner task_graph_runner; |
| 7024 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &shared_bitmap_manager, | 7025 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &shared_bitmap_manager, |
| 7025 &task_graph_runner); | 7026 &task_graph_runner); |
| 7026 host_impl.CreatePendingTree(); | 7027 host_impl.CreatePendingTree(); |
| 7027 std::unique_ptr<LayerImpl> root_ptr = | 7028 std::unique_ptr<LayerImpl> root_ptr = |
| 7028 LayerImpl::Create(host_impl.active_tree(), 1); | 7029 CreateTestLayerImpl(host_impl.active_tree(), 1); |
| 7029 LayerImpl* root = root_ptr.get(); | 7030 LayerImpl* root = root_ptr.get(); |
| 7030 std::unique_ptr<LayerImpl> container = | 7031 std::unique_ptr<LayerImpl> container = |
| 7031 LayerImpl::Create(host_impl.active_tree(), 2); | 7032 CreateTestLayerImpl(host_impl.active_tree(), 2); |
| 7032 LayerImpl* container_layer = container.get(); | 7033 LayerImpl* container_layer = container.get(); |
| 7033 std::unique_ptr<LayerImpl> scroller = | 7034 std::unique_ptr<LayerImpl> scroller = |
| 7034 LayerImpl::Create(host_impl.active_tree(), 3); | 7035 CreateTestLayerImpl(host_impl.active_tree(), 3); |
| 7035 LayerImpl* scroll_layer = scroller.get(); | 7036 LayerImpl* scroll_layer = scroller.get(); |
| 7036 std::unique_ptr<LayerImpl> fixed = | 7037 std::unique_ptr<LayerImpl> fixed = |
| 7037 LayerImpl::Create(host_impl.active_tree(), 4); | 7038 CreateTestLayerImpl(host_impl.active_tree(), 4); |
| 7038 LayerImpl* fixed_layer = fixed.get(); | 7039 LayerImpl* fixed_layer = fixed.get(); |
| 7039 | 7040 |
| 7040 container->test_properties()->is_container_for_fixed_position_layers = true; | 7041 container->test_properties()->is_container_for_fixed_position_layers = true; |
| 7041 | 7042 |
| 7042 LayerPositionConstraint constraint; | 7043 LayerPositionConstraint constraint; |
| 7043 constraint.set_is_fixed_position(true); | 7044 constraint.set_is_fixed_position(true); |
| 7044 fixed->test_properties()->position_constraint = constraint; | 7045 fixed->test_properties()->position_constraint = constraint; |
| 7045 | 7046 |
| 7046 scroller->SetScrollClipLayer(container->id()); | 7047 scroller->SetScrollClipLayer(container->id()); |
| 7047 | 7048 |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7188 SetLayerPropertiesForTesting(scroller, identity_transform, gfx::Point3F(), | 7189 SetLayerPropertiesForTesting(scroller, identity_transform, gfx::Point3F(), |
| 7189 gfx::PointF(), gfx::Size(100, 100), true, false, | 7190 gfx::PointF(), gfx::Size(100, 100), true, false, |
| 7190 false); | 7191 false); |
| 7191 | 7192 |
| 7192 gfx::Transform end_scale; | 7193 gfx::Transform end_scale; |
| 7193 end_scale.Scale(2.f, 2.f); | 7194 end_scale.Scale(2.f, 2.f); |
| 7194 TransformOperations start_operations; | 7195 TransformOperations start_operations; |
| 7195 start_operations.AppendMatrix(start_scale); | 7196 start_operations.AppendMatrix(start_scale); |
| 7196 TransformOperations end_operations; | 7197 TransformOperations end_operations; |
| 7197 end_operations.AppendMatrix(end_scale); | 7198 end_operations.AppendMatrix(end_scale); |
| 7198 AddAnimatedTransformToLayerWithPlayer(animated_layer->id(), timeline_impl(), | 7199 AddAnimatedTransformToElementWithPlayer(animated_layer->element_id(), |
| 7199 1.0, start_operations, end_operations); | 7200 timeline_impl(), 1.0, |
| 7201 start_operations, end_operations); |
| 7200 gfx::Vector2dF scroll_delta(5.f, 9.f); | 7202 gfx::Vector2dF scroll_delta(5.f, 9.f); |
| 7201 SetScrollOffsetDelta(scroller, scroll_delta); | 7203 SetScrollOffsetDelta(scroller, scroll_delta); |
| 7202 | 7204 |
| 7203 ExecuteCalculateDrawProperties(root); | 7205 ExecuteCalculateDrawProperties(root); |
| 7204 | 7206 |
| 7205 gfx::Vector2dF expected_draw_transform_translation(-7.5f, -13.5f); | 7207 gfx::Vector2dF expected_draw_transform_translation(-7.5f, -13.5f); |
| 7206 EXPECT_VECTOR2DF_EQ(expected_draw_transform_translation, | 7208 EXPECT_VECTOR2DF_EQ(expected_draw_transform_translation, |
| 7207 scroller->DrawTransform().To2dTranslation()); | 7209 scroller->DrawTransform().To2dTranslation()); |
| 7208 } | 7210 } |
| 7209 | 7211 |
| 7210 class AnimationScaleFactorTrackingLayerImpl : public LayerImpl { | 7212 class AnimationScaleFactorTrackingLayerImpl : public LayerImpl { |
| 7211 public: | 7213 public: |
| 7212 static std::unique_ptr<AnimationScaleFactorTrackingLayerImpl> Create( | 7214 static std::unique_ptr<AnimationScaleFactorTrackingLayerImpl> Create( |
| 7213 LayerTreeImpl* tree_impl, | 7215 LayerTreeImpl* tree_impl, |
| 7214 int id) { | 7216 int id) { |
| 7215 return base::WrapUnique( | 7217 auto layer = base::WrapUnique( |
| 7216 new AnimationScaleFactorTrackingLayerImpl(tree_impl, id)); | 7218 new AnimationScaleFactorTrackingLayerImpl(tree_impl, id)); |
| 7219 layer->SetElementId(NextElementId()); |
| 7220 return layer; |
| 7217 } | 7221 } |
| 7218 | 7222 |
| 7219 ~AnimationScaleFactorTrackingLayerImpl() override {} | 7223 ~AnimationScaleFactorTrackingLayerImpl() override {} |
| 7220 | 7224 |
| 7221 private: | 7225 private: |
| 7222 explicit AnimationScaleFactorTrackingLayerImpl(LayerTreeImpl* tree_impl, | 7226 explicit AnimationScaleFactorTrackingLayerImpl(LayerTreeImpl* tree_impl, |
| 7223 int id) | 7227 int id) |
| 7224 : LayerImpl(tree_impl, id) { | 7228 : LayerImpl(tree_impl, id) { |
| 7225 SetDrawsContent(true); | 7229 SetDrawsContent(true); |
| 7226 } | 7230 } |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7292 0.f, | 7296 0.f, |
| 7293 grand_child_raw->draw_properties().starting_animation_contents_scale); | 7297 grand_child_raw->draw_properties().starting_animation_contents_scale); |
| 7294 | 7298 |
| 7295 TransformOperations translation; | 7299 TransformOperations translation; |
| 7296 translation.AppendTranslate(1.f, 2.f, 3.f); | 7300 translation.AppendTranslate(1.f, 2.f, 3.f); |
| 7297 | 7301 |
| 7298 scoped_refptr<AnimationTimeline> timeline; | 7302 scoped_refptr<AnimationTimeline> timeline; |
| 7299 timeline = AnimationTimeline::Create(AnimationIdProvider::NextTimelineId()); | 7303 timeline = AnimationTimeline::Create(AnimationIdProvider::NextTimelineId()); |
| 7300 host_impl.animation_host()->AddAnimationTimeline(timeline); | 7304 host_impl.animation_host()->AddAnimationTimeline(timeline); |
| 7301 | 7305 |
| 7302 AddAnimatedTransformToLayerWithPlayer(parent_raw->id(), timeline, 1.0, | 7306 AddAnimatedTransformToElementWithPlayer(parent_raw->element_id(), timeline, |
| 7303 TransformOperations(), translation); | 7307 1.0, TransformOperations(), |
| 7308 translation); |
| 7304 | 7309 |
| 7305 // No layers have scale-affecting animations. | 7310 // No layers have scale-affecting animations. |
| 7306 EXPECT_EQ( | 7311 EXPECT_EQ( |
| 7307 0.f, | 7312 0.f, |
| 7308 grand_parent_raw->draw_properties().maximum_animation_contents_scale); | 7313 grand_parent_raw->draw_properties().maximum_animation_contents_scale); |
| 7309 EXPECT_EQ(0.f, | 7314 EXPECT_EQ(0.f, |
| 7310 parent_raw->draw_properties().maximum_animation_contents_scale); | 7315 parent_raw->draw_properties().maximum_animation_contents_scale); |
| 7311 EXPECT_EQ(0.f, child_raw->draw_properties().maximum_animation_contents_scale); | 7316 EXPECT_EQ(0.f, child_raw->draw_properties().maximum_animation_contents_scale); |
| 7312 EXPECT_EQ( | 7317 EXPECT_EQ( |
| 7313 0.f, grand_child_raw->draw_properties().maximum_animation_contents_scale); | 7318 0.f, grand_child_raw->draw_properties().maximum_animation_contents_scale); |
| 7314 | 7319 |
| 7315 EXPECT_EQ( | 7320 EXPECT_EQ( |
| 7316 0.f, | 7321 0.f, |
| 7317 grand_parent_raw->draw_properties().starting_animation_contents_scale); | 7322 grand_parent_raw->draw_properties().starting_animation_contents_scale); |
| 7318 EXPECT_EQ(0.f, | 7323 EXPECT_EQ(0.f, |
| 7319 parent_raw->draw_properties().starting_animation_contents_scale); | 7324 parent_raw->draw_properties().starting_animation_contents_scale); |
| 7320 EXPECT_EQ(0.f, | 7325 EXPECT_EQ(0.f, |
| 7321 child_raw->draw_properties().starting_animation_contents_scale); | 7326 child_raw->draw_properties().starting_animation_contents_scale); |
| 7322 EXPECT_EQ( | 7327 EXPECT_EQ( |
| 7323 0.f, | 7328 0.f, |
| 7324 grand_child_raw->draw_properties().starting_animation_contents_scale); | 7329 grand_child_raw->draw_properties().starting_animation_contents_scale); |
| 7325 | 7330 |
| 7326 TransformOperations scale; | 7331 TransformOperations scale; |
| 7327 scale.AppendScale(5.f, 4.f, 3.f); | 7332 scale.AppendScale(5.f, 4.f, 3.f); |
| 7328 | 7333 |
| 7329 AddAnimatedTransformToLayerWithPlayer(child_raw->id(), timeline, 1.0, | 7334 AddAnimatedTransformToElementWithPlayer(child_raw->element_id(), timeline, |
| 7330 TransformOperations(), scale); | 7335 1.0, TransformOperations(), scale); |
| 7331 child_raw->layer_tree_impl()->property_trees()->needs_rebuild = true; | 7336 child_raw->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| 7332 ExecuteCalculateDrawProperties(grand_parent_raw); | 7337 ExecuteCalculateDrawProperties(grand_parent_raw); |
| 7333 | 7338 |
| 7334 // Only |child| has a scale-affecting animation. | 7339 // Only |child| has a scale-affecting animation. |
| 7335 EXPECT_EQ( | 7340 EXPECT_EQ( |
| 7336 0.f, | 7341 0.f, |
| 7337 grand_parent_raw->draw_properties().maximum_animation_contents_scale); | 7342 grand_parent_raw->draw_properties().maximum_animation_contents_scale); |
| 7338 EXPECT_EQ(0.f, | 7343 EXPECT_EQ(0.f, |
| 7339 parent_raw->draw_properties().maximum_animation_contents_scale); | 7344 parent_raw->draw_properties().maximum_animation_contents_scale); |
| 7340 EXPECT_EQ(5.f, child_raw->draw_properties().maximum_animation_contents_scale); | 7345 EXPECT_EQ(5.f, child_raw->draw_properties().maximum_animation_contents_scale); |
| 7341 EXPECT_EQ( | 7346 EXPECT_EQ( |
| 7342 5.f, grand_child_raw->draw_properties().maximum_animation_contents_scale); | 7347 5.f, grand_child_raw->draw_properties().maximum_animation_contents_scale); |
| 7343 | 7348 |
| 7344 EXPECT_EQ( | 7349 EXPECT_EQ( |
| 7345 0.f, | 7350 0.f, |
| 7346 grand_parent_raw->draw_properties().starting_animation_contents_scale); | 7351 grand_parent_raw->draw_properties().starting_animation_contents_scale); |
| 7347 EXPECT_EQ(0.f, | 7352 EXPECT_EQ(0.f, |
| 7348 parent_raw->draw_properties().starting_animation_contents_scale); | 7353 parent_raw->draw_properties().starting_animation_contents_scale); |
| 7349 EXPECT_EQ(1.f, | 7354 EXPECT_EQ(1.f, |
| 7350 child_raw->draw_properties().starting_animation_contents_scale); | 7355 child_raw->draw_properties().starting_animation_contents_scale); |
| 7351 EXPECT_EQ( | 7356 EXPECT_EQ( |
| 7352 1.f, | 7357 1.f, |
| 7353 grand_child_raw->draw_properties().starting_animation_contents_scale); | 7358 grand_child_raw->draw_properties().starting_animation_contents_scale); |
| 7354 | 7359 |
| 7355 AddAnimatedTransformToLayerWithPlayer(grand_parent_raw->id(), timeline, 1.0, | 7360 AddAnimatedTransformToElementWithPlayer(grand_parent_raw->element_id(), |
| 7356 TransformOperations(), scale); | 7361 timeline, 1.0, TransformOperations(), |
| 7362 scale); |
| 7357 grand_parent_raw->layer_tree_impl()->property_trees()->needs_rebuild = true; | 7363 grand_parent_raw->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| 7358 ExecuteCalculateDrawProperties(grand_parent_raw); | 7364 ExecuteCalculateDrawProperties(grand_parent_raw); |
| 7359 | 7365 |
| 7360 // |grand_parent| and |child| have scale-affecting animations. | 7366 // |grand_parent| and |child| have scale-affecting animations. |
| 7361 EXPECT_EQ( | 7367 EXPECT_EQ( |
| 7362 5.f, | 7368 5.f, |
| 7363 grand_parent_raw->draw_properties().maximum_animation_contents_scale); | 7369 grand_parent_raw->draw_properties().maximum_animation_contents_scale); |
| 7364 EXPECT_EQ(5.f, | 7370 EXPECT_EQ(5.f, |
| 7365 parent_raw->draw_properties().maximum_animation_contents_scale); | 7371 parent_raw->draw_properties().maximum_animation_contents_scale); |
| 7366 // We don't support combining animated scales from two nodes; 0.f means | 7372 // We don't support combining animated scales from two nodes; 0.f means |
| 7367 // that the maximum scale could not be computed. | 7373 // that the maximum scale could not be computed. |
| 7368 EXPECT_EQ(0.f, child_raw->draw_properties().maximum_animation_contents_scale); | 7374 EXPECT_EQ(0.f, child_raw->draw_properties().maximum_animation_contents_scale); |
| 7369 EXPECT_EQ( | 7375 EXPECT_EQ( |
| 7370 0.f, grand_child_raw->draw_properties().maximum_animation_contents_scale); | 7376 0.f, grand_child_raw->draw_properties().maximum_animation_contents_scale); |
| 7371 | 7377 |
| 7372 EXPECT_EQ( | 7378 EXPECT_EQ( |
| 7373 1.f, | 7379 1.f, |
| 7374 grand_parent_raw->draw_properties().starting_animation_contents_scale); | 7380 grand_parent_raw->draw_properties().starting_animation_contents_scale); |
| 7375 EXPECT_EQ(1.f, | 7381 EXPECT_EQ(1.f, |
| 7376 parent_raw->draw_properties().starting_animation_contents_scale); | 7382 parent_raw->draw_properties().starting_animation_contents_scale); |
| 7377 EXPECT_EQ(0.f, | 7383 EXPECT_EQ(0.f, |
| 7378 child_raw->draw_properties().starting_animation_contents_scale); | 7384 child_raw->draw_properties().starting_animation_contents_scale); |
| 7379 EXPECT_EQ( | 7385 EXPECT_EQ( |
| 7380 0.f, | 7386 0.f, |
| 7381 grand_child_raw->draw_properties().starting_animation_contents_scale); | 7387 grand_child_raw->draw_properties().starting_animation_contents_scale); |
| 7382 | 7388 |
| 7383 AddAnimatedTransformToLayerWithPlayer(parent_raw->id(), timeline, 1.0, | 7389 AddAnimatedTransformToElementWithPlayer(parent_raw->element_id(), timeline, |
| 7384 TransformOperations(), scale); | 7390 1.0, TransformOperations(), scale); |
| 7385 parent_raw->layer_tree_impl()->property_trees()->needs_rebuild = true; | 7391 parent_raw->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| 7386 ExecuteCalculateDrawProperties(grand_parent_raw); | 7392 ExecuteCalculateDrawProperties(grand_parent_raw); |
| 7387 | 7393 |
| 7388 // |grand_parent|, |parent|, and |child| have scale-affecting animations. | 7394 // |grand_parent|, |parent|, and |child| have scale-affecting animations. |
| 7389 EXPECT_EQ( | 7395 EXPECT_EQ( |
| 7390 5.f, | 7396 5.f, |
| 7391 grand_parent_raw->draw_properties().maximum_animation_contents_scale); | 7397 grand_parent_raw->draw_properties().maximum_animation_contents_scale); |
| 7392 EXPECT_EQ(0.f, | 7398 EXPECT_EQ(0.f, |
| 7393 parent_raw->draw_properties().maximum_animation_contents_scale); | 7399 parent_raw->draw_properties().maximum_animation_contents_scale); |
| 7394 EXPECT_EQ(0.f, child_raw->draw_properties().maximum_animation_contents_scale); | 7400 EXPECT_EQ(0.f, child_raw->draw_properties().maximum_animation_contents_scale); |
| 7395 EXPECT_EQ( | 7401 EXPECT_EQ( |
| 7396 0.f, grand_child_raw->draw_properties().maximum_animation_contents_scale); | 7402 0.f, grand_child_raw->draw_properties().maximum_animation_contents_scale); |
| 7397 | 7403 |
| 7398 EXPECT_EQ( | 7404 EXPECT_EQ( |
| 7399 1.f, | 7405 1.f, |
| 7400 grand_parent_raw->draw_properties().starting_animation_contents_scale); | 7406 grand_parent_raw->draw_properties().starting_animation_contents_scale); |
| 7401 EXPECT_EQ(0.f, | 7407 EXPECT_EQ(0.f, |
| 7402 parent_raw->draw_properties().starting_animation_contents_scale); | 7408 parent_raw->draw_properties().starting_animation_contents_scale); |
| 7403 EXPECT_EQ(0.f, | 7409 EXPECT_EQ(0.f, |
| 7404 child_raw->draw_properties().starting_animation_contents_scale); | 7410 child_raw->draw_properties().starting_animation_contents_scale); |
| 7405 EXPECT_EQ( | 7411 EXPECT_EQ( |
| 7406 0.f, | 7412 0.f, |
| 7407 grand_child_raw->draw_properties().starting_animation_contents_scale); | 7413 grand_child_raw->draw_properties().starting_animation_contents_scale); |
| 7408 | 7414 |
| 7409 AbortAnimationsOnLayerWithPlayer(grand_parent_raw->id(), timeline, | 7415 AbortAnimationsOnElementWithPlayer(grand_parent_raw->element_id(), timeline, |
| 7410 TargetProperty::TRANSFORM); | 7416 TargetProperty::TRANSFORM); |
| 7411 AbortAnimationsOnLayerWithPlayer(parent_raw->id(), timeline, | 7417 AbortAnimationsOnElementWithPlayer(parent_raw->element_id(), timeline, |
| 7412 TargetProperty::TRANSFORM); | 7418 TargetProperty::TRANSFORM); |
| 7413 AbortAnimationsOnLayerWithPlayer(child_raw->id(), timeline, | 7419 AbortAnimationsOnElementWithPlayer(child_raw->element_id(), timeline, |
| 7414 TargetProperty::TRANSFORM); | 7420 TargetProperty::TRANSFORM); |
| 7415 | 7421 |
| 7416 TransformOperations perspective; | 7422 TransformOperations perspective; |
| 7417 perspective.AppendPerspective(10.f); | 7423 perspective.AppendPerspective(10.f); |
| 7418 | 7424 |
| 7419 AddAnimatedTransformToLayerWithPlayer(child_raw->id(), timeline, 1.0, | 7425 AddAnimatedTransformToElementWithPlayer(child_raw->element_id(), timeline, |
| 7420 TransformOperations(), perspective); | 7426 1.0, TransformOperations(), |
| 7427 perspective); |
| 7421 child_raw->layer_tree_impl()->property_trees()->needs_rebuild = true; | 7428 child_raw->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| 7422 ExecuteCalculateDrawProperties(grand_parent_raw); | 7429 ExecuteCalculateDrawProperties(grand_parent_raw); |
| 7423 | 7430 |
| 7424 // |child| has a scale-affecting animation but computing the maximum of this | 7431 // |child| has a scale-affecting animation but computing the maximum of this |
| 7425 // animation is not supported. | 7432 // animation is not supported. |
| 7426 EXPECT_EQ( | 7433 EXPECT_EQ( |
| 7427 0.f, | 7434 0.f, |
| 7428 grand_parent_raw->draw_properties().maximum_animation_contents_scale); | 7435 grand_parent_raw->draw_properties().maximum_animation_contents_scale); |
| 7429 EXPECT_EQ(0.f, | 7436 EXPECT_EQ(0.f, |
| 7430 parent_raw->draw_properties().maximum_animation_contents_scale); | 7437 parent_raw->draw_properties().maximum_animation_contents_scale); |
| 7431 EXPECT_EQ(0.f, child_raw->draw_properties().maximum_animation_contents_scale); | 7438 EXPECT_EQ(0.f, child_raw->draw_properties().maximum_animation_contents_scale); |
| 7432 EXPECT_EQ( | 7439 EXPECT_EQ( |
| 7433 0.f, grand_child_raw->draw_properties().maximum_animation_contents_scale); | 7440 0.f, grand_child_raw->draw_properties().maximum_animation_contents_scale); |
| 7434 | 7441 |
| 7435 EXPECT_EQ( | 7442 EXPECT_EQ( |
| 7436 0.f, | 7443 0.f, |
| 7437 grand_parent_raw->draw_properties().starting_animation_contents_scale); | 7444 grand_parent_raw->draw_properties().starting_animation_contents_scale); |
| 7438 EXPECT_EQ(0.f, | 7445 EXPECT_EQ(0.f, |
| 7439 parent_raw->draw_properties().starting_animation_contents_scale); | 7446 parent_raw->draw_properties().starting_animation_contents_scale); |
| 7440 EXPECT_EQ(0.f, | 7447 EXPECT_EQ(0.f, |
| 7441 child_raw->draw_properties().starting_animation_contents_scale); | 7448 child_raw->draw_properties().starting_animation_contents_scale); |
| 7442 EXPECT_EQ( | 7449 EXPECT_EQ( |
| 7443 0.f, | 7450 0.f, |
| 7444 grand_child_raw->draw_properties().starting_animation_contents_scale); | 7451 grand_child_raw->draw_properties().starting_animation_contents_scale); |
| 7445 | 7452 |
| 7446 AbortAnimationsOnLayerWithPlayer(child_raw->id(), timeline, | 7453 AbortAnimationsOnElementWithPlayer(child_raw->element_id(), timeline, |
| 7447 TargetProperty::TRANSFORM); | 7454 TargetProperty::TRANSFORM); |
| 7448 gfx::Transform scale_matrix; | 7455 gfx::Transform scale_matrix; |
| 7449 scale_matrix.Scale(1.f, 2.f); | 7456 scale_matrix.Scale(1.f, 2.f); |
| 7450 grand_parent_raw->SetTransform(scale_matrix); | 7457 grand_parent_raw->SetTransform(scale_matrix); |
| 7451 parent_raw->SetTransform(scale_matrix); | 7458 parent_raw->SetTransform(scale_matrix); |
| 7452 grand_parent_raw->layer_tree_impl()->property_trees()->needs_rebuild = true; | 7459 grand_parent_raw->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| 7453 | 7460 |
| 7454 AddAnimatedTransformToLayerWithPlayer(parent_raw->id(), timeline, 1.0, | 7461 AddAnimatedTransformToElementWithPlayer(parent_raw->element_id(), timeline, |
| 7455 TransformOperations(), scale); | 7462 1.0, TransformOperations(), scale); |
| 7456 ExecuteCalculateDrawProperties(grand_parent_raw); | 7463 ExecuteCalculateDrawProperties(grand_parent_raw); |
| 7457 | 7464 |
| 7458 // |grand_parent| and |parent| each have scale 2.f. |parent| has a scale | 7465 // |grand_parent| and |parent| each have scale 2.f. |parent| has a scale |
| 7459 // animation with maximum scale 5.f. | 7466 // animation with maximum scale 5.f. |
| 7460 EXPECT_EQ( | 7467 EXPECT_EQ( |
| 7461 0.f, | 7468 0.f, |
| 7462 grand_parent_raw->draw_properties().maximum_animation_contents_scale); | 7469 grand_parent_raw->draw_properties().maximum_animation_contents_scale); |
| 7463 EXPECT_EQ(10.f, | 7470 EXPECT_EQ(10.f, |
| 7464 parent_raw->draw_properties().maximum_animation_contents_scale); | 7471 parent_raw->draw_properties().maximum_animation_contents_scale); |
| 7465 EXPECT_EQ(10.f, | 7472 EXPECT_EQ(10.f, |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7582 | 7589 |
| 7583 TEST_F(LayerTreeHostCommonTest, RenderSurfaceLayerListMembership) { | 7590 TEST_F(LayerTreeHostCommonTest, RenderSurfaceLayerListMembership) { |
| 7584 FakeImplTaskRunnerProvider task_runner_provider; | 7591 FakeImplTaskRunnerProvider task_runner_provider; |
| 7585 TestSharedBitmapManager shared_bitmap_manager; | 7592 TestSharedBitmapManager shared_bitmap_manager; |
| 7586 TestTaskGraphRunner task_graph_runner; | 7593 TestTaskGraphRunner task_graph_runner; |
| 7587 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &shared_bitmap_manager, | 7594 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &shared_bitmap_manager, |
| 7588 &task_graph_runner); | 7595 &task_graph_runner); |
| 7589 gfx::Transform identity_matrix; | 7596 gfx::Transform identity_matrix; |
| 7590 | 7597 |
| 7591 std::unique_ptr<LayerImpl> grand_parent = | 7598 std::unique_ptr<LayerImpl> grand_parent = |
| 7592 LayerImpl::Create(host_impl.active_tree(), 1); | 7599 CreateTestLayerImpl(host_impl.active_tree(), 1); |
| 7593 std::unique_ptr<LayerImpl> parent = | 7600 std::unique_ptr<LayerImpl> parent = |
| 7594 LayerImpl::Create(host_impl.active_tree(), 3); | 7601 CreateTestLayerImpl(host_impl.active_tree(), 3); |
| 7595 std::unique_ptr<LayerImpl> child = | 7602 std::unique_ptr<LayerImpl> child = |
| 7596 LayerImpl::Create(host_impl.active_tree(), 5); | 7603 CreateTestLayerImpl(host_impl.active_tree(), 5); |
| 7597 std::unique_ptr<LayerImpl> grand_child1 = | 7604 std::unique_ptr<LayerImpl> grand_child1 = |
| 7598 LayerImpl::Create(host_impl.active_tree(), 7); | 7605 CreateTestLayerImpl(host_impl.active_tree(), 7); |
| 7599 std::unique_ptr<LayerImpl> grand_child2 = | 7606 std::unique_ptr<LayerImpl> grand_child2 = |
| 7600 LayerImpl::Create(host_impl.active_tree(), 9); | 7607 CreateTestLayerImpl(host_impl.active_tree(), 9); |
| 7601 | 7608 |
| 7602 LayerImpl* grand_parent_raw = grand_parent.get(); | 7609 LayerImpl* grand_parent_raw = grand_parent.get(); |
| 7603 LayerImpl* parent_raw = parent.get(); | 7610 LayerImpl* parent_raw = parent.get(); |
| 7604 LayerImpl* child_raw = child.get(); | 7611 LayerImpl* child_raw = child.get(); |
| 7605 LayerImpl* grand_child1_raw = grand_child1.get(); | 7612 LayerImpl* grand_child1_raw = grand_child1.get(); |
| 7606 LayerImpl* grand_child2_raw = grand_child2.get(); | 7613 LayerImpl* grand_child2_raw = grand_child2.get(); |
| 7607 | 7614 |
| 7608 child->AddChild(std::move(grand_child1)); | 7615 child->AddChild(std::move(grand_child1)); |
| 7609 child->AddChild(std::move(grand_child2)); | 7616 child->AddChild(std::move(grand_child2)); |
| 7610 parent->AddChild(std::move(child)); | 7617 parent->AddChild(std::move(child)); |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7698 EXPECT_TRUE(grand_child2_raw->is_drawn_render_surface_layer_list_member()); | 7705 EXPECT_TRUE(grand_child2_raw->is_drawn_render_surface_layer_list_member()); |
| 7699 | 7706 |
| 7700 expected.clear(); | 7707 expected.clear(); |
| 7701 expected.insert(grand_child2_raw); | 7708 expected.insert(grand_child2_raw); |
| 7702 | 7709 |
| 7703 actual.clear(); | 7710 actual.clear(); |
| 7704 GatherDrawnLayers(render_surface_layer_list_impl(), &actual); | 7711 GatherDrawnLayers(render_surface_layer_list_impl(), &actual); |
| 7705 EXPECT_EQ(expected, actual); | 7712 EXPECT_EQ(expected, actual); |
| 7706 | 7713 |
| 7707 // Add a mask layer to child. | 7714 // Add a mask layer to child. |
| 7708 child_raw->SetMaskLayer(LayerImpl::Create(host_impl.active_tree(), 6)); | 7715 child_raw->SetMaskLayer(CreateTestLayerImpl(host_impl.active_tree(), 6)); |
| 7709 child_raw->layer_tree_impl()->property_trees()->needs_rebuild = true; | 7716 child_raw->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| 7710 | 7717 |
| 7711 ExecuteCalculateDrawProperties(grand_parent_raw); | 7718 ExecuteCalculateDrawProperties(grand_parent_raw); |
| 7712 | 7719 |
| 7713 EXPECT_FALSE(grand_parent_raw->is_drawn_render_surface_layer_list_member()); | 7720 EXPECT_FALSE(grand_parent_raw->is_drawn_render_surface_layer_list_member()); |
| 7714 EXPECT_FALSE(parent_raw->is_drawn_render_surface_layer_list_member()); | 7721 EXPECT_FALSE(parent_raw->is_drawn_render_surface_layer_list_member()); |
| 7715 EXPECT_FALSE(child_raw->is_drawn_render_surface_layer_list_member()); | 7722 EXPECT_FALSE(child_raw->is_drawn_render_surface_layer_list_member()); |
| 7716 EXPECT_TRUE( | 7723 EXPECT_TRUE( |
| 7717 child_raw->mask_layer()->is_drawn_render_surface_layer_list_member()); | 7724 child_raw->mask_layer()->is_drawn_render_surface_layer_list_member()); |
| 7718 EXPECT_FALSE(grand_child1_raw->is_drawn_render_surface_layer_list_member()); | 7725 EXPECT_FALSE(grand_child1_raw->is_drawn_render_surface_layer_list_member()); |
| 7719 EXPECT_TRUE(grand_child2_raw->is_drawn_render_surface_layer_list_member()); | 7726 EXPECT_TRUE(grand_child2_raw->is_drawn_render_surface_layer_list_member()); |
| 7720 | 7727 |
| 7721 expected.clear(); | 7728 expected.clear(); |
| 7722 expected.insert(grand_child2_raw); | 7729 expected.insert(grand_child2_raw); |
| 7723 expected.insert(child_raw->mask_layer()); | 7730 expected.insert(child_raw->mask_layer()); |
| 7724 | 7731 |
| 7725 expected.clear(); | 7732 expected.clear(); |
| 7726 expected.insert(grand_child2_raw); | 7733 expected.insert(grand_child2_raw); |
| 7727 expected.insert(child_raw->mask_layer()); | 7734 expected.insert(child_raw->mask_layer()); |
| 7728 | 7735 |
| 7729 actual.clear(); | 7736 actual.clear(); |
| 7730 GatherDrawnLayers(render_surface_layer_list_impl(), &actual); | 7737 GatherDrawnLayers(render_surface_layer_list_impl(), &actual); |
| 7731 EXPECT_EQ(expected, actual); | 7738 EXPECT_EQ(expected, actual); |
| 7732 | 7739 |
| 7733 // Add replica mask layer. | 7740 // Add replica mask layer. |
| 7734 std::unique_ptr<LayerImpl> replica_layer = | 7741 std::unique_ptr<LayerImpl> replica_layer = |
| 7735 LayerImpl::Create(host_impl.active_tree(), 20); | 7742 CreateTestLayerImpl(host_impl.active_tree(), 20); |
| 7736 replica_layer->SetMaskLayer(LayerImpl::Create(host_impl.active_tree(), 21)); | 7743 replica_layer->SetMaskLayer(CreateTestLayerImpl(host_impl.active_tree(), 21)); |
| 7737 child_raw->SetReplicaLayer(std::move(replica_layer)); | 7744 child_raw->SetReplicaLayer(std::move(replica_layer)); |
| 7738 child_raw->layer_tree_impl()->property_trees()->needs_rebuild = true; | 7745 child_raw->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| 7739 | 7746 |
| 7740 ExecuteCalculateDrawProperties(grand_parent_raw); | 7747 ExecuteCalculateDrawProperties(grand_parent_raw); |
| 7741 | 7748 |
| 7742 EXPECT_FALSE(grand_parent_raw->is_drawn_render_surface_layer_list_member()); | 7749 EXPECT_FALSE(grand_parent_raw->is_drawn_render_surface_layer_list_member()); |
| 7743 EXPECT_FALSE(parent_raw->is_drawn_render_surface_layer_list_member()); | 7750 EXPECT_FALSE(parent_raw->is_drawn_render_surface_layer_list_member()); |
| 7744 EXPECT_FALSE(child_raw->is_drawn_render_surface_layer_list_member()); | 7751 EXPECT_FALSE(child_raw->is_drawn_render_surface_layer_list_member()); |
| 7745 EXPECT_TRUE( | 7752 EXPECT_TRUE( |
| 7746 child_raw->mask_layer()->is_drawn_render_surface_layer_list_member()); | 7753 child_raw->mask_layer()->is_drawn_render_surface_layer_list_member()); |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7833 TEST_F(LayerTreeHostCommonTest, DrawPropertyScales) { | 7840 TEST_F(LayerTreeHostCommonTest, DrawPropertyScales) { |
| 7834 FakeImplTaskRunnerProvider task_runner_provider; | 7841 FakeImplTaskRunnerProvider task_runner_provider; |
| 7835 TestSharedBitmapManager shared_bitmap_manager; | 7842 TestSharedBitmapManager shared_bitmap_manager; |
| 7836 TestTaskGraphRunner task_graph_runner; | 7843 TestTaskGraphRunner task_graph_runner; |
| 7837 LayerTreeSettings settings = host()->settings(); | 7844 LayerTreeSettings settings = host()->settings(); |
| 7838 settings.layer_transforms_should_scale_layer_contents = true; | 7845 settings.layer_transforms_should_scale_layer_contents = true; |
| 7839 FakeLayerTreeHostImpl host_impl(settings, &task_runner_provider, | 7846 FakeLayerTreeHostImpl host_impl(settings, &task_runner_provider, |
| 7840 &shared_bitmap_manager, &task_graph_runner); | 7847 &shared_bitmap_manager, &task_graph_runner); |
| 7841 | 7848 |
| 7842 std::unique_ptr<LayerImpl> root = | 7849 std::unique_ptr<LayerImpl> root = |
| 7843 LayerImpl::Create(host_impl.active_tree(), 1); | 7850 CreateTestLayerImpl(host_impl.active_tree(), 1); |
| 7844 LayerImpl* root_layer = root.get(); | 7851 LayerImpl* root_layer = root.get(); |
| 7845 std::unique_ptr<LayerImpl> child1 = | 7852 std::unique_ptr<LayerImpl> child1 = |
| 7846 LayerImpl::Create(host_impl.active_tree(), 2); | 7853 CreateTestLayerImpl(host_impl.active_tree(), 2); |
| 7847 LayerImpl* child1_layer = child1.get(); | 7854 LayerImpl* child1_layer = child1.get(); |
| 7848 std::unique_ptr<LayerImpl> child2 = | 7855 std::unique_ptr<LayerImpl> child2 = |
| 7849 LayerImpl::Create(host_impl.active_tree(), 3); | 7856 CreateTestLayerImpl(host_impl.active_tree(), 3); |
| 7850 LayerImpl* child2_layer = child2.get(); | 7857 LayerImpl* child2_layer = child2.get(); |
| 7851 | 7858 |
| 7852 root->AddChild(std::move(child1)); | 7859 root->AddChild(std::move(child1)); |
| 7853 root->AddChild(std::move(child2)); | 7860 root->AddChild(std::move(child2)); |
| 7854 root->test_properties()->force_render_surface = true; | 7861 root->test_properties()->force_render_surface = true; |
| 7855 root->SetDrawsContent(true); | 7862 root->SetDrawsContent(true); |
| 7856 host_impl.active_tree()->SetRootLayer(std::move(root)); | 7863 host_impl.active_tree()->SetRootLayer(std::move(root)); |
| 7857 | 7864 |
| 7858 gfx::Transform identity_matrix, scale_transform_child1, | 7865 gfx::Transform identity_matrix, scale_transform_child1, |
| 7859 scale_transform_child2; | 7866 scale_transform_child2; |
| 7860 scale_transform_child1.Scale(2, 3); | 7867 scale_transform_child1.Scale(2, 3); |
| 7861 scale_transform_child2.Scale(4, 5); | 7868 scale_transform_child2.Scale(4, 5); |
| 7862 | 7869 |
| 7863 SetLayerPropertiesForTesting(root_layer, identity_matrix, gfx::Point3F(), | 7870 SetLayerPropertiesForTesting(root_layer, identity_matrix, gfx::Point3F(), |
| 7864 gfx::PointF(), gfx::Size(1, 1), true, false, | 7871 gfx::PointF(), gfx::Size(1, 1), true, false, |
| 7865 true); | 7872 true); |
| 7866 SetLayerPropertiesForTesting(child1_layer, scale_transform_child1, | 7873 SetLayerPropertiesForTesting(child1_layer, scale_transform_child1, |
| 7867 gfx::Point3F(), gfx::PointF(), gfx::Size(1, 1), | 7874 gfx::Point3F(), gfx::PointF(), gfx::Size(1, 1), |
| 7868 true, false, false); | 7875 true, false, false); |
| 7869 | 7876 |
| 7870 child1_layer->SetMaskLayer(LayerImpl::Create(host_impl.active_tree(), 4)); | 7877 child1_layer->SetMaskLayer(CreateTestLayerImpl(host_impl.active_tree(), 4)); |
| 7871 child1_layer->SetDrawsContent(true); | 7878 child1_layer->SetDrawsContent(true); |
| 7872 | 7879 |
| 7873 std::unique_ptr<LayerImpl> replica_layer = | 7880 std::unique_ptr<LayerImpl> replica_layer = |
| 7874 LayerImpl::Create(host_impl.active_tree(), 5); | 7881 CreateTestLayerImpl(host_impl.active_tree(), 5); |
| 7875 replica_layer->SetMaskLayer(LayerImpl::Create(host_impl.active_tree(), 6)); | 7882 replica_layer->SetMaskLayer(CreateTestLayerImpl(host_impl.active_tree(), 6)); |
| 7876 child1_layer->SetReplicaLayer(std::move(replica_layer)); | 7883 child1_layer->SetReplicaLayer(std::move(replica_layer)); |
| 7877 child1_layer->SetHasRenderSurface(true); | 7884 child1_layer->SetHasRenderSurface(true); |
| 7878 | 7885 |
| 7879 ExecuteCalculateDrawProperties(root_layer); | 7886 ExecuteCalculateDrawProperties(root_layer); |
| 7880 | 7887 |
| 7881 TransformOperations scale; | 7888 TransformOperations scale; |
| 7882 scale.AppendScale(5.f, 8.f, 3.f); | 7889 scale.AppendScale(5.f, 8.f, 3.f); |
| 7883 | 7890 |
| 7884 scoped_refptr<AnimationTimeline> timeline = | 7891 scoped_refptr<AnimationTimeline> timeline = |
| 7885 AnimationTimeline::Create(AnimationIdProvider::NextTimelineId()); | 7892 AnimationTimeline::Create(AnimationIdProvider::NextTimelineId()); |
| 7886 host_impl.animation_host()->AddAnimationTimeline(timeline); | 7893 host_impl.animation_host()->AddAnimationTimeline(timeline); |
| 7887 | 7894 |
| 7888 AddAnimatedTransformToLayerWithPlayer(child2_layer->id(), timeline, 1.0, | 7895 AddAnimatedTransformToElementWithPlayer(child2_layer->element_id(), timeline, |
| 7889 TransformOperations(), scale); | 7896 1.0, TransformOperations(), scale); |
| 7890 | 7897 |
| 7891 SetLayerPropertiesForTesting(child2_layer, scale_transform_child2, | 7898 SetLayerPropertiesForTesting(child2_layer, scale_transform_child2, |
| 7892 gfx::Point3F(), gfx::PointF(), gfx::Size(1, 1), | 7899 gfx::Point3F(), gfx::PointF(), gfx::Size(1, 1), |
| 7893 true, false, false); | 7900 true, false, false); |
| 7894 child2_layer->SetDrawsContent(true); | 7901 child2_layer->SetDrawsContent(true); |
| 7895 | 7902 |
| 7896 root_layer->layer_tree_impl()->property_trees()->needs_rebuild = true; | 7903 root_layer->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| 7897 ExecuteCalculateDrawProperties(root_layer); | 7904 ExecuteCalculateDrawProperties(root_layer); |
| 7898 | 7905 |
| 7899 EXPECT_FLOAT_EQ(1.f, root_layer->GetIdealContentsScale()); | 7906 EXPECT_FLOAT_EQ(1.f, root_layer->GetIdealContentsScale()); |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8044 | 8051 |
| 8045 // Sublayer should be bigger than the root enlarged by bounds_delta. | 8052 // Sublayer should be bigger than the root enlarged by bounds_delta. |
| 8046 gfx::Size sublayer_size = gfx::Size(300, 1000); | 8053 gfx::Size sublayer_size = gfx::Size(300, 1000); |
| 8047 | 8054 |
| 8048 // Device viewport accomidated the root and the top controls. | 8055 // Device viewport accomidated the root and the top controls. |
| 8049 gfx::Size device_viewport_size = gfx::Size(300, 600); | 8056 gfx::Size device_viewport_size = gfx::Size(300, 600); |
| 8050 gfx::Transform identity_matrix; | 8057 gfx::Transform identity_matrix; |
| 8051 | 8058 |
| 8052 host_impl.SetViewportSize(device_viewport_size); | 8059 host_impl.SetViewportSize(device_viewport_size); |
| 8053 host_impl.active_tree()->SetRootLayer( | 8060 host_impl.active_tree()->SetRootLayer( |
| 8054 LayerImpl::Create(host_impl.active_tree(), 1)); | 8061 CreateTestLayerImpl(host_impl.active_tree(), 1)); |
| 8055 | 8062 |
| 8056 LayerImpl* root = host_impl.active_tree()->root_layer(); | 8063 LayerImpl* root = host_impl.active_tree()->root_layer(); |
| 8057 SetLayerPropertiesForTesting(root, | 8064 SetLayerPropertiesForTesting(root, |
| 8058 identity_matrix, | 8065 identity_matrix, |
| 8059 gfx::Point3F(), | 8066 gfx::Point3F(), |
| 8060 gfx::PointF(), | 8067 gfx::PointF(), |
| 8061 root_size, | 8068 root_size, |
| 8062 false, | 8069 false, |
| 8063 false, | 8070 false, |
| 8064 true); | 8071 true); |
| 8065 root->SetMasksToBounds(true); | 8072 root->SetMasksToBounds(true); |
| 8066 | 8073 |
| 8067 root->AddChild(LayerImpl::Create(host_impl.active_tree(), 2)); | 8074 root->AddChild(CreateTestLayerImpl(host_impl.active_tree(), 2)); |
| 8068 | 8075 |
| 8069 LayerImpl* sublayer = root->child_at(0); | 8076 LayerImpl* sublayer = root->child_at(0); |
| 8070 SetLayerPropertiesForTesting(sublayer, | 8077 SetLayerPropertiesForTesting(sublayer, |
| 8071 identity_matrix, | 8078 identity_matrix, |
| 8072 gfx::Point3F(), | 8079 gfx::Point3F(), |
| 8073 gfx::PointF(), | 8080 gfx::PointF(), |
| 8074 sublayer_size, | 8081 sublayer_size, |
| 8075 false, | 8082 false, |
| 8076 false, | 8083 false, |
| 8077 false); | 8084 false); |
| 8078 sublayer->SetDrawsContent(true); | 8085 sublayer->SetDrawsContent(true); |
| 8079 | 8086 |
| 8080 LayerImplList layer_impl_list; | 8087 LayerImplList layer_impl_list; |
| 8081 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( | 8088 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( |
| 8082 root, device_viewport_size, &layer_impl_list); | 8089 root, device_viewport_size, &layer_impl_list); |
| 8083 | 8090 |
| 8084 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); | 8091 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); |
| 8085 EXPECT_EQ(gfx::Rect(root_size), sublayer->visible_layer_rect()); | 8092 EXPECT_EQ(gfx::Rect(root_size), sublayer->visible_layer_rect()); |
| 8086 | 8093 |
| 8087 root->SetBoundsDelta(gfx::Vector2dF(0.0, 50.0)); | 8094 root->SetBoundsDelta(gfx::Vector2dF(0.0, 50.0)); |
| 8088 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); | 8095 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); |
| 8089 | 8096 |
| 8090 gfx::Rect affected_by_delta(0, 0, root_size.width(), | 8097 gfx::Rect affected_by_delta(0, 0, root_size.width(), |
| 8091 root_size.height() + 50); | 8098 root_size.height() + 50); |
| 8092 EXPECT_EQ(affected_by_delta, sublayer->visible_layer_rect()); | 8099 EXPECT_EQ(affected_by_delta, sublayer->visible_layer_rect()); |
| 8093 } | 8100 } |
| 8094 | 8101 |
| 8095 TEST_F(LayerTreeHostCommonTest, NodesAffectedByBoundsDeltaGetUpdated) { | 8102 TEST_F(LayerTreeHostCommonTest, NodesAffectedByBoundsDeltaGetUpdated) { |
| 8096 scoped_refptr<Layer> root = Layer::Create(); | 8103 scoped_refptr<Layer> root = CreateTestLayer(); |
| 8097 scoped_refptr<Layer> inner_viewport_container_layer = Layer::Create(); | 8104 scoped_refptr<Layer> inner_viewport_container_layer = CreateTestLayer(); |
| 8098 scoped_refptr<Layer> inner_viewport_scroll_layer = Layer::Create(); | 8105 scoped_refptr<Layer> inner_viewport_scroll_layer = CreateTestLayer(); |
| 8099 scoped_refptr<Layer> outer_viewport_container_layer = Layer::Create(); | 8106 scoped_refptr<Layer> outer_viewport_container_layer = CreateTestLayer(); |
| 8100 scoped_refptr<Layer> outer_viewport_scroll_layer = Layer::Create(); | 8107 scoped_refptr<Layer> outer_viewport_scroll_layer = CreateTestLayer(); |
| 8101 | 8108 |
| 8102 root->AddChild(inner_viewport_container_layer); | 8109 root->AddChild(inner_viewport_container_layer); |
| 8103 inner_viewport_container_layer->AddChild(inner_viewport_scroll_layer); | 8110 inner_viewport_container_layer->AddChild(inner_viewport_scroll_layer); |
| 8104 inner_viewport_scroll_layer->AddChild(outer_viewport_container_layer); | 8111 inner_viewport_scroll_layer->AddChild(outer_viewport_container_layer); |
| 8105 outer_viewport_container_layer->AddChild(outer_viewport_scroll_layer); | 8112 outer_viewport_container_layer->AddChild(outer_viewport_scroll_layer); |
| 8106 | 8113 |
| 8107 inner_viewport_scroll_layer->SetScrollClipLayerId( | 8114 inner_viewport_scroll_layer->SetScrollClipLayerId( |
| 8108 inner_viewport_container_layer->id()); | 8115 inner_viewport_container_layer->id()); |
| 8109 outer_viewport_scroll_layer->SetScrollClipLayerId( | 8116 outer_viewport_scroll_layer->SetScrollClipLayerId( |
| 8110 outer_viewport_container_layer->id()); | 8117 outer_viewport_container_layer->id()); |
| 8111 | 8118 |
| 8112 inner_viewport_scroll_layer->SetIsContainerForFixedPositionLayers(true); | 8119 inner_viewport_scroll_layer->SetIsContainerForFixedPositionLayers(true); |
| 8113 outer_viewport_scroll_layer->SetIsContainerForFixedPositionLayers(true); | 8120 outer_viewport_scroll_layer->SetIsContainerForFixedPositionLayers(true); |
| 8114 | 8121 |
| 8115 host()->SetRootLayer(root); | 8122 host()->SetRootLayer(root); |
| 8116 host()->RegisterViewportLayers(nullptr, root, inner_viewport_scroll_layer, | 8123 host()->RegisterViewportLayers(nullptr, root, inner_viewport_scroll_layer, |
| 8117 outer_viewport_scroll_layer); | 8124 outer_viewport_scroll_layer); |
| 8118 | 8125 |
| 8119 scoped_refptr<Layer> fixed_to_inner = Layer::Create(); | 8126 scoped_refptr<Layer> fixed_to_inner = CreateTestLayer(); |
| 8120 scoped_refptr<Layer> fixed_to_outer = Layer::Create(); | 8127 scoped_refptr<Layer> fixed_to_outer = CreateTestLayer(); |
| 8121 | 8128 |
| 8122 inner_viewport_scroll_layer->AddChild(fixed_to_inner); | 8129 inner_viewport_scroll_layer->AddChild(fixed_to_inner); |
| 8123 outer_viewport_scroll_layer->AddChild(fixed_to_outer); | 8130 outer_viewport_scroll_layer->AddChild(fixed_to_outer); |
| 8124 | 8131 |
| 8125 LayerPositionConstraint fixed_to_right; | 8132 LayerPositionConstraint fixed_to_right; |
| 8126 fixed_to_right.set_is_fixed_position(true); | 8133 fixed_to_right.set_is_fixed_position(true); |
| 8127 fixed_to_right.set_is_fixed_to_right_edge(true); | 8134 fixed_to_right.set_is_fixed_to_right_edge(true); |
| 8128 | 8135 |
| 8129 fixed_to_inner->SetPositionConstraint(fixed_to_right); | 8136 fixed_to_inner->SetPositionConstraint(fixed_to_right); |
| 8130 fixed_to_outer->SetPositionConstraint(fixed_to_right); | 8137 fixed_to_outer->SetPositionConstraint(fixed_to_right); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 8145 | 8152 |
| 8146 fixed_to_outer->SetPositionConstraint(fixed_to_left); | 8153 fixed_to_outer->SetPositionConstraint(fixed_to_left); |
| 8147 | 8154 |
| 8148 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); | 8155 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); |
| 8149 EXPECT_FALSE(transform_tree.HasNodesAffectedByInnerViewportBoundsDelta()); | 8156 EXPECT_FALSE(transform_tree.HasNodesAffectedByInnerViewportBoundsDelta()); |
| 8150 EXPECT_FALSE(transform_tree.HasNodesAffectedByOuterViewportBoundsDelta()); | 8157 EXPECT_FALSE(transform_tree.HasNodesAffectedByOuterViewportBoundsDelta()); |
| 8151 } | 8158 } |
| 8152 | 8159 |
| 8153 TEST_F(LayerTreeHostCommonTest, VisibleContentRectForAnimatedLayer) { | 8160 TEST_F(LayerTreeHostCommonTest, VisibleContentRectForAnimatedLayer) { |
| 8154 const gfx::Transform identity_matrix; | 8161 const gfx::Transform identity_matrix; |
| 8155 scoped_refptr<Layer> root = Layer::Create(); | 8162 scoped_refptr<Layer> root = CreateTestLayer(); |
| 8156 scoped_refptr<LayerWithForcedDrawsContent> animated = | 8163 scoped_refptr<LayerWithForcedDrawsContent> animated = |
| 8157 make_scoped_refptr(new LayerWithForcedDrawsContent()); | 8164 make_scoped_refptr(new LayerWithForcedDrawsContent()); |
| 8158 | 8165 |
| 8159 root->AddChild(animated); | 8166 root->AddChild(animated); |
| 8160 | 8167 |
| 8161 host()->SetRootLayer(root); | 8168 host()->SetRootLayer(root); |
| 8162 | 8169 |
| 8163 SetLayerPropertiesForTesting(root.get(), identity_matrix, gfx::Point3F(), | 8170 SetLayerPropertiesForTesting(root.get(), identity_matrix, gfx::Point3F(), |
| 8164 gfx::PointF(), gfx::Size(100, 100), true, false); | 8171 gfx::PointF(), gfx::Size(100, 100), true, false); |
| 8165 SetLayerPropertiesForTesting(animated.get(), identity_matrix, gfx::Point3F(), | 8172 SetLayerPropertiesForTesting(animated.get(), identity_matrix, gfx::Point3F(), |
| 8166 gfx::PointF(), gfx::Size(20, 20), true, false); | 8173 gfx::PointF(), gfx::Size(20, 20), true, false); |
| 8167 | 8174 |
| 8168 root->SetMasksToBounds(true); | 8175 root->SetMasksToBounds(true); |
| 8169 root->SetForceRenderSurfaceForTesting(true); | 8176 root->SetForceRenderSurfaceForTesting(true); |
| 8170 animated->SetOpacity(0.f); | 8177 animated->SetOpacity(0.f); |
| 8171 | 8178 |
| 8172 AddOpacityTransitionToLayerWithPlayer(animated->id(), timeline(), 10.0, 0.f, | 8179 AddOpacityTransitionToElementWithPlayer(animated->element_id(), timeline(), |
| 8173 1.f, false); | 8180 10.0, 0.f, 1.f, false); |
| 8174 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); | 8181 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); |
| 8175 | 8182 |
| 8176 EXPECT_FALSE(animated->visible_layer_rect_for_testing().IsEmpty()); | 8183 EXPECT_FALSE(animated->visible_layer_rect_for_testing().IsEmpty()); |
| 8177 } | 8184 } |
| 8178 | 8185 |
| 8179 TEST_F(LayerTreeHostCommonTest, | 8186 TEST_F(LayerTreeHostCommonTest, |
| 8180 VisibleContentRectForAnimatedLayerWithSingularTransform) { | 8187 VisibleContentRectForAnimatedLayerWithSingularTransform) { |
| 8181 const gfx::Transform identity_matrix; | 8188 const gfx::Transform identity_matrix; |
| 8182 scoped_refptr<Layer> root = Layer::Create(); | 8189 scoped_refptr<Layer> root = CreateTestLayer(); |
| 8183 scoped_refptr<Layer> clip = Layer::Create(); | 8190 scoped_refptr<Layer> clip = CreateTestLayer(); |
| 8184 scoped_refptr<LayerWithForcedDrawsContent> animated = | 8191 scoped_refptr<LayerWithForcedDrawsContent> animated = |
| 8185 make_scoped_refptr(new LayerWithForcedDrawsContent()); | 8192 make_scoped_refptr(new LayerWithForcedDrawsContent()); |
| 8186 scoped_refptr<LayerWithForcedDrawsContent> surface = | 8193 scoped_refptr<LayerWithForcedDrawsContent> surface = |
| 8187 make_scoped_refptr(new LayerWithForcedDrawsContent()); | 8194 make_scoped_refptr(new LayerWithForcedDrawsContent()); |
| 8188 scoped_refptr<LayerWithForcedDrawsContent> descendant_of_animation = | 8195 scoped_refptr<LayerWithForcedDrawsContent> descendant_of_animation = |
| 8189 make_scoped_refptr(new LayerWithForcedDrawsContent()); | 8196 make_scoped_refptr(new LayerWithForcedDrawsContent()); |
| 8190 | 8197 |
| 8191 root->AddChild(clip); | 8198 root->AddChild(clip); |
| 8192 clip->AddChild(animated); | 8199 clip->AddChild(animated); |
| 8193 animated->AddChild(surface); | 8200 animated->AddChild(surface); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 8211 SetLayerPropertiesForTesting(surface.get(), identity_matrix, gfx::Point3F(), | 8218 SetLayerPropertiesForTesting(surface.get(), identity_matrix, gfx::Point3F(), |
| 8212 gfx::PointF(), gfx::Size(100, 100), true, false); | 8219 gfx::PointF(), gfx::Size(100, 100), true, false); |
| 8213 SetLayerPropertiesForTesting(descendant_of_animation.get(), identity_matrix, | 8220 SetLayerPropertiesForTesting(descendant_of_animation.get(), identity_matrix, |
| 8214 gfx::Point3F(), gfx::PointF(), | 8221 gfx::Point3F(), gfx::PointF(), |
| 8215 gfx::Size(200, 200), true, false); | 8222 gfx::Size(200, 200), true, false); |
| 8216 | 8223 |
| 8217 TransformOperations start_transform_operations; | 8224 TransformOperations start_transform_operations; |
| 8218 start_transform_operations.AppendMatrix(uninvertible_matrix); | 8225 start_transform_operations.AppendMatrix(uninvertible_matrix); |
| 8219 TransformOperations end_transform_operations; | 8226 TransformOperations end_transform_operations; |
| 8220 | 8227 |
| 8221 AddAnimatedTransformToLayerWithPlayer(animated->id(), timeline(), 10.0, | 8228 AddAnimatedTransformToElementWithPlayer(animated->element_id(), timeline(), |
| 8222 start_transform_operations, | 8229 10.0, start_transform_operations, |
| 8223 end_transform_operations); | 8230 end_transform_operations); |
| 8224 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); | 8231 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); |
| 8225 | 8232 |
| 8226 // The animated layer has a singular transform and maps to a non-empty rect in | 8233 // The animated layer has a singular transform and maps to a non-empty rect in |
| 8227 // clipped target space, so is treated as fully visible. | 8234 // clipped target space, so is treated as fully visible. |
| 8228 EXPECT_EQ(gfx::Rect(120, 120), animated->visible_layer_rect_for_testing()); | 8235 EXPECT_EQ(gfx::Rect(120, 120), animated->visible_layer_rect_for_testing()); |
| 8229 | 8236 |
| 8230 // The singular transform on |animated| is flattened when inherited by | 8237 // The singular transform on |animated| is flattened when inherited by |
| 8231 // |surface|, and this happens to make it invertible. | 8238 // |surface|, and this happens to make it invertible. |
| 8232 EXPECT_EQ(gfx::Rect(2, 2), surface->visible_layer_rect_for_testing()); | 8239 EXPECT_EQ(gfx::Rect(2, 2), surface->visible_layer_rect_for_testing()); |
| 8233 EXPECT_EQ(gfx::Rect(2, 2), | 8240 EXPECT_EQ(gfx::Rect(2, 2), |
| (...skipping 14 matching lines...) Expand all Loading... |
| 8248 // means the clip cannot be projected into |surface|'s space, so we treat | 8255 // means the clip cannot be projected into |surface|'s space, so we treat |
| 8249 // |surface| and layers that draw into it as having empty visible rect. | 8256 // |surface| and layers that draw into it as having empty visible rect. |
| 8250 EXPECT_EQ(gfx::Rect(), surface->visible_layer_rect_for_testing()); | 8257 EXPECT_EQ(gfx::Rect(), surface->visible_layer_rect_for_testing()); |
| 8251 EXPECT_EQ(gfx::Rect(), | 8258 EXPECT_EQ(gfx::Rect(), |
| 8252 descendant_of_animation->visible_layer_rect_for_testing()); | 8259 descendant_of_animation->visible_layer_rect_for_testing()); |
| 8253 } | 8260 } |
| 8254 | 8261 |
| 8255 // Verify that having an animated filter (but no current filter, as these | 8262 // Verify that having an animated filter (but no current filter, as these |
| 8256 // are mutually exclusive) correctly creates a render surface. | 8263 // are mutually exclusive) correctly creates a render surface. |
| 8257 TEST_F(LayerTreeHostCommonTest, AnimatedFilterCreatesRenderSurface) { | 8264 TEST_F(LayerTreeHostCommonTest, AnimatedFilterCreatesRenderSurface) { |
| 8258 scoped_refptr<Layer> root = Layer::Create(); | 8265 scoped_refptr<Layer> root = CreateTestLayer(); |
| 8259 scoped_refptr<Layer> child = Layer::Create(); | 8266 scoped_refptr<Layer> child = CreateTestLayer(); |
| 8260 scoped_refptr<Layer> grandchild = Layer::Create(); | 8267 scoped_refptr<Layer> grandchild = CreateTestLayer(); |
| 8261 root->AddChild(child); | 8268 root->AddChild(child); |
| 8262 child->AddChild(grandchild); | 8269 child->AddChild(grandchild); |
| 8263 | 8270 |
| 8264 gfx::Transform identity_transform; | 8271 gfx::Transform identity_transform; |
| 8265 SetLayerPropertiesForTesting(root.get(), identity_transform, gfx::Point3F(), | 8272 SetLayerPropertiesForTesting(root.get(), identity_transform, gfx::Point3F(), |
| 8266 gfx::PointF(), gfx::Size(50, 50), true, false); | 8273 gfx::PointF(), gfx::Size(50, 50), true, false); |
| 8267 SetLayerPropertiesForTesting(child.get(), identity_transform, gfx::Point3F(), | 8274 SetLayerPropertiesForTesting(child.get(), identity_transform, gfx::Point3F(), |
| 8268 gfx::PointF(), gfx::Size(50, 50), true, false); | 8275 gfx::PointF(), gfx::Size(50, 50), true, false); |
| 8269 SetLayerPropertiesForTesting(grandchild.get(), identity_transform, | 8276 SetLayerPropertiesForTesting(grandchild.get(), identity_transform, |
| 8270 gfx::Point3F(), gfx::PointF(), gfx::Size(50, 50), | 8277 gfx::Point3F(), gfx::PointF(), gfx::Size(50, 50), |
| 8271 true, false); | 8278 true, false); |
| 8272 host()->SetRootLayer(root); | 8279 host()->SetRootLayer(root); |
| 8273 | 8280 |
| 8274 AddAnimatedFilterToLayerWithPlayer(child->id(), timeline(), 10.0, 0.1f, 0.2f); | 8281 AddAnimatedFilterToElementWithPlayer(child->element_id(), timeline(), 10.0, |
| 8282 0.1f, 0.2f); |
| 8275 ExecuteCalculateDrawProperties(root.get()); | 8283 ExecuteCalculateDrawProperties(root.get()); |
| 8276 | 8284 |
| 8277 EXPECT_TRUE(root->has_render_surface()); | 8285 EXPECT_TRUE(root->has_render_surface()); |
| 8278 EXPECT_TRUE(child->has_render_surface()); | 8286 EXPECT_TRUE(child->has_render_surface()); |
| 8279 EXPECT_FALSE(grandchild->has_render_surface()); | 8287 EXPECT_FALSE(grandchild->has_render_surface()); |
| 8280 | 8288 |
| 8281 EXPECT_TRUE(root->filters().IsEmpty()); | 8289 EXPECT_TRUE(root->filters().IsEmpty()); |
| 8282 EXPECT_TRUE(child->filters().IsEmpty()); | 8290 EXPECT_TRUE(child->filters().IsEmpty()); |
| 8283 EXPECT_TRUE(grandchild->filters().IsEmpty()); | 8291 EXPECT_TRUE(grandchild->filters().IsEmpty()); |
| 8284 | 8292 |
| 8285 EXPECT_FALSE(root->FilterIsAnimating()); | 8293 EXPECT_FALSE(root->FilterIsAnimating()); |
| 8286 EXPECT_TRUE(child->FilterIsAnimating()); | 8294 EXPECT_TRUE(child->FilterIsAnimating()); |
| 8287 EXPECT_FALSE(grandchild->FilterIsAnimating()); | 8295 EXPECT_FALSE(grandchild->FilterIsAnimating()); |
| 8288 } | 8296 } |
| 8289 | 8297 |
| 8290 // Verify that having a filter animation with a delayed start time creates a | 8298 // Verify that having a filter animation with a delayed start time creates a |
| 8291 // render surface. | 8299 // render surface. |
| 8292 TEST_F(LayerTreeHostCommonTest, DelayedFilterAnimationCreatesRenderSurface) { | 8300 TEST_F(LayerTreeHostCommonTest, DelayedFilterAnimationCreatesRenderSurface) { |
| 8293 scoped_refptr<Layer> root = Layer::Create(); | 8301 scoped_refptr<Layer> root = CreateTestLayer(); |
| 8294 scoped_refptr<Layer> child = Layer::Create(); | 8302 scoped_refptr<Layer> child = CreateTestLayer(); |
| 8295 scoped_refptr<Layer> grandchild = Layer::Create(); | 8303 scoped_refptr<Layer> grandchild = CreateTestLayer(); |
| 8296 root->AddChild(child); | 8304 root->AddChild(child); |
| 8297 child->AddChild(grandchild); | 8305 child->AddChild(grandchild); |
| 8298 | 8306 |
| 8299 gfx::Transform identity_transform; | 8307 gfx::Transform identity_transform; |
| 8300 SetLayerPropertiesForTesting(root.get(), identity_transform, gfx::Point3F(), | 8308 SetLayerPropertiesForTesting(root.get(), identity_transform, gfx::Point3F(), |
| 8301 gfx::PointF(), gfx::Size(50, 50), true, false); | 8309 gfx::PointF(), gfx::Size(50, 50), true, false); |
| 8302 SetLayerPropertiesForTesting(child.get(), identity_transform, gfx::Point3F(), | 8310 SetLayerPropertiesForTesting(child.get(), identity_transform, gfx::Point3F(), |
| 8303 gfx::PointF(), gfx::Size(50, 50), true, false); | 8311 gfx::PointF(), gfx::Size(50, 50), true, false); |
| 8304 SetLayerPropertiesForTesting(grandchild.get(), identity_transform, | 8312 SetLayerPropertiesForTesting(grandchild.get(), identity_transform, |
| 8305 gfx::Point3F(), gfx::PointF(), gfx::Size(50, 50), | 8313 gfx::Point3F(), gfx::PointF(), gfx::Size(50, 50), |
| 8306 true, false); | 8314 true, false); |
| 8307 host()->SetRootLayer(root); | 8315 host()->SetRootLayer(root); |
| 8308 | 8316 |
| 8309 std::unique_ptr<KeyframedFilterAnimationCurve> curve( | 8317 std::unique_ptr<KeyframedFilterAnimationCurve> curve( |
| 8310 KeyframedFilterAnimationCurve::Create()); | 8318 KeyframedFilterAnimationCurve::Create()); |
| 8311 FilterOperations start_filters; | 8319 FilterOperations start_filters; |
| 8312 start_filters.Append(FilterOperation::CreateBrightnessFilter(0.1f)); | 8320 start_filters.Append(FilterOperation::CreateBrightnessFilter(0.1f)); |
| 8313 FilterOperations end_filters; | 8321 FilterOperations end_filters; |
| 8314 end_filters.Append(FilterOperation::CreateBrightnessFilter(0.3f)); | 8322 end_filters.Append(FilterOperation::CreateBrightnessFilter(0.3f)); |
| 8315 curve->AddKeyframe( | 8323 curve->AddKeyframe( |
| 8316 FilterKeyframe::Create(base::TimeDelta(), start_filters, nullptr)); | 8324 FilterKeyframe::Create(base::TimeDelta(), start_filters, nullptr)); |
| 8317 curve->AddKeyframe(FilterKeyframe::Create( | 8325 curve->AddKeyframe(FilterKeyframe::Create( |
| 8318 base::TimeDelta::FromMilliseconds(100), end_filters, nullptr)); | 8326 base::TimeDelta::FromMilliseconds(100), end_filters, nullptr)); |
| 8319 std::unique_ptr<Animation> animation = | 8327 std::unique_ptr<Animation> animation = |
| 8320 Animation::Create(std::move(curve), 0, 1, TargetProperty::FILTER); | 8328 Animation::Create(std::move(curve), 0, 1, TargetProperty::FILTER); |
| 8321 animation->set_fill_mode(Animation::FILL_MODE_NONE); | 8329 animation->set_fill_mode(Animation::FILL_MODE_NONE); |
| 8322 animation->set_time_offset(base::TimeDelta::FromMilliseconds(-1000)); | 8330 animation->set_time_offset(base::TimeDelta::FromMilliseconds(-1000)); |
| 8323 | 8331 |
| 8324 AddAnimationToLayerWithPlayer(child->id(), timeline(), std::move(animation)); | 8332 AddAnimationToElementWithPlayer(child->element_id(), timeline(), |
| 8333 std::move(animation)); |
| 8325 ExecuteCalculateDrawProperties(root.get()); | 8334 ExecuteCalculateDrawProperties(root.get()); |
| 8326 | 8335 |
| 8327 EXPECT_TRUE(root->has_render_surface()); | 8336 EXPECT_TRUE(root->has_render_surface()); |
| 8328 EXPECT_TRUE(child->has_render_surface()); | 8337 EXPECT_TRUE(child->has_render_surface()); |
| 8329 EXPECT_FALSE(grandchild->has_render_surface()); | 8338 EXPECT_FALSE(grandchild->has_render_surface()); |
| 8330 | 8339 |
| 8331 EXPECT_TRUE(root->filters().IsEmpty()); | 8340 EXPECT_TRUE(root->filters().IsEmpty()); |
| 8332 EXPECT_TRUE(child->filters().IsEmpty()); | 8341 EXPECT_TRUE(child->filters().IsEmpty()); |
| 8333 EXPECT_TRUE(grandchild->filters().IsEmpty()); | 8342 EXPECT_TRUE(grandchild->filters().IsEmpty()); |
| 8334 | 8343 |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8410 TEST_F(LayerTreeHostCommonTest, CombineClipsUsingContentTarget) { | 8419 TEST_F(LayerTreeHostCommonTest, CombineClipsUsingContentTarget) { |
| 8411 // In the following layer tree, the layer |box|'s render target is |surface|. | 8420 // In the following layer tree, the layer |box|'s render target is |surface|. |
| 8412 // |surface| also creates a transform node. We want to combine clips for |box| | 8421 // |surface| also creates a transform node. We want to combine clips for |box| |
| 8413 // in the space of its target (i.e., |surface|), not its target's target. This | 8422 // in the space of its target (i.e., |surface|), not its target's target. This |
| 8414 // test ensures that happens. | 8423 // test ensures that happens. |
| 8415 | 8424 |
| 8416 gfx::Transform rotate; | 8425 gfx::Transform rotate; |
| 8417 rotate.Rotate(5); | 8426 rotate.Rotate(5); |
| 8418 gfx::Transform identity; | 8427 gfx::Transform identity; |
| 8419 | 8428 |
| 8420 scoped_refptr<Layer> root = Layer::Create(); | 8429 scoped_refptr<Layer> root = CreateTestLayer(); |
| 8421 SetLayerPropertiesForTesting(root.get(), identity, gfx::Point3F(), | 8430 SetLayerPropertiesForTesting(root.get(), identity, gfx::Point3F(), |
| 8422 gfx::PointF(), gfx::Size(2500, 1500), true, | 8431 gfx::PointF(), gfx::Size(2500, 1500), true, |
| 8423 false); | 8432 false); |
| 8424 | 8433 |
| 8425 scoped_refptr<Layer> frame_clip = Layer::Create(); | 8434 scoped_refptr<Layer> frame_clip = CreateTestLayer(); |
| 8426 SetLayerPropertiesForTesting(frame_clip.get(), identity, gfx::Point3F(), | 8435 SetLayerPropertiesForTesting(frame_clip.get(), identity, gfx::Point3F(), |
| 8427 gfx::PointF(), gfx::Size(2500, 1500), true, | 8436 gfx::PointF(), gfx::Size(2500, 1500), true, |
| 8428 false); | 8437 false); |
| 8429 frame_clip->SetMasksToBounds(true); | 8438 frame_clip->SetMasksToBounds(true); |
| 8430 | 8439 |
| 8431 scoped_refptr<Layer> rotated = Layer::Create(); | 8440 scoped_refptr<Layer> rotated = CreateTestLayer(); |
| 8432 SetLayerPropertiesForTesting(rotated.get(), rotate, | 8441 SetLayerPropertiesForTesting(rotated.get(), rotate, |
| 8433 gfx::Point3F(1250, 250, 0), gfx::PointF(), | 8442 gfx::Point3F(1250, 250, 0), gfx::PointF(), |
| 8434 gfx::Size(2500, 500), true, false); | 8443 gfx::Size(2500, 500), true, false); |
| 8435 | 8444 |
| 8436 scoped_refptr<Layer> surface = Layer::Create(); | 8445 scoped_refptr<Layer> surface = CreateTestLayer(); |
| 8437 SetLayerPropertiesForTesting(surface.get(), rotate, gfx::Point3F(), | 8446 SetLayerPropertiesForTesting(surface.get(), rotate, gfx::Point3F(), |
| 8438 gfx::PointF(), gfx::Size(2500, 500), true, | 8447 gfx::PointF(), gfx::Size(2500, 500), true, |
| 8439 false); | 8448 false); |
| 8440 surface->SetOpacity(0.5); | 8449 surface->SetOpacity(0.5); |
| 8441 | 8450 |
| 8442 scoped_refptr<LayerWithForcedDrawsContent> container = | 8451 scoped_refptr<LayerWithForcedDrawsContent> container = |
| 8443 make_scoped_refptr(new LayerWithForcedDrawsContent()); | 8452 make_scoped_refptr(new LayerWithForcedDrawsContent()); |
| 8444 SetLayerPropertiesForTesting(container.get(), identity, gfx::Point3F(), | 8453 SetLayerPropertiesForTesting(container.get(), identity, gfx::Point3F(), |
| 8445 gfx::PointF(), gfx::Size(300, 300), true, false); | 8454 gfx::PointF(), gfx::Size(300, 300), true, false); |
| 8446 | 8455 |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8533 } | 8542 } |
| 8534 | 8543 |
| 8535 TEST_F(LayerTreeHostCommonTest, ChangingAxisAlignmentTriggersRebuild) { | 8544 TEST_F(LayerTreeHostCommonTest, ChangingAxisAlignmentTriggersRebuild) { |
| 8536 gfx::Transform identity; | 8545 gfx::Transform identity; |
| 8537 gfx::Transform translate; | 8546 gfx::Transform translate; |
| 8538 gfx::Transform rotate; | 8547 gfx::Transform rotate; |
| 8539 | 8548 |
| 8540 translate.Translate(10, 10); | 8549 translate.Translate(10, 10); |
| 8541 rotate.Rotate(45); | 8550 rotate.Rotate(45); |
| 8542 | 8551 |
| 8543 scoped_refptr<Layer> root = Layer::Create(); | 8552 scoped_refptr<Layer> root = CreateTestLayer(); |
| 8544 SetLayerPropertiesForTesting(root.get(), identity, gfx::Point3F(), | 8553 SetLayerPropertiesForTesting(root.get(), identity, gfx::Point3F(), |
| 8545 gfx::PointF(), gfx::Size(800, 800), true, false); | 8554 gfx::PointF(), gfx::Size(800, 800), true, false); |
| 8546 root->SetIsContainerForFixedPositionLayers(true); | 8555 root->SetIsContainerForFixedPositionLayers(true); |
| 8547 | 8556 |
| 8548 host()->SetRootLayer(root); | 8557 host()->SetRootLayer(root); |
| 8549 | 8558 |
| 8550 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); | 8559 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); |
| 8551 EXPECT_FALSE(host()->property_trees()->needs_rebuild); | 8560 EXPECT_FALSE(host()->property_trees()->needs_rebuild); |
| 8552 | 8561 |
| 8553 root->SetTransform(translate); | 8562 root->SetTransform(translate); |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8624 static void CopyOutputCallback(std::unique_ptr<CopyOutputResult> result) {} | 8633 static void CopyOutputCallback(std::unique_ptr<CopyOutputResult> result) {} |
| 8625 | 8634 |
| 8626 TEST_F(LayerTreeHostCommonTest, NumCopyRequestsInTargetSubtree) { | 8635 TEST_F(LayerTreeHostCommonTest, NumCopyRequestsInTargetSubtree) { |
| 8627 // If the layer has a node in effect_tree, the return value of | 8636 // If the layer has a node in effect_tree, the return value of |
| 8628 // num_copy_requests_in_target_subtree() must be equal to the actual number | 8637 // num_copy_requests_in_target_subtree() must be equal to the actual number |
| 8629 // of copy requests in the sub-layer_tree; Otherwise, the number is expected | 8638 // of copy requests in the sub-layer_tree; Otherwise, the number is expected |
| 8630 // to be the value of its nearest ancestor that owns an effect node and | 8639 // to be the value of its nearest ancestor that owns an effect node and |
| 8631 // greater than or equal to the actual number of copy requests in the | 8640 // greater than or equal to the actual number of copy requests in the |
| 8632 // sub-layer_tree. | 8641 // sub-layer_tree. |
| 8633 | 8642 |
| 8634 scoped_refptr<Layer> root = Layer::Create(); | 8643 scoped_refptr<Layer> root = CreateTestLayer(); |
| 8635 scoped_refptr<Layer> child1 = Layer::Create(); | 8644 scoped_refptr<Layer> child1 = CreateTestLayer(); |
| 8636 scoped_refptr<Layer> child2 = Layer::Create(); | 8645 scoped_refptr<Layer> child2 = CreateTestLayer(); |
| 8637 scoped_refptr<Layer> grandchild = Layer::Create(); | 8646 scoped_refptr<Layer> grandchild = CreateTestLayer(); |
| 8638 scoped_refptr<Layer> greatgrandchild = Layer::Create(); | 8647 scoped_refptr<Layer> greatgrandchild = CreateTestLayer(); |
| 8639 | 8648 |
| 8640 root->AddChild(child1); | 8649 root->AddChild(child1); |
| 8641 root->AddChild(child2); | 8650 root->AddChild(child2); |
| 8642 child1->AddChild(grandchild); | 8651 child1->AddChild(grandchild); |
| 8643 grandchild->AddChild(greatgrandchild); | 8652 grandchild->AddChild(greatgrandchild); |
| 8644 host()->SetRootLayer(root); | 8653 host()->SetRootLayer(root); |
| 8645 | 8654 |
| 8646 child1->RequestCopyOfOutput( | 8655 child1->RequestCopyOfOutput( |
| 8647 CopyOutputRequest::CreateBitmapRequest(base::Bind(&CopyOutputCallback))); | 8656 CopyOutputRequest::CreateBitmapRequest(base::Bind(&CopyOutputCallback))); |
| 8648 greatgrandchild->RequestCopyOfOutput( | 8657 greatgrandchild->RequestCopyOfOutput( |
| 8649 CopyOutputRequest::CreateBitmapRequest(base::Bind(&CopyOutputCallback))); | 8658 CopyOutputRequest::CreateBitmapRequest(base::Bind(&CopyOutputCallback))); |
| 8650 child2->SetOpacity(0.f); | 8659 child2->SetOpacity(0.f); |
| 8651 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); | 8660 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); |
| 8652 | 8661 |
| 8653 EXPECT_EQ(root->num_copy_requests_in_target_subtree(), 2); | 8662 EXPECT_EQ(root->num_copy_requests_in_target_subtree(), 2); |
| 8654 EXPECT_EQ(child1->num_copy_requests_in_target_subtree(), 2); | 8663 EXPECT_EQ(child1->num_copy_requests_in_target_subtree(), 2); |
| 8655 EXPECT_EQ(child2->num_copy_requests_in_target_subtree(), 0); | 8664 EXPECT_EQ(child2->num_copy_requests_in_target_subtree(), 0); |
| 8656 EXPECT_EQ(grandchild->num_copy_requests_in_target_subtree(), 2); | 8665 EXPECT_EQ(grandchild->num_copy_requests_in_target_subtree(), 2); |
| 8657 EXPECT_EQ(greatgrandchild->num_copy_requests_in_target_subtree(), 1); | 8666 EXPECT_EQ(greatgrandchild->num_copy_requests_in_target_subtree(), 1); |
| 8658 } | 8667 } |
| 8659 | 8668 |
| 8660 TEST_F(LayerTreeHostCommonTest, SkippingSubtreeMain) { | 8669 TEST_F(LayerTreeHostCommonTest, SkippingSubtreeMain) { |
| 8661 gfx::Transform identity; | 8670 gfx::Transform identity; |
| 8662 scoped_refptr<Layer> root = Layer::Create(); | 8671 scoped_refptr<Layer> root = CreateTestLayer(); |
| 8663 FakeContentLayerClient client; | 8672 FakeContentLayerClient client; |
| 8664 client.set_bounds(root->bounds()); | 8673 client.set_bounds(root->bounds()); |
| 8665 scoped_refptr<LayerWithForcedDrawsContent> child = | 8674 scoped_refptr<LayerWithForcedDrawsContent> child = |
| 8666 make_scoped_refptr(new LayerWithForcedDrawsContent()); | 8675 make_scoped_refptr(new LayerWithForcedDrawsContent()); |
| 8667 scoped_refptr<LayerWithForcedDrawsContent> grandchild = | 8676 scoped_refptr<LayerWithForcedDrawsContent> grandchild = |
| 8668 make_scoped_refptr(new LayerWithForcedDrawsContent()); | 8677 make_scoped_refptr(new LayerWithForcedDrawsContent()); |
| 8669 scoped_refptr<FakePictureLayer> greatgrandchild( | 8678 scoped_refptr<FakePictureLayer> greatgrandchild( |
| 8670 FakePictureLayer::Create(&client)); | 8679 FakePictureLayer::Create(&client)); |
| 8671 SetLayerPropertiesForTesting(root.get(), identity, gfx::Point3F(), | 8680 SetLayerPropertiesForTesting(root.get(), identity, gfx::Point3F(), |
| 8672 gfx::PointF(), gfx::Size(100, 100), true, false); | 8681 gfx::PointF(), gfx::Size(100, 100), true, false); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8710 child->SetTransform(zero_z_scale); | 8719 child->SetTransform(zero_z_scale); |
| 8711 | 8720 |
| 8712 // Add a transform animation with a start delay. Now, even though |child| has | 8721 // Add a transform animation with a start delay. Now, even though |child| has |
| 8713 // a singular transform, the subtree should still get processed. | 8722 // a singular transform, the subtree should still get processed. |
| 8714 int animation_id = 0; | 8723 int animation_id = 0; |
| 8715 std::unique_ptr<Animation> animation = Animation::Create( | 8724 std::unique_ptr<Animation> animation = Animation::Create( |
| 8716 std::unique_ptr<AnimationCurve>(new FakeTransformTransition(1.0)), | 8725 std::unique_ptr<AnimationCurve>(new FakeTransformTransition(1.0)), |
| 8717 animation_id, 1, TargetProperty::TRANSFORM); | 8726 animation_id, 1, TargetProperty::TRANSFORM); |
| 8718 animation->set_fill_mode(Animation::FILL_MODE_NONE); | 8727 animation->set_fill_mode(Animation::FILL_MODE_NONE); |
| 8719 animation->set_time_offset(base::TimeDelta::FromMilliseconds(-1000)); | 8728 animation->set_time_offset(base::TimeDelta::FromMilliseconds(-1000)); |
| 8720 AddAnimationToLayerWithPlayer(child->id(), timeline(), std::move(animation)); | 8729 AddAnimationToElementWithPlayer(child->element_id(), timeline(), |
| 8730 std::move(animation)); |
| 8721 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); | 8731 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); |
| 8722 EXPECT_EQ(gfx::Rect(10, 10), grandchild->visible_layer_rect_for_testing()); | 8732 EXPECT_EQ(gfx::Rect(10, 10), grandchild->visible_layer_rect_for_testing()); |
| 8723 grandchild->set_visible_layer_rect(gfx::Rect()); | 8733 grandchild->set_visible_layer_rect(gfx::Rect()); |
| 8724 | 8734 |
| 8725 RemoveAnimationFromLayerWithExistingPlayer(child->id(), timeline(), | 8735 RemoveAnimationFromElementWithExistingPlayer(child->element_id(), timeline(), |
| 8726 animation_id); | 8736 animation_id); |
| 8727 child->SetTransform(identity); | 8737 child->SetTransform(identity); |
| 8728 child->SetOpacity(0.f); | 8738 child->SetOpacity(0.f); |
| 8729 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); | 8739 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); |
| 8730 EXPECT_EQ(gfx::Rect(0, 0), grandchild->visible_layer_rect_for_testing()); | 8740 EXPECT_EQ(gfx::Rect(0, 0), grandchild->visible_layer_rect_for_testing()); |
| 8731 | 8741 |
| 8732 // Now, even though child has zero opacity, we will configure |grandchild| and | 8742 // Now, even though child has zero opacity, we will configure |grandchild| and |
| 8733 // |greatgrandchild| in several ways that should force the subtree to be | 8743 // |greatgrandchild| in several ways that should force the subtree to be |
| 8734 // processed anyhow. | 8744 // processed anyhow. |
| 8735 grandchild->RequestCopyOfOutput( | 8745 grandchild->RequestCopyOfOutput( |
| 8736 CopyOutputRequest::CreateBitmapRequest(base::Bind(&CopyOutputCallback))); | 8746 CopyOutputRequest::CreateBitmapRequest(base::Bind(&CopyOutputCallback))); |
| 8737 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); | 8747 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); |
| 8738 EXPECT_EQ(gfx::Rect(10, 10), grandchild->visible_layer_rect_for_testing()); | 8748 EXPECT_EQ(gfx::Rect(10, 10), grandchild->visible_layer_rect_for_testing()); |
| 8739 greatgrandchild->set_visible_layer_rect(gfx::Rect()); | 8749 greatgrandchild->set_visible_layer_rect(gfx::Rect()); |
| 8740 | 8750 |
| 8741 // Add an opacity animation with a start delay. | 8751 // Add an opacity animation with a start delay. |
| 8742 animation_id = 1; | 8752 animation_id = 1; |
| 8743 animation = Animation::Create( | 8753 animation = Animation::Create( |
| 8744 std::unique_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)), | 8754 std::unique_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)), |
| 8745 animation_id, 1, TargetProperty::OPACITY); | 8755 animation_id, 1, TargetProperty::OPACITY); |
| 8746 animation->set_fill_mode(Animation::FILL_MODE_NONE); | 8756 animation->set_fill_mode(Animation::FILL_MODE_NONE); |
| 8747 animation->set_time_offset(base::TimeDelta::FromMilliseconds(-1000)); | 8757 animation->set_time_offset(base::TimeDelta::FromMilliseconds(-1000)); |
| 8748 AddAnimationToLayerWithExistingPlayer(child->id(), timeline(), | 8758 AddAnimationToElementWithExistingPlayer(child->element_id(), timeline(), |
| 8749 std::move(animation)); | 8759 std::move(animation)); |
| 8750 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); | 8760 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); |
| 8751 EXPECT_EQ(gfx::Rect(10, 10), grandchild->visible_layer_rect_for_testing()); | 8761 EXPECT_EQ(gfx::Rect(10, 10), grandchild->visible_layer_rect_for_testing()); |
| 8752 } | 8762 } |
| 8753 | 8763 |
| 8754 TEST_F(LayerTreeHostCommonTest, SkippingLayerImpl) { | 8764 TEST_F(LayerTreeHostCommonTest, SkippingLayerImpl) { |
| 8755 FakeImplTaskRunnerProvider task_runner_provider; | 8765 FakeImplTaskRunnerProvider task_runner_provider; |
| 8756 TestSharedBitmapManager shared_bitmap_manager; | 8766 TestSharedBitmapManager shared_bitmap_manager; |
| 8757 TestTaskGraphRunner task_graph_runner; | 8767 TestTaskGraphRunner task_graph_runner; |
| 8758 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &shared_bitmap_manager, | 8768 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &shared_bitmap_manager, |
| 8759 &task_graph_runner); | 8769 &task_graph_runner); |
| 8760 | 8770 |
| 8761 gfx::Transform identity; | 8771 gfx::Transform identity; |
| 8762 std::unique_ptr<LayerImpl> root = | 8772 std::unique_ptr<LayerImpl> root = |
| 8763 LayerImpl::Create(host_impl.active_tree(), 1); | 8773 CreateTestLayerImpl(host_impl.active_tree(), 1); |
| 8764 std::unique_ptr<LayerImpl> child = | 8774 std::unique_ptr<LayerImpl> child = |
| 8765 LayerImpl::Create(host_impl.active_tree(), 2); | 8775 CreateTestLayerImpl(host_impl.active_tree(), 2); |
| 8766 std::unique_ptr<LayerImpl> grandchild = | 8776 std::unique_ptr<LayerImpl> grandchild = |
| 8767 LayerImpl::Create(host_impl.active_tree(), 3); | 8777 CreateTestLayerImpl(host_impl.active_tree(), 3); |
| 8768 | 8778 |
| 8769 std::unique_ptr<FakePictureLayerImpl> greatgrandchild( | 8779 std::unique_ptr<FakePictureLayerImpl> greatgrandchild( |
| 8770 FakePictureLayerImpl::Create(host_impl.active_tree(), 4)); | 8780 FakePictureLayerImpl::Create(host_impl.active_tree(), 4)); |
| 8771 | 8781 |
| 8772 child->SetDrawsContent(true); | 8782 child->SetDrawsContent(true); |
| 8773 grandchild->SetDrawsContent(true); | 8783 grandchild->SetDrawsContent(true); |
| 8774 greatgrandchild->SetDrawsContent(true); | 8784 greatgrandchild->SetDrawsContent(true); |
| 8775 | 8785 |
| 8776 SetLayerPropertiesForTesting(root.get(), identity, gfx::Point3F(), | 8786 SetLayerPropertiesForTesting(root.get(), identity, gfx::Point3F(), |
| 8777 gfx::PointF(), gfx::Size(100, 100), true, false, | 8787 gfx::PointF(), gfx::Size(100, 100), true, false, |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8881 TransformOperations operation; | 8891 TransformOperations operation; |
| 8882 operation.AppendMatrix(transform); | 8892 operation.AppendMatrix(transform); |
| 8883 curve->AddKeyframe( | 8893 curve->AddKeyframe( |
| 8884 TransformKeyframe::Create(base::TimeDelta(), start, nullptr)); | 8894 TransformKeyframe::Create(base::TimeDelta(), start, nullptr)); |
| 8885 curve->AddKeyframe(TransformKeyframe::Create( | 8895 curve->AddKeyframe(TransformKeyframe::Create( |
| 8886 base::TimeDelta::FromSecondsD(1.0), operation, nullptr)); | 8896 base::TimeDelta::FromSecondsD(1.0), operation, nullptr)); |
| 8887 std::unique_ptr<Animation> transform_animation( | 8897 std::unique_ptr<Animation> transform_animation( |
| 8888 Animation::Create(std::move(curve), 3, 3, TargetProperty::TRANSFORM)); | 8898 Animation::Create(std::move(curve), 3, 3, TargetProperty::TRANSFORM)); |
| 8889 scoped_refptr<AnimationPlayer> player(AnimationPlayer::Create(1)); | 8899 scoped_refptr<AnimationPlayer> player(AnimationPlayer::Create(1)); |
| 8890 host_impl.active_tree()->animation_host()->RegisterPlayerForElement( | 8900 host_impl.active_tree()->animation_host()->RegisterPlayerForElement( |
| 8891 root_ptr->id(), player.get()); | 8901 root_ptr->element_id(), player.get()); |
| 8892 host_impl.active_tree() | 8902 host_impl.active_tree() |
| 8893 ->animation_host() | 8903 ->animation_host() |
| 8894 ->GetElementAnimationsForElementId(root_ptr->id()) | 8904 ->GetElementAnimationsForElementId(root_ptr->element_id()) |
| 8895 ->AddAnimation(std::move(transform_animation)); | 8905 ->AddAnimation(std::move(transform_animation)); |
| 8896 grandchild_ptr->set_visible_layer_rect(gfx::Rect()); | 8906 grandchild_ptr->set_visible_layer_rect(gfx::Rect()); |
| 8897 child_ptr->SetScrollClipLayer(root_ptr->id()); | 8907 child_ptr->SetScrollClipLayer(root_ptr->id()); |
| 8898 root_ptr->SetTransform(singular); | 8908 root_ptr->SetTransform(singular); |
| 8899 child_ptr->SetTransform(singular); | 8909 child_ptr->SetTransform(singular); |
| 8900 root_ptr->layer_tree_impl()->property_trees()->needs_rebuild = true; | 8910 root_ptr->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| 8901 ExecuteCalculateDrawPropertiesWithPropertyTrees(root_ptr); | 8911 ExecuteCalculateDrawPropertiesWithPropertyTrees(root_ptr); |
| 8902 EXPECT_EQ(gfx::Rect(0, 0), grandchild_ptr->visible_layer_rect()); | 8912 EXPECT_EQ(gfx::Rect(0, 0), grandchild_ptr->visible_layer_rect()); |
| 8903 | 8913 |
| 8904 host_impl.active_tree()->animation_host()->UnregisterPlayerForElement( | 8914 host_impl.active_tree()->animation_host()->UnregisterPlayerForElement( |
| 8905 root_ptr->id(), player.get()); | 8915 root_ptr->element_id(), player.get()); |
| 8906 } | 8916 } |
| 8907 | 8917 |
| 8908 TEST_F(LayerTreeHostCommonTest, LayerSkippingInSubtreeOfSingularTransform) { | 8918 TEST_F(LayerTreeHostCommonTest, LayerSkippingInSubtreeOfSingularTransform) { |
| 8909 LayerImpl* root = root_layer(); | 8919 LayerImpl* root = root_layer(); |
| 8910 LayerImpl* child = AddChild<LayerImpl>(root); | 8920 LayerImpl* child = AddChild<LayerImpl>(root); |
| 8911 LayerImpl* grand_child = AddChild<LayerImpl>(child); | 8921 LayerImpl* grand_child = AddChild<LayerImpl>(child); |
| 8912 | 8922 |
| 8913 gfx::Transform identity; | 8923 gfx::Transform identity; |
| 8914 SetLayerPropertiesForTesting(root, identity, gfx::Point3F(), gfx::PointF(), | 8924 SetLayerPropertiesForTesting(root, identity, gfx::Point3F(), gfx::PointF(), |
| 8915 gfx::Size(10, 10), true, false, true); | 8925 gfx::Size(10, 10), true, false, true); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 8936 TransformOperations operation; | 8946 TransformOperations operation; |
| 8937 operation.AppendMatrix(transform); | 8947 operation.AppendMatrix(transform); |
| 8938 curve->AddKeyframe( | 8948 curve->AddKeyframe( |
| 8939 TransformKeyframe::Create(base::TimeDelta(), start, nullptr)); | 8949 TransformKeyframe::Create(base::TimeDelta(), start, nullptr)); |
| 8940 curve->AddKeyframe(TransformKeyframe::Create( | 8950 curve->AddKeyframe(TransformKeyframe::Create( |
| 8941 base::TimeDelta::FromSecondsD(1.0), operation, nullptr)); | 8951 base::TimeDelta::FromSecondsD(1.0), operation, nullptr)); |
| 8942 std::unique_ptr<Animation> transform_animation( | 8952 std::unique_ptr<Animation> transform_animation( |
| 8943 Animation::Create(std::move(curve), 3, 3, TargetProperty::TRANSFORM)); | 8953 Animation::Create(std::move(curve), 3, 3, TargetProperty::TRANSFORM)); |
| 8944 scoped_refptr<AnimationPlayer> player(AnimationPlayer::Create(1)); | 8954 scoped_refptr<AnimationPlayer> player(AnimationPlayer::Create(1)); |
| 8945 host_impl()->active_tree()->animation_host()->RegisterPlayerForElement( | 8955 host_impl()->active_tree()->animation_host()->RegisterPlayerForElement( |
| 8946 grand_child->id(), player.get()); | 8956 grand_child->element_id(), player.get()); |
| 8947 host_impl() | 8957 host_impl() |
| 8948 ->active_tree() | 8958 ->active_tree() |
| 8949 ->animation_host() | 8959 ->animation_host() |
| 8950 ->GetElementAnimationsForElementId(grand_child->id()) | 8960 ->GetElementAnimationsForElementId(grand_child->element_id()) |
| 8951 ->AddAnimation(std::move(transform_animation)); | 8961 ->AddAnimation(std::move(transform_animation)); |
| 8952 | 8962 |
| 8953 ExecuteCalculateDrawProperties(root); | 8963 ExecuteCalculateDrawProperties(root); |
| 8954 EXPECT_EQ(gfx::Rect(0, 0), grand_child->visible_layer_rect()); | 8964 EXPECT_EQ(gfx::Rect(0, 0), grand_child->visible_layer_rect()); |
| 8955 EXPECT_EQ(gfx::Rect(0, 0), child->visible_layer_rect()); | 8965 EXPECT_EQ(gfx::Rect(0, 0), child->visible_layer_rect()); |
| 8956 | 8966 |
| 8957 host_impl()->active_tree()->animation_host()->UnregisterPlayerForElement( | 8967 host_impl()->active_tree()->animation_host()->UnregisterPlayerForElement( |
| 8958 grand_child->id(), player.get()); | 8968 grand_child->element_id(), player.get()); |
| 8959 } | 8969 } |
| 8960 | 8970 |
| 8961 TEST_F(LayerTreeHostCommonTest, SkippingPendingLayerImpl) { | 8971 TEST_F(LayerTreeHostCommonTest, SkippingPendingLayerImpl) { |
| 8962 FakeImplTaskRunnerProvider task_runner_provider; | 8972 FakeImplTaskRunnerProvider task_runner_provider; |
| 8963 TestSharedBitmapManager shared_bitmap_manager; | 8973 TestSharedBitmapManager shared_bitmap_manager; |
| 8964 TestTaskGraphRunner task_graph_runner; | 8974 TestTaskGraphRunner task_graph_runner; |
| 8965 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &shared_bitmap_manager, | 8975 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &shared_bitmap_manager, |
| 8966 &task_graph_runner); | 8976 &task_graph_runner); |
| 8967 | 8977 |
| 8968 gfx::Transform identity; | 8978 gfx::Transform identity; |
| 8969 host_impl.CreatePendingTree(); | 8979 host_impl.CreatePendingTree(); |
| 8970 std::unique_ptr<LayerImpl> root = | 8980 std::unique_ptr<LayerImpl> root = |
| 8971 LayerImpl::Create(host_impl.pending_tree(), 1); | 8981 CreateTestLayerImpl(host_impl.pending_tree(), 1); |
| 8972 std::unique_ptr<LayerImpl> child = | 8982 std::unique_ptr<LayerImpl> child = |
| 8973 LayerImpl::Create(host_impl.pending_tree(), 2); | 8983 CreateTestLayerImpl(host_impl.pending_tree(), 2); |
| 8974 std::unique_ptr<LayerImpl> grandchild = | 8984 std::unique_ptr<LayerImpl> grandchild = |
| 8975 LayerImpl::Create(host_impl.pending_tree(), 3); | 8985 CreateTestLayerImpl(host_impl.pending_tree(), 3); |
| 8976 | 8986 |
| 8977 std::unique_ptr<FakePictureLayerImpl> greatgrandchild( | 8987 std::unique_ptr<FakePictureLayerImpl> greatgrandchild( |
| 8978 FakePictureLayerImpl::Create(host_impl.pending_tree(), 4)); | 8988 FakePictureLayerImpl::Create(host_impl.pending_tree(), 4)); |
| 8979 | 8989 |
| 8980 child->SetDrawsContent(true); | 8990 child->SetDrawsContent(true); |
| 8981 grandchild->SetDrawsContent(true); | 8991 grandchild->SetDrawsContent(true); |
| 8982 greatgrandchild->SetDrawsContent(true); | 8992 greatgrandchild->SetDrawsContent(true); |
| 8983 | 8993 |
| 8984 SetLayerPropertiesForTesting(root.get(), identity, gfx::Point3F(), | 8994 SetLayerPropertiesForTesting(root.get(), identity, gfx::Point3F(), |
| 8985 gfx::PointF(), gfx::Size(100, 100), true, false, | 8995 gfx::PointF(), gfx::Size(100, 100), true, false, |
| (...skipping 21 matching lines...) Expand all Loading... |
| 9007 KeyframedFloatAnimationCurve::Create()); | 9017 KeyframedFloatAnimationCurve::Create()); |
| 9008 std::unique_ptr<TimingFunction> func = EaseTimingFunction::Create(); | 9018 std::unique_ptr<TimingFunction> func = EaseTimingFunction::Create(); |
| 9009 curve->AddKeyframe( | 9019 curve->AddKeyframe( |
| 9010 FloatKeyframe::Create(base::TimeDelta(), 0.9f, std::move(func))); | 9020 FloatKeyframe::Create(base::TimeDelta(), 0.9f, std::move(func))); |
| 9011 curve->AddKeyframe( | 9021 curve->AddKeyframe( |
| 9012 FloatKeyframe::Create(base::TimeDelta::FromSecondsD(1.0), 0.3f, nullptr)); | 9022 FloatKeyframe::Create(base::TimeDelta::FromSecondsD(1.0), 0.3f, nullptr)); |
| 9013 std::unique_ptr<Animation> animation( | 9023 std::unique_ptr<Animation> animation( |
| 9014 Animation::Create(std::move(curve), 3, 3, TargetProperty::OPACITY)); | 9024 Animation::Create(std::move(curve), 3, 3, TargetProperty::OPACITY)); |
| 9015 scoped_refptr<AnimationPlayer> player(AnimationPlayer::Create(1)); | 9025 scoped_refptr<AnimationPlayer> player(AnimationPlayer::Create(1)); |
| 9016 host_impl.active_tree()->animation_host()->RegisterPlayerForElement( | 9026 host_impl.active_tree()->animation_host()->RegisterPlayerForElement( |
| 9017 root_ptr->id(), player.get()); | 9027 root_ptr->element_id(), player.get()); |
| 9018 host_impl.active_tree() | 9028 host_impl.active_tree() |
| 9019 ->animation_host() | 9029 ->animation_host() |
| 9020 ->GetElementAnimationsForElementId(root_ptr->id()) | 9030 ->GetElementAnimationsForElementId(root_ptr->element_id()) |
| 9021 ->AddAnimation(std::move(animation)); | 9031 ->AddAnimation(std::move(animation)); |
| 9022 root_ptr->SetOpacity(0); | 9032 root_ptr->SetOpacity(0); |
| 9023 grandchild_ptr->set_visible_layer_rect(gfx::Rect()); | 9033 grandchild_ptr->set_visible_layer_rect(gfx::Rect()); |
| 9024 root_ptr->layer_tree_impl()->property_trees()->needs_rebuild = true; | 9034 root_ptr->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| 9025 ExecuteCalculateDrawPropertiesWithPropertyTrees(root_ptr); | 9035 ExecuteCalculateDrawPropertiesWithPropertyTrees(root_ptr); |
| 9026 EXPECT_EQ(gfx::Rect(10, 10), grandchild_ptr->visible_layer_rect()); | 9036 EXPECT_EQ(gfx::Rect(10, 10), grandchild_ptr->visible_layer_rect()); |
| 9027 | 9037 |
| 9028 host_impl.active_tree()->animation_host()->UnregisterPlayerForElement( | 9038 host_impl.active_tree()->animation_host()->UnregisterPlayerForElement( |
| 9029 root_ptr->id(), player.get()); | 9039 root_ptr->element_id(), player.get()); |
| 9030 } | 9040 } |
| 9031 | 9041 |
| 9032 TEST_F(LayerTreeHostCommonTest, SkippingLayer) { | 9042 TEST_F(LayerTreeHostCommonTest, SkippingLayer) { |
| 9033 gfx::Transform identity; | 9043 gfx::Transform identity; |
| 9034 LayerImpl* root = root_layer(); | 9044 LayerImpl* root = root_layer(); |
| 9035 LayerImpl* child = AddChild<LayerImpl>(root); | 9045 LayerImpl* child = AddChild<LayerImpl>(root); |
| 9036 | 9046 |
| 9037 SetLayerPropertiesForTesting(root, identity, gfx::Point3F(), gfx::PointF(), | 9047 SetLayerPropertiesForTesting(root, identity, gfx::Point3F(), gfx::PointF(), |
| 9038 gfx::Size(100, 100), true, false, true); | 9048 gfx::Size(100, 100), true, false, true); |
| 9039 SetLayerPropertiesForTesting(child, identity, gfx::Point3F(), gfx::PointF(), | 9049 SetLayerPropertiesForTesting(child, identity, gfx::Point3F(), gfx::PointF(), |
| (...skipping 28 matching lines...) Expand all Loading... |
| 9068 | 9078 |
| 9069 child->SetOpacity(0.f); | 9079 child->SetOpacity(0.f); |
| 9070 root->layer_tree_impl()->property_trees()->needs_rebuild = true; | 9080 root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| 9071 ExecuteCalculateDrawProperties(root); | 9081 ExecuteCalculateDrawProperties(root); |
| 9072 EXPECT_EQ(gfx::Rect(0, 0), child->visible_layer_rect()); | 9082 EXPECT_EQ(gfx::Rect(0, 0), child->visible_layer_rect()); |
| 9073 } | 9083 } |
| 9074 | 9084 |
| 9075 TEST_F(LayerTreeHostCommonTest, LayerTreeRebuildTest) { | 9085 TEST_F(LayerTreeHostCommonTest, LayerTreeRebuildTest) { |
| 9076 // Ensure that the treewalk in LayerTreeHostCommom:: | 9086 // Ensure that the treewalk in LayerTreeHostCommom:: |
| 9077 // PreCalculateMetaInformation happens when its required. | 9087 // PreCalculateMetaInformation happens when its required. |
| 9078 scoped_refptr<Layer> root = Layer::Create(); | 9088 scoped_refptr<Layer> root = CreateTestLayer(); |
| 9079 scoped_refptr<Layer> parent = Layer::Create(); | 9089 scoped_refptr<Layer> parent = CreateTestLayer(); |
| 9080 scoped_refptr<Layer> child = Layer::Create(); | 9090 scoped_refptr<Layer> child = CreateTestLayer(); |
| 9081 | 9091 |
| 9082 root->AddChild(parent); | 9092 root->AddChild(parent); |
| 9083 parent->AddChild(child); | 9093 parent->AddChild(child); |
| 9084 | 9094 |
| 9085 child->SetClipParent(root.get()); | 9095 child->SetClipParent(root.get()); |
| 9086 | 9096 |
| 9087 gfx::Transform identity; | 9097 gfx::Transform identity; |
| 9088 | 9098 |
| 9089 SetLayerPropertiesForTesting(root.get(), identity, gfx::Point3F(), | 9099 SetLayerPropertiesForTesting(root.get(), identity, gfx::Point3F(), |
| 9090 gfx::PointF(), gfx::Size(100, 100), true, false); | 9100 gfx::PointF(), gfx::Size(100, 100), true, false); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9128 child->SetTouchEventHandlerRegion(gfx::Rect()); | 9138 child->SetTouchEventHandlerRegion(gfx::Rect()); |
| 9129 ExecuteCalculateDrawProperties(root); | 9139 ExecuteCalculateDrawProperties(root); |
| 9130 EXPECT_EQ(root->layer_or_descendant_has_touch_handler(), false); | 9140 EXPECT_EQ(root->layer_or_descendant_has_touch_handler(), false); |
| 9131 } | 9141 } |
| 9132 | 9142 |
| 9133 TEST_F(LayerTreeHostCommonTest, ResetPropertyTreeIndices) { | 9143 TEST_F(LayerTreeHostCommonTest, ResetPropertyTreeIndices) { |
| 9134 gfx::Transform identity; | 9144 gfx::Transform identity; |
| 9135 gfx::Transform translate_z; | 9145 gfx::Transform translate_z; |
| 9136 translate_z.Translate3d(0, 0, 10); | 9146 translate_z.Translate3d(0, 0, 10); |
| 9137 | 9147 |
| 9138 scoped_refptr<Layer> root = Layer::Create(); | 9148 scoped_refptr<Layer> root = CreateTestLayer(); |
| 9139 SetLayerPropertiesForTesting(root.get(), identity, gfx::Point3F(), | 9149 SetLayerPropertiesForTesting(root.get(), identity, gfx::Point3F(), |
| 9140 gfx::PointF(), gfx::Size(800, 800), true, false); | 9150 gfx::PointF(), gfx::Size(800, 800), true, false); |
| 9141 | 9151 |
| 9142 scoped_refptr<Layer> child = Layer::Create(); | 9152 scoped_refptr<Layer> child = CreateTestLayer(); |
| 9143 SetLayerPropertiesForTesting(child.get(), translate_z, gfx::Point3F(), | 9153 SetLayerPropertiesForTesting(child.get(), translate_z, gfx::Point3F(), |
| 9144 gfx::PointF(), gfx::Size(100, 100), true, false); | 9154 gfx::PointF(), gfx::Size(100, 100), true, false); |
| 9145 | 9155 |
| 9146 root->AddChild(child); | 9156 root->AddChild(child); |
| 9147 | 9157 |
| 9148 host()->SetRootLayer(root); | 9158 host()->SetRootLayer(root); |
| 9149 | 9159 |
| 9150 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); | 9160 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); |
| 9151 EXPECT_NE(-1, child->transform_tree_index()); | 9161 EXPECT_NE(-1, child->transform_tree_index()); |
| 9152 | 9162 |
| (...skipping 574 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9727 gfx::Transform transform; | 9737 gfx::Transform transform; |
| 9728 transform.Translate(10, 10); | 9738 transform.Translate(10, 10); |
| 9729 | 9739 |
| 9730 SetLayerPropertiesForTesting(root, identity_matrix, gfx::Point3F(), | 9740 SetLayerPropertiesForTesting(root, identity_matrix, gfx::Point3F(), |
| 9731 gfx::PointF(), gfx::Size(30, 30), true, false, | 9741 gfx::PointF(), gfx::Size(30, 30), true, false, |
| 9732 true); | 9742 true); |
| 9733 SetLayerPropertiesForTesting(child, transform, gfx::Point3F(), gfx::PointF(), | 9743 SetLayerPropertiesForTesting(child, transform, gfx::Point3F(), gfx::PointF(), |
| 9734 gfx::Size(30, 30), true, false, false); | 9744 gfx::Size(30, 30), true, false, false); |
| 9735 root->SetDrawsContent(true); | 9745 root->SetDrawsContent(true); |
| 9736 child->SetDrawsContent(false); | 9746 child->SetDrawsContent(false); |
| 9737 child->SetMaskLayer(LayerImpl::Create(root->layer_tree_impl(), 100)); | 9747 child->SetMaskLayer(CreateTestLayerImpl(root->layer_tree_impl(), 100)); |
| 9738 ExecuteCalculateDrawProperties(root); | 9748 ExecuteCalculateDrawProperties(root); |
| 9739 | 9749 |
| 9740 EXPECT_TRANSFORMATION_MATRIX_EQ(transform, | 9750 EXPECT_TRANSFORMATION_MATRIX_EQ(transform, |
| 9741 child->mask_layer()->ScreenSpaceTransform()); | 9751 child->mask_layer()->ScreenSpaceTransform()); |
| 9742 transform.Translate(10, 10); | 9752 transform.Translate(10, 10); |
| 9743 child->SetTransform(transform); | 9753 child->SetTransform(transform); |
| 9744 child->SetDrawsContent(true); | 9754 child->SetDrawsContent(true); |
| 9745 root->layer_tree_impl()->property_trees()->needs_rebuild = true; | 9755 root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| 9746 ExecuteCalculateDrawProperties(root); | 9756 ExecuteCalculateDrawProperties(root); |
| 9747 EXPECT_TRANSFORMATION_MATRIX_EQ(transform, | 9757 EXPECT_TRANSFORMATION_MATRIX_EQ(transform, |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9910 // +----node---owner:5, id:6 | 9920 // +----node---owner:5, id:6 |
| 9911 // | 9921 // |
| 9912 // Extra check: | 9922 // Extra check: |
| 9913 // scroll_tree_index() of: | 9923 // scroll_tree_index() of: |
| 9914 // grand_child10:3 | 9924 // grand_child10:3 |
| 9915 // parent3:1 | 9925 // parent3:1 |
| 9916 // child8:4 | 9926 // child8:4 |
| 9917 // parent4:1 | 9927 // parent4:1 |
| 9918 // child9:1 | 9928 // child9:1 |
| 9919 // grand_child12:1 | 9929 // grand_child12:1 |
| 9920 scoped_refptr<Layer> root1 = Layer::Create(); | 9930 scoped_refptr<Layer> root1 = CreateTestLayer(); |
| 9921 scoped_refptr<Layer> page_scale_layer = Layer::Create(); | 9931 scoped_refptr<Layer> page_scale_layer = CreateTestLayer(); |
| 9922 scoped_refptr<Layer> parent2 = Layer::Create(); | 9932 scoped_refptr<Layer> parent2 = CreateTestLayer(); |
| 9923 scoped_refptr<Layer> parent3 = Layer::Create(); | 9933 scoped_refptr<Layer> parent3 = CreateTestLayer(); |
| 9924 scoped_refptr<Layer> parent4 = Layer::Create(); | 9934 scoped_refptr<Layer> parent4 = CreateTestLayer(); |
| 9925 scoped_refptr<Layer> parent5 = Layer::Create(); | 9935 scoped_refptr<Layer> parent5 = CreateTestLayer(); |
| 9926 scoped_refptr<Layer> child6 = Layer::Create(); | 9936 scoped_refptr<Layer> child6 = CreateTestLayer(); |
| 9927 scoped_refptr<Layer> child7 = Layer::Create(); | 9937 scoped_refptr<Layer> child7 = CreateTestLayer(); |
| 9928 scoped_refptr<Layer> child8 = Layer::Create(); | 9938 scoped_refptr<Layer> child8 = CreateTestLayer(); |
| 9929 scoped_refptr<Layer> child9 = Layer::Create(); | 9939 scoped_refptr<Layer> child9 = CreateTestLayer(); |
| 9930 scoped_refptr<Layer> grand_child10 = Layer::Create(); | 9940 scoped_refptr<Layer> grand_child10 = CreateTestLayer(); |
| 9931 scoped_refptr<Layer> grand_child11 = Layer::Create(); | 9941 scoped_refptr<Layer> grand_child11 = CreateTestLayer(); |
| 9932 scoped_refptr<Layer> grand_child12 = Layer::Create(); | 9942 scoped_refptr<Layer> grand_child12 = CreateTestLayer(); |
| 9933 | 9943 |
| 9934 root1->AddChild(page_scale_layer); | 9944 root1->AddChild(page_scale_layer); |
| 9935 page_scale_layer->AddChild(parent2); | 9945 page_scale_layer->AddChild(parent2); |
| 9936 page_scale_layer->AddChild(parent3); | 9946 page_scale_layer->AddChild(parent3); |
| 9937 page_scale_layer->AddChild(parent4); | 9947 page_scale_layer->AddChild(parent4); |
| 9938 page_scale_layer->AddChild(parent5); | 9948 page_scale_layer->AddChild(parent5); |
| 9939 parent2->AddChild(child6); | 9949 parent2->AddChild(child6); |
| 9940 parent3->AddChild(child7); | 9950 parent3->AddChild(child7); |
| 9941 parent3->AddChild(child8); | 9951 parent3->AddChild(child8); |
| 9942 parent4->AddChild(child9); | 9952 parent4->AddChild(child9); |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9985 property_tree_root->data.contains_non_fast_scrollable_region = false; | 9995 property_tree_root->data.contains_non_fast_scrollable_region = false; |
| 9986 property_tree_root->data.transform_id = kRootPropertyTreeNodeId; | 9996 property_tree_root->data.transform_id = kRootPropertyTreeNodeId; |
| 9987 | 9997 |
| 9988 // The node owned by root1 | 9998 // The node owned by root1 |
| 9989 ScrollNode scroll_root1; | 9999 ScrollNode scroll_root1; |
| 9990 scroll_root1.id = 1; | 10000 scroll_root1.id = 1; |
| 9991 scroll_root1.owner_id = root1->id(); | 10001 scroll_root1.owner_id = root1->id(); |
| 9992 scroll_root1.data.user_scrollable_horizontal = true; | 10002 scroll_root1.data.user_scrollable_horizontal = true; |
| 9993 scroll_root1.data.user_scrollable_vertical = true; | 10003 scroll_root1.data.user_scrollable_vertical = true; |
| 9994 scroll_root1.data.transform_id = root1->transform_tree_index(); | 10004 scroll_root1.data.transform_id = root1->transform_tree_index(); |
| 10005 scroll_root1.data.element_id = root1->element_id(); |
| 9995 expected_scroll_tree.Insert(scroll_root1, 0); | 10006 expected_scroll_tree.Insert(scroll_root1, 0); |
| 9996 | 10007 |
| 9997 // The node owned by parent2 | 10008 // The node owned by parent2 |
| 9998 ScrollNode scroll_parent2; | 10009 ScrollNode scroll_parent2; |
| 9999 scroll_parent2.id = 2; | 10010 scroll_parent2.id = 2; |
| 10000 scroll_parent2.owner_id = parent2->id(); | 10011 scroll_parent2.owner_id = parent2->id(); |
| 10001 scroll_parent2.data.scrollable = true; | 10012 scroll_parent2.data.scrollable = true; |
| 10002 scroll_parent2.data.main_thread_scrolling_reasons = | 10013 scroll_parent2.data.main_thread_scrolling_reasons = |
| 10003 parent2->main_thread_scrolling_reasons(); | 10014 parent2->main_thread_scrolling_reasons(); |
| 10004 scroll_parent2.data.scroll_clip_layer_bounds = root1->bounds(); | 10015 scroll_parent2.data.scroll_clip_layer_bounds = root1->bounds(); |
| 10005 scroll_parent2.data.bounds = parent2->bounds(); | 10016 scroll_parent2.data.bounds = parent2->bounds(); |
| 10006 scroll_parent2.data.max_scroll_offset_affected_by_page_scale = true; | 10017 scroll_parent2.data.max_scroll_offset_affected_by_page_scale = true; |
| 10007 scroll_parent2.data.is_inner_viewport_scroll_layer = true; | 10018 scroll_parent2.data.is_inner_viewport_scroll_layer = true; |
| 10008 scroll_parent2.data.user_scrollable_horizontal = true; | 10019 scroll_parent2.data.user_scrollable_horizontal = true; |
| 10009 scroll_parent2.data.user_scrollable_vertical = true; | 10020 scroll_parent2.data.user_scrollable_vertical = true; |
| 10010 scroll_parent2.data.transform_id = parent2->transform_tree_index(); | 10021 scroll_parent2.data.transform_id = parent2->transform_tree_index(); |
| 10022 scroll_parent2.data.element_id = parent2->element_id(); |
| 10011 expected_scroll_tree.Insert(scroll_parent2, 1); | 10023 expected_scroll_tree.Insert(scroll_parent2, 1); |
| 10012 | 10024 |
| 10013 // The node owned by child6 | 10025 // The node owned by child6 |
| 10014 ScrollNode scroll_child6; | 10026 ScrollNode scroll_child6; |
| 10015 scroll_child6.id = 3; | 10027 scroll_child6.id = 3; |
| 10016 scroll_child6.owner_id = child6->id(); | 10028 scroll_child6.owner_id = child6->id(); |
| 10017 scroll_child6.data.main_thread_scrolling_reasons = | 10029 scroll_child6.data.main_thread_scrolling_reasons = |
| 10018 child6->main_thread_scrolling_reasons(); | 10030 child6->main_thread_scrolling_reasons(); |
| 10019 scroll_child6.data.should_flatten = true; | 10031 scroll_child6.data.should_flatten = true; |
| 10020 scroll_child6.data.user_scrollable_horizontal = true; | 10032 scroll_child6.data.user_scrollable_horizontal = true; |
| 10021 scroll_child6.data.user_scrollable_vertical = true; | 10033 scroll_child6.data.user_scrollable_vertical = true; |
| 10022 scroll_child6.data.transform_id = child6->transform_tree_index(); | 10034 scroll_child6.data.transform_id = child6->transform_tree_index(); |
| 10035 scroll_child6.data.element_id = child6->element_id(); |
| 10023 expected_scroll_tree.Insert(scroll_child6, 2); | 10036 expected_scroll_tree.Insert(scroll_child6, 2); |
| 10024 | 10037 |
| 10025 // The node owned by child7, child7 also owns a transform node | 10038 // The node owned by child7, child7 also owns a transform node |
| 10026 ScrollNode scroll_child7; | 10039 ScrollNode scroll_child7; |
| 10027 scroll_child7.id = 4; | 10040 scroll_child7.id = 4; |
| 10028 scroll_child7.owner_id = child7->id(); | 10041 scroll_child7.owner_id = child7->id(); |
| 10029 scroll_child7.data.scrollable = true; | 10042 scroll_child7.data.scrollable = true; |
| 10030 scroll_child7.data.scroll_clip_layer_bounds = parent3->bounds(); | 10043 scroll_child7.data.scroll_clip_layer_bounds = parent3->bounds(); |
| 10031 scroll_child7.data.bounds = child7->bounds(); | 10044 scroll_child7.data.bounds = child7->bounds(); |
| 10032 scroll_child7.data.user_scrollable_horizontal = true; | 10045 scroll_child7.data.user_scrollable_horizontal = true; |
| 10033 scroll_child7.data.user_scrollable_vertical = true; | 10046 scroll_child7.data.user_scrollable_vertical = true; |
| 10034 scroll_child7.data.transform_id = child7->transform_tree_index(); | 10047 scroll_child7.data.transform_id = child7->transform_tree_index(); |
| 10048 scroll_child7.data.element_id = child7->element_id(); |
| 10035 expected_scroll_tree.Insert(scroll_child7, 1); | 10049 expected_scroll_tree.Insert(scroll_child7, 1); |
| 10036 | 10050 |
| 10037 // The node owned by grand_child11, grand_child11 also owns a transform node | 10051 // The node owned by grand_child11, grand_child11 also owns a transform node |
| 10038 ScrollNode scroll_grand_child11; | 10052 ScrollNode scroll_grand_child11; |
| 10039 scroll_grand_child11.id = 5; | 10053 scroll_grand_child11.id = 5; |
| 10040 scroll_grand_child11.owner_id = grand_child11->id(); | 10054 scroll_grand_child11.owner_id = grand_child11->id(); |
| 10041 scroll_grand_child11.data.scrollable = true; | 10055 scroll_grand_child11.data.scrollable = true; |
| 10042 scroll_grand_child11.data.user_scrollable_horizontal = true; | 10056 scroll_grand_child11.data.user_scrollable_horizontal = true; |
| 10043 scroll_grand_child11.data.user_scrollable_vertical = true; | 10057 scroll_grand_child11.data.user_scrollable_vertical = true; |
| 10044 scroll_grand_child11.data.transform_id = | 10058 scroll_grand_child11.data.transform_id = |
| 10045 grand_child11->transform_tree_index(); | 10059 grand_child11->transform_tree_index(); |
| 10060 scroll_grand_child11.data.element_id = grand_child11->element_id(); |
| 10046 expected_scroll_tree.Insert(scroll_grand_child11, 4); | 10061 expected_scroll_tree.Insert(scroll_grand_child11, 4); |
| 10047 | 10062 |
| 10048 // The node owned by parent5 | 10063 // The node owned by parent5 |
| 10049 ScrollNode scroll_parent5; | 10064 ScrollNode scroll_parent5; |
| 10050 scroll_parent5.id = 8; | 10065 scroll_parent5.id = 8; |
| 10051 scroll_parent5.owner_id = parent5->id(); | 10066 scroll_parent5.owner_id = parent5->id(); |
| 10052 scroll_parent5.data.contains_non_fast_scrollable_region = true; | 10067 scroll_parent5.data.contains_non_fast_scrollable_region = true; |
| 10053 scroll_parent5.data.bounds = gfx::Size(10, 10); | 10068 scroll_parent5.data.bounds = gfx::Size(10, 10); |
| 10054 scroll_parent5.data.should_flatten = true; | 10069 scroll_parent5.data.should_flatten = true; |
| 10055 scroll_parent5.data.user_scrollable_horizontal = true; | 10070 scroll_parent5.data.user_scrollable_horizontal = true; |
| 10056 scroll_parent5.data.user_scrollable_vertical = true; | 10071 scroll_parent5.data.user_scrollable_vertical = true; |
| 10057 scroll_parent5.data.transform_id = parent5->transform_tree_index(); | 10072 scroll_parent5.data.transform_id = parent5->transform_tree_index(); |
| 10073 scroll_parent5.data.element_id = parent5->element_id(); |
| 10058 expected_scroll_tree.Insert(scroll_parent5, 1); | 10074 expected_scroll_tree.Insert(scroll_parent5, 1); |
| 10059 | 10075 |
| 10060 expected_scroll_tree.SetScrollOffset(parent2->id(), gfx::ScrollOffset(0, 0)); | 10076 expected_scroll_tree.SetScrollOffset(parent2->id(), gfx::ScrollOffset(0, 0)); |
| 10061 expected_scroll_tree.SetScrollOffset(child7->id(), gfx::ScrollOffset(0, 0)); | 10077 expected_scroll_tree.SetScrollOffset(child7->id(), gfx::ScrollOffset(0, 0)); |
| 10062 expected_scroll_tree.SetScrollOffset(grand_child11->id(), | 10078 expected_scroll_tree.SetScrollOffset(grand_child11->id(), |
| 10063 gfx::ScrollOffset(0, 0)); | 10079 gfx::ScrollOffset(0, 0)); |
| 10064 expected_scroll_tree.set_needs_update(false); | 10080 expected_scroll_tree.set_needs_update(false); |
| 10065 | 10081 |
| 10066 EXPECT_EQ(expected_scroll_tree, scroll_tree); | 10082 EXPECT_EQ(expected_scroll_tree, scroll_tree); |
| 10067 | 10083 |
| 10068 // Check other layers' scroll_tree_index | 10084 // Check other layers' scroll_tree_index |
| 10069 EXPECT_EQ(scroll_root1.id, page_scale_layer->scroll_tree_index()); | 10085 EXPECT_EQ(scroll_root1.id, page_scale_layer->scroll_tree_index()); |
| 10070 EXPECT_EQ(scroll_child6.id, grand_child10->scroll_tree_index()); | 10086 EXPECT_EQ(scroll_child6.id, grand_child10->scroll_tree_index()); |
| 10071 EXPECT_EQ(scroll_root1.id, parent3->scroll_tree_index()); | 10087 EXPECT_EQ(scroll_root1.id, parent3->scroll_tree_index()); |
| 10072 EXPECT_EQ(scroll_child7.id, child8->scroll_tree_index()); | 10088 EXPECT_EQ(scroll_child7.id, child8->scroll_tree_index()); |
| 10073 EXPECT_EQ(scroll_root1.id, parent4->scroll_tree_index()); | 10089 EXPECT_EQ(scroll_root1.id, parent4->scroll_tree_index()); |
| 10074 EXPECT_EQ(scroll_root1.id, child9->scroll_tree_index()); | 10090 EXPECT_EQ(scroll_root1.id, child9->scroll_tree_index()); |
| 10075 EXPECT_EQ(scroll_root1.id, grand_child12->scroll_tree_index()); | 10091 EXPECT_EQ(scroll_root1.id, grand_child12->scroll_tree_index()); |
| 10076 } | 10092 } |
| 10077 | 10093 |
| 10078 } // namespace | 10094 } // namespace |
| 10079 } // namespace cc | 10095 } // namespace cc |
| OLD | NEW |