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

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

Issue 1944623002: CC Animation: Use ElementId to attach CC animation players. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@erasedomids
Patch Set: Let CC clients generate their own ElementIds locally. Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2011 The Chromium Authors. All rights reserved. 1 // Copyright 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "cc/trees/layer_tree_host_common.h" 5 #include "cc/trees/layer_tree_host_common.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <memory> 10 #include <memory>
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
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(NextTestElementId()); }
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
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
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
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
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
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
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 584 matching lines...) Expand 10 before | Expand all | Expand 10 after
4161 EXPECT_EQ(gfx::Rect(0, 0, 50, 50), child2->visible_layer_rect()); 4162 EXPECT_EQ(gfx::Rect(0, 0, 50, 50), child2->visible_layer_rect());
4162 EXPECT_EQ(gfx::Rect(0, 0, 50, 50), child3->visible_layer_rect()); 4163 EXPECT_EQ(gfx::Rect(0, 0, 50, 50), child3->visible_layer_rect());
4163 } 4164 }
4164 4165
4165 TEST_F(LayerTreeHostCommonTest, BackFaceCullingWithoutPreserves3d) { 4166 TEST_F(LayerTreeHostCommonTest, BackFaceCullingWithoutPreserves3d) {
4166 // Verify the behavior of back-face culling when there are no preserve-3d 4167 // Verify the behavior of back-face culling when there are no preserve-3d
4167 // layers. Note that 3d transforms still apply in this case, but they are 4168 // layers. Note that 3d transforms still apply in this case, but they are
4168 // "flattened" to each parent layer according to current W3C spec. 4169 // "flattened" to each parent layer according to current W3C spec.
4169 4170
4170 const gfx::Transform identity_matrix; 4171 const gfx::Transform identity_matrix;
4171 scoped_refptr<Layer> parent = Layer::Create(); 4172 scoped_refptr<Layer> parent = CreateTestLayer();
4172 scoped_refptr<LayerWithForcedDrawsContent> front_facing_child = 4173 scoped_refptr<LayerWithForcedDrawsContent> front_facing_child =
4173 make_scoped_refptr(new LayerWithForcedDrawsContent()); 4174 make_scoped_refptr(new LayerWithForcedDrawsContent());
4174 scoped_refptr<LayerWithForcedDrawsContent> back_facing_child = 4175 scoped_refptr<LayerWithForcedDrawsContent> back_facing_child =
4175 make_scoped_refptr(new LayerWithForcedDrawsContent()); 4176 make_scoped_refptr(new LayerWithForcedDrawsContent());
4176 scoped_refptr<LayerWithForcedDrawsContent> front_facing_surface = 4177 scoped_refptr<LayerWithForcedDrawsContent> front_facing_surface =
4177 make_scoped_refptr(new LayerWithForcedDrawsContent()); 4178 make_scoped_refptr(new LayerWithForcedDrawsContent());
4178 scoped_refptr<LayerWithForcedDrawsContent> back_facing_surface = 4179 scoped_refptr<LayerWithForcedDrawsContent> back_facing_surface =
4179 make_scoped_refptr(new LayerWithForcedDrawsContent()); 4180 make_scoped_refptr(new LayerWithForcedDrawsContent());
4180 scoped_refptr<LayerWithForcedDrawsContent> 4181 scoped_refptr<LayerWithForcedDrawsContent>
4181 front_facing_child_of_front_facing_surface = 4182 front_facing_child_of_front_facing_surface =
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after
4424 } 4425 }
4425 4426
4426 TEST_F(LayerTreeHostCommonTest, BackFaceCullingWithAnimatingTransforms) { 4427 TEST_F(LayerTreeHostCommonTest, BackFaceCullingWithAnimatingTransforms) {
4427 // Verify that layers are appropriately culled when their back face is showing 4428 // Verify that layers are appropriately culled when their back face is showing
4428 // and they are not double sided, while animations are going on. 4429 // and they are not double sided, while animations are going on.
4429 // 4430 //
4430 // Layers that are animating do not get culled on the main thread, as their 4431 // Layers that are animating do not get culled on the main thread, as their
4431 // transforms should be treated as "unknown" so we can not be sure that their 4432 // transforms should be treated as "unknown" so we can not be sure that their
4432 // back face is really showing. 4433 // back face is really showing.
4433 const gfx::Transform identity_matrix; 4434 const gfx::Transform identity_matrix;
4434 scoped_refptr<Layer> parent = Layer::Create(); 4435 scoped_refptr<Layer> parent = CreateTestLayer();
4435 scoped_refptr<LayerWithForcedDrawsContent> child = 4436 scoped_refptr<LayerWithForcedDrawsContent> child =
4436 make_scoped_refptr(new LayerWithForcedDrawsContent()); 4437 make_scoped_refptr(new LayerWithForcedDrawsContent());
4437 scoped_refptr<LayerWithForcedDrawsContent> animating_surface = 4438 scoped_refptr<LayerWithForcedDrawsContent> animating_surface =
4438 make_scoped_refptr(new LayerWithForcedDrawsContent()); 4439 make_scoped_refptr(new LayerWithForcedDrawsContent());
4439 scoped_refptr<LayerWithForcedDrawsContent> child_of_animating_surface = 4440 scoped_refptr<LayerWithForcedDrawsContent> child_of_animating_surface =
4440 make_scoped_refptr(new LayerWithForcedDrawsContent()); 4441 make_scoped_refptr(new LayerWithForcedDrawsContent());
4441 scoped_refptr<LayerWithForcedDrawsContent> animating_child = 4442 scoped_refptr<LayerWithForcedDrawsContent> animating_child =
4442 make_scoped_refptr(new LayerWithForcedDrawsContent()); 4443 make_scoped_refptr(new LayerWithForcedDrawsContent());
4443 scoped_refptr<LayerWithForcedDrawsContent> child2 = 4444 scoped_refptr<LayerWithForcedDrawsContent> child2 =
4444 make_scoped_refptr(new LayerWithForcedDrawsContent()); 4445 make_scoped_refptr(new LayerWithForcedDrawsContent());
(...skipping 15 matching lines...) Expand all
4460 4461
4461 gfx::Transform backface_matrix; 4462 gfx::Transform backface_matrix;
4462 backface_matrix.Translate(50.0, 50.0); 4463 backface_matrix.Translate(50.0, 50.0);
4463 backface_matrix.RotateAboutYAxis(180.0); 4464 backface_matrix.RotateAboutYAxis(180.0);
4464 backface_matrix.Translate(-50.0, -50.0); 4465 backface_matrix.Translate(-50.0, -50.0);
4465 4466
4466 // Make our render surface. 4467 // Make our render surface.
4467 animating_surface->SetForceRenderSurfaceForTesting(true); 4468 animating_surface->SetForceRenderSurfaceForTesting(true);
4468 4469
4469 // Animate the transform on the render surface. 4470 // Animate the transform on the render surface.
4470 AddAnimatedTransformToLayerWithPlayer(animating_surface->id(), timeline(), 4471 AddAnimatedTransformToElementWithPlayer(animating_surface->element_id(),
4471 10.0, 30, 0); 4472 timeline(), 10.0, 30, 0);
4472 // This is just an animating layer, not a surface. 4473 // This is just an animating layer, not a surface.
4473 AddAnimatedTransformToLayerWithPlayer(animating_child->id(), timeline(), 10.0, 4474 AddAnimatedTransformToElementWithPlayer(animating_child->element_id(),
4474 30, 0); 4475 timeline(), 10.0, 30, 0);
4475 4476
4476 SetLayerPropertiesForTesting(parent.get(), 4477 SetLayerPropertiesForTesting(parent.get(),
4477 identity_matrix, 4478 identity_matrix,
4478 gfx::Point3F(), 4479 gfx::Point3F(),
4479 gfx::PointF(), 4480 gfx::PointF(),
4480 gfx::Size(100, 100), 4481 gfx::Size(100, 100),
4481 true, 4482 true,
4482 false); 4483 false);
4483 SetLayerPropertiesForTesting(child.get(), 4484 SetLayerPropertiesForTesting(child.get(),
4484 backface_matrix, 4485 backface_matrix,
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
4550 EXPECT_EQ(child_of_animating_surface->visible_layer_rect_for_testing(), 4551 EXPECT_EQ(child_of_animating_surface->visible_layer_rect_for_testing(),
4551 gfx::Rect(child_of_animating_surface->bounds())); 4552 gfx::Rect(child_of_animating_surface->bounds()));
4552 } 4553 }
4553 4554
4554 TEST_F(LayerTreeHostCommonTest, 4555 TEST_F(LayerTreeHostCommonTest,
4555 BackFaceCullingWithPreserves3dForFlatteningSurface) { 4556 BackFaceCullingWithPreserves3dForFlatteningSurface) {
4556 // Verify the behavior of back-face culling for a render surface that is 4557 // Verify the behavior of back-face culling for a render surface that is
4557 // created when it flattens its subtree, and its parent has preserves-3d. 4558 // created when it flattens its subtree, and its parent has preserves-3d.
4558 4559
4559 const gfx::Transform identity_matrix; 4560 const gfx::Transform identity_matrix;
4560 scoped_refptr<Layer> parent = Layer::Create(); 4561 scoped_refptr<Layer> parent = CreateTestLayer();
4561 scoped_refptr<LayerWithForcedDrawsContent> front_facing_surface = 4562 scoped_refptr<LayerWithForcedDrawsContent> front_facing_surface =
4562 make_scoped_refptr(new LayerWithForcedDrawsContent()); 4563 make_scoped_refptr(new LayerWithForcedDrawsContent());
4563 scoped_refptr<LayerWithForcedDrawsContent> back_facing_surface = 4564 scoped_refptr<LayerWithForcedDrawsContent> back_facing_surface =
4564 make_scoped_refptr(new LayerWithForcedDrawsContent()); 4565 make_scoped_refptr(new LayerWithForcedDrawsContent());
4565 scoped_refptr<LayerWithForcedDrawsContent> child1 = 4566 scoped_refptr<LayerWithForcedDrawsContent> child1 =
4566 make_scoped_refptr(new LayerWithForcedDrawsContent()); 4567 make_scoped_refptr(new LayerWithForcedDrawsContent());
4567 scoped_refptr<LayerWithForcedDrawsContent> child2 = 4568 scoped_refptr<LayerWithForcedDrawsContent> child2 =
4568 make_scoped_refptr(new LayerWithForcedDrawsContent()); 4569 make_scoped_refptr(new LayerWithForcedDrawsContent());
4569 4570
4570 parent->AddChild(front_facing_surface); 4571 parent->AddChild(front_facing_surface);
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after
4910 LayerImpl* child = AddChildToRoot<LayerImpl>(); 4911 LayerImpl* child = AddChildToRoot<LayerImpl>();
4911 child->SetDrawsContent(true); 4912 child->SetDrawsContent(true);
4912 SetLayerPropertiesForTesting(child, identity_matrix, gfx::Point3F(), 4913 SetLayerPropertiesForTesting(child, identity_matrix, gfx::Point3F(),
4913 gfx::PointF(2.f, 2.f), gfx::Size(10, 10), false, 4914 gfx::PointF(2.f, 2.f), gfx::Size(10, 10), false,
4914 true, true); 4915 true, true);
4915 4916
4916 gfx::Transform replica_transform; 4917 gfx::Transform replica_transform;
4917 replica_transform.Scale(1.0, -1.0); 4918 replica_transform.Scale(1.0, -1.0);
4918 4919
4919 std::unique_ptr<LayerImpl> replica = 4920 std::unique_ptr<LayerImpl> replica =
4920 LayerImpl::Create(host_impl()->active_tree(), 7); 4921 CreateTestLayerImpl(host_impl()->active_tree(), 7);
4921 SetLayerPropertiesForTesting(replica.get(), replica_transform, gfx::Point3F(), 4922 SetLayerPropertiesForTesting(replica.get(), replica_transform, gfx::Point3F(),
4922 gfx::PointF(2.f, 2.f), gfx::Size(10, 10), false, 4923 gfx::PointF(2.f, 2.f), gfx::Size(10, 10), false,
4923 true, false); 4924 true, false);
4924 // We need to set parent on replica layer for property tree building. 4925 // We need to set parent on replica layer for property tree building.
4925 replica->SetParent(child); 4926 replica->SetParent(child);
4926 child->SetReplicaLayer(std::move(replica)); 4927 child->SetReplicaLayer(std::move(replica));
4927 4928
4928 // This layer should end up in the same surface as child, with the same draw 4929 // This layer should end up in the same surface as child, with the same draw
4929 // and screen space transforms. 4930 // and screen space transforms.
4930 LayerImpl* duplicate_child_non_owner = AddChild<LayerImpl>(child); 4931 LayerImpl* duplicate_child_non_owner = AddChild<LayerImpl>(child);
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
5023 5024
5024 LayerImpl* child = AddChildToRoot<LayerImpl>(); 5025 LayerImpl* child = AddChildToRoot<LayerImpl>();
5025 child->SetDrawsContent(true); 5026 child->SetDrawsContent(true);
5026 SetLayerPropertiesForTesting(child, identity_matrix, gfx::Point3F(), 5027 SetLayerPropertiesForTesting(child, identity_matrix, gfx::Point3F(),
5027 gfx::PointF(), gfx::Size(13, 11), false, true, 5028 gfx::PointF(), gfx::Size(13, 11), false, true,
5028 true); 5029 true);
5029 5030
5030 gfx::Transform replica_transform; 5031 gfx::Transform replica_transform;
5031 replica_transform.Scale(1.0, -1.0); 5032 replica_transform.Scale(1.0, -1.0);
5032 std::unique_ptr<LayerImpl> replica = 5033 std::unique_ptr<LayerImpl> replica =
5033 LayerImpl::Create(host_impl()->active_tree(), 7); 5034 CreateTestLayerImpl(host_impl()->active_tree(), 7);
5034 SetLayerPropertiesForTesting(replica.get(), replica_transform, gfx::Point3F(), 5035 SetLayerPropertiesForTesting(replica.get(), replica_transform, gfx::Point3F(),
5035 gfx::PointF(), gfx::Size(13, 11), false, true, 5036 gfx::PointF(), gfx::Size(13, 11), false, true,
5036 false); 5037 false);
5037 child->SetReplicaLayer(std::move(replica)); 5038 child->SetReplicaLayer(std::move(replica));
5038 5039
5039 float device_scale_factor = 1.7f; 5040 float device_scale_factor = 1.7f;
5040 ExecuteCalculateDrawProperties(parent, device_scale_factor); 5041 ExecuteCalculateDrawProperties(parent, device_scale_factor);
5041 5042
5042 // We should have two render surfaces. The root's render surface and child's 5043 // We should have two render surfaces. The root's render surface and child's
5043 // render surface (it needs one because it has a replica layer). 5044 // render surface (it needs one because it has a replica layer).
(...skipping 14 matching lines...) Expand all
5058 child->render_surface()->replica_draw_transform()); 5059 child->render_surface()->replica_draw_transform());
5059 5060
5060 gfx::Transform expected_replica_screen_space_transform; 5061 gfx::Transform expected_replica_screen_space_transform;
5061 expected_replica_screen_space_transform.matrix().set(1, 1, -1.0); 5062 expected_replica_screen_space_transform.matrix().set(1, 1, -1.0);
5062 EXPECT_TRANSFORMATION_MATRIX_EQ( 5063 EXPECT_TRANSFORMATION_MATRIX_EQ(
5063 expected_replica_screen_space_transform, 5064 expected_replica_screen_space_transform,
5064 child->render_surface()->replica_screen_space_transform()); 5065 child->render_surface()->replica_screen_space_transform());
5065 } 5066 }
5066 5067
5067 TEST_F(LayerTreeHostCommonTest, LayerSearch) { 5068 TEST_F(LayerTreeHostCommonTest, LayerSearch) {
5068 scoped_refptr<Layer> root = Layer::Create(); 5069 scoped_refptr<Layer> root = CreateTestLayer();
5069 scoped_refptr<Layer> child = Layer::Create(); 5070 scoped_refptr<Layer> child = CreateTestLayer();
5070 scoped_refptr<Layer> grand_child = Layer::Create(); 5071 scoped_refptr<Layer> grand_child = CreateTestLayer();
5071 scoped_refptr<Layer> mask_layer = Layer::Create(); 5072 scoped_refptr<Layer> mask_layer = CreateTestLayer();
5072 scoped_refptr<Layer> replica_layer = Layer::Create(); 5073 scoped_refptr<Layer> replica_layer = CreateTestLayer();
5073 5074
5074 grand_child->SetReplicaLayer(replica_layer.get()); 5075 grand_child->SetReplicaLayer(replica_layer.get());
5075 child->AddChild(grand_child.get()); 5076 child->AddChild(grand_child.get());
5076 child->SetMaskLayer(mask_layer.get()); 5077 child->SetMaskLayer(mask_layer.get());
5077 root->AddChild(child.get()); 5078 root->AddChild(child.get());
5078 5079
5079 host()->SetRootLayer(root); 5080 host()->SetRootLayer(root);
5080 5081
5081 int nonexistent_id = -1; 5082 int nonexistent_id = -1;
5082 EXPECT_EQ(root.get(), host()->LayerById(root->id())); 5083 EXPECT_EQ(root.get(), host()->LayerById(root->id()));
5083 EXPECT_EQ(child.get(), host()->LayerById(child->id())); 5084 EXPECT_EQ(child.get(), host()->LayerById(child->id()));
5084 EXPECT_EQ(grand_child.get(), host()->LayerById(grand_child->id())); 5085 EXPECT_EQ(grand_child.get(), host()->LayerById(grand_child->id()));
5085 EXPECT_EQ(mask_layer.get(), host()->LayerById(mask_layer->id())); 5086 EXPECT_EQ(mask_layer.get(), host()->LayerById(mask_layer->id()));
5086 EXPECT_EQ(replica_layer.get(), host()->LayerById(replica_layer->id())); 5087 EXPECT_EQ(replica_layer.get(), host()->LayerById(replica_layer->id()));
5087 EXPECT_FALSE(host()->LayerById(nonexistent_id)); 5088 EXPECT_FALSE(host()->LayerById(nonexistent_id));
5088 } 5089 }
5089 5090
5090 TEST_F(LayerTreeHostCommonTest, TransparentChildRenderSurfaceCreation) { 5091 TEST_F(LayerTreeHostCommonTest, TransparentChildRenderSurfaceCreation) {
5091 scoped_refptr<Layer> root = Layer::Create(); 5092 scoped_refptr<Layer> root = CreateTestLayer();
5092 scoped_refptr<Layer> child = Layer::Create(); 5093 scoped_refptr<Layer> child = CreateTestLayer();
5093 scoped_refptr<LayerWithForcedDrawsContent> grand_child = 5094 scoped_refptr<LayerWithForcedDrawsContent> grand_child =
5094 make_scoped_refptr(new LayerWithForcedDrawsContent()); 5095 make_scoped_refptr(new LayerWithForcedDrawsContent());
5095 5096
5096 const gfx::Transform identity_matrix; 5097 const gfx::Transform identity_matrix;
5097 SetLayerPropertiesForTesting(root.get(), 5098 SetLayerPropertiesForTesting(root.get(),
5098 identity_matrix, 5099 identity_matrix,
5099 gfx::Point3F(), 5100 gfx::Point3F(),
5100 gfx::PointF(), 5101 gfx::PointF(),
5101 gfx::Size(100, 100), 5102 gfx::Size(100, 100),
5102 true, 5103 true,
(...skipping 25 matching lines...) Expand all
5128 } 5129 }
5129 5130
5130 TEST_F(LayerTreeHostCommonTest, OpacityAnimatingOnPendingTree) { 5131 TEST_F(LayerTreeHostCommonTest, OpacityAnimatingOnPendingTree) {
5131 FakeImplTaskRunnerProvider task_runner_provider; 5132 FakeImplTaskRunnerProvider task_runner_provider;
5132 TestSharedBitmapManager shared_bitmap_manager; 5133 TestSharedBitmapManager shared_bitmap_manager;
5133 TestTaskGraphRunner task_graph_runner; 5134 TestTaskGraphRunner task_graph_runner;
5134 FakeLayerTreeHostImpl host_impl(host()->settings(), &task_runner_provider, 5135 FakeLayerTreeHostImpl host_impl(host()->settings(), &task_runner_provider,
5135 &shared_bitmap_manager, &task_graph_runner); 5136 &shared_bitmap_manager, &task_graph_runner);
5136 host_impl.CreatePendingTree(); 5137 host_impl.CreatePendingTree();
5137 std::unique_ptr<LayerImpl> root = 5138 std::unique_ptr<LayerImpl> root =
5138 LayerImpl::Create(host_impl.pending_tree(), 1); 5139 CreateTestLayerImpl(host_impl.pending_tree(), 1);
5139 5140
5140 const gfx::Transform identity_matrix; 5141 const gfx::Transform identity_matrix;
5141 SetLayerPropertiesForTesting(root.get(), identity_matrix, gfx::Point3F(), 5142 SetLayerPropertiesForTesting(root.get(), identity_matrix, gfx::Point3F(),
5142 gfx::PointF(), gfx::Size(100, 100), true, false, 5143 gfx::PointF(), gfx::Size(100, 100), true, false,
5143 false); 5144 false);
5144 root->SetDrawsContent(true); 5145 root->SetDrawsContent(true);
5145 5146
5146 std::unique_ptr<LayerImpl> child = 5147 std::unique_ptr<LayerImpl> child =
5147 LayerImpl::Create(host_impl.pending_tree(), 2); 5148 CreateTestLayerImpl(host_impl.pending_tree(), 2);
5148 SetLayerPropertiesForTesting(child.get(), identity_matrix, gfx::Point3F(), 5149 SetLayerPropertiesForTesting(child.get(), identity_matrix, gfx::Point3F(),
5149 gfx::PointF(), gfx::Size(50, 50), true, false, 5150 gfx::PointF(), gfx::Size(50, 50), true, false,
5150 false); 5151 false);
5151 child->SetDrawsContent(true); 5152 child->SetDrawsContent(true);
5152 child->SetOpacity(0.0f); 5153 child->SetOpacity(0.0f);
5153 5154
5154 // Add opacity animation. 5155 // Add opacity animation.
5155 scoped_refptr<AnimationTimeline> timeline = 5156 scoped_refptr<AnimationTimeline> timeline =
5156 AnimationTimeline::Create(AnimationIdProvider::NextTimelineId()); 5157 AnimationTimeline::Create(AnimationIdProvider::NextTimelineId());
5157 host_impl.animation_host()->AddAnimationTimeline(timeline); 5158 host_impl.animation_host()->AddAnimationTimeline(timeline);
5158 5159
5159 AddOpacityTransitionToLayerWithPlayer(child->id(), timeline, 10.0, 0.0f, 1.0f, 5160 AddOpacityTransitionToElementWithPlayer(child->element_id(), timeline, 10.0,
5160 false); 5161 0.0f, 1.0f, false);
5161 5162
5162 root->AddChild(std::move(child)); 5163 root->AddChild(std::move(child));
5163 root->SetHasRenderSurface(true); 5164 root->SetHasRenderSurface(true);
5164 LayerImpl* root_layer = root.get(); 5165 LayerImpl* root_layer = root.get();
5165 host_impl.pending_tree()->SetRootLayer(std::move(root)); 5166 host_impl.pending_tree()->SetRootLayer(std::move(root));
5166 5167
5167 LayerImplList render_surface_layer_list; 5168 LayerImplList render_surface_layer_list;
5168 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( 5169 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs(
5169 root_layer, root_layer->bounds(), &render_surface_layer_list); 5170 root_layer, root_layer->bounds(), &render_surface_layer_list);
5170 inputs.can_adjust_raster_scales = true; 5171 inputs.can_adjust_raster_scales = true;
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
5244 protected: 5245 protected:
5245 void SetUp() override { 5246 void SetUp() override {
5246 timeline_ = 5247 timeline_ =
5247 AnimationTimeline::Create(AnimationIdProvider::NextTimelineId()); 5248 AnimationTimeline::Create(AnimationIdProvider::NextTimelineId());
5248 host_impl_.animation_host()->AddAnimationTimeline(timeline_); 5249 host_impl_.animation_host()->AddAnimationTimeline(timeline_);
5249 5250
5250 can_use_lcd_text_ = std::tr1::get<0>(GetParam()); 5251 can_use_lcd_text_ = std::tr1::get<0>(GetParam());
5251 layers_always_allowed_lcd_text_ = std::tr1::get<1>(GetParam()); 5252 layers_always_allowed_lcd_text_ = std::tr1::get<1>(GetParam());
5252 5253
5253 std::unique_ptr<LayerImpl> root_ptr = 5254 std::unique_ptr<LayerImpl> root_ptr =
5254 LayerImpl::Create(host_impl_.active_tree(), 1); 5255 CreateTestLayerImpl(host_impl_.active_tree(), 1);
5255 std::unique_ptr<LayerImpl> child_ptr = 5256 std::unique_ptr<LayerImpl> child_ptr =
5256 LayerImpl::Create(host_impl_.active_tree(), 2); 5257 CreateTestLayerImpl(host_impl_.active_tree(), 2);
5257 std::unique_ptr<LayerImpl> grand_child_ptr = 5258 std::unique_ptr<LayerImpl> grand_child_ptr =
5258 LayerImpl::Create(host_impl_.active_tree(), 3); 5259 CreateTestLayerImpl(host_impl_.active_tree(), 3);
5259 5260
5260 // Stash raw pointers to look at later. 5261 // Stash raw pointers to look at later.
5261 root_ = root_ptr.get(); 5262 root_ = root_ptr.get();
5262 child_ = child_ptr.get(); 5263 child_ = child_ptr.get();
5263 grand_child_ = grand_child_ptr.get(); 5264 grand_child_ = grand_child_ptr.get();
5264 5265
5265 child_->AddChild(std::move(grand_child_ptr)); 5266 child_->AddChild(std::move(grand_child_ptr));
5266 root_->AddChild(std::move(child_ptr)); 5267 root_->AddChild(std::move(child_ptr));
5267 host_impl_.active_tree()->SetRootLayer(std::move(root_ptr)); 5268 host_impl_.active_tree()->SetRootLayer(std::move(root_ptr));
5268 5269
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
5411 // Sanity check: Make sure can_use_lcd_text_ is set on each node. 5412 // Sanity check: Make sure can_use_lcd_text_ is set on each node.
5412 ExecuteCalculateDrawProperties(root_, 1.f, 1.f, NULL, can_use_lcd_text_, 5413 ExecuteCalculateDrawProperties(root_, 1.f, 1.f, NULL, can_use_lcd_text_,
5413 layers_always_allowed_lcd_text_); 5414 layers_always_allowed_lcd_text_);
5414 EXPECT_EQ(expect_lcd_text, root_->can_use_lcd_text()); 5415 EXPECT_EQ(expect_lcd_text, root_->can_use_lcd_text());
5415 EXPECT_EQ(expect_lcd_text, child_->can_use_lcd_text()); 5416 EXPECT_EQ(expect_lcd_text, child_->can_use_lcd_text());
5416 EXPECT_EQ(expect_lcd_text, grand_child_->can_use_lcd_text()); 5417 EXPECT_EQ(expect_lcd_text, grand_child_->can_use_lcd_text());
5417 5418
5418 // Add opacity animation. 5419 // Add opacity animation.
5419 child_->SetOpacity(0.9f); 5420 child_->SetOpacity(0.9f);
5420 child_->layer_tree_impl()->property_trees()->needs_rebuild = true; 5421 child_->layer_tree_impl()->property_trees()->needs_rebuild = true;
5421 AddOpacityTransitionToLayerWithPlayer(child_->id(), timeline(), 10.0, 0.9f, 5422 AddOpacityTransitionToElementWithPlayer(child_->element_id(), timeline(),
5422 0.1f, false); 5423 10.0, 0.9f, 0.1f, false);
5423 ExecuteCalculateDrawProperties(root_, 1.f, 1.f, NULL, can_use_lcd_text_, 5424 ExecuteCalculateDrawProperties(root_, 1.f, 1.f, NULL, can_use_lcd_text_,
5424 layers_always_allowed_lcd_text_); 5425 layers_always_allowed_lcd_text_);
5425 // Text LCD should be adjusted while animation is active. 5426 // Text LCD should be adjusted while animation is active.
5426 EXPECT_EQ(expect_lcd_text, root_->can_use_lcd_text()); 5427 EXPECT_EQ(expect_lcd_text, root_->can_use_lcd_text());
5427 EXPECT_EQ(expect_not_lcd_text, child_->can_use_lcd_text()); 5428 EXPECT_EQ(expect_not_lcd_text, child_->can_use_lcd_text());
5428 EXPECT_EQ(expect_not_lcd_text, grand_child_->can_use_lcd_text()); 5429 EXPECT_EQ(expect_not_lcd_text, grand_child_->can_use_lcd_text());
5429 } 5430 }
5430 5431
5431 TEST_P(LCDTextTest, CanUseLCDTextWithAnimationContentsOpaque) { 5432 TEST_P(LCDTextTest, CanUseLCDTextWithAnimationContentsOpaque) {
5432 bool expect_lcd_text = can_use_lcd_text_ || layers_always_allowed_lcd_text_; 5433 bool expect_lcd_text = can_use_lcd_text_ || layers_always_allowed_lcd_text_;
5433 bool expect_not_lcd_text = layers_always_allowed_lcd_text_; 5434 bool expect_not_lcd_text = layers_always_allowed_lcd_text_;
5434 5435
5435 // Sanity check: Make sure can_use_lcd_text_ is set on each node. 5436 // Sanity check: Make sure can_use_lcd_text_ is set on each node.
5436 ExecuteCalculateDrawProperties(root_, 1.f, 1.f, NULL, can_use_lcd_text_, 5437 ExecuteCalculateDrawProperties(root_, 1.f, 1.f, NULL, can_use_lcd_text_,
5437 layers_always_allowed_lcd_text_); 5438 layers_always_allowed_lcd_text_);
5438 EXPECT_EQ(expect_lcd_text, root_->can_use_lcd_text()); 5439 EXPECT_EQ(expect_lcd_text, root_->can_use_lcd_text());
5439 EXPECT_EQ(expect_lcd_text, child_->can_use_lcd_text()); 5440 EXPECT_EQ(expect_lcd_text, child_->can_use_lcd_text());
5440 EXPECT_EQ(expect_lcd_text, grand_child_->can_use_lcd_text()); 5441 EXPECT_EQ(expect_lcd_text, grand_child_->can_use_lcd_text());
5441 5442
5442 // Mark contents non-opaque within the first animation frame. 5443 // Mark contents non-opaque within the first animation frame.
5443 child_->SetContentsOpaque(false); 5444 child_->SetContentsOpaque(false);
5444 AddOpacityTransitionToLayerWithPlayer(child_->id(), timeline(), 10.0, 0.9f, 5445 AddOpacityTransitionToElementWithPlayer(child_->element_id(), timeline(),
5445 0.1f, false); 5446 10.0, 0.9f, 0.1f, false);
5446 ExecuteCalculateDrawProperties(root_, 1.f, 1.f, NULL, can_use_lcd_text_, 5447 ExecuteCalculateDrawProperties(root_, 1.f, 1.f, NULL, can_use_lcd_text_,
5447 layers_always_allowed_lcd_text_); 5448 layers_always_allowed_lcd_text_);
5448 // LCD text should be disabled for non-opaque layers even during animations. 5449 // LCD text should be disabled for non-opaque layers even during animations.
5449 EXPECT_EQ(expect_lcd_text, root_->can_use_lcd_text()); 5450 EXPECT_EQ(expect_lcd_text, root_->can_use_lcd_text());
5450 EXPECT_EQ(expect_not_lcd_text, child_->can_use_lcd_text()); 5451 EXPECT_EQ(expect_not_lcd_text, child_->can_use_lcd_text());
5451 EXPECT_EQ(expect_lcd_text, grand_child_->can_use_lcd_text()); 5452 EXPECT_EQ(expect_lcd_text, grand_child_->can_use_lcd_text());
5452 } 5453 }
5453 5454
5454 INSTANTIATE_TEST_CASE_P(LayerTreeHostCommonTest, 5455 INSTANTIATE_TEST_CASE_P(LayerTreeHostCommonTest,
5455 LCDTextTest, 5456 LCDTextTest,
5456 testing::Combine(testing::Bool(), 5457 testing::Combine(testing::Bool(),
5457 testing::Bool(), 5458 testing::Bool(),
5458 testing::Bool())); 5459 testing::Bool()));
5459 5460
5460 TEST_F(LayerTreeHostCommonTest, SubtreeHidden_SingleLayerImpl) { 5461 TEST_F(LayerTreeHostCommonTest, SubtreeHidden_SingleLayerImpl) {
5461 FakeImplTaskRunnerProvider task_runner_provider; 5462 FakeImplTaskRunnerProvider task_runner_provider;
5462 TestSharedBitmapManager shared_bitmap_manager; 5463 TestSharedBitmapManager shared_bitmap_manager;
5463 TestTaskGraphRunner task_graph_runner; 5464 TestTaskGraphRunner task_graph_runner;
5464 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &shared_bitmap_manager, 5465 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &shared_bitmap_manager,
5465 &task_graph_runner); 5466 &task_graph_runner);
5466 host_impl.CreatePendingTree(); 5467 host_impl.CreatePendingTree();
5467 const gfx::Transform identity_matrix; 5468 const gfx::Transform identity_matrix;
5468 5469
5469 std::unique_ptr<LayerImpl> root = 5470 std::unique_ptr<LayerImpl> root =
5470 LayerImpl::Create(host_impl.pending_tree(), 1); 5471 CreateTestLayerImpl(host_impl.pending_tree(), 1);
5471 LayerImpl* root_layer = root.get(); 5472 LayerImpl* root_layer = root.get();
5472 SetLayerPropertiesForTesting(root.get(), identity_matrix, gfx::Point3F(), 5473 SetLayerPropertiesForTesting(root.get(), identity_matrix, gfx::Point3F(),
5473 gfx::PointF(), gfx::Size(50, 50), true, false, 5474 gfx::PointF(), gfx::Size(50, 50), true, false,
5474 false); 5475 false);
5475 root->SetDrawsContent(true); 5476 root->SetDrawsContent(true);
5476 5477
5477 std::unique_ptr<LayerImpl> child = 5478 std::unique_ptr<LayerImpl> child =
5478 LayerImpl::Create(host_impl.pending_tree(), 2); 5479 CreateTestLayerImpl(host_impl.pending_tree(), 2);
5479 SetLayerPropertiesForTesting(child.get(), identity_matrix, gfx::Point3F(), 5480 SetLayerPropertiesForTesting(child.get(), identity_matrix, gfx::Point3F(),
5480 gfx::PointF(), gfx::Size(40, 40), true, false, 5481 gfx::PointF(), gfx::Size(40, 40), true, false,
5481 false); 5482 false);
5482 child->SetDrawsContent(true); 5483 child->SetDrawsContent(true);
5483 5484
5484 std::unique_ptr<LayerImpl> grand_child = 5485 std::unique_ptr<LayerImpl> grand_child =
5485 LayerImpl::Create(host_impl.pending_tree(), 3); 5486 CreateTestLayerImpl(host_impl.pending_tree(), 3);
5486 SetLayerPropertiesForTesting(grand_child.get(), identity_matrix, 5487 SetLayerPropertiesForTesting(grand_child.get(), identity_matrix,
5487 gfx::Point3F(), gfx::PointF(), gfx::Size(30, 30), 5488 gfx::Point3F(), gfx::PointF(), gfx::Size(30, 30),
5488 true, false, false); 5489 true, false, false);
5489 grand_child->SetDrawsContent(true); 5490 grand_child->SetDrawsContent(true);
5490 grand_child->test_properties()->hide_layer_and_subtree = true; 5491 grand_child->test_properties()->hide_layer_and_subtree = true;
5491 5492
5492 child->AddChild(std::move(grand_child)); 5493 child->AddChild(std::move(grand_child));
5493 root->AddChild(std::move(child)); 5494 root->AddChild(std::move(child));
5494 root->SetHasRenderSurface(true); 5495 root->SetHasRenderSurface(true);
5495 host_impl.pending_tree()->SetRootLayer(std::move(root)); 5496 host_impl.pending_tree()->SetRootLayer(std::move(root));
(...skipping 15 matching lines...) Expand all
5511 TEST_F(LayerTreeHostCommonTest, SubtreeHidden_TwoLayersImpl) { 5512 TEST_F(LayerTreeHostCommonTest, SubtreeHidden_TwoLayersImpl) {
5512 FakeImplTaskRunnerProvider task_runner_provider; 5513 FakeImplTaskRunnerProvider task_runner_provider;
5513 TestSharedBitmapManager shared_bitmap_manager; 5514 TestSharedBitmapManager shared_bitmap_manager;
5514 TestTaskGraphRunner task_graph_runner; 5515 TestTaskGraphRunner task_graph_runner;
5515 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &shared_bitmap_manager, 5516 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &shared_bitmap_manager,
5516 &task_graph_runner); 5517 &task_graph_runner);
5517 host_impl.CreatePendingTree(); 5518 host_impl.CreatePendingTree();
5518 const gfx::Transform identity_matrix; 5519 const gfx::Transform identity_matrix;
5519 5520
5520 std::unique_ptr<LayerImpl> root = 5521 std::unique_ptr<LayerImpl> root =
5521 LayerImpl::Create(host_impl.pending_tree(), 1); 5522 CreateTestLayerImpl(host_impl.pending_tree(), 1);
5522 SetLayerPropertiesForTesting(root.get(), identity_matrix, gfx::Point3F(), 5523 SetLayerPropertiesForTesting(root.get(), identity_matrix, gfx::Point3F(),
5523 gfx::PointF(), gfx::Size(50, 50), true, false, 5524 gfx::PointF(), gfx::Size(50, 50), true, false,
5524 true); 5525 true);
5525 root->SetDrawsContent(true); 5526 root->SetDrawsContent(true);
5526 LayerImpl* root_layer = root.get(); 5527 LayerImpl* root_layer = root.get();
5527 5528
5528 std::unique_ptr<LayerImpl> child = 5529 std::unique_ptr<LayerImpl> child =
5529 LayerImpl::Create(host_impl.pending_tree(), 2); 5530 CreateTestLayerImpl(host_impl.pending_tree(), 2);
5530 SetLayerPropertiesForTesting(child.get(), identity_matrix, gfx::Point3F(), 5531 SetLayerPropertiesForTesting(child.get(), identity_matrix, gfx::Point3F(),
5531 gfx::PointF(), gfx::Size(40, 40), true, false, 5532 gfx::PointF(), gfx::Size(40, 40), true, false,
5532 false); 5533 false);
5533 child->SetDrawsContent(true); 5534 child->SetDrawsContent(true);
5534 child->test_properties()->hide_layer_and_subtree = true; 5535 child->test_properties()->hide_layer_and_subtree = true;
5535 5536
5536 std::unique_ptr<LayerImpl> grand_child = 5537 std::unique_ptr<LayerImpl> grand_child =
5537 LayerImpl::Create(host_impl.pending_tree(), 3); 5538 CreateTestLayerImpl(host_impl.pending_tree(), 3);
5538 SetLayerPropertiesForTesting(grand_child.get(), identity_matrix, 5539 SetLayerPropertiesForTesting(grand_child.get(), identity_matrix,
5539 gfx::Point3F(), gfx::PointF(), gfx::Size(30, 30), 5540 gfx::Point3F(), gfx::PointF(), gfx::Size(30, 30),
5540 true, false, false); 5541 true, false, false);
5541 grand_child->SetDrawsContent(true); 5542 grand_child->SetDrawsContent(true);
5542 5543
5543 child->AddChild(std::move(grand_child)); 5544 child->AddChild(std::move(grand_child));
5544 root->AddChild(std::move(child)); 5545 root->AddChild(std::move(child));
5545 host_impl.pending_tree()->SetRootLayer(std::move(root)); 5546 host_impl.pending_tree()->SetRootLayer(std::move(root));
5546 5547
5547 LayerImplList render_surface_layer_list; 5548 LayerImplList render_surface_layer_list;
(...skipping 14 matching lines...) Expand all
5562 TEST_F(LayerTreeHostCommonTest, SubtreeHiddenWithCopyRequest) { 5563 TEST_F(LayerTreeHostCommonTest, SubtreeHiddenWithCopyRequest) {
5563 FakeImplTaskRunnerProvider task_runner_provider; 5564 FakeImplTaskRunnerProvider task_runner_provider;
5564 TestSharedBitmapManager shared_bitmap_manager; 5565 TestSharedBitmapManager shared_bitmap_manager;
5565 TestTaskGraphRunner task_graph_runner; 5566 TestTaskGraphRunner task_graph_runner;
5566 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &shared_bitmap_manager, 5567 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &shared_bitmap_manager,
5567 &task_graph_runner); 5568 &task_graph_runner);
5568 host_impl.CreatePendingTree(); 5569 host_impl.CreatePendingTree();
5569 const gfx::Transform identity_matrix; 5570 const gfx::Transform identity_matrix;
5570 5571
5571 std::unique_ptr<LayerImpl> root = 5572 std::unique_ptr<LayerImpl> root =
5572 LayerImpl::Create(host_impl.pending_tree(), 1); 5573 CreateTestLayerImpl(host_impl.pending_tree(), 1);
5573 SetLayerPropertiesForTesting(root.get(), identity_matrix, gfx::Point3F(), 5574 SetLayerPropertiesForTesting(root.get(), identity_matrix, gfx::Point3F(),
5574 gfx::PointF(), gfx::Size(50, 50), true, false, 5575 gfx::PointF(), gfx::Size(50, 50), true, false,
5575 true); 5576 true);
5576 root->SetDrawsContent(true); 5577 root->SetDrawsContent(true);
5577 LayerImpl* root_layer = root.get(); 5578 LayerImpl* root_layer = root.get();
5578 5579
5579 std::unique_ptr<LayerImpl> copy_grand_parent = 5580 std::unique_ptr<LayerImpl> copy_grand_parent =
5580 LayerImpl::Create(host_impl.pending_tree(), 2); 5581 CreateTestLayerImpl(host_impl.pending_tree(), 2);
5581 SetLayerPropertiesForTesting(copy_grand_parent.get(), identity_matrix, 5582 SetLayerPropertiesForTesting(copy_grand_parent.get(), identity_matrix,
5582 gfx::Point3F(), gfx::PointF(), gfx::Size(40, 40), 5583 gfx::Point3F(), gfx::PointF(), gfx::Size(40, 40),
5583 true, false, false); 5584 true, false, false);
5584 copy_grand_parent->SetDrawsContent(true); 5585 copy_grand_parent->SetDrawsContent(true);
5585 LayerImpl* copy_grand_parent_layer = copy_grand_parent.get(); 5586 LayerImpl* copy_grand_parent_layer = copy_grand_parent.get();
5586 5587
5587 std::unique_ptr<LayerImpl> copy_parent = 5588 std::unique_ptr<LayerImpl> copy_parent =
5588 LayerImpl::Create(host_impl.pending_tree(), 3); 5589 CreateTestLayerImpl(host_impl.pending_tree(), 3);
5589 SetLayerPropertiesForTesting(copy_parent.get(), identity_matrix, 5590 SetLayerPropertiesForTesting(copy_parent.get(), identity_matrix,
5590 gfx::Point3F(), gfx::PointF(), gfx::Size(30, 30), 5591 gfx::Point3F(), gfx::PointF(), gfx::Size(30, 30),
5591 true, false, true); 5592 true, false, true);
5592 copy_parent->SetDrawsContent(true); 5593 copy_parent->SetDrawsContent(true);
5593 LayerImpl* copy_parent_layer = copy_parent.get(); 5594 LayerImpl* copy_parent_layer = copy_parent.get();
5594 5595
5595 std::unique_ptr<LayerImpl> copy_request = 5596 std::unique_ptr<LayerImpl> copy_request =
5596 LayerImpl::Create(host_impl.pending_tree(), 4); 5597 CreateTestLayerImpl(host_impl.pending_tree(), 4);
5597 SetLayerPropertiesForTesting(copy_request.get(), identity_matrix, 5598 SetLayerPropertiesForTesting(copy_request.get(), identity_matrix,
5598 gfx::Point3F(), gfx::PointF(), gfx::Size(20, 20), 5599 gfx::Point3F(), gfx::PointF(), gfx::Size(20, 20),
5599 true, false, true); 5600 true, false, true);
5600 copy_request->SetDrawsContent(true); 5601 copy_request->SetDrawsContent(true);
5601 LayerImpl* copy_layer = copy_request.get(); 5602 LayerImpl* copy_layer = copy_request.get();
5602 5603
5603 std::unique_ptr<LayerImpl> copy_child = 5604 std::unique_ptr<LayerImpl> copy_child =
5604 LayerImpl::Create(host_impl.pending_tree(), 5); 5605 CreateTestLayerImpl(host_impl.pending_tree(), 5);
5605 SetLayerPropertiesForTesting(copy_child.get(), identity_matrix, 5606 SetLayerPropertiesForTesting(copy_child.get(), identity_matrix,
5606 gfx::Point3F(), gfx::PointF(), gfx::Size(20, 20), 5607 gfx::Point3F(), gfx::PointF(), gfx::Size(20, 20),
5607 true, false, false); 5608 true, false, false);
5608 copy_child->SetDrawsContent(true); 5609 copy_child->SetDrawsContent(true);
5609 LayerImpl* copy_child_layer = copy_child.get(); 5610 LayerImpl* copy_child_layer = copy_child.get();
5610 5611
5611 std::unique_ptr<LayerImpl> copy_grand_child = 5612 std::unique_ptr<LayerImpl> copy_grand_child =
5612 LayerImpl::Create(host_impl.pending_tree(), 6); 5613 CreateTestLayerImpl(host_impl.pending_tree(), 6);
5613 SetLayerPropertiesForTesting(copy_grand_child.get(), identity_matrix, 5614 SetLayerPropertiesForTesting(copy_grand_child.get(), identity_matrix,
5614 gfx::Point3F(), gfx::PointF(), gfx::Size(20, 20), 5615 gfx::Point3F(), gfx::PointF(), gfx::Size(20, 20),
5615 true, false, false); 5616 true, false, false);
5616 copy_child->SetDrawsContent(true); 5617 copy_child->SetDrawsContent(true);
5617 LayerImpl* copy_grand_child_layer = copy_grand_child.get(); 5618 LayerImpl* copy_grand_child_layer = copy_grand_child.get();
5618 5619
5619 std::unique_ptr<LayerImpl> copy_grand_parent_sibling_before = 5620 std::unique_ptr<LayerImpl> copy_grand_parent_sibling_before =
5620 LayerImpl::Create(host_impl.pending_tree(), 7); 5621 CreateTestLayerImpl(host_impl.pending_tree(), 7);
5621 SetLayerPropertiesForTesting(copy_grand_parent_sibling_before.get(), 5622 SetLayerPropertiesForTesting(copy_grand_parent_sibling_before.get(),
5622 identity_matrix, gfx::Point3F(), gfx::PointF(), 5623 identity_matrix, gfx::Point3F(), gfx::PointF(),
5623 gfx::Size(40, 40), true, false, false); 5624 gfx::Size(40, 40), true, false, false);
5624 copy_grand_parent_sibling_before->SetDrawsContent(true); 5625 copy_grand_parent_sibling_before->SetDrawsContent(true);
5625 LayerImpl* copy_grand_parent_sibling_before_layer = 5626 LayerImpl* copy_grand_parent_sibling_before_layer =
5626 copy_grand_parent_sibling_before.get(); 5627 copy_grand_parent_sibling_before.get();
5627 5628
5628 std::unique_ptr<LayerImpl> copy_grand_parent_sibling_after = 5629 std::unique_ptr<LayerImpl> copy_grand_parent_sibling_after =
5629 LayerImpl::Create(host_impl.pending_tree(), 8); 5630 CreateTestLayerImpl(host_impl.pending_tree(), 8);
5630 SetLayerPropertiesForTesting(copy_grand_parent_sibling_after.get(), 5631 SetLayerPropertiesForTesting(copy_grand_parent_sibling_after.get(),
5631 identity_matrix, gfx::Point3F(), gfx::PointF(), 5632 identity_matrix, gfx::Point3F(), gfx::PointF(),
5632 gfx::Size(40, 40), true, false, false); 5633 gfx::Size(40, 40), true, false, false);
5633 copy_grand_parent_sibling_after->SetDrawsContent(true); 5634 copy_grand_parent_sibling_after->SetDrawsContent(true);
5634 LayerImpl* copy_grand_parent_sibling_after_layer = 5635 LayerImpl* copy_grand_parent_sibling_after_layer =
5635 copy_grand_parent_sibling_after.get(); 5636 copy_grand_parent_sibling_after.get();
5636 5637
5637 copy_child->AddChild(std::move(copy_grand_child)); 5638 copy_child->AddChild(std::move(copy_grand_child));
5638 copy_request->AddChild(std::move(copy_child)); 5639 copy_request->AddChild(std::move(copy_child));
5639 copy_parent->AddChild(std::move(copy_request)); 5640 copy_parent->AddChild(std::move(copy_request));
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
5725 TEST_F(LayerTreeHostCommonTest, ClippedOutCopyRequest) { 5726 TEST_F(LayerTreeHostCommonTest, ClippedOutCopyRequest) {
5726 FakeImplTaskRunnerProvider task_runner_provider; 5727 FakeImplTaskRunnerProvider task_runner_provider;
5727 TestSharedBitmapManager shared_bitmap_manager; 5728 TestSharedBitmapManager shared_bitmap_manager;
5728 TestTaskGraphRunner task_graph_runner; 5729 TestTaskGraphRunner task_graph_runner;
5729 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &shared_bitmap_manager, 5730 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &shared_bitmap_manager,
5730 &task_graph_runner); 5731 &task_graph_runner);
5731 host_impl.CreatePendingTree(); 5732 host_impl.CreatePendingTree();
5732 const gfx::Transform identity_matrix; 5733 const gfx::Transform identity_matrix;
5733 5734
5734 std::unique_ptr<LayerImpl> root = 5735 std::unique_ptr<LayerImpl> root =
5735 LayerImpl::Create(host_impl.pending_tree(), 1); 5736 CreateTestLayerImpl(host_impl.pending_tree(), 1);
5736 SetLayerPropertiesForTesting(root.get(), identity_matrix, gfx::Point3F(), 5737 SetLayerPropertiesForTesting(root.get(), identity_matrix, gfx::Point3F(),
5737 gfx::PointF(), gfx::Size(50, 50), true, false, 5738 gfx::PointF(), gfx::Size(50, 50), true, false,
5738 true); 5739 true);
5739 root->SetDrawsContent(true); 5740 root->SetDrawsContent(true);
5740 5741
5741 std::unique_ptr<LayerImpl> copy_parent = 5742 std::unique_ptr<LayerImpl> copy_parent =
5742 LayerImpl::Create(host_impl.pending_tree(), 2); 5743 CreateTestLayerImpl(host_impl.pending_tree(), 2);
5743 SetLayerPropertiesForTesting(copy_parent.get(), identity_matrix, 5744 SetLayerPropertiesForTesting(copy_parent.get(), identity_matrix,
5744 gfx::Point3F(), gfx::PointF(), gfx::Size(), true, 5745 gfx::Point3F(), gfx::PointF(), gfx::Size(), true,
5745 false, false); 5746 false, false);
5746 copy_parent->SetDrawsContent(true); 5747 copy_parent->SetDrawsContent(true);
5747 copy_parent->SetMasksToBounds(true); 5748 copy_parent->SetMasksToBounds(true);
5748 5749
5749 std::unique_ptr<LayerImpl> copy_layer = 5750 std::unique_ptr<LayerImpl> copy_layer =
5750 LayerImpl::Create(host_impl.pending_tree(), 3); 5751 CreateTestLayerImpl(host_impl.pending_tree(), 3);
5751 SetLayerPropertiesForTesting(copy_layer.get(), identity_matrix, 5752 SetLayerPropertiesForTesting(copy_layer.get(), identity_matrix,
5752 gfx::Point3F(), gfx::PointF(), gfx::Size(30, 30), 5753 gfx::Point3F(), gfx::PointF(), gfx::Size(30, 30),
5753 true, false, true); 5754 true, false, true);
5754 copy_layer->SetDrawsContent(true); 5755 copy_layer->SetDrawsContent(true);
5755 5756
5756 std::unique_ptr<LayerImpl> copy_child = 5757 std::unique_ptr<LayerImpl> copy_child =
5757 LayerImpl::Create(host_impl.pending_tree(), 4); 5758 CreateTestLayerImpl(host_impl.pending_tree(), 4);
5758 SetLayerPropertiesForTesting(copy_child.get(), identity_matrix, 5759 SetLayerPropertiesForTesting(copy_child.get(), identity_matrix,
5759 gfx::Point3F(), gfx::PointF(), gfx::Size(20, 20), 5760 gfx::Point3F(), gfx::PointF(), gfx::Size(20, 20),
5760 true, false, false); 5761 true, false, false);
5761 copy_child->SetDrawsContent(true); 5762 copy_child->SetDrawsContent(true);
5762 5763
5763 std::vector<std::unique_ptr<CopyOutputRequest>> copy_requests; 5764 std::vector<std::unique_ptr<CopyOutputRequest>> copy_requests;
5764 copy_requests.push_back( 5765 copy_requests.push_back(
5765 CopyOutputRequest::CreateRequest(base::Bind(&EmptyCopyOutputCallback))); 5766 CopyOutputRequest::CreateRequest(base::Bind(&EmptyCopyOutputCallback)));
5766 copy_layer->PassCopyRequests(&copy_requests); 5767 copy_layer->PassCopyRequests(&copy_requests);
5767 EXPECT_TRUE(copy_layer->HasCopyRequest()); 5768 EXPECT_TRUE(copy_layer->HasCopyRequest());
(...skipping 480 matching lines...) Expand 10 before | Expand all | Expand 10 after
6248 } 6249 }
6249 6250
6250 TEST_F(LayerTreeHostCommonTest, CanRenderToSeparateSurface) { 6251 TEST_F(LayerTreeHostCommonTest, CanRenderToSeparateSurface) {
6251 FakeImplTaskRunnerProvider task_runner_provider; 6252 FakeImplTaskRunnerProvider task_runner_provider;
6252 TestSharedBitmapManager shared_bitmap_manager; 6253 TestSharedBitmapManager shared_bitmap_manager;
6253 TestTaskGraphRunner task_graph_runner; 6254 TestTaskGraphRunner task_graph_runner;
6254 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &shared_bitmap_manager, 6255 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &shared_bitmap_manager,
6255 &task_graph_runner); 6256 &task_graph_runner);
6256 6257
6257 std::unique_ptr<LayerImpl> root = 6258 std::unique_ptr<LayerImpl> root =
6258 LayerImpl::Create(host_impl.active_tree(), 12345); 6259 CreateTestLayerImpl(host_impl.active_tree(), 12345);
6259 std::unique_ptr<LayerImpl> child1 = 6260 std::unique_ptr<LayerImpl> child1 =
6260 LayerImpl::Create(host_impl.active_tree(), 123456); 6261 CreateTestLayerImpl(host_impl.active_tree(), 123456);
6261 std::unique_ptr<LayerImpl> child2 = 6262 std::unique_ptr<LayerImpl> child2 =
6262 LayerImpl::Create(host_impl.active_tree(), 1234567); 6263 CreateTestLayerImpl(host_impl.active_tree(), 1234567);
6263 std::unique_ptr<LayerImpl> child3 = 6264 std::unique_ptr<LayerImpl> child3 =
6264 LayerImpl::Create(host_impl.active_tree(), 12345678); 6265 CreateTestLayerImpl(host_impl.active_tree(), 12345678);
6265 6266
6266 gfx::Transform identity_matrix; 6267 gfx::Transform identity_matrix;
6267 gfx::Point3F transform_origin; 6268 gfx::Point3F transform_origin;
6268 gfx::PointF position; 6269 gfx::PointF position;
6269 gfx::Size bounds(100, 100); 6270 gfx::Size bounds(100, 100);
6270 SetLayerPropertiesForTesting(root.get(), identity_matrix, transform_origin, 6271 SetLayerPropertiesForTesting(root.get(), identity_matrix, transform_origin,
6271 position, bounds, true, false, true); 6272 position, bounds, true, false, true);
6272 root->SetDrawsContent(true); 6273 root->SetDrawsContent(true);
6273 6274
6274 // This layer structure normally forces render surface due to preserves3d 6275 // This layer structure normally forces render surface due to preserves3d
(...skipping 712 matching lines...) Expand 10 before | Expand all | Expand 10 after
6987 // + scroller 6988 // + scroller
6988 // + fixed 6989 // + fixed
6989 // 6990 //
6990 FakeImplTaskRunnerProvider task_runner_provider; 6991 FakeImplTaskRunnerProvider task_runner_provider;
6991 TestSharedBitmapManager shared_bitmap_manager; 6992 TestSharedBitmapManager shared_bitmap_manager;
6992 TestTaskGraphRunner task_graph_runner; 6993 TestTaskGraphRunner task_graph_runner;
6993 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &shared_bitmap_manager, 6994 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &shared_bitmap_manager,
6994 &task_graph_runner); 6995 &task_graph_runner);
6995 host_impl.CreatePendingTree(); 6996 host_impl.CreatePendingTree();
6996 std::unique_ptr<LayerImpl> root_ptr = 6997 std::unique_ptr<LayerImpl> root_ptr =
6997 LayerImpl::Create(host_impl.active_tree(), 1); 6998 CreateTestLayerImpl(host_impl.active_tree(), 1);
6998 LayerImpl* root = root_ptr.get(); 6999 LayerImpl* root = root_ptr.get();
6999 std::unique_ptr<LayerImpl> container = 7000 std::unique_ptr<LayerImpl> container =
7000 LayerImpl::Create(host_impl.active_tree(), 2); 7001 CreateTestLayerImpl(host_impl.active_tree(), 2);
7001 LayerImpl* container_layer = container.get(); 7002 LayerImpl* container_layer = container.get();
7002 std::unique_ptr<LayerImpl> scroller = 7003 std::unique_ptr<LayerImpl> scroller =
7003 LayerImpl::Create(host_impl.active_tree(), 3); 7004 CreateTestLayerImpl(host_impl.active_tree(), 3);
7004 LayerImpl* scroll_layer = scroller.get(); 7005 LayerImpl* scroll_layer = scroller.get();
7005 std::unique_ptr<LayerImpl> fixed = 7006 std::unique_ptr<LayerImpl> fixed =
7006 LayerImpl::Create(host_impl.active_tree(), 4); 7007 CreateTestLayerImpl(host_impl.active_tree(), 4);
7007 LayerImpl* fixed_layer = fixed.get(); 7008 LayerImpl* fixed_layer = fixed.get();
7008 7009
7009 container->test_properties()->is_container_for_fixed_position_layers = true; 7010 container->test_properties()->is_container_for_fixed_position_layers = true;
7010 7011
7011 LayerPositionConstraint constraint; 7012 LayerPositionConstraint constraint;
7012 constraint.set_is_fixed_position(true); 7013 constraint.set_is_fixed_position(true);
7013 fixed->test_properties()->position_constraint = constraint; 7014 fixed->test_properties()->position_constraint = constraint;
7014 7015
7015 scroller->SetScrollClipLayer(container->id()); 7016 scroller->SetScrollClipLayer(container->id());
7016 7017
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
7157 SetLayerPropertiesForTesting(scroller, identity_transform, gfx::Point3F(), 7158 SetLayerPropertiesForTesting(scroller, identity_transform, gfx::Point3F(),
7158 gfx::PointF(), gfx::Size(100, 100), true, false, 7159 gfx::PointF(), gfx::Size(100, 100), true, false,
7159 false); 7160 false);
7160 7161
7161 gfx::Transform end_scale; 7162 gfx::Transform end_scale;
7162 end_scale.Scale(2.f, 2.f); 7163 end_scale.Scale(2.f, 2.f);
7163 TransformOperations start_operations; 7164 TransformOperations start_operations;
7164 start_operations.AppendMatrix(start_scale); 7165 start_operations.AppendMatrix(start_scale);
7165 TransformOperations end_operations; 7166 TransformOperations end_operations;
7166 end_operations.AppendMatrix(end_scale); 7167 end_operations.AppendMatrix(end_scale);
7167 AddAnimatedTransformToLayerWithPlayer(animated_layer->id(), timeline_impl(), 7168 AddAnimatedTransformToElementWithPlayer(animated_layer->element_id(),
7168 1.0, start_operations, end_operations); 7169 timeline_impl(), 1.0,
7170 start_operations, end_operations);
7169 gfx::Vector2dF scroll_delta(5.f, 9.f); 7171 gfx::Vector2dF scroll_delta(5.f, 9.f);
7170 SetScrollOffsetDelta(scroller, scroll_delta); 7172 SetScrollOffsetDelta(scroller, scroll_delta);
7171 7173
7172 ExecuteCalculateDrawProperties(root); 7174 ExecuteCalculateDrawProperties(root);
7173 7175
7174 gfx::Vector2dF expected_draw_transform_translation(-7.5f, -13.5f); 7176 gfx::Vector2dF expected_draw_transform_translation(-7.5f, -13.5f);
7175 EXPECT_VECTOR2DF_EQ(expected_draw_transform_translation, 7177 EXPECT_VECTOR2DF_EQ(expected_draw_transform_translation,
7176 scroller->DrawTransform().To2dTranslation()); 7178 scroller->DrawTransform().To2dTranslation());
7177 } 7179 }
7178 7180
7179 class AnimationScaleFactorTrackingLayerImpl : public LayerImpl { 7181 class AnimationScaleFactorTrackingLayerImpl : public LayerImpl {
7180 public: 7182 public:
7181 static std::unique_ptr<AnimationScaleFactorTrackingLayerImpl> Create( 7183 static std::unique_ptr<AnimationScaleFactorTrackingLayerImpl> Create(
7182 LayerTreeImpl* tree_impl, 7184 LayerTreeImpl* tree_impl,
7183 int id) { 7185 int id) {
7184 return base::WrapUnique( 7186 auto layer = base::WrapUnique(
7185 new AnimationScaleFactorTrackingLayerImpl(tree_impl, id)); 7187 new AnimationScaleFactorTrackingLayerImpl(tree_impl, id));
7188 layer->SetElementId(NextTestElementId());
7189 return layer;
7186 } 7190 }
7187 7191
7188 ~AnimationScaleFactorTrackingLayerImpl() override {} 7192 ~AnimationScaleFactorTrackingLayerImpl() override {}
7189 7193
7190 private: 7194 private:
7191 explicit AnimationScaleFactorTrackingLayerImpl(LayerTreeImpl* tree_impl, 7195 explicit AnimationScaleFactorTrackingLayerImpl(LayerTreeImpl* tree_impl,
7192 int id) 7196 int id)
7193 : LayerImpl(tree_impl, id) { 7197 : LayerImpl(tree_impl, id) {
7194 SetDrawsContent(true); 7198 SetDrawsContent(true);
7195 } 7199 }
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
7261 0.f, 7265 0.f,
7262 grand_child_raw->draw_properties().starting_animation_contents_scale); 7266 grand_child_raw->draw_properties().starting_animation_contents_scale);
7263 7267
7264 TransformOperations translation; 7268 TransformOperations translation;
7265 translation.AppendTranslate(1.f, 2.f, 3.f); 7269 translation.AppendTranslate(1.f, 2.f, 3.f);
7266 7270
7267 scoped_refptr<AnimationTimeline> timeline; 7271 scoped_refptr<AnimationTimeline> timeline;
7268 timeline = AnimationTimeline::Create(AnimationIdProvider::NextTimelineId()); 7272 timeline = AnimationTimeline::Create(AnimationIdProvider::NextTimelineId());
7269 host_impl.animation_host()->AddAnimationTimeline(timeline); 7273 host_impl.animation_host()->AddAnimationTimeline(timeline);
7270 7274
7271 AddAnimatedTransformToLayerWithPlayer(parent_raw->id(), timeline, 1.0, 7275 AddAnimatedTransformToElementWithPlayer(parent_raw->element_id(), timeline,
7272 TransformOperations(), translation); 7276 1.0, TransformOperations(),
7277 translation);
7273 7278
7274 // No layers have scale-affecting animations. 7279 // No layers have scale-affecting animations.
7275 EXPECT_EQ( 7280 EXPECT_EQ(
7276 0.f, 7281 0.f,
7277 grand_parent_raw->draw_properties().maximum_animation_contents_scale); 7282 grand_parent_raw->draw_properties().maximum_animation_contents_scale);
7278 EXPECT_EQ(0.f, 7283 EXPECT_EQ(0.f,
7279 parent_raw->draw_properties().maximum_animation_contents_scale); 7284 parent_raw->draw_properties().maximum_animation_contents_scale);
7280 EXPECT_EQ(0.f, child_raw->draw_properties().maximum_animation_contents_scale); 7285 EXPECT_EQ(0.f, child_raw->draw_properties().maximum_animation_contents_scale);
7281 EXPECT_EQ( 7286 EXPECT_EQ(
7282 0.f, grand_child_raw->draw_properties().maximum_animation_contents_scale); 7287 0.f, grand_child_raw->draw_properties().maximum_animation_contents_scale);
7283 7288
7284 EXPECT_EQ( 7289 EXPECT_EQ(
7285 0.f, 7290 0.f,
7286 grand_parent_raw->draw_properties().starting_animation_contents_scale); 7291 grand_parent_raw->draw_properties().starting_animation_contents_scale);
7287 EXPECT_EQ(0.f, 7292 EXPECT_EQ(0.f,
7288 parent_raw->draw_properties().starting_animation_contents_scale); 7293 parent_raw->draw_properties().starting_animation_contents_scale);
7289 EXPECT_EQ(0.f, 7294 EXPECT_EQ(0.f,
7290 child_raw->draw_properties().starting_animation_contents_scale); 7295 child_raw->draw_properties().starting_animation_contents_scale);
7291 EXPECT_EQ( 7296 EXPECT_EQ(
7292 0.f, 7297 0.f,
7293 grand_child_raw->draw_properties().starting_animation_contents_scale); 7298 grand_child_raw->draw_properties().starting_animation_contents_scale);
7294 7299
7295 TransformOperations scale; 7300 TransformOperations scale;
7296 scale.AppendScale(5.f, 4.f, 3.f); 7301 scale.AppendScale(5.f, 4.f, 3.f);
7297 7302
7298 AddAnimatedTransformToLayerWithPlayer(child_raw->id(), timeline, 1.0, 7303 AddAnimatedTransformToElementWithPlayer(child_raw->element_id(), timeline,
7299 TransformOperations(), scale); 7304 1.0, TransformOperations(), scale);
7300 child_raw->layer_tree_impl()->property_trees()->needs_rebuild = true; 7305 child_raw->layer_tree_impl()->property_trees()->needs_rebuild = true;
7301 ExecuteCalculateDrawProperties(grand_parent_raw); 7306 ExecuteCalculateDrawProperties(grand_parent_raw);
7302 7307
7303 // Only |child| has a scale-affecting animation. 7308 // Only |child| has a scale-affecting animation.
7304 EXPECT_EQ( 7309 EXPECT_EQ(
7305 0.f, 7310 0.f,
7306 grand_parent_raw->draw_properties().maximum_animation_contents_scale); 7311 grand_parent_raw->draw_properties().maximum_animation_contents_scale);
7307 EXPECT_EQ(0.f, 7312 EXPECT_EQ(0.f,
7308 parent_raw->draw_properties().maximum_animation_contents_scale); 7313 parent_raw->draw_properties().maximum_animation_contents_scale);
7309 EXPECT_EQ(5.f, child_raw->draw_properties().maximum_animation_contents_scale); 7314 EXPECT_EQ(5.f, child_raw->draw_properties().maximum_animation_contents_scale);
7310 EXPECT_EQ( 7315 EXPECT_EQ(
7311 5.f, grand_child_raw->draw_properties().maximum_animation_contents_scale); 7316 5.f, grand_child_raw->draw_properties().maximum_animation_contents_scale);
7312 7317
7313 EXPECT_EQ( 7318 EXPECT_EQ(
7314 0.f, 7319 0.f,
7315 grand_parent_raw->draw_properties().starting_animation_contents_scale); 7320 grand_parent_raw->draw_properties().starting_animation_contents_scale);
7316 EXPECT_EQ(0.f, 7321 EXPECT_EQ(0.f,
7317 parent_raw->draw_properties().starting_animation_contents_scale); 7322 parent_raw->draw_properties().starting_animation_contents_scale);
7318 EXPECT_EQ(1.f, 7323 EXPECT_EQ(1.f,
7319 child_raw->draw_properties().starting_animation_contents_scale); 7324 child_raw->draw_properties().starting_animation_contents_scale);
7320 EXPECT_EQ( 7325 EXPECT_EQ(
7321 1.f, 7326 1.f,
7322 grand_child_raw->draw_properties().starting_animation_contents_scale); 7327 grand_child_raw->draw_properties().starting_animation_contents_scale);
7323 7328
7324 AddAnimatedTransformToLayerWithPlayer(grand_parent_raw->id(), timeline, 1.0, 7329 AddAnimatedTransformToElementWithPlayer(grand_parent_raw->element_id(),
7325 TransformOperations(), scale); 7330 timeline, 1.0, TransformOperations(),
7331 scale);
7326 grand_parent_raw->layer_tree_impl()->property_trees()->needs_rebuild = true; 7332 grand_parent_raw->layer_tree_impl()->property_trees()->needs_rebuild = true;
7327 ExecuteCalculateDrawProperties(grand_parent_raw); 7333 ExecuteCalculateDrawProperties(grand_parent_raw);
7328 7334
7329 // |grand_parent| and |child| have scale-affecting animations. 7335 // |grand_parent| and |child| have scale-affecting animations.
7330 EXPECT_EQ( 7336 EXPECT_EQ(
7331 5.f, 7337 5.f,
7332 grand_parent_raw->draw_properties().maximum_animation_contents_scale); 7338 grand_parent_raw->draw_properties().maximum_animation_contents_scale);
7333 EXPECT_EQ(5.f, 7339 EXPECT_EQ(5.f,
7334 parent_raw->draw_properties().maximum_animation_contents_scale); 7340 parent_raw->draw_properties().maximum_animation_contents_scale);
7335 // We don't support combining animated scales from two nodes; 0.f means 7341 // We don't support combining animated scales from two nodes; 0.f means
7336 // that the maximum scale could not be computed. 7342 // that the maximum scale could not be computed.
7337 EXPECT_EQ(0.f, child_raw->draw_properties().maximum_animation_contents_scale); 7343 EXPECT_EQ(0.f, child_raw->draw_properties().maximum_animation_contents_scale);
7338 EXPECT_EQ( 7344 EXPECT_EQ(
7339 0.f, grand_child_raw->draw_properties().maximum_animation_contents_scale); 7345 0.f, grand_child_raw->draw_properties().maximum_animation_contents_scale);
7340 7346
7341 EXPECT_EQ( 7347 EXPECT_EQ(
7342 1.f, 7348 1.f,
7343 grand_parent_raw->draw_properties().starting_animation_contents_scale); 7349 grand_parent_raw->draw_properties().starting_animation_contents_scale);
7344 EXPECT_EQ(1.f, 7350 EXPECT_EQ(1.f,
7345 parent_raw->draw_properties().starting_animation_contents_scale); 7351 parent_raw->draw_properties().starting_animation_contents_scale);
7346 EXPECT_EQ(0.f, 7352 EXPECT_EQ(0.f,
7347 child_raw->draw_properties().starting_animation_contents_scale); 7353 child_raw->draw_properties().starting_animation_contents_scale);
7348 EXPECT_EQ( 7354 EXPECT_EQ(
7349 0.f, 7355 0.f,
7350 grand_child_raw->draw_properties().starting_animation_contents_scale); 7356 grand_child_raw->draw_properties().starting_animation_contents_scale);
7351 7357
7352 AddAnimatedTransformToLayerWithPlayer(parent_raw->id(), timeline, 1.0, 7358 AddAnimatedTransformToElementWithPlayer(parent_raw->element_id(), timeline,
7353 TransformOperations(), scale); 7359 1.0, TransformOperations(), scale);
7354 parent_raw->layer_tree_impl()->property_trees()->needs_rebuild = true; 7360 parent_raw->layer_tree_impl()->property_trees()->needs_rebuild = true;
7355 ExecuteCalculateDrawProperties(grand_parent_raw); 7361 ExecuteCalculateDrawProperties(grand_parent_raw);
7356 7362
7357 // |grand_parent|, |parent|, and |child| have scale-affecting animations. 7363 // |grand_parent|, |parent|, and |child| have scale-affecting animations.
7358 EXPECT_EQ( 7364 EXPECT_EQ(
7359 5.f, 7365 5.f,
7360 grand_parent_raw->draw_properties().maximum_animation_contents_scale); 7366 grand_parent_raw->draw_properties().maximum_animation_contents_scale);
7361 EXPECT_EQ(0.f, 7367 EXPECT_EQ(0.f,
7362 parent_raw->draw_properties().maximum_animation_contents_scale); 7368 parent_raw->draw_properties().maximum_animation_contents_scale);
7363 EXPECT_EQ(0.f, child_raw->draw_properties().maximum_animation_contents_scale); 7369 EXPECT_EQ(0.f, child_raw->draw_properties().maximum_animation_contents_scale);
7364 EXPECT_EQ( 7370 EXPECT_EQ(
7365 0.f, grand_child_raw->draw_properties().maximum_animation_contents_scale); 7371 0.f, grand_child_raw->draw_properties().maximum_animation_contents_scale);
7366 7372
7367 EXPECT_EQ( 7373 EXPECT_EQ(
7368 1.f, 7374 1.f,
7369 grand_parent_raw->draw_properties().starting_animation_contents_scale); 7375 grand_parent_raw->draw_properties().starting_animation_contents_scale);
7370 EXPECT_EQ(0.f, 7376 EXPECT_EQ(0.f,
7371 parent_raw->draw_properties().starting_animation_contents_scale); 7377 parent_raw->draw_properties().starting_animation_contents_scale);
7372 EXPECT_EQ(0.f, 7378 EXPECT_EQ(0.f,
7373 child_raw->draw_properties().starting_animation_contents_scale); 7379 child_raw->draw_properties().starting_animation_contents_scale);
7374 EXPECT_EQ( 7380 EXPECT_EQ(
7375 0.f, 7381 0.f,
7376 grand_child_raw->draw_properties().starting_animation_contents_scale); 7382 grand_child_raw->draw_properties().starting_animation_contents_scale);
7377 7383
7378 AbortAnimationsOnLayerWithPlayer(grand_parent_raw->id(), timeline, 7384 AbortAnimationsOnElementWithPlayer(grand_parent_raw->element_id(), timeline,
7379 TargetProperty::TRANSFORM); 7385 TargetProperty::TRANSFORM);
7380 AbortAnimationsOnLayerWithPlayer(parent_raw->id(), timeline, 7386 AbortAnimationsOnElementWithPlayer(parent_raw->element_id(), timeline,
7381 TargetProperty::TRANSFORM); 7387 TargetProperty::TRANSFORM);
7382 AbortAnimationsOnLayerWithPlayer(child_raw->id(), timeline, 7388 AbortAnimationsOnElementWithPlayer(child_raw->element_id(), timeline,
7383 TargetProperty::TRANSFORM); 7389 TargetProperty::TRANSFORM);
7384 7390
7385 TransformOperations perspective; 7391 TransformOperations perspective;
7386 perspective.AppendPerspective(10.f); 7392 perspective.AppendPerspective(10.f);
7387 7393
7388 AddAnimatedTransformToLayerWithPlayer(child_raw->id(), timeline, 1.0, 7394 AddAnimatedTransformToElementWithPlayer(child_raw->element_id(), timeline,
7389 TransformOperations(), perspective); 7395 1.0, TransformOperations(),
7396 perspective);
7390 child_raw->layer_tree_impl()->property_trees()->needs_rebuild = true; 7397 child_raw->layer_tree_impl()->property_trees()->needs_rebuild = true;
7391 ExecuteCalculateDrawProperties(grand_parent_raw); 7398 ExecuteCalculateDrawProperties(grand_parent_raw);
7392 7399
7393 // |child| has a scale-affecting animation but computing the maximum of this 7400 // |child| has a scale-affecting animation but computing the maximum of this
7394 // animation is not supported. 7401 // animation is not supported.
7395 EXPECT_EQ( 7402 EXPECT_EQ(
7396 0.f, 7403 0.f,
7397 grand_parent_raw->draw_properties().maximum_animation_contents_scale); 7404 grand_parent_raw->draw_properties().maximum_animation_contents_scale);
7398 EXPECT_EQ(0.f, 7405 EXPECT_EQ(0.f,
7399 parent_raw->draw_properties().maximum_animation_contents_scale); 7406 parent_raw->draw_properties().maximum_animation_contents_scale);
7400 EXPECT_EQ(0.f, child_raw->draw_properties().maximum_animation_contents_scale); 7407 EXPECT_EQ(0.f, child_raw->draw_properties().maximum_animation_contents_scale);
7401 EXPECT_EQ( 7408 EXPECT_EQ(
7402 0.f, grand_child_raw->draw_properties().maximum_animation_contents_scale); 7409 0.f, grand_child_raw->draw_properties().maximum_animation_contents_scale);
7403 7410
7404 EXPECT_EQ( 7411 EXPECT_EQ(
7405 0.f, 7412 0.f,
7406 grand_parent_raw->draw_properties().starting_animation_contents_scale); 7413 grand_parent_raw->draw_properties().starting_animation_contents_scale);
7407 EXPECT_EQ(0.f, 7414 EXPECT_EQ(0.f,
7408 parent_raw->draw_properties().starting_animation_contents_scale); 7415 parent_raw->draw_properties().starting_animation_contents_scale);
7409 EXPECT_EQ(0.f, 7416 EXPECT_EQ(0.f,
7410 child_raw->draw_properties().starting_animation_contents_scale); 7417 child_raw->draw_properties().starting_animation_contents_scale);
7411 EXPECT_EQ( 7418 EXPECT_EQ(
7412 0.f, 7419 0.f,
7413 grand_child_raw->draw_properties().starting_animation_contents_scale); 7420 grand_child_raw->draw_properties().starting_animation_contents_scale);
7414 7421
7415 AbortAnimationsOnLayerWithPlayer(child_raw->id(), timeline, 7422 AbortAnimationsOnElementWithPlayer(child_raw->element_id(), timeline,
7416 TargetProperty::TRANSFORM); 7423 TargetProperty::TRANSFORM);
7417 gfx::Transform scale_matrix; 7424 gfx::Transform scale_matrix;
7418 scale_matrix.Scale(1.f, 2.f); 7425 scale_matrix.Scale(1.f, 2.f);
7419 grand_parent_raw->SetTransform(scale_matrix); 7426 grand_parent_raw->SetTransform(scale_matrix);
7420 parent_raw->SetTransform(scale_matrix); 7427 parent_raw->SetTransform(scale_matrix);
7421 grand_parent_raw->layer_tree_impl()->property_trees()->needs_rebuild = true; 7428 grand_parent_raw->layer_tree_impl()->property_trees()->needs_rebuild = true;
7422 7429
7423 AddAnimatedTransformToLayerWithPlayer(parent_raw->id(), timeline, 1.0, 7430 AddAnimatedTransformToElementWithPlayer(parent_raw->element_id(), timeline,
7424 TransformOperations(), scale); 7431 1.0, TransformOperations(), scale);
7425 ExecuteCalculateDrawProperties(grand_parent_raw); 7432 ExecuteCalculateDrawProperties(grand_parent_raw);
7426 7433
7427 // |grand_parent| and |parent| each have scale 2.f. |parent| has a scale 7434 // |grand_parent| and |parent| each have scale 2.f. |parent| has a scale
7428 // animation with maximum scale 5.f. 7435 // animation with maximum scale 5.f.
7429 EXPECT_EQ( 7436 EXPECT_EQ(
7430 0.f, 7437 0.f,
7431 grand_parent_raw->draw_properties().maximum_animation_contents_scale); 7438 grand_parent_raw->draw_properties().maximum_animation_contents_scale);
7432 EXPECT_EQ(10.f, 7439 EXPECT_EQ(10.f,
7433 parent_raw->draw_properties().maximum_animation_contents_scale); 7440 parent_raw->draw_properties().maximum_animation_contents_scale);
7434 EXPECT_EQ(10.f, 7441 EXPECT_EQ(10.f,
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
7551 7558
7552 TEST_F(LayerTreeHostCommonTest, RenderSurfaceLayerListMembership) { 7559 TEST_F(LayerTreeHostCommonTest, RenderSurfaceLayerListMembership) {
7553 FakeImplTaskRunnerProvider task_runner_provider; 7560 FakeImplTaskRunnerProvider task_runner_provider;
7554 TestSharedBitmapManager shared_bitmap_manager; 7561 TestSharedBitmapManager shared_bitmap_manager;
7555 TestTaskGraphRunner task_graph_runner; 7562 TestTaskGraphRunner task_graph_runner;
7556 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &shared_bitmap_manager, 7563 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &shared_bitmap_manager,
7557 &task_graph_runner); 7564 &task_graph_runner);
7558 gfx::Transform identity_matrix; 7565 gfx::Transform identity_matrix;
7559 7566
7560 std::unique_ptr<LayerImpl> grand_parent = 7567 std::unique_ptr<LayerImpl> grand_parent =
7561 LayerImpl::Create(host_impl.active_tree(), 1); 7568 CreateTestLayerImpl(host_impl.active_tree(), 1);
7562 std::unique_ptr<LayerImpl> parent = 7569 std::unique_ptr<LayerImpl> parent =
7563 LayerImpl::Create(host_impl.active_tree(), 3); 7570 CreateTestLayerImpl(host_impl.active_tree(), 3);
7564 std::unique_ptr<LayerImpl> child = 7571 std::unique_ptr<LayerImpl> child =
7565 LayerImpl::Create(host_impl.active_tree(), 5); 7572 CreateTestLayerImpl(host_impl.active_tree(), 5);
7566 std::unique_ptr<LayerImpl> grand_child1 = 7573 std::unique_ptr<LayerImpl> grand_child1 =
7567 LayerImpl::Create(host_impl.active_tree(), 7); 7574 CreateTestLayerImpl(host_impl.active_tree(), 7);
7568 std::unique_ptr<LayerImpl> grand_child2 = 7575 std::unique_ptr<LayerImpl> grand_child2 =
7569 LayerImpl::Create(host_impl.active_tree(), 9); 7576 CreateTestLayerImpl(host_impl.active_tree(), 9);
7570 7577
7571 LayerImpl* grand_parent_raw = grand_parent.get(); 7578 LayerImpl* grand_parent_raw = grand_parent.get();
7572 LayerImpl* parent_raw = parent.get(); 7579 LayerImpl* parent_raw = parent.get();
7573 LayerImpl* child_raw = child.get(); 7580 LayerImpl* child_raw = child.get();
7574 LayerImpl* grand_child1_raw = grand_child1.get(); 7581 LayerImpl* grand_child1_raw = grand_child1.get();
7575 LayerImpl* grand_child2_raw = grand_child2.get(); 7582 LayerImpl* grand_child2_raw = grand_child2.get();
7576 7583
7577 child->AddChild(std::move(grand_child1)); 7584 child->AddChild(std::move(grand_child1));
7578 child->AddChild(std::move(grand_child2)); 7585 child->AddChild(std::move(grand_child2));
7579 parent->AddChild(std::move(child)); 7586 parent->AddChild(std::move(child));
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
7667 EXPECT_TRUE(grand_child2_raw->is_drawn_render_surface_layer_list_member()); 7674 EXPECT_TRUE(grand_child2_raw->is_drawn_render_surface_layer_list_member());
7668 7675
7669 expected.clear(); 7676 expected.clear();
7670 expected.insert(grand_child2_raw); 7677 expected.insert(grand_child2_raw);
7671 7678
7672 actual.clear(); 7679 actual.clear();
7673 GatherDrawnLayers(render_surface_layer_list_impl(), &actual); 7680 GatherDrawnLayers(render_surface_layer_list_impl(), &actual);
7674 EXPECT_EQ(expected, actual); 7681 EXPECT_EQ(expected, actual);
7675 7682
7676 // Add a mask layer to child. 7683 // Add a mask layer to child.
7677 child_raw->SetMaskLayer(LayerImpl::Create(host_impl.active_tree(), 6)); 7684 child_raw->SetMaskLayer(CreateTestLayerImpl(host_impl.active_tree(), 6));
7678 child_raw->layer_tree_impl()->property_trees()->needs_rebuild = true; 7685 child_raw->layer_tree_impl()->property_trees()->needs_rebuild = true;
7679 7686
7680 ExecuteCalculateDrawProperties(grand_parent_raw); 7687 ExecuteCalculateDrawProperties(grand_parent_raw);
7681 7688
7682 EXPECT_FALSE(grand_parent_raw->is_drawn_render_surface_layer_list_member()); 7689 EXPECT_FALSE(grand_parent_raw->is_drawn_render_surface_layer_list_member());
7683 EXPECT_FALSE(parent_raw->is_drawn_render_surface_layer_list_member()); 7690 EXPECT_FALSE(parent_raw->is_drawn_render_surface_layer_list_member());
7684 EXPECT_FALSE(child_raw->is_drawn_render_surface_layer_list_member()); 7691 EXPECT_FALSE(child_raw->is_drawn_render_surface_layer_list_member());
7685 EXPECT_TRUE( 7692 EXPECT_TRUE(
7686 child_raw->mask_layer()->is_drawn_render_surface_layer_list_member()); 7693 child_raw->mask_layer()->is_drawn_render_surface_layer_list_member());
7687 EXPECT_FALSE(grand_child1_raw->is_drawn_render_surface_layer_list_member()); 7694 EXPECT_FALSE(grand_child1_raw->is_drawn_render_surface_layer_list_member());
7688 EXPECT_TRUE(grand_child2_raw->is_drawn_render_surface_layer_list_member()); 7695 EXPECT_TRUE(grand_child2_raw->is_drawn_render_surface_layer_list_member());
7689 7696
7690 expected.clear(); 7697 expected.clear();
7691 expected.insert(grand_child2_raw); 7698 expected.insert(grand_child2_raw);
7692 expected.insert(child_raw->mask_layer()); 7699 expected.insert(child_raw->mask_layer());
7693 7700
7694 expected.clear(); 7701 expected.clear();
7695 expected.insert(grand_child2_raw); 7702 expected.insert(grand_child2_raw);
7696 expected.insert(child_raw->mask_layer()); 7703 expected.insert(child_raw->mask_layer());
7697 7704
7698 actual.clear(); 7705 actual.clear();
7699 GatherDrawnLayers(render_surface_layer_list_impl(), &actual); 7706 GatherDrawnLayers(render_surface_layer_list_impl(), &actual);
7700 EXPECT_EQ(expected, actual); 7707 EXPECT_EQ(expected, actual);
7701 7708
7702 // Add replica mask layer. 7709 // Add replica mask layer.
7703 std::unique_ptr<LayerImpl> replica_layer = 7710 std::unique_ptr<LayerImpl> replica_layer =
7704 LayerImpl::Create(host_impl.active_tree(), 20); 7711 CreateTestLayerImpl(host_impl.active_tree(), 20);
7705 replica_layer->SetMaskLayer(LayerImpl::Create(host_impl.active_tree(), 21)); 7712 replica_layer->SetMaskLayer(CreateTestLayerImpl(host_impl.active_tree(), 21));
7706 child_raw->SetReplicaLayer(std::move(replica_layer)); 7713 child_raw->SetReplicaLayer(std::move(replica_layer));
7707 child_raw->layer_tree_impl()->property_trees()->needs_rebuild = true; 7714 child_raw->layer_tree_impl()->property_trees()->needs_rebuild = true;
7708 7715
7709 ExecuteCalculateDrawProperties(grand_parent_raw); 7716 ExecuteCalculateDrawProperties(grand_parent_raw);
7710 7717
7711 EXPECT_FALSE(grand_parent_raw->is_drawn_render_surface_layer_list_member()); 7718 EXPECT_FALSE(grand_parent_raw->is_drawn_render_surface_layer_list_member());
7712 EXPECT_FALSE(parent_raw->is_drawn_render_surface_layer_list_member()); 7719 EXPECT_FALSE(parent_raw->is_drawn_render_surface_layer_list_member());
7713 EXPECT_FALSE(child_raw->is_drawn_render_surface_layer_list_member()); 7720 EXPECT_FALSE(child_raw->is_drawn_render_surface_layer_list_member());
7714 EXPECT_TRUE( 7721 EXPECT_TRUE(
7715 child_raw->mask_layer()->is_drawn_render_surface_layer_list_member()); 7722 child_raw->mask_layer()->is_drawn_render_surface_layer_list_member());
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
7802 TEST_F(LayerTreeHostCommonTest, DrawPropertyScales) { 7809 TEST_F(LayerTreeHostCommonTest, DrawPropertyScales) {
7803 FakeImplTaskRunnerProvider task_runner_provider; 7810 FakeImplTaskRunnerProvider task_runner_provider;
7804 TestSharedBitmapManager shared_bitmap_manager; 7811 TestSharedBitmapManager shared_bitmap_manager;
7805 TestTaskGraphRunner task_graph_runner; 7812 TestTaskGraphRunner task_graph_runner;
7806 LayerTreeSettings settings = host()->settings(); 7813 LayerTreeSettings settings = host()->settings();
7807 settings.layer_transforms_should_scale_layer_contents = true; 7814 settings.layer_transforms_should_scale_layer_contents = true;
7808 FakeLayerTreeHostImpl host_impl(settings, &task_runner_provider, 7815 FakeLayerTreeHostImpl host_impl(settings, &task_runner_provider,
7809 &shared_bitmap_manager, &task_graph_runner); 7816 &shared_bitmap_manager, &task_graph_runner);
7810 7817
7811 std::unique_ptr<LayerImpl> root = 7818 std::unique_ptr<LayerImpl> root =
7812 LayerImpl::Create(host_impl.active_tree(), 1); 7819 CreateTestLayerImpl(host_impl.active_tree(), 1);
7813 LayerImpl* root_layer = root.get(); 7820 LayerImpl* root_layer = root.get();
7814 std::unique_ptr<LayerImpl> child1 = 7821 std::unique_ptr<LayerImpl> child1 =
7815 LayerImpl::Create(host_impl.active_tree(), 2); 7822 CreateTestLayerImpl(host_impl.active_tree(), 2);
7816 LayerImpl* child1_layer = child1.get(); 7823 LayerImpl* child1_layer = child1.get();
7817 std::unique_ptr<LayerImpl> child2 = 7824 std::unique_ptr<LayerImpl> child2 =
7818 LayerImpl::Create(host_impl.active_tree(), 3); 7825 CreateTestLayerImpl(host_impl.active_tree(), 3);
7819 LayerImpl* child2_layer = child2.get(); 7826 LayerImpl* child2_layer = child2.get();
7820 7827
7821 root->AddChild(std::move(child1)); 7828 root->AddChild(std::move(child1));
7822 root->AddChild(std::move(child2)); 7829 root->AddChild(std::move(child2));
7823 root->test_properties()->force_render_surface = true; 7830 root->test_properties()->force_render_surface = true;
7824 root->SetDrawsContent(true); 7831 root->SetDrawsContent(true);
7825 host_impl.active_tree()->SetRootLayer(std::move(root)); 7832 host_impl.active_tree()->SetRootLayer(std::move(root));
7826 7833
7827 gfx::Transform identity_matrix, scale_transform_child1, 7834 gfx::Transform identity_matrix, scale_transform_child1,
7828 scale_transform_child2; 7835 scale_transform_child2;
7829 scale_transform_child1.Scale(2, 3); 7836 scale_transform_child1.Scale(2, 3);
7830 scale_transform_child2.Scale(4, 5); 7837 scale_transform_child2.Scale(4, 5);
7831 7838
7832 SetLayerPropertiesForTesting(root_layer, identity_matrix, gfx::Point3F(), 7839 SetLayerPropertiesForTesting(root_layer, identity_matrix, gfx::Point3F(),
7833 gfx::PointF(), gfx::Size(1, 1), true, false, 7840 gfx::PointF(), gfx::Size(1, 1), true, false,
7834 true); 7841 true);
7835 SetLayerPropertiesForTesting(child1_layer, scale_transform_child1, 7842 SetLayerPropertiesForTesting(child1_layer, scale_transform_child1,
7836 gfx::Point3F(), gfx::PointF(), gfx::Size(1, 1), 7843 gfx::Point3F(), gfx::PointF(), gfx::Size(1, 1),
7837 true, false, false); 7844 true, false, false);
7838 7845
7839 child1_layer->SetMaskLayer(LayerImpl::Create(host_impl.active_tree(), 4)); 7846 child1_layer->SetMaskLayer(CreateTestLayerImpl(host_impl.active_tree(), 4));
7840 child1_layer->SetDrawsContent(true); 7847 child1_layer->SetDrawsContent(true);
7841 7848
7842 std::unique_ptr<LayerImpl> replica_layer = 7849 std::unique_ptr<LayerImpl> replica_layer =
7843 LayerImpl::Create(host_impl.active_tree(), 5); 7850 CreateTestLayerImpl(host_impl.active_tree(), 5);
7844 replica_layer->SetMaskLayer(LayerImpl::Create(host_impl.active_tree(), 6)); 7851 replica_layer->SetMaskLayer(CreateTestLayerImpl(host_impl.active_tree(), 6));
7845 child1_layer->SetReplicaLayer(std::move(replica_layer)); 7852 child1_layer->SetReplicaLayer(std::move(replica_layer));
7846 child1_layer->SetHasRenderSurface(true); 7853 child1_layer->SetHasRenderSurface(true);
7847 7854
7848 ExecuteCalculateDrawProperties(root_layer); 7855 ExecuteCalculateDrawProperties(root_layer);
7849 7856
7850 TransformOperations scale; 7857 TransformOperations scale;
7851 scale.AppendScale(5.f, 8.f, 3.f); 7858 scale.AppendScale(5.f, 8.f, 3.f);
7852 7859
7853 scoped_refptr<AnimationTimeline> timeline = 7860 scoped_refptr<AnimationTimeline> timeline =
7854 AnimationTimeline::Create(AnimationIdProvider::NextTimelineId()); 7861 AnimationTimeline::Create(AnimationIdProvider::NextTimelineId());
7855 host_impl.animation_host()->AddAnimationTimeline(timeline); 7862 host_impl.animation_host()->AddAnimationTimeline(timeline);
7856 7863
7857 AddAnimatedTransformToLayerWithPlayer(child2_layer->id(), timeline, 1.0, 7864 AddAnimatedTransformToElementWithPlayer(child2_layer->element_id(), timeline,
7858 TransformOperations(), scale); 7865 1.0, TransformOperations(), scale);
7859 7866
7860 SetLayerPropertiesForTesting(child2_layer, scale_transform_child2, 7867 SetLayerPropertiesForTesting(child2_layer, scale_transform_child2,
7861 gfx::Point3F(), gfx::PointF(), gfx::Size(1, 1), 7868 gfx::Point3F(), gfx::PointF(), gfx::Size(1, 1),
7862 true, false, false); 7869 true, false, false);
7863 child2_layer->SetDrawsContent(true); 7870 child2_layer->SetDrawsContent(true);
7864 7871
7865 root_layer->layer_tree_impl()->property_trees()->needs_rebuild = true; 7872 root_layer->layer_tree_impl()->property_trees()->needs_rebuild = true;
7866 ExecuteCalculateDrawProperties(root_layer); 7873 ExecuteCalculateDrawProperties(root_layer);
7867 7874
7868 EXPECT_FLOAT_EQ(1.f, root_layer->GetIdealContentsScale()); 7875 EXPECT_FLOAT_EQ(1.f, root_layer->GetIdealContentsScale());
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
8013 8020
8014 // Sublayer should be bigger than the root enlarged by bounds_delta. 8021 // Sublayer should be bigger than the root enlarged by bounds_delta.
8015 gfx::Size sublayer_size = gfx::Size(300, 1000); 8022 gfx::Size sublayer_size = gfx::Size(300, 1000);
8016 8023
8017 // Device viewport accomidated the root and the top controls. 8024 // Device viewport accomidated the root and the top controls.
8018 gfx::Size device_viewport_size = gfx::Size(300, 600); 8025 gfx::Size device_viewport_size = gfx::Size(300, 600);
8019 gfx::Transform identity_matrix; 8026 gfx::Transform identity_matrix;
8020 8027
8021 host_impl.SetViewportSize(device_viewport_size); 8028 host_impl.SetViewportSize(device_viewport_size);
8022 host_impl.active_tree()->SetRootLayer( 8029 host_impl.active_tree()->SetRootLayer(
8023 LayerImpl::Create(host_impl.active_tree(), 1)); 8030 CreateTestLayerImpl(host_impl.active_tree(), 1));
8024 8031
8025 LayerImpl* root = host_impl.active_tree()->root_layer(); 8032 LayerImpl* root = host_impl.active_tree()->root_layer();
8026 SetLayerPropertiesForTesting(root, 8033 SetLayerPropertiesForTesting(root,
8027 identity_matrix, 8034 identity_matrix,
8028 gfx::Point3F(), 8035 gfx::Point3F(),
8029 gfx::PointF(), 8036 gfx::PointF(),
8030 root_size, 8037 root_size,
8031 false, 8038 false,
8032 false, 8039 false,
8033 true); 8040 true);
8034 root->SetMasksToBounds(true); 8041 root->SetMasksToBounds(true);
8035 8042
8036 root->AddChild(LayerImpl::Create(host_impl.active_tree(), 2)); 8043 root->AddChild(CreateTestLayerImpl(host_impl.active_tree(), 2));
8037 8044
8038 LayerImpl* sublayer = root->child_at(0); 8045 LayerImpl* sublayer = root->child_at(0);
8039 SetLayerPropertiesForTesting(sublayer, 8046 SetLayerPropertiesForTesting(sublayer,
8040 identity_matrix, 8047 identity_matrix,
8041 gfx::Point3F(), 8048 gfx::Point3F(),
8042 gfx::PointF(), 8049 gfx::PointF(),
8043 sublayer_size, 8050 sublayer_size,
8044 false, 8051 false,
8045 false, 8052 false,
8046 false); 8053 false);
8047 sublayer->SetDrawsContent(true); 8054 sublayer->SetDrawsContent(true);
8048 8055
8049 LayerImplList layer_impl_list; 8056 LayerImplList layer_impl_list;
8050 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( 8057 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs(
8051 root, device_viewport_size, &layer_impl_list); 8058 root, device_viewport_size, &layer_impl_list);
8052 8059
8053 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); 8060 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs);
8054 EXPECT_EQ(gfx::Rect(root_size), sublayer->visible_layer_rect()); 8061 EXPECT_EQ(gfx::Rect(root_size), sublayer->visible_layer_rect());
8055 8062
8056 root->SetBoundsDelta(gfx::Vector2dF(0.0, 50.0)); 8063 root->SetBoundsDelta(gfx::Vector2dF(0.0, 50.0));
8057 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); 8064 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs);
8058 8065
8059 gfx::Rect affected_by_delta(0, 0, root_size.width(), 8066 gfx::Rect affected_by_delta(0, 0, root_size.width(),
8060 root_size.height() + 50); 8067 root_size.height() + 50);
8061 EXPECT_EQ(affected_by_delta, sublayer->visible_layer_rect()); 8068 EXPECT_EQ(affected_by_delta, sublayer->visible_layer_rect());
8062 } 8069 }
8063 8070
8064 TEST_F(LayerTreeHostCommonTest, NodesAffectedByBoundsDeltaGetUpdated) { 8071 TEST_F(LayerTreeHostCommonTest, NodesAffectedByBoundsDeltaGetUpdated) {
8065 scoped_refptr<Layer> root = Layer::Create(); 8072 scoped_refptr<Layer> root = CreateTestLayer();
8066 scoped_refptr<Layer> inner_viewport_container_layer = Layer::Create(); 8073 scoped_refptr<Layer> inner_viewport_container_layer = CreateTestLayer();
8067 scoped_refptr<Layer> inner_viewport_scroll_layer = Layer::Create(); 8074 scoped_refptr<Layer> inner_viewport_scroll_layer = CreateTestLayer();
8068 scoped_refptr<Layer> outer_viewport_container_layer = Layer::Create(); 8075 scoped_refptr<Layer> outer_viewport_container_layer = CreateTestLayer();
8069 scoped_refptr<Layer> outer_viewport_scroll_layer = Layer::Create(); 8076 scoped_refptr<Layer> outer_viewport_scroll_layer = CreateTestLayer();
8070 8077
8071 root->AddChild(inner_viewport_container_layer); 8078 root->AddChild(inner_viewport_container_layer);
8072 inner_viewport_container_layer->AddChild(inner_viewport_scroll_layer); 8079 inner_viewport_container_layer->AddChild(inner_viewport_scroll_layer);
8073 inner_viewport_scroll_layer->AddChild(outer_viewport_container_layer); 8080 inner_viewport_scroll_layer->AddChild(outer_viewport_container_layer);
8074 outer_viewport_container_layer->AddChild(outer_viewport_scroll_layer); 8081 outer_viewport_container_layer->AddChild(outer_viewport_scroll_layer);
8075 8082
8076 inner_viewport_scroll_layer->SetScrollClipLayerId( 8083 inner_viewport_scroll_layer->SetScrollClipLayerId(
8077 inner_viewport_container_layer->id()); 8084 inner_viewport_container_layer->id());
8078 outer_viewport_scroll_layer->SetScrollClipLayerId( 8085 outer_viewport_scroll_layer->SetScrollClipLayerId(
8079 outer_viewport_container_layer->id()); 8086 outer_viewport_container_layer->id());
8080 8087
8081 inner_viewport_scroll_layer->SetIsContainerForFixedPositionLayers(true); 8088 inner_viewport_scroll_layer->SetIsContainerForFixedPositionLayers(true);
8082 outer_viewport_scroll_layer->SetIsContainerForFixedPositionLayers(true); 8089 outer_viewport_scroll_layer->SetIsContainerForFixedPositionLayers(true);
8083 8090
8084 host()->SetRootLayer(root); 8091 host()->SetRootLayer(root);
8085 host()->RegisterViewportLayers(nullptr, root, inner_viewport_scroll_layer, 8092 host()->RegisterViewportLayers(nullptr, root, inner_viewport_scroll_layer,
8086 outer_viewport_scroll_layer); 8093 outer_viewport_scroll_layer);
8087 8094
8088 scoped_refptr<Layer> fixed_to_inner = Layer::Create(); 8095 scoped_refptr<Layer> fixed_to_inner = CreateTestLayer();
8089 scoped_refptr<Layer> fixed_to_outer = Layer::Create(); 8096 scoped_refptr<Layer> fixed_to_outer = CreateTestLayer();
8090 8097
8091 inner_viewport_scroll_layer->AddChild(fixed_to_inner); 8098 inner_viewport_scroll_layer->AddChild(fixed_to_inner);
8092 outer_viewport_scroll_layer->AddChild(fixed_to_outer); 8099 outer_viewport_scroll_layer->AddChild(fixed_to_outer);
8093 8100
8094 LayerPositionConstraint fixed_to_right; 8101 LayerPositionConstraint fixed_to_right;
8095 fixed_to_right.set_is_fixed_position(true); 8102 fixed_to_right.set_is_fixed_position(true);
8096 fixed_to_right.set_is_fixed_to_right_edge(true); 8103 fixed_to_right.set_is_fixed_to_right_edge(true);
8097 8104
8098 fixed_to_inner->SetPositionConstraint(fixed_to_right); 8105 fixed_to_inner->SetPositionConstraint(fixed_to_right);
8099 fixed_to_outer->SetPositionConstraint(fixed_to_right); 8106 fixed_to_outer->SetPositionConstraint(fixed_to_right);
(...skipping 14 matching lines...) Expand all
8114 8121
8115 fixed_to_outer->SetPositionConstraint(fixed_to_left); 8122 fixed_to_outer->SetPositionConstraint(fixed_to_left);
8116 8123
8117 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); 8124 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get());
8118 EXPECT_FALSE(transform_tree.HasNodesAffectedByInnerViewportBoundsDelta()); 8125 EXPECT_FALSE(transform_tree.HasNodesAffectedByInnerViewportBoundsDelta());
8119 EXPECT_FALSE(transform_tree.HasNodesAffectedByOuterViewportBoundsDelta()); 8126 EXPECT_FALSE(transform_tree.HasNodesAffectedByOuterViewportBoundsDelta());
8120 } 8127 }
8121 8128
8122 TEST_F(LayerTreeHostCommonTest, VisibleContentRectForAnimatedLayer) { 8129 TEST_F(LayerTreeHostCommonTest, VisibleContentRectForAnimatedLayer) {
8123 const gfx::Transform identity_matrix; 8130 const gfx::Transform identity_matrix;
8124 scoped_refptr<Layer> root = Layer::Create(); 8131 scoped_refptr<Layer> root = CreateTestLayer();
8125 scoped_refptr<LayerWithForcedDrawsContent> animated = 8132 scoped_refptr<LayerWithForcedDrawsContent> animated =
8126 make_scoped_refptr(new LayerWithForcedDrawsContent()); 8133 make_scoped_refptr(new LayerWithForcedDrawsContent());
8127 8134
8128 root->AddChild(animated); 8135 root->AddChild(animated);
8129 8136
8130 host()->SetRootLayer(root); 8137 host()->SetRootLayer(root);
8131 8138
8132 SetLayerPropertiesForTesting(root.get(), identity_matrix, gfx::Point3F(), 8139 SetLayerPropertiesForTesting(root.get(), identity_matrix, gfx::Point3F(),
8133 gfx::PointF(), gfx::Size(100, 100), true, false); 8140 gfx::PointF(), gfx::Size(100, 100), true, false);
8134 SetLayerPropertiesForTesting(animated.get(), identity_matrix, gfx::Point3F(), 8141 SetLayerPropertiesForTesting(animated.get(), identity_matrix, gfx::Point3F(),
8135 gfx::PointF(), gfx::Size(20, 20), true, false); 8142 gfx::PointF(), gfx::Size(20, 20), true, false);
8136 8143
8137 root->SetMasksToBounds(true); 8144 root->SetMasksToBounds(true);
8138 root->SetForceRenderSurfaceForTesting(true); 8145 root->SetForceRenderSurfaceForTesting(true);
8139 animated->SetOpacity(0.f); 8146 animated->SetOpacity(0.f);
8140 8147
8141 AddOpacityTransitionToLayerWithPlayer(animated->id(), timeline(), 10.0, 0.f, 8148 AddOpacityTransitionToElementWithPlayer(animated->element_id(), timeline(),
8142 1.f, false); 8149 10.0, 0.f, 1.f, false);
8143 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); 8150 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get());
8144 8151
8145 EXPECT_FALSE(animated->visible_layer_rect_for_testing().IsEmpty()); 8152 EXPECT_FALSE(animated->visible_layer_rect_for_testing().IsEmpty());
8146 } 8153 }
8147 8154
8148 TEST_F(LayerTreeHostCommonTest, 8155 TEST_F(LayerTreeHostCommonTest,
8149 VisibleContentRectForAnimatedLayerWithSingularTransform) { 8156 VisibleContentRectForAnimatedLayerWithSingularTransform) {
8150 const gfx::Transform identity_matrix; 8157 const gfx::Transform identity_matrix;
8151 scoped_refptr<Layer> root = Layer::Create(); 8158 scoped_refptr<Layer> root = CreateTestLayer();
8152 scoped_refptr<Layer> clip = Layer::Create(); 8159 scoped_refptr<Layer> clip = CreateTestLayer();
8153 scoped_refptr<LayerWithForcedDrawsContent> animated = 8160 scoped_refptr<LayerWithForcedDrawsContent> animated =
8154 make_scoped_refptr(new LayerWithForcedDrawsContent()); 8161 make_scoped_refptr(new LayerWithForcedDrawsContent());
8155 scoped_refptr<LayerWithForcedDrawsContent> surface = 8162 scoped_refptr<LayerWithForcedDrawsContent> surface =
8156 make_scoped_refptr(new LayerWithForcedDrawsContent()); 8163 make_scoped_refptr(new LayerWithForcedDrawsContent());
8157 scoped_refptr<LayerWithForcedDrawsContent> descendant_of_animation = 8164 scoped_refptr<LayerWithForcedDrawsContent> descendant_of_animation =
8158 make_scoped_refptr(new LayerWithForcedDrawsContent()); 8165 make_scoped_refptr(new LayerWithForcedDrawsContent());
8159 8166
8160 root->AddChild(clip); 8167 root->AddChild(clip);
8161 clip->AddChild(animated); 8168 clip->AddChild(animated);
8162 animated->AddChild(surface); 8169 animated->AddChild(surface);
(...skipping 17 matching lines...) Expand all
8180 SetLayerPropertiesForTesting(surface.get(), identity_matrix, gfx::Point3F(), 8187 SetLayerPropertiesForTesting(surface.get(), identity_matrix, gfx::Point3F(),
8181 gfx::PointF(), gfx::Size(100, 100), true, false); 8188 gfx::PointF(), gfx::Size(100, 100), true, false);
8182 SetLayerPropertiesForTesting(descendant_of_animation.get(), identity_matrix, 8189 SetLayerPropertiesForTesting(descendant_of_animation.get(), identity_matrix,
8183 gfx::Point3F(), gfx::PointF(), 8190 gfx::Point3F(), gfx::PointF(),
8184 gfx::Size(200, 200), true, false); 8191 gfx::Size(200, 200), true, false);
8185 8192
8186 TransformOperations start_transform_operations; 8193 TransformOperations start_transform_operations;
8187 start_transform_operations.AppendMatrix(uninvertible_matrix); 8194 start_transform_operations.AppendMatrix(uninvertible_matrix);
8188 TransformOperations end_transform_operations; 8195 TransformOperations end_transform_operations;
8189 8196
8190 AddAnimatedTransformToLayerWithPlayer(animated->id(), timeline(), 10.0, 8197 AddAnimatedTransformToElementWithPlayer(animated->element_id(), timeline(),
8191 start_transform_operations, 8198 10.0, start_transform_operations,
8192 end_transform_operations); 8199 end_transform_operations);
8193 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); 8200 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get());
8194 8201
8195 // The animated layer has a singular transform and maps to a non-empty rect in 8202 // The animated layer has a singular transform and maps to a non-empty rect in
8196 // clipped target space, so is treated as fully visible. 8203 // clipped target space, so is treated as fully visible.
8197 EXPECT_EQ(gfx::Rect(120, 120), animated->visible_layer_rect_for_testing()); 8204 EXPECT_EQ(gfx::Rect(120, 120), animated->visible_layer_rect_for_testing());
8198 8205
8199 // The singular transform on |animated| is flattened when inherited by 8206 // The singular transform on |animated| is flattened when inherited by
8200 // |surface|, and this happens to make it invertible. 8207 // |surface|, and this happens to make it invertible.
8201 EXPECT_EQ(gfx::Rect(2, 2), surface->visible_layer_rect_for_testing()); 8208 EXPECT_EQ(gfx::Rect(2, 2), surface->visible_layer_rect_for_testing());
8202 EXPECT_EQ(gfx::Rect(2, 2), 8209 EXPECT_EQ(gfx::Rect(2, 2),
(...skipping 14 matching lines...) Expand all
8217 // means the clip cannot be projected into |surface|'s space, so we treat 8224 // means the clip cannot be projected into |surface|'s space, so we treat
8218 // |surface| and layers that draw into it as having empty visible rect. 8225 // |surface| and layers that draw into it as having empty visible rect.
8219 EXPECT_EQ(gfx::Rect(), surface->visible_layer_rect_for_testing()); 8226 EXPECT_EQ(gfx::Rect(), surface->visible_layer_rect_for_testing());
8220 EXPECT_EQ(gfx::Rect(), 8227 EXPECT_EQ(gfx::Rect(),
8221 descendant_of_animation->visible_layer_rect_for_testing()); 8228 descendant_of_animation->visible_layer_rect_for_testing());
8222 } 8229 }
8223 8230
8224 // Verify that having an animated filter (but no current filter, as these 8231 // Verify that having an animated filter (but no current filter, as these
8225 // are mutually exclusive) correctly creates a render surface. 8232 // are mutually exclusive) correctly creates a render surface.
8226 TEST_F(LayerTreeHostCommonTest, AnimatedFilterCreatesRenderSurface) { 8233 TEST_F(LayerTreeHostCommonTest, AnimatedFilterCreatesRenderSurface) {
8227 scoped_refptr<Layer> root = Layer::Create(); 8234 scoped_refptr<Layer> root = CreateTestLayer();
8228 scoped_refptr<Layer> child = Layer::Create(); 8235 scoped_refptr<Layer> child = CreateTestLayer();
8229 scoped_refptr<Layer> grandchild = Layer::Create(); 8236 scoped_refptr<Layer> grandchild = CreateTestLayer();
8230 root->AddChild(child); 8237 root->AddChild(child);
8231 child->AddChild(grandchild); 8238 child->AddChild(grandchild);
8232 8239
8233 gfx::Transform identity_transform; 8240 gfx::Transform identity_transform;
8234 SetLayerPropertiesForTesting(root.get(), identity_transform, gfx::Point3F(), 8241 SetLayerPropertiesForTesting(root.get(), identity_transform, gfx::Point3F(),
8235 gfx::PointF(), gfx::Size(50, 50), true, false); 8242 gfx::PointF(), gfx::Size(50, 50), true, false);
8236 SetLayerPropertiesForTesting(child.get(), identity_transform, gfx::Point3F(), 8243 SetLayerPropertiesForTesting(child.get(), identity_transform, gfx::Point3F(),
8237 gfx::PointF(), gfx::Size(50, 50), true, false); 8244 gfx::PointF(), gfx::Size(50, 50), true, false);
8238 SetLayerPropertiesForTesting(grandchild.get(), identity_transform, 8245 SetLayerPropertiesForTesting(grandchild.get(), identity_transform,
8239 gfx::Point3F(), gfx::PointF(), gfx::Size(50, 50), 8246 gfx::Point3F(), gfx::PointF(), gfx::Size(50, 50),
8240 true, false); 8247 true, false);
8241 host()->SetRootLayer(root); 8248 host()->SetRootLayer(root);
8242 8249
8243 AddAnimatedFilterToLayerWithPlayer(child->id(), timeline(), 10.0, 0.1f, 0.2f); 8250 AddAnimatedFilterToElementWithPlayer(child->element_id(), timeline(), 10.0,
8251 0.1f, 0.2f);
8244 ExecuteCalculateDrawProperties(root.get()); 8252 ExecuteCalculateDrawProperties(root.get());
8245 8253
8246 EXPECT_TRUE(root->has_render_surface()); 8254 EXPECT_TRUE(root->has_render_surface());
8247 EXPECT_TRUE(child->has_render_surface()); 8255 EXPECT_TRUE(child->has_render_surface());
8248 EXPECT_FALSE(grandchild->has_render_surface()); 8256 EXPECT_FALSE(grandchild->has_render_surface());
8249 8257
8250 EXPECT_TRUE(root->filters().IsEmpty()); 8258 EXPECT_TRUE(root->filters().IsEmpty());
8251 EXPECT_TRUE(child->filters().IsEmpty()); 8259 EXPECT_TRUE(child->filters().IsEmpty());
8252 EXPECT_TRUE(grandchild->filters().IsEmpty()); 8260 EXPECT_TRUE(grandchild->filters().IsEmpty());
8253 8261
8254 EXPECT_FALSE(root->FilterIsAnimating()); 8262 EXPECT_FALSE(root->FilterIsAnimating());
8255 EXPECT_TRUE(child->FilterIsAnimating()); 8263 EXPECT_TRUE(child->FilterIsAnimating());
8256 EXPECT_FALSE(grandchild->FilterIsAnimating()); 8264 EXPECT_FALSE(grandchild->FilterIsAnimating());
8257 } 8265 }
8258 8266
8259 // Verify that having a filter animation with a delayed start time creates a 8267 // Verify that having a filter animation with a delayed start time creates a
8260 // render surface. 8268 // render surface.
8261 TEST_F(LayerTreeHostCommonTest, DelayedFilterAnimationCreatesRenderSurface) { 8269 TEST_F(LayerTreeHostCommonTest, DelayedFilterAnimationCreatesRenderSurface) {
8262 scoped_refptr<Layer> root = Layer::Create(); 8270 scoped_refptr<Layer> root = CreateTestLayer();
8263 scoped_refptr<Layer> child = Layer::Create(); 8271 scoped_refptr<Layer> child = CreateTestLayer();
8264 scoped_refptr<Layer> grandchild = Layer::Create(); 8272 scoped_refptr<Layer> grandchild = CreateTestLayer();
8265 root->AddChild(child); 8273 root->AddChild(child);
8266 child->AddChild(grandchild); 8274 child->AddChild(grandchild);
8267 8275
8268 gfx::Transform identity_transform; 8276 gfx::Transform identity_transform;
8269 SetLayerPropertiesForTesting(root.get(), identity_transform, gfx::Point3F(), 8277 SetLayerPropertiesForTesting(root.get(), identity_transform, gfx::Point3F(),
8270 gfx::PointF(), gfx::Size(50, 50), true, false); 8278 gfx::PointF(), gfx::Size(50, 50), true, false);
8271 SetLayerPropertiesForTesting(child.get(), identity_transform, gfx::Point3F(), 8279 SetLayerPropertiesForTesting(child.get(), identity_transform, gfx::Point3F(),
8272 gfx::PointF(), gfx::Size(50, 50), true, false); 8280 gfx::PointF(), gfx::Size(50, 50), true, false);
8273 SetLayerPropertiesForTesting(grandchild.get(), identity_transform, 8281 SetLayerPropertiesForTesting(grandchild.get(), identity_transform,
8274 gfx::Point3F(), gfx::PointF(), gfx::Size(50, 50), 8282 gfx::Point3F(), gfx::PointF(), gfx::Size(50, 50),
8275 true, false); 8283 true, false);
8276 host()->SetRootLayer(root); 8284 host()->SetRootLayer(root);
8277 8285
8278 std::unique_ptr<KeyframedFilterAnimationCurve> curve( 8286 std::unique_ptr<KeyframedFilterAnimationCurve> curve(
8279 KeyframedFilterAnimationCurve::Create()); 8287 KeyframedFilterAnimationCurve::Create());
8280 FilterOperations start_filters; 8288 FilterOperations start_filters;
8281 start_filters.Append(FilterOperation::CreateBrightnessFilter(0.1f)); 8289 start_filters.Append(FilterOperation::CreateBrightnessFilter(0.1f));
8282 FilterOperations end_filters; 8290 FilterOperations end_filters;
8283 end_filters.Append(FilterOperation::CreateBrightnessFilter(0.3f)); 8291 end_filters.Append(FilterOperation::CreateBrightnessFilter(0.3f));
8284 curve->AddKeyframe( 8292 curve->AddKeyframe(
8285 FilterKeyframe::Create(base::TimeDelta(), start_filters, nullptr)); 8293 FilterKeyframe::Create(base::TimeDelta(), start_filters, nullptr));
8286 curve->AddKeyframe(FilterKeyframe::Create( 8294 curve->AddKeyframe(FilterKeyframe::Create(
8287 base::TimeDelta::FromMilliseconds(100), end_filters, nullptr)); 8295 base::TimeDelta::FromMilliseconds(100), end_filters, nullptr));
8288 std::unique_ptr<Animation> animation = 8296 std::unique_ptr<Animation> animation =
8289 Animation::Create(std::move(curve), 0, 1, TargetProperty::FILTER); 8297 Animation::Create(std::move(curve), 0, 1, TargetProperty::FILTER);
8290 animation->set_fill_mode(Animation::FILL_MODE_NONE); 8298 animation->set_fill_mode(Animation::FILL_MODE_NONE);
8291 animation->set_time_offset(base::TimeDelta::FromMilliseconds(-1000)); 8299 animation->set_time_offset(base::TimeDelta::FromMilliseconds(-1000));
8292 8300
8293 AddAnimationToLayerWithPlayer(child->id(), timeline(), std::move(animation)); 8301 AddAnimationToElementWithPlayer(child->element_id(), timeline(),
8302 std::move(animation));
8294 ExecuteCalculateDrawProperties(root.get()); 8303 ExecuteCalculateDrawProperties(root.get());
8295 8304
8296 EXPECT_TRUE(root->has_render_surface()); 8305 EXPECT_TRUE(root->has_render_surface());
8297 EXPECT_TRUE(child->has_render_surface()); 8306 EXPECT_TRUE(child->has_render_surface());
8298 EXPECT_FALSE(grandchild->has_render_surface()); 8307 EXPECT_FALSE(grandchild->has_render_surface());
8299 8308
8300 EXPECT_TRUE(root->filters().IsEmpty()); 8309 EXPECT_TRUE(root->filters().IsEmpty());
8301 EXPECT_TRUE(child->filters().IsEmpty()); 8310 EXPECT_TRUE(child->filters().IsEmpty());
8302 EXPECT_TRUE(grandchild->filters().IsEmpty()); 8311 EXPECT_TRUE(grandchild->filters().IsEmpty());
8303 8312
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
8379 TEST_F(LayerTreeHostCommonTest, CombineClipsUsingContentTarget) { 8388 TEST_F(LayerTreeHostCommonTest, CombineClipsUsingContentTarget) {
8380 // In the following layer tree, the layer |box|'s render target is |surface|. 8389 // In the following layer tree, the layer |box|'s render target is |surface|.
8381 // |surface| also creates a transform node. We want to combine clips for |box| 8390 // |surface| also creates a transform node. We want to combine clips for |box|
8382 // in the space of its target (i.e., |surface|), not its target's target. This 8391 // in the space of its target (i.e., |surface|), not its target's target. This
8383 // test ensures that happens. 8392 // test ensures that happens.
8384 8393
8385 gfx::Transform rotate; 8394 gfx::Transform rotate;
8386 rotate.Rotate(5); 8395 rotate.Rotate(5);
8387 gfx::Transform identity; 8396 gfx::Transform identity;
8388 8397
8389 scoped_refptr<Layer> root = Layer::Create(); 8398 scoped_refptr<Layer> root = CreateTestLayer();
8390 SetLayerPropertiesForTesting(root.get(), identity, gfx::Point3F(), 8399 SetLayerPropertiesForTesting(root.get(), identity, gfx::Point3F(),
8391 gfx::PointF(), gfx::Size(2500, 1500), true, 8400 gfx::PointF(), gfx::Size(2500, 1500), true,
8392 false); 8401 false);
8393 8402
8394 scoped_refptr<Layer> frame_clip = Layer::Create(); 8403 scoped_refptr<Layer> frame_clip = CreateTestLayer();
8395 SetLayerPropertiesForTesting(frame_clip.get(), identity, gfx::Point3F(), 8404 SetLayerPropertiesForTesting(frame_clip.get(), identity, gfx::Point3F(),
8396 gfx::PointF(), gfx::Size(2500, 1500), true, 8405 gfx::PointF(), gfx::Size(2500, 1500), true,
8397 false); 8406 false);
8398 frame_clip->SetMasksToBounds(true); 8407 frame_clip->SetMasksToBounds(true);
8399 8408
8400 scoped_refptr<Layer> rotated = Layer::Create(); 8409 scoped_refptr<Layer> rotated = CreateTestLayer();
8401 SetLayerPropertiesForTesting(rotated.get(), rotate, 8410 SetLayerPropertiesForTesting(rotated.get(), rotate,
8402 gfx::Point3F(1250, 250, 0), gfx::PointF(), 8411 gfx::Point3F(1250, 250, 0), gfx::PointF(),
8403 gfx::Size(2500, 500), true, false); 8412 gfx::Size(2500, 500), true, false);
8404 8413
8405 scoped_refptr<Layer> surface = Layer::Create(); 8414 scoped_refptr<Layer> surface = CreateTestLayer();
8406 SetLayerPropertiesForTesting(surface.get(), rotate, gfx::Point3F(), 8415 SetLayerPropertiesForTesting(surface.get(), rotate, gfx::Point3F(),
8407 gfx::PointF(), gfx::Size(2500, 500), true, 8416 gfx::PointF(), gfx::Size(2500, 500), true,
8408 false); 8417 false);
8409 surface->SetOpacity(0.5); 8418 surface->SetOpacity(0.5);
8410 8419
8411 scoped_refptr<LayerWithForcedDrawsContent> container = 8420 scoped_refptr<LayerWithForcedDrawsContent> container =
8412 make_scoped_refptr(new LayerWithForcedDrawsContent()); 8421 make_scoped_refptr(new LayerWithForcedDrawsContent());
8413 SetLayerPropertiesForTesting(container.get(), identity, gfx::Point3F(), 8422 SetLayerPropertiesForTesting(container.get(), identity, gfx::Point3F(),
8414 gfx::PointF(), gfx::Size(300, 300), true, false); 8423 gfx::PointF(), gfx::Size(300, 300), true, false);
8415 8424
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
8502 } 8511 }
8503 8512
8504 TEST_F(LayerTreeHostCommonTest, ChangingAxisAlignmentTriggersRebuild) { 8513 TEST_F(LayerTreeHostCommonTest, ChangingAxisAlignmentTriggersRebuild) {
8505 gfx::Transform identity; 8514 gfx::Transform identity;
8506 gfx::Transform translate; 8515 gfx::Transform translate;
8507 gfx::Transform rotate; 8516 gfx::Transform rotate;
8508 8517
8509 translate.Translate(10, 10); 8518 translate.Translate(10, 10);
8510 rotate.Rotate(45); 8519 rotate.Rotate(45);
8511 8520
8512 scoped_refptr<Layer> root = Layer::Create(); 8521 scoped_refptr<Layer> root = CreateTestLayer();
8513 SetLayerPropertiesForTesting(root.get(), identity, gfx::Point3F(), 8522 SetLayerPropertiesForTesting(root.get(), identity, gfx::Point3F(),
8514 gfx::PointF(), gfx::Size(800, 800), true, false); 8523 gfx::PointF(), gfx::Size(800, 800), true, false);
8515 root->SetIsContainerForFixedPositionLayers(true); 8524 root->SetIsContainerForFixedPositionLayers(true);
8516 8525
8517 host()->SetRootLayer(root); 8526 host()->SetRootLayer(root);
8518 8527
8519 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); 8528 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get());
8520 EXPECT_FALSE(host()->property_trees()->needs_rebuild); 8529 EXPECT_FALSE(host()->property_trees()->needs_rebuild);
8521 8530
8522 root->SetTransform(translate); 8531 root->SetTransform(translate);
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
8593 static void CopyOutputCallback(std::unique_ptr<CopyOutputResult> result) {} 8602 static void CopyOutputCallback(std::unique_ptr<CopyOutputResult> result) {}
8594 8603
8595 TEST_F(LayerTreeHostCommonTest, NumCopyRequestsInTargetSubtree) { 8604 TEST_F(LayerTreeHostCommonTest, NumCopyRequestsInTargetSubtree) {
8596 // If the layer has a node in effect_tree, the return value of 8605 // If the layer has a node in effect_tree, the return value of
8597 // num_copy_requests_in_target_subtree() must be equal to the actual number 8606 // num_copy_requests_in_target_subtree() must be equal to the actual number
8598 // of copy requests in the sub-layer_tree; Otherwise, the number is expected 8607 // of copy requests in the sub-layer_tree; Otherwise, the number is expected
8599 // to be the value of its nearest ancestor that owns an effect node and 8608 // to be the value of its nearest ancestor that owns an effect node and
8600 // greater than or equal to the actual number of copy requests in the 8609 // greater than or equal to the actual number of copy requests in the
8601 // sub-layer_tree. 8610 // sub-layer_tree.
8602 8611
8603 scoped_refptr<Layer> root = Layer::Create(); 8612 scoped_refptr<Layer> root = CreateTestLayer();
8604 scoped_refptr<Layer> child1 = Layer::Create(); 8613 scoped_refptr<Layer> child1 = CreateTestLayer();
8605 scoped_refptr<Layer> child2 = Layer::Create(); 8614 scoped_refptr<Layer> child2 = CreateTestLayer();
8606 scoped_refptr<Layer> grandchild = Layer::Create(); 8615 scoped_refptr<Layer> grandchild = CreateTestLayer();
8607 scoped_refptr<Layer> greatgrandchild = Layer::Create(); 8616 scoped_refptr<Layer> greatgrandchild = CreateTestLayer();
8608 8617
8609 root->AddChild(child1); 8618 root->AddChild(child1);
8610 root->AddChild(child2); 8619 root->AddChild(child2);
8611 child1->AddChild(grandchild); 8620 child1->AddChild(grandchild);
8612 grandchild->AddChild(greatgrandchild); 8621 grandchild->AddChild(greatgrandchild);
8613 host()->SetRootLayer(root); 8622 host()->SetRootLayer(root);
8614 8623
8615 child1->RequestCopyOfOutput( 8624 child1->RequestCopyOfOutput(
8616 CopyOutputRequest::CreateBitmapRequest(base::Bind(&CopyOutputCallback))); 8625 CopyOutputRequest::CreateBitmapRequest(base::Bind(&CopyOutputCallback)));
8617 greatgrandchild->RequestCopyOfOutput( 8626 greatgrandchild->RequestCopyOfOutput(
8618 CopyOutputRequest::CreateBitmapRequest(base::Bind(&CopyOutputCallback))); 8627 CopyOutputRequest::CreateBitmapRequest(base::Bind(&CopyOutputCallback)));
8619 child2->SetOpacity(0.f); 8628 child2->SetOpacity(0.f);
8620 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); 8629 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get());
8621 8630
8622 EXPECT_EQ(root->num_copy_requests_in_target_subtree(), 2); 8631 EXPECT_EQ(root->num_copy_requests_in_target_subtree(), 2);
8623 EXPECT_EQ(child1->num_copy_requests_in_target_subtree(), 2); 8632 EXPECT_EQ(child1->num_copy_requests_in_target_subtree(), 2);
8624 EXPECT_EQ(child2->num_copy_requests_in_target_subtree(), 0); 8633 EXPECT_EQ(child2->num_copy_requests_in_target_subtree(), 0);
8625 EXPECT_EQ(grandchild->num_copy_requests_in_target_subtree(), 2); 8634 EXPECT_EQ(grandchild->num_copy_requests_in_target_subtree(), 2);
8626 EXPECT_EQ(greatgrandchild->num_copy_requests_in_target_subtree(), 1); 8635 EXPECT_EQ(greatgrandchild->num_copy_requests_in_target_subtree(), 1);
8627 } 8636 }
8628 8637
8629 TEST_F(LayerTreeHostCommonTest, SkippingSubtreeMain) { 8638 TEST_F(LayerTreeHostCommonTest, SkippingSubtreeMain) {
8630 gfx::Transform identity; 8639 gfx::Transform identity;
8631 scoped_refptr<Layer> root = Layer::Create(); 8640 scoped_refptr<Layer> root = CreateTestLayer();
8632 FakeContentLayerClient client; 8641 FakeContentLayerClient client;
8633 client.set_bounds(root->bounds()); 8642 client.set_bounds(root->bounds());
8634 scoped_refptr<LayerWithForcedDrawsContent> child = 8643 scoped_refptr<LayerWithForcedDrawsContent> child =
8635 make_scoped_refptr(new LayerWithForcedDrawsContent()); 8644 make_scoped_refptr(new LayerWithForcedDrawsContent());
8636 scoped_refptr<LayerWithForcedDrawsContent> grandchild = 8645 scoped_refptr<LayerWithForcedDrawsContent> grandchild =
8637 make_scoped_refptr(new LayerWithForcedDrawsContent()); 8646 make_scoped_refptr(new LayerWithForcedDrawsContent());
8638 scoped_refptr<FakePictureLayer> greatgrandchild( 8647 scoped_refptr<FakePictureLayer> greatgrandchild(
8639 FakePictureLayer::Create(&client)); 8648 FakePictureLayer::Create(&client));
8640 SetLayerPropertiesForTesting(root.get(), identity, gfx::Point3F(), 8649 SetLayerPropertiesForTesting(root.get(), identity, gfx::Point3F(),
8641 gfx::PointF(), gfx::Size(100, 100), true, false); 8650 gfx::PointF(), gfx::Size(100, 100), true, false);
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
8679 child->SetTransform(zero_z_scale); 8688 child->SetTransform(zero_z_scale);
8680 8689
8681 // Add a transform animation with a start delay. Now, even though |child| has 8690 // Add a transform animation with a start delay. Now, even though |child| has
8682 // a singular transform, the subtree should still get processed. 8691 // a singular transform, the subtree should still get processed.
8683 int animation_id = 0; 8692 int animation_id = 0;
8684 std::unique_ptr<Animation> animation = Animation::Create( 8693 std::unique_ptr<Animation> animation = Animation::Create(
8685 std::unique_ptr<AnimationCurve>(new FakeTransformTransition(1.0)), 8694 std::unique_ptr<AnimationCurve>(new FakeTransformTransition(1.0)),
8686 animation_id, 1, TargetProperty::TRANSFORM); 8695 animation_id, 1, TargetProperty::TRANSFORM);
8687 animation->set_fill_mode(Animation::FILL_MODE_NONE); 8696 animation->set_fill_mode(Animation::FILL_MODE_NONE);
8688 animation->set_time_offset(base::TimeDelta::FromMilliseconds(-1000)); 8697 animation->set_time_offset(base::TimeDelta::FromMilliseconds(-1000));
8689 AddAnimationToLayerWithPlayer(child->id(), timeline(), std::move(animation)); 8698 AddAnimationToElementWithPlayer(child->element_id(), timeline(),
8699 std::move(animation));
8690 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); 8700 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get());
8691 EXPECT_EQ(gfx::Rect(10, 10), grandchild->visible_layer_rect_for_testing()); 8701 EXPECT_EQ(gfx::Rect(10, 10), grandchild->visible_layer_rect_for_testing());
8692 grandchild->set_visible_layer_rect(gfx::Rect()); 8702 grandchild->set_visible_layer_rect(gfx::Rect());
8693 8703
8694 RemoveAnimationFromLayerWithExistingPlayer(child->id(), timeline(), 8704 RemoveAnimationFromElementWithExistingPlayer(child->element_id(), timeline(),
8695 animation_id); 8705 animation_id);
8696 child->SetTransform(identity); 8706 child->SetTransform(identity);
8697 child->SetOpacity(0.f); 8707 child->SetOpacity(0.f);
8698 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); 8708 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get());
8699 EXPECT_EQ(gfx::Rect(0, 0), grandchild->visible_layer_rect_for_testing()); 8709 EXPECT_EQ(gfx::Rect(0, 0), grandchild->visible_layer_rect_for_testing());
8700 8710
8701 // Now, even though child has zero opacity, we will configure |grandchild| and 8711 // Now, even though child has zero opacity, we will configure |grandchild| and
8702 // |greatgrandchild| in several ways that should force the subtree to be 8712 // |greatgrandchild| in several ways that should force the subtree to be
8703 // processed anyhow. 8713 // processed anyhow.
8704 grandchild->RequestCopyOfOutput( 8714 grandchild->RequestCopyOfOutput(
8705 CopyOutputRequest::CreateBitmapRequest(base::Bind(&CopyOutputCallback))); 8715 CopyOutputRequest::CreateBitmapRequest(base::Bind(&CopyOutputCallback)));
8706 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); 8716 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get());
8707 EXPECT_EQ(gfx::Rect(10, 10), grandchild->visible_layer_rect_for_testing()); 8717 EXPECT_EQ(gfx::Rect(10, 10), grandchild->visible_layer_rect_for_testing());
8708 greatgrandchild->set_visible_layer_rect(gfx::Rect()); 8718 greatgrandchild->set_visible_layer_rect(gfx::Rect());
8709 8719
8710 // Add an opacity animation with a start delay. 8720 // Add an opacity animation with a start delay.
8711 animation_id = 1; 8721 animation_id = 1;
8712 animation = Animation::Create( 8722 animation = Animation::Create(
8713 std::unique_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)), 8723 std::unique_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)),
8714 animation_id, 1, TargetProperty::OPACITY); 8724 animation_id, 1, TargetProperty::OPACITY);
8715 animation->set_fill_mode(Animation::FILL_MODE_NONE); 8725 animation->set_fill_mode(Animation::FILL_MODE_NONE);
8716 animation->set_time_offset(base::TimeDelta::FromMilliseconds(-1000)); 8726 animation->set_time_offset(base::TimeDelta::FromMilliseconds(-1000));
8717 AddAnimationToLayerWithExistingPlayer(child->id(), timeline(), 8727 AddAnimationToElementWithExistingPlayer(child->element_id(), timeline(),
8718 std::move(animation)); 8728 std::move(animation));
8719 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); 8729 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get());
8720 EXPECT_EQ(gfx::Rect(10, 10), grandchild->visible_layer_rect_for_testing()); 8730 EXPECT_EQ(gfx::Rect(10, 10), grandchild->visible_layer_rect_for_testing());
8721 } 8731 }
8722 8732
8723 TEST_F(LayerTreeHostCommonTest, SkippingLayerImpl) { 8733 TEST_F(LayerTreeHostCommonTest, SkippingLayerImpl) {
8724 FakeImplTaskRunnerProvider task_runner_provider; 8734 FakeImplTaskRunnerProvider task_runner_provider;
8725 TestSharedBitmapManager shared_bitmap_manager; 8735 TestSharedBitmapManager shared_bitmap_manager;
8726 TestTaskGraphRunner task_graph_runner; 8736 TestTaskGraphRunner task_graph_runner;
8727 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &shared_bitmap_manager, 8737 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &shared_bitmap_manager,
8728 &task_graph_runner); 8738 &task_graph_runner);
8729 8739
8730 gfx::Transform identity; 8740 gfx::Transform identity;
8731 std::unique_ptr<LayerImpl> root = 8741 std::unique_ptr<LayerImpl> root =
8732 LayerImpl::Create(host_impl.active_tree(), 1); 8742 CreateTestLayerImpl(host_impl.active_tree(), 1);
8733 std::unique_ptr<LayerImpl> child = 8743 std::unique_ptr<LayerImpl> child =
8734 LayerImpl::Create(host_impl.active_tree(), 2); 8744 CreateTestLayerImpl(host_impl.active_tree(), 2);
8735 std::unique_ptr<LayerImpl> grandchild = 8745 std::unique_ptr<LayerImpl> grandchild =
8736 LayerImpl::Create(host_impl.active_tree(), 3); 8746 CreateTestLayerImpl(host_impl.active_tree(), 3);
8737 8747
8738 std::unique_ptr<FakePictureLayerImpl> greatgrandchild( 8748 std::unique_ptr<FakePictureLayerImpl> greatgrandchild(
8739 FakePictureLayerImpl::Create(host_impl.active_tree(), 4)); 8749 FakePictureLayerImpl::Create(host_impl.active_tree(), 4));
8740 8750
8741 child->SetDrawsContent(true); 8751 child->SetDrawsContent(true);
8742 grandchild->SetDrawsContent(true); 8752 grandchild->SetDrawsContent(true);
8743 greatgrandchild->SetDrawsContent(true); 8753 greatgrandchild->SetDrawsContent(true);
8744 8754
8745 SetLayerPropertiesForTesting(root.get(), identity, gfx::Point3F(), 8755 SetLayerPropertiesForTesting(root.get(), identity, gfx::Point3F(),
8746 gfx::PointF(), gfx::Size(100, 100), true, false, 8756 gfx::PointF(), gfx::Size(100, 100), true, false,
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
8850 TransformOperations operation; 8860 TransformOperations operation;
8851 operation.AppendMatrix(transform); 8861 operation.AppendMatrix(transform);
8852 curve->AddKeyframe( 8862 curve->AddKeyframe(
8853 TransformKeyframe::Create(base::TimeDelta(), start, nullptr)); 8863 TransformKeyframe::Create(base::TimeDelta(), start, nullptr));
8854 curve->AddKeyframe(TransformKeyframe::Create( 8864 curve->AddKeyframe(TransformKeyframe::Create(
8855 base::TimeDelta::FromSecondsD(1.0), operation, nullptr)); 8865 base::TimeDelta::FromSecondsD(1.0), operation, nullptr));
8856 std::unique_ptr<Animation> transform_animation( 8866 std::unique_ptr<Animation> transform_animation(
8857 Animation::Create(std::move(curve), 3, 3, TargetProperty::TRANSFORM)); 8867 Animation::Create(std::move(curve), 3, 3, TargetProperty::TRANSFORM));
8858 scoped_refptr<AnimationPlayer> player(AnimationPlayer::Create(1)); 8868 scoped_refptr<AnimationPlayer> player(AnimationPlayer::Create(1));
8859 host_impl.active_tree()->animation_host()->RegisterPlayerForElement( 8869 host_impl.active_tree()->animation_host()->RegisterPlayerForElement(
8860 root_ptr->id(), player.get()); 8870 root_ptr->element_id(), player.get());
8861 host_impl.active_tree() 8871 host_impl.active_tree()
8862 ->animation_host() 8872 ->animation_host()
8863 ->GetElementAnimationsForElementId(root_ptr->id()) 8873 ->GetElementAnimationsForElementId(root_ptr->element_id())
8864 ->AddAnimation(std::move(transform_animation)); 8874 ->AddAnimation(std::move(transform_animation));
8865 grandchild_ptr->set_visible_layer_rect(gfx::Rect()); 8875 grandchild_ptr->set_visible_layer_rect(gfx::Rect());
8866 child_ptr->SetScrollClipLayer(root_ptr->id()); 8876 child_ptr->SetScrollClipLayer(root_ptr->id());
8867 root_ptr->SetTransform(singular); 8877 root_ptr->SetTransform(singular);
8868 child_ptr->SetTransform(singular); 8878 child_ptr->SetTransform(singular);
8869 root_ptr->layer_tree_impl()->property_trees()->needs_rebuild = true; 8879 root_ptr->layer_tree_impl()->property_trees()->needs_rebuild = true;
8870 ExecuteCalculateDrawPropertiesWithPropertyTrees(root_ptr); 8880 ExecuteCalculateDrawPropertiesWithPropertyTrees(root_ptr);
8871 EXPECT_EQ(gfx::Rect(0, 0), grandchild_ptr->visible_layer_rect()); 8881 EXPECT_EQ(gfx::Rect(0, 0), grandchild_ptr->visible_layer_rect());
8872 8882
8873 host_impl.active_tree()->animation_host()->UnregisterPlayerForElement( 8883 host_impl.active_tree()->animation_host()->UnregisterPlayerForElement(
8874 root_ptr->id(), player.get()); 8884 root_ptr->element_id(), player.get());
8875 } 8885 }
8876 8886
8877 TEST_F(LayerTreeHostCommonTest, LayerSkippingInSubtreeOfSingularTransform) { 8887 TEST_F(LayerTreeHostCommonTest, LayerSkippingInSubtreeOfSingularTransform) {
8878 LayerImpl* root = root_layer(); 8888 LayerImpl* root = root_layer();
8879 LayerImpl* child = AddChild<LayerImpl>(root); 8889 LayerImpl* child = AddChild<LayerImpl>(root);
8880 LayerImpl* grand_child = AddChild<LayerImpl>(child); 8890 LayerImpl* grand_child = AddChild<LayerImpl>(child);
8881 8891
8882 gfx::Transform identity; 8892 gfx::Transform identity;
8883 SetLayerPropertiesForTesting(root, identity, gfx::Point3F(), gfx::PointF(), 8893 SetLayerPropertiesForTesting(root, identity, gfx::Point3F(), gfx::PointF(),
8884 gfx::Size(10, 10), true, false, true); 8894 gfx::Size(10, 10), true, false, true);
(...skipping 20 matching lines...) Expand all
8905 TransformOperations operation; 8915 TransformOperations operation;
8906 operation.AppendMatrix(transform); 8916 operation.AppendMatrix(transform);
8907 curve->AddKeyframe( 8917 curve->AddKeyframe(
8908 TransformKeyframe::Create(base::TimeDelta(), start, nullptr)); 8918 TransformKeyframe::Create(base::TimeDelta(), start, nullptr));
8909 curve->AddKeyframe(TransformKeyframe::Create( 8919 curve->AddKeyframe(TransformKeyframe::Create(
8910 base::TimeDelta::FromSecondsD(1.0), operation, nullptr)); 8920 base::TimeDelta::FromSecondsD(1.0), operation, nullptr));
8911 std::unique_ptr<Animation> transform_animation( 8921 std::unique_ptr<Animation> transform_animation(
8912 Animation::Create(std::move(curve), 3, 3, TargetProperty::TRANSFORM)); 8922 Animation::Create(std::move(curve), 3, 3, TargetProperty::TRANSFORM));
8913 scoped_refptr<AnimationPlayer> player(AnimationPlayer::Create(1)); 8923 scoped_refptr<AnimationPlayer> player(AnimationPlayer::Create(1));
8914 host_impl()->active_tree()->animation_host()->RegisterPlayerForElement( 8924 host_impl()->active_tree()->animation_host()->RegisterPlayerForElement(
8915 grand_child->id(), player.get()); 8925 grand_child->element_id(), player.get());
8916 host_impl() 8926 host_impl()
8917 ->active_tree() 8927 ->active_tree()
8918 ->animation_host() 8928 ->animation_host()
8919 ->GetElementAnimationsForElementId(grand_child->id()) 8929 ->GetElementAnimationsForElementId(grand_child->element_id())
8920 ->AddAnimation(std::move(transform_animation)); 8930 ->AddAnimation(std::move(transform_animation));
8921 8931
8922 ExecuteCalculateDrawProperties(root); 8932 ExecuteCalculateDrawProperties(root);
8923 EXPECT_EQ(gfx::Rect(0, 0), grand_child->visible_layer_rect()); 8933 EXPECT_EQ(gfx::Rect(0, 0), grand_child->visible_layer_rect());
8924 EXPECT_EQ(gfx::Rect(0, 0), child->visible_layer_rect()); 8934 EXPECT_EQ(gfx::Rect(0, 0), child->visible_layer_rect());
8925 8935
8926 host_impl()->active_tree()->animation_host()->UnregisterPlayerForElement( 8936 host_impl()->active_tree()->animation_host()->UnregisterPlayerForElement(
8927 grand_child->id(), player.get()); 8937 grand_child->element_id(), player.get());
8928 } 8938 }
8929 8939
8930 TEST_F(LayerTreeHostCommonTest, SkippingPendingLayerImpl) { 8940 TEST_F(LayerTreeHostCommonTest, SkippingPendingLayerImpl) {
8931 FakeImplTaskRunnerProvider task_runner_provider; 8941 FakeImplTaskRunnerProvider task_runner_provider;
8932 TestSharedBitmapManager shared_bitmap_manager; 8942 TestSharedBitmapManager shared_bitmap_manager;
8933 TestTaskGraphRunner task_graph_runner; 8943 TestTaskGraphRunner task_graph_runner;
8934 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &shared_bitmap_manager, 8944 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &shared_bitmap_manager,
8935 &task_graph_runner); 8945 &task_graph_runner);
8936 8946
8937 gfx::Transform identity; 8947 gfx::Transform identity;
8938 host_impl.CreatePendingTree(); 8948 host_impl.CreatePendingTree();
8939 std::unique_ptr<LayerImpl> root = 8949 std::unique_ptr<LayerImpl> root =
8940 LayerImpl::Create(host_impl.pending_tree(), 1); 8950 CreateTestLayerImpl(host_impl.pending_tree(), 1);
8941 std::unique_ptr<LayerImpl> child = 8951 std::unique_ptr<LayerImpl> child =
8942 LayerImpl::Create(host_impl.pending_tree(), 2); 8952 CreateTestLayerImpl(host_impl.pending_tree(), 2);
8943 std::unique_ptr<LayerImpl> grandchild = 8953 std::unique_ptr<LayerImpl> grandchild =
8944 LayerImpl::Create(host_impl.pending_tree(), 3); 8954 CreateTestLayerImpl(host_impl.pending_tree(), 3);
8945 8955
8946 std::unique_ptr<FakePictureLayerImpl> greatgrandchild( 8956 std::unique_ptr<FakePictureLayerImpl> greatgrandchild(
8947 FakePictureLayerImpl::Create(host_impl.pending_tree(), 4)); 8957 FakePictureLayerImpl::Create(host_impl.pending_tree(), 4));
8948 8958
8949 child->SetDrawsContent(true); 8959 child->SetDrawsContent(true);
8950 grandchild->SetDrawsContent(true); 8960 grandchild->SetDrawsContent(true);
8951 greatgrandchild->SetDrawsContent(true); 8961 greatgrandchild->SetDrawsContent(true);
8952 8962
8953 SetLayerPropertiesForTesting(root.get(), identity, gfx::Point3F(), 8963 SetLayerPropertiesForTesting(root.get(), identity, gfx::Point3F(),
8954 gfx::PointF(), gfx::Size(100, 100), true, false, 8964 gfx::PointF(), gfx::Size(100, 100), true, false,
(...skipping 21 matching lines...) Expand all
8976 KeyframedFloatAnimationCurve::Create()); 8986 KeyframedFloatAnimationCurve::Create());
8977 std::unique_ptr<TimingFunction> func = EaseTimingFunction::Create(); 8987 std::unique_ptr<TimingFunction> func = EaseTimingFunction::Create();
8978 curve->AddKeyframe( 8988 curve->AddKeyframe(
8979 FloatKeyframe::Create(base::TimeDelta(), 0.9f, std::move(func))); 8989 FloatKeyframe::Create(base::TimeDelta(), 0.9f, std::move(func)));
8980 curve->AddKeyframe( 8990 curve->AddKeyframe(
8981 FloatKeyframe::Create(base::TimeDelta::FromSecondsD(1.0), 0.3f, nullptr)); 8991 FloatKeyframe::Create(base::TimeDelta::FromSecondsD(1.0), 0.3f, nullptr));
8982 std::unique_ptr<Animation> animation( 8992 std::unique_ptr<Animation> animation(
8983 Animation::Create(std::move(curve), 3, 3, TargetProperty::OPACITY)); 8993 Animation::Create(std::move(curve), 3, 3, TargetProperty::OPACITY));
8984 scoped_refptr<AnimationPlayer> player(AnimationPlayer::Create(1)); 8994 scoped_refptr<AnimationPlayer> player(AnimationPlayer::Create(1));
8985 host_impl.active_tree()->animation_host()->RegisterPlayerForElement( 8995 host_impl.active_tree()->animation_host()->RegisterPlayerForElement(
8986 root_ptr->id(), player.get()); 8996 root_ptr->element_id(), player.get());
8987 host_impl.active_tree() 8997 host_impl.active_tree()
8988 ->animation_host() 8998 ->animation_host()
8989 ->GetElementAnimationsForElementId(root_ptr->id()) 8999 ->GetElementAnimationsForElementId(root_ptr->element_id())
8990 ->AddAnimation(std::move(animation)); 9000 ->AddAnimation(std::move(animation));
8991 root_ptr->SetOpacity(0); 9001 root_ptr->SetOpacity(0);
8992 grandchild_ptr->set_visible_layer_rect(gfx::Rect()); 9002 grandchild_ptr->set_visible_layer_rect(gfx::Rect());
8993 root_ptr->layer_tree_impl()->property_trees()->needs_rebuild = true; 9003 root_ptr->layer_tree_impl()->property_trees()->needs_rebuild = true;
8994 ExecuteCalculateDrawPropertiesWithPropertyTrees(root_ptr); 9004 ExecuteCalculateDrawPropertiesWithPropertyTrees(root_ptr);
8995 EXPECT_EQ(gfx::Rect(10, 10), grandchild_ptr->visible_layer_rect()); 9005 EXPECT_EQ(gfx::Rect(10, 10), grandchild_ptr->visible_layer_rect());
8996 9006
8997 host_impl.active_tree()->animation_host()->UnregisterPlayerForElement( 9007 host_impl.active_tree()->animation_host()->UnregisterPlayerForElement(
8998 root_ptr->id(), player.get()); 9008 root_ptr->element_id(), player.get());
8999 } 9009 }
9000 9010
9001 TEST_F(LayerTreeHostCommonTest, SkippingLayer) { 9011 TEST_F(LayerTreeHostCommonTest, SkippingLayer) {
9002 gfx::Transform identity; 9012 gfx::Transform identity;
9003 LayerImpl* root = root_layer(); 9013 LayerImpl* root = root_layer();
9004 LayerImpl* child = AddChild<LayerImpl>(root); 9014 LayerImpl* child = AddChild<LayerImpl>(root);
9005 9015
9006 SetLayerPropertiesForTesting(root, identity, gfx::Point3F(), gfx::PointF(), 9016 SetLayerPropertiesForTesting(root, identity, gfx::Point3F(), gfx::PointF(),
9007 gfx::Size(100, 100), true, false, true); 9017 gfx::Size(100, 100), true, false, true);
9008 SetLayerPropertiesForTesting(child, identity, gfx::Point3F(), gfx::PointF(), 9018 SetLayerPropertiesForTesting(child, identity, gfx::Point3F(), gfx::PointF(),
(...skipping 28 matching lines...) Expand all
9037 9047
9038 child->SetOpacity(0.f); 9048 child->SetOpacity(0.f);
9039 root->layer_tree_impl()->property_trees()->needs_rebuild = true; 9049 root->layer_tree_impl()->property_trees()->needs_rebuild = true;
9040 ExecuteCalculateDrawProperties(root); 9050 ExecuteCalculateDrawProperties(root);
9041 EXPECT_EQ(gfx::Rect(0, 0), child->visible_layer_rect()); 9051 EXPECT_EQ(gfx::Rect(0, 0), child->visible_layer_rect());
9042 } 9052 }
9043 9053
9044 TEST_F(LayerTreeHostCommonTest, LayerTreeRebuildTest) { 9054 TEST_F(LayerTreeHostCommonTest, LayerTreeRebuildTest) {
9045 // Ensure that the treewalk in LayerTreeHostCommom:: 9055 // Ensure that the treewalk in LayerTreeHostCommom::
9046 // PreCalculateMetaInformation happens when its required. 9056 // PreCalculateMetaInformation happens when its required.
9047 scoped_refptr<Layer> root = Layer::Create(); 9057 scoped_refptr<Layer> root = CreateTestLayer();
9048 scoped_refptr<Layer> parent = Layer::Create(); 9058 scoped_refptr<Layer> parent = CreateTestLayer();
9049 scoped_refptr<Layer> child = Layer::Create(); 9059 scoped_refptr<Layer> child = CreateTestLayer();
9050 9060
9051 root->AddChild(parent); 9061 root->AddChild(parent);
9052 parent->AddChild(child); 9062 parent->AddChild(child);
9053 9063
9054 child->SetClipParent(root.get()); 9064 child->SetClipParent(root.get());
9055 9065
9056 gfx::Transform identity; 9066 gfx::Transform identity;
9057 9067
9058 SetLayerPropertiesForTesting(root.get(), identity, gfx::Point3F(), 9068 SetLayerPropertiesForTesting(root.get(), identity, gfx::Point3F(),
9059 gfx::PointF(), gfx::Size(100, 100), true, false); 9069 gfx::PointF(), gfx::Size(100, 100), true, false);
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
9097 child->SetTouchEventHandlerRegion(gfx::Rect()); 9107 child->SetTouchEventHandlerRegion(gfx::Rect());
9098 ExecuteCalculateDrawProperties(root); 9108 ExecuteCalculateDrawProperties(root);
9099 EXPECT_EQ(root->layer_or_descendant_has_touch_handler(), false); 9109 EXPECT_EQ(root->layer_or_descendant_has_touch_handler(), false);
9100 } 9110 }
9101 9111
9102 TEST_F(LayerTreeHostCommonTest, ResetPropertyTreeIndices) { 9112 TEST_F(LayerTreeHostCommonTest, ResetPropertyTreeIndices) {
9103 gfx::Transform identity; 9113 gfx::Transform identity;
9104 gfx::Transform translate_z; 9114 gfx::Transform translate_z;
9105 translate_z.Translate3d(0, 0, 10); 9115 translate_z.Translate3d(0, 0, 10);
9106 9116
9107 scoped_refptr<Layer> root = Layer::Create(); 9117 scoped_refptr<Layer> root = CreateTestLayer();
9108 SetLayerPropertiesForTesting(root.get(), identity, gfx::Point3F(), 9118 SetLayerPropertiesForTesting(root.get(), identity, gfx::Point3F(),
9109 gfx::PointF(), gfx::Size(800, 800), true, false); 9119 gfx::PointF(), gfx::Size(800, 800), true, false);
9110 9120
9111 scoped_refptr<Layer> child = Layer::Create(); 9121 scoped_refptr<Layer> child = CreateTestLayer();
9112 SetLayerPropertiesForTesting(child.get(), translate_z, gfx::Point3F(), 9122 SetLayerPropertiesForTesting(child.get(), translate_z, gfx::Point3F(),
9113 gfx::PointF(), gfx::Size(100, 100), true, false); 9123 gfx::PointF(), gfx::Size(100, 100), true, false);
9114 9124
9115 root->AddChild(child); 9125 root->AddChild(child);
9116 9126
9117 host()->SetRootLayer(root); 9127 host()->SetRootLayer(root);
9118 9128
9119 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); 9129 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get());
9120 EXPECT_NE(-1, child->transform_tree_index()); 9130 EXPECT_NE(-1, child->transform_tree_index());
9121 9131
(...skipping 574 matching lines...) Expand 10 before | Expand all | Expand 10 after
9696 gfx::Transform transform; 9706 gfx::Transform transform;
9697 transform.Translate(10, 10); 9707 transform.Translate(10, 10);
9698 9708
9699 SetLayerPropertiesForTesting(root, identity_matrix, gfx::Point3F(), 9709 SetLayerPropertiesForTesting(root, identity_matrix, gfx::Point3F(),
9700 gfx::PointF(), gfx::Size(30, 30), true, false, 9710 gfx::PointF(), gfx::Size(30, 30), true, false,
9701 true); 9711 true);
9702 SetLayerPropertiesForTesting(child, transform, gfx::Point3F(), gfx::PointF(), 9712 SetLayerPropertiesForTesting(child, transform, gfx::Point3F(), gfx::PointF(),
9703 gfx::Size(30, 30), true, false, false); 9713 gfx::Size(30, 30), true, false, false);
9704 root->SetDrawsContent(true); 9714 root->SetDrawsContent(true);
9705 child->SetDrawsContent(false); 9715 child->SetDrawsContent(false);
9706 child->SetMaskLayer(LayerImpl::Create(root->layer_tree_impl(), 100)); 9716 child->SetMaskLayer(CreateTestLayerImpl(root->layer_tree_impl(), 100));
9707 ExecuteCalculateDrawProperties(root); 9717 ExecuteCalculateDrawProperties(root);
9708 9718
9709 EXPECT_TRANSFORMATION_MATRIX_EQ(transform, 9719 EXPECT_TRANSFORMATION_MATRIX_EQ(transform,
9710 child->mask_layer()->ScreenSpaceTransform()); 9720 child->mask_layer()->ScreenSpaceTransform());
9711 transform.Translate(10, 10); 9721 transform.Translate(10, 10);
9712 child->SetTransform(transform); 9722 child->SetTransform(transform);
9713 child->SetDrawsContent(true); 9723 child->SetDrawsContent(true);
9714 root->layer_tree_impl()->property_trees()->needs_rebuild = true; 9724 root->layer_tree_impl()->property_trees()->needs_rebuild = true;
9715 ExecuteCalculateDrawProperties(root); 9725 ExecuteCalculateDrawProperties(root);
9716 EXPECT_TRANSFORMATION_MATRIX_EQ(transform, 9726 EXPECT_TRANSFORMATION_MATRIX_EQ(transform,
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
9879 // +----node---owner:5, id:6 9889 // +----node---owner:5, id:6
9880 // 9890 //
9881 // Extra check: 9891 // Extra check:
9882 // scroll_tree_index() of: 9892 // scroll_tree_index() of:
9883 // grand_child10:3 9893 // grand_child10:3
9884 // parent3:1 9894 // parent3:1
9885 // child8:4 9895 // child8:4
9886 // parent4:1 9896 // parent4:1
9887 // child9:1 9897 // child9:1
9888 // grand_child12:1 9898 // grand_child12:1
9889 scoped_refptr<Layer> root1 = Layer::Create(); 9899 scoped_refptr<Layer> root1 = CreateTestLayer();
9890 scoped_refptr<Layer> page_scale_layer = Layer::Create(); 9900 scoped_refptr<Layer> page_scale_layer = CreateTestLayer();
9891 scoped_refptr<Layer> parent2 = Layer::Create(); 9901 scoped_refptr<Layer> parent2 = CreateTestLayer();
9892 scoped_refptr<Layer> parent3 = Layer::Create(); 9902 scoped_refptr<Layer> parent3 = CreateTestLayer();
9893 scoped_refptr<Layer> parent4 = Layer::Create(); 9903 scoped_refptr<Layer> parent4 = CreateTestLayer();
9894 scoped_refptr<Layer> parent5 = Layer::Create(); 9904 scoped_refptr<Layer> parent5 = CreateTestLayer();
9895 scoped_refptr<Layer> child6 = Layer::Create(); 9905 scoped_refptr<Layer> child6 = CreateTestLayer();
9896 scoped_refptr<Layer> child7 = Layer::Create(); 9906 scoped_refptr<Layer> child7 = CreateTestLayer();
9897 scoped_refptr<Layer> child8 = Layer::Create(); 9907 scoped_refptr<Layer> child8 = CreateTestLayer();
9898 scoped_refptr<Layer> child9 = Layer::Create(); 9908 scoped_refptr<Layer> child9 = CreateTestLayer();
9899 scoped_refptr<Layer> grand_child10 = Layer::Create(); 9909 scoped_refptr<Layer> grand_child10 = CreateTestLayer();
9900 scoped_refptr<Layer> grand_child11 = Layer::Create(); 9910 scoped_refptr<Layer> grand_child11 = CreateTestLayer();
9901 scoped_refptr<Layer> grand_child12 = Layer::Create(); 9911 scoped_refptr<Layer> grand_child12 = CreateTestLayer();
9902 9912
9903 root1->AddChild(page_scale_layer); 9913 root1->AddChild(page_scale_layer);
9904 page_scale_layer->AddChild(parent2); 9914 page_scale_layer->AddChild(parent2);
9905 page_scale_layer->AddChild(parent3); 9915 page_scale_layer->AddChild(parent3);
9906 page_scale_layer->AddChild(parent4); 9916 page_scale_layer->AddChild(parent4);
9907 page_scale_layer->AddChild(parent5); 9917 page_scale_layer->AddChild(parent5);
9908 parent2->AddChild(child6); 9918 parent2->AddChild(child6);
9909 parent3->AddChild(child7); 9919 parent3->AddChild(child7);
9910 parent3->AddChild(child8); 9920 parent3->AddChild(child8);
9911 parent4->AddChild(child9); 9921 parent4->AddChild(child9);
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
9954 property_tree_root->data.contains_non_fast_scrollable_region = false; 9964 property_tree_root->data.contains_non_fast_scrollable_region = false;
9955 property_tree_root->data.transform_id = kRootPropertyTreeNodeId; 9965 property_tree_root->data.transform_id = kRootPropertyTreeNodeId;
9956 9966
9957 // The node owned by root1 9967 // The node owned by root1
9958 ScrollNode scroll_root1; 9968 ScrollNode scroll_root1;
9959 scroll_root1.id = 1; 9969 scroll_root1.id = 1;
9960 scroll_root1.owner_id = root1->id(); 9970 scroll_root1.owner_id = root1->id();
9961 scroll_root1.data.user_scrollable_horizontal = true; 9971 scroll_root1.data.user_scrollable_horizontal = true;
9962 scroll_root1.data.user_scrollable_vertical = true; 9972 scroll_root1.data.user_scrollable_vertical = true;
9963 scroll_root1.data.transform_id = root1->transform_tree_index(); 9973 scroll_root1.data.transform_id = root1->transform_tree_index();
9974 scroll_root1.data.element_id = root1->element_id();
9964 expected_scroll_tree.Insert(scroll_root1, 0); 9975 expected_scroll_tree.Insert(scroll_root1, 0);
9965 9976
9966 // The node owned by parent2 9977 // The node owned by parent2
9967 ScrollNode scroll_parent2; 9978 ScrollNode scroll_parent2;
9968 scroll_parent2.id = 2; 9979 scroll_parent2.id = 2;
9969 scroll_parent2.owner_id = parent2->id(); 9980 scroll_parent2.owner_id = parent2->id();
9970 scroll_parent2.data.scrollable = true; 9981 scroll_parent2.data.scrollable = true;
9971 scroll_parent2.data.main_thread_scrolling_reasons = 9982 scroll_parent2.data.main_thread_scrolling_reasons =
9972 parent2->main_thread_scrolling_reasons(); 9983 parent2->main_thread_scrolling_reasons();
9973 scroll_parent2.data.scroll_clip_layer_bounds = root1->bounds(); 9984 scroll_parent2.data.scroll_clip_layer_bounds = root1->bounds();
9974 scroll_parent2.data.bounds = parent2->bounds(); 9985 scroll_parent2.data.bounds = parent2->bounds();
9975 scroll_parent2.data.max_scroll_offset_affected_by_page_scale = true; 9986 scroll_parent2.data.max_scroll_offset_affected_by_page_scale = true;
9976 scroll_parent2.data.is_inner_viewport_scroll_layer = true; 9987 scroll_parent2.data.is_inner_viewport_scroll_layer = true;
9977 scroll_parent2.data.user_scrollable_horizontal = true; 9988 scroll_parent2.data.user_scrollable_horizontal = true;
9978 scroll_parent2.data.user_scrollable_vertical = true; 9989 scroll_parent2.data.user_scrollable_vertical = true;
9979 scroll_parent2.data.transform_id = parent2->transform_tree_index(); 9990 scroll_parent2.data.transform_id = parent2->transform_tree_index();
9991 scroll_parent2.data.element_id = parent2->element_id();
9980 expected_scroll_tree.Insert(scroll_parent2, 1); 9992 expected_scroll_tree.Insert(scroll_parent2, 1);
9981 9993
9982 // The node owned by child6 9994 // The node owned by child6
9983 ScrollNode scroll_child6; 9995 ScrollNode scroll_child6;
9984 scroll_child6.id = 3; 9996 scroll_child6.id = 3;
9985 scroll_child6.owner_id = child6->id(); 9997 scroll_child6.owner_id = child6->id();
9986 scroll_child6.data.main_thread_scrolling_reasons = 9998 scroll_child6.data.main_thread_scrolling_reasons =
9987 child6->main_thread_scrolling_reasons(); 9999 child6->main_thread_scrolling_reasons();
9988 scroll_child6.data.should_flatten = true; 10000 scroll_child6.data.should_flatten = true;
9989 scroll_child6.data.user_scrollable_horizontal = true; 10001 scroll_child6.data.user_scrollable_horizontal = true;
9990 scroll_child6.data.user_scrollable_vertical = true; 10002 scroll_child6.data.user_scrollable_vertical = true;
9991 scroll_child6.data.transform_id = child6->transform_tree_index(); 10003 scroll_child6.data.transform_id = child6->transform_tree_index();
10004 scroll_child6.data.element_id = child6->element_id();
9992 expected_scroll_tree.Insert(scroll_child6, 2); 10005 expected_scroll_tree.Insert(scroll_child6, 2);
9993 10006
9994 // The node owned by child7, child7 also owns a transform node 10007 // The node owned by child7, child7 also owns a transform node
9995 ScrollNode scroll_child7; 10008 ScrollNode scroll_child7;
9996 scroll_child7.id = 4; 10009 scroll_child7.id = 4;
9997 scroll_child7.owner_id = child7->id(); 10010 scroll_child7.owner_id = child7->id();
9998 scroll_child7.data.scrollable = true; 10011 scroll_child7.data.scrollable = true;
9999 scroll_child7.data.scroll_clip_layer_bounds = parent3->bounds(); 10012 scroll_child7.data.scroll_clip_layer_bounds = parent3->bounds();
10000 scroll_child7.data.bounds = child7->bounds(); 10013 scroll_child7.data.bounds = child7->bounds();
10001 scroll_child7.data.user_scrollable_horizontal = true; 10014 scroll_child7.data.user_scrollable_horizontal = true;
10002 scroll_child7.data.user_scrollable_vertical = true; 10015 scroll_child7.data.user_scrollable_vertical = true;
10003 scroll_child7.data.transform_id = child7->transform_tree_index(); 10016 scroll_child7.data.transform_id = child7->transform_tree_index();
10017 scroll_child7.data.element_id = child7->element_id();
10004 expected_scroll_tree.Insert(scroll_child7, 1); 10018 expected_scroll_tree.Insert(scroll_child7, 1);
10005 10019
10006 // The node owned by grand_child11, grand_child11 also owns a transform node 10020 // The node owned by grand_child11, grand_child11 also owns a transform node
10007 ScrollNode scroll_grand_child11; 10021 ScrollNode scroll_grand_child11;
10008 scroll_grand_child11.id = 5; 10022 scroll_grand_child11.id = 5;
10009 scroll_grand_child11.owner_id = grand_child11->id(); 10023 scroll_grand_child11.owner_id = grand_child11->id();
10010 scroll_grand_child11.data.scrollable = true; 10024 scroll_grand_child11.data.scrollable = true;
10011 scroll_grand_child11.data.user_scrollable_horizontal = true; 10025 scroll_grand_child11.data.user_scrollable_horizontal = true;
10012 scroll_grand_child11.data.user_scrollable_vertical = true; 10026 scroll_grand_child11.data.user_scrollable_vertical = true;
10013 scroll_grand_child11.data.transform_id = 10027 scroll_grand_child11.data.transform_id =
10014 grand_child11->transform_tree_index(); 10028 grand_child11->transform_tree_index();
10029 scroll_grand_child11.data.element_id = grand_child11->element_id();
10015 expected_scroll_tree.Insert(scroll_grand_child11, 4); 10030 expected_scroll_tree.Insert(scroll_grand_child11, 4);
10016 10031
10017 // The node owned by parent5 10032 // The node owned by parent5
10018 ScrollNode scroll_parent5; 10033 ScrollNode scroll_parent5;
10019 scroll_parent5.id = 8; 10034 scroll_parent5.id = 8;
10020 scroll_parent5.owner_id = parent5->id(); 10035 scroll_parent5.owner_id = parent5->id();
10021 scroll_parent5.data.contains_non_fast_scrollable_region = true; 10036 scroll_parent5.data.contains_non_fast_scrollable_region = true;
10022 scroll_parent5.data.bounds = gfx::Size(10, 10); 10037 scroll_parent5.data.bounds = gfx::Size(10, 10);
10023 scroll_parent5.data.should_flatten = true; 10038 scroll_parent5.data.should_flatten = true;
10024 scroll_parent5.data.user_scrollable_horizontal = true; 10039 scroll_parent5.data.user_scrollable_horizontal = true;
10025 scroll_parent5.data.user_scrollable_vertical = true; 10040 scroll_parent5.data.user_scrollable_vertical = true;
10026 scroll_parent5.data.transform_id = parent5->transform_tree_index(); 10041 scroll_parent5.data.transform_id = parent5->transform_tree_index();
10042 scroll_parent5.data.element_id = parent5->element_id();
10027 expected_scroll_tree.Insert(scroll_parent5, 1); 10043 expected_scroll_tree.Insert(scroll_parent5, 1);
10028 10044
10029 expected_scroll_tree.SetScrollOffset(parent2->id(), gfx::ScrollOffset(0, 0)); 10045 expected_scroll_tree.SetScrollOffset(parent2->id(), gfx::ScrollOffset(0, 0));
10030 expected_scroll_tree.SetScrollOffset(child7->id(), gfx::ScrollOffset(0, 0)); 10046 expected_scroll_tree.SetScrollOffset(child7->id(), gfx::ScrollOffset(0, 0));
10031 expected_scroll_tree.SetScrollOffset(grand_child11->id(), 10047 expected_scroll_tree.SetScrollOffset(grand_child11->id(),
10032 gfx::ScrollOffset(0, 0)); 10048 gfx::ScrollOffset(0, 0));
10033 expected_scroll_tree.set_needs_update(false); 10049 expected_scroll_tree.set_needs_update(false);
10034 10050
10035 EXPECT_EQ(expected_scroll_tree, scroll_tree); 10051 EXPECT_EQ(expected_scroll_tree, scroll_tree);
10036 10052
10037 // Check other layers' scroll_tree_index 10053 // Check other layers' scroll_tree_index
10038 EXPECT_EQ(scroll_root1.id, page_scale_layer->scroll_tree_index()); 10054 EXPECT_EQ(scroll_root1.id, page_scale_layer->scroll_tree_index());
10039 EXPECT_EQ(scroll_child6.id, grand_child10->scroll_tree_index()); 10055 EXPECT_EQ(scroll_child6.id, grand_child10->scroll_tree_index());
10040 EXPECT_EQ(scroll_root1.id, parent3->scroll_tree_index()); 10056 EXPECT_EQ(scroll_root1.id, parent3->scroll_tree_index());
10041 EXPECT_EQ(scroll_child7.id, child8->scroll_tree_index()); 10057 EXPECT_EQ(scroll_child7.id, child8->scroll_tree_index());
10042 EXPECT_EQ(scroll_root1.id, parent4->scroll_tree_index()); 10058 EXPECT_EQ(scroll_root1.id, parent4->scroll_tree_index());
10043 EXPECT_EQ(scroll_root1.id, child9->scroll_tree_index()); 10059 EXPECT_EQ(scroll_root1.id, child9->scroll_tree_index());
10044 EXPECT_EQ(scroll_root1.id, grand_child12->scroll_tree_index()); 10060 EXPECT_EQ(scroll_root1.id, grand_child12->scroll_tree_index());
10045 } 10061 }
10046 10062
10047 } // namespace 10063 } // namespace
10048 } // namespace cc 10064 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698