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

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

Issue 2080223010: cc: Clean up root_layer code in LTI (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase++ Created 4 years, 5 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
« no previous file with comments | « cc/trees/layer_tree_host_common_perftest.cc ('k') | cc/trees/layer_tree_host_impl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 }; 105 };
106 106
107 class LayerTreeHostCommonDrawRectsTest : public LayerTreeHostCommonTest { 107 class LayerTreeHostCommonDrawRectsTest : public LayerTreeHostCommonTest {
108 public: 108 public:
109 LayerTreeHostCommonDrawRectsTest() : LayerTreeHostCommonTest() {} 109 LayerTreeHostCommonDrawRectsTest() : LayerTreeHostCommonTest() {}
110 110
111 LayerImpl* TestVisibleRectAndDrawableContentRect( 111 LayerImpl* TestVisibleRectAndDrawableContentRect(
112 const gfx::Rect& target_rect, 112 const gfx::Rect& target_rect,
113 const gfx::Transform& layer_transform, 113 const gfx::Transform& layer_transform,
114 const gfx::Rect& layer_rect) { 114 const gfx::Rect& layer_rect) {
115 LayerImpl* root = root_layer(); 115 LayerImpl* root = root_layer_for_testing();
116 LayerImpl* target = AddChild<LayerImpl>(root); 116 LayerImpl* target = AddChild<LayerImpl>(root);
117 LayerImpl* drawing_layer = AddChild<LayerImpl>(target); 117 LayerImpl* drawing_layer = AddChild<LayerImpl>(target);
118 118
119 root->SetDrawsContent(true); 119 root->SetDrawsContent(true);
120 target->SetDrawsContent(true); 120 target->SetDrawsContent(true);
121 target->SetMasksToBounds(true); 121 target->SetMasksToBounds(true);
122 drawing_layer->SetDrawsContent(true); 122 drawing_layer->SetDrawsContent(true);
123 123
124 gfx::Transform identity; 124 gfx::Transform identity;
125 125
(...skipping 12 matching lines...) Expand all
138 return drawing_layer; 138 return drawing_layer;
139 } 139 }
140 }; 140 };
141 141
142 TEST_F(LayerTreeHostCommonTest, TransformsForNoOpLayer) { 142 TEST_F(LayerTreeHostCommonTest, TransformsForNoOpLayer) {
143 // Sanity check: For layers positioned at zero, with zero size, 143 // Sanity check: For layers positioned at zero, with zero size,
144 // and with identity transforms, then the draw transform, 144 // and with identity transforms, then the draw transform,
145 // screen space transform, and the hierarchy passed on to children 145 // screen space transform, and the hierarchy passed on to children
146 // layers should also be identity transforms. 146 // layers should also be identity transforms.
147 147
148 LayerImpl* parent = root_layer(); 148 LayerImpl* parent = root_layer_for_testing();
149 LayerImpl* child = AddChild<LayerImpl>(parent); 149 LayerImpl* child = AddChild<LayerImpl>(parent);
150 LayerImpl* grand_child = AddChild<LayerImpl>(child); 150 LayerImpl* grand_child = AddChild<LayerImpl>(child);
151 151
152 gfx::Transform identity_matrix; 152 gfx::Transform identity_matrix;
153 SetLayerPropertiesForTesting(parent, identity_matrix, gfx::Point3F(), 153 SetLayerPropertiesForTesting(parent, identity_matrix, gfx::Point3F(),
154 gfx::PointF(), gfx::Size(100, 100), true, false); 154 gfx::PointF(), gfx::Size(100, 100), true, false);
155 SetLayerPropertiesForTesting(child, identity_matrix, gfx::Point3F(), 155 SetLayerPropertiesForTesting(child, identity_matrix, gfx::Point3F(),
156 gfx::PointF(), gfx::Size(), true, false); 156 gfx::PointF(), gfx::Size(), true, false);
157 SetLayerPropertiesForTesting(grand_child, identity_matrix, gfx::Point3F(), 157 SetLayerPropertiesForTesting(grand_child, identity_matrix, gfx::Point3F(),
158 gfx::PointF(), gfx::Size(), true, false); 158 gfx::PointF(), gfx::Size(), true, false);
159 159
160 ExecuteCalculateDrawProperties(parent); 160 ExecuteCalculateDrawProperties(parent);
161 161
162 EXPECT_TRANSFORMATION_MATRIX_EQ(identity_matrix, child->DrawTransform()); 162 EXPECT_TRANSFORMATION_MATRIX_EQ(identity_matrix, child->DrawTransform());
163 EXPECT_TRANSFORMATION_MATRIX_EQ(identity_matrix, 163 EXPECT_TRANSFORMATION_MATRIX_EQ(identity_matrix,
164 child->ScreenSpaceTransform()); 164 child->ScreenSpaceTransform());
165 EXPECT_TRANSFORMATION_MATRIX_EQ(identity_matrix, 165 EXPECT_TRANSFORMATION_MATRIX_EQ(identity_matrix,
166 grand_child->DrawTransform()); 166 grand_child->DrawTransform());
167 EXPECT_TRANSFORMATION_MATRIX_EQ(identity_matrix, 167 EXPECT_TRANSFORMATION_MATRIX_EQ(identity_matrix,
168 grand_child->ScreenSpaceTransform()); 168 grand_child->ScreenSpaceTransform());
169 } 169 }
170 170
171 TEST_F(LayerTreeHostCommonTest, EffectTreeTransformIdTest) { 171 TEST_F(LayerTreeHostCommonTest, EffectTreeTransformIdTest) {
172 // Tests that effect tree node gets a valid transform id when a layer 172 // Tests that effect tree node gets a valid transform id when a layer
173 // has opacity but doesn't create a render surface. 173 // has opacity but doesn't create a render surface.
174 LayerImpl* parent = root_layer(); 174 LayerImpl* parent = root_layer_for_testing();
175 LayerImpl* child = AddChild<LayerImpl>(parent); 175 LayerImpl* child = AddChild<LayerImpl>(parent);
176 child->SetDrawsContent(true); 176 child->SetDrawsContent(true);
177 177
178 gfx::Transform identity_matrix; 178 gfx::Transform identity_matrix;
179 SetLayerPropertiesForTesting(parent, identity_matrix, gfx::Point3F(), 179 SetLayerPropertiesForTesting(parent, identity_matrix, gfx::Point3F(),
180 gfx::PointF(), gfx::Size(100, 100), true, false); 180 gfx::PointF(), gfx::Size(100, 100), true, false);
181 SetLayerPropertiesForTesting(child, identity_matrix, gfx::Point3F(), 181 SetLayerPropertiesForTesting(child, identity_matrix, gfx::Point3F(),
182 gfx::PointF(10, 10), gfx::Size(100, 100), true, 182 gfx::PointF(10, 10), gfx::Size(100, 100), true,
183 false); 183 false);
184 child->test_properties()->opacity = 0.f; 184 child->test_properties()->opacity = 0.f;
185 ExecuteCalculateDrawProperties(parent); 185 ExecuteCalculateDrawProperties(parent);
186 EffectTree& effect_tree = 186 EffectTree& effect_tree =
187 parent->layer_tree_impl()->property_trees()->effect_tree; 187 parent->layer_tree_impl()->property_trees()->effect_tree;
188 EffectNode* node = effect_tree.Node(child->effect_tree_index()); 188 EffectNode* node = effect_tree.Node(child->effect_tree_index());
189 const int transform_tree_size = parent->layer_tree_impl() 189 const int transform_tree_size = parent->layer_tree_impl()
190 ->property_trees() 190 ->property_trees()
191 ->transform_tree.next_available_id(); 191 ->transform_tree.next_available_id();
192 EXPECT_LT(node->data.transform_id, transform_tree_size); 192 EXPECT_LT(node->data.transform_id, transform_tree_size);
193 } 193 }
194 194
195 TEST_F(LayerTreeHostCommonTest, TransformsForSingleLayer) { 195 TEST_F(LayerTreeHostCommonTest, TransformsForSingleLayer) {
196 gfx::Transform identity_matrix; 196 gfx::Transform identity_matrix;
197 LayerImpl* root = root_layer(); 197 LayerImpl* root = root_layer_for_testing();
198 LayerImpl* layer = AddChild<LayerImpl>(root); 198 LayerImpl* layer = AddChild<LayerImpl>(root);
199 199
200 SetLayerPropertiesForTesting(root, identity_matrix, gfx::Point3F(), 200 SetLayerPropertiesForTesting(root, identity_matrix, gfx::Point3F(),
201 gfx::PointF(), gfx::Size(1, 2), true, false); 201 gfx::PointF(), gfx::Size(1, 2), true, false);
202 202
203 TransformTree& tree = 203 TransformTree& tree =
204 host_impl()->active_tree()->property_trees()->transform_tree; 204 host_impl()->active_tree()->property_trees()->transform_tree;
205 205
206 // Case 2: Setting the bounds of the layer should not affect either the draw 206 // Case 2: Setting the bounds of the layer should not affect either the draw
207 // transform or the screenspace transform. 207 // transform or the screenspace transform.
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
337 kScrollOffset); 337 kScrollOffset);
338 338
339 std::unique_ptr<LayerImpl> root( 339 std::unique_ptr<LayerImpl> root(
340 LayerImpl::Create(host_impl.active_tree(), 3)); 340 LayerImpl::Create(host_impl.active_tree(), 3));
341 SetLayerPropertiesForTesting(root.get(), identity_matrix, gfx::Point3F(), 341 SetLayerPropertiesForTesting(root.get(), identity_matrix, gfx::Point3F(),
342 gfx::PointF(), gfx::Size(3, 4), true, false, 342 gfx::PointF(), gfx::Size(3, 4), true, false,
343 false); 343 false);
344 root->test_properties()->AddChild(std::move(clip_layer_scoped_ptr)); 344 root->test_properties()->AddChild(std::move(clip_layer_scoped_ptr));
345 root->SetHasRenderSurface(true); 345 root->SetHasRenderSurface(true);
346 LayerImpl* root_layer = root.get(); 346 LayerImpl* root_layer = root.get();
347 host_impl.active_tree()->SetRootLayer(std::move(root)); 347 host_impl.active_tree()->SetRootLayerForTesting(std::move(root));
348 348
349 ExecuteCalculateDrawProperties(root_layer, kDeviceScale, page_scale, 349 ExecuteCalculateDrawProperties(root_layer, kDeviceScale, page_scale,
350 scroll_layer->test_properties()->parent); 350 scroll_layer->test_properties()->parent);
351 gfx::Transform expected_transform = identity_matrix; 351 gfx::Transform expected_transform = identity_matrix;
352 gfx::PointF sub_layer_screen_position = kScrollLayerPosition - kScrollDelta; 352 gfx::PointF sub_layer_screen_position = kScrollLayerPosition - kScrollDelta;
353 expected_transform.Translate(MathUtil::Round(sub_layer_screen_position.x() * 353 expected_transform.Translate(MathUtil::Round(sub_layer_screen_position.x() *
354 page_scale * kDeviceScale), 354 page_scale * kDeviceScale),
355 MathUtil::Round(sub_layer_screen_position.y() * 355 MathUtil::Round(sub_layer_screen_position.y() *
356 page_scale * kDeviceScale)); 356 page_scale * kDeviceScale));
357 expected_transform.Scale(page_scale * kDeviceScale, 357 expected_transform.Scale(page_scale * kDeviceScale,
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
403 sub_layer_screen_position.y() * page_scale * 403 sub_layer_screen_position.y() * page_scale *
404 kDeviceScale)); 404 kDeviceScale));
405 expected_transform.Scale(page_scale * kDeviceScale, 405 expected_transform.Scale(page_scale * kDeviceScale,
406 page_scale * kDeviceScale); 406 page_scale * kDeviceScale);
407 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_transform, 407 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_transform,
408 sublayer->DrawTransform()); 408 sublayer->DrawTransform());
409 } 409 }
410 410
411 TEST_F(LayerTreeHostCommonTest, TransformsForSimpleHierarchy) { 411 TEST_F(LayerTreeHostCommonTest, TransformsForSimpleHierarchy) {
412 gfx::Transform identity_matrix; 412 gfx::Transform identity_matrix;
413 LayerImpl* root = root_layer(); 413 LayerImpl* root = root_layer_for_testing();
414 LayerImpl* parent = AddChild<LayerImpl>(root); 414 LayerImpl* parent = AddChild<LayerImpl>(root);
415 LayerImpl* child = AddChild<LayerImpl>(parent); 415 LayerImpl* child = AddChild<LayerImpl>(parent);
416 LayerImpl* grand_child = AddChild<LayerImpl>(child); 416 LayerImpl* grand_child = AddChild<LayerImpl>(child);
417 417
418 // One-time setup of root layer 418 // One-time setup of root layer
419 SetLayerPropertiesForTesting(root, identity_matrix, gfx::Point3F(), 419 SetLayerPropertiesForTesting(root, identity_matrix, gfx::Point3F(),
420 gfx::PointF(), gfx::Size(1, 2), true, false); 420 gfx::PointF(), gfx::Size(1, 2), true, false);
421 421
422 TransformTree& tree = 422 TransformTree& tree =
423 host_impl()->active_tree()->property_trees()->transform_tree; 423 host_impl()->active_tree()->property_trees()->transform_tree;
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
492 draw_property_utils::ScreenSpaceTransform(child, tree)); 492 draw_property_utils::ScreenSpaceTransform(child, tree));
493 EXPECT_TRANSFORMATION_MATRIX_EQ( 493 EXPECT_TRANSFORMATION_MATRIX_EQ(
494 parent_composite_transform, 494 parent_composite_transform,
495 draw_property_utils::DrawTransform(grand_child, tree)); 495 draw_property_utils::DrawTransform(grand_child, tree));
496 EXPECT_TRANSFORMATION_MATRIX_EQ( 496 EXPECT_TRANSFORMATION_MATRIX_EQ(
497 parent_composite_transform, 497 parent_composite_transform,
498 draw_property_utils::ScreenSpaceTransform(grand_child, tree)); 498 draw_property_utils::ScreenSpaceTransform(grand_child, tree));
499 } 499 }
500 500
501 TEST_F(LayerTreeHostCommonTest, TransformsForSingleRenderSurface) { 501 TEST_F(LayerTreeHostCommonTest, TransformsForSingleRenderSurface) {
502 LayerImpl* root = root_layer(); 502 LayerImpl* root = root_layer_for_testing();
503 LayerImpl* parent = AddChildToRoot<LayerImpl>(); 503 LayerImpl* parent = AddChildToRoot<LayerImpl>();
504 LayerImpl* child = AddChild<LayerImpl>(parent); 504 LayerImpl* child = AddChild<LayerImpl>(parent);
505 LayerImpl* grand_child = AddChild<LayerImpl>(child); 505 LayerImpl* grand_child = AddChild<LayerImpl>(child);
506 grand_child->SetDrawsContent(true); 506 grand_child->SetDrawsContent(true);
507 507
508 gfx::Transform identity_matrix; 508 gfx::Transform identity_matrix;
509 SetLayerPropertiesForTesting(root, identity_matrix, gfx::Point3F(), 509 SetLayerPropertiesForTesting(root, identity_matrix, gfx::Point3F(),
510 gfx::PointF(), gfx::Size(1, 2), true, false, 510 gfx::PointF(), gfx::Size(1, 2), true, false,
511 true); 511 true);
512 512
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
560 child->render_target()->draw_transform()); 560 child->render_target()->draw_transform());
561 561
562 // The screen space is the same as the target since the child surface draws 562 // The screen space is the same as the target since the child surface draws
563 // into the root. 563 // into the root.
564 EXPECT_TRANSFORMATION_MATRIX_EQ( 564 EXPECT_TRANSFORMATION_MATRIX_EQ(
565 surface_sublayer_composite_transform, 565 surface_sublayer_composite_transform,
566 child->render_target()->screen_space_transform()); 566 child->render_target()->screen_space_transform());
567 } 567 }
568 568
569 TEST_F(LayerTreeHostCommonTest, TransformsWhenCannotRenderToSeparateSurface) { 569 TEST_F(LayerTreeHostCommonTest, TransformsWhenCannotRenderToSeparateSurface) {
570 LayerImpl* root = root_layer(); 570 LayerImpl* root = root_layer_for_testing();
571 LayerImpl* parent = AddChildToRoot<LayerImpl>(); 571 LayerImpl* parent = AddChildToRoot<LayerImpl>();
572 LayerImpl* child = AddChild<LayerImpl>(parent); 572 LayerImpl* child = AddChild<LayerImpl>(parent);
573 LayerImpl* grand_child = AddChild<LayerImpl>(child); 573 LayerImpl* grand_child = AddChild<LayerImpl>(child);
574 grand_child->SetDrawsContent(true); 574 grand_child->SetDrawsContent(true);
575 575
576 gfx::Transform identity_matrix; 576 gfx::Transform identity_matrix;
577 SetLayerPropertiesForTesting(root, identity_matrix, gfx::Point3F(), 577 SetLayerPropertiesForTesting(root, identity_matrix, gfx::Point3F(),
578 gfx::PointF(), gfx::Size(100, 100), true, false, 578 gfx::PointF(), gfx::Size(100, 100), true, false,
579 true); 579 true);
580 580
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
615 615
616 // With separate surfaces disabled, the grand child's draw transform should be 616 // With separate surfaces disabled, the grand child's draw transform should be
617 // the same as its screen space transform. 617 // the same as its screen space transform.
618 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_grand_child_screen_space_transform, 618 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_grand_child_screen_space_transform,
619 grand_child->DrawTransform()); 619 grand_child->DrawTransform());
620 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_grand_child_screen_space_transform, 620 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_grand_child_screen_space_transform,
621 grand_child->ScreenSpaceTransform()); 621 grand_child->ScreenSpaceTransform());
622 } 622 }
623 623
624 TEST_F(LayerTreeHostCommonTest, TransformsForReplica) { 624 TEST_F(LayerTreeHostCommonTest, TransformsForReplica) {
625 LayerImpl* root = root_layer(); 625 LayerImpl* root = root_layer_for_testing();
626 LayerImpl* parent = AddChildToRoot<LayerImpl>(); 626 LayerImpl* parent = AddChildToRoot<LayerImpl>();
627 LayerImpl* child = AddChild<LayerImpl>(parent); 627 LayerImpl* child = AddChild<LayerImpl>(parent);
628 LayerImpl* grand_child = AddChild<LayerImpl>(child); 628 LayerImpl* grand_child = AddChild<LayerImpl>(child);
629 grand_child->SetDrawsContent(true); 629 grand_child->SetDrawsContent(true);
630 std::unique_ptr<LayerImpl> child_replica = 630 std::unique_ptr<LayerImpl> child_replica =
631 LayerImpl::Create(host_impl()->active_tree(), 100); 631 LayerImpl::Create(host_impl()->active_tree(), 100);
632 632
633 // One-time setup of root layer 633 // One-time setup of root layer
634 gfx::Transform identity_matrix; 634 gfx::Transform identity_matrix;
635 SetLayerPropertiesForTesting(root, identity_matrix, gfx::Point3F(), 635 SetLayerPropertiesForTesting(root, identity_matrix, gfx::Point3F(),
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
696 // transforms described w.r.t. that surface 696 // transforms described w.r.t. that surface
697 // - A render surface described w.r.t. an ancestor render surface: should 697 // - A render surface described w.r.t. an ancestor render surface: should
698 // have a draw transform described w.r.t. that ancestor surface 698 // have a draw transform described w.r.t. that ancestor surface
699 // - Replicas of a render surface are described w.r.t. the replica's 699 // - Replicas of a render surface are described w.r.t. the replica's
700 // transform around its anchor, along with the surface itself. 700 // transform around its anchor, along with the surface itself.
701 // - Sanity check on recursion: verify transforms of layers described w.r.t. 701 // - Sanity check on recursion: verify transforms of layers described w.r.t.
702 // a render surface that is described w.r.t. an ancestor render surface. 702 // a render surface that is described w.r.t. an ancestor render surface.
703 // - verifying that each layer has a reference to the correct render surface 703 // - verifying that each layer has a reference to the correct render surface
704 // and render target values. 704 // and render target values.
705 705
706 LayerImpl* root = root_layer(); 706 LayerImpl* root = root_layer_for_testing();
707 LayerImpl* parent = AddChildToRoot<LayerImpl>(); 707 LayerImpl* parent = AddChildToRoot<LayerImpl>();
708 parent->SetDrawsContent(true); 708 parent->SetDrawsContent(true);
709 LayerImpl* render_surface1 = AddChild<LayerImpl>(parent); 709 LayerImpl* render_surface1 = AddChild<LayerImpl>(parent);
710 render_surface1->SetDrawsContent(true); 710 render_surface1->SetDrawsContent(true);
711 LayerImpl* render_surface2 = AddChild<LayerImpl>(render_surface1); 711 LayerImpl* render_surface2 = AddChild<LayerImpl>(render_surface1);
712 render_surface2->SetDrawsContent(true); 712 render_surface2->SetDrawsContent(true);
713 LayerImpl* child_of_root = AddChild<LayerImpl>(parent); 713 LayerImpl* child_of_root = AddChild<LayerImpl>(parent);
714 child_of_root->SetDrawsContent(true); 714 child_of_root->SetDrawsContent(true);
715 LayerImpl* child_of_rs1 = AddChild<LayerImpl>(render_surface1); 715 LayerImpl* child_of_rs1 = AddChild<LayerImpl>(render_surface1);
716 child_of_rs1->SetDrawsContent(true); 716 child_of_rs1->SetDrawsContent(true);
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
938 EXPECT_FLOAT_EQ( 938 EXPECT_FLOAT_EQ(
939 5.0, grand_child_of_rs2->ScreenSpaceTransform().matrix().get(1, 3)); 939 5.0, grand_child_of_rs2->ScreenSpaceTransform().matrix().get(1, 3));
940 } 940 }
941 941
942 TEST_F(LayerTreeHostCommonTest, TransformsForFlatteningLayer) { 942 TEST_F(LayerTreeHostCommonTest, TransformsForFlatteningLayer) {
943 // For layers that flatten their subtree, there should be an orthographic 943 // For layers that flatten their subtree, there should be an orthographic
944 // projection (for x and y values) in the middle of the transform sequence. 944 // projection (for x and y values) in the middle of the transform sequence.
945 // Note that the way the code is currently implemented, it is not expected to 945 // Note that the way the code is currently implemented, it is not expected to
946 // use a canonical orthographic projection. 946 // use a canonical orthographic projection.
947 947
948 LayerImpl* root = root_layer(); 948 LayerImpl* root = root_layer_for_testing();
949 LayerImpl* child = AddChildToRoot<LayerImpl>(); 949 LayerImpl* child = AddChildToRoot<LayerImpl>();
950 child->SetDrawsContent(true); 950 child->SetDrawsContent(true);
951 LayerImpl* grand_child = AddChild<LayerImpl>(child); 951 LayerImpl* grand_child = AddChild<LayerImpl>(child);
952 grand_child->SetDrawsContent(true); 952 grand_child->SetDrawsContent(true);
953 LayerImpl* great_grand_child = AddChild<LayerImpl>(grand_child); 953 LayerImpl* great_grand_child = AddChild<LayerImpl>(grand_child);
954 great_grand_child->SetDrawsContent(true); 954 great_grand_child->SetDrawsContent(true);
955 955
956 gfx::Transform rotation_about_y_axis; 956 gfx::Transform rotation_about_y_axis;
957 rotation_about_y_axis.RotateAboutYAxis(30.0); 957 rotation_about_y_axis.RotateAboutYAxis(30.0);
958 958
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
1006 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_grand_child_screen_space_transform, 1006 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_grand_child_screen_space_transform,
1007 grand_child->ScreenSpaceTransform()); 1007 grand_child->ScreenSpaceTransform());
1008 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_great_grand_child_draw_transform, 1008 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_great_grand_child_draw_transform,
1009 great_grand_child->DrawTransform()); 1009 great_grand_child->DrawTransform());
1010 EXPECT_TRANSFORMATION_MATRIX_EQ( 1010 EXPECT_TRANSFORMATION_MATRIX_EQ(
1011 expected_great_grand_child_screen_space_transform, 1011 expected_great_grand_child_screen_space_transform,
1012 great_grand_child->ScreenSpaceTransform()); 1012 great_grand_child->ScreenSpaceTransform());
1013 } 1013 }
1014 1014
1015 TEST_F(LayerTreeHostCommonTest, LayerFullyContainedWithinClipInTargetSpace) { 1015 TEST_F(LayerTreeHostCommonTest, LayerFullyContainedWithinClipInTargetSpace) {
1016 LayerImpl* root = root_layer(); 1016 LayerImpl* root = root_layer_for_testing();
1017 LayerImpl* child = AddChild<LayerImpl>(root); 1017 LayerImpl* child = AddChild<LayerImpl>(root);
1018 LayerImpl* grand_child = AddChild<LayerImpl>(child); 1018 LayerImpl* grand_child = AddChild<LayerImpl>(child);
1019 1019
1020 gfx::Transform child_transform; 1020 gfx::Transform child_transform;
1021 child_transform.Translate(50.0, 50.0); 1021 child_transform.Translate(50.0, 50.0);
1022 child_transform.RotateAboutZAxis(30.0); 1022 child_transform.RotateAboutZAxis(30.0);
1023 1023
1024 gfx::Transform grand_child_transform; 1024 gfx::Transform grand_child_transform;
1025 grand_child_transform.RotateAboutYAxis(90.0); 1025 grand_child_transform.RotateAboutYAxis(90.0);
1026 1026
(...skipping 23 matching lines...) Expand all
1050 TEST_F(LayerTreeHostCommonTest, TransformsForDegenerateIntermediateLayer) { 1050 TEST_F(LayerTreeHostCommonTest, TransformsForDegenerateIntermediateLayer) {
1051 // A layer that is empty in one axis, but not the other, was accidentally 1051 // A layer that is empty in one axis, but not the other, was accidentally
1052 // skipping a necessary translation. Without that translation, the coordinate 1052 // skipping a necessary translation. Without that translation, the coordinate
1053 // space of the layer's draw transform is incorrect. 1053 // space of the layer's draw transform is incorrect.
1054 // 1054 //
1055 // Normally this isn't a problem, because the layer wouldn't be drawn anyway, 1055 // Normally this isn't a problem, because the layer wouldn't be drawn anyway,
1056 // but if that layer becomes a render surface, then its draw transform is 1056 // but if that layer becomes a render surface, then its draw transform is
1057 // implicitly inherited by the rest of the subtree, which then is positioned 1057 // implicitly inherited by the rest of the subtree, which then is positioned
1058 // incorrectly as a result. 1058 // incorrectly as a result.
1059 1059
1060 LayerImpl* root = root_layer(); 1060 LayerImpl* root = root_layer_for_testing();
1061 LayerImpl* child = AddChild<LayerImpl>(root); 1061 LayerImpl* child = AddChild<LayerImpl>(root);
1062 LayerImpl* grand_child = AddChild<LayerImpl>(child); 1062 LayerImpl* grand_child = AddChild<LayerImpl>(child);
1063 grand_child->SetDrawsContent(true); 1063 grand_child->SetDrawsContent(true);
1064 1064
1065 // The child height is zero, but has non-zero width that should be accounted 1065 // The child height is zero, but has non-zero width that should be accounted
1066 // for while computing draw transforms. 1066 // for while computing draw transforms.
1067 const gfx::Transform identity_matrix; 1067 const gfx::Transform identity_matrix;
1068 SetLayerPropertiesForTesting(root, identity_matrix, gfx::Point3F(), 1068 SetLayerPropertiesForTesting(root, identity_matrix, gfx::Point3F(),
1069 gfx::PointF(), gfx::Size(100, 100), true, false, 1069 gfx::PointF(), gfx::Size(100, 100), true, false,
1070 true); 1070 true);
(...skipping 10 matching lines...) Expand all
1081 // This is the real test, the rest are sanity checks. 1081 // This is the real test, the rest are sanity checks.
1082 EXPECT_TRANSFORMATION_MATRIX_EQ(identity_matrix, 1082 EXPECT_TRANSFORMATION_MATRIX_EQ(identity_matrix,
1083 child->render_surface()->draw_transform()); 1083 child->render_surface()->draw_transform());
1084 EXPECT_TRANSFORMATION_MATRIX_EQ(identity_matrix, child->DrawTransform()); 1084 EXPECT_TRANSFORMATION_MATRIX_EQ(identity_matrix, child->DrawTransform());
1085 EXPECT_TRANSFORMATION_MATRIX_EQ(identity_matrix, 1085 EXPECT_TRANSFORMATION_MATRIX_EQ(identity_matrix,
1086 grand_child->DrawTransform()); 1086 grand_child->DrawTransform());
1087 } 1087 }
1088 1088
1089 TEST_F(LayerTreeHostCommonTest, RenderSurfaceWithSublayerScale) { 1089 TEST_F(LayerTreeHostCommonTest, RenderSurfaceWithSublayerScale) {
1090 const gfx::Transform identity_matrix; 1090 const gfx::Transform identity_matrix;
1091 LayerImpl* root = root_layer(); 1091 LayerImpl* root = root_layer_for_testing();
1092 LayerImpl* render_surface = AddChild<LayerImpl>(root); 1092 LayerImpl* render_surface = AddChild<LayerImpl>(root);
1093 LayerImpl* child = AddChild<LayerImpl>(render_surface); 1093 LayerImpl* child = AddChild<LayerImpl>(render_surface);
1094 LayerImpl* grand_child = AddChild<LayerImpl>(child); 1094 LayerImpl* grand_child = AddChild<LayerImpl>(child);
1095 1095
1096 SetLayerPropertiesForTesting(root, identity_matrix, gfx::Point3F(), 1096 SetLayerPropertiesForTesting(root, identity_matrix, gfx::Point3F(),
1097 gfx::PointF(), gfx::Size(100, 100), true, false, 1097 gfx::PointF(), gfx::Size(100, 100), true, false,
1098 true); 1098 true);
1099 gfx::Transform translate; 1099 gfx::Transform translate;
1100 translate.Translate3d(5, 5, 5); 1100 translate.Translate3d(5, 5, 5);
1101 SetLayerPropertiesForTesting(render_surface, translate, gfx::Point3F(), 1101 SetLayerPropertiesForTesting(render_surface, translate, gfx::Point3F(),
(...skipping 19 matching lines...) Expand all
1121 // by a factor of 2. 1121 // by a factor of 2.
1122 gfx::Vector2dF expected_translation(20.0f, 20.0f); 1122 gfx::Vector2dF expected_translation(20.0f, 20.0f);
1123 EXPECT_EQ(grand_child->DrawTransform().To2dTranslation(), 1123 EXPECT_EQ(grand_child->DrawTransform().To2dTranslation(),
1124 expected_translation); 1124 expected_translation);
1125 } 1125 }
1126 1126
1127 TEST_F(LayerTreeHostCommonTest, TransformAboveRootLayer) { 1127 TEST_F(LayerTreeHostCommonTest, TransformAboveRootLayer) {
1128 // Transformations applied at the root of the tree should be forwarded 1128 // Transformations applied at the root of the tree should be forwarded
1129 // to child layers instead of applied to the root RenderSurface. 1129 // to child layers instead of applied to the root RenderSurface.
1130 const gfx::Transform identity_matrix; 1130 const gfx::Transform identity_matrix;
1131 LayerImpl* root = root_layer(); 1131 LayerImpl* root = root_layer_for_testing();
1132 root->SetDrawsContent(true); 1132 root->SetDrawsContent(true);
1133 LayerImpl* child = AddChild<LayerImpl>(root); 1133 LayerImpl* child = AddChild<LayerImpl>(root);
1134 child->SetDrawsContent(true); 1134 child->SetDrawsContent(true);
1135 1135
1136 child->SetScrollClipLayer(root->id()); 1136 child->SetScrollClipLayer(root->id());
1137 1137
1138 SetLayerPropertiesForTesting(root, identity_matrix, gfx::Point3F(), 1138 SetLayerPropertiesForTesting(root, identity_matrix, gfx::Point3F(),
1139 gfx::PointF(), gfx::Size(20, 20), true, false, 1139 gfx::PointF(), gfx::Size(20, 20), true, false,
1140 true); 1140 true);
1141 SetLayerPropertiesForTesting(child, identity_matrix, gfx::Point3F(), 1141 SetLayerPropertiesForTesting(child, identity_matrix, gfx::Point3F(),
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
1249 EXPECT_TRANSFORMATION_MATRIX_EQ( 1249 EXPECT_TRANSFORMATION_MATRIX_EQ(
1250 compositeSquared, root->draw_properties().target_space_transform); 1250 compositeSquared, root->draw_properties().target_space_transform);
1251 EXPECT_TRANSFORMATION_MATRIX_EQ( 1251 EXPECT_TRANSFORMATION_MATRIX_EQ(
1252 compositeSquared, child->draw_properties().target_space_transform); 1252 compositeSquared, child->draw_properties().target_space_transform);
1253 EXPECT_EQ(identity_matrix, root->render_surface()->draw_transform()); 1253 EXPECT_EQ(identity_matrix, root->render_surface()->draw_transform());
1254 } 1254 }
1255 } 1255 }
1256 1256
1257 TEST_F(LayerTreeHostCommonTest, 1257 TEST_F(LayerTreeHostCommonTest,
1258 RenderSurfaceListForRenderSurfaceWithClippedLayer) { 1258 RenderSurfaceListForRenderSurfaceWithClippedLayer) {
1259 LayerImpl* parent = root_layer(); 1259 LayerImpl* parent = root_layer_for_testing();
1260 parent->SetMasksToBounds(true); 1260 parent->SetMasksToBounds(true);
1261 LayerImpl* render_surface1 = AddChildToRoot<LayerImpl>(); 1261 LayerImpl* render_surface1 = AddChildToRoot<LayerImpl>();
1262 LayerImpl* child = AddChild<LayerImpl>(render_surface1); 1262 LayerImpl* child = AddChild<LayerImpl>(render_surface1);
1263 child->SetDrawsContent(true); 1263 child->SetDrawsContent(true);
1264 1264
1265 const gfx::Transform identity_matrix; 1265 const gfx::Transform identity_matrix;
1266 SetLayerPropertiesForTesting(parent, identity_matrix, gfx::Point3F(), 1266 SetLayerPropertiesForTesting(parent, identity_matrix, gfx::Point3F(),
1267 gfx::PointF(), gfx::Size(10, 10), true, false, 1267 gfx::PointF(), gfx::Size(10, 10), true, false,
1268 true); 1268 true);
1269 SetLayerPropertiesForTesting(render_surface1, identity_matrix, gfx::Point3F(), 1269 SetLayerPropertiesForTesting(render_surface1, identity_matrix, gfx::Point3F(),
1270 gfx::PointF(), gfx::Size(10, 10), true, false, 1270 gfx::PointF(), gfx::Size(10, 10), true, false,
1271 true); 1271 true);
1272 SetLayerPropertiesForTesting(child, identity_matrix, gfx::Point3F(), 1272 SetLayerPropertiesForTesting(child, identity_matrix, gfx::Point3F(),
1273 gfx::PointF(30.f, 30.f), gfx::Size(10, 10), true, 1273 gfx::PointF(30.f, 30.f), gfx::Size(10, 10), true,
1274 false, false); 1274 false, false);
1275 1275
1276 ExecuteCalculateDrawProperties(parent); 1276 ExecuteCalculateDrawProperties(parent);
1277 1277
1278 // The child layer's content is entirely outside the parent's clip rect, so 1278 // The child layer's content is entirely outside the parent's clip rect, so
1279 // the intermediate render surface should not be listed here, even if it was 1279 // the intermediate render surface should not be listed here, even if it was
1280 // forced to be created. Render surfaces without children or visible content 1280 // forced to be created. Render surfaces without children or visible content
1281 // are unexpected at draw time (e.g. we might try to create a content texture 1281 // are unexpected at draw time (e.g. we might try to create a content texture
1282 // of size 0). 1282 // of size 0).
1283 ASSERT_TRUE(parent->render_surface()); 1283 ASSERT_TRUE(parent->render_surface());
1284 EXPECT_EQ(1U, render_surface_layer_list_impl()->size()); 1284 EXPECT_EQ(1U, render_surface_layer_list_impl()->size());
1285 } 1285 }
1286 1286
1287 TEST_F(LayerTreeHostCommonTest, RenderSurfaceListForTransparentChild) { 1287 TEST_F(LayerTreeHostCommonTest, RenderSurfaceListForTransparentChild) {
1288 LayerImpl* parent = root_layer(); 1288 LayerImpl* parent = root_layer_for_testing();
1289 LayerImpl* render_surface1 = AddChild<LayerImpl>(parent); 1289 LayerImpl* render_surface1 = AddChild<LayerImpl>(parent);
1290 LayerImpl* child = AddChild<LayerImpl>(render_surface1); 1290 LayerImpl* child = AddChild<LayerImpl>(render_surface1);
1291 child->SetDrawsContent(true); 1291 child->SetDrawsContent(true);
1292 1292
1293 const gfx::Transform identity_matrix; 1293 const gfx::Transform identity_matrix;
1294 SetLayerPropertiesForTesting(render_surface1, identity_matrix, gfx::Point3F(), 1294 SetLayerPropertiesForTesting(render_surface1, identity_matrix, gfx::Point3F(),
1295 gfx::PointF(), gfx::Size(10, 10), true, false, 1295 gfx::PointF(), gfx::Size(10, 10), true, false,
1296 true); 1296 true);
1297 SetLayerPropertiesForTesting(child, identity_matrix, gfx::Point3F(), 1297 SetLayerPropertiesForTesting(child, identity_matrix, gfx::Point3F(),
1298 gfx::PointF(), gfx::Size(10, 10), true, false, 1298 gfx::PointF(), gfx::Size(10, 10), true, false,
(...skipping 11 matching lines...) Expand all
1310 // have been extended by the children. 1310 // have been extended by the children.
1311 ASSERT_TRUE(parent->render_surface()); 1311 ASSERT_TRUE(parent->render_surface());
1312 EXPECT_EQ(0U, parent->render_surface()->layer_list().size()); 1312 EXPECT_EQ(0U, parent->render_surface()->layer_list().size());
1313 EXPECT_EQ(1U, render_surface_layer_list.size()); 1313 EXPECT_EQ(1U, render_surface_layer_list.size());
1314 EXPECT_EQ(parent->id(), render_surface_layer_list.at(0)->id()); 1314 EXPECT_EQ(parent->id(), render_surface_layer_list.at(0)->id());
1315 EXPECT_EQ(gfx::Rect(), parent->drawable_content_rect()); 1315 EXPECT_EQ(gfx::Rect(), parent->drawable_content_rect());
1316 } 1316 }
1317 1317
1318 TEST_F(LayerTreeHostCommonTest, 1318 TEST_F(LayerTreeHostCommonTest,
1319 RenderSurfaceListForTransparentChildWithBackgroundFilter) { 1319 RenderSurfaceListForTransparentChildWithBackgroundFilter) {
1320 LayerImpl* parent = root_layer(); 1320 LayerImpl* parent = root_layer_for_testing();
1321 LayerImpl* render_surface1 = AddChild<LayerImpl>(parent); 1321 LayerImpl* render_surface1 = AddChild<LayerImpl>(parent);
1322 LayerImpl* child = AddChild<LayerImpl>(render_surface1); 1322 LayerImpl* child = AddChild<LayerImpl>(render_surface1);
1323 child->SetDrawsContent(true); 1323 child->SetDrawsContent(true);
1324 1324
1325 const gfx::Transform identity_matrix; 1325 const gfx::Transform identity_matrix;
1326 SetLayerPropertiesForTesting(parent, identity_matrix, gfx::Point3F(), 1326 SetLayerPropertiesForTesting(parent, identity_matrix, gfx::Point3F(),
1327 gfx::PointF(), gfx::Size(10, 10), true, false, 1327 gfx::PointF(), gfx::Size(10, 10), true, false,
1328 true); 1328 true);
1329 SetLayerPropertiesForTesting(render_surface1, identity_matrix, gfx::Point3F(), 1329 SetLayerPropertiesForTesting(render_surface1, identity_matrix, gfx::Point3F(),
1330 gfx::PointF(), gfx::Size(10, 10), true, false, 1330 gfx::PointF(), gfx::Size(10, 10), true, false,
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
1369 inputs.can_adjust_raster_scales = true; 1369 inputs.can_adjust_raster_scales = true;
1370 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); 1370 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs);
1371 } 1371 }
1372 1372
1373 node = effect_tree.Node(render_surface1->effect_tree_index()); 1373 node = effect_tree.Node(render_surface1->effect_tree_index());
1374 EXPECT_FALSE(node->data.is_drawn); 1374 EXPECT_FALSE(node->data.is_drawn);
1375 EXPECT_EQ(gfx::Rect(), render_surface1->visible_layer_rect()); 1375 EXPECT_EQ(gfx::Rect(), render_surface1->visible_layer_rect());
1376 } 1376 }
1377 1377
1378 TEST_F(LayerTreeHostCommonTest, RenderSurfaceListForFilter) { 1378 TEST_F(LayerTreeHostCommonTest, RenderSurfaceListForFilter) {
1379 LayerImpl* root = root_layer(); 1379 LayerImpl* root = root_layer_for_testing();
1380 LayerImpl* parent = AddChild<LayerImpl>(root); 1380 LayerImpl* parent = AddChild<LayerImpl>(root);
1381 LayerImpl* child1 = AddChild<LayerImpl>(parent); 1381 LayerImpl* child1 = AddChild<LayerImpl>(parent);
1382 LayerImpl* child2 = AddChild<LayerImpl>(parent); 1382 LayerImpl* child2 = AddChild<LayerImpl>(parent);
1383 child1->SetDrawsContent(true); 1383 child1->SetDrawsContent(true);
1384 child2->SetDrawsContent(true); 1384 child2->SetDrawsContent(true);
1385 1385
1386 const gfx::Transform identity_matrix; 1386 const gfx::Transform identity_matrix;
1387 gfx::Transform scale_matrix; 1387 gfx::Transform scale_matrix;
1388 scale_matrix.Scale(2.0f, 2.0f); 1388 scale_matrix.Scale(2.0f, 2.0f);
1389 SetLayerPropertiesForTesting(root, identity_matrix, gfx::Point3F(), 1389 SetLayerPropertiesForTesting(root, identity_matrix, gfx::Point3F(),
(...skipping 22 matching lines...) Expand all
1412 EXPECT_EQ(4U, render_surface_layer_list.size()); 1412 EXPECT_EQ(4U, render_surface_layer_list.size());
1413 1413
1414 // The rectangle enclosing child1 and child2 (0,0 50x50), expanded for the 1414 // The rectangle enclosing child1 and child2 (0,0 50x50), expanded for the
1415 // blur (-30,-30 110x110), and then scaled by the scale matrix 1415 // blur (-30,-30 110x110), and then scaled by the scale matrix
1416 // (-60,-60 220x220). 1416 // (-60,-60 220x220).
1417 EXPECT_EQ(gfx::RectF(-60, -60, 220, 220), 1417 EXPECT_EQ(gfx::RectF(-60, -60, 220, 220),
1418 parent->render_surface()->DrawableContentRect()); 1418 parent->render_surface()->DrawableContentRect());
1419 } 1419 }
1420 1420
1421 TEST_F(LayerTreeHostCommonTest, DrawableContentRectForReferenceFilter) { 1421 TEST_F(LayerTreeHostCommonTest, DrawableContentRectForReferenceFilter) {
1422 LayerImpl* root = root_layer(); 1422 LayerImpl* root = root_layer_for_testing();
1423 LayerImpl* child = AddChild<LayerImpl>(root); 1423 LayerImpl* child = AddChild<LayerImpl>(root);
1424 child->SetDrawsContent(true); 1424 child->SetDrawsContent(true);
1425 1425
1426 SetLayerPropertiesForTesting(root, gfx::Transform(), gfx::Point3F(), 1426 SetLayerPropertiesForTesting(root, gfx::Transform(), gfx::Point3F(),
1427 gfx::PointF(), gfx::Size(100, 100), true, false, 1427 gfx::PointF(), gfx::Size(100, 100), true, false,
1428 true); 1428 true);
1429 SetLayerPropertiesForTesting(child, gfx::Transform(), gfx::Point3F(), 1429 SetLayerPropertiesForTesting(child, gfx::Transform(), gfx::Point3F(),
1430 gfx::PointF(), gfx::Size(25, 25), true, false, 1430 gfx::PointF(), gfx::Size(25, 25), true, false,
1431 true); 1431 true);
1432 1432
1433 FilterOperations filters; 1433 FilterOperations filters;
1434 filters.Append(FilterOperation::CreateReferenceFilter( 1434 filters.Append(FilterOperation::CreateReferenceFilter(
1435 SkOffsetImageFilter::Make(50, 50, nullptr))); 1435 SkOffsetImageFilter::Make(50, 50, nullptr)));
1436 child->SetFilters(filters); 1436 child->SetFilters(filters);
1437 1437
1438 ExecuteCalculateDrawProperties(root); 1438 ExecuteCalculateDrawProperties(root);
1439 1439
1440 // The render surface's size should be unaffected by the offset image filter; 1440 // The render surface's size should be unaffected by the offset image filter;
1441 // it need only have a drawable content rect large enough to contain the 1441 // it need only have a drawable content rect large enough to contain the
1442 // contents (at the new offset). 1442 // contents (at the new offset).
1443 ASSERT_TRUE(child->render_surface()); 1443 ASSERT_TRUE(child->render_surface());
1444 EXPECT_EQ(gfx::RectF(50, 50, 25, 25), 1444 EXPECT_EQ(gfx::RectF(50, 50, 25, 25),
1445 child->render_surface()->DrawableContentRect()); 1445 child->render_surface()->DrawableContentRect());
1446 } 1446 }
1447 1447
1448 TEST_F(LayerTreeHostCommonTest, DrawableContentRectForReferenceFilterHighDpi) { 1448 TEST_F(LayerTreeHostCommonTest, DrawableContentRectForReferenceFilterHighDpi) {
1449 const float device_scale_factor = 2.0f; 1449 const float device_scale_factor = 2.0f;
1450 1450
1451 LayerImpl* root = root_layer(); 1451 LayerImpl* root = root_layer_for_testing();
1452 root->layer_tree_impl()->SetDeviceScaleFactor(device_scale_factor); 1452 root->layer_tree_impl()->SetDeviceScaleFactor(device_scale_factor);
1453 LayerImpl* child = AddChild<LayerImpl>(root); 1453 LayerImpl* child = AddChild<LayerImpl>(root);
1454 child->SetDrawsContent(true); 1454 child->SetDrawsContent(true);
1455 1455
1456 SetLayerPropertiesForTesting(root, gfx::Transform(), gfx::Point3F(), 1456 SetLayerPropertiesForTesting(root, gfx::Transform(), gfx::Point3F(),
1457 gfx::PointF(), gfx::Size(100, 100), true, false, 1457 gfx::PointF(), gfx::Size(100, 100), true, false,
1458 true); 1458 true);
1459 SetLayerPropertiesForTesting(child, gfx::Transform(), gfx::Point3F(), 1459 SetLayerPropertiesForTesting(child, gfx::Transform(), gfx::Point3F(),
1460 gfx::PointF(), gfx::Size(25, 25), true, false, 1460 gfx::PointF(), gfx::Size(25, 25), true, false,
1461 true); 1461 true);
1462 1462
1463 FilterOperations filters; 1463 FilterOperations filters;
1464 filters.Append(FilterOperation::CreateReferenceFilter( 1464 filters.Append(FilterOperation::CreateReferenceFilter(
1465 SkOffsetImageFilter::Make(50, 50, nullptr))); 1465 SkOffsetImageFilter::Make(50, 50, nullptr)));
1466 child->SetFilters(filters); 1466 child->SetFilters(filters);
1467 1467
1468 ExecuteCalculateDrawProperties(root, device_scale_factor); 1468 ExecuteCalculateDrawProperties(root, device_scale_factor);
1469 1469
1470 // The render surface's size should be unaffected by the offset image filter; 1470 // The render surface's size should be unaffected by the offset image filter;
1471 // it need only have a drawable content rect large enough to contain the 1471 // it need only have a drawable content rect large enough to contain the
1472 // contents (at the new offset). All coordinates should be scaled by 2, 1472 // contents (at the new offset). All coordinates should be scaled by 2,
1473 // corresponding to the device scale factor. 1473 // corresponding to the device scale factor.
1474 ASSERT_TRUE(child->render_surface()); 1474 ASSERT_TRUE(child->render_surface());
1475 EXPECT_EQ(gfx::RectF(100, 100, 50, 50), 1475 EXPECT_EQ(gfx::RectF(100, 100, 50, 50),
1476 child->render_surface()->DrawableContentRect()); 1476 child->render_surface()->DrawableContentRect());
1477 } 1477 }
1478 1478
1479 TEST_F(LayerTreeHostCommonTest, RenderSurfaceForBlendMode) { 1479 TEST_F(LayerTreeHostCommonTest, RenderSurfaceForBlendMode) {
1480 LayerImpl* parent = root_layer(); 1480 LayerImpl* parent = root_layer_for_testing();
1481 LayerImpl* child = AddChild<LayerImpl>(parent); 1481 LayerImpl* child = AddChild<LayerImpl>(parent);
1482 child->SetDrawsContent(true); 1482 child->SetDrawsContent(true);
1483 1483
1484 const gfx::Transform identity_matrix; 1484 const gfx::Transform identity_matrix;
1485 const SkXfermode::Mode blend_mode = SkXfermode::kMultiply_Mode; 1485 const SkXfermode::Mode blend_mode = SkXfermode::kMultiply_Mode;
1486 SetLayerPropertiesForTesting(parent, identity_matrix, gfx::Point3F(), 1486 SetLayerPropertiesForTesting(parent, identity_matrix, gfx::Point3F(),
1487 gfx::PointF(), gfx::Size(10, 10), true, false, 1487 gfx::PointF(), gfx::Size(10, 10), true, false,
1488 true); 1488 true);
1489 SetLayerPropertiesForTesting(child, identity_matrix, gfx::Point3F(), 1489 SetLayerPropertiesForTesting(child, identity_matrix, gfx::Point3F(),
1490 gfx::PointF(), gfx::Size(10, 10), true, false, 1490 gfx::PointF(), gfx::Size(10, 10), true, false,
1491 true); 1491 true);
1492 1492
1493 child->SetBlendMode(blend_mode); 1493 child->SetBlendMode(blend_mode);
1494 child->test_properties()->opacity = 0.5f; 1494 child->test_properties()->opacity = 0.5f;
1495 1495
1496 ExecuteCalculateDrawProperties(parent); 1496 ExecuteCalculateDrawProperties(parent);
1497 1497
1498 // Since the child layer has a blend mode other than normal, it should get 1498 // Since the child layer has a blend mode other than normal, it should get
1499 // its own render surface. Also, layer's draw_properties should contain the 1499 // its own render surface. Also, layer's draw_properties should contain the
1500 // default blend mode, since the render surface becomes responsible for 1500 // default blend mode, since the render surface becomes responsible for
1501 // applying the blend mode. 1501 // applying the blend mode.
1502 ASSERT_TRUE(child->render_surface()); 1502 ASSERT_TRUE(child->render_surface());
1503 EXPECT_EQ(1.0f, child->draw_opacity()); 1503 EXPECT_EQ(1.0f, child->draw_opacity());
1504 EXPECT_EQ(0.5f, child->render_surface()->draw_opacity()); 1504 EXPECT_EQ(0.5f, child->render_surface()->draw_opacity());
1505 EXPECT_EQ(SkXfermode::kSrcOver_Mode, child->draw_blend_mode()); 1505 EXPECT_EQ(SkXfermode::kSrcOver_Mode, child->draw_blend_mode());
1506 } 1506 }
1507 1507
1508 TEST_F(LayerTreeHostCommonTest, RenderSurfaceDrawOpacity) { 1508 TEST_F(LayerTreeHostCommonTest, RenderSurfaceDrawOpacity) {
1509 LayerImpl* root = root_layer(); 1509 LayerImpl* root = root_layer_for_testing();
1510 LayerImpl* surface1 = AddChildToRoot<LayerImpl>(); 1510 LayerImpl* surface1 = AddChildToRoot<LayerImpl>();
1511 LayerImpl* not_surface = AddChild<LayerImpl>(surface1); 1511 LayerImpl* not_surface = AddChild<LayerImpl>(surface1);
1512 LayerImpl* surface2 = AddChild<LayerImpl>(not_surface); 1512 LayerImpl* surface2 = AddChild<LayerImpl>(not_surface);
1513 1513
1514 const gfx::Transform identity_matrix; 1514 const gfx::Transform identity_matrix;
1515 SetLayerPropertiesForTesting(root, identity_matrix, gfx::Point3F(), 1515 SetLayerPropertiesForTesting(root, identity_matrix, gfx::Point3F(),
1516 gfx::PointF(), gfx::Size(10, 10), true, false, 1516 gfx::PointF(), gfx::Size(10, 10), true, false,
1517 true); 1517 true);
1518 SetLayerPropertiesForTesting(surface1, identity_matrix, gfx::Point3F(), 1518 SetLayerPropertiesForTesting(surface1, identity_matrix, gfx::Point3F(),
1519 gfx::PointF(), gfx::Size(10, 10), true, false, 1519 gfx::PointF(), gfx::Size(10, 10), true, false,
(...skipping 21 matching lines...) Expand all
1541 // itself, but not the opacity of surface1. 1541 // itself, but not the opacity of surface1.
1542 EXPECT_EQ(0.25f, surface2->render_surface()->draw_opacity()); 1542 EXPECT_EQ(0.25f, surface2->render_surface()->draw_opacity());
1543 } 1543 }
1544 1544
1545 TEST_F(LayerTreeHostCommonTest, DrawOpacityWhenCannotRenderToSeparateSurface) { 1545 TEST_F(LayerTreeHostCommonTest, DrawOpacityWhenCannotRenderToSeparateSurface) {
1546 // Tests that when separate surfaces are disabled, a layer's draw opacity is 1546 // Tests that when separate surfaces are disabled, a layer's draw opacity is
1547 // the product of all ancestor layer opacties and the layer's own opacity. 1547 // the product of all ancestor layer opacties and the layer's own opacity.
1548 // (Rendering will still be incorrect in situations where we really do need 1548 // (Rendering will still be incorrect in situations where we really do need
1549 // surfaces to apply opacity, such as when we have overlapping layers with an 1549 // surfaces to apply opacity, such as when we have overlapping layers with an
1550 // ancestor whose opacity is <1.) 1550 // ancestor whose opacity is <1.)
1551 LayerImpl* root = root_layer(); 1551 LayerImpl* root = root_layer_for_testing();
1552 LayerImpl* parent = AddChild<LayerImpl>(root); 1552 LayerImpl* parent = AddChild<LayerImpl>(root);
1553 LayerImpl* child1 = AddChild<LayerImpl>(parent); 1553 LayerImpl* child1 = AddChild<LayerImpl>(parent);
1554 LayerImpl* child2 = AddChild<LayerImpl>(parent); 1554 LayerImpl* child2 = AddChild<LayerImpl>(parent);
1555 LayerImpl* grand_child = AddChild<LayerImpl>(child1); 1555 LayerImpl* grand_child = AddChild<LayerImpl>(child1);
1556 LayerImpl* leaf_node1 = AddChild<LayerImpl>(grand_child); 1556 LayerImpl* leaf_node1 = AddChild<LayerImpl>(grand_child);
1557 LayerImpl* leaf_node2 = AddChild<LayerImpl>(child2); 1557 LayerImpl* leaf_node2 = AddChild<LayerImpl>(child2);
1558 1558
1559 root->SetDrawsContent(true); 1559 root->SetDrawsContent(true);
1560 parent->SetDrawsContent(true); 1560 parent->SetDrawsContent(true);
1561 child1->SetDrawsContent(true); 1561 child1->SetDrawsContent(true);
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
1613 EXPECT_EQ(1.f, root->draw_opacity()); 1613 EXPECT_EQ(1.f, root->draw_opacity());
1614 EXPECT_EQ(1.f, parent->draw_opacity()); 1614 EXPECT_EQ(1.f, parent->draw_opacity());
1615 EXPECT_EQ(0.5f, child1->draw_opacity()); 1615 EXPECT_EQ(0.5f, child1->draw_opacity());
1616 EXPECT_EQ(1.f, child2->draw_opacity()); 1616 EXPECT_EQ(1.f, child2->draw_opacity());
1617 EXPECT_EQ(0.25f, grand_child->draw_opacity()); 1617 EXPECT_EQ(0.25f, grand_child->draw_opacity());
1618 EXPECT_EQ(0.125f, leaf_node1->draw_opacity()); 1618 EXPECT_EQ(0.125f, leaf_node1->draw_opacity());
1619 EXPECT_EQ(0.5f, leaf_node2->draw_opacity()); 1619 EXPECT_EQ(0.5f, leaf_node2->draw_opacity());
1620 } 1620 }
1621 1621
1622 TEST_F(LayerTreeHostCommonTest, ForceRenderSurface) { 1622 TEST_F(LayerTreeHostCommonTest, ForceRenderSurface) {
1623 LayerImpl* parent = root_layer(); 1623 LayerImpl* parent = root_layer_for_testing();
1624 LayerImpl* render_surface1 = AddChildToRoot<LayerImpl>(); 1624 LayerImpl* render_surface1 = AddChildToRoot<LayerImpl>();
1625 LayerImpl* child = AddChild<LayerImpl>(render_surface1); 1625 LayerImpl* child = AddChild<LayerImpl>(render_surface1);
1626 1626
1627 const gfx::Transform identity_matrix; 1627 const gfx::Transform identity_matrix;
1628 SetLayerPropertiesForTesting(parent, identity_matrix, gfx::Point3F(), 1628 SetLayerPropertiesForTesting(parent, identity_matrix, gfx::Point3F(),
1629 gfx::PointF(), gfx::Size(10, 10), true, false); 1629 gfx::PointF(), gfx::Size(10, 10), true, false);
1630 SetLayerPropertiesForTesting(render_surface1, identity_matrix, gfx::Point3F(), 1630 SetLayerPropertiesForTesting(render_surface1, identity_matrix, gfx::Point3F(),
1631 gfx::PointF(), gfx::Size(10, 10), true, false); 1631 gfx::PointF(), gfx::Size(10, 10), true, false);
1632 SetLayerPropertiesForTesting(child, identity_matrix, gfx::Point3F(), 1632 SetLayerPropertiesForTesting(child, identity_matrix, gfx::Point3F(),
1633 gfx::PointF(), gfx::Size(10, 10), true, false); 1633 gfx::PointF(), gfx::Size(10, 10), true, false);
(...skipping 15 matching lines...) Expand all
1649 ExecuteCalculateDrawPropertiesWithPropertyTrees(parent); 1649 ExecuteCalculateDrawPropertiesWithPropertyTrees(parent);
1650 EXPECT_TRUE(parent->has_render_surface()); 1650 EXPECT_TRUE(parent->has_render_surface());
1651 EXPECT_FALSE(render_surface1->has_render_surface()); 1651 EXPECT_FALSE(render_surface1->has_render_surface());
1652 } 1652 }
1653 } 1653 }
1654 1654
1655 TEST_F(LayerTreeHostCommonTest, RenderSurfacesFlattenScreenSpaceTransform) { 1655 TEST_F(LayerTreeHostCommonTest, RenderSurfacesFlattenScreenSpaceTransform) {
1656 // Render surfaces act as a flattening point for their subtree, so should 1656 // Render surfaces act as a flattening point for their subtree, so should
1657 // always flatten the target-to-screen space transform seen by descendants. 1657 // always flatten the target-to-screen space transform seen by descendants.
1658 1658
1659 LayerImpl* root = root_layer(); 1659 LayerImpl* root = root_layer_for_testing();
1660 LayerImpl* parent = AddChild<LayerImpl>(root); 1660 LayerImpl* parent = AddChild<LayerImpl>(root);
1661 LayerImpl* child = AddChild<LayerImpl>(parent); 1661 LayerImpl* child = AddChild<LayerImpl>(parent);
1662 LayerImpl* grand_child = AddChild<LayerImpl>(child); 1662 LayerImpl* grand_child = AddChild<LayerImpl>(child);
1663 1663
1664 child->SetDrawsContent(true); 1664 child->SetDrawsContent(true);
1665 grand_child->SetDrawsContent(true); 1665 grand_child->SetDrawsContent(true);
1666 1666
1667 gfx::Transform rotation_about_y_axis; 1667 gfx::Transform rotation_about_y_axis;
1668 rotation_about_y_axis.RotateAboutYAxis(30.0); 1668 rotation_about_y_axis.RotateAboutYAxis(30.0);
1669 // Make |parent| have a render surface. 1669 // Make |parent| have a render surface.
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
1725 // that have something to draw. 1725 // that have something to draw.
1726 // - parent is a large container layer. 1726 // - parent is a large container layer.
1727 // - child has masksToBounds=true to cause clipping. 1727 // - child has masksToBounds=true to cause clipping.
1728 // - grand_child is positioned outside of the child's bounds 1728 // - grand_child is positioned outside of the child's bounds
1729 // - great_grand_child is also kept outside child's bounds. 1729 // - great_grand_child is also kept outside child's bounds.
1730 // 1730 //
1731 // In this configuration, grand_child and great_grand_child are completely 1731 // In this configuration, grand_child and great_grand_child are completely
1732 // outside the clip rect, and they should never get scheduled on the list of 1732 // outside the clip rect, and they should never get scheduled on the list of
1733 // render surfaces. 1733 // render surfaces.
1734 1734
1735 LayerImpl* parent = root_layer(); 1735 LayerImpl* parent = root_layer_for_testing();
1736 LayerImpl* child = AddChildToRoot<LayerImpl>(); 1736 LayerImpl* child = AddChildToRoot<LayerImpl>();
1737 LayerImpl* grand_child = AddChild<LayerImpl>(child); 1737 LayerImpl* grand_child = AddChild<LayerImpl>(child);
1738 LayerImpl* great_grand_child = AddChild<LayerImpl>(grand_child); 1738 LayerImpl* great_grand_child = AddChild<LayerImpl>(grand_child);
1739 1739
1740 // leaf_node1 ensures that parent and child are kept on the 1740 // leaf_node1 ensures that parent and child are kept on the
1741 // render_surface_layer_list, even though grand_child and great_grand_child 1741 // render_surface_layer_list, even though grand_child and great_grand_child
1742 // should be clipped. 1742 // should be clipped.
1743 LayerImpl* leaf_node1 = AddChild<LayerImpl>(child); 1743 LayerImpl* leaf_node1 = AddChild<LayerImpl>(child);
1744 leaf_node1->SetDrawsContent(true); 1744 leaf_node1->SetDrawsContent(true);
1745 LayerImpl* leaf_node2 = AddChild<LayerImpl>(great_grand_child); 1745 LayerImpl* leaf_node2 = AddChild<LayerImpl>(great_grand_child);
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
1786 // - parent is a container layer that masksToBounds=true to cause clipping. 1786 // - parent is a container layer that masksToBounds=true to cause clipping.
1787 // - child is a render surface, which has a clip rect set to the bounds of 1787 // - child is a render surface, which has a clip rect set to the bounds of
1788 // the parent. 1788 // the parent.
1789 // - grand_child is a render surface, and the only visible content in child. 1789 // - grand_child is a render surface, and the only visible content in child.
1790 // It is positioned outside of the clip rect from parent. 1790 // It is positioned outside of the clip rect from parent.
1791 1791
1792 // In this configuration, grand_child should be outside the clipped 1792 // In this configuration, grand_child should be outside the clipped
1793 // content rect of the child, making grand_child not appear in the 1793 // content rect of the child, making grand_child not appear in the
1794 // render_surface_layer_list. 1794 // render_surface_layer_list.
1795 1795
1796 LayerImpl* parent = root_layer(); 1796 LayerImpl* parent = root_layer_for_testing();
1797 LayerImpl* child = AddChildToRoot<LayerImpl>(); 1797 LayerImpl* child = AddChildToRoot<LayerImpl>();
1798 LayerImpl* grand_child = AddChild<LayerImpl>(child); 1798 LayerImpl* grand_child = AddChild<LayerImpl>(child);
1799 LayerImpl* leaf_node = AddChild<LayerImpl>(grand_child); 1799 LayerImpl* leaf_node = AddChild<LayerImpl>(grand_child);
1800 leaf_node->SetDrawsContent(true); 1800 leaf_node->SetDrawsContent(true);
1801 1801
1802 const gfx::Transform identity_matrix; 1802 const gfx::Transform identity_matrix;
1803 1803
1804 SetLayerPropertiesForTesting(parent, identity_matrix, gfx::Point3F(), 1804 SetLayerPropertiesForTesting(parent, identity_matrix, gfx::Point3F(),
1805 gfx::PointF(), gfx::Size(100, 100), true, false, 1805 gfx::PointF(), gfx::Size(100, 100), true, false,
1806 true); 1806 true);
(...skipping 27 matching lines...) Expand all
1834 // - a surface is clipped by an ancestor that contributes to the same 1834 // - a surface is clipped by an ancestor that contributes to the same
1835 // render target. 1835 // render target.
1836 // 1836 //
1837 // In particular, for a layer that owns a render surface: 1837 // In particular, for a layer that owns a render surface:
1838 // - the render surface inherits any clip from ancestors, and does NOT 1838 // - the render surface inherits any clip from ancestors, and does NOT
1839 // pass that clipped status to the layer itself. 1839 // pass that clipped status to the layer itself.
1840 // - but if the layer itself masks to bounds, it is considered clipped 1840 // - but if the layer itself masks to bounds, it is considered clipped
1841 // and propagates the clip to the subtree. 1841 // and propagates the clip to the subtree.
1842 1842
1843 const gfx::Transform identity_matrix; 1843 const gfx::Transform identity_matrix;
1844 LayerImpl* root = root_layer(); 1844 LayerImpl* root = root_layer_for_testing();
1845 LayerImpl* parent = AddChild<LayerImpl>(root); 1845 LayerImpl* parent = AddChild<LayerImpl>(root);
1846 parent->SetDrawsContent(true); 1846 parent->SetDrawsContent(true);
1847 LayerImpl* child1 = AddChild<LayerImpl>(parent); 1847 LayerImpl* child1 = AddChild<LayerImpl>(parent);
1848 child1->SetDrawsContent(true); 1848 child1->SetDrawsContent(true);
1849 LayerImpl* child2 = AddChild<LayerImpl>(parent); 1849 LayerImpl* child2 = AddChild<LayerImpl>(parent);
1850 child2->SetDrawsContent(true); 1850 child2->SetDrawsContent(true);
1851 LayerImpl* grand_child = AddChild<LayerImpl>(child1); 1851 LayerImpl* grand_child = AddChild<LayerImpl>(child1);
1852 grand_child->SetDrawsContent(true); 1852 grand_child->SetDrawsContent(true);
1853 LayerImpl* leaf_node1 = AddChild<LayerImpl>(grand_child); 1853 LayerImpl* leaf_node1 = AddChild<LayerImpl>(grand_child);
1854 leaf_node1->SetDrawsContent(true); 1854 leaf_node1->SetDrawsContent(true);
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
1934 EXPECT_TRUE(child2->is_clipped()); 1934 EXPECT_TRUE(child2->is_clipped());
1935 EXPECT_FALSE(child2->render_surface()->is_clipped()); 1935 EXPECT_FALSE(child2->render_surface()->is_clipped());
1936 EXPECT_FALSE(grand_child->is_clipped()); 1936 EXPECT_FALSE(grand_child->is_clipped());
1937 EXPECT_FALSE(leaf_node1->is_clipped()); 1937 EXPECT_FALSE(leaf_node1->is_clipped());
1938 EXPECT_TRUE(leaf_node2->is_clipped()); 1938 EXPECT_TRUE(leaf_node2->is_clipped());
1939 } 1939 }
1940 1940
1941 TEST_F(LayerTreeHostCommonTest, UpdateClipRectCorrectly) { 1941 TEST_F(LayerTreeHostCommonTest, UpdateClipRectCorrectly) {
1942 // Tests that when as long as layer is clipped, it's clip rect is set to 1942 // Tests that when as long as layer is clipped, it's clip rect is set to
1943 // correct value. 1943 // correct value.
1944 LayerImpl* root = root_layer(); 1944 LayerImpl* root = root_layer_for_testing();
1945 LayerImpl* parent = AddChild<LayerImpl>(root); 1945 LayerImpl* parent = AddChild<LayerImpl>(root);
1946 LayerImpl* child = AddChild<LayerImpl>(parent); 1946 LayerImpl* child = AddChild<LayerImpl>(parent);
1947 1947
1948 root->SetDrawsContent(true); 1948 root->SetDrawsContent(true);
1949 parent->SetDrawsContent(true); 1949 parent->SetDrawsContent(true);
1950 child->SetDrawsContent(true); 1950 child->SetDrawsContent(true);
1951 1951
1952 const gfx::Transform identity_matrix; 1952 const gfx::Transform identity_matrix;
1953 1953
1954 SetLayerPropertiesForTesting(root, identity_matrix, gfx::Point3F(), 1954 SetLayerPropertiesForTesting(root, identity_matrix, gfx::Point3F(),
(...skipping 24 matching lines...) Expand all
1979 EXPECT_TRUE(parent->is_clipped()); 1979 EXPECT_TRUE(parent->is_clipped());
1980 EXPECT_TRUE(child->is_clipped()); 1980 EXPECT_TRUE(child->is_clipped());
1981 EXPECT_EQ(gfx::Rect(), child->clip_rect()); 1981 EXPECT_EQ(gfx::Rect(), child->clip_rect());
1982 } 1982 }
1983 1983
1984 TEST_F(LayerTreeHostCommonTest, IsClippedWhenCannotRenderToSeparateSurface) { 1984 TEST_F(LayerTreeHostCommonTest, IsClippedWhenCannotRenderToSeparateSurface) {
1985 // Tests that when separate surfaces are disabled, is_clipped is true exactly 1985 // Tests that when separate surfaces are disabled, is_clipped is true exactly
1986 // when a layer or its ancestor has a clip; in particular, if a layer 1986 // when a layer or its ancestor has a clip; in particular, if a layer
1987 // is_clipped, so is its entire subtree (since there are no render surfaces 1987 // is_clipped, so is its entire subtree (since there are no render surfaces
1988 // that can reset is_clipped). 1988 // that can reset is_clipped).
1989 LayerImpl* root = root_layer(); 1989 LayerImpl* root = root_layer_for_testing();
1990 LayerImpl* parent = AddChild<LayerImpl>(root); 1990 LayerImpl* parent = AddChild<LayerImpl>(root);
1991 LayerImpl* child1 = AddChild<LayerImpl>(parent); 1991 LayerImpl* child1 = AddChild<LayerImpl>(parent);
1992 LayerImpl* child2 = AddChild<LayerImpl>(parent); 1992 LayerImpl* child2 = AddChild<LayerImpl>(parent);
1993 LayerImpl* grand_child = AddChild<LayerImpl>(child1); 1993 LayerImpl* grand_child = AddChild<LayerImpl>(child1);
1994 LayerImpl* leaf_node1 = AddChild<LayerImpl>(grand_child); 1994 LayerImpl* leaf_node1 = AddChild<LayerImpl>(grand_child);
1995 LayerImpl* leaf_node2 = AddChild<LayerImpl>(child2); 1995 LayerImpl* leaf_node2 = AddChild<LayerImpl>(child2);
1996 1996
1997 root->SetDrawsContent(true); 1997 root->SetDrawsContent(true);
1998 parent->SetDrawsContent(true); 1998 parent->SetDrawsContent(true);
1999 child1->SetDrawsContent(true); 1999 child1->SetDrawsContent(true);
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
2168 // be the layer rect expressed in target space. 2168 // be the layer rect expressed in target space.
2169 // grand_child2 - partially clipped but NOT masksToBounds; the clip rect 2169 // grand_child2 - partially clipped but NOT masksToBounds; the clip rect
2170 // will be the intersection of layer bounds and the mask region. 2170 // will be the intersection of layer bounds and the mask region.
2171 // grand_child3 - partially clipped and masksToBounds; the 2171 // grand_child3 - partially clipped and masksToBounds; the
2172 // DrawableContentRect will still be the intersection of layer bounds and 2172 // DrawableContentRect will still be the intersection of layer bounds and
2173 // the mask region. 2173 // the mask region.
2174 // grand_child4 - outside parent's clip rect; the DrawableContentRect should 2174 // grand_child4 - outside parent's clip rect; the DrawableContentRect should
2175 // be empty. 2175 // be empty.
2176 2176
2177 const gfx::Transform identity_matrix; 2177 const gfx::Transform identity_matrix;
2178 LayerImpl* parent = root_layer(); 2178 LayerImpl* parent = root_layer_for_testing();
2179 LayerImpl* child = AddChild<LayerImpl>(parent); 2179 LayerImpl* child = AddChild<LayerImpl>(parent);
2180 LayerImpl* grand_child1 = AddChild<LayerImpl>(child); 2180 LayerImpl* grand_child1 = AddChild<LayerImpl>(child);
2181 grand_child1->SetDrawsContent(true); 2181 grand_child1->SetDrawsContent(true);
2182 LayerImpl* grand_child2 = AddChild<LayerImpl>(child); 2182 LayerImpl* grand_child2 = AddChild<LayerImpl>(child);
2183 grand_child2->SetDrawsContent(true); 2183 grand_child2->SetDrawsContent(true);
2184 LayerImpl* grand_child3 = AddChild<LayerImpl>(child); 2184 LayerImpl* grand_child3 = AddChild<LayerImpl>(child);
2185 grand_child3->SetDrawsContent(true); 2185 grand_child3->SetDrawsContent(true);
2186 LayerImpl* grand_child4 = AddChild<LayerImpl>(child); 2186 LayerImpl* grand_child4 = AddChild<LayerImpl>(child);
2187 grand_child4->SetDrawsContent(true); 2187 grand_child4->SetDrawsContent(true);
2188 2188
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
2220 } 2220 }
2221 2221
2222 TEST_F(LayerTreeHostCommonTest, ClipRectIsPropagatedCorrectlyToSurfaces) { 2222 TEST_F(LayerTreeHostCommonTest, ClipRectIsPropagatedCorrectlyToSurfaces) {
2223 // Verify that render surfaces (and their layers) get the appropriate 2223 // Verify that render surfaces (and their layers) get the appropriate
2224 // clip rects when their parent masksToBounds is true. 2224 // clip rects when their parent masksToBounds is true.
2225 // 2225 //
2226 // Layers that own render surfaces (at least for now) do not inherit any 2226 // Layers that own render surfaces (at least for now) do not inherit any
2227 // clipping; instead the surface will enforce the clip for the entire subtree. 2227 // clipping; instead the surface will enforce the clip for the entire subtree.
2228 // They may still have a clip rect of their own layer bounds, however, if 2228 // They may still have a clip rect of their own layer bounds, however, if
2229 // masksToBounds was true. 2229 // masksToBounds was true.
2230 LayerImpl* parent = root_layer(); 2230 LayerImpl* parent = root_layer_for_testing();
2231 LayerImpl* child = AddChildToRoot<LayerImpl>(); 2231 LayerImpl* child = AddChildToRoot<LayerImpl>();
2232 LayerImpl* grand_child1 = AddChild<LayerImpl>(child); 2232 LayerImpl* grand_child1 = AddChild<LayerImpl>(child);
2233 LayerImpl* grand_child2 = AddChild<LayerImpl>(child); 2233 LayerImpl* grand_child2 = AddChild<LayerImpl>(child);
2234 LayerImpl* grand_child3 = AddChild<LayerImpl>(child); 2234 LayerImpl* grand_child3 = AddChild<LayerImpl>(child);
2235 LayerImpl* grand_child4 = AddChild<LayerImpl>(child); 2235 LayerImpl* grand_child4 = AddChild<LayerImpl>(child);
2236 // the leaf nodes ensure that these grand_children become render surfaces for 2236 // the leaf nodes ensure that these grand_children become render surfaces for
2237 // this test. 2237 // this test.
2238 LayerImpl* leaf_node1 = AddChild<LayerImpl>(grand_child1); 2238 LayerImpl* leaf_node1 = AddChild<LayerImpl>(grand_child1);
2239 leaf_node1->SetDrawsContent(true); 2239 leaf_node1->SetDrawsContent(true);
2240 LayerImpl* leaf_node2 = AddChild<LayerImpl>(grand_child2); 2240 LayerImpl* leaf_node2 = AddChild<LayerImpl>(grand_child2);
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
2302 grand_child2->render_surface()->clip_rect()); 2302 grand_child2->render_surface()->clip_rect());
2303 EXPECT_EQ(gfx::Rect(0, 0, 20, 20), 2303 EXPECT_EQ(gfx::Rect(0, 0, 20, 20),
2304 grand_child3->render_surface()->clip_rect()); 2304 grand_child3->render_surface()->clip_rect());
2305 } 2305 }
2306 2306
2307 TEST_F(LayerTreeHostCommonTest, ClipRectWhenCannotRenderToSeparateSurface) { 2307 TEST_F(LayerTreeHostCommonTest, ClipRectWhenCannotRenderToSeparateSurface) {
2308 // Tests that when separate surfaces are disabled, a layer's clip_rect is the 2308 // Tests that when separate surfaces are disabled, a layer's clip_rect is the
2309 // intersection of all ancestor clips in screen space; in particular, if a 2309 // intersection of all ancestor clips in screen space; in particular, if a
2310 // layer masks to bounds, it contributes to the clip_rect of all layers in its 2310 // layer masks to bounds, it contributes to the clip_rect of all layers in its
2311 // subtree (since there are no render surfaces that can reset the clip_rect). 2311 // subtree (since there are no render surfaces that can reset the clip_rect).
2312 LayerImpl* root = root_layer(); 2312 LayerImpl* root = root_layer_for_testing();
2313 LayerImpl* parent = AddChild<LayerImpl>(root); 2313 LayerImpl* parent = AddChild<LayerImpl>(root);
2314 LayerImpl* child1 = AddChild<LayerImpl>(parent); 2314 LayerImpl* child1 = AddChild<LayerImpl>(parent);
2315 LayerImpl* child2 = AddChild<LayerImpl>(parent); 2315 LayerImpl* child2 = AddChild<LayerImpl>(parent);
2316 LayerImpl* grand_child = AddChild<LayerImpl>(child1); 2316 LayerImpl* grand_child = AddChild<LayerImpl>(child1);
2317 LayerImpl* leaf_node1 = AddChild<LayerImpl>(grand_child); 2317 LayerImpl* leaf_node1 = AddChild<LayerImpl>(grand_child);
2318 LayerImpl* leaf_node2 = AddChild<LayerImpl>(child2); 2318 LayerImpl* leaf_node2 = AddChild<LayerImpl>(child2);
2319 2319
2320 root->SetDrawsContent(true); 2320 root->SetDrawsContent(true);
2321 parent->SetDrawsContent(true); 2321 parent->SetDrawsContent(true);
2322 child1->SetDrawsContent(true); 2322 child1->SetDrawsContent(true);
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
2482 EXPECT_EQ(gfx::Rect(100, 100), root->render_surface()->clip_rect()); 2482 EXPECT_EQ(gfx::Rect(100, 100), root->render_surface()->clip_rect());
2483 EXPECT_EQ(gfx::Rect(2, 2, 400, 400), parent->clip_rect()); 2483 EXPECT_EQ(gfx::Rect(2, 2, 400, 400), parent->clip_rect());
2484 EXPECT_EQ(gfx::Rect(6, 6, 396, 396), child1->clip_rect()); 2484 EXPECT_EQ(gfx::Rect(6, 6, 396, 396), child1->clip_rect());
2485 EXPECT_EQ(gfx::Rect(2, 2, 400, 400), child2->clip_rect()); 2485 EXPECT_EQ(gfx::Rect(2, 2, 400, 400), child2->clip_rect());
2486 EXPECT_EQ(gfx::Rect(6, 6, 396, 396), grand_child->clip_rect()); 2486 EXPECT_EQ(gfx::Rect(6, 6, 396, 396), grand_child->clip_rect());
2487 EXPECT_EQ(gfx::Rect(6, 6, 396, 396), leaf_node1->clip_rect()); 2487 EXPECT_EQ(gfx::Rect(6, 6, 396, 396), leaf_node1->clip_rect());
2488 EXPECT_EQ(gfx::Rect(2, 2, 400, 400), leaf_node2->clip_rect()); 2488 EXPECT_EQ(gfx::Rect(2, 2, 400, 400), leaf_node2->clip_rect());
2489 } 2489 }
2490 2490
2491 TEST_F(LayerTreeHostCommonTest, HitTestingWhenSurfacesDisabled) { 2491 TEST_F(LayerTreeHostCommonTest, HitTestingWhenSurfacesDisabled) {
2492 LayerImpl* root = root_layer(); 2492 LayerImpl* root = root_layer_for_testing();
2493 LayerImpl* parent = AddChild<LayerImpl>(root); 2493 LayerImpl* parent = AddChild<LayerImpl>(root);
2494 LayerImpl* child = AddChild<LayerImpl>(parent); 2494 LayerImpl* child = AddChild<LayerImpl>(parent);
2495 LayerImpl* grand_child = AddChild<LayerImpl>(child); 2495 LayerImpl* grand_child = AddChild<LayerImpl>(child);
2496 LayerImpl* leaf_node = AddChild<LayerImpl>(grand_child); 2496 LayerImpl* leaf_node = AddChild<LayerImpl>(grand_child);
2497 2497
2498 root->SetDrawsContent(true); 2498 root->SetDrawsContent(true);
2499 parent->SetDrawsContent(true); 2499 parent->SetDrawsContent(true);
2500 child->SetDrawsContent(true); 2500 child->SetDrawsContent(true);
2501 grand_child->SetDrawsContent(true); 2501 grand_child->SetDrawsContent(true);
2502 leaf_node->SetDrawsContent(true); 2502 leaf_node->SetDrawsContent(true);
(...skipping 29 matching lines...) Expand all
2532 gfx::PointF test_point(90.f, 90.f); 2532 gfx::PointF test_point(90.f, 90.f);
2533 LayerImpl* result_layer = 2533 LayerImpl* result_layer =
2534 root->layer_tree_impl()->FindLayerThatIsHitByPoint(test_point); 2534 root->layer_tree_impl()->FindLayerThatIsHitByPoint(test_point);
2535 ASSERT_TRUE(result_layer); 2535 ASSERT_TRUE(result_layer);
2536 EXPECT_EQ(leaf_node, result_layer); 2536 EXPECT_EQ(leaf_node, result_layer);
2537 } 2537 }
2538 2538
2539 TEST_F(LayerTreeHostCommonTest, SurfacesDisabledAndReEnabled) { 2539 TEST_F(LayerTreeHostCommonTest, SurfacesDisabledAndReEnabled) {
2540 // Tests that draw properties are computed correctly when we disable and then 2540 // Tests that draw properties are computed correctly when we disable and then
2541 // re-enable separate surfaces. 2541 // re-enable separate surfaces.
2542 LayerImpl* root = root_layer(); 2542 LayerImpl* root = root_layer_for_testing();
2543 LayerImpl* parent = AddChild<LayerImpl>(root); 2543 LayerImpl* parent = AddChild<LayerImpl>(root);
2544 LayerImpl* child = AddChild<LayerImpl>(parent); 2544 LayerImpl* child = AddChild<LayerImpl>(parent);
2545 LayerImpl* grand_child = AddChild<LayerImpl>(child); 2545 LayerImpl* grand_child = AddChild<LayerImpl>(child);
2546 LayerImpl* leaf_node = AddChild<LayerImpl>(grand_child); 2546 LayerImpl* leaf_node = AddChild<LayerImpl>(grand_child);
2547 2547
2548 root->SetDrawsContent(true); 2548 root->SetDrawsContent(true);
2549 parent->SetDrawsContent(true); 2549 parent->SetDrawsContent(true);
2550 child->SetDrawsContent(true); 2550 child->SetDrawsContent(true);
2551 grand_child->SetDrawsContent(true); 2551 grand_child->SetDrawsContent(true);
2552 leaf_node->SetDrawsContent(true); 2552 leaf_node->SetDrawsContent(true);
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
2607 2607
2608 ExecuteCalculateDrawProperties(root); 2608 ExecuteCalculateDrawProperties(root);
2609 EXPECT_FALSE(leaf_node->is_clipped()); 2609 EXPECT_FALSE(leaf_node->is_clipped());
2610 EXPECT_TRUE(leaf_node->render_target()->is_clipped()); 2610 EXPECT_TRUE(leaf_node->render_target()->is_clipped());
2611 EXPECT_EQ(gfx::Rect(16, 16, 2000, 2000), leaf_node->drawable_content_rect()); 2611 EXPECT_EQ(gfx::Rect(16, 16, 2000, 2000), leaf_node->drawable_content_rect());
2612 EXPECT_EQ(expected_leaf_draw_transform_with_surfaces, 2612 EXPECT_EQ(expected_leaf_draw_transform_with_surfaces,
2613 leaf_node->DrawTransform()); 2613 leaf_node->DrawTransform());
2614 } 2614 }
2615 2615
2616 TEST_F(LayerTreeHostCommonTest, AnimationsForRenderSurfaceHierarchy) { 2616 TEST_F(LayerTreeHostCommonTest, AnimationsForRenderSurfaceHierarchy) {
2617 LayerImpl* parent = root_layer(); 2617 LayerImpl* parent = root_layer_for_testing();
2618 LayerImpl* render_surface1 = AddChildToRoot<LayerImpl>(); 2618 LayerImpl* render_surface1 = AddChildToRoot<LayerImpl>();
2619 LayerImpl* child_of_rs1 = AddChild<LayerImpl>(render_surface1); 2619 LayerImpl* child_of_rs1 = AddChild<LayerImpl>(render_surface1);
2620 LayerImpl* grand_child_of_rs1 = AddChild<LayerImpl>(child_of_rs1); 2620 LayerImpl* grand_child_of_rs1 = AddChild<LayerImpl>(child_of_rs1);
2621 LayerImpl* render_surface2 = AddChild<LayerImpl>(render_surface1); 2621 LayerImpl* render_surface2 = AddChild<LayerImpl>(render_surface1);
2622 LayerImpl* child_of_rs2 = AddChild<LayerImpl>(render_surface2); 2622 LayerImpl* child_of_rs2 = AddChild<LayerImpl>(render_surface2);
2623 LayerImpl* grand_child_of_rs2 = AddChild<LayerImpl>(child_of_rs2); 2623 LayerImpl* grand_child_of_rs2 = AddChild<LayerImpl>(child_of_rs2);
2624 LayerImpl* child_of_root = AddChildToRoot<LayerImpl>(); 2624 LayerImpl* child_of_root = AddChildToRoot<LayerImpl>();
2625 LayerImpl* grand_child_of_root = AddChild<LayerImpl>(child_of_root); 2625 LayerImpl* grand_child_of_root = AddChild<LayerImpl>(child_of_root);
2626 2626
2627 parent->SetDrawsContent(true); 2627 parent->SetDrawsContent(true);
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
2747 4.0, grand_child_of_rs1->ScreenSpaceTransform().matrix().get(1, 3)); 2747 4.0, grand_child_of_rs1->ScreenSpaceTransform().matrix().get(1, 3));
2748 2748
2749 EXPECT_FLOAT_EQ(3.0, 2749 EXPECT_FLOAT_EQ(3.0,
2750 render_surface2->ScreenSpaceTransform().matrix().get(1, 3)); 2750 render_surface2->ScreenSpaceTransform().matrix().get(1, 3));
2751 EXPECT_FLOAT_EQ(4.0, child_of_rs2->ScreenSpaceTransform().matrix().get(1, 3)); 2751 EXPECT_FLOAT_EQ(4.0, child_of_rs2->ScreenSpaceTransform().matrix().get(1, 3));
2752 EXPECT_FLOAT_EQ( 2752 EXPECT_FLOAT_EQ(
2753 5.0, grand_child_of_rs2->ScreenSpaceTransform().matrix().get(1, 3)); 2753 5.0, grand_child_of_rs2->ScreenSpaceTransform().matrix().get(1, 3));
2754 } 2754 }
2755 2755
2756 TEST_F(LayerTreeHostCommonTest, LargeTransforms) { 2756 TEST_F(LayerTreeHostCommonTest, LargeTransforms) {
2757 LayerImpl* parent = root_layer(); 2757 LayerImpl* parent = root_layer_for_testing();
2758 LayerImpl* child = AddChildToRoot<LayerImpl>(); 2758 LayerImpl* child = AddChildToRoot<LayerImpl>();
2759 LayerImpl* grand_child = AddChild<LayerImpl>(child); 2759 LayerImpl* grand_child = AddChild<LayerImpl>(child);
2760 2760
2761 grand_child->SetDrawsContent(true); 2761 grand_child->SetDrawsContent(true);
2762 2762
2763 gfx::Transform large_transform; 2763 gfx::Transform large_transform;
2764 large_transform.Scale(SkDoubleToMScalar(1e37), SkDoubleToMScalar(1e37)); 2764 large_transform.Scale(SkDoubleToMScalar(1e37), SkDoubleToMScalar(1e37));
2765 2765
2766 gfx::Transform identity; 2766 gfx::Transform identity;
2767 2767
2768 SetLayerPropertiesForTesting(parent, identity, gfx::Point3F(), gfx::PointF(), 2768 SetLayerPropertiesForTesting(parent, identity, gfx::Point3F(), gfx::PointF(),
2769 gfx::Size(10, 10), true, false, true); 2769 gfx::Size(10, 10), true, false, true);
2770 SetLayerPropertiesForTesting(child, large_transform, gfx::Point3F(), 2770 SetLayerPropertiesForTesting(child, large_transform, gfx::Point3F(),
2771 gfx::PointF(), gfx::Size(10, 10), true, false, 2771 gfx::PointF(), gfx::Size(10, 10), true, false,
2772 false); 2772 false);
2773 SetLayerPropertiesForTesting(grand_child, large_transform, gfx::Point3F(), 2773 SetLayerPropertiesForTesting(grand_child, large_transform, gfx::Point3F(),
2774 gfx::PointF(), gfx::Size(10, 10), true, false, 2774 gfx::PointF(), gfx::Size(10, 10), true, false,
2775 false); 2775 false);
2776 ExecuteCalculateDrawProperties(parent); 2776 ExecuteCalculateDrawProperties(parent);
2777 2777
2778 EXPECT_EQ(gfx::Rect(), grand_child->visible_layer_rect()); 2778 EXPECT_EQ(gfx::Rect(), grand_child->visible_layer_rect());
2779 } 2779 }
2780 2780
2781 TEST_F(LayerTreeHostCommonTest, 2781 TEST_F(LayerTreeHostCommonTest,
2782 ScreenSpaceTransformIsAnimatingWithDelayedAnimation) { 2782 ScreenSpaceTransformIsAnimatingWithDelayedAnimation) {
2783 LayerImpl* parent = root_layer(); 2783 LayerImpl* parent = root_layer_for_testing();
2784 LayerImpl* child = AddChild<LayerImpl>(parent); 2784 LayerImpl* child = AddChild<LayerImpl>(parent);
2785 LayerImpl* grand_child = AddChild<LayerImpl>(child); 2785 LayerImpl* grand_child = AddChild<LayerImpl>(child);
2786 LayerImpl* great_grand_child = AddChild<LayerImpl>(grand_child); 2786 LayerImpl* great_grand_child = AddChild<LayerImpl>(grand_child);
2787 2787
2788 parent->SetDrawsContent(true); 2788 parent->SetDrawsContent(true);
2789 child->SetDrawsContent(true); 2789 child->SetDrawsContent(true);
2790 grand_child->SetDrawsContent(true); 2790 grand_child->SetDrawsContent(true);
2791 great_grand_child->SetDrawsContent(true); 2791 great_grand_child->SetDrawsContent(true);
2792 2792
2793 gfx::Transform identity; 2793 gfx::Transform identity;
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after
3126 gfx::Rect expected_drawable_content_rect = target_surface_rect; 3126 gfx::Rect expected_drawable_content_rect = target_surface_rect;
3127 LayerImpl* drawing_layer = TestVisibleRectAndDrawableContentRect( 3127 LayerImpl* drawing_layer = TestVisibleRectAndDrawableContentRect(
3128 target_surface_rect, layer_to_surface_transform, layer_content_rect); 3128 target_surface_rect, layer_to_surface_transform, layer_content_rect);
3129 EXPECT_EQ(expected_visible_layer_rect, drawing_layer->visible_layer_rect()); 3129 EXPECT_EQ(expected_visible_layer_rect, drawing_layer->visible_layer_rect());
3130 EXPECT_EQ(expected_drawable_content_rect, 3130 EXPECT_EQ(expected_drawable_content_rect,
3131 drawing_layer->drawable_content_rect()); 3131 drawing_layer->drawable_content_rect());
3132 } 3132 }
3133 3133
3134 TEST_F(LayerTreeHostCommonTest, 3134 TEST_F(LayerTreeHostCommonTest,
3135 VisibleRectsForPositionedRootLayerClippedByViewport) { 3135 VisibleRectsForPositionedRootLayerClippedByViewport) {
3136 LayerImpl* root = root_layer(); 3136 LayerImpl* root = root_layer_for_testing();
3137 root->SetDrawsContent(true); 3137 root->SetDrawsContent(true);
3138 3138
3139 gfx::Transform identity_matrix; 3139 gfx::Transform identity_matrix;
3140 // Root layer is positioned at (60, 70). The default device viewport size 3140 // Root layer is positioned at (60, 70). The default device viewport size
3141 // is (0, 0, 100x100) in target space. So the root layer's visible rect 3141 // is (0, 0, 100x100) in target space. So the root layer's visible rect
3142 // will be clipped by the viewport to be (0, 0, 40x30) in layer's space. 3142 // will be clipped by the viewport to be (0, 0, 40x30) in layer's space.
3143 SetLayerPropertiesForTesting(root, identity_matrix, gfx::Point3F(), 3143 SetLayerPropertiesForTesting(root, identity_matrix, gfx::Point3F(),
3144 gfx::PointF(60, 70), gfx::Size(100, 100), true, 3144 gfx::PointF(60, 70), gfx::Size(100, 100), true,
3145 false, true); 3145 false, true);
3146 ExecuteCalculateDrawProperties(root); 3146 ExecuteCalculateDrawProperties(root);
3147 3147
3148 EXPECT_EQ(gfx::RectF(100.f, 100.f), 3148 EXPECT_EQ(gfx::RectF(100.f, 100.f),
3149 root->render_surface()->DrawableContentRect()); 3149 root->render_surface()->DrawableContentRect());
3150 // In target space, not clipped. 3150 // In target space, not clipped.
3151 EXPECT_EQ(gfx::Rect(60, 70, 100, 100), root->drawable_content_rect()); 3151 EXPECT_EQ(gfx::Rect(60, 70, 100, 100), root->drawable_content_rect());
3152 // In layer space, clipped. 3152 // In layer space, clipped.
3153 EXPECT_EQ(gfx::Rect(40, 30), root->visible_layer_rect()); 3153 EXPECT_EQ(gfx::Rect(40, 30), root->visible_layer_rect());
3154 } 3154 }
3155 3155
3156 TEST_F(LayerTreeHostCommonTest, DrawableAndVisibleContentRectsForSimpleLayers) { 3156 TEST_F(LayerTreeHostCommonTest, DrawableAndVisibleContentRectsForSimpleLayers) {
3157 LayerImpl* root = root_layer(); 3157 LayerImpl* root = root_layer_for_testing();
3158 LayerImpl* child1_layer = AddChildToRoot<LayerImpl>(); 3158 LayerImpl* child1_layer = AddChildToRoot<LayerImpl>();
3159 child1_layer->SetDrawsContent(true); 3159 child1_layer->SetDrawsContent(true);
3160 LayerImpl* child2_layer = AddChildToRoot<LayerImpl>(); 3160 LayerImpl* child2_layer = AddChildToRoot<LayerImpl>();
3161 child2_layer->SetDrawsContent(true); 3161 child2_layer->SetDrawsContent(true);
3162 LayerImpl* child3_layer = AddChildToRoot<LayerImpl>(); 3162 LayerImpl* child3_layer = AddChildToRoot<LayerImpl>();
3163 child3_layer->SetDrawsContent(true); 3163 child3_layer->SetDrawsContent(true);
3164 3164
3165 gfx::Transform identity_matrix; 3165 gfx::Transform identity_matrix;
3166 SetLayerPropertiesForTesting(root, identity_matrix, gfx::Point3F(), 3166 SetLayerPropertiesForTesting(root, identity_matrix, gfx::Point3F(),
3167 gfx::PointF(), gfx::Size(100, 100), true, false, 3167 gfx::PointF(), gfx::Size(100, 100), true, false,
(...skipping 22 matching lines...) Expand all
3190 EXPECT_TRUE(child3_layer->visible_layer_rect().IsEmpty()); 3190 EXPECT_TRUE(child3_layer->visible_layer_rect().IsEmpty());
3191 3191
3192 // layer drawable_content_rects are not clipped. 3192 // layer drawable_content_rects are not clipped.
3193 EXPECT_EQ(gfx::Rect(0, 0, 50, 50), child1_layer->drawable_content_rect()); 3193 EXPECT_EQ(gfx::Rect(0, 0, 50, 50), child1_layer->drawable_content_rect());
3194 EXPECT_EQ(gfx::Rect(75, 75, 50, 50), child2_layer->drawable_content_rect()); 3194 EXPECT_EQ(gfx::Rect(75, 75, 50, 50), child2_layer->drawable_content_rect());
3195 EXPECT_EQ(gfx::Rect(125, 125, 50, 50), child3_layer->drawable_content_rect()); 3195 EXPECT_EQ(gfx::Rect(125, 125, 50, 50), child3_layer->drawable_content_rect());
3196 } 3196 }
3197 3197
3198 TEST_F(LayerTreeHostCommonTest, 3198 TEST_F(LayerTreeHostCommonTest,
3199 DrawableAndVisibleContentRectsForLayersClippedByLayer) { 3199 DrawableAndVisibleContentRectsForLayersClippedByLayer) {
3200 LayerImpl* root = root_layer(); 3200 LayerImpl* root = root_layer_for_testing();
3201 LayerImpl* child = AddChildToRoot<LayerImpl>(); 3201 LayerImpl* child = AddChildToRoot<LayerImpl>();
3202 LayerImpl* grand_child1 = AddChild<LayerImpl>(child); 3202 LayerImpl* grand_child1 = AddChild<LayerImpl>(child);
3203 grand_child1->SetDrawsContent(true); 3203 grand_child1->SetDrawsContent(true);
3204 LayerImpl* grand_child2 = AddChild<LayerImpl>(child); 3204 LayerImpl* grand_child2 = AddChild<LayerImpl>(child);
3205 grand_child2->SetDrawsContent(true); 3205 grand_child2->SetDrawsContent(true);
3206 LayerImpl* grand_child3 = AddChild<LayerImpl>(child); 3206 LayerImpl* grand_child3 = AddChild<LayerImpl>(child);
3207 grand_child3->SetDrawsContent(true); 3207 grand_child3->SetDrawsContent(true);
3208 3208
3209 gfx::Transform identity_matrix; 3209 gfx::Transform identity_matrix;
3210 SetLayerPropertiesForTesting(root, identity_matrix, gfx::Point3F(), 3210 SetLayerPropertiesForTesting(root, identity_matrix, gfx::Point3F(),
(...skipping 27 matching lines...) Expand all
3238 EXPECT_EQ(gfx::Rect(0, 0, 25, 25), grand_child2->visible_layer_rect()); 3238 EXPECT_EQ(gfx::Rect(0, 0, 25, 25), grand_child2->visible_layer_rect());
3239 EXPECT_TRUE(grand_child3->visible_layer_rect().IsEmpty()); 3239 EXPECT_TRUE(grand_child3->visible_layer_rect().IsEmpty());
3240 3240
3241 // All grandchild DrawableContentRects should also be clipped by child. 3241 // All grandchild DrawableContentRects should also be clipped by child.
3242 EXPECT_EQ(gfx::Rect(5, 5, 50, 50), grand_child1->drawable_content_rect()); 3242 EXPECT_EQ(gfx::Rect(5, 5, 50, 50), grand_child1->drawable_content_rect());
3243 EXPECT_EQ(gfx::Rect(75, 75, 25, 25), grand_child2->drawable_content_rect()); 3243 EXPECT_EQ(gfx::Rect(75, 75, 25, 25), grand_child2->drawable_content_rect());
3244 EXPECT_TRUE(grand_child3->drawable_content_rect().IsEmpty()); 3244 EXPECT_TRUE(grand_child3->drawable_content_rect().IsEmpty());
3245 } 3245 }
3246 3246
3247 TEST_F(LayerTreeHostCommonTest, VisibleContentRectWithClippingAndScaling) { 3247 TEST_F(LayerTreeHostCommonTest, VisibleContentRectWithClippingAndScaling) {
3248 LayerImpl* root = root_layer(); 3248 LayerImpl* root = root_layer_for_testing();
3249 LayerImpl* child = AddChild<LayerImpl>(root); 3249 LayerImpl* child = AddChild<LayerImpl>(root);
3250 LayerImpl* grand_child = AddChild<LayerImpl>(child); 3250 LayerImpl* grand_child = AddChild<LayerImpl>(child);
3251 3251
3252 gfx::Transform identity_matrix; 3252 gfx::Transform identity_matrix;
3253 gfx::Transform child_scale_matrix; 3253 gfx::Transform child_scale_matrix;
3254 child_scale_matrix.Scale(0.25f, 0.25f); 3254 child_scale_matrix.Scale(0.25f, 0.25f);
3255 gfx::Transform grand_child_scale_matrix; 3255 gfx::Transform grand_child_scale_matrix;
3256 grand_child_scale_matrix.Scale(0.246f, 0.246f); 3256 grand_child_scale_matrix.Scale(0.246f, 0.246f);
3257 SetLayerPropertiesForTesting(root, identity_matrix, gfx::Point3F(), 3257 SetLayerPropertiesForTesting(root, identity_matrix, gfx::Point3F(),
3258 gfx::PointF(), gfx::Size(100, 100), true, false, 3258 gfx::PointF(), gfx::Size(100, 100), true, false,
3259 true); 3259 true);
3260 SetLayerPropertiesForTesting(child, child_scale_matrix, gfx::Point3F(), 3260 SetLayerPropertiesForTesting(child, child_scale_matrix, gfx::Point3F(),
3261 gfx::PointF(), gfx::Size(10, 10), true, false, 3261 gfx::PointF(), gfx::Size(10, 10), true, false,
3262 false); 3262 false);
3263 SetLayerPropertiesForTesting(grand_child, grand_child_scale_matrix, 3263 SetLayerPropertiesForTesting(grand_child, grand_child_scale_matrix,
3264 gfx::Point3F(), gfx::PointF(), 3264 gfx::Point3F(), gfx::PointF(),
3265 gfx::Size(100, 100), true, false, false); 3265 gfx::Size(100, 100), true, false, false);
3266 3266
3267 child->SetMasksToBounds(true); 3267 child->SetMasksToBounds(true);
3268 grand_child->SetDrawsContent(true); 3268 grand_child->SetDrawsContent(true);
3269 ExecuteCalculateDrawProperties(root); 3269 ExecuteCalculateDrawProperties(root);
3270 3270
3271 // The visible rect is expanded to integer coordinates. 3271 // The visible rect is expanded to integer coordinates.
3272 EXPECT_EQ(gfx::Rect(41, 41), grand_child->visible_layer_rect()); 3272 EXPECT_EQ(gfx::Rect(41, 41), grand_child->visible_layer_rect());
3273 } 3273 }
3274 3274
3275 TEST_F(LayerTreeHostCommonTest, 3275 TEST_F(LayerTreeHostCommonTest,
3276 DrawableAndVisibleContentRectsForLayersInUnclippedRenderSurface) { 3276 DrawableAndVisibleContentRectsForLayersInUnclippedRenderSurface) {
3277 LayerImpl* root = root_layer(); 3277 LayerImpl* root = root_layer_for_testing();
3278 LayerImpl* render_surface = AddChildToRoot<LayerImpl>(); 3278 LayerImpl* render_surface = AddChildToRoot<LayerImpl>();
3279 LayerImpl* child1 = AddChild<LayerImpl>(render_surface); 3279 LayerImpl* child1 = AddChild<LayerImpl>(render_surface);
3280 child1->SetDrawsContent(true); 3280 child1->SetDrawsContent(true);
3281 LayerImpl* child2 = AddChild<LayerImpl>(render_surface); 3281 LayerImpl* child2 = AddChild<LayerImpl>(render_surface);
3282 child2->SetDrawsContent(true); 3282 child2->SetDrawsContent(true);
3283 LayerImpl* child3 = AddChild<LayerImpl>(render_surface); 3283 LayerImpl* child3 = AddChild<LayerImpl>(render_surface);
3284 child3->SetDrawsContent(true); 3284 child3->SetDrawsContent(true);
3285 3285
3286 gfx::Transform identity_matrix; 3286 gfx::Transform identity_matrix;
3287 SetLayerPropertiesForTesting(root, identity_matrix, gfx::Point3F(), 3287 SetLayerPropertiesForTesting(root, identity_matrix, gfx::Point3F(),
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
3321 EXPECT_EQ(gfx::Rect(0, 0, 50, 50), child2->visible_layer_rect()); 3321 EXPECT_EQ(gfx::Rect(0, 0, 50, 50), child2->visible_layer_rect());
3322 EXPECT_EQ(gfx::Rect(0, 0, 50, 50), child3->visible_layer_rect()); 3322 EXPECT_EQ(gfx::Rect(0, 0, 50, 50), child3->visible_layer_rect());
3323 3323
3324 EXPECT_EQ(gfx::Rect(5, 5, 50, 50), child1->drawable_content_rect()); 3324 EXPECT_EQ(gfx::Rect(5, 5, 50, 50), child1->drawable_content_rect());
3325 EXPECT_EQ(gfx::Rect(75, 75, 50, 50), child2->drawable_content_rect()); 3325 EXPECT_EQ(gfx::Rect(75, 75, 50, 50), child2->drawable_content_rect());
3326 EXPECT_EQ(gfx::Rect(125, 125, 50, 50), child3->drawable_content_rect()); 3326 EXPECT_EQ(gfx::Rect(125, 125, 50, 50), child3->drawable_content_rect());
3327 } 3327 }
3328 3328
3329 TEST_F(LayerTreeHostCommonTest, 3329 TEST_F(LayerTreeHostCommonTest,
3330 DrawableAndVisibleRectsWhenCannotRenderToSeparateSurface) { 3330 DrawableAndVisibleRectsWhenCannotRenderToSeparateSurface) {
3331 LayerImpl* root = root_layer(); 3331 LayerImpl* root = root_layer_for_testing();
3332 LayerImpl* parent = AddChild<LayerImpl>(root); 3332 LayerImpl* parent = AddChild<LayerImpl>(root);
3333 LayerImpl* child1 = AddChild<LayerImpl>(parent); 3333 LayerImpl* child1 = AddChild<LayerImpl>(parent);
3334 LayerImpl* child2 = AddChild<LayerImpl>(parent); 3334 LayerImpl* child2 = AddChild<LayerImpl>(parent);
3335 LayerImpl* grand_child1 = AddChild<LayerImpl>(child1); 3335 LayerImpl* grand_child1 = AddChild<LayerImpl>(child1);
3336 LayerImpl* grand_child2 = AddChild<LayerImpl>(child2); 3336 LayerImpl* grand_child2 = AddChild<LayerImpl>(child2);
3337 LayerImpl* leaf_node1 = AddChild<LayerImpl>(grand_child1); 3337 LayerImpl* leaf_node1 = AddChild<LayerImpl>(grand_child1);
3338 LayerImpl* leaf_node2 = AddChild<LayerImpl>(grand_child2); 3338 LayerImpl* leaf_node2 = AddChild<LayerImpl>(grand_child2);
3339 3339
3340 root->SetDrawsContent(true); 3340 root->SetDrawsContent(true);
3341 parent->SetDrawsContent(true); 3341 parent->SetDrawsContent(true);
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
3518 EXPECT_EQ(gfx::Rect(5, 5, 800, 800), child2->drawable_content_rect()); 3518 EXPECT_EQ(gfx::Rect(5, 5, 800, 800), child2->drawable_content_rect());
3519 EXPECT_EQ(gfx::Rect(14, 14, 792, 792), grand_child1->drawable_content_rect()); 3519 EXPECT_EQ(gfx::Rect(14, 14, 792, 792), grand_child1->drawable_content_rect());
3520 EXPECT_EQ(gfx::Rect(12, 12, 1500, 1500), 3520 EXPECT_EQ(gfx::Rect(12, 12, 1500, 1500),
3521 grand_child2->drawable_content_rect()); 3521 grand_child2->drawable_content_rect());
3522 EXPECT_EQ(gfx::Rect(30, 30, 776, 776), leaf_node1->drawable_content_rect()); 3522 EXPECT_EQ(gfx::Rect(30, 30, 776, 776), leaf_node1->drawable_content_rect());
3523 EXPECT_EQ(gfx::Rect(21, 21, 1491, 1491), leaf_node2->drawable_content_rect()); 3523 EXPECT_EQ(gfx::Rect(21, 21, 1491, 1491), leaf_node2->drawable_content_rect());
3524 } 3524 }
3525 3525
3526 TEST_F(LayerTreeHostCommonTest, 3526 TEST_F(LayerTreeHostCommonTest,
3527 VisibleContentRectsForClippedSurfaceWithEmptyClip) { 3527 VisibleContentRectsForClippedSurfaceWithEmptyClip) {
3528 LayerImpl* root = root_layer(); 3528 LayerImpl* root = root_layer_for_testing();
3529 LayerImpl* child1 = AddChild<LayerImpl>(root); 3529 LayerImpl* child1 = AddChild<LayerImpl>(root);
3530 LayerImpl* child2 = AddChild<LayerImpl>(root); 3530 LayerImpl* child2 = AddChild<LayerImpl>(root);
3531 LayerImpl* child3 = AddChild<LayerImpl>(root); 3531 LayerImpl* child3 = AddChild<LayerImpl>(root);
3532 child1->SetDrawsContent(true); 3532 child1->SetDrawsContent(true);
3533 child2->SetDrawsContent(true); 3533 child2->SetDrawsContent(true);
3534 child3->SetDrawsContent(true); 3534 child3->SetDrawsContent(true);
3535 3535
3536 gfx::Transform identity_matrix; 3536 gfx::Transform identity_matrix;
3537 SetLayerPropertiesForTesting(root, identity_matrix, gfx::Point3F(), 3537 SetLayerPropertiesForTesting(root, identity_matrix, gfx::Point3F(),
3538 gfx::PointF(), gfx::Size(100, 100), true, false, 3538 gfx::PointF(), gfx::Size(100, 100), true, false,
(...skipping 24 matching lines...) Expand all
3563 // Visible content rect calculation will check if the target surface is 3563 // Visible content rect calculation will check if the target surface is
3564 // clipped or not. An empty clip rect does not indicate the render surface 3564 // clipped or not. An empty clip rect does not indicate the render surface
3565 // is unclipped. 3565 // is unclipped.
3566 EXPECT_EQ(empty, child1->visible_layer_rect()); 3566 EXPECT_EQ(empty, child1->visible_layer_rect());
3567 EXPECT_EQ(empty, child2->visible_layer_rect()); 3567 EXPECT_EQ(empty, child2->visible_layer_rect());
3568 EXPECT_EQ(empty, child3->visible_layer_rect()); 3568 EXPECT_EQ(empty, child3->visible_layer_rect());
3569 } 3569 }
3570 3570
3571 TEST_F(LayerTreeHostCommonTest, 3571 TEST_F(LayerTreeHostCommonTest,
3572 DrawableAndVisibleContentRectsForLayersWithUninvertibleTransform) { 3572 DrawableAndVisibleContentRectsForLayersWithUninvertibleTransform) {
3573 LayerImpl* root = root_layer(); 3573 LayerImpl* root = root_layer_for_testing();
3574 LayerImpl* child = AddChildToRoot<LayerImpl>(); 3574 LayerImpl* child = AddChildToRoot<LayerImpl>();
3575 child->SetDrawsContent(true); 3575 child->SetDrawsContent(true);
3576 3576
3577 // Case 1: a truly degenerate matrix 3577 // Case 1: a truly degenerate matrix
3578 gfx::Transform identity_matrix; 3578 gfx::Transform identity_matrix;
3579 gfx::Transform uninvertible_matrix(0.0, 0.0, 0.0, 0.0, 0.0, 0.0); 3579 gfx::Transform uninvertible_matrix(0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
3580 ASSERT_FALSE(uninvertible_matrix.IsInvertible()); 3580 ASSERT_FALSE(uninvertible_matrix.IsInvertible());
3581 3581
3582 SetLayerPropertiesForTesting(root, identity_matrix, gfx::Point3F(), 3582 SetLayerPropertiesForTesting(root, identity_matrix, gfx::Point3F(),
3583 gfx::PointF(), gfx::Size(100, 100), true, false, 3583 gfx::PointF(), gfx::Size(100, 100), true, false,
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
3617 false, false); 3617 false, false);
3618 3618
3619 ExecuteCalculateDrawProperties(root); 3619 ExecuteCalculateDrawProperties(root);
3620 3620
3621 EXPECT_TRUE(child->visible_layer_rect().IsEmpty()); 3621 EXPECT_TRUE(child->visible_layer_rect().IsEmpty());
3622 EXPECT_TRUE(child->drawable_content_rect().IsEmpty()); 3622 EXPECT_TRUE(child->drawable_content_rect().IsEmpty());
3623 } 3623 }
3624 3624
3625 TEST_F(LayerTreeHostCommonTest, 3625 TEST_F(LayerTreeHostCommonTest,
3626 VisibleContentRectForLayerWithUninvertibleDrawTransform) { 3626 VisibleContentRectForLayerWithUninvertibleDrawTransform) {
3627 LayerImpl* root = root_layer(); 3627 LayerImpl* root = root_layer_for_testing();
3628 LayerImpl* child = AddChildToRoot<LayerImpl>(); 3628 LayerImpl* child = AddChildToRoot<LayerImpl>();
3629 LayerImpl* grand_child = AddChild<LayerImpl>(child); 3629 LayerImpl* grand_child = AddChild<LayerImpl>(child);
3630 child->SetDrawsContent(true); 3630 child->SetDrawsContent(true);
3631 grand_child->SetDrawsContent(true); 3631 grand_child->SetDrawsContent(true);
3632 3632
3633 gfx::Transform identity_matrix; 3633 gfx::Transform identity_matrix;
3634 3634
3635 gfx::Transform perspective; 3635 gfx::Transform perspective;
3636 perspective.ApplyPerspectiveDepth(SkDoubleToMScalar(1e-12)); 3636 perspective.ApplyPerspectiveDepth(SkDoubleToMScalar(1e-12));
3637 3637
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
3701 false); 3701 false);
3702 SetLayerPropertiesForTesting(occluding_child.get(), identity_matrix, 3702 SetLayerPropertiesForTesting(occluding_child.get(), identity_matrix,
3703 gfx::Point3F(), gfx::PointF(), 3703 gfx::Point3F(), gfx::PointF(),
3704 gfx::Size(200, 200), false, false, false); 3704 gfx::Size(200, 200), false, false, false);
3705 3705
3706 host_impl.SetViewportSize(root->bounds()); 3706 host_impl.SetViewportSize(root->bounds());
3707 3707
3708 child->test_properties()->AddChild(std::move(grand_child)); 3708 child->test_properties()->AddChild(std::move(grand_child));
3709 root->test_properties()->AddChild(std::move(child)); 3709 root->test_properties()->AddChild(std::move(child));
3710 root->test_properties()->AddChild(std::move(occluding_child)); 3710 root->test_properties()->AddChild(std::move(occluding_child));
3711 host_impl.active_tree()->SetRootLayer(std::move(root)); 3711 host_impl.active_tree()->SetRootLayerForTesting(std::move(root));
3712 host_impl.SetVisible(true); 3712 host_impl.SetVisible(true);
3713 host_impl.InitializeRenderer(output_surface.get()); 3713 host_impl.InitializeRenderer(output_surface.get());
3714 host_impl.active_tree()->BuildLayerListAndPropertyTreesForTesting(); 3714 host_impl.active_tree()->BuildLayerListAndPropertyTreesForTesting();
3715 bool update_lcd_text = false; 3715 bool update_lcd_text = false;
3716 host_impl.active_tree()->UpdateDrawProperties(update_lcd_text); 3716 host_impl.active_tree()->UpdateDrawProperties(update_lcd_text);
3717 3717
3718 LayerImpl* grand_child_ptr = host_impl.active_tree() 3718 LayerImpl* grand_child_ptr = host_impl.active_tree()
3719 ->root_layer() 3719 ->root_layer_for_testing()
3720 ->test_properties() 3720 ->test_properties()
3721 ->children[0] 3721 ->children[0]
3722 ->test_properties() 3722 ->test_properties()
3723 ->children[0]; 3723 ->children[0];
3724 3724
3725 // Though all layers have invertible transforms, matrix multiplication using 3725 // Though all layers have invertible transforms, matrix multiplication using
3726 // floating-point math makes the draw transform uninvertible. 3726 // floating-point math makes the draw transform uninvertible.
3727 EXPECT_FALSE( 3727 EXPECT_FALSE(
3728 host_impl.active_tree() 3728 host_impl.active_tree()
3729 ->property_trees() 3729 ->property_trees()
3730 ->transform_tree.Node(grand_child_ptr->transform_tree_index()) 3730 ->transform_tree.Node(grand_child_ptr->transform_tree_index())
3731 ->data.ancestors_are_invertible); 3731 ->data.ancestors_are_invertible);
3732 3732
3733 // Since |grand_child| has an uninvertible screen space transform, it is 3733 // Since |grand_child| has an uninvertible screen space transform, it is
3734 // skipped so 3734 // skipped so
3735 // that we are not computing its occlusion_in_content_space. 3735 // that we are not computing its occlusion_in_content_space.
3736 gfx::Rect layer_bounds = gfx::Rect(); 3736 gfx::Rect layer_bounds = gfx::Rect();
3737 EXPECT_EQ( 3737 EXPECT_EQ(
3738 layer_bounds, 3738 layer_bounds,
3739 grand_child_ptr->draw_properties() 3739 grand_child_ptr->draw_properties()
3740 .occlusion_in_content_space.GetUnoccludedContentRect(layer_bounds)); 3740 .occlusion_in_content_space.GetUnoccludedContentRect(layer_bounds));
3741 } 3741 }
3742 3742
3743 TEST_F(LayerTreeHostCommonTest, 3743 TEST_F(LayerTreeHostCommonTest,
3744 DrawableAndVisibleContentRectsForLayersInClippedRenderSurface) { 3744 DrawableAndVisibleContentRectsForLayersInClippedRenderSurface) {
3745 LayerImpl* root = root_layer(); 3745 LayerImpl* root = root_layer_for_testing();
3746 LayerImpl* render_surface = AddChildToRoot<LayerImpl>(); 3746 LayerImpl* render_surface = AddChildToRoot<LayerImpl>();
3747 LayerImpl* child1 = AddChild<LayerImpl>(render_surface); 3747 LayerImpl* child1 = AddChild<LayerImpl>(render_surface);
3748 child1->SetDrawsContent(true); 3748 child1->SetDrawsContent(true);
3749 LayerImpl* child2 = AddChild<LayerImpl>(render_surface); 3749 LayerImpl* child2 = AddChild<LayerImpl>(render_surface);
3750 child2->SetDrawsContent(true); 3750 child2->SetDrawsContent(true);
3751 LayerImpl* child3 = AddChild<LayerImpl>(render_surface); 3751 LayerImpl* child3 = AddChild<LayerImpl>(render_surface);
3752 child3->SetDrawsContent(true); 3752 child3->SetDrawsContent(true);
3753 3753
3754 gfx::Transform identity_matrix; 3754 gfx::Transform identity_matrix;
3755 SetLayerPropertiesForTesting(root, identity_matrix, gfx::Point3F(), 3755 SetLayerPropertiesForTesting(root, identity_matrix, gfx::Point3F(),
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
3794 3794
3795 // But the DrawableContentRects are unclipped. 3795 // But the DrawableContentRects are unclipped.
3796 EXPECT_EQ(gfx::Rect(5, 5, 50, 50), child1->drawable_content_rect()); 3796 EXPECT_EQ(gfx::Rect(5, 5, 50, 50), child1->drawable_content_rect());
3797 EXPECT_EQ(gfx::Rect(75, 75, 50, 50), child2->drawable_content_rect()); 3797 EXPECT_EQ(gfx::Rect(75, 75, 50, 50), child2->drawable_content_rect());
3798 EXPECT_EQ(gfx::Rect(125, 125, 50, 50), child3->drawable_content_rect()); 3798 EXPECT_EQ(gfx::Rect(125, 125, 50, 50), child3->drawable_content_rect());
3799 } 3799 }
3800 3800
3801 TEST_F(LayerTreeHostCommonTest, 3801 TEST_F(LayerTreeHostCommonTest,
3802 DrawableAndVisibleContentRectsForSurfaceHierarchy) { 3802 DrawableAndVisibleContentRectsForSurfaceHierarchy) {
3803 // Check that clipping does not propagate down surfaces. 3803 // Check that clipping does not propagate down surfaces.
3804 LayerImpl* root = root_layer(); 3804 LayerImpl* root = root_layer_for_testing();
3805 LayerImpl* render_surface1 = AddChildToRoot<LayerImpl>(); 3805 LayerImpl* render_surface1 = AddChildToRoot<LayerImpl>();
3806 LayerImpl* render_surface2 = AddChild<LayerImpl>(render_surface1); 3806 LayerImpl* render_surface2 = AddChild<LayerImpl>(render_surface1);
3807 LayerImpl* child1 = AddChild<LayerImpl>(render_surface2); 3807 LayerImpl* child1 = AddChild<LayerImpl>(render_surface2);
3808 child1->SetDrawsContent(true); 3808 child1->SetDrawsContent(true);
3809 LayerImpl* child2 = AddChild<LayerImpl>(render_surface2); 3809 LayerImpl* child2 = AddChild<LayerImpl>(render_surface2);
3810 child2->SetDrawsContent(true); 3810 child2->SetDrawsContent(true);
3811 LayerImpl* child3 = AddChild<LayerImpl>(render_surface2); 3811 LayerImpl* child3 = AddChild<LayerImpl>(render_surface2);
3812 child3->SetDrawsContent(true); 3812 child3->SetDrawsContent(true);
3813 3813
3814 gfx::Transform identity_matrix; 3814 gfx::Transform identity_matrix;
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
3863 EXPECT_EQ(gfx::Rect(0, 0, 50, 50), child3->visible_layer_rect()); 3863 EXPECT_EQ(gfx::Rect(0, 0, 50, 50), child3->visible_layer_rect());
3864 3864
3865 // DrawableContentRects are also unclipped. 3865 // DrawableContentRects are also unclipped.
3866 EXPECT_EQ(gfx::Rect(5, 5, 50, 50), child1->drawable_content_rect()); 3866 EXPECT_EQ(gfx::Rect(5, 5, 50, 50), child1->drawable_content_rect());
3867 EXPECT_EQ(gfx::Rect(75, 75, 50, 50), child2->drawable_content_rect()); 3867 EXPECT_EQ(gfx::Rect(75, 75, 50, 50), child2->drawable_content_rect());
3868 EXPECT_EQ(gfx::Rect(125, 125, 50, 50), child3->drawable_content_rect()); 3868 EXPECT_EQ(gfx::Rect(125, 125, 50, 50), child3->drawable_content_rect());
3869 } 3869 }
3870 3870
3871 TEST_F(LayerTreeHostCommonTest, 3871 TEST_F(LayerTreeHostCommonTest,
3872 VisibleRectsForClippedDescendantsOfUnclippedSurfaces) { 3872 VisibleRectsForClippedDescendantsOfUnclippedSurfaces) {
3873 LayerImpl* root = root_layer(); 3873 LayerImpl* root = root_layer_for_testing();
3874 LayerImpl* render_surface1 = AddChildToRoot<LayerImpl>(); 3874 LayerImpl* render_surface1 = AddChildToRoot<LayerImpl>();
3875 LayerImpl* child1 = AddChild<LayerImpl>(render_surface1); 3875 LayerImpl* child1 = AddChild<LayerImpl>(render_surface1);
3876 LayerImpl* child2 = AddChild<LayerImpl>(child1); 3876 LayerImpl* child2 = AddChild<LayerImpl>(child1);
3877 LayerImpl* render_surface2 = AddChild<LayerImpl>(child2); 3877 LayerImpl* render_surface2 = AddChild<LayerImpl>(child2);
3878 child1->SetDrawsContent(true); 3878 child1->SetDrawsContent(true);
3879 child2->SetDrawsContent(true); 3879 child2->SetDrawsContent(true);
3880 render_surface2->SetDrawsContent(true); 3880 render_surface2->SetDrawsContent(true);
3881 3881
3882 gfx::Transform identity_matrix; 3882 gfx::Transform identity_matrix;
3883 SetLayerPropertiesForTesting(root, identity_matrix, gfx::Point3F(), 3883 SetLayerPropertiesForTesting(root, identity_matrix, gfx::Point3F(),
(...skipping 15 matching lines...) Expand all
3899 child1->SetMasksToBounds(true); 3899 child1->SetMasksToBounds(true);
3900 child2->SetMasksToBounds(true); 3900 child2->SetMasksToBounds(true);
3901 3901
3902 ExecuteCalculateDrawProperties(root); 3902 ExecuteCalculateDrawProperties(root);
3903 EXPECT_EQ(gfx::Rect(500, 500), child1->visible_layer_rect()); 3903 EXPECT_EQ(gfx::Rect(500, 500), child1->visible_layer_rect());
3904 EXPECT_EQ(gfx::Rect(100, 100), render_surface2->visible_layer_rect()); 3904 EXPECT_EQ(gfx::Rect(100, 100), render_surface2->visible_layer_rect());
3905 } 3905 }
3906 3906
3907 TEST_F(LayerTreeHostCommonTest, 3907 TEST_F(LayerTreeHostCommonTest,
3908 VisibleRectsWhenClipChildIsBetweenTwoRenderSurfaces) { 3908 VisibleRectsWhenClipChildIsBetweenTwoRenderSurfaces) {
3909 LayerImpl* root = root_layer(); 3909 LayerImpl* root = root_layer_for_testing();
3910 LayerImpl* clip_parent = AddChildToRoot<LayerImpl>(); 3910 LayerImpl* clip_parent = AddChildToRoot<LayerImpl>();
3911 LayerImpl* render_surface1 = AddChild<LayerImpl>(clip_parent); 3911 LayerImpl* render_surface1 = AddChild<LayerImpl>(clip_parent);
3912 LayerImpl* clip_child = AddChild<LayerImpl>(render_surface1); 3912 LayerImpl* clip_child = AddChild<LayerImpl>(render_surface1);
3913 LayerImpl* render_surface2 = AddChild<LayerImpl>(clip_child); 3913 LayerImpl* render_surface2 = AddChild<LayerImpl>(clip_child);
3914 3914
3915 render_surface1->SetDrawsContent(true); 3915 render_surface1->SetDrawsContent(true);
3916 render_surface2->SetDrawsContent(true); 3916 render_surface2->SetDrawsContent(true);
3917 clip_child->SetDrawsContent(true); 3917 clip_child->SetDrawsContent(true);
3918 clip_child->test_properties()->clip_parent = clip_parent; 3918 clip_child->test_properties()->clip_parent = clip_parent;
3919 std::unique_ptr<std::set<LayerImpl*>> clip_children(new std::set<LayerImpl*>); 3919 std::unique_ptr<std::set<LayerImpl*>> clip_children(new std::set<LayerImpl*>);
(...skipping 19 matching lines...) Expand all
3939 clip_parent->SetMasksToBounds(true); 3939 clip_parent->SetMasksToBounds(true);
3940 render_surface1->SetMasksToBounds(true); 3940 render_surface1->SetMasksToBounds(true);
3941 3941
3942 ExecuteCalculateDrawProperties(root); 3942 ExecuteCalculateDrawProperties(root);
3943 EXPECT_EQ(gfx::Rect(20, 20), render_surface1->visible_layer_rect()); 3943 EXPECT_EQ(gfx::Rect(20, 20), render_surface1->visible_layer_rect());
3944 EXPECT_EQ(gfx::Rect(50, 50), clip_child->visible_layer_rect()); 3944 EXPECT_EQ(gfx::Rect(50, 50), clip_child->visible_layer_rect());
3945 EXPECT_EQ(gfx::Rect(50, 50), render_surface2->visible_layer_rect()); 3945 EXPECT_EQ(gfx::Rect(50, 50), render_surface2->visible_layer_rect());
3946 } 3946 }
3947 3947
3948 TEST_F(LayerTreeHostCommonTest, ClipRectOfSurfaceWhoseParentIsAClipChild) { 3948 TEST_F(LayerTreeHostCommonTest, ClipRectOfSurfaceWhoseParentIsAClipChild) {
3949 LayerImpl* root = root_layer(); 3949 LayerImpl* root = root_layer_for_testing();
3950 LayerImpl* clip_parent = AddChildToRoot<LayerImpl>(); 3950 LayerImpl* clip_parent = AddChildToRoot<LayerImpl>();
3951 LayerImpl* render_surface1 = AddChild<LayerImpl>(clip_parent); 3951 LayerImpl* render_surface1 = AddChild<LayerImpl>(clip_parent);
3952 LayerImpl* clip_child = AddChild<LayerImpl>(render_surface1); 3952 LayerImpl* clip_child = AddChild<LayerImpl>(render_surface1);
3953 LayerImpl* render_surface2 = AddChild<LayerImpl>(clip_child); 3953 LayerImpl* render_surface2 = AddChild<LayerImpl>(clip_child);
3954 3954
3955 render_surface1->SetDrawsContent(true); 3955 render_surface1->SetDrawsContent(true);
3956 render_surface2->SetDrawsContent(true); 3956 render_surface2->SetDrawsContent(true);
3957 clip_child->SetDrawsContent(true); 3957 clip_child->SetDrawsContent(true);
3958 clip_child->test_properties()->clip_parent = clip_parent; 3958 clip_child->test_properties()->clip_parent = clip_parent;
3959 std::unique_ptr<std::set<LayerImpl*>> clip_children(new std::set<LayerImpl*>); 3959 std::unique_ptr<std::set<LayerImpl*>> clip_children(new std::set<LayerImpl*>);
(...skipping 18 matching lines...) Expand all
3978 true); 3978 true);
3979 clip_parent->SetMasksToBounds(true); 3979 clip_parent->SetMasksToBounds(true);
3980 render_surface1->SetMasksToBounds(true); 3980 render_surface1->SetMasksToBounds(true);
3981 3981
3982 ExecuteCalculateDrawProperties(root); 3982 ExecuteCalculateDrawProperties(root);
3983 EXPECT_EQ(gfx::Rect(50, 50), render_surface2->render_surface()->clip_rect()); 3983 EXPECT_EQ(gfx::Rect(50, 50), render_surface2->render_surface()->clip_rect());
3984 } 3984 }
3985 3985
3986 TEST_F(LayerTreeHostCommonTest, RenderSurfaceContentRectWhenLayerNotDrawn) { 3986 TEST_F(LayerTreeHostCommonTest, RenderSurfaceContentRectWhenLayerNotDrawn) {
3987 // Test that only drawn layers contribute to render surface content rect. 3987 // Test that only drawn layers contribute to render surface content rect.
3988 LayerImpl* root = root_layer(); 3988 LayerImpl* root = root_layer_for_testing();
3989 LayerImpl* surface = AddChildToRoot<LayerImpl>(); 3989 LayerImpl* surface = AddChildToRoot<LayerImpl>();
3990 LayerImpl* test_layer = AddChild<LayerImpl>(surface); 3990 LayerImpl* test_layer = AddChild<LayerImpl>(surface);
3991 3991
3992 test_layer->SetDrawsContent(false); 3992 test_layer->SetDrawsContent(false);
3993 surface->SetDrawsContent(true); 3993 surface->SetDrawsContent(true);
3994 gfx::Transform identity_matrix; 3994 gfx::Transform identity_matrix;
3995 SetLayerPropertiesForTesting(root, identity_matrix, gfx::Point3F(), 3995 SetLayerPropertiesForTesting(root, identity_matrix, gfx::Point3F(),
3996 gfx::PointF(), gfx::Size(200, 200), true, false, 3996 gfx::PointF(), gfx::Size(200, 200), true, false,
3997 true); 3997 true);
3998 SetLayerPropertiesForTesting(surface, identity_matrix, gfx::Point3F(), 3998 SetLayerPropertiesForTesting(surface, identity_matrix, gfx::Point3F(),
3999 gfx::PointF(), gfx::Size(100, 100), true, false, 3999 gfx::PointF(), gfx::Size(100, 100), true, false,
4000 true); 4000 true);
4001 SetLayerPropertiesForTesting(test_layer, identity_matrix, gfx::Point3F(), 4001 SetLayerPropertiesForTesting(test_layer, identity_matrix, gfx::Point3F(),
4002 gfx::PointF(), gfx::Size(150, 150), true, false, 4002 gfx::PointF(), gfx::Size(150, 150), true, false,
4003 false); 4003 false);
4004 4004
4005 ExecuteCalculateDrawProperties(root); 4005 ExecuteCalculateDrawProperties(root);
4006 EXPECT_EQ(gfx::Rect(100, 100), surface->render_surface()->content_rect()); 4006 EXPECT_EQ(gfx::Rect(100, 100), surface->render_surface()->content_rect());
4007 4007
4008 test_layer->SetDrawsContent(true); 4008 test_layer->SetDrawsContent(true);
4009 ExecuteCalculateDrawProperties(root); 4009 ExecuteCalculateDrawProperties(root);
4010 EXPECT_EQ(gfx::Rect(150, 150), surface->render_surface()->content_rect()); 4010 EXPECT_EQ(gfx::Rect(150, 150), surface->render_surface()->content_rect());
4011 } 4011 }
4012 4012
4013 TEST_F(LayerTreeHostCommonTest, VisibleRectsMultipleSurfaces) { 4013 TEST_F(LayerTreeHostCommonTest, VisibleRectsMultipleSurfaces) {
4014 // Tests visible rects computation when we have unclipped_surface-> 4014 // Tests visible rects computation when we have unclipped_surface->
4015 // surface_with_unclipped_descendants->clipped_surface, checks that the bounds 4015 // surface_with_unclipped_descendants->clipped_surface, checks that the bounds
4016 // of surface_with_unclipped_descendants doesn't propagate to the 4016 // of surface_with_unclipped_descendants doesn't propagate to the
4017 // clipped_surface below it. 4017 // clipped_surface below it.
4018 LayerImpl* root = root_layer(); 4018 LayerImpl* root = root_layer_for_testing();
4019 LayerImpl* unclipped_surface = AddChildToRoot<LayerImpl>(); 4019 LayerImpl* unclipped_surface = AddChildToRoot<LayerImpl>();
4020 LayerImpl* clip_parent = AddChild<LayerImpl>(unclipped_surface); 4020 LayerImpl* clip_parent = AddChild<LayerImpl>(unclipped_surface);
4021 LayerImpl* unclipped_desc_surface = AddChild<LayerImpl>(clip_parent); 4021 LayerImpl* unclipped_desc_surface = AddChild<LayerImpl>(clip_parent);
4022 LayerImpl* clip_child = AddChild<LayerImpl>(unclipped_desc_surface); 4022 LayerImpl* clip_child = AddChild<LayerImpl>(unclipped_desc_surface);
4023 LayerImpl* clipped_surface = AddChild<LayerImpl>(clip_child); 4023 LayerImpl* clipped_surface = AddChild<LayerImpl>(clip_child);
4024 4024
4025 unclipped_surface->SetDrawsContent(true); 4025 unclipped_surface->SetDrawsContent(true);
4026 unclipped_desc_surface->SetDrawsContent(true); 4026 unclipped_desc_surface->SetDrawsContent(true);
4027 clipped_surface->SetDrawsContent(true); 4027 clipped_surface->SetDrawsContent(true);
4028 clip_child->test_properties()->clip_parent = clip_parent; 4028 clip_child->test_properties()->clip_parent = clip_parent;
(...skipping 25 matching lines...) Expand all
4054 ExecuteCalculateDrawProperties(root); 4054 ExecuteCalculateDrawProperties(root);
4055 EXPECT_EQ(gfx::Rect(30, 30), unclipped_surface->visible_layer_rect()); 4055 EXPECT_EQ(gfx::Rect(30, 30), unclipped_surface->visible_layer_rect());
4056 EXPECT_EQ(gfx::Rect(20, 20), unclipped_desc_surface->visible_layer_rect()); 4056 EXPECT_EQ(gfx::Rect(20, 20), unclipped_desc_surface->visible_layer_rect());
4057 EXPECT_EQ(gfx::Rect(50, 50), clipped_surface->visible_layer_rect()); 4057 EXPECT_EQ(gfx::Rect(50, 50), clipped_surface->visible_layer_rect());
4058 } 4058 }
4059 4059
4060 TEST_F(LayerTreeHostCommonTest, RootClipPropagationToClippedSurface) { 4060 TEST_F(LayerTreeHostCommonTest, RootClipPropagationToClippedSurface) {
4061 // Tests visible rects computation when we have unclipped_surface-> 4061 // Tests visible rects computation when we have unclipped_surface->
4062 // surface_with_unclipped_descendants->clipped_surface, checks that the bounds 4062 // surface_with_unclipped_descendants->clipped_surface, checks that the bounds
4063 // of root propagate to the clipped_surface. 4063 // of root propagate to the clipped_surface.
4064 LayerImpl* root = root_layer(); 4064 LayerImpl* root = root_layer_for_testing();
4065 LayerImpl* unclipped_surface = AddChildToRoot<LayerImpl>(); 4065 LayerImpl* unclipped_surface = AddChildToRoot<LayerImpl>();
4066 LayerImpl* clip_parent = AddChild<LayerImpl>(unclipped_surface); 4066 LayerImpl* clip_parent = AddChild<LayerImpl>(unclipped_surface);
4067 LayerImpl* unclipped_desc_surface = AddChild<LayerImpl>(clip_parent); 4067 LayerImpl* unclipped_desc_surface = AddChild<LayerImpl>(clip_parent);
4068 LayerImpl* clip_child = AddChild<LayerImpl>(unclipped_desc_surface); 4068 LayerImpl* clip_child = AddChild<LayerImpl>(unclipped_desc_surface);
4069 LayerImpl* clipped_surface = AddChild<LayerImpl>(clip_child); 4069 LayerImpl* clipped_surface = AddChild<LayerImpl>(clip_child);
4070 4070
4071 unclipped_surface->SetDrawsContent(true); 4071 unclipped_surface->SetDrawsContent(true);
4072 unclipped_desc_surface->SetDrawsContent(true); 4072 unclipped_desc_surface->SetDrawsContent(true);
4073 clipped_surface->SetDrawsContent(true); 4073 clipped_surface->SetDrawsContent(true);
4074 clip_child->test_properties()->clip_parent = clip_parent; 4074 clip_child->test_properties()->clip_parent = clip_parent;
(...skipping 26 matching lines...) Expand all
4101 ExecuteCalculateDrawProperties(root); 4101 ExecuteCalculateDrawProperties(root);
4102 EXPECT_EQ(gfx::Rect(50, 50), unclipped_surface->visible_layer_rect()); 4102 EXPECT_EQ(gfx::Rect(50, 50), unclipped_surface->visible_layer_rect());
4103 EXPECT_EQ(gfx::Rect(50, 50), unclipped_desc_surface->visible_layer_rect()); 4103 EXPECT_EQ(gfx::Rect(50, 50), unclipped_desc_surface->visible_layer_rect());
4104 EXPECT_EQ(gfx::Rect(10, 10), clipped_surface->visible_layer_rect()); 4104 EXPECT_EQ(gfx::Rect(10, 10), clipped_surface->visible_layer_rect());
4105 } 4105 }
4106 4106
4107 TEST_F(LayerTreeHostCommonTest, 4107 TEST_F(LayerTreeHostCommonTest,
4108 DrawableAndVisibleContentRectsWithTransformOnUnclippedSurface) { 4108 DrawableAndVisibleContentRectsWithTransformOnUnclippedSurface) {
4109 // Layers that have non-axis aligned bounds (due to transforms) have an 4109 // Layers that have non-axis aligned bounds (due to transforms) have an
4110 // expanded, axis-aligned DrawableContentRect and visible content rect. 4110 // expanded, axis-aligned DrawableContentRect and visible content rect.
4111 LayerImpl* root = root_layer(); 4111 LayerImpl* root = root_layer_for_testing();
4112 LayerImpl* render_surface = AddChildToRoot<LayerImpl>(); 4112 LayerImpl* render_surface = AddChildToRoot<LayerImpl>();
4113 LayerImpl* child1 = AddChild<LayerImpl>(render_surface); 4113 LayerImpl* child1 = AddChild<LayerImpl>(render_surface);
4114 child1->SetDrawsContent(true); 4114 child1->SetDrawsContent(true);
4115 4115
4116 gfx::Transform identity_matrix; 4116 gfx::Transform identity_matrix;
4117 gfx::Transform child_rotation; 4117 gfx::Transform child_rotation;
4118 child_rotation.Rotate(45.0); 4118 child_rotation.Rotate(45.0);
4119 SetLayerPropertiesForTesting(root, identity_matrix, gfx::Point3F(), 4119 SetLayerPropertiesForTesting(root, identity_matrix, gfx::Point3F(),
4120 gfx::PointF(), gfx::Size(100, 100), true, false, 4120 gfx::PointF(), gfx::Size(100, 100), true, false,
4121 true); 4121 true);
(...skipping 28 matching lines...) Expand all
4150 4150
4151 // All layers that draw content into the unclipped surface are also unclipped. 4151 // All layers that draw content into the unclipped surface are also unclipped.
4152 EXPECT_EQ(gfx::Rect(0, 0, 50, 50), child1->visible_layer_rect()); 4152 EXPECT_EQ(gfx::Rect(0, 0, 50, 50), child1->visible_layer_rect());
4153 EXPECT_EQ(expected_surface_drawable_content, child1->drawable_content_rect()); 4153 EXPECT_EQ(expected_surface_drawable_content, child1->drawable_content_rect());
4154 } 4154 }
4155 4155
4156 TEST_F(LayerTreeHostCommonTest, 4156 TEST_F(LayerTreeHostCommonTest,
4157 DrawableAndVisibleContentRectsWithTransformOnClippedSurface) { 4157 DrawableAndVisibleContentRectsWithTransformOnClippedSurface) {
4158 // Layers that have non-axis aligned bounds (due to transforms) have an 4158 // Layers that have non-axis aligned bounds (due to transforms) have an
4159 // expanded, axis-aligned DrawableContentRect and visible content rect. 4159 // expanded, axis-aligned DrawableContentRect and visible content rect.
4160 LayerImpl* root = root_layer(); 4160 LayerImpl* root = root_layer_for_testing();
4161 LayerImpl* render_surface = AddChildToRoot<LayerImpl>(); 4161 LayerImpl* render_surface = AddChildToRoot<LayerImpl>();
4162 LayerImpl* child1 = AddChild<LayerImpl>(render_surface); 4162 LayerImpl* child1 = AddChild<LayerImpl>(render_surface);
4163 child1->SetDrawsContent(true); 4163 child1->SetDrawsContent(true);
4164 4164
4165 gfx::Transform identity_matrix; 4165 gfx::Transform identity_matrix;
4166 gfx::Transform child_rotation; 4166 gfx::Transform child_rotation;
4167 child_rotation.Rotate(45.0); 4167 child_rotation.Rotate(45.0);
4168 SetLayerPropertiesForTesting(root, identity_matrix, gfx::Point3F(), 4168 SetLayerPropertiesForTesting(root, identity_matrix, gfx::Point3F(),
4169 gfx::PointF(), gfx::Size(50, 50), true, false, 4169 gfx::PointF(), gfx::Size(50, 50), true, false,
4170 true); 4170 true);
(...skipping 26 matching lines...) Expand all
4197 // On the clipped surface, only a quarter of the child1 is visible, but when 4197 // On the clipped surface, only a quarter of the child1 is visible, but when
4198 // rotating it back to child1's content space, the actual enclosing rect ends 4198 // rotating it back to child1's content space, the actual enclosing rect ends
4199 // up covering the full left half of child1. 4199 // up covering the full left half of child1.
4200 EXPECT_EQ(gfx::Rect(0, 0, 25, 50), child1->visible_layer_rect()); 4200 EXPECT_EQ(gfx::Rect(0, 0, 25, 50), child1->visible_layer_rect());
4201 4201
4202 // The child's DrawableContentRect is unclipped. 4202 // The child's DrawableContentRect is unclipped.
4203 EXPECT_EQ(unclipped_surface_content, child1->drawable_content_rect()); 4203 EXPECT_EQ(unclipped_surface_content, child1->drawable_content_rect());
4204 } 4204 }
4205 4205
4206 TEST_F(LayerTreeHostCommonTest, DrawableAndVisibleContentRectsInHighDPI) { 4206 TEST_F(LayerTreeHostCommonTest, DrawableAndVisibleContentRectsInHighDPI) {
4207 LayerImpl* root = root_layer(); 4207 LayerImpl* root = root_layer_for_testing();
4208 FakePictureLayerImpl* render_surface1 = 4208 FakePictureLayerImpl* render_surface1 =
4209 AddChildToRoot<FakePictureLayerImpl>(); 4209 AddChildToRoot<FakePictureLayerImpl>();
4210 render_surface1->SetDrawsContent(true); 4210 render_surface1->SetDrawsContent(true);
4211 FakePictureLayerImpl* render_surface2 = 4211 FakePictureLayerImpl* render_surface2 =
4212 AddChild<FakePictureLayerImpl>(render_surface1); 4212 AddChild<FakePictureLayerImpl>(render_surface1);
4213 render_surface2->SetDrawsContent(true); 4213 render_surface2->SetDrawsContent(true);
4214 FakePictureLayerImpl* child1 = 4214 FakePictureLayerImpl* child1 =
4215 AddChild<FakePictureLayerImpl>(render_surface2); 4215 AddChild<FakePictureLayerImpl>(render_surface2);
4216 child1->SetDrawsContent(true); 4216 child1->SetDrawsContent(true);
4217 FakePictureLayerImpl* child2 = 4217 FakePictureLayerImpl* child2 =
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
4277 EXPECT_EQ(gfx::Rect(0, 0, 50, 50), child2->visible_layer_rect()); 4277 EXPECT_EQ(gfx::Rect(0, 0, 50, 50), child2->visible_layer_rect());
4278 EXPECT_EQ(gfx::Rect(0, 0, 50, 50), child3->visible_layer_rect()); 4278 EXPECT_EQ(gfx::Rect(0, 0, 50, 50), child3->visible_layer_rect());
4279 } 4279 }
4280 4280
4281 TEST_F(LayerTreeHostCommonTest, BackFaceCullingWithoutPreserves3d) { 4281 TEST_F(LayerTreeHostCommonTest, BackFaceCullingWithoutPreserves3d) {
4282 // Verify the behavior of back-face culling when there are no preserve-3d 4282 // Verify the behavior of back-face culling when there are no preserve-3d
4283 // layers. Note that 3d transforms still apply in this case, but they are 4283 // layers. Note that 3d transforms still apply in this case, but they are
4284 // "flattened" to each parent layer according to current W3C spec. 4284 // "flattened" to each parent layer according to current W3C spec.
4285 4285
4286 const gfx::Transform identity_matrix; 4286 const gfx::Transform identity_matrix;
4287 LayerImpl* parent = root_layer(); 4287 LayerImpl* parent = root_layer_for_testing();
4288 LayerImpl* front_facing_child = AddChildToRoot<LayerImpl>(); 4288 LayerImpl* front_facing_child = AddChildToRoot<LayerImpl>();
4289 LayerImpl* back_facing_child = AddChildToRoot<LayerImpl>(); 4289 LayerImpl* back_facing_child = AddChildToRoot<LayerImpl>();
4290 LayerImpl* front_facing_surface = AddChildToRoot<LayerImpl>(); 4290 LayerImpl* front_facing_surface = AddChildToRoot<LayerImpl>();
4291 LayerImpl* back_facing_surface = AddChildToRoot<LayerImpl>(); 4291 LayerImpl* back_facing_surface = AddChildToRoot<LayerImpl>();
4292 LayerImpl* front_facing_child_of_front_facing_surface = 4292 LayerImpl* front_facing_child_of_front_facing_surface =
4293 AddChild<LayerImpl>(front_facing_surface); 4293 AddChild<LayerImpl>(front_facing_surface);
4294 LayerImpl* back_facing_child_of_front_facing_surface = 4294 LayerImpl* back_facing_child_of_front_facing_surface =
4295 AddChild<LayerImpl>(front_facing_surface); 4295 AddChild<LayerImpl>(front_facing_surface);
4296 LayerImpl* front_facing_child_of_back_facing_surface = 4296 LayerImpl* front_facing_child_of_back_facing_surface =
4297 AddChild<LayerImpl>(back_facing_surface); 4297 AddChild<LayerImpl>(back_facing_surface);
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
4381 front_facing_child_of_front_facing_surface->id())); 4381 front_facing_child_of_front_facing_surface->id()));
4382 EXPECT_TRUE(UpdateLayerListImplContains( 4382 EXPECT_TRUE(UpdateLayerListImplContains(
4383 front_facing_child_of_back_facing_surface->id())); 4383 front_facing_child_of_back_facing_surface->id()));
4384 } 4384 }
4385 4385
4386 TEST_F(LayerTreeHostCommonTest, BackFaceCullingWithPreserves3d) { 4386 TEST_F(LayerTreeHostCommonTest, BackFaceCullingWithPreserves3d) {
4387 // Verify the behavior of back-face culling when preserves-3d transform style 4387 // Verify the behavior of back-face culling when preserves-3d transform style
4388 // is used. 4388 // is used.
4389 4389
4390 const gfx::Transform identity_matrix; 4390 const gfx::Transform identity_matrix;
4391 LayerImpl* parent = root_layer(); 4391 LayerImpl* parent = root_layer_for_testing();
4392 LayerImpl* front_facing_child = AddChildToRoot<LayerImpl>(); 4392 LayerImpl* front_facing_child = AddChildToRoot<LayerImpl>();
4393 LayerImpl* back_facing_child = AddChildToRoot<LayerImpl>(); 4393 LayerImpl* back_facing_child = AddChildToRoot<LayerImpl>();
4394 LayerImpl* front_facing_surface = AddChildToRoot<LayerImpl>(); 4394 LayerImpl* front_facing_surface = AddChildToRoot<LayerImpl>();
4395 LayerImpl* back_facing_surface = AddChildToRoot<LayerImpl>(); 4395 LayerImpl* back_facing_surface = AddChildToRoot<LayerImpl>();
4396 LayerImpl* front_facing_child_of_front_facing_surface = 4396 LayerImpl* front_facing_child_of_front_facing_surface =
4397 AddChild<LayerImpl>(front_facing_surface); 4397 AddChild<LayerImpl>(front_facing_surface);
4398 LayerImpl* back_facing_child_of_front_facing_surface = 4398 LayerImpl* back_facing_child_of_front_facing_surface =
4399 AddChild<LayerImpl>(front_facing_surface); 4399 AddChild<LayerImpl>(front_facing_surface);
4400 LayerImpl* front_facing_child_of_back_facing_surface = 4400 LayerImpl* front_facing_child_of_back_facing_surface =
4401 AddChild<LayerImpl>(back_facing_surface); 4401 AddChild<LayerImpl>(back_facing_surface);
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
4497 front_facing_child_of_front_facing_surface->id())); 4497 front_facing_child_of_front_facing_surface->id()));
4498 } 4498 }
4499 4499
4500 TEST_F(LayerTreeHostCommonTest, BackFaceCullingWithAnimatingTransforms) { 4500 TEST_F(LayerTreeHostCommonTest, BackFaceCullingWithAnimatingTransforms) {
4501 // Verify that layers are appropriately culled when their back face is showing 4501 // Verify that layers are appropriately culled when their back face is showing
4502 // and they are not double sided, while animations are going on. 4502 // and they are not double sided, while animations are going on.
4503 // 4503 //
4504 // Even layers that are animating get culled if their back face is showing and 4504 // Even layers that are animating get culled if their back face is showing and
4505 // they are not double sided. 4505 // they are not double sided.
4506 const gfx::Transform identity_matrix; 4506 const gfx::Transform identity_matrix;
4507 LayerImpl* parent = root_layer(); 4507 LayerImpl* parent = root_layer_for_testing();
4508 LayerImpl* child = AddChildToRoot<LayerImpl>(); 4508 LayerImpl* child = AddChildToRoot<LayerImpl>();
4509 LayerImpl* animating_surface = AddChildToRoot<LayerImpl>(); 4509 LayerImpl* animating_surface = AddChildToRoot<LayerImpl>();
4510 LayerImpl* child_of_animating_surface = 4510 LayerImpl* child_of_animating_surface =
4511 AddChild<LayerImpl>(animating_surface); 4511 AddChild<LayerImpl>(animating_surface);
4512 LayerImpl* animating_child = AddChildToRoot<LayerImpl>(); 4512 LayerImpl* animating_child = AddChildToRoot<LayerImpl>();
4513 LayerImpl* child2 = AddChildToRoot<LayerImpl>(); 4513 LayerImpl* child2 = AddChildToRoot<LayerImpl>();
4514 4514
4515 // Nothing is double-sided 4515 // Nothing is double-sided
4516 child->test_properties()->double_sided = false; 4516 child->test_properties()->double_sided = false;
4517 child2->test_properties()->double_sided = false; 4517 child2->test_properties()->double_sided = false;
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
4573 4573
4574 EXPECT_EQ(gfx::Rect(100, 100), child2->visible_layer_rect()); 4574 EXPECT_EQ(gfx::Rect(100, 100), child2->visible_layer_rect());
4575 } 4575 }
4576 4576
4577 TEST_F(LayerTreeHostCommonTest, 4577 TEST_F(LayerTreeHostCommonTest,
4578 BackFaceCullingWithPreserves3dForFlatteningSurface) { 4578 BackFaceCullingWithPreserves3dForFlatteningSurface) {
4579 // Verify the behavior of back-face culling for a render surface that is 4579 // Verify the behavior of back-face culling for a render surface that is
4580 // created when it flattens its subtree, and its parent has preserves-3d. 4580 // created when it flattens its subtree, and its parent has preserves-3d.
4581 4581
4582 const gfx::Transform identity_matrix; 4582 const gfx::Transform identity_matrix;
4583 LayerImpl* parent = root_layer(); 4583 LayerImpl* parent = root_layer_for_testing();
4584 LayerImpl* front_facing_surface = AddChildToRoot<LayerImpl>(); 4584 LayerImpl* front_facing_surface = AddChildToRoot<LayerImpl>();
4585 LayerImpl* back_facing_surface = AddChildToRoot<LayerImpl>(); 4585 LayerImpl* back_facing_surface = AddChildToRoot<LayerImpl>();
4586 LayerImpl* child1 = AddChild<LayerImpl>(front_facing_surface); 4586 LayerImpl* child1 = AddChild<LayerImpl>(front_facing_surface);
4587 LayerImpl* child2 = AddChild<LayerImpl>(back_facing_surface); 4587 LayerImpl* child2 = AddChild<LayerImpl>(back_facing_surface);
4588 4588
4589 // RenderSurfaces are not double-sided 4589 // RenderSurfaces are not double-sided
4590 front_facing_surface->test_properties()->double_sided = false; 4590 front_facing_surface->test_properties()->double_sided = false;
4591 back_facing_surface->test_properties()->double_sided = false; 4591 back_facing_surface->test_properties()->double_sided = false;
4592 4592
4593 // Everything draws content. 4593 // Everything draws content.
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
4632 4632
4633 EXPECT_EQ(2u, update_layer_list_impl()->size()); 4633 EXPECT_EQ(2u, update_layer_list_impl()->size());
4634 EXPECT_TRUE(UpdateLayerListImplContains(front_facing_surface->id())); 4634 EXPECT_TRUE(UpdateLayerListImplContains(front_facing_surface->id()));
4635 EXPECT_TRUE(UpdateLayerListImplContains(child1->id())); 4635 EXPECT_TRUE(UpdateLayerListImplContains(child1->id()));
4636 } 4636 }
4637 4637
4638 TEST_F(LayerTreeHostCommonScalingTest, LayerTransformsInHighDPI) { 4638 TEST_F(LayerTreeHostCommonScalingTest, LayerTransformsInHighDPI) {
4639 // Verify draw and screen space transforms of layers not in a surface. 4639 // Verify draw and screen space transforms of layers not in a surface.
4640 gfx::Transform identity_matrix; 4640 gfx::Transform identity_matrix;
4641 4641
4642 LayerImpl* parent = root_layer(); 4642 LayerImpl* parent = root_layer_for_testing();
4643 parent->SetDrawsContent(true); 4643 parent->SetDrawsContent(true);
4644 SetLayerPropertiesForTesting(parent, identity_matrix, gfx::Point3F(), 4644 SetLayerPropertiesForTesting(parent, identity_matrix, gfx::Point3F(),
4645 gfx::PointF(), gfx::Size(100, 100), false, true, 4645 gfx::PointF(), gfx::Size(100, 100), false, true,
4646 true); 4646 true);
4647 4647
4648 LayerImpl* child = AddChildToRoot<LayerImpl>(); 4648 LayerImpl* child = AddChildToRoot<LayerImpl>();
4649 child->SetDrawsContent(true); 4649 child->SetDrawsContent(true);
4650 SetLayerPropertiesForTesting(child, identity_matrix, gfx::Point3F(), 4650 SetLayerPropertiesForTesting(child, identity_matrix, gfx::Point3F(),
4651 gfx::PointF(2.f, 2.f), gfx::Size(10, 10), false, 4651 gfx::PointF(2.f, 2.f), gfx::Size(10, 10), false,
4652 true, false); 4652 true, false);
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
4727 4727
4728 TEST_F(LayerTreeHostCommonScalingTest, SurfaceLayerTransformsInHighDPI) { 4728 TEST_F(LayerTreeHostCommonScalingTest, SurfaceLayerTransformsInHighDPI) {
4729 // Verify draw and screen space transforms of layers in a surface. 4729 // Verify draw and screen space transforms of layers in a surface.
4730 gfx::Transform identity_matrix; 4730 gfx::Transform identity_matrix;
4731 gfx::Transform perspective_matrix; 4731 gfx::Transform perspective_matrix;
4732 perspective_matrix.ApplyPerspectiveDepth(2.0); 4732 perspective_matrix.ApplyPerspectiveDepth(2.0);
4733 4733
4734 gfx::Transform scale_small_matrix; 4734 gfx::Transform scale_small_matrix;
4735 scale_small_matrix.Scale(SK_MScalar1 / 10.f, SK_MScalar1 / 12.f); 4735 scale_small_matrix.Scale(SK_MScalar1 / 10.f, SK_MScalar1 / 12.f);
4736 4736
4737 LayerImpl* root = root_layer(); 4737 LayerImpl* root = root_layer_for_testing();
4738 SetLayerPropertiesForTesting(root, identity_matrix, gfx::Point3F(), 4738 SetLayerPropertiesForTesting(root, identity_matrix, gfx::Point3F(),
4739 gfx::PointF(), gfx::Size(100, 100), false, true, 4739 gfx::PointF(), gfx::Size(100, 100), false, true,
4740 false); 4740 false);
4741 4741
4742 LayerImpl* page_scale = AddChildToRoot<LayerImpl>(); 4742 LayerImpl* page_scale = AddChildToRoot<LayerImpl>();
4743 SetLayerPropertiesForTesting(page_scale, identity_matrix, gfx::Point3F(), 4743 SetLayerPropertiesForTesting(page_scale, identity_matrix, gfx::Point3F(),
4744 gfx::PointF(), gfx::Size(100, 100), false, true, 4744 gfx::PointF(), gfx::Size(100, 100), false, true,
4745 false); 4745 false);
4746 4746
4747 LayerImpl* parent = AddChild<LayerImpl>(page_scale); 4747 LayerImpl* parent = AddChild<LayerImpl>(page_scale);
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
4831 4831
4832 TEST_F(LayerTreeHostCommonScalingTest, SmallIdealScale) { 4832 TEST_F(LayerTreeHostCommonScalingTest, SmallIdealScale) {
4833 gfx::Transform parent_scale_matrix; 4833 gfx::Transform parent_scale_matrix;
4834 SkMScalar initial_parent_scale = 1.75; 4834 SkMScalar initial_parent_scale = 1.75;
4835 parent_scale_matrix.Scale(initial_parent_scale, initial_parent_scale); 4835 parent_scale_matrix.Scale(initial_parent_scale, initial_parent_scale);
4836 4836
4837 gfx::Transform child_scale_matrix; 4837 gfx::Transform child_scale_matrix;
4838 SkMScalar initial_child_scale = 0.25; 4838 SkMScalar initial_child_scale = 0.25;
4839 child_scale_matrix.Scale(initial_child_scale, initial_child_scale); 4839 child_scale_matrix.Scale(initial_child_scale, initial_child_scale);
4840 4840
4841 LayerImpl* root = root_layer(); 4841 LayerImpl* root = root_layer_for_testing();
4842 root->SetBounds(gfx::Size(100, 100)); 4842 root->SetBounds(gfx::Size(100, 100));
4843 4843
4844 LayerImpl* parent = AddChildToRoot<LayerImpl>(); 4844 LayerImpl* parent = AddChildToRoot<LayerImpl>();
4845 parent->SetDrawsContent(true); 4845 parent->SetDrawsContent(true);
4846 SetLayerPropertiesForTesting(parent, parent_scale_matrix, gfx::Point3F(), 4846 SetLayerPropertiesForTesting(parent, parent_scale_matrix, gfx::Point3F(),
4847 gfx::PointF(), gfx::Size(100, 100), false, true, 4847 gfx::PointF(), gfx::Size(100, 100), false, true,
4848 false); 4848 false);
4849 4849
4850 LayerImpl* child_scale = AddChild<LayerImpl>(parent); 4850 LayerImpl* child_scale = AddChild<LayerImpl>(parent);
4851 child_scale->SetDrawsContent(true); 4851 child_scale->SetDrawsContent(true);
(...skipping 23 matching lines...) Expand all
4875 4875
4876 TEST_F(LayerTreeHostCommonScalingTest, IdealScaleForAnimatingLayer) { 4876 TEST_F(LayerTreeHostCommonScalingTest, IdealScaleForAnimatingLayer) {
4877 gfx::Transform parent_scale_matrix; 4877 gfx::Transform parent_scale_matrix;
4878 SkMScalar initial_parent_scale = 1.75; 4878 SkMScalar initial_parent_scale = 1.75;
4879 parent_scale_matrix.Scale(initial_parent_scale, initial_parent_scale); 4879 parent_scale_matrix.Scale(initial_parent_scale, initial_parent_scale);
4880 4880
4881 gfx::Transform child_scale_matrix; 4881 gfx::Transform child_scale_matrix;
4882 SkMScalar initial_child_scale = 1.25; 4882 SkMScalar initial_child_scale = 1.25;
4883 child_scale_matrix.Scale(initial_child_scale, initial_child_scale); 4883 child_scale_matrix.Scale(initial_child_scale, initial_child_scale);
4884 4884
4885 LayerImpl* root = root_layer(); 4885 LayerImpl* root = root_layer_for_testing();
4886 root->SetBounds(gfx::Size(100, 100)); 4886 root->SetBounds(gfx::Size(100, 100));
4887 4887
4888 LayerImpl* parent = AddChildToRoot<LayerImpl>(); 4888 LayerImpl* parent = AddChildToRoot<LayerImpl>();
4889 parent->SetDrawsContent(true); 4889 parent->SetDrawsContent(true);
4890 SetLayerPropertiesForTesting(parent, parent_scale_matrix, gfx::Point3F(), 4890 SetLayerPropertiesForTesting(parent, parent_scale_matrix, gfx::Point3F(),
4891 gfx::PointF(), gfx::Size(100, 100), false, true, 4891 gfx::PointF(), gfx::Size(100, 100), false, true,
4892 false); 4892 false);
4893 4893
4894 LayerImpl* child_scale = AddChild<LayerImpl>(parent); 4894 LayerImpl* child_scale = AddChild<LayerImpl>(parent);
4895 child_scale->SetDrawsContent(true); 4895 child_scale->SetDrawsContent(true);
4896 SetLayerPropertiesForTesting(child_scale, child_scale_matrix, gfx::Point3F(), 4896 SetLayerPropertiesForTesting(child_scale, child_scale_matrix, gfx::Point3F(),
4897 gfx::PointF(2.f, 2.f), gfx::Size(10, 10), false, 4897 gfx::PointF(2.f, 2.f), gfx::Size(10, 10), false,
4898 true, false); 4898 true, false);
4899 4899
4900 { 4900 {
4901 ExecuteCalculateDrawProperties(root); 4901 ExecuteCalculateDrawProperties(root);
4902 4902
4903 EXPECT_IDEAL_SCALE_EQ(initial_parent_scale, parent); 4903 EXPECT_IDEAL_SCALE_EQ(initial_parent_scale, parent);
4904 // Animating layers compute ideal scale in the same way as when 4904 // Animating layers compute ideal scale in the same way as when
4905 // they are static. 4905 // they are static.
4906 EXPECT_IDEAL_SCALE_EQ(initial_child_scale * initial_parent_scale, 4906 EXPECT_IDEAL_SCALE_EQ(initial_child_scale * initial_parent_scale,
4907 child_scale); 4907 child_scale);
4908 } 4908 }
4909 } 4909 }
4910 4910
4911 TEST_F(LayerTreeHostCommonTest, RenderSurfaceTransformsInHighDPI) { 4911 TEST_F(LayerTreeHostCommonTest, RenderSurfaceTransformsInHighDPI) {
4912 gfx::Transform identity_matrix; 4912 gfx::Transform identity_matrix;
4913 4913
4914 LayerImpl* parent = root_layer(); 4914 LayerImpl* parent = root_layer_for_testing();
4915 parent->SetDrawsContent(true); 4915 parent->SetDrawsContent(true);
4916 SetLayerPropertiesForTesting(parent, identity_matrix, gfx::Point3F(), 4916 SetLayerPropertiesForTesting(parent, identity_matrix, gfx::Point3F(),
4917 gfx::PointF(), gfx::Size(30, 30), false, true, 4917 gfx::PointF(), gfx::Size(30, 30), false, true,
4918 true); 4918 true);
4919 4919
4920 LayerImpl* child = AddChildToRoot<LayerImpl>(); 4920 LayerImpl* child = AddChildToRoot<LayerImpl>();
4921 child->SetDrawsContent(true); 4921 child->SetDrawsContent(true);
4922 SetLayerPropertiesForTesting(child, identity_matrix, gfx::Point3F(), 4922 SetLayerPropertiesForTesting(child, identity_matrix, gfx::Point3F(),
4923 gfx::PointF(2.f, 2.f), gfx::Size(10, 10), false, 4923 gfx::PointF(2.f, 2.f), gfx::Size(10, 10), false,
4924 true, true); 4924 true, true);
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
5018 child->render_surface()->replica_screen_space_transform()); 5018 child->render_surface()->replica_screen_space_transform());
5019 EXPECT_TRANSFORMATION_MATRIX_EQ( 5019 EXPECT_TRANSFORMATION_MATRIX_EQ(
5020 expected_replica_screen_space_transform, 5020 expected_replica_screen_space_transform,
5021 child->render_surface()->replica_screen_space_transform()); 5021 child->render_surface()->replica_screen_space_transform());
5022 } 5022 }
5023 5023
5024 TEST_F(LayerTreeHostCommonTest, 5024 TEST_F(LayerTreeHostCommonTest,
5025 RenderSurfaceTransformsInHighDPIAccurateScaleZeroPosition) { 5025 RenderSurfaceTransformsInHighDPIAccurateScaleZeroPosition) {
5026 gfx::Transform identity_matrix; 5026 gfx::Transform identity_matrix;
5027 5027
5028 LayerImpl* parent = root_layer(); 5028 LayerImpl* parent = root_layer_for_testing();
5029 parent->SetDrawsContent(true); 5029 parent->SetDrawsContent(true);
5030 SetLayerPropertiesForTesting(parent, identity_matrix, gfx::Point3F(), 5030 SetLayerPropertiesForTesting(parent, identity_matrix, gfx::Point3F(),
5031 gfx::PointF(), gfx::Size(33, 31), false, true, 5031 gfx::PointF(), gfx::Size(33, 31), false, true,
5032 true); 5032 true);
5033 5033
5034 LayerImpl* child = AddChildToRoot<LayerImpl>(); 5034 LayerImpl* child = AddChildToRoot<LayerImpl>();
5035 child->SetDrawsContent(true); 5035 child->SetDrawsContent(true);
5036 SetLayerPropertiesForTesting(child, identity_matrix, gfx::Point3F(), 5036 SetLayerPropertiesForTesting(child, identity_matrix, gfx::Point3F(),
5037 gfx::PointF(), gfx::Size(13, 11), false, true, 5037 gfx::PointF(), gfx::Size(13, 11), false, true,
5038 true); 5038 true);
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
5091 int nonexistent_id = -1; 5091 int nonexistent_id = -1;
5092 EXPECT_EQ(root.get(), host()->LayerById(root->id())); 5092 EXPECT_EQ(root.get(), host()->LayerById(root->id()));
5093 EXPECT_EQ(child.get(), host()->LayerById(child->id())); 5093 EXPECT_EQ(child.get(), host()->LayerById(child->id()));
5094 EXPECT_EQ(grand_child.get(), host()->LayerById(grand_child->id())); 5094 EXPECT_EQ(grand_child.get(), host()->LayerById(grand_child->id()));
5095 EXPECT_EQ(mask_layer.get(), host()->LayerById(mask_layer->id())); 5095 EXPECT_EQ(mask_layer.get(), host()->LayerById(mask_layer->id()));
5096 EXPECT_EQ(replica_layer.get(), host()->LayerById(replica_layer->id())); 5096 EXPECT_EQ(replica_layer.get(), host()->LayerById(replica_layer->id()));
5097 EXPECT_FALSE(host()->LayerById(nonexistent_id)); 5097 EXPECT_FALSE(host()->LayerById(nonexistent_id));
5098 } 5098 }
5099 5099
5100 TEST_F(LayerTreeHostCommonTest, TransparentChildRenderSurfaceCreation) { 5100 TEST_F(LayerTreeHostCommonTest, TransparentChildRenderSurfaceCreation) {
5101 LayerImpl* root = root_layer(); 5101 LayerImpl* root = root_layer_for_testing();
5102 LayerImpl* child = AddChild<LayerImpl>(root); 5102 LayerImpl* child = AddChild<LayerImpl>(root);
5103 LayerImpl* grand_child = AddChild<LayerImpl>(child); 5103 LayerImpl* grand_child = AddChild<LayerImpl>(child);
5104 grand_child->SetDrawsContent(true); 5104 grand_child->SetDrawsContent(true);
5105 5105
5106 const gfx::Transform identity_matrix; 5106 const gfx::Transform identity_matrix;
5107 SetLayerPropertiesForTesting(root, identity_matrix, gfx::Point3F(), 5107 SetLayerPropertiesForTesting(root, identity_matrix, gfx::Point3F(),
5108 gfx::PointF(), gfx::Size(100, 100), true, false); 5108 gfx::PointF(), gfx::Size(100, 100), true, false);
5109 SetLayerPropertiesForTesting(child, identity_matrix, gfx::Point3F(), 5109 SetLayerPropertiesForTesting(child, identity_matrix, gfx::Point3F(),
5110 gfx::PointF(), gfx::Size(10, 10), true, false); 5110 gfx::PointF(), gfx::Size(10, 10), true, false);
5111 SetLayerPropertiesForTesting(grand_child, identity_matrix, gfx::Point3F(), 5111 SetLayerPropertiesForTesting(grand_child, identity_matrix, gfx::Point3F(),
(...skipping 27 matching lines...) Expand all
5139 SetLayerPropertiesForTesting(child.get(), identity_matrix, gfx::Point3F(), 5139 SetLayerPropertiesForTesting(child.get(), identity_matrix, gfx::Point3F(),
5140 gfx::PointF(), gfx::Size(50, 50), true, false, 5140 gfx::PointF(), gfx::Size(50, 50), true, false,
5141 false); 5141 false);
5142 child->SetDrawsContent(true); 5142 child->SetDrawsContent(true);
5143 child->test_properties()->opacity = 0.0f; 5143 child->test_properties()->opacity = 0.0f;
5144 5144
5145 const int child_id = child->id(); 5145 const int child_id = child->id();
5146 root->test_properties()->AddChild(std::move(child)); 5146 root->test_properties()->AddChild(std::move(child));
5147 root->SetHasRenderSurface(true); 5147 root->SetHasRenderSurface(true);
5148 LayerImpl* root_layer = root.get(); 5148 LayerImpl* root_layer = root.get();
5149 host_impl.pending_tree()->SetRootLayer(std::move(root)); 5149 host_impl.pending_tree()->SetRootLayerForTesting(std::move(root));
5150 host_impl.pending_tree()->BuildLayerListAndPropertyTreesForTesting(); 5150 host_impl.pending_tree()->BuildLayerListAndPropertyTreesForTesting();
5151 // Add opacity animation. 5151 // Add opacity animation.
5152 scoped_refptr<AnimationTimeline> timeline = 5152 scoped_refptr<AnimationTimeline> timeline =
5153 AnimationTimeline::Create(AnimationIdProvider::NextTimelineId()); 5153 AnimationTimeline::Create(AnimationIdProvider::NextTimelineId());
5154 host_impl.animation_host()->AddAnimationTimeline(timeline); 5154 host_impl.animation_host()->AddAnimationTimeline(timeline);
5155 5155
5156 AddOpacityTransitionToLayerWithPlayer(child_id, timeline, 10.0, 0.0f, 1.0f, 5156 AddOpacityTransitionToLayerWithPlayer(child_id, timeline, 10.0, 0.0f, 1.0f,
5157 false); 5157 false);
5158 5158
5159 LayerImplList render_surface_layer_list; 5159 LayerImplList render_surface_layer_list;
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
5196 5196
5197 child_ptr = root_layer->layer_tree_impl()->LayerById(2); 5197 child_ptr = root_layer->layer_tree_impl()->LayerById(2);
5198 tree = root_layer->layer_tree_impl()->property_trees()->effect_tree; 5198 tree = root_layer->layer_tree_impl()->property_trees()->effect_tree;
5199 node = tree.Node(child_ptr->effect_tree_index()); 5199 node = tree.Node(child_ptr->effect_tree_index());
5200 EXPECT_TRUE(node->data.is_drawn); 5200 EXPECT_TRUE(node->data.is_drawn);
5201 EXPECT_TRUE(tree.ContributesToDrawnSurface(child_ptr->effect_tree_index())); 5201 EXPECT_TRUE(tree.ContributesToDrawnSurface(child_ptr->effect_tree_index()));
5202 5202
5203 // But if the opacity of the layer remains 0 after activation, it should not 5203 // But if the opacity of the layer remains 0 after activation, it should not
5204 // be drawn. 5204 // be drawn.
5205 host_impl.ActivateSyncTree(); 5205 host_impl.ActivateSyncTree();
5206 LayerImpl* active_root = host_impl.active_tree()->root_layer(); 5206 host_impl.active_tree()->SetRootLayerFromLayerListForTesting();
5207 LayerImpl* active_root = host_impl.active_tree()->root_layer_for_testing();
5207 LayerImpl* active_child = host_impl.active_tree()->LayerById(child_ptr->id()); 5208 LayerImpl* active_child = host_impl.active_tree()->LayerById(child_ptr->id());
5208 5209
5209 EffectTree& active_effect_tree = 5210 EffectTree& active_effect_tree =
5210 host_impl.active_tree()->property_trees()->effect_tree; 5211 host_impl.active_tree()->property_trees()->effect_tree;
5211 EXPECT_TRUE(active_effect_tree.needs_update()); 5212 EXPECT_TRUE(active_effect_tree.needs_update());
5212 5213
5213 ExecuteCalculateDrawProperties(active_root); 5214 ExecuteCalculateDrawProperties(active_root);
5214 5215
5215 node = active_effect_tree.Node(active_child->effect_tree_index()); 5216 node = active_effect_tree.Node(active_child->effect_tree_index());
5216 EXPECT_FALSE(node->data.is_drawn); 5217 EXPECT_FALSE(node->data.is_drawn);
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 LayerImpl::Create(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_->test_properties()->AddChild(std::move(grand_child_ptr)); 5266 child_->test_properties()->AddChild(std::move(grand_child_ptr));
5266 root_->test_properties()->AddChild(std::move(child_ptr)); 5267 root_->test_properties()->AddChild(std::move(child_ptr));
5267 host_impl_.active_tree()->SetRootLayer(std::move(root_ptr)); 5268 host_impl_.active_tree()->SetRootLayerForTesting(std::move(root_ptr));
5268 5269
5269 root_->SetContentsOpaque(true); 5270 root_->SetContentsOpaque(true);
5270 child_->SetContentsOpaque(true); 5271 child_->SetContentsOpaque(true);
5271 grand_child_->SetContentsOpaque(true); 5272 grand_child_->SetContentsOpaque(true);
5272 5273
5273 root_->SetDrawsContent(true); 5274 root_->SetDrawsContent(true);
5274 child_->SetDrawsContent(true); 5275 child_->SetDrawsContent(true);
5275 grand_child_->SetDrawsContent(true); 5276 grand_child_->SetDrawsContent(true);
5276 5277
5277 gfx::Transform identity_matrix; 5278 gfx::Transform identity_matrix;
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
5471 LayerImpl::Create(host_impl.pending_tree(), 3); 5472 LayerImpl::Create(host_impl.pending_tree(), 3);
5472 SetLayerPropertiesForTesting(grand_child.get(), identity_matrix, 5473 SetLayerPropertiesForTesting(grand_child.get(), identity_matrix,
5473 gfx::Point3F(), gfx::PointF(), gfx::Size(30, 30), 5474 gfx::Point3F(), gfx::PointF(), gfx::Size(30, 30),
5474 true, false, false); 5475 true, false, false);
5475 grand_child->SetDrawsContent(true); 5476 grand_child->SetDrawsContent(true);
5476 grand_child->test_properties()->hide_layer_and_subtree = true; 5477 grand_child->test_properties()->hide_layer_and_subtree = true;
5477 5478
5478 child->test_properties()->AddChild(std::move(grand_child)); 5479 child->test_properties()->AddChild(std::move(grand_child));
5479 root->test_properties()->AddChild(std::move(child)); 5480 root->test_properties()->AddChild(std::move(child));
5480 root->SetHasRenderSurface(true); 5481 root->SetHasRenderSurface(true);
5481 host_impl.pending_tree()->SetRootLayer(std::move(root)); 5482 host_impl.pending_tree()->SetRootLayerForTesting(std::move(root));
5482 5483
5483 LayerImplList render_surface_layer_list; 5484 LayerImplList render_surface_layer_list;
5484 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( 5485 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs(
5485 root_layer, root_layer->bounds(), &render_surface_layer_list); 5486 root_layer, root_layer->bounds(), &render_surface_layer_list);
5486 inputs.can_adjust_raster_scales = true; 5487 inputs.can_adjust_raster_scales = true;
5487 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); 5488 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs);
5488 5489
5489 // We should have one render surface and two layers. The grand child has 5490 // We should have one render surface and two layers. The grand child has
5490 // hidden itself. 5491 // hidden itself.
5491 ASSERT_EQ(1u, render_surface_layer_list.size()); 5492 ASSERT_EQ(1u, render_surface_layer_list.size());
(...skipping 29 matching lines...) Expand all
5521 5522
5522 std::unique_ptr<LayerImpl> grand_child = 5523 std::unique_ptr<LayerImpl> grand_child =
5523 LayerImpl::Create(host_impl.pending_tree(), 3); 5524 LayerImpl::Create(host_impl.pending_tree(), 3);
5524 SetLayerPropertiesForTesting(grand_child.get(), identity_matrix, 5525 SetLayerPropertiesForTesting(grand_child.get(), identity_matrix,
5525 gfx::Point3F(), gfx::PointF(), gfx::Size(30, 30), 5526 gfx::Point3F(), gfx::PointF(), gfx::Size(30, 30),
5526 true, false, false); 5527 true, false, false);
5527 grand_child->SetDrawsContent(true); 5528 grand_child->SetDrawsContent(true);
5528 5529
5529 child->test_properties()->AddChild(std::move(grand_child)); 5530 child->test_properties()->AddChild(std::move(grand_child));
5530 root->test_properties()->AddChild(std::move(child)); 5531 root->test_properties()->AddChild(std::move(child));
5531 host_impl.pending_tree()->SetRootLayer(std::move(root)); 5532 host_impl.pending_tree()->SetRootLayerForTesting(std::move(root));
5532 5533
5533 LayerImplList render_surface_layer_list; 5534 LayerImplList render_surface_layer_list;
5534 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( 5535 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs(
5535 root_layer, root_layer->bounds(), &render_surface_layer_list); 5536 root_layer, root_layer->bounds(), &render_surface_layer_list);
5536 inputs.can_adjust_raster_scales = true; 5537 inputs.can_adjust_raster_scales = true;
5537 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); 5538 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs);
5538 5539
5539 // We should have one render surface and one layers. The child has 5540 // We should have one render surface and one layers. The child has
5540 // hidden itself and the grand child. 5541 // hidden itself and the grand child.
5541 ASSERT_EQ(1u, render_surface_layer_list.size()); 5542 ASSERT_EQ(1u, render_surface_layer_list.size());
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
5621 copy_grand_parent_sibling_after.get(); 5622 copy_grand_parent_sibling_after.get();
5622 5623
5623 copy_child->test_properties()->AddChild(std::move(copy_grand_child)); 5624 copy_child->test_properties()->AddChild(std::move(copy_grand_child));
5624 copy_request->test_properties()->AddChild(std::move(copy_child)); 5625 copy_request->test_properties()->AddChild(std::move(copy_child));
5625 copy_parent->test_properties()->AddChild(std::move(copy_request)); 5626 copy_parent->test_properties()->AddChild(std::move(copy_request));
5626 copy_grand_parent->test_properties()->AddChild(std::move(copy_parent)); 5627 copy_grand_parent->test_properties()->AddChild(std::move(copy_parent));
5627 root->test_properties()->AddChild( 5628 root->test_properties()->AddChild(
5628 std::move(copy_grand_parent_sibling_before)); 5629 std::move(copy_grand_parent_sibling_before));
5629 root->test_properties()->AddChild(std::move(copy_grand_parent)); 5630 root->test_properties()->AddChild(std::move(copy_grand_parent));
5630 root->test_properties()->AddChild(std::move(copy_grand_parent_sibling_after)); 5631 root->test_properties()->AddChild(std::move(copy_grand_parent_sibling_after));
5631 host_impl.pending_tree()->SetRootLayer(std::move(root)); 5632 host_impl.pending_tree()->SetRootLayerForTesting(std::move(root));
5632 5633
5633 // Hide the copy_grand_parent and its subtree. But make a copy request in that 5634 // Hide the copy_grand_parent and its subtree. But make a copy request in that
5634 // hidden subtree on copy_layer. Also hide the copy grand child and its 5635 // hidden subtree on copy_layer. Also hide the copy grand child and its
5635 // subtree. 5636 // subtree.
5636 copy_grand_parent_layer->test_properties()->hide_layer_and_subtree = true; 5637 copy_grand_parent_layer->test_properties()->hide_layer_and_subtree = true;
5637 copy_grand_parent_sibling_before_layer->test_properties() 5638 copy_grand_parent_sibling_before_layer->test_properties()
5638 ->hide_layer_and_subtree = true; 5639 ->hide_layer_and_subtree = true;
5639 copy_grand_parent_sibling_after_layer->test_properties() 5640 copy_grand_parent_sibling_after_layer->test_properties()
5640 ->hide_layer_and_subtree = true; 5641 ->hide_layer_and_subtree = true;
5641 copy_grand_child_layer->test_properties()->hide_layer_and_subtree = true; 5642 copy_grand_child_layer->test_properties()->hide_layer_and_subtree = true;
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
5746 5747
5747 copy_layer->test_properties()->copy_requests.push_back( 5748 copy_layer->test_properties()->copy_requests.push_back(
5748 CopyOutputRequest::CreateRequest(base::Bind(&EmptyCopyOutputCallback))); 5749 CopyOutputRequest::CreateRequest(base::Bind(&EmptyCopyOutputCallback)));
5749 5750
5750 copy_layer->test_properties()->AddChild(std::move(copy_child)); 5751 copy_layer->test_properties()->AddChild(std::move(copy_child));
5751 copy_parent->test_properties()->AddChild(std::move(copy_layer)); 5752 copy_parent->test_properties()->AddChild(std::move(copy_layer));
5752 root->test_properties()->AddChild(std::move(copy_parent)); 5753 root->test_properties()->AddChild(std::move(copy_parent));
5753 5754
5754 LayerImplList render_surface_layer_list; 5755 LayerImplList render_surface_layer_list;
5755 LayerImpl* root_layer = root.get(); 5756 LayerImpl* root_layer = root.get();
5756 root_layer->layer_tree_impl()->SetRootLayer(std::move(root)); 5757 root_layer->layer_tree_impl()->SetRootLayerForTesting(std::move(root));
5757 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( 5758 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs(
5758 root_layer, root_layer->bounds(), &render_surface_layer_list); 5759 root_layer, root_layer->bounds(), &render_surface_layer_list);
5759 inputs.can_adjust_raster_scales = true; 5760 inputs.can_adjust_raster_scales = true;
5760 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); 5761 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs);
5761 5762
5762 // We should have two render surface, as the others are clipped out. 5763 // We should have two render surface, as the others are clipped out.
5763 ASSERT_EQ(2u, render_surface_layer_list.size()); 5764 ASSERT_EQ(2u, render_surface_layer_list.size());
5764 EXPECT_EQ(root_layer->id(), render_surface_layer_list.at(0)->id()); 5765 EXPECT_EQ(root_layer->id(), render_surface_layer_list.at(0)->id());
5765 5766
5766 // The root render surface should only have 2 contributing layer, since the 5767 // The root render surface should only have 2 contributing layer, since the
5767 // other layers are empty/clipped away. 5768 // other layers are empty/clipped away.
5768 ASSERT_EQ(2u, root_layer->render_surface()->layer_list().size()); 5769 ASSERT_EQ(2u, root_layer->render_surface()->layer_list().size());
5769 EXPECT_EQ(root_layer->id(), 5770 EXPECT_EQ(root_layer->id(),
5770 root_layer->render_surface()->layer_list().at(0)->id()); 5771 root_layer->render_surface()->layer_list().at(0)->id());
5771 } 5772 }
5772 5773
5773 TEST_F(LayerTreeHostCommonTest, VisibleRectInNonRootCopyRequest) { 5774 TEST_F(LayerTreeHostCommonTest, VisibleRectInNonRootCopyRequest) {
5774 const gfx::Transform identity_matrix; 5775 const gfx::Transform identity_matrix;
5775 5776
5776 LayerImpl* root = root_layer(); 5777 LayerImpl* root = root_layer_for_testing();
5777 SetLayerPropertiesForTesting(root, identity_matrix, gfx::Point3F(), 5778 SetLayerPropertiesForTesting(root, identity_matrix, gfx::Point3F(),
5778 gfx::PointF(), gfx::Size(50, 50), true, false, 5779 gfx::PointF(), gfx::Size(50, 50), true, false,
5779 true); 5780 true);
5780 root->SetDrawsContent(true); 5781 root->SetDrawsContent(true);
5781 root->SetMasksToBounds(true); 5782 root->SetMasksToBounds(true);
5782 5783
5783 LayerImpl* copy_layer = AddChild<LayerImpl>(root); 5784 LayerImpl* copy_layer = AddChild<LayerImpl>(root);
5784 SetLayerPropertiesForTesting(copy_layer, identity_matrix, gfx::Point3F(), 5785 SetLayerPropertiesForTesting(copy_layer, identity_matrix, gfx::Point3F(),
5785 gfx::PointF(), gfx::Size(100, 100), true, false, 5786 gfx::PointF(), gfx::Size(100, 100), true, false,
5786 true); 5787 true);
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
5827 5828
5828 ExecuteCalculateDrawProperties(root); 5829 ExecuteCalculateDrawProperties(root);
5829 5830
5830 EXPECT_EQ(gfx::Rect(50, 50), copy_layer->visible_layer_rect()); 5831 EXPECT_EQ(gfx::Rect(50, 50), copy_layer->visible_layer_rect());
5831 EXPECT_EQ(gfx::Rect(10, 10), copy_child->visible_layer_rect()); 5832 EXPECT_EQ(gfx::Rect(10, 10), copy_child->visible_layer_rect());
5832 EXPECT_EQ(gfx::Rect(10, 10), copy_clipped_child->visible_layer_rect()); 5833 EXPECT_EQ(gfx::Rect(10, 10), copy_clipped_child->visible_layer_rect());
5833 EXPECT_EQ(gfx::Rect(5, 5), copy_surface->visible_layer_rect()); 5834 EXPECT_EQ(gfx::Rect(5, 5), copy_surface->visible_layer_rect());
5834 } 5835 }
5835 5836
5836 TEST_F(LayerTreeHostCommonTest, VisibleContentRectInsideSurface) { 5837 TEST_F(LayerTreeHostCommonTest, VisibleContentRectInsideSurface) {
5837 LayerImpl* root = root_layer(); 5838 LayerImpl* root = root_layer_for_testing();
5838 LayerImpl* surface = AddChild<LayerImpl>(root); 5839 LayerImpl* surface = AddChild<LayerImpl>(root);
5839 LayerImpl* surface_child = AddChild<LayerImpl>(surface); 5840 LayerImpl* surface_child = AddChild<LayerImpl>(surface);
5840 5841
5841 const gfx::Transform identity_matrix; 5842 const gfx::Transform identity_matrix;
5842 SetLayerPropertiesForTesting(root, identity_matrix, gfx::Point3F(), 5843 SetLayerPropertiesForTesting(root, identity_matrix, gfx::Point3F(),
5843 gfx::PointF(), gfx::Size(50, 50), true, false, 5844 gfx::PointF(), gfx::Size(50, 50), true, false,
5844 true); 5845 true);
5845 SetLayerPropertiesForTesting(surface, identity_matrix, gfx::Point3F(), 5846 SetLayerPropertiesForTesting(surface, identity_matrix, gfx::Point3F(),
5846 gfx::PointF(-10, 20), gfx::Size(), true, false, 5847 gfx::PointF(-10, 20), gfx::Size(), true, false,
5847 true); 5848 true);
(...skipping 15 matching lines...) Expand all
5863 // problem. Constructs the following layer tree. 5864 // problem. Constructs the following layer tree.
5864 // 5865 //
5865 // root (a render surface) 5866 // root (a render surface)
5866 // + render_surface 5867 // + render_surface
5867 // + clip_parent (scaled) 5868 // + clip_parent (scaled)
5868 // + intervening_clipping_layer 5869 // + intervening_clipping_layer
5869 // + clip_child 5870 // + clip_child
5870 // 5871 //
5871 // The render surface should be resized correctly and the clip child should 5872 // The render surface should be resized correctly and the clip child should
5872 // inherit the right clip rect. 5873 // inherit the right clip rect.
5873 LayerImpl* root = root_layer(); 5874 LayerImpl* root = root_layer_for_testing();
5874 LayerImpl* render_surface = AddChildToRoot<LayerImpl>(); 5875 LayerImpl* render_surface = AddChildToRoot<LayerImpl>();
5875 LayerImpl* clip_parent = AddChild<LayerImpl>(render_surface); 5876 LayerImpl* clip_parent = AddChild<LayerImpl>(render_surface);
5876 clip_parent->SetDrawsContent(true); 5877 clip_parent->SetDrawsContent(true);
5877 LayerImpl* intervening = AddChild<LayerImpl>(clip_parent); 5878 LayerImpl* intervening = AddChild<LayerImpl>(clip_parent);
5878 intervening->SetDrawsContent(true); 5879 intervening->SetDrawsContent(true);
5879 LayerImpl* clip_child = AddChild<LayerImpl>(intervening); 5880 LayerImpl* clip_child = AddChild<LayerImpl>(intervening);
5880 clip_child->SetDrawsContent(true); 5881 clip_child->SetDrawsContent(true);
5881 clip_child->test_properties()->clip_parent = clip_parent; 5882 clip_child->test_properties()->clip_parent = clip_parent;
5882 std::unique_ptr<std::set<LayerImpl*>> clip_children(new std::set<LayerImpl*>); 5883 std::unique_ptr<std::set<LayerImpl*>> clip_children(new std::set<LayerImpl*>);
5883 clip_children->insert(clip_child); 5884 clip_children->insert(clip_child);
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
5936 // case. In the following tree, both render surfaces should be resized to 5937 // case. In the following tree, both render surfaces should be resized to
5937 // accomodate for the clip child, despite an intervening clip. 5938 // accomodate for the clip child, despite an intervening clip.
5938 // 5939 //
5939 // root (a render surface) 5940 // root (a render surface)
5940 // + clip_parent (masks to bounds) 5941 // + clip_parent (masks to bounds)
5941 // + render_surface1 (sets opacity) 5942 // + render_surface1 (sets opacity)
5942 // + intervening (masks to bounds) 5943 // + intervening (masks to bounds)
5943 // + render_surface2 (also sets opacity) 5944 // + render_surface2 (also sets opacity)
5944 // + clip_child 5945 // + clip_child
5945 // 5946 //
5946 LayerImpl* root = root_layer(); 5947 LayerImpl* root = root_layer_for_testing();
5947 LayerImpl* clip_parent = AddChildToRoot<LayerImpl>(); 5948 LayerImpl* clip_parent = AddChildToRoot<LayerImpl>();
5948 LayerImpl* render_surface1 = AddChild<LayerImpl>(clip_parent); 5949 LayerImpl* render_surface1 = AddChild<LayerImpl>(clip_parent);
5949 LayerImpl* intervening = AddChild<LayerImpl>(render_surface1); 5950 LayerImpl* intervening = AddChild<LayerImpl>(render_surface1);
5950 LayerImpl* render_surface2 = AddChild<LayerImpl>(intervening); 5951 LayerImpl* render_surface2 = AddChild<LayerImpl>(intervening);
5951 LayerImpl* clip_child = AddChild<LayerImpl>(render_surface2); 5952 LayerImpl* clip_child = AddChild<LayerImpl>(render_surface2);
5952 render_surface1->SetDrawsContent(true); 5953 render_surface1->SetDrawsContent(true);
5953 render_surface2->SetDrawsContent(true); 5954 render_surface2->SetDrawsContent(true);
5954 clip_child->SetDrawsContent(true); 5955 clip_child->SetDrawsContent(true);
5955 5956
5956 clip_child->test_properties()->clip_parent = clip_parent; 5957 clip_child->test_properties()->clip_parent = clip_parent;
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
6025 // is a scroll involved. Note, we do _not_ have to consider any other sort 6026 // is a scroll involved. Note, we do _not_ have to consider any other sort
6026 // of transform. 6027 // of transform.
6027 // 6028 //
6028 // root (a render surface) 6029 // root (a render surface)
6029 // + clip_parent (masks to bounds) 6030 // + clip_parent (masks to bounds)
6030 // + render_surface1 (sets opacity) 6031 // + render_surface1 (sets opacity)
6031 // + intervening (masks to bounds AND scrolls) 6032 // + intervening (masks to bounds AND scrolls)
6032 // + render_surface2 (also sets opacity) 6033 // + render_surface2 (also sets opacity)
6033 // + clip_child 6034 // + clip_child
6034 // 6035 //
6035 LayerImpl* root = root_layer(); 6036 LayerImpl* root = root_layer_for_testing();
6036 LayerImpl* clip_parent = AddChildToRoot<LayerImpl>(); 6037 LayerImpl* clip_parent = AddChildToRoot<LayerImpl>();
6037 LayerImpl* render_surface1 = AddChild<LayerImpl>(clip_parent); 6038 LayerImpl* render_surface1 = AddChild<LayerImpl>(clip_parent);
6038 LayerImpl* intervening = AddChild<LayerImpl>(render_surface1); 6039 LayerImpl* intervening = AddChild<LayerImpl>(render_surface1);
6039 LayerImpl* render_surface2 = AddChild<LayerImpl>(intervening); 6040 LayerImpl* render_surface2 = AddChild<LayerImpl>(intervening);
6040 LayerImpl* clip_child = AddChild<LayerImpl>(render_surface2); 6041 LayerImpl* clip_child = AddChild<LayerImpl>(render_surface2);
6041 render_surface1->SetDrawsContent(true); 6042 render_surface1->SetDrawsContent(true);
6042 render_surface2->SetDrawsContent(true); 6043 render_surface2->SetDrawsContent(true);
6043 clip_child->SetDrawsContent(true); 6044 clip_child->SetDrawsContent(true);
6044 6045
6045 clip_child->test_properties()->clip_parent = clip_parent; 6046 clip_child->test_properties()->clip_parent = clip_parent;
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
6113 6114
6114 TEST_F(LayerTreeHostCommonTest, DescendantsOfClipChildren) { 6115 TEST_F(LayerTreeHostCommonTest, DescendantsOfClipChildren) {
6115 // Ensures that descendants of the clip child inherit the correct clip. 6116 // Ensures that descendants of the clip child inherit the correct clip.
6116 // 6117 //
6117 // root (a render surface) 6118 // root (a render surface)
6118 // + clip_parent (masks to bounds) 6119 // + clip_parent (masks to bounds)
6119 // + intervening (masks to bounds) 6120 // + intervening (masks to bounds)
6120 // + clip_child 6121 // + clip_child
6121 // + child 6122 // + child
6122 // 6123 //
6123 LayerImpl* root = root_layer(); 6124 LayerImpl* root = root_layer_for_testing();
6124 LayerImpl* clip_parent = AddChild<LayerImpl>(root); 6125 LayerImpl* clip_parent = AddChild<LayerImpl>(root);
6125 LayerImpl* intervening = AddChild<LayerImpl>(clip_parent); 6126 LayerImpl* intervening = AddChild<LayerImpl>(clip_parent);
6126 LayerImpl* clip_child = AddChild<LayerImpl>(intervening); 6127 LayerImpl* clip_child = AddChild<LayerImpl>(intervening);
6127 LayerImpl* child = AddChild<LayerImpl>(clip_child); 6128 LayerImpl* child = AddChild<LayerImpl>(clip_child);
6128 clip_child->SetDrawsContent(true); 6129 clip_child->SetDrawsContent(true);
6129 child->SetDrawsContent(true); 6130 child->SetDrawsContent(true);
6130 6131
6131 clip_child->test_properties()->clip_parent = clip_parent; 6132 clip_child->test_properties()->clip_parent = clip_parent;
6132 std::unique_ptr<std::set<LayerImpl*>> clip_children(new std::set<LayerImpl*>); 6133 std::unique_ptr<std::set<LayerImpl*>> clip_children(new std::set<LayerImpl*>);
6133 clip_children->insert(clip_child); 6134 clip_children->insert(clip_child);
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
6171 // render surfaces. 6172 // render surfaces.
6172 // 6173 //
6173 // root (a render surface) 6174 // root (a render surface)
6174 // + clip_parent (masks to bounds) 6175 // + clip_parent (masks to bounds)
6175 // + render_surface1 6176 // + render_surface1
6176 // + clip_child 6177 // + clip_child
6177 // + render_surface2 6178 // + render_surface2
6178 // + non_clip_child 6179 // + non_clip_child
6179 // 6180 //
6180 // In this example render_surface2 should be unaffected by clip_child. 6181 // In this example render_surface2 should be unaffected by clip_child.
6181 LayerImpl* root = root_layer(); 6182 LayerImpl* root = root_layer_for_testing();
6182 LayerImpl* clip_parent = AddChildToRoot<LayerImpl>(); 6183 LayerImpl* clip_parent = AddChildToRoot<LayerImpl>();
6183 LayerImpl* render_surface1 = AddChild<LayerImpl>(clip_parent); 6184 LayerImpl* render_surface1 = AddChild<LayerImpl>(clip_parent);
6184 render_surface1->SetDrawsContent(true); 6185 render_surface1->SetDrawsContent(true);
6185 LayerImpl* clip_child = AddChild<LayerImpl>(render_surface1); 6186 LayerImpl* clip_child = AddChild<LayerImpl>(render_surface1);
6186 clip_child->SetDrawsContent(true); 6187 clip_child->SetDrawsContent(true);
6187 LayerImpl* render_surface2 = AddChild<LayerImpl>(clip_parent); 6188 LayerImpl* render_surface2 = AddChild<LayerImpl>(clip_parent);
6188 render_surface2->SetDrawsContent(true); 6189 render_surface2->SetDrawsContent(true);
6189 LayerImpl* non_clip_child = AddChild<LayerImpl>(render_surface2); 6190 LayerImpl* non_clip_child = AddChild<LayerImpl>(render_surface2);
6190 non_clip_child->SetDrawsContent(true); 6191 non_clip_child->SetDrawsContent(true);
6191 6192
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
6249 6250
6250 // Sanity check our num_unclipped_descendants values. 6251 // Sanity check our num_unclipped_descendants values.
6251 EXPECT_EQ(1u, render_surface1->test_properties()->num_unclipped_descendants); 6252 EXPECT_EQ(1u, render_surface1->test_properties()->num_unclipped_descendants);
6252 EXPECT_EQ(0u, render_surface2->test_properties()->num_unclipped_descendants); 6253 EXPECT_EQ(0u, render_surface2->test_properties()->num_unclipped_descendants);
6253 } 6254 }
6254 6255
6255 TEST_F(LayerTreeHostCommonTest, 6256 TEST_F(LayerTreeHostCommonTest,
6256 CreateRenderSurfaceWhenFlattenInsideRenderingContext) { 6257 CreateRenderSurfaceWhenFlattenInsideRenderingContext) {
6257 // Verifies that Render Surfaces are created at the edge of rendering context. 6258 // Verifies that Render Surfaces are created at the edge of rendering context.
6258 6259
6259 LayerImpl* root = root_layer(); 6260 LayerImpl* root = root_layer_for_testing();
6260 LayerImpl* child1 = AddChildToRoot<LayerImpl>(); 6261 LayerImpl* child1 = AddChildToRoot<LayerImpl>();
6261 LayerImpl* child2 = AddChild<LayerImpl>(child1); 6262 LayerImpl* child2 = AddChild<LayerImpl>(child1);
6262 LayerImpl* child3 = AddChild<LayerImpl>(child2); 6263 LayerImpl* child3 = AddChild<LayerImpl>(child2);
6263 root->SetDrawsContent(true); 6264 root->SetDrawsContent(true);
6264 6265
6265 const gfx::Transform identity_matrix; 6266 const gfx::Transform identity_matrix;
6266 gfx::Point3F transform_origin; 6267 gfx::Point3F transform_origin;
6267 gfx::PointF position; 6268 gfx::PointF position;
6268 gfx::Size bounds(100, 100); 6269 gfx::Size bounds(100, 100);
6269 6270
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
6327 position, bounds, true, false, false); 6328 position, bounds, true, false, false);
6328 child3->SetDrawsContent(true); 6329 child3->SetDrawsContent(true);
6329 6330
6330 child2->Set3dSortingContextId(1); 6331 child2->Set3dSortingContextId(1);
6331 child3->Set3dSortingContextId(1); 6332 child3->Set3dSortingContextId(1);
6332 6333
6333 child2->test_properties()->AddChild(std::move(child3)); 6334 child2->test_properties()->AddChild(std::move(child3));
6334 child1->test_properties()->AddChild(std::move(child2)); 6335 child1->test_properties()->AddChild(std::move(child2));
6335 root->test_properties()->AddChild(std::move(child1)); 6336 root->test_properties()->AddChild(std::move(child1));
6336 LayerImpl* root_layer = root.get(); 6337 LayerImpl* root_layer = root.get();
6337 root_layer->layer_tree_impl()->SetRootLayer(std::move(root)); 6338 root_layer->layer_tree_impl()->SetRootLayerForTesting(std::move(root));
6338 6339
6339 { 6340 {
6340 LayerImplList render_surface_layer_list; 6341 LayerImplList render_surface_layer_list;
6341 FakeLayerTreeHostImpl::RecursiveUpdateNumChildren(root_layer); 6342 FakeLayerTreeHostImpl::RecursiveUpdateNumChildren(root_layer);
6342 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( 6343 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs(
6343 root_layer, root_layer->bounds(), &render_surface_layer_list); 6344 root_layer, root_layer->bounds(), &render_surface_layer_list);
6344 inputs.can_render_to_separate_surface = true; 6345 inputs.can_render_to_separate_surface = true;
6345 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); 6346 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs);
6346 6347
6347 EXPECT_EQ(2u, render_surface_layer_list.size()); 6348 EXPECT_EQ(2u, render_surface_layer_list.size());
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
6394 // Only root layer has a render surface. 6395 // Only root layer has a render surface.
6395 EXPECT_EQ(1, count_represents_target_render_surface); 6396 EXPECT_EQ(1, count_represents_target_render_surface);
6396 // No layer contributes a render surface to root render surface. 6397 // No layer contributes a render surface to root render surface.
6397 EXPECT_EQ(0, count_represents_contributing_render_surface); 6398 EXPECT_EQ(0, count_represents_contributing_render_surface);
6398 // All 4 layers represent itself. 6399 // All 4 layers represent itself.
6399 EXPECT_EQ(4, count_represents_itself); 6400 EXPECT_EQ(4, count_represents_itself);
6400 } 6401 }
6401 } 6402 }
6402 6403
6403 TEST_F(LayerTreeHostCommonTest, DoNotIncludeBackfaceInvisibleSurfaces) { 6404 TEST_F(LayerTreeHostCommonTest, DoNotIncludeBackfaceInvisibleSurfaces) {
6404 LayerImpl* root = root_layer(); 6405 LayerImpl* root = root_layer_for_testing();
6405 LayerImpl* back_facing = AddChild<LayerImpl>(root); 6406 LayerImpl* back_facing = AddChild<LayerImpl>(root);
6406 LayerImpl* render_surface1 = AddChild<LayerImpl>(back_facing); 6407 LayerImpl* render_surface1 = AddChild<LayerImpl>(back_facing);
6407 LayerImpl* render_surface2 = AddChild<LayerImpl>(back_facing); 6408 LayerImpl* render_surface2 = AddChild<LayerImpl>(back_facing);
6408 LayerImpl* child1 = AddChild<LayerImpl>(render_surface1); 6409 LayerImpl* child1 = AddChild<LayerImpl>(render_surface1);
6409 LayerImpl* child2 = AddChild<LayerImpl>(render_surface2); 6410 LayerImpl* child2 = AddChild<LayerImpl>(render_surface2);
6410 child1->SetDrawsContent(true); 6411 child1->SetDrawsContent(true);
6411 child2->SetDrawsContent(true); 6412 child2->SetDrawsContent(true);
6412 6413
6413 gfx::Transform identity_transform; 6414 gfx::Transform identity_transform;
6414 SetLayerPropertiesForTesting(root, identity_transform, gfx::Point3F(), 6415 SetLayerPropertiesForTesting(root, identity_transform, gfx::Point3F(),
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
6468 // context. 6469 // context.
6469 EXPECT_EQ(2u, render_surface_layer_list_impl()->size()); 6470 EXPECT_EQ(2u, render_surface_layer_list_impl()->size());
6470 EXPECT_EQ(1u, render_surface_layer_list_impl() 6471 EXPECT_EQ(1u, render_surface_layer_list_impl()
6471 ->at(0) 6472 ->at(0)
6472 ->render_surface() 6473 ->render_surface()
6473 ->layer_list() 6474 ->layer_list()
6474 .size()); 6475 .size());
6475 } 6476 }
6476 6477
6477 TEST_F(LayerTreeHostCommonTest, DoNotIncludeBackfaceInvisibleLayers) { 6478 TEST_F(LayerTreeHostCommonTest, DoNotIncludeBackfaceInvisibleLayers) {
6478 LayerImpl* root = root_layer(); 6479 LayerImpl* root = root_layer_for_testing();
6479 LayerImpl* child = AddChild<LayerImpl>(root); 6480 LayerImpl* child = AddChild<LayerImpl>(root);
6480 LayerImpl* grand_child = AddChild<LayerImpl>(child); 6481 LayerImpl* grand_child = AddChild<LayerImpl>(child);
6481 grand_child->SetDrawsContent(true); 6482 grand_child->SetDrawsContent(true);
6482 6483
6483 child->test_properties()->double_sided = false; 6484 child->test_properties()->double_sided = false;
6484 grand_child->SetUseParentBackfaceVisibility(true); 6485 grand_child->SetUseParentBackfaceVisibility(true);
6485 6486
6486 gfx::Transform identity_transform; 6487 gfx::Transform identity_transform;
6487 SetLayerPropertiesForTesting(root, identity_transform, gfx::Point3F(), 6488 SetLayerPropertiesForTesting(root, identity_transform, gfx::Point3F(),
6488 gfx::PointF(), gfx::Size(50, 50), false, false, 6489 gfx::PointF(), gfx::Size(50, 50), false, false,
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
6562 EXPECT_TRUE(child->should_check_backface_visibility()); 6563 EXPECT_TRUE(child->should_check_backface_visibility());
6563 EXPECT_TRUE(grand_child->should_check_backface_visibility()); 6564 EXPECT_TRUE(grand_child->should_check_backface_visibility());
6564 // grand_child is in an existing 3d rendering context, so it should not use 6565 // grand_child is in an existing 3d rendering context, so it should not use
6565 // local transform for backface visibility. 6566 // local transform for backface visibility.
6566 EXPECT_TRUE(root->use_local_transform_for_backface_visibility()); 6567 EXPECT_TRUE(root->use_local_transform_for_backface_visibility());
6567 EXPECT_TRUE(child->use_local_transform_for_backface_visibility()); 6568 EXPECT_TRUE(child->use_local_transform_for_backface_visibility());
6568 EXPECT_FALSE(grand_child->use_local_transform_for_backface_visibility()); 6569 EXPECT_FALSE(grand_child->use_local_transform_for_backface_visibility());
6569 } 6570 }
6570 6571
6571 TEST_F(LayerTreeHostCommonTest, TransformAnimationUpdatesBackfaceVisibility) { 6572 TEST_F(LayerTreeHostCommonTest, TransformAnimationUpdatesBackfaceVisibility) {
6572 LayerImpl* root = root_layer(); 6573 LayerImpl* root = root_layer_for_testing();
6573 LayerImpl* back_facing = AddChild<LayerImpl>(root); 6574 LayerImpl* back_facing = AddChild<LayerImpl>(root);
6574 LayerImpl* render_surface1 = AddChild<LayerImpl>(back_facing); 6575 LayerImpl* render_surface1 = AddChild<LayerImpl>(back_facing);
6575 LayerImpl* render_surface2 = AddChild<LayerImpl>(back_facing); 6576 LayerImpl* render_surface2 = AddChild<LayerImpl>(back_facing);
6576 6577
6577 gfx::Transform identity_transform; 6578 gfx::Transform identity_transform;
6578 gfx::Transform rotate_about_y; 6579 gfx::Transform rotate_about_y;
6579 rotate_about_y.RotateAboutYAxis(180.0); 6580 rotate_about_y.RotateAboutYAxis(180.0);
6580 SetLayerPropertiesForTesting(root, identity_transform, gfx::Point3F(), 6581 SetLayerPropertiesForTesting(root, identity_transform, gfx::Point3F(),
6581 gfx::PointF(), gfx::Size(50, 50), false, true, 6582 gfx::PointF(), gfx::Size(50, 50), false, true,
6582 true); 6583 true);
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
6621 TEST_F(LayerTreeHostCommonTest, ClippedByScrollParent) { 6622 TEST_F(LayerTreeHostCommonTest, ClippedByScrollParent) {
6622 // Checks that the simple case (being clipped by a scroll parent that would 6623 // Checks that the simple case (being clipped by a scroll parent that would
6623 // have been processed before you anyhow) results in the right clips. 6624 // have been processed before you anyhow) results in the right clips.
6624 // 6625 //
6625 // + root 6626 // + root
6626 // + scroll_parent_border 6627 // + scroll_parent_border
6627 // | + scroll_parent_clip 6628 // | + scroll_parent_clip
6628 // | + scroll_parent 6629 // | + scroll_parent
6629 // + scroll_child 6630 // + scroll_child
6630 // 6631 //
6631 LayerImpl* root = root_layer(); 6632 LayerImpl* root = root_layer_for_testing();
6632 LayerImpl* scroll_parent_border = AddChildToRoot<LayerImpl>(); 6633 LayerImpl* scroll_parent_border = AddChildToRoot<LayerImpl>();
6633 LayerImpl* scroll_parent_clip = AddChild<LayerImpl>(scroll_parent_border); 6634 LayerImpl* scroll_parent_clip = AddChild<LayerImpl>(scroll_parent_border);
6634 LayerImpl* scroll_parent = AddChild<LayerImpl>(scroll_parent_clip); 6635 LayerImpl* scroll_parent = AddChild<LayerImpl>(scroll_parent_clip);
6635 LayerImpl* scroll_child = AddChild<LayerImpl>(root); 6636 LayerImpl* scroll_child = AddChild<LayerImpl>(root);
6636 6637
6637 scroll_parent->SetDrawsContent(true); 6638 scroll_parent->SetDrawsContent(true);
6638 scroll_child->SetDrawsContent(true); 6639 scroll_child->SetDrawsContent(true);
6639 scroll_parent_clip->SetMasksToBounds(true); 6640 scroll_parent_clip->SetMasksToBounds(true);
6640 6641
6641 scroll_child->test_properties()->scroll_parent = scroll_parent; 6642 scroll_child->test_properties()->scroll_parent = scroll_parent;
(...skipping 24 matching lines...) Expand all
6666 6667
6667 EXPECT_TRUE(root->render_surface()); 6668 EXPECT_TRUE(root->render_surface());
6668 6669
6669 EXPECT_EQ(gfx::Rect(0, 0, 30, 30), scroll_child->clip_rect()); 6670 EXPECT_EQ(gfx::Rect(0, 0, 30, 30), scroll_child->clip_rect());
6670 EXPECT_TRUE(scroll_child->is_clipped()); 6671 EXPECT_TRUE(scroll_child->is_clipped());
6671 } 6672 }
6672 6673
6673 TEST_F(LayerTreeHostCommonTest, ScrollChildAndScrollParentDifferentTargets) { 6674 TEST_F(LayerTreeHostCommonTest, ScrollChildAndScrollParentDifferentTargets) {
6674 // Tests the computation of draw transform for the scroll child when its 6675 // Tests the computation of draw transform for the scroll child when its
6675 // target is different from its scroll parent's target. 6676 // target is different from its scroll parent's target.
6676 LayerImpl* root = root_layer(); 6677 LayerImpl* root = root_layer_for_testing();
6677 LayerImpl* scroll_child_target = AddChildToRoot<LayerImpl>(); 6678 LayerImpl* scroll_child_target = AddChildToRoot<LayerImpl>();
6678 LayerImpl* scroll_child = AddChild<LayerImpl>(scroll_child_target); 6679 LayerImpl* scroll_child = AddChild<LayerImpl>(scroll_child_target);
6679 LayerImpl* scroll_parent_target = AddChild<LayerImpl>(scroll_child_target); 6680 LayerImpl* scroll_parent_target = AddChild<LayerImpl>(scroll_child_target);
6680 LayerImpl* scroll_parent = AddChild<LayerImpl>(scroll_parent_target); 6681 LayerImpl* scroll_parent = AddChild<LayerImpl>(scroll_parent_target);
6681 6682
6682 scroll_parent->SetDrawsContent(true); 6683 scroll_parent->SetDrawsContent(true);
6683 scroll_child->SetDrawsContent(true); 6684 scroll_child->SetDrawsContent(true);
6684 6685
6685 scroll_child->test_properties()->scroll_parent = scroll_parent; 6686 scroll_child->test_properties()->scroll_parent = scroll_parent;
6686 std::unique_ptr<std::set<LayerImpl*>> scroll_children( 6687 std::unique_ptr<std::set<LayerImpl*>> scroll_children(
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
6718 EXPECT_EQ(scroll_child->effect_tree_index(), 6719 EXPECT_EQ(scroll_child->effect_tree_index(),
6719 scroll_child_target->effect_tree_index()); 6720 scroll_child_target->effect_tree_index());
6720 EXPECT_EQ(scroll_child->visible_layer_rect(), gfx::Rect(10, 10, 40, 40)); 6721 EXPECT_EQ(scroll_child->visible_layer_rect(), gfx::Rect(10, 10, 40, 40));
6721 EXPECT_EQ(scroll_child->clip_rect(), gfx::Rect(15, 15, 75, 75)); 6722 EXPECT_EQ(scroll_child->clip_rect(), gfx::Rect(15, 15, 75, 75));
6722 gfx::Transform scale; 6723 gfx::Transform scale;
6723 scale.Scale(1.5f, 1.5f); 6724 scale.Scale(1.5f, 1.5f);
6724 EXPECT_EQ(scroll_child->DrawTransform(), scale); 6725 EXPECT_EQ(scroll_child->DrawTransform(), scale);
6725 } 6726 }
6726 6727
6727 TEST_F(LayerTreeHostCommonTest, SingularTransformSubtreesDoNotDraw) { 6728 TEST_F(LayerTreeHostCommonTest, SingularTransformSubtreesDoNotDraw) {
6728 LayerImpl* root = root_layer(); 6729 LayerImpl* root = root_layer_for_testing();
6729 root->SetDrawsContent(true); 6730 root->SetDrawsContent(true);
6730 LayerImpl* parent = AddChildToRoot<LayerImpl>(); 6731 LayerImpl* parent = AddChildToRoot<LayerImpl>();
6731 parent->SetDrawsContent(true); 6732 parent->SetDrawsContent(true);
6732 LayerImpl* child = AddChild<LayerImpl>(parent); 6733 LayerImpl* child = AddChild<LayerImpl>(parent);
6733 child->SetDrawsContent(true); 6734 child->SetDrawsContent(true);
6734 6735
6735 gfx::Transform identity_transform; 6736 gfx::Transform identity_transform;
6736 SetLayerPropertiesForTesting(root, identity_transform, gfx::Point3F(), 6737 SetLayerPropertiesForTesting(root, identity_transform, gfx::Point3F(),
6737 gfx::PointF(), gfx::Size(50, 50), true, true, 6738 gfx::PointF(), gfx::Size(50, 50), true, true,
6738 true); 6739 true);
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
6772 TEST_F(LayerTreeHostCommonTest, ClippedByOutOfOrderScrollParent) { 6773 TEST_F(LayerTreeHostCommonTest, ClippedByOutOfOrderScrollParent) {
6773 // Checks that clipping by a scroll parent that follows you in paint order 6774 // Checks that clipping by a scroll parent that follows you in paint order
6774 // still results in correct clipping. 6775 // still results in correct clipping.
6775 // 6776 //
6776 // + root 6777 // + root
6777 // + scroll_parent_border 6778 // + scroll_parent_border
6778 // + scroll_parent_clip 6779 // + scroll_parent_clip
6779 // + scroll_parent 6780 // + scroll_parent
6780 // + scroll_child 6781 // + scroll_child
6781 // 6782 //
6782 LayerImpl* root = root_layer(); 6783 LayerImpl* root = root_layer_for_testing();
6783 LayerImpl* scroll_parent_border = AddChild<LayerImpl>(root); 6784 LayerImpl* scroll_parent_border = AddChild<LayerImpl>(root);
6784 LayerImpl* scroll_parent_clip = AddChild<LayerImpl>(scroll_parent_border); 6785 LayerImpl* scroll_parent_clip = AddChild<LayerImpl>(scroll_parent_border);
6785 LayerImpl* scroll_parent = AddChild<LayerImpl>(scroll_parent_clip); 6786 LayerImpl* scroll_parent = AddChild<LayerImpl>(scroll_parent_clip);
6786 LayerImpl* scroll_child = AddChild<LayerImpl>(root); 6787 LayerImpl* scroll_child = AddChild<LayerImpl>(root);
6787 6788
6788 scroll_parent->SetDrawsContent(true); 6789 scroll_parent->SetDrawsContent(true);
6789 scroll_child->SetDrawsContent(true); 6790 scroll_child->SetDrawsContent(true);
6790 6791
6791 scroll_parent_clip->SetMasksToBounds(true); 6792 scroll_parent_clip->SetMasksToBounds(true);
6792 6793
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
6828 // 6829 //
6829 // + root 6830 // + root
6830 // + scroll_child 6831 // + scroll_child
6831 // + scroll_parent_border 6832 // + scroll_parent_border
6832 // | + scroll_parent_clip 6833 // | + scroll_parent_clip
6833 // | + scroll_parent 6834 // | + scroll_parent
6834 // + scroll_grandparent_border 6835 // + scroll_grandparent_border
6835 // + scroll_grandparent_clip 6836 // + scroll_grandparent_clip
6836 // + scroll_grandparent 6837 // + scroll_grandparent
6837 // 6838 //
6838 LayerImpl* root = root_layer(); 6839 LayerImpl* root = root_layer_for_testing();
6839 LayerImpl* scroll_child = AddChild<LayerImpl>(root); 6840 LayerImpl* scroll_child = AddChild<LayerImpl>(root);
6840 LayerImpl* scroll_parent_border = AddChild<LayerImpl>(root); 6841 LayerImpl* scroll_parent_border = AddChild<LayerImpl>(root);
6841 LayerImpl* scroll_parent_clip = AddChild<LayerImpl>(scroll_parent_border); 6842 LayerImpl* scroll_parent_clip = AddChild<LayerImpl>(scroll_parent_border);
6842 LayerImpl* scroll_parent = AddChild<LayerImpl>(scroll_parent_clip); 6843 LayerImpl* scroll_parent = AddChild<LayerImpl>(scroll_parent_clip);
6843 LayerImpl* scroll_grandparent_border = AddChild<LayerImpl>(root); 6844 LayerImpl* scroll_grandparent_border = AddChild<LayerImpl>(root);
6844 LayerImpl* scroll_grandparent_clip = 6845 LayerImpl* scroll_grandparent_clip =
6845 AddChild<LayerImpl>(scroll_grandparent_border); 6846 AddChild<LayerImpl>(scroll_grandparent_border);
6846 LayerImpl* scroll_grandparent = AddChild<LayerImpl>(scroll_grandparent_clip); 6847 LayerImpl* scroll_grandparent = AddChild<LayerImpl>(scroll_grandparent_clip);
6847 6848
6848 scroll_parent->SetDrawsContent(true); 6849 scroll_parent->SetDrawsContent(true);
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
6913 // + scroll_child 6914 // + scroll_child
6914 // + scroll_parent_border 6915 // + scroll_parent_border
6915 // + scroll_parent_clip 6916 // + scroll_parent_clip
6916 // + scroll_parent 6917 // + scroll_parent
6917 // + render_surface2 6918 // + render_surface2
6918 // + scroll_grandparent_border 6919 // + scroll_grandparent_border
6919 // + scroll_grandparent_clip 6920 // + scroll_grandparent_clip
6920 // + scroll_grandparent 6921 // + scroll_grandparent
6921 // + render_surface1 6922 // + render_surface1
6922 // 6923 //
6923 LayerImpl* root = root_layer(); 6924 LayerImpl* root = root_layer_for_testing();
6924 root->SetDrawsContent(true); 6925 root->SetDrawsContent(true);
6925 6926
6926 LayerImpl* scroll_child = AddChild<LayerImpl>(root); 6927 LayerImpl* scroll_child = AddChild<LayerImpl>(root);
6927 scroll_child->SetDrawsContent(true); 6928 scroll_child->SetDrawsContent(true);
6928 6929
6929 LayerImpl* scroll_parent_border = AddChild<LayerImpl>(root); 6930 LayerImpl* scroll_parent_border = AddChild<LayerImpl>(root);
6930 LayerImpl* scroll_parent_clip = AddChild<LayerImpl>(scroll_parent_border); 6931 LayerImpl* scroll_parent_clip = AddChild<LayerImpl>(scroll_parent_border);
6931 LayerImpl* scroll_parent = AddChild<LayerImpl>(scroll_parent_clip); 6932 LayerImpl* scroll_parent = AddChild<LayerImpl>(scroll_parent_clip);
6932 LayerImpl* render_surface2 = AddChild<LayerImpl>(scroll_parent); 6933 LayerImpl* render_surface2 = AddChild<LayerImpl>(scroll_parent);
6933 LayerImpl* scroll_grandparent_border = AddChild<LayerImpl>(root); 6934 LayerImpl* scroll_grandparent_border = AddChild<LayerImpl>(root);
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
7011 // Ensures that when we have a render surface between a fixed position layer 7012 // Ensures that when we have a render surface between a fixed position layer
7012 // and its container, we compute the fixed position layer's draw transform 7013 // and its container, we compute the fixed position layer's draw transform
7013 // with respect to that intervening render surface, not with respect to its 7014 // with respect to that intervening render surface, not with respect to its
7014 // container's render target. 7015 // container's render target.
7015 // 7016 //
7016 // + root 7017 // + root
7017 // + render_surface 7018 // + render_surface
7018 // + fixed 7019 // + fixed
7019 // + child 7020 // + child
7020 // 7021 //
7021 LayerImpl* root = root_layer(); 7022 LayerImpl* root = root_layer_for_testing();
7022 LayerImpl* render_surface = AddChild<LayerImpl>(root); 7023 LayerImpl* render_surface = AddChild<LayerImpl>(root);
7023 LayerImpl* fixed = AddChild<LayerImpl>(render_surface); 7024 LayerImpl* fixed = AddChild<LayerImpl>(render_surface);
7024 LayerImpl* child = AddChild<LayerImpl>(fixed); 7025 LayerImpl* child = AddChild<LayerImpl>(fixed);
7025 7026
7026 render_surface->SetDrawsContent(true); 7027 render_surface->SetDrawsContent(true);
7027 fixed->SetDrawsContent(true); 7028 fixed->SetDrawsContent(true);
7028 child->SetDrawsContent(true); 7029 child->SetDrawsContent(true);
7029 7030
7030 render_surface->test_properties()->force_render_surface = true; 7031 render_surface->test_properties()->force_render_surface = true;
7031 root->test_properties()->is_container_for_fixed_position_layers = true; 7032 root->test_properties()->is_container_for_fixed_position_layers = true;
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
7129 root->SetDrawsContent(true); 7130 root->SetDrawsContent(true);
7130 container->SetDrawsContent(true); 7131 container->SetDrawsContent(true);
7131 scroller->SetDrawsContent(true); 7132 scroller->SetDrawsContent(true);
7132 fixed->SetDrawsContent(true); 7133 fixed->SetDrawsContent(true);
7133 scroller->test_properties()->AddChild(std::move(fixed)); 7134 scroller->test_properties()->AddChild(std::move(fixed));
7134 container->test_properties()->AddChild(std::move(scroller)); 7135 container->test_properties()->AddChild(std::move(scroller));
7135 root->test_properties()->AddChild(std::move(container)); 7136 root->test_properties()->AddChild(std::move(container));
7136 7137
7137 // Rounded to integers already. 7138 // Rounded to integers already.
7138 { 7139 {
7139 root->layer_tree_impl()->SetRootLayer(std::move(root_ptr)); 7140 root->layer_tree_impl()->SetRootLayerForTesting(std::move(root_ptr));
7140 root->layer_tree_impl()->BuildLayerListAndPropertyTreesForTesting(); 7141 root->layer_tree_impl()->BuildLayerListAndPropertyTreesForTesting();
7141 7142
7142 gfx::Vector2dF scroll_delta(3.0, 5.0); 7143 gfx::Vector2dF scroll_delta(3.0, 5.0);
7143 SetScrollOffsetDelta(scroll_layer, scroll_delta); 7144 SetScrollOffsetDelta(scroll_layer, scroll_delta);
7144 7145
7145 LayerImplList render_surface_layer_list; 7146 LayerImplList render_surface_layer_list;
7146 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( 7147 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs(
7147 root, root->bounds(), &render_surface_layer_list); 7148 root, root->bounds(), &render_surface_layer_list);
7148 root->layer_tree_impl() 7149 root->layer_tree_impl()
7149 ->property_trees() 7150 ->property_trees()
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
7218 ScrollSnappingWithAnimatedScreenSpaceTransform) { 7219 ScrollSnappingWithAnimatedScreenSpaceTransform) {
7219 // This test verifies that a scrolling layer whose screen space transform is 7220 // This test verifies that a scrolling layer whose screen space transform is
7220 // animating doesn't get snapped to integer coordinates. 7221 // animating doesn't get snapped to integer coordinates.
7221 // 7222 //
7222 // + root 7223 // + root
7223 // + animated layer 7224 // + animated layer
7224 // + surface 7225 // + surface
7225 // + container 7226 // + container
7226 // + scroller 7227 // + scroller
7227 // 7228 //
7228 LayerImpl* root = root_layer(); 7229 LayerImpl* root = root_layer_for_testing();
7229 LayerImpl* animated_layer = AddChildToRoot<FakePictureLayerImpl>(); 7230 LayerImpl* animated_layer = AddChildToRoot<FakePictureLayerImpl>();
7230 LayerImpl* surface = AddChild<LayerImpl>(animated_layer); 7231 LayerImpl* surface = AddChild<LayerImpl>(animated_layer);
7231 LayerImpl* container = AddChild<LayerImpl>(surface); 7232 LayerImpl* container = AddChild<LayerImpl>(surface);
7232 LayerImpl* scroller = AddChild<LayerImpl>(container); 7233 LayerImpl* scroller = AddChild<LayerImpl>(container);
7233 scroller->SetScrollClipLayer(container->id()); 7234 scroller->SetScrollClipLayer(container->id());
7234 scroller->SetDrawsContent(true); 7235 scroller->SetDrawsContent(true);
7235 7236
7236 gfx::Transform identity_transform; 7237 gfx::Transform identity_transform;
7237 gfx::Transform start_scale; 7238 gfx::Transform start_scale;
7238 start_scale.Scale(1.5f, 1.5f); 7239 start_scale.Scale(1.5f, 1.5f);
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
7323 gfx::PointF(), gfx::Size(1, 2), true, false, 7324 gfx::PointF(), gfx::Size(1, 2), true, false,
7324 false); 7325 false);
7325 SetLayerPropertiesForTesting(child_raw, identity_matrix, gfx::Point3F(), 7326 SetLayerPropertiesForTesting(child_raw, identity_matrix, gfx::Point3F(),
7326 gfx::PointF(), gfx::Size(1, 2), true, false, 7327 gfx::PointF(), gfx::Size(1, 2), true, false,
7327 false); 7328 false);
7328 7329
7329 SetLayerPropertiesForTesting(grand_child_raw, identity_matrix, gfx::Point3F(), 7330 SetLayerPropertiesForTesting(grand_child_raw, identity_matrix, gfx::Point3F(),
7330 gfx::PointF(), gfx::Size(1, 2), true, false, 7331 gfx::PointF(), gfx::Size(1, 2), true, false,
7331 false); 7332 false);
7332 7333
7333 host_impl.active_tree()->SetRootLayer(std::move(grand_parent)); 7334 host_impl.active_tree()->SetRootLayerForTesting(std::move(grand_parent));
7334 7335
7335 ExecuteCalculateDrawProperties(grand_parent_raw); 7336 ExecuteCalculateDrawProperties(grand_parent_raw);
7336 7337
7337 // No layers have animations. 7338 // No layers have animations.
7338 EXPECT_EQ( 7339 EXPECT_EQ(
7339 0.f, 7340 0.f,
7340 grand_parent_raw->draw_properties().maximum_animation_contents_scale); 7341 grand_parent_raw->draw_properties().maximum_animation_contents_scale);
7341 EXPECT_EQ(0.f, 7342 EXPECT_EQ(0.f,
7342 parent_raw->draw_properties().maximum_animation_contents_scale); 7343 parent_raw->draw_properties().maximum_animation_contents_scale);
7343 EXPECT_EQ(0.f, child_raw->draw_properties().maximum_animation_contents_scale); 7344 EXPECT_EQ(0.f, child_raw->draw_properties().maximum_animation_contents_scale);
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after
7665 LayerImpl* grand_parent_raw = grand_parent.get(); 7666 LayerImpl* grand_parent_raw = grand_parent.get();
7666 LayerImpl* parent_raw = parent.get(); 7667 LayerImpl* parent_raw = parent.get();
7667 LayerImpl* child_raw = child.get(); 7668 LayerImpl* child_raw = child.get();
7668 LayerImpl* grand_child1_raw = grand_child1.get(); 7669 LayerImpl* grand_child1_raw = grand_child1.get();
7669 LayerImpl* grand_child2_raw = grand_child2.get(); 7670 LayerImpl* grand_child2_raw = grand_child2.get();
7670 7671
7671 child->test_properties()->AddChild(std::move(grand_child1)); 7672 child->test_properties()->AddChild(std::move(grand_child1));
7672 child->test_properties()->AddChild(std::move(grand_child2)); 7673 child->test_properties()->AddChild(std::move(grand_child2));
7673 parent->test_properties()->AddChild(std::move(child)); 7674 parent->test_properties()->AddChild(std::move(child));
7674 grand_parent->test_properties()->AddChild(std::move(parent)); 7675 grand_parent->test_properties()->AddChild(std::move(parent));
7675 host_impl.active_tree()->SetRootLayer(std::move(grand_parent)); 7676 host_impl.active_tree()->SetRootLayerForTesting(std::move(grand_parent));
7676 7677
7677 SetLayerPropertiesForTesting(grand_parent_raw, identity_matrix, 7678 SetLayerPropertiesForTesting(grand_parent_raw, identity_matrix,
7678 gfx::Point3F(), gfx::PointF(), gfx::Size(1, 2), 7679 gfx::Point3F(), gfx::PointF(), gfx::Size(1, 2),
7679 true, false, true); 7680 true, false, true);
7680 SetLayerPropertiesForTesting(parent_raw, identity_matrix, gfx::Point3F(), 7681 SetLayerPropertiesForTesting(parent_raw, identity_matrix, gfx::Point3F(),
7681 gfx::PointF(), gfx::Size(1, 2), true, false, 7682 gfx::PointF(), gfx::Size(1, 2), true, false,
7682 false); 7683 false);
7683 7684
7684 SetLayerPropertiesForTesting(child_raw, identity_matrix, gfx::Point3F(), 7685 SetLayerPropertiesForTesting(child_raw, identity_matrix, gfx::Point3F(),
7685 gfx::PointF(), gfx::Size(1, 2), true, false, 7686 gfx::PointF(), gfx::Size(1, 2), true, false,
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
7914 LayerImpl::Create(host_impl.active_tree(), 2); 7915 LayerImpl::Create(host_impl.active_tree(), 2);
7915 LayerImpl* child1_layer = child1.get(); 7916 LayerImpl* child1_layer = child1.get();
7916 std::unique_ptr<LayerImpl> child2 = 7917 std::unique_ptr<LayerImpl> child2 =
7917 LayerImpl::Create(host_impl.active_tree(), 3); 7918 LayerImpl::Create(host_impl.active_tree(), 3);
7918 LayerImpl* child2_layer = child2.get(); 7919 LayerImpl* child2_layer = child2.get();
7919 7920
7920 root->test_properties()->AddChild(std::move(child1)); 7921 root->test_properties()->AddChild(std::move(child1));
7921 root->test_properties()->AddChild(std::move(child2)); 7922 root->test_properties()->AddChild(std::move(child2));
7922 root->test_properties()->force_render_surface = true; 7923 root->test_properties()->force_render_surface = true;
7923 root->SetDrawsContent(true); 7924 root->SetDrawsContent(true);
7924 host_impl.active_tree()->SetRootLayer(std::move(root)); 7925 host_impl.active_tree()->SetRootLayerForTesting(std::move(root));
7925 7926
7926 gfx::Transform identity_matrix, scale_transform_child1, 7927 gfx::Transform identity_matrix, scale_transform_child1,
7927 scale_transform_child2; 7928 scale_transform_child2;
7928 scale_transform_child1.Scale(2, 3); 7929 scale_transform_child1.Scale(2, 3);
7929 scale_transform_child2.Scale(4, 5); 7930 scale_transform_child2.Scale(4, 5);
7930 7931
7931 SetLayerPropertiesForTesting(root_layer, identity_matrix, gfx::Point3F(), 7932 SetLayerPropertiesForTesting(root_layer, identity_matrix, gfx::Point3F(),
7932 gfx::PointF(), gfx::Size(1, 1), true, false, 7933 gfx::PointF(), gfx::Size(1, 1), true, false,
7933 true); 7934 true);
7934 SetLayerPropertiesForTesting(child1_layer, scale_transform_child1, 7935 SetLayerPropertiesForTesting(child1_layer, scale_transform_child1,
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
8035 8036
8036 EXPECT_FLOAT_EQ( 8037 EXPECT_FLOAT_EQ(
8037 0.f, root_layer->draw_properties().maximum_animation_contents_scale); 8038 0.f, root_layer->draw_properties().maximum_animation_contents_scale);
8038 EXPECT_FLOAT_EQ( 8039 EXPECT_FLOAT_EQ(
8039 0.f, child1_layer->draw_properties().maximum_animation_contents_scale); 8040 0.f, child1_layer->draw_properties().maximum_animation_contents_scale);
8040 EXPECT_FLOAT_EQ( 8041 EXPECT_FLOAT_EQ(
8041 96.f, child2_layer->draw_properties().maximum_animation_contents_scale); 8042 96.f, child2_layer->draw_properties().maximum_animation_contents_scale);
8042 } 8043 }
8043 8044
8044 TEST_F(LayerTreeHostCommonTest, VisibleContentRectInChildRenderSurface) { 8045 TEST_F(LayerTreeHostCommonTest, VisibleContentRectInChildRenderSurface) {
8045 LayerImpl* root = root_layer(); 8046 LayerImpl* root = root_layer_for_testing();
8046 LayerImpl* clip = AddChild<LayerImpl>(root); 8047 LayerImpl* clip = AddChild<LayerImpl>(root);
8047 LayerImpl* content = AddChild<LayerImpl>(clip); 8048 LayerImpl* content = AddChild<LayerImpl>(clip);
8048 8049
8049 const gfx::Transform identity_matrix; 8050 const gfx::Transform identity_matrix;
8050 SetLayerPropertiesForTesting(root, identity_matrix, gfx::Point3F(), 8051 SetLayerPropertiesForTesting(root, identity_matrix, gfx::Point3F(),
8051 gfx::PointF(), gfx::Size(768 / 2, 3000), true, 8052 gfx::PointF(), gfx::Size(768 / 2, 3000), true,
8052 false, true); 8053 false, true);
8053 SetLayerPropertiesForTesting(clip, identity_matrix, gfx::Point3F(), 8054 SetLayerPropertiesForTesting(clip, identity_matrix, gfx::Point3F(),
8054 gfx::PointF(), gfx::Size(768 / 2, 10000), true, 8055 gfx::PointF(), gfx::Size(768 / 2, 10000), true,
8055 false, false); 8056 false, false);
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
8092 gfx::Size root_size = gfx::Size(300, 500); 8093 gfx::Size root_size = gfx::Size(300, 500);
8093 8094
8094 // Sublayer should be bigger than the root enlarged by bounds_delta. 8095 // Sublayer should be bigger than the root enlarged by bounds_delta.
8095 gfx::Size sublayer_size = gfx::Size(300, 1000); 8096 gfx::Size sublayer_size = gfx::Size(300, 1000);
8096 8097
8097 // Device viewport accomidated the root and the top controls. 8098 // Device viewport accomidated the root and the top controls.
8098 gfx::Size device_viewport_size = gfx::Size(300, 600); 8099 gfx::Size device_viewport_size = gfx::Size(300, 600);
8099 gfx::Transform identity_matrix; 8100 gfx::Transform identity_matrix;
8100 8101
8101 host_impl.SetViewportSize(device_viewport_size); 8102 host_impl.SetViewportSize(device_viewport_size);
8102 host_impl.active_tree()->SetRootLayer( 8103 host_impl.active_tree()->SetRootLayerForTesting(
8103 LayerImpl::Create(host_impl.active_tree(), 1)); 8104 LayerImpl::Create(host_impl.active_tree(), 1));
8104 8105
8105 LayerImpl* root = host_impl.active_tree()->root_layer(); 8106 LayerImpl* root = host_impl.active_tree()->root_layer_for_testing();
8106 SetLayerPropertiesForTesting(root, 8107 SetLayerPropertiesForTesting(root,
8107 identity_matrix, 8108 identity_matrix,
8108 gfx::Point3F(), 8109 gfx::Point3F(),
8109 gfx::PointF(), 8110 gfx::PointF(),
8110 root_size, 8111 root_size,
8111 false, 8112 false,
8112 false, 8113 false,
8113 true); 8114 true);
8114 root->SetMasksToBounds(true); 8115 root->SetMasksToBounds(true);
8115 8116
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
8298 // means the clip cannot be projected into |surface|'s space, so we treat 8299 // means the clip cannot be projected into |surface|'s space, so we treat
8299 // |surface| and layers that draw into it as having empty visible rect. 8300 // |surface| and layers that draw into it as having empty visible rect.
8300 EXPECT_EQ(gfx::Rect(), surface->visible_layer_rect_for_testing()); 8301 EXPECT_EQ(gfx::Rect(), surface->visible_layer_rect_for_testing());
8301 EXPECT_EQ(gfx::Rect(), 8302 EXPECT_EQ(gfx::Rect(),
8302 descendant_of_animation->visible_layer_rect_for_testing()); 8303 descendant_of_animation->visible_layer_rect_for_testing());
8303 } 8304 }
8304 8305
8305 // Verify that having an animated filter (but no current filter, as these 8306 // Verify that having an animated filter (but no current filter, as these
8306 // are mutually exclusive) correctly creates a render surface. 8307 // are mutually exclusive) correctly creates a render surface.
8307 TEST_F(LayerTreeHostCommonTest, AnimatedFilterCreatesRenderSurface) { 8308 TEST_F(LayerTreeHostCommonTest, AnimatedFilterCreatesRenderSurface) {
8308 LayerImpl* root = root_layer(); 8309 LayerImpl* root = root_layer_for_testing();
8309 LayerImpl* child = AddChild<LayerImpl>(root); 8310 LayerImpl* child = AddChild<LayerImpl>(root);
8310 LayerImpl* grandchild = AddChild<LayerImpl>(child); 8311 LayerImpl* grandchild = AddChild<LayerImpl>(child);
8311 8312
8312 gfx::Transform identity_transform; 8313 gfx::Transform identity_transform;
8313 SetLayerPropertiesForTesting(root, identity_transform, gfx::Point3F(), 8314 SetLayerPropertiesForTesting(root, identity_transform, gfx::Point3F(),
8314 gfx::PointF(), gfx::Size(50, 50), true, false); 8315 gfx::PointF(), gfx::Size(50, 50), true, false);
8315 SetLayerPropertiesForTesting(child, identity_transform, gfx::Point3F(), 8316 SetLayerPropertiesForTesting(child, identity_transform, gfx::Point3F(),
8316 gfx::PointF(), gfx::Size(50, 50), true, false); 8317 gfx::PointF(), gfx::Size(50, 50), true, false);
8317 SetLayerPropertiesForTesting(grandchild, identity_transform, gfx::Point3F(), 8318 SetLayerPropertiesForTesting(grandchild, identity_transform, gfx::Point3F(),
8318 gfx::PointF(), gfx::Size(50, 50), true, false); 8319 gfx::PointF(), gfx::Size(50, 50), true, false);
(...skipping 11 matching lines...) Expand all
8330 EXPECT_TRUE(grandchild->filters().IsEmpty()); 8331 EXPECT_TRUE(grandchild->filters().IsEmpty());
8331 8332
8332 EXPECT_FALSE(root->FilterIsAnimating()); 8333 EXPECT_FALSE(root->FilterIsAnimating());
8333 EXPECT_TRUE(child->FilterIsAnimating()); 8334 EXPECT_TRUE(child->FilterIsAnimating());
8334 EXPECT_FALSE(grandchild->FilterIsAnimating()); 8335 EXPECT_FALSE(grandchild->FilterIsAnimating());
8335 } 8336 }
8336 8337
8337 // Verify that having a filter animation with a delayed start time creates a 8338 // Verify that having a filter animation with a delayed start time creates a
8338 // render surface. 8339 // render surface.
8339 TEST_F(LayerTreeHostCommonTest, DelayedFilterAnimationCreatesRenderSurface) { 8340 TEST_F(LayerTreeHostCommonTest, DelayedFilterAnimationCreatesRenderSurface) {
8340 LayerImpl* root = root_layer(); 8341 LayerImpl* root = root_layer_for_testing();
8341 LayerImpl* child = AddChild<LayerImpl>(root); 8342 LayerImpl* child = AddChild<LayerImpl>(root);
8342 LayerImpl* grandchild = AddChild<LayerImpl>(child); 8343 LayerImpl* grandchild = AddChild<LayerImpl>(child);
8343 8344
8344 gfx::Transform identity_transform; 8345 gfx::Transform identity_transform;
8345 SetLayerPropertiesForTesting(root, identity_transform, gfx::Point3F(), 8346 SetLayerPropertiesForTesting(root, identity_transform, gfx::Point3F(),
8346 gfx::PointF(), gfx::Size(50, 50), true, false); 8347 gfx::PointF(), gfx::Size(50, 50), true, false);
8347 SetLayerPropertiesForTesting(child, identity_transform, gfx::Point3F(), 8348 SetLayerPropertiesForTesting(child, identity_transform, gfx::Point3F(),
8348 gfx::PointF(), gfx::Size(50, 50), true, false); 8349 gfx::PointF(), gfx::Size(50, 50), true, false);
8349 SetLayerPropertiesForTesting(grandchild, identity_transform, gfx::Point3F(), 8350 SetLayerPropertiesForTesting(grandchild, identity_transform, gfx::Point3F(),
8350 gfx::PointF(), gfx::Size(50, 50), true, false); 8351 gfx::PointF(), gfx::Size(50, 50), true, false);
(...skipping 29 matching lines...) Expand all
8380 EXPECT_FALSE(root->HasPotentiallyRunningFilterAnimation()); 8381 EXPECT_FALSE(root->HasPotentiallyRunningFilterAnimation());
8381 EXPECT_FALSE(child->FilterIsAnimating()); 8382 EXPECT_FALSE(child->FilterIsAnimating());
8382 EXPECT_TRUE(child->HasPotentiallyRunningFilterAnimation()); 8383 EXPECT_TRUE(child->HasPotentiallyRunningFilterAnimation());
8383 EXPECT_FALSE(grandchild->FilterIsAnimating()); 8384 EXPECT_FALSE(grandchild->FilterIsAnimating());
8384 EXPECT_FALSE(grandchild->HasPotentiallyRunningFilterAnimation()); 8385 EXPECT_FALSE(grandchild->HasPotentiallyRunningFilterAnimation());
8385 } 8386 }
8386 8387
8387 // Ensures that the property tree code accounts for offsets between fixed 8388 // Ensures that the property tree code accounts for offsets between fixed
8388 // position layers and their respective containers. 8389 // position layers and their respective containers.
8389 TEST_F(LayerTreeHostCommonTest, PropertyTreesAccountForFixedParentOffset) { 8390 TEST_F(LayerTreeHostCommonTest, PropertyTreesAccountForFixedParentOffset) {
8390 LayerImpl* root = root_layer(); 8391 LayerImpl* root = root_layer_for_testing();
8391 LayerImpl* child = AddChild<LayerImpl>(root); 8392 LayerImpl* child = AddChild<LayerImpl>(root);
8392 LayerImpl* grandchild = AddChild<LayerImpl>(child); 8393 LayerImpl* grandchild = AddChild<LayerImpl>(child);
8393 8394
8394 gfx::Transform identity_transform; 8395 gfx::Transform identity_transform;
8395 SetLayerPropertiesForTesting(root, identity_transform, gfx::Point3F(), 8396 SetLayerPropertiesForTesting(root, identity_transform, gfx::Point3F(),
8396 gfx::PointF(), gfx::Size(50, 50), true, false, 8397 gfx::PointF(), gfx::Size(50, 50), true, false,
8397 true); 8398 true);
8398 SetLayerPropertiesForTesting(child, identity_transform, gfx::Point3F(), 8399 SetLayerPropertiesForTesting(child, identity_transform, gfx::Point3F(),
8399 gfx::PointF(1000, 1000), gfx::Size(50, 50), true, 8400 gfx::PointF(1000, 1000), gfx::Size(50, 50), true,
8400 false, false); 8401 false, false);
(...skipping 14 matching lines...) Expand all
8415 8416
8416 EXPECT_EQ(gfx::Rect(0, 0, 50, 50), grandchild->visible_layer_rect()); 8417 EXPECT_EQ(gfx::Rect(0, 0, 50, 50), grandchild->visible_layer_rect());
8417 } 8418 }
8418 8419
8419 // Ensures that the property tree code accounts for offsets between fixed 8420 // Ensures that the property tree code accounts for offsets between fixed
8420 // position containers and their transform tree parents, when a fixed position 8421 // position containers and their transform tree parents, when a fixed position
8421 // layer's container is its layer tree parent, but this parent doesn't have its 8422 // layer's container is its layer tree parent, but this parent doesn't have its
8422 // own transform tree node. 8423 // own transform tree node.
8423 TEST_F(LayerTreeHostCommonTest, 8424 TEST_F(LayerTreeHostCommonTest,
8424 PropertyTreesAccountForFixedParentOffsetWhenContainerIsParent) { 8425 PropertyTreesAccountForFixedParentOffsetWhenContainerIsParent) {
8425 LayerImpl* root = root_layer(); 8426 LayerImpl* root = root_layer_for_testing();
8426 LayerImpl* child = AddChild<LayerImpl>(root); 8427 LayerImpl* child = AddChild<LayerImpl>(root);
8427 LayerImpl* grandchild = AddChild<LayerImpl>(child); 8428 LayerImpl* grandchild = AddChild<LayerImpl>(child);
8428 8429
8429 gfx::Transform identity_transform; 8430 gfx::Transform identity_transform;
8430 SetLayerPropertiesForTesting(root, identity_transform, gfx::Point3F(), 8431 SetLayerPropertiesForTesting(root, identity_transform, gfx::Point3F(),
8431 gfx::PointF(), gfx::Size(50, 50), true, false, 8432 gfx::PointF(), gfx::Size(50, 50), true, false,
8432 true); 8433 true);
8433 SetLayerPropertiesForTesting(child, identity_transform, gfx::Point3F(), 8434 SetLayerPropertiesForTesting(child, identity_transform, gfx::Point3F(),
8434 gfx::PointF(1000, 1000), gfx::Size(50, 50), true, 8435 gfx::PointF(1000, 1000), gfx::Size(50, 50), true,
8435 false, false); 8436 false, false);
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
8498 rotated->AddChild(surface); 8499 rotated->AddChild(surface);
8499 surface->AddChild(container); 8500 surface->AddChild(container);
8500 surface->AddChild(box); 8501 surface->AddChild(box);
8501 8502
8502 host()->SetRootLayer(root); 8503 host()->SetRootLayer(root);
8503 8504
8504 ExecuteCalculateDrawProperties(root.get()); 8505 ExecuteCalculateDrawProperties(root.get());
8505 } 8506 }
8506 8507
8507 TEST_F(LayerTreeHostCommonTest, OnlyApplyFixedPositioningOnce) { 8508 TEST_F(LayerTreeHostCommonTest, OnlyApplyFixedPositioningOnce) {
8508 LayerImpl* root = root_layer(); 8509 LayerImpl* root = root_layer_for_testing();
8509 LayerImpl* frame_clip = AddChild<LayerImpl>(root); 8510 LayerImpl* frame_clip = AddChild<LayerImpl>(root);
8510 LayerImpl* fixed = AddChild<LayerImpl>(frame_clip); 8511 LayerImpl* fixed = AddChild<LayerImpl>(frame_clip);
8511 gfx::Transform identity; 8512 gfx::Transform identity;
8512 gfx::Transform translate_z; 8513 gfx::Transform translate_z;
8513 translate_z.Translate3d(0, 0, 10); 8514 translate_z.Translate3d(0, 0, 10);
8514 8515
8515 SetLayerPropertiesForTesting(root, identity, gfx::Point3F(), gfx::PointF(), 8516 SetLayerPropertiesForTesting(root, identity, gfx::Point3F(), gfx::PointF(),
8516 gfx::Size(800, 800), true, false, true); 8517 gfx::Size(800, 800), true, false, true);
8517 root->test_properties()->is_container_for_fixed_position_layers = true; 8518 root->test_properties()->is_container_for_fixed_position_layers = true;
8518 8519
(...skipping 10 matching lines...) Expand all
8529 fixed->test_properties()->position_constraint = constraint; 8530 fixed->test_properties()->position_constraint = constraint;
8530 fixed->SetDrawsContent(true); 8531 fixed->SetDrawsContent(true);
8531 8532
8532 ExecuteCalculateDrawProperties(root); 8533 ExecuteCalculateDrawProperties(root);
8533 8534
8534 gfx::Rect expected(0, 0, 100, 100); 8535 gfx::Rect expected(0, 0, 100, 100);
8535 EXPECT_EQ(expected, fixed->visible_layer_rect()); 8536 EXPECT_EQ(expected, fixed->visible_layer_rect());
8536 } 8537 }
8537 8538
8538 TEST_F(LayerTreeHostCommonTest, FixedClipsShouldBeAssociatedWithTheRightNode) { 8539 TEST_F(LayerTreeHostCommonTest, FixedClipsShouldBeAssociatedWithTheRightNode) {
8539 LayerImpl* root = root_layer(); 8540 LayerImpl* root = root_layer_for_testing();
8540 LayerImpl* frame_clip = AddChild<LayerImpl>(root); 8541 LayerImpl* frame_clip = AddChild<LayerImpl>(root);
8541 LayerImpl* scroller = AddChild<LayerImpl>(frame_clip); 8542 LayerImpl* scroller = AddChild<LayerImpl>(frame_clip);
8542 LayerImpl* fixed = AddChild<LayerImpl>(scroller); 8543 LayerImpl* fixed = AddChild<LayerImpl>(scroller);
8543 8544
8544 gfx::Transform identity; 8545 gfx::Transform identity;
8545 SetLayerPropertiesForTesting(root, identity, gfx::Point3F(), gfx::PointF(), 8546 SetLayerPropertiesForTesting(root, identity, gfx::Point3F(), gfx::PointF(),
8546 gfx::Size(800, 800), true, false, true); 8547 gfx::Size(800, 800), true, false, true);
8547 SetLayerPropertiesForTesting(frame_clip, identity, gfx::Point3F(), 8548 SetLayerPropertiesForTesting(frame_clip, identity, gfx::Point3F(),
8548 gfx::PointF(500, 100), gfx::Size(100, 100), true, 8549 gfx::PointF(500, 100), gfx::Size(100, 100), true,
8549 false, false); 8550 false, false);
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
8595 EXPECT_FALSE(host()->property_trees()->needs_rebuild); 8596 EXPECT_FALSE(host()->property_trees()->needs_rebuild);
8596 8597
8597 root->SetTransform(translate); 8598 root->SetTransform(translate);
8598 EXPECT_FALSE(host()->property_trees()->needs_rebuild); 8599 EXPECT_FALSE(host()->property_trees()->needs_rebuild);
8599 8600
8600 root->SetTransform(rotate); 8601 root->SetTransform(rotate);
8601 EXPECT_TRUE(host()->property_trees()->needs_rebuild); 8602 EXPECT_TRUE(host()->property_trees()->needs_rebuild);
8602 } 8603 }
8603 8604
8604 TEST_F(LayerTreeHostCommonTest, ChangeTransformOrigin) { 8605 TEST_F(LayerTreeHostCommonTest, ChangeTransformOrigin) {
8605 LayerImpl* root = root_layer(); 8606 LayerImpl* root = root_layer_for_testing();
8606 LayerImpl* child = AddChild<LayerImpl>(root); 8607 LayerImpl* child = AddChild<LayerImpl>(root);
8607 8608
8608 gfx::Transform identity_matrix; 8609 gfx::Transform identity_matrix;
8609 gfx::Transform scale_matrix; 8610 gfx::Transform scale_matrix;
8610 scale_matrix.Scale(2.f, 2.f); 8611 scale_matrix.Scale(2.f, 2.f);
8611 SetLayerPropertiesForTesting(root, identity_matrix, gfx::Point3F(), 8612 SetLayerPropertiesForTesting(root, identity_matrix, gfx::Point3F(),
8612 gfx::PointF(), gfx::Size(100, 100), true, false, 8613 gfx::PointF(), gfx::Size(100, 100), true, false,
8613 true); 8614 true);
8614 SetLayerPropertiesForTesting(child, scale_matrix, gfx::Point3F(), 8615 SetLayerPropertiesForTesting(child, scale_matrix, gfx::Point3F(),
8615 gfx::PointF(), gfx::Size(10, 10), true, false, 8616 gfx::PointF(), gfx::Size(10, 10), true, false,
8616 false); 8617 false);
8617 8618
8618 root->SetDrawsContent(true); 8619 root->SetDrawsContent(true);
8619 child->SetDrawsContent(true); 8620 child->SetDrawsContent(true);
8620 8621
8621 ExecuteCalculateDrawProperties(root); 8622 ExecuteCalculateDrawProperties(root);
8622 EXPECT_EQ(gfx::Rect(10, 10), child->visible_layer_rect()); 8623 EXPECT_EQ(gfx::Rect(10, 10), child->visible_layer_rect());
8623 8624
8624 child->test_properties()->transform_origin = gfx::Point3F(10.f, 10.f, 10.f); 8625 child->test_properties()->transform_origin = gfx::Point3F(10.f, 10.f, 10.f);
8625 8626
8626 root->layer_tree_impl()->property_trees()->needs_rebuild = true; 8627 root->layer_tree_impl()->property_trees()->needs_rebuild = true;
8627 ExecuteCalculateDrawProperties(root); 8628 ExecuteCalculateDrawProperties(root);
8628 EXPECT_EQ(gfx::Rect(5, 5, 5, 5), child->visible_layer_rect()); 8629 EXPECT_EQ(gfx::Rect(5, 5, 5, 5), child->visible_layer_rect());
8629 } 8630 }
8630 8631
8631 TEST_F(LayerTreeHostCommonTest, UpdateScrollChildPosition) { 8632 TEST_F(LayerTreeHostCommonTest, UpdateScrollChildPosition) {
8632 LayerImpl* root = root_layer(); 8633 LayerImpl* root = root_layer_for_testing();
8633 LayerImpl* scroll_parent = AddChild<LayerImpl>(root); 8634 LayerImpl* scroll_parent = AddChild<LayerImpl>(root);
8634 LayerImpl* scroll_child = AddChild<LayerImpl>(scroll_parent); 8635 LayerImpl* scroll_child = AddChild<LayerImpl>(scroll_parent);
8635 8636
8636 scroll_child->SetDrawsContent(true); 8637 scroll_child->SetDrawsContent(true);
8637 scroll_child->test_properties()->scroll_parent = scroll_parent; 8638 scroll_child->test_properties()->scroll_parent = scroll_parent;
8638 std::unique_ptr<std::set<LayerImpl*>> scroll_children( 8639 std::unique_ptr<std::set<LayerImpl*>> scroll_children(
8639 new std::set<LayerImpl*>); 8640 new std::set<LayerImpl*>);
8640 scroll_children->insert(scroll_child); 8641 scroll_children->insert(scroll_child);
8641 scroll_parent->test_properties()->scroll_children.reset( 8642 scroll_parent->test_properties()->scroll_children.reset(
8642 scroll_children.release()); 8643 scroll_children.release());
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
8826 SetLayerPropertiesForTesting(grandchild.get(), identity, gfx::Point3F(), 8827 SetLayerPropertiesForTesting(grandchild.get(), identity, gfx::Point3F(),
8827 gfx::PointF(), gfx::Size(10, 10), true, false, 8828 gfx::PointF(), gfx::Size(10, 10), true, false,
8828 false); 8829 false);
8829 8830
8830 LayerImpl* root_ptr = root.get(); 8831 LayerImpl* root_ptr = root.get();
8831 LayerImpl* child_ptr = child.get(); 8832 LayerImpl* child_ptr = child.get();
8832 LayerImpl* grandchild_ptr = grandchild.get(); 8833 LayerImpl* grandchild_ptr = grandchild.get();
8833 8834
8834 child->test_properties()->AddChild(std::move(grandchild)); 8835 child->test_properties()->AddChild(std::move(grandchild));
8835 root->test_properties()->AddChild(std::move(child)); 8836 root->test_properties()->AddChild(std::move(child));
8836 host_impl.active_tree()->SetRootLayer(std::move(root)); 8837 host_impl.active_tree()->SetRootLayerForTesting(std::move(root));
8837 8838
8838 // Check the non-skipped case. 8839 // Check the non-skipped case.
8839 // ExecuteCalculateDrawPropertiesWithPropertyTrees(root_ptr); 8840 // ExecuteCalculateDrawPropertiesWithPropertyTrees(root_ptr);
8840 // EXPECT_EQ(gfx::Rect(10, 10), grandchild_ptr->visible_layer_rect()); 8841 // EXPECT_EQ(gfx::Rect(10, 10), grandchild_ptr->visible_layer_rect());
8841 8842
8842 // Now we will reset the visible rect from property trees for the grandchild, 8843 // Now we will reset the visible rect from property trees for the grandchild,
8843 // and we will configure |child| in several ways that should force the subtree 8844 // and we will configure |child| in several ways that should force the subtree
8844 // to be skipped. The visible content rect for |grandchild| should, therefore, 8845 // to be skipped. The visible content rect for |grandchild| should, therefore,
8845 // remain empty. 8846 // remain empty.
8846 grandchild_ptr->set_visible_layer_rect(gfx::Rect()); 8847 grandchild_ptr->set_visible_layer_rect(gfx::Rect());
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
8941 child_ptr->SetTransform(singular); 8942 child_ptr->SetTransform(singular);
8942 root_ptr->layer_tree_impl()->property_trees()->needs_rebuild = true; 8943 root_ptr->layer_tree_impl()->property_trees()->needs_rebuild = true;
8943 ExecuteCalculateDrawPropertiesWithPropertyTrees(root_ptr); 8944 ExecuteCalculateDrawPropertiesWithPropertyTrees(root_ptr);
8944 EXPECT_EQ(gfx::Rect(0, 0), grandchild_ptr->visible_layer_rect()); 8945 EXPECT_EQ(gfx::Rect(0, 0), grandchild_ptr->visible_layer_rect());
8945 8946
8946 host_impl.active_tree()->animation_host()->UnregisterPlayerForElement( 8947 host_impl.active_tree()->animation_host()->UnregisterPlayerForElement(
8947 root_ptr->id(), player.get()); 8948 root_ptr->id(), player.get());
8948 } 8949 }
8949 8950
8950 TEST_F(LayerTreeHostCommonTest, LayerSkippingInSubtreeOfSingularTransform) { 8951 TEST_F(LayerTreeHostCommonTest, LayerSkippingInSubtreeOfSingularTransform) {
8951 LayerImpl* root = root_layer(); 8952 LayerImpl* root = root_layer_for_testing();
8952 LayerImpl* child = AddChild<LayerImpl>(root); 8953 LayerImpl* child = AddChild<LayerImpl>(root);
8953 LayerImpl* grand_child = AddChild<LayerImpl>(child); 8954 LayerImpl* grand_child = AddChild<LayerImpl>(child);
8954 8955
8955 gfx::Transform identity; 8956 gfx::Transform identity;
8956 SetLayerPropertiesForTesting(root, identity, gfx::Point3F(), gfx::PointF(), 8957 SetLayerPropertiesForTesting(root, identity, gfx::Point3F(), gfx::PointF(),
8957 gfx::Size(10, 10), true, false, true); 8958 gfx::Size(10, 10), true, false, true);
8958 SetLayerPropertiesForTesting(child, identity, gfx::Point3F(), gfx::PointF(), 8959 SetLayerPropertiesForTesting(child, identity, gfx::Point3F(), gfx::PointF(),
8959 gfx::Size(10, 10), true, false, false); 8960 gfx::Size(10, 10), true, false, false);
8960 SetLayerPropertiesForTesting(grand_child, identity, gfx::Point3F(), 8961 SetLayerPropertiesForTesting(grand_child, identity, gfx::Point3F(),
8961 gfx::PointF(), gfx::Size(10, 10), true, false, 8962 gfx::PointF(), gfx::Size(10, 10), true, false,
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
9032 SetLayerPropertiesForTesting(grandchild.get(), identity, gfx::Point3F(), 9033 SetLayerPropertiesForTesting(grandchild.get(), identity, gfx::Point3F(),
9033 gfx::PointF(), gfx::Size(10, 10), true, false, 9034 gfx::PointF(), gfx::Size(10, 10), true, false,
9034 false); 9035 false);
9035 9036
9036 LayerImpl* root_ptr = root.get(); 9037 LayerImpl* root_ptr = root.get();
9037 LayerImpl* grandchild_ptr = grandchild.get(); 9038 LayerImpl* grandchild_ptr = grandchild.get();
9038 9039
9039 child->test_properties()->AddChild(std::move(grandchild)); 9040 child->test_properties()->AddChild(std::move(grandchild));
9040 root->test_properties()->AddChild(std::move(child)); 9041 root->test_properties()->AddChild(std::move(child));
9041 9042
9042 host_impl.pending_tree()->SetRootLayer(std::move(root)); 9043 host_impl.pending_tree()->SetRootLayerForTesting(std::move(root));
9043 9044
9044 // Check the non-skipped case. 9045 // Check the non-skipped case.
9045 ExecuteCalculateDrawPropertiesWithPropertyTrees(root_ptr); 9046 ExecuteCalculateDrawPropertiesWithPropertyTrees(root_ptr);
9046 EXPECT_EQ(gfx::Rect(10, 10), grandchild_ptr->visible_layer_rect()); 9047 EXPECT_EQ(gfx::Rect(10, 10), grandchild_ptr->visible_layer_rect());
9047 9048
9048 std::unique_ptr<KeyframedFloatAnimationCurve> curve( 9049 std::unique_ptr<KeyframedFloatAnimationCurve> curve(
9049 KeyframedFloatAnimationCurve::Create()); 9050 KeyframedFloatAnimationCurve::Create());
9050 std::unique_ptr<TimingFunction> func = 9051 std::unique_ptr<TimingFunction> func =
9051 CubicBezierTimingFunction::CreatePreset( 9052 CubicBezierTimingFunction::CreatePreset(
9052 CubicBezierTimingFunction::EaseType::EASE); 9053 CubicBezierTimingFunction::EaseType::EASE);
(...skipping 15 matching lines...) Expand all
9068 root_ptr->layer_tree_impl()->property_trees()->needs_rebuild = true; 9069 root_ptr->layer_tree_impl()->property_trees()->needs_rebuild = true;
9069 ExecuteCalculateDrawPropertiesWithPropertyTrees(root_ptr); 9070 ExecuteCalculateDrawPropertiesWithPropertyTrees(root_ptr);
9070 EXPECT_EQ(gfx::Rect(10, 10), grandchild_ptr->visible_layer_rect()); 9071 EXPECT_EQ(gfx::Rect(10, 10), grandchild_ptr->visible_layer_rect());
9071 9072
9072 host_impl.active_tree()->animation_host()->UnregisterPlayerForElement( 9073 host_impl.active_tree()->animation_host()->UnregisterPlayerForElement(
9073 root_ptr->id(), player.get()); 9074 root_ptr->id(), player.get());
9074 } 9075 }
9075 9076
9076 TEST_F(LayerTreeHostCommonTest, SkippingLayer) { 9077 TEST_F(LayerTreeHostCommonTest, SkippingLayer) {
9077 gfx::Transform identity; 9078 gfx::Transform identity;
9078 LayerImpl* root = root_layer(); 9079 LayerImpl* root = root_layer_for_testing();
9079 LayerImpl* child = AddChild<LayerImpl>(root); 9080 LayerImpl* child = AddChild<LayerImpl>(root);
9080 9081
9081 SetLayerPropertiesForTesting(root, identity, gfx::Point3F(), gfx::PointF(), 9082 SetLayerPropertiesForTesting(root, identity, gfx::Point3F(), gfx::PointF(),
9082 gfx::Size(100, 100), true, false, true); 9083 gfx::Size(100, 100), true, false, true);
9083 SetLayerPropertiesForTesting(child, identity, gfx::Point3F(), gfx::PointF(), 9084 SetLayerPropertiesForTesting(child, identity, gfx::Point3F(), gfx::PointF(),
9084 gfx::Size(10, 10), true, false, false); 9085 gfx::Size(10, 10), true, false, false);
9085 child->SetDrawsContent(true); 9086 child->SetDrawsContent(true);
9086 9087
9087 ExecuteCalculateDrawProperties(root); 9088 ExecuteCalculateDrawProperties(root);
9088 EXPECT_EQ(gfx::Rect(10, 10), child->visible_layer_rect()); 9089 EXPECT_EQ(gfx::Rect(10, 10), child->visible_layer_rect());
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
9171 EXPECT_NE(-1, child->transform_tree_index()); 9172 EXPECT_NE(-1, child->transform_tree_index());
9172 9173
9173 child->RemoveFromParent(); 9174 child->RemoveFromParent();
9174 9175
9175 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); 9176 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get());
9176 EXPECT_EQ(-1, child->transform_tree_index()); 9177 EXPECT_EQ(-1, child->transform_tree_index());
9177 } 9178 }
9178 9179
9179 TEST_F(LayerTreeHostCommonTest, RenderSurfaceClipsSubtree) { 9180 TEST_F(LayerTreeHostCommonTest, RenderSurfaceClipsSubtree) {
9180 // Ensure that a Clip Node is added when a render surface applies clip. 9181 // Ensure that a Clip Node is added when a render surface applies clip.
9181 LayerImpl* root = root_layer(); 9182 LayerImpl* root = root_layer_for_testing();
9182 LayerImpl* significant_transform = AddChildToRoot<LayerImpl>(); 9183 LayerImpl* significant_transform = AddChildToRoot<LayerImpl>();
9183 LayerImpl* layer_clips_subtree = AddChild<LayerImpl>(significant_transform); 9184 LayerImpl* layer_clips_subtree = AddChild<LayerImpl>(significant_transform);
9184 LayerImpl* render_surface = AddChild<LayerImpl>(layer_clips_subtree); 9185 LayerImpl* render_surface = AddChild<LayerImpl>(layer_clips_subtree);
9185 LayerImpl* test_layer = AddChild<LayerImpl>(render_surface); 9186 LayerImpl* test_layer = AddChild<LayerImpl>(render_surface);
9186 9187
9187 const gfx::Transform identity_matrix; 9188 const gfx::Transform identity_matrix;
9188 // This transform should be a significant one so that a transform node is 9189 // This transform should be a significant one so that a transform node is
9189 // formed for it. 9190 // formed for it.
9190 gfx::Transform transform1; 9191 gfx::Transform transform1;
9191 transform1.RotateAboutYAxis(45); 9192 transform1.RotateAboutYAxis(45);
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
9233 ClipTree& clip_tree = root->layer_tree_impl()->property_trees()->clip_tree; 9234 ClipTree& clip_tree = root->layer_tree_impl()->property_trees()->clip_tree;
9234 ClipNode* clip_node = clip_tree.Node(render_surface->clip_tree_index()); 9235 ClipNode* clip_node = clip_tree.Node(render_surface->clip_tree_index());
9235 EXPECT_FALSE(clip_node->data.applies_local_clip); 9236 EXPECT_FALSE(clip_node->data.applies_local_clip);
9236 EXPECT_EQ(gfx::Rect(20, 20), test_layer->visible_layer_rect()); 9237 EXPECT_EQ(gfx::Rect(20, 20), test_layer->visible_layer_rect());
9237 } 9238 }
9238 9239
9239 TEST_F(LayerTreeHostCommonTest, TransformOfParentClipNodeAncestorOfTarget) { 9240 TEST_F(LayerTreeHostCommonTest, TransformOfParentClipNodeAncestorOfTarget) {
9240 // Ensure that when parent clip node's transform is an ancestor of current 9241 // Ensure that when parent clip node's transform is an ancestor of current
9241 // clip node's target, clip is 'projected' from parent space to current 9242 // clip node's target, clip is 'projected' from parent space to current
9242 // target space and visible rects are calculated correctly. 9243 // target space and visible rects are calculated correctly.
9243 LayerImpl* root = root_layer(); 9244 LayerImpl* root = root_layer_for_testing();
9244 LayerImpl* clip_layer = AddChild<LayerImpl>(root); 9245 LayerImpl* clip_layer = AddChild<LayerImpl>(root);
9245 LayerImpl* target_layer = AddChild<LayerImpl>(clip_layer); 9246 LayerImpl* target_layer = AddChild<LayerImpl>(clip_layer);
9246 LayerImpl* test_layer = AddChild<LayerImpl>(target_layer); 9247 LayerImpl* test_layer = AddChild<LayerImpl>(target_layer);
9247 9248
9248 const gfx::Transform identity_matrix; 9249 const gfx::Transform identity_matrix;
9249 gfx::Transform transform; 9250 gfx::Transform transform;
9250 transform.RotateAboutYAxis(45); 9251 transform.RotateAboutYAxis(45);
9251 clip_layer->SetMasksToBounds(true); 9252 clip_layer->SetMasksToBounds(true);
9252 target_layer->SetMasksToBounds(true); 9253 target_layer->SetMasksToBounds(true);
9253 test_layer->SetDrawsContent(true); 9254 test_layer->SetDrawsContent(true);
(...skipping 12 matching lines...) Expand all
9266 false); 9267 false);
9267 ExecuteCalculateDrawProperties(root); 9268 ExecuteCalculateDrawProperties(root);
9268 9269
9269 EXPECT_EQ(gfx::Rect(30, 30), test_layer->visible_layer_rect()); 9270 EXPECT_EQ(gfx::Rect(30, 30), test_layer->visible_layer_rect());
9270 } 9271 }
9271 9272
9272 TEST_F(LayerTreeHostCommonTest, 9273 TEST_F(LayerTreeHostCommonTest,
9273 RenderSurfaceWithUnclippedDescendantsClipsSubtree) { 9274 RenderSurfaceWithUnclippedDescendantsClipsSubtree) {
9274 // Ensure clip rect is calculated correctly when render surface has unclipped 9275 // Ensure clip rect is calculated correctly when render surface has unclipped
9275 // descendants. 9276 // descendants.
9276 LayerImpl* root = root_layer(); 9277 LayerImpl* root = root_layer_for_testing();
9277 LayerImpl* clip_parent = AddChildToRoot<LayerImpl>(); 9278 LayerImpl* clip_parent = AddChildToRoot<LayerImpl>();
9278 LayerImpl* between_clip_parent_and_child = AddChild<LayerImpl>(clip_parent); 9279 LayerImpl* between_clip_parent_and_child = AddChild<LayerImpl>(clip_parent);
9279 LayerImpl* render_surface = 9280 LayerImpl* render_surface =
9280 AddChild<LayerImpl>(between_clip_parent_and_child); 9281 AddChild<LayerImpl>(between_clip_parent_and_child);
9281 LayerImpl* test_layer = AddChild<LayerImpl>(render_surface); 9282 LayerImpl* test_layer = AddChild<LayerImpl>(render_surface);
9282 9283
9283 const gfx::Transform identity_matrix; 9284 const gfx::Transform identity_matrix;
9284 gfx::Transform translate; 9285 gfx::Transform translate;
9285 translate.Translate(2.0, 2.0); 9286 translate.Translate(2.0, 2.0);
9286 9287
(...skipping 25 matching lines...) Expand all
9312 EXPECT_FALSE(test_layer->render_target()->is_clipped()); 9313 EXPECT_FALSE(test_layer->render_target()->is_clipped());
9313 EXPECT_EQ(gfx::Rect(-2, -2, 30, 30), test_layer->clip_rect()); 9314 EXPECT_EQ(gfx::Rect(-2, -2, 30, 30), test_layer->clip_rect());
9314 EXPECT_EQ(gfx::Rect(28, 28), test_layer->drawable_content_rect()); 9315 EXPECT_EQ(gfx::Rect(28, 28), test_layer->drawable_content_rect());
9315 } 9316 }
9316 9317
9317 TEST_F(LayerTreeHostCommonTest, 9318 TEST_F(LayerTreeHostCommonTest,
9318 RenderSurfaceWithUnclippedDescendantsButDoesntApplyOwnClip) { 9319 RenderSurfaceWithUnclippedDescendantsButDoesntApplyOwnClip) {
9319 // Ensure that the visible layer rect of a descendant of a surface with 9320 // Ensure that the visible layer rect of a descendant of a surface with
9320 // unclipped descendants is computed correctly, when the surface doesn't apply 9321 // unclipped descendants is computed correctly, when the surface doesn't apply
9321 // a clip. 9322 // a clip.
9322 LayerImpl* root = root_layer(); 9323 LayerImpl* root = root_layer_for_testing();
9323 LayerImpl* clip_parent = AddChildToRoot<LayerImpl>(); 9324 LayerImpl* clip_parent = AddChildToRoot<LayerImpl>();
9324 LayerImpl* render_surface = AddChild<LayerImpl>(clip_parent); 9325 LayerImpl* render_surface = AddChild<LayerImpl>(clip_parent);
9325 LayerImpl* clip_child = AddChild<LayerImpl>(render_surface); 9326 LayerImpl* clip_child = AddChild<LayerImpl>(render_surface);
9326 LayerImpl* child = AddChild<LayerImpl>(render_surface); 9327 LayerImpl* child = AddChild<LayerImpl>(render_surface);
9327 9328
9328 const gfx::Transform identity_matrix; 9329 const gfx::Transform identity_matrix;
9329 9330
9330 clip_child->SetDrawsContent(true); 9331 clip_child->SetDrawsContent(true);
9331 child->SetDrawsContent(true); 9332 child->SetDrawsContent(true);
9332 clip_child->test_properties()->clip_parent = clip_parent; 9333 clip_child->test_properties()->clip_parent = clip_parent;
(...skipping 15 matching lines...) Expand all
9348 SetLayerPropertiesForTesting(child, identity_matrix, gfx::Point3F(), 9349 SetLayerPropertiesForTesting(child, identity_matrix, gfx::Point3F(),
9349 gfx::PointF(), gfx::Size(40, 40), true, false, 9350 gfx::PointF(), gfx::Size(40, 40), true, false,
9350 false); 9351 false);
9351 9352
9352 ExecuteCalculateDrawProperties(root); 9353 ExecuteCalculateDrawProperties(root);
9353 EXPECT_EQ(gfx::Rect(40, 40), child->visible_layer_rect()); 9354 EXPECT_EQ(gfx::Rect(40, 40), child->visible_layer_rect());
9354 } 9355 }
9355 9356
9356 TEST_F(LayerTreeHostCommonTest, 9357 TEST_F(LayerTreeHostCommonTest,
9357 RenderSurfaceClipsSubtreeAndHasUnclippedDescendants) { 9358 RenderSurfaceClipsSubtreeAndHasUnclippedDescendants) {
9358 LayerImpl* root = root_layer(); 9359 LayerImpl* root = root_layer_for_testing();
9359 LayerImpl* clip_parent = AddChildToRoot<LayerImpl>(); 9360 LayerImpl* clip_parent = AddChildToRoot<LayerImpl>();
9360 LayerImpl* render_surface = AddChild<LayerImpl>(clip_parent); 9361 LayerImpl* render_surface = AddChild<LayerImpl>(clip_parent);
9361 LayerImpl* test_layer1 = AddChild<LayerImpl>(render_surface); 9362 LayerImpl* test_layer1 = AddChild<LayerImpl>(render_surface);
9362 LayerImpl* clip_child = AddChild<LayerImpl>(test_layer1); 9363 LayerImpl* clip_child = AddChild<LayerImpl>(test_layer1);
9363 LayerImpl* test_layer2 = AddChild<LayerImpl>(clip_child); 9364 LayerImpl* test_layer2 = AddChild<LayerImpl>(clip_child);
9364 9365
9365 const gfx::Transform identity_matrix; 9366 const gfx::Transform identity_matrix;
9366 root->SetMasksToBounds(true); 9367 root->SetMasksToBounds(true);
9367 render_surface->SetMasksToBounds(true); 9368 render_surface->SetMasksToBounds(true);
9368 render_surface->SetDrawsContent(true); 9369 render_surface->SetDrawsContent(true);
(...skipping 25 matching lines...) Expand all
9394 false); 9395 false);
9395 9396
9396 ExecuteCalculateDrawProperties(root); 9397 ExecuteCalculateDrawProperties(root);
9397 EXPECT_EQ(gfx::Rect(30, 30), render_surface->visible_layer_rect()); 9398 EXPECT_EQ(gfx::Rect(30, 30), render_surface->visible_layer_rect());
9398 EXPECT_EQ(gfx::Rect(30, 30), test_layer1->visible_layer_rect()); 9399 EXPECT_EQ(gfx::Rect(30, 30), test_layer1->visible_layer_rect());
9399 EXPECT_EQ(gfx::Rect(30, 30), clip_child->visible_layer_rect()); 9400 EXPECT_EQ(gfx::Rect(30, 30), clip_child->visible_layer_rect());
9400 EXPECT_EQ(gfx::Rect(30, 30), test_layer2->visible_layer_rect()); 9401 EXPECT_EQ(gfx::Rect(30, 30), test_layer2->visible_layer_rect());
9401 } 9402 }
9402 9403
9403 TEST_F(LayerTreeHostCommonTest, UnclippedClipParent) { 9404 TEST_F(LayerTreeHostCommonTest, UnclippedClipParent) {
9404 LayerImpl* root = root_layer(); 9405 LayerImpl* root = root_layer_for_testing();
9405 LayerImpl* clip_parent = AddChildToRoot<LayerImpl>(); 9406 LayerImpl* clip_parent = AddChildToRoot<LayerImpl>();
9406 LayerImpl* render_surface = AddChild<LayerImpl>(clip_parent); 9407 LayerImpl* render_surface = AddChild<LayerImpl>(clip_parent);
9407 LayerImpl* clip_child = AddChild<LayerImpl>(render_surface); 9408 LayerImpl* clip_child = AddChild<LayerImpl>(render_surface);
9408 9409
9409 const gfx::Transform identity_matrix; 9410 const gfx::Transform identity_matrix;
9410 clip_parent->SetDrawsContent(true); 9411 clip_parent->SetDrawsContent(true);
9411 render_surface->SetMasksToBounds(true); 9412 render_surface->SetMasksToBounds(true);
9412 render_surface->SetDrawsContent(true); 9413 render_surface->SetDrawsContent(true);
9413 clip_child->SetDrawsContent(true); 9414 clip_child->SetDrawsContent(true);
9414 9415
(...skipping 21 matching lines...) Expand all
9436 // tree parent's clipping state. 9437 // tree parent's clipping state.
9437 EXPECT_FALSE(clip_parent->is_clipped()); 9438 EXPECT_FALSE(clip_parent->is_clipped());
9438 EXPECT_TRUE(render_surface->is_clipped()); 9439 EXPECT_TRUE(render_surface->is_clipped());
9439 EXPECT_FALSE(clip_child->is_clipped()); 9440 EXPECT_FALSE(clip_child->is_clipped());
9440 } 9441 }
9441 9442
9442 TEST_F(LayerTreeHostCommonTest, RenderSurfaceContentRectWithMultipleSurfaces) { 9443 TEST_F(LayerTreeHostCommonTest, RenderSurfaceContentRectWithMultipleSurfaces) {
9443 // Tests the value of render surface content rect when we have multiple types 9444 // Tests the value of render surface content rect when we have multiple types
9444 // of surfaces : unclipped surfaces, surfaces with unclipped surfaces and 9445 // of surfaces : unclipped surfaces, surfaces with unclipped surfaces and
9445 // clipped surfaces. 9446 // clipped surfaces.
9446 LayerImpl* root = root_layer(); 9447 LayerImpl* root = root_layer_for_testing();
9447 LayerImpl* unclipped_surface = AddChildToRoot<LayerImpl>(); 9448 LayerImpl* unclipped_surface = AddChildToRoot<LayerImpl>();
9448 LayerImpl* clip_parent = AddChild<LayerImpl>(unclipped_surface); 9449 LayerImpl* clip_parent = AddChild<LayerImpl>(unclipped_surface);
9449 LayerImpl* unclipped_desc_surface = AddChild<LayerImpl>(clip_parent); 9450 LayerImpl* unclipped_desc_surface = AddChild<LayerImpl>(clip_parent);
9450 LayerImpl* unclipped_desc_surface2 = 9451 LayerImpl* unclipped_desc_surface2 =
9451 AddChild<LayerImpl>(unclipped_desc_surface); 9452 AddChild<LayerImpl>(unclipped_desc_surface);
9452 LayerImpl* clip_child = AddChild<LayerImpl>(unclipped_desc_surface2); 9453 LayerImpl* clip_child = AddChild<LayerImpl>(unclipped_desc_surface2);
9453 LayerImpl* clipped_surface = AddChild<LayerImpl>(clip_child); 9454 LayerImpl* clipped_surface = AddChild<LayerImpl>(clip_child);
9454 9455
9455 unclipped_surface->SetDrawsContent(true); 9456 unclipped_surface->SetDrawsContent(true);
9456 unclipped_desc_surface->SetDrawsContent(true); 9457 unclipped_desc_surface->SetDrawsContent(true);
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
9494 unclipped_desc_surface->render_surface()->content_rect()); 9495 unclipped_desc_surface->render_surface()->content_rect());
9495 EXPECT_EQ(gfx::Rect(50, 50), 9496 EXPECT_EQ(gfx::Rect(50, 50),
9496 unclipped_desc_surface2->render_surface()->content_rect()); 9497 unclipped_desc_surface2->render_surface()->content_rect());
9497 EXPECT_EQ(gfx::Rect(50, 50), 9498 EXPECT_EQ(gfx::Rect(50, 50),
9498 clipped_surface->render_surface()->content_rect()); 9499 clipped_surface->render_surface()->content_rect());
9499 } 9500 }
9500 9501
9501 TEST_F(LayerTreeHostCommonTest, ClipBetweenClipChildTargetAndClipParentTarget) { 9502 TEST_F(LayerTreeHostCommonTest, ClipBetweenClipChildTargetAndClipParentTarget) {
9502 // Tests the value of render surface content rect when we have a layer that 9503 // Tests the value of render surface content rect when we have a layer that
9503 // clips between the clip parent's target and clip child's target. 9504 // clips between the clip parent's target and clip child's target.
9504 LayerImpl* root = root_layer(); 9505 LayerImpl* root = root_layer_for_testing();
9505 LayerImpl* surface = AddChildToRoot<LayerImpl>(); 9506 LayerImpl* surface = AddChildToRoot<LayerImpl>();
9506 LayerImpl* clip_layer = AddChild<LayerImpl>(surface); 9507 LayerImpl* clip_layer = AddChild<LayerImpl>(surface);
9507 LayerImpl* clip_parent = AddChild<LayerImpl>(clip_layer); 9508 LayerImpl* clip_parent = AddChild<LayerImpl>(clip_layer);
9508 LayerImpl* unclipped_desc_surface = AddChild<LayerImpl>(clip_parent); 9509 LayerImpl* unclipped_desc_surface = AddChild<LayerImpl>(clip_parent);
9509 LayerImpl* clip_child = AddChild<LayerImpl>(unclipped_desc_surface); 9510 LayerImpl* clip_child = AddChild<LayerImpl>(unclipped_desc_surface);
9510 9511
9511 clip_child->SetDrawsContent(true); 9512 clip_child->SetDrawsContent(true);
9512 unclipped_desc_surface->SetDrawsContent(true); 9513 unclipped_desc_surface->SetDrawsContent(true);
9513 clip_child->test_properties()->clip_parent = clip_parent; 9514 clip_child->test_properties()->clip_parent = clip_parent;
9514 std::unique_ptr<std::set<LayerImpl*>> clip_children(new std::set<LayerImpl*>); 9515 std::unique_ptr<std::set<LayerImpl*>> clip_children(new std::set<LayerImpl*>);
(...skipping 24 matching lines...) Expand all
9539 surface->SetMasksToBounds(true); 9540 surface->SetMasksToBounds(true);
9540 clip_layer->SetMasksToBounds(true); 9541 clip_layer->SetMasksToBounds(true);
9541 9542
9542 ExecuteCalculateDrawProperties(root); 9543 ExecuteCalculateDrawProperties(root);
9543 9544
9544 EXPECT_EQ(gfx::Rect(10, 10), 9545 EXPECT_EQ(gfx::Rect(10, 10),
9545 unclipped_desc_surface->render_surface()->content_rect()); 9546 unclipped_desc_surface->render_surface()->content_rect());
9546 } 9547 }
9547 9548
9548 TEST_F(LayerTreeHostCommonTest, VisibleRectForDescendantOfScaledSurface) { 9549 TEST_F(LayerTreeHostCommonTest, VisibleRectForDescendantOfScaledSurface) {
9549 LayerImpl* root = root_layer(); 9550 LayerImpl* root = root_layer_for_testing();
9550 LayerImpl* surface = AddChildToRoot<LayerImpl>(); 9551 LayerImpl* surface = AddChildToRoot<LayerImpl>();
9551 LayerImpl* clip_layer = AddChild<LayerImpl>(surface); 9552 LayerImpl* clip_layer = AddChild<LayerImpl>(surface);
9552 LayerImpl* clip_parent = AddChild<LayerImpl>(clip_layer); 9553 LayerImpl* clip_parent = AddChild<LayerImpl>(clip_layer);
9553 LayerImpl* unclipped_desc_surface = AddChild<LayerImpl>(clip_parent); 9554 LayerImpl* unclipped_desc_surface = AddChild<LayerImpl>(clip_parent);
9554 LayerImpl* clip_child = AddChild<LayerImpl>(unclipped_desc_surface); 9555 LayerImpl* clip_child = AddChild<LayerImpl>(unclipped_desc_surface);
9555 9556
9556 clip_child->SetDrawsContent(true); 9557 clip_child->SetDrawsContent(true);
9557 unclipped_desc_surface->SetDrawsContent(true); 9558 unclipped_desc_surface->SetDrawsContent(true);
9558 clip_child->test_properties()->clip_parent = clip_parent; 9559 clip_child->test_properties()->clip_parent = clip_parent;
9559 std::unique_ptr<std::set<LayerImpl*>> clip_children(new std::set<LayerImpl*>); 9560 std::unique_ptr<std::set<LayerImpl*>> clip_children(new std::set<LayerImpl*>);
(...skipping 22 matching lines...) Expand all
9582 false); 9583 false);
9583 surface->SetMasksToBounds(true); 9584 surface->SetMasksToBounds(true);
9584 clip_layer->SetMasksToBounds(true); 9585 clip_layer->SetMasksToBounds(true);
9585 9586
9586 ExecuteCalculateDrawProperties(root); 9587 ExecuteCalculateDrawProperties(root);
9587 9588
9588 EXPECT_EQ(gfx::Rect(20, 20), clip_child->visible_layer_rect()); 9589 EXPECT_EQ(gfx::Rect(20, 20), clip_child->visible_layer_rect());
9589 } 9590 }
9590 9591
9591 TEST_F(LayerTreeHostCommonTest, LayerWithInputHandlerAndZeroOpacity) { 9592 TEST_F(LayerTreeHostCommonTest, LayerWithInputHandlerAndZeroOpacity) {
9592 LayerImpl* root = root_layer(); 9593 LayerImpl* root = root_layer_for_testing();
9593 LayerImpl* render_surface = AddChild<LayerImpl>(root); 9594 LayerImpl* render_surface = AddChild<LayerImpl>(root);
9594 LayerImpl* test_layer = AddChild<LayerImpl>(render_surface); 9595 LayerImpl* test_layer = AddChild<LayerImpl>(render_surface);
9595 9596
9596 const gfx::Transform identity_matrix; 9597 const gfx::Transform identity_matrix;
9597 SetLayerPropertiesForTesting(root, identity_matrix, gfx::Point3F(), 9598 SetLayerPropertiesForTesting(root, identity_matrix, gfx::Point3F(),
9598 gfx::PointF(), gfx::Size(30, 30), true, false, 9599 gfx::PointF(), gfx::Size(30, 30), true, false,
9599 true); 9600 true);
9600 SetLayerPropertiesForTesting(render_surface, identity_matrix, gfx::Point3F(), 9601 SetLayerPropertiesForTesting(render_surface, identity_matrix, gfx::Point3F(),
9601 gfx::PointF(), gfx::Size(30, 30), true, false, 9602 gfx::PointF(), gfx::Size(30, 30), true, false,
9602 true); 9603 true);
9603 gfx::Transform translation; 9604 gfx::Transform translation;
9604 translation.Translate(10, 10); 9605 translation.Translate(10, 10);
9605 SetLayerPropertiesForTesting(test_layer, translation, gfx::Point3F(), 9606 SetLayerPropertiesForTesting(test_layer, translation, gfx::Point3F(),
9606 gfx::PointF(), gfx::Size(20, 20), true, false, 9607 gfx::PointF(), gfx::Size(20, 20), true, false,
9607 false); 9608 false);
9608 9609
9609 render_surface->SetMasksToBounds(true); 9610 render_surface->SetMasksToBounds(true);
9610 test_layer->SetDrawsContent(true); 9611 test_layer->SetDrawsContent(true);
9611 test_layer->test_properties()->opacity = 0.f; 9612 test_layer->test_properties()->opacity = 0.f;
9612 test_layer->SetTouchEventHandlerRegion(gfx::Rect(0, 0, 20, 20)); 9613 test_layer->SetTouchEventHandlerRegion(gfx::Rect(0, 0, 20, 20));
9613 9614
9614 ExecuteCalculateDrawProperties(root); 9615 ExecuteCalculateDrawProperties(root);
9615 EXPECT_EQ(translation, test_layer->ScreenSpaceTransform()); 9616 EXPECT_EQ(translation, test_layer->ScreenSpaceTransform());
9616 } 9617 }
9617 9618
9618 TEST_F(LayerTreeHostCommonTest, ClipChildVisibleRect) { 9619 TEST_F(LayerTreeHostCommonTest, ClipChildVisibleRect) {
9619 LayerImpl* root = root_layer(); 9620 LayerImpl* root = root_layer_for_testing();
9620 LayerImpl* clip_parent = AddChildToRoot<LayerImpl>(); 9621 LayerImpl* clip_parent = AddChildToRoot<LayerImpl>();
9621 LayerImpl* render_surface = AddChild<LayerImpl>(clip_parent); 9622 LayerImpl* render_surface = AddChild<LayerImpl>(clip_parent);
9622 LayerImpl* clip_child = AddChild<LayerImpl>(render_surface); 9623 LayerImpl* clip_child = AddChild<LayerImpl>(render_surface);
9623 9624
9624 const gfx::Transform identity_matrix; 9625 const gfx::Transform identity_matrix;
9625 clip_parent->SetMasksToBounds(true); 9626 clip_parent->SetMasksToBounds(true);
9626 render_surface->SetMasksToBounds(true); 9627 render_surface->SetMasksToBounds(true);
9627 render_surface->SetDrawsContent(true); 9628 render_surface->SetDrawsContent(true);
9628 clip_child->SetDrawsContent(true); 9629 clip_child->SetDrawsContent(true);
9629 clip_child->test_properties()->clip_parent = clip_parent; 9630 clip_child->test_properties()->clip_parent = clip_parent;
(...skipping 13 matching lines...) Expand all
9643 SetLayerPropertiesForTesting(clip_child, identity_matrix, gfx::Point3F(), 9644 SetLayerPropertiesForTesting(clip_child, identity_matrix, gfx::Point3F(),
9644 gfx::PointF(), gfx::Size(50, 50), true, false, 9645 gfx::PointF(), gfx::Size(50, 50), true, false,
9645 false); 9646 false);
9646 9647
9647 ExecuteCalculateDrawProperties(root); 9648 ExecuteCalculateDrawProperties(root);
9648 EXPECT_EQ(gfx::Rect(40, 40), clip_child->visible_layer_rect()); 9649 EXPECT_EQ(gfx::Rect(40, 40), clip_child->visible_layer_rect());
9649 } 9650 }
9650 9651
9651 TEST_F(LayerTreeHostCommonTest, 9652 TEST_F(LayerTreeHostCommonTest,
9652 LayerClipRectLargerThanClippingRenderSurfaceRect) { 9653 LayerClipRectLargerThanClippingRenderSurfaceRect) {
9653 LayerImpl* root = root_layer(); 9654 LayerImpl* root = root_layer_for_testing();
9654 LayerImpl* render_surface = AddChild<LayerImpl>(root); 9655 LayerImpl* render_surface = AddChild<LayerImpl>(root);
9655 LayerImpl* test_layer = AddChild<LayerImpl>(render_surface); 9656 LayerImpl* test_layer = AddChild<LayerImpl>(render_surface);
9656 const gfx::Transform identity_matrix; 9657 const gfx::Transform identity_matrix;
9657 SetLayerPropertiesForTesting(root, identity_matrix, gfx::Point3F(), 9658 SetLayerPropertiesForTesting(root, identity_matrix, gfx::Point3F(),
9658 gfx::PointF(), gfx::Size(30, 30), true, false, 9659 gfx::PointF(), gfx::Size(30, 30), true, false,
9659 true); 9660 true);
9660 SetLayerPropertiesForTesting(render_surface, identity_matrix, gfx::Point3F(), 9661 SetLayerPropertiesForTesting(render_surface, identity_matrix, gfx::Point3F(),
9661 gfx::PointF(), gfx::Size(50, 50), true, false, 9662 gfx::PointF(), gfx::Size(50, 50), true, false,
9662 true); 9663 true);
9663 SetLayerPropertiesForTesting(test_layer, identity_matrix, gfx::Point3F(), 9664 SetLayerPropertiesForTesting(test_layer, identity_matrix, gfx::Point3F(),
9664 gfx::PointF(), gfx::Size(50, 50), true, false, 9665 gfx::PointF(), gfx::Size(50, 50), true, false,
9665 false); 9666 false);
9666 root->SetMasksToBounds(true); 9667 root->SetMasksToBounds(true);
9667 root->SetDrawsContent(true); 9668 root->SetDrawsContent(true);
9668 render_surface->SetMasksToBounds(true); 9669 render_surface->SetMasksToBounds(true);
9669 render_surface->SetDrawsContent(true); 9670 render_surface->SetDrawsContent(true);
9670 test_layer->SetMasksToBounds(true); 9671 test_layer->SetMasksToBounds(true);
9671 test_layer->SetDrawsContent(true); 9672 test_layer->SetDrawsContent(true);
9672 ExecuteCalculateDrawProperties(root); 9673 ExecuteCalculateDrawProperties(root);
9673 9674
9674 EXPECT_EQ(gfx::Rect(30, 30), root->clip_rect()); 9675 EXPECT_EQ(gfx::Rect(30, 30), root->clip_rect());
9675 EXPECT_EQ(gfx::Rect(50, 50), render_surface->clip_rect()); 9676 EXPECT_EQ(gfx::Rect(50, 50), render_surface->clip_rect());
9676 EXPECT_EQ(gfx::Rect(50, 50), test_layer->clip_rect()); 9677 EXPECT_EQ(gfx::Rect(50, 50), test_layer->clip_rect());
9677 } 9678 }
9678 9679
9679 TEST_F(LayerTreeHostCommonTest, SubtreeIsHiddenTest) { 9680 TEST_F(LayerTreeHostCommonTest, SubtreeIsHiddenTest) {
9680 // Tests that subtree is hidden is updated. 9681 // Tests that subtree is hidden is updated.
9681 LayerImpl* root = root_layer(); 9682 LayerImpl* root = root_layer_for_testing();
9682 LayerImpl* hidden = AddChild<LayerImpl>(root); 9683 LayerImpl* hidden = AddChild<LayerImpl>(root);
9683 LayerImpl* test = AddChild<LayerImpl>(hidden); 9684 LayerImpl* test = AddChild<LayerImpl>(hidden);
9684 9685
9685 const gfx::Transform identity_matrix; 9686 const gfx::Transform identity_matrix;
9686 SetLayerPropertiesForTesting(root, identity_matrix, gfx::Point3F(), 9687 SetLayerPropertiesForTesting(root, identity_matrix, gfx::Point3F(),
9687 gfx::PointF(), gfx::Size(30, 30), true, false, 9688 gfx::PointF(), gfx::Size(30, 30), true, false,
9688 true); 9689 true);
9689 SetLayerPropertiesForTesting(hidden, identity_matrix, gfx::Point3F(), 9690 SetLayerPropertiesForTesting(hidden, identity_matrix, gfx::Point3F(),
9690 gfx::PointF(10, 10), gfx::Size(30, 30), true, 9691 gfx::PointF(10, 10), gfx::Size(30, 30), true,
9691 false, true); 9692 false, true);
9692 SetLayerPropertiesForTesting(test, identity_matrix, gfx::Point3F(), 9693 SetLayerPropertiesForTesting(test, identity_matrix, gfx::Point3F(),
9693 gfx::PointF(), gfx::Size(30, 30), true, false, 9694 gfx::PointF(), gfx::Size(30, 30), true, false,
9694 true); 9695 true);
9695 9696
9696 hidden->test_properties()->hide_layer_and_subtree = true; 9697 hidden->test_properties()->hide_layer_and_subtree = true;
9697 ExecuteCalculateDrawProperties(root); 9698 ExecuteCalculateDrawProperties(root);
9698 EXPECT_TRUE(test->IsHidden()); 9699 EXPECT_TRUE(test->IsHidden());
9699 9700
9700 hidden->test_properties()->hide_layer_and_subtree = false; 9701 hidden->test_properties()->hide_layer_and_subtree = false;
9701 root->layer_tree_impl()->property_trees()->needs_rebuild = true; 9702 root->layer_tree_impl()->property_trees()->needs_rebuild = true;
9702 ExecuteCalculateDrawProperties(root); 9703 ExecuteCalculateDrawProperties(root);
9703 EXPECT_FALSE(test->IsHidden()); 9704 EXPECT_FALSE(test->IsHidden());
9704 } 9705 }
9705 9706
9706 TEST_F(LayerTreeHostCommonTest, TwoUnclippedRenderSurfaces) { 9707 TEST_F(LayerTreeHostCommonTest, TwoUnclippedRenderSurfaces) {
9707 LayerImpl* root = root_layer(); 9708 LayerImpl* root = root_layer_for_testing();
9708 LayerImpl* render_surface1 = AddChild<LayerImpl>(root); 9709 LayerImpl* render_surface1 = AddChild<LayerImpl>(root);
9709 LayerImpl* render_surface2 = AddChild<LayerImpl>(render_surface1); 9710 LayerImpl* render_surface2 = AddChild<LayerImpl>(render_surface1);
9710 LayerImpl* clip_child = AddChild<LayerImpl>(render_surface2); 9711 LayerImpl* clip_child = AddChild<LayerImpl>(render_surface2);
9711 9712
9712 const gfx::Transform identity_matrix; 9713 const gfx::Transform identity_matrix;
9713 clip_child->test_properties()->clip_parent = root; 9714 clip_child->test_properties()->clip_parent = root;
9714 std::unique_ptr<std::set<LayerImpl*>> clip_children(new std::set<LayerImpl*>); 9715 std::unique_ptr<std::set<LayerImpl*>> clip_children(new std::set<LayerImpl*>);
9715 clip_children->insert(clip_child); 9716 clip_children->insert(clip_child);
9716 root->test_properties()->clip_children.reset(clip_children.release()); 9717 root->test_properties()->clip_children.reset(clip_children.release());
9717 root->SetMasksToBounds(true); 9718 root->SetMasksToBounds(true);
(...skipping 15 matching lines...) Expand all
9733 ExecuteCalculateDrawProperties(root); 9734 ExecuteCalculateDrawProperties(root);
9734 9735
9735 EXPECT_EQ(gfx::Rect(-10, -10, 30, 30), render_surface2->clip_rect()); 9736 EXPECT_EQ(gfx::Rect(-10, -10, 30, 30), render_surface2->clip_rect());
9736 // A clip node is created for every render surface and for layers that have 9737 // A clip node is created for every render surface and for layers that have
9737 // local clip. So, here it should be craeted for every layer. 9738 // local clip. So, here it should be craeted for every layer.
9738 EXPECT_EQ(root->layer_tree_impl()->property_trees()->clip_tree.size(), 5u); 9739 EXPECT_EQ(root->layer_tree_impl()->property_trees()->clip_tree.size(), 5u);
9739 } 9740 }
9740 9741
9741 TEST_F(LayerTreeHostCommonTest, MaskLayerDrawProperties) { 9742 TEST_F(LayerTreeHostCommonTest, MaskLayerDrawProperties) {
9742 // Tests that a mask layer's draw properties are computed correctly. 9743 // Tests that a mask layer's draw properties are computed correctly.
9743 LayerImpl* root = root_layer(); 9744 LayerImpl* root = root_layer_for_testing();
9744 LayerImpl* child = AddChild<LayerImpl>(root); 9745 LayerImpl* child = AddChild<LayerImpl>(root);
9745 child->test_properties()->SetMaskLayer( 9746 child->test_properties()->SetMaskLayer(
9746 LayerImpl::Create(root->layer_tree_impl(), 100)); 9747 LayerImpl::Create(root->layer_tree_impl(), 100));
9747 LayerImpl* mask = child->test_properties()->mask_layer; 9748 LayerImpl* mask = child->test_properties()->mask_layer;
9748 9749
9749 const gfx::Transform identity_matrix; 9750 const gfx::Transform identity_matrix;
9750 gfx::Transform transform; 9751 gfx::Transform transform;
9751 transform.Translate(10, 10); 9752 transform.Translate(10, 10);
9752 9753
9753 SetLayerPropertiesForTesting(root, identity_matrix, gfx::Point3F(), 9754 SetLayerPropertiesForTesting(root, identity_matrix, gfx::Point3F(),
(...skipping 26 matching lines...) Expand all
9780 transform.Translate(10, 10); 9781 transform.Translate(10, 10);
9781 child->SetTransform(transform); 9782 child->SetTransform(transform);
9782 root->layer_tree_impl()->property_trees()->needs_rebuild = true; 9783 root->layer_tree_impl()->property_trees()->needs_rebuild = true;
9783 ExecuteCalculateDrawProperties(root); 9784 ExecuteCalculateDrawProperties(root);
9784 EXPECT_TRANSFORMATION_MATRIX_EQ(transform, mask->ScreenSpaceTransform()); 9785 EXPECT_TRANSFORMATION_MATRIX_EQ(transform, mask->ScreenSpaceTransform());
9785 EXPECT_EQ(gfx::Rect(20, 20), mask->visible_layer_rect()); 9786 EXPECT_EQ(gfx::Rect(20, 20), mask->visible_layer_rect());
9786 } 9787 }
9787 9788
9788 TEST_F(LayerTreeHostCommonTest, ReplicaMaskLayerDrawProperties) { 9789 TEST_F(LayerTreeHostCommonTest, ReplicaMaskLayerDrawProperties) {
9789 // Tests that a replica mask layer's draw properties are computed correctly. 9790 // Tests that a replica mask layer's draw properties are computed correctly.
9790 LayerImpl* root = root_layer(); 9791 LayerImpl* root = root_layer_for_testing();
9791 LayerImpl* child = AddChild<LayerImpl>(root); 9792 LayerImpl* child = AddChild<LayerImpl>(root);
9792 child->test_properties()->SetReplicaLayer( 9793 child->test_properties()->SetReplicaLayer(
9793 LayerImpl::Create(root->layer_tree_impl(), 100)); 9794 LayerImpl::Create(root->layer_tree_impl(), 100));
9794 LayerImpl* replica = child->test_properties()->replica_layer; 9795 LayerImpl* replica = child->test_properties()->replica_layer;
9795 replica->test_properties()->parent = child; 9796 replica->test_properties()->parent = child;
9796 replica->test_properties()->SetMaskLayer( 9797 replica->test_properties()->SetMaskLayer(
9797 LayerImpl::Create(root->layer_tree_impl(), 200)); 9798 LayerImpl::Create(root->layer_tree_impl(), 200));
9798 LayerImpl* replica_mask = replica->test_properties()->mask_layer; 9799 LayerImpl* replica_mask = replica->test_properties()->mask_layer;
9799 9800
9800 const gfx::Transform identity_matrix; 9801 const gfx::Transform identity_matrix;
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
9837 root->layer_tree_impl()->property_trees()->needs_rebuild = true; 9838 root->layer_tree_impl()->property_trees()->needs_rebuild = true;
9838 ExecuteCalculateDrawProperties(root); 9839 ExecuteCalculateDrawProperties(root);
9839 EXPECT_TRUE(replica_mask->is_drawn_render_surface_layer_list_member()); 9840 EXPECT_TRUE(replica_mask->is_drawn_render_surface_layer_list_member());
9840 EXPECT_EQ(gfx::Rect(20, 20), replica_mask->visible_layer_rect()); 9841 EXPECT_EQ(gfx::Rect(20, 20), replica_mask->visible_layer_rect());
9841 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_screen_space_transform, 9842 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_screen_space_transform,
9842 replica_mask->ScreenSpaceTransform()); 9843 replica_mask->ScreenSpaceTransform());
9843 } 9844 }
9844 9845
9845 TEST_F(LayerTreeHostCommonTest, 9846 TEST_F(LayerTreeHostCommonTest,
9846 SublayerScaleWithTransformNodeBetweenTwoTargets) { 9847 SublayerScaleWithTransformNodeBetweenTwoTargets) {
9847 LayerImpl* root = root_layer(); 9848 LayerImpl* root = root_layer_for_testing();
9848 LayerImpl* render_surface1 = AddChild<LayerImpl>(root); 9849 LayerImpl* render_surface1 = AddChild<LayerImpl>(root);
9849 LayerImpl* between_targets = AddChild<LayerImpl>(render_surface1); 9850 LayerImpl* between_targets = AddChild<LayerImpl>(render_surface1);
9850 LayerImpl* render_surface2 = AddChild<LayerImpl>(between_targets); 9851 LayerImpl* render_surface2 = AddChild<LayerImpl>(between_targets);
9851 LayerImpl* test_layer = AddChild<LayerImpl>(render_surface2); 9852 LayerImpl* test_layer = AddChild<LayerImpl>(render_surface2);
9852 const gfx::Transform identity_matrix; 9853 const gfx::Transform identity_matrix;
9853 test_layer->SetDrawsContent(true); 9854 test_layer->SetDrawsContent(true);
9854 9855
9855 gfx::Transform scale; 9856 gfx::Transform scale;
9856 scale.Scale(2.f, 2.f); 9857 scale.Scale(2.f, 2.f);
9857 SetLayerPropertiesForTesting(root, identity_matrix, gfx::Point3F(), 9858 SetLayerPropertiesForTesting(root, identity_matrix, gfx::Point3F(),
(...skipping 26 matching lines...) Expand all
9884 node = tree.Node(between_targets->transform_tree_index()); 9885 node = tree.Node(between_targets->transform_tree_index());
9885 EXPECT_EQ(node->data.sublayer_scale, gfx::Vector2dF(1.f, 1.f)); 9886 EXPECT_EQ(node->data.sublayer_scale, gfx::Vector2dF(1.f, 1.f));
9886 9887
9887 node = tree.Node(render_surface2->transform_tree_index()); 9888 node = tree.Node(render_surface2->transform_tree_index());
9888 EXPECT_EQ(node->data.sublayer_scale, gfx::Vector2dF(2.f, 2.f)); 9889 EXPECT_EQ(node->data.sublayer_scale, gfx::Vector2dF(2.f, 2.f));
9889 9890
9890 EXPECT_EQ(gfx::Rect(15, 15), test_layer->visible_layer_rect()); 9891 EXPECT_EQ(gfx::Rect(15, 15), test_layer->visible_layer_rect());
9891 } 9892 }
9892 9893
9893 TEST_F(LayerTreeHostCommonTest, LargeTransformTest) { 9894 TEST_F(LayerTreeHostCommonTest, LargeTransformTest) {
9894 LayerImpl* root = root_layer(); 9895 LayerImpl* root = root_layer_for_testing();
9895 LayerImpl* render_surface1 = AddChild<LayerImpl>(root); 9896 LayerImpl* render_surface1 = AddChild<LayerImpl>(root);
9896 LayerImpl* child = AddChild<LayerImpl>(render_surface1); 9897 LayerImpl* child = AddChild<LayerImpl>(render_surface1);
9897 9898
9898 const gfx::Transform identity_matrix; 9899 const gfx::Transform identity_matrix;
9899 child->SetDrawsContent(true); 9900 child->SetDrawsContent(true);
9900 child->SetMasksToBounds(true); 9901 child->SetMasksToBounds(true);
9901 9902
9902 gfx::Transform large_transform; 9903 gfx::Transform large_transform;
9903 large_transform.Scale(99999999999999999999.f, 99999999999999999999.f); 9904 large_transform.Scale(99999999999999999999.f, 99999999999999999999.f);
9904 large_transform.Scale(9999999999999999999.f, 9999999999999999999.f); 9905 large_transform.Scale(9999999999999999999.f, 9999999999999999999.f);
(...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after
10326 EXPECT_EQ(scroll_child6.id, grand_child10->scroll_tree_index()); 10327 EXPECT_EQ(scroll_child6.id, grand_child10->scroll_tree_index());
10327 EXPECT_EQ(scroll_root1.id, parent3->scroll_tree_index()); 10328 EXPECT_EQ(scroll_root1.id, parent3->scroll_tree_index());
10328 EXPECT_EQ(scroll_child7.id, child8->scroll_tree_index()); 10329 EXPECT_EQ(scroll_child7.id, child8->scroll_tree_index());
10329 EXPECT_EQ(scroll_root1.id, parent4->scroll_tree_index()); 10330 EXPECT_EQ(scroll_root1.id, parent4->scroll_tree_index());
10330 EXPECT_EQ(scroll_root1.id, child9->scroll_tree_index()); 10331 EXPECT_EQ(scroll_root1.id, child9->scroll_tree_index());
10331 EXPECT_EQ(scroll_root1.id, grand_child12->scroll_tree_index()); 10332 EXPECT_EQ(scroll_root1.id, grand_child12->scroll_tree_index());
10332 } 10333 }
10333 10334
10334 } // namespace 10335 } // namespace
10335 } // namespace cc 10336 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_host_common_perftest.cc ('k') | cc/trees/layer_tree_host_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698