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

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

Issue 1101823002: CC Animations: Make LayerAnimationController creation optional (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Plumb LayerSettings parameter for cc::Layer construction. Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2011 The Chromium Authors. All rights reserved. 1 // Copyright 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "cc/trees/layer_tree_host_common.h" 5 #include "cc/trees/layer_tree_host_common.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <set> 8 #include <set>
9 9
10 #include "cc/animation/layer_animation_controller.h" 10 #include "cc/animation/layer_animation_controller.h"
(...skipping 28 matching lines...) Expand all
39 #include "testing/gtest/include/gtest/gtest.h" 39 #include "testing/gtest/include/gtest/gtest.h"
40 #include "ui/gfx/geometry/quad_f.h" 40 #include "ui/gfx/geometry/quad_f.h"
41 #include "ui/gfx/geometry/vector2d_conversions.h" 41 #include "ui/gfx/geometry/vector2d_conversions.h"
42 #include "ui/gfx/transform.h" 42 #include "ui/gfx/transform.h"
43 43
44 namespace cc { 44 namespace cc {
45 namespace { 45 namespace {
46 46
47 class LayerWithForcedDrawsContent : public Layer { 47 class LayerWithForcedDrawsContent : public Layer {
48 public: 48 public:
49 LayerWithForcedDrawsContent() {} 49 explicit LayerWithForcedDrawsContent(const LayerSettings& settings)
50 : Layer(settings) {}
50 51
51 bool DrawsContent() const override; 52 bool DrawsContent() const override;
52 53
53 private: 54 private:
54 ~LayerWithForcedDrawsContent() override {} 55 ~LayerWithForcedDrawsContent() override {}
55 }; 56 };
56 57
57 bool LayerWithForcedDrawsContent::DrawsContent() const { return true; } 58 bool LayerWithForcedDrawsContent::DrawsContent() const { return true; }
58 59
59 class MockContentLayerClient : public ContentLayerClient { 60 class MockContentLayerClient : public ContentLayerClient {
60 public: 61 public:
61 MockContentLayerClient() {} 62 MockContentLayerClient() {}
62 ~MockContentLayerClient() override {} 63 ~MockContentLayerClient() override {}
63 void PaintContents(SkCanvas* canvas, 64 void PaintContents(SkCanvas* canvas,
64 const gfx::Rect& clip, 65 const gfx::Rect& clip,
65 PaintingControlSetting picture_control) override {} 66 PaintingControlSetting picture_control) override {}
66 void PaintContentsToDisplayList( 67 void PaintContentsToDisplayList(
67 DisplayItemList* display_list, 68 DisplayItemList* display_list,
68 const gfx::Rect& clip, 69 const gfx::Rect& clip,
69 PaintingControlSetting picture_control) override { 70 PaintingControlSetting picture_control) override {
70 NOTIMPLEMENTED(); 71 NOTIMPLEMENTED();
71 } 72 }
72 bool FillsBoundsCompletely() const override { return false; } 73 bool FillsBoundsCompletely() const override { return false; }
73 }; 74 };
74 75
75 scoped_refptr<FakePictureLayer> CreateDrawablePictureLayer( 76 scoped_refptr<FakePictureLayer> CreateDrawablePictureLayer(
77 const LayerSettings& settings,
76 ContentLayerClient* delegate) { 78 ContentLayerClient* delegate) {
77 scoped_refptr<FakePictureLayer> to_return = 79 scoped_refptr<FakePictureLayer> to_return =
78 FakePictureLayer::Create(delegate); 80 FakePictureLayer::Create(settings, delegate);
79 to_return->SetIsDrawable(true); 81 to_return->SetIsDrawable(true);
80 return to_return; 82 return to_return;
81 } 83 }
82 84
83 scoped_refptr<ContentLayer> CreateDrawableContentLayer( 85 scoped_refptr<ContentLayer> CreateDrawableContentLayer(
86 const LayerSettings& settings,
84 ContentLayerClient* delegate) { 87 ContentLayerClient* delegate) {
85 scoped_refptr<ContentLayer> to_return = ContentLayer::Create(delegate); 88 scoped_refptr<ContentLayer> to_return =
89 ContentLayer::Create(settings, delegate);
86 to_return->SetIsDrawable(true); 90 to_return->SetIsDrawable(true);
87 return to_return; 91 return to_return;
88 } 92 }
89 93
90 #define EXPECT_CONTENTS_SCALE_EQ(expected, layer) \ 94 #define EXPECT_CONTENTS_SCALE_EQ(expected, layer) \
91 do { \ 95 do { \
92 EXPECT_FLOAT_EQ(expected, layer->contents_scale_x()); \ 96 EXPECT_FLOAT_EQ(expected, layer->contents_scale_x()); \
93 EXPECT_FLOAT_EQ(expected, layer->contents_scale_y()); \ 97 EXPECT_FLOAT_EQ(expected, layer->contents_scale_y()); \
94 } while (false) 98 } while (false)
95 99
96 #define EXPECT_IDEAL_SCALE_EQ(expected, layer) \ 100 #define EXPECT_IDEAL_SCALE_EQ(expected, layer) \
97 do { \ 101 do { \
98 EXPECT_FLOAT_EQ(expected, layer->draw_properties().ideal_contents_scale); \ 102 EXPECT_FLOAT_EQ(expected, layer->draw_properties().ideal_contents_scale); \
99 } while (false) 103 } while (false)
100 104
101 TEST_F(LayerTreeHostCommonTest, TransformsForNoOpLayer) { 105 TEST_F(LayerTreeHostCommonTest, TransformsForNoOpLayer) {
102 // Sanity check: For layers positioned at zero, with zero size, 106 // Sanity check: For layers positioned at zero, with zero size,
103 // and with identity transforms, then the draw transform, 107 // and with identity transforms, then the draw transform,
104 // screen space transform, and the hierarchy passed on to children 108 // screen space transform, and the hierarchy passed on to children
105 // layers should also be identity transforms. 109 // layers should also be identity transforms.
106 110
107 scoped_refptr<Layer> parent = Layer::Create(); 111 scoped_refptr<Layer> parent = Layer::Create(layer_settings());
108 scoped_refptr<Layer> child = Layer::Create(); 112 scoped_refptr<Layer> child = Layer::Create(layer_settings());
109 scoped_refptr<Layer> grand_child = Layer::Create(); 113 scoped_refptr<Layer> grand_child = Layer::Create(layer_settings());
110 parent->AddChild(child); 114 parent->AddChild(child);
111 child->AddChild(grand_child); 115 child->AddChild(grand_child);
112 116
113 scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost()); 117 scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost());
114 host->SetRootLayer(parent); 118 host->SetRootLayer(parent);
115 119
116 gfx::Transform identity_matrix; 120 gfx::Transform identity_matrix;
117 SetLayerPropertiesForTesting(parent.get(), 121 SetLayerPropertiesForTesting(parent.get(),
118 identity_matrix, 122 identity_matrix,
119 gfx::Point3F(), 123 gfx::Point3F(),
(...skipping 21 matching lines...) Expand all
141 EXPECT_TRANSFORMATION_MATRIX_EQ(identity_matrix, child->draw_transform()); 145 EXPECT_TRANSFORMATION_MATRIX_EQ(identity_matrix, child->draw_transform());
142 EXPECT_TRANSFORMATION_MATRIX_EQ(identity_matrix, 146 EXPECT_TRANSFORMATION_MATRIX_EQ(identity_matrix,
143 child->screen_space_transform()); 147 child->screen_space_transform());
144 EXPECT_TRANSFORMATION_MATRIX_EQ(identity_matrix, 148 EXPECT_TRANSFORMATION_MATRIX_EQ(identity_matrix,
145 grand_child->draw_transform()); 149 grand_child->draw_transform());
146 EXPECT_TRANSFORMATION_MATRIX_EQ(identity_matrix, 150 EXPECT_TRANSFORMATION_MATRIX_EQ(identity_matrix,
147 grand_child->screen_space_transform()); 151 grand_child->screen_space_transform());
148 } 152 }
149 153
150 TEST_F(LayerTreeHostCommonTest, DoNotSkipLayersWithHandlers) { 154 TEST_F(LayerTreeHostCommonTest, DoNotSkipLayersWithHandlers) {
151 scoped_refptr<Layer> parent = Layer::Create(); 155 scoped_refptr<Layer> parent = Layer::Create(layer_settings());
152 scoped_refptr<Layer> child = Layer::Create(); 156 scoped_refptr<Layer> child = Layer::Create(layer_settings());
153 scoped_refptr<Layer> grand_child = Layer::Create(); 157 scoped_refptr<Layer> grand_child = Layer::Create(layer_settings());
154 parent->AddChild(child); 158 parent->AddChild(child);
155 child->AddChild(grand_child); 159 child->AddChild(grand_child);
156 160
157 scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost()); 161 scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost());
158 host->SetRootLayer(parent); 162 host->SetRootLayer(parent);
159 163
160 gfx::Transform identity_matrix; 164 gfx::Transform identity_matrix;
161 SetLayerPropertiesForTesting(parent.get(), 165 SetLayerPropertiesForTesting(parent.get(),
162 identity_matrix, 166 identity_matrix,
163 gfx::Point3F(), 167 gfx::Point3F(),
(...skipping 24 matching lines...) Expand all
188 ExecuteCalculateDrawProperties(parent.get()); 192 ExecuteCalculateDrawProperties(parent.get());
189 193
190 // Check that we've computed draw properties for the subtree rooted at 194 // Check that we've computed draw properties for the subtree rooted at
191 // |child|. 195 // |child|.
192 EXPECT_FALSE(child->draw_transform().IsIdentity()); 196 EXPECT_FALSE(child->draw_transform().IsIdentity());
193 EXPECT_FALSE(grand_child->draw_transform().IsIdentity()); 197 EXPECT_FALSE(grand_child->draw_transform().IsIdentity());
194 } 198 }
195 199
196 TEST_F(LayerTreeHostCommonTest, TransformsForSingleLayer) { 200 TEST_F(LayerTreeHostCommonTest, TransformsForSingleLayer) {
197 gfx::Transform identity_matrix; 201 gfx::Transform identity_matrix;
198 scoped_refptr<Layer> layer = Layer::Create(); 202 scoped_refptr<Layer> layer = Layer::Create(layer_settings());
199 203
200 scoped_refptr<Layer> root = Layer::Create(); 204 scoped_refptr<Layer> root = Layer::Create(layer_settings());
201 SetLayerPropertiesForTesting(root.get(), 205 SetLayerPropertiesForTesting(root.get(),
202 identity_matrix, 206 identity_matrix,
203 gfx::Point3F(), 207 gfx::Point3F(),
204 gfx::PointF(), 208 gfx::PointF(),
205 gfx::Size(1, 2), 209 gfx::Size(1, 2),
206 true, 210 true,
207 false); 211 false);
208 root->AddChild(layer); 212 root->AddChild(layer);
209 213
210 scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost()); 214 scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost());
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
386 MathUtil::Round(kTranslateX * kPageScale * kDeviceScale + 390 MathUtil::Round(kTranslateX * kPageScale * kDeviceScale +
387 sub_layer_screen_position.x()), 391 sub_layer_screen_position.x()),
388 MathUtil::Round(kTranslateY * kPageScale * kDeviceScale + 392 MathUtil::Round(kTranslateY * kPageScale * kDeviceScale +
389 sub_layer_screen_position.y())); 393 sub_layer_screen_position.y()));
390 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_transform, 394 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_transform,
391 sublayer->draw_transform()); 395 sublayer->draw_transform());
392 } 396 }
393 397
394 TEST_F(LayerTreeHostCommonTest, TransformsForSimpleHierarchy) { 398 TEST_F(LayerTreeHostCommonTest, TransformsForSimpleHierarchy) {
395 gfx::Transform identity_matrix; 399 gfx::Transform identity_matrix;
396 scoped_refptr<Layer> root = Layer::Create(); 400 scoped_refptr<Layer> root = Layer::Create(layer_settings());
397 scoped_refptr<Layer> parent = Layer::Create(); 401 scoped_refptr<Layer> parent = Layer::Create(layer_settings());
398 scoped_refptr<Layer> child = Layer::Create(); 402 scoped_refptr<Layer> child = Layer::Create(layer_settings());
399 scoped_refptr<Layer> grand_child = Layer::Create(); 403 scoped_refptr<Layer> grand_child = Layer::Create(layer_settings());
400 root->AddChild(parent); 404 root->AddChild(parent);
401 parent->AddChild(child); 405 parent->AddChild(child);
402 child->AddChild(grand_child); 406 child->AddChild(grand_child);
403 407
404 scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost()); 408 scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost());
405 host->SetRootLayer(root); 409 host->SetRootLayer(root);
406 410
407 // One-time setup of root layer 411 // One-time setup of root layer
408 SetLayerPropertiesForTesting(root.get(), 412 SetLayerPropertiesForTesting(root.get(),
409 identity_matrix, 413 identity_matrix,
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
512 child->draw_transform()); 516 child->draw_transform());
513 EXPECT_TRANSFORMATION_MATRIX_EQ(parent_composite_transform, 517 EXPECT_TRANSFORMATION_MATRIX_EQ(parent_composite_transform,
514 child->screen_space_transform()); 518 child->screen_space_transform());
515 EXPECT_TRANSFORMATION_MATRIX_EQ(parent_composite_transform, 519 EXPECT_TRANSFORMATION_MATRIX_EQ(parent_composite_transform,
516 grand_child->draw_transform()); 520 grand_child->draw_transform());
517 EXPECT_TRANSFORMATION_MATRIX_EQ(parent_composite_transform, 521 EXPECT_TRANSFORMATION_MATRIX_EQ(parent_composite_transform,
518 grand_child->screen_space_transform()); 522 grand_child->screen_space_transform());
519 } 523 }
520 524
521 TEST_F(LayerTreeHostCommonTest, TransformsForSingleRenderSurface) { 525 TEST_F(LayerTreeHostCommonTest, TransformsForSingleRenderSurface) {
522 scoped_refptr<Layer> root = Layer::Create(); 526 scoped_refptr<Layer> root = Layer::Create(layer_settings());
523 scoped_refptr<Layer> parent = Layer::Create(); 527 scoped_refptr<Layer> parent = Layer::Create(layer_settings());
524 scoped_refptr<Layer> child = Layer::Create(); 528 scoped_refptr<Layer> child = Layer::Create(layer_settings());
525 scoped_refptr<LayerWithForcedDrawsContent> grand_child = 529 scoped_refptr<LayerWithForcedDrawsContent> grand_child =
526 make_scoped_refptr(new LayerWithForcedDrawsContent()); 530 make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
527 root->AddChild(parent); 531 root->AddChild(parent);
528 parent->AddChild(child); 532 parent->AddChild(child);
529 child->AddChild(grand_child); 533 child->AddChild(grand_child);
530 534
531 scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost()); 535 scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost());
532 host->SetRootLayer(root); 536 host->SetRootLayer(root);
533 537
534 // One-time setup of root layer 538 // One-time setup of root layer
535 gfx::Transform identity_matrix; 539 gfx::Transform identity_matrix;
536 SetLayerPropertiesForTesting(root.get(), 540 SetLayerPropertiesForTesting(root.get(),
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
607 child->render_target()->render_surface()->draw_transform()); 611 child->render_target()->render_surface()->draw_transform());
608 612
609 // The screen space is the same as the target since the child surface draws 613 // The screen space is the same as the target since the child surface draws
610 // into the root. 614 // into the root.
611 EXPECT_TRANSFORMATION_MATRIX_EQ( 615 EXPECT_TRANSFORMATION_MATRIX_EQ(
612 surface_sublayer_composite_transform, 616 surface_sublayer_composite_transform,
613 child->render_target()->render_surface()->screen_space_transform()); 617 child->render_target()->render_surface()->screen_space_transform());
614 } 618 }
615 619
616 TEST_F(LayerTreeHostCommonTest, TransformsForReplica) { 620 TEST_F(LayerTreeHostCommonTest, TransformsForReplica) {
617 scoped_refptr<Layer> root = Layer::Create(); 621 scoped_refptr<Layer> root = Layer::Create(layer_settings());
618 scoped_refptr<Layer> parent = Layer::Create(); 622 scoped_refptr<Layer> parent = Layer::Create(layer_settings());
619 scoped_refptr<Layer> child = Layer::Create(); 623 scoped_refptr<Layer> child = Layer::Create(layer_settings());
620 scoped_refptr<Layer> child_replica = Layer::Create(); 624 scoped_refptr<Layer> child_replica = Layer::Create(layer_settings());
621 scoped_refptr<LayerWithForcedDrawsContent> grand_child = 625 scoped_refptr<LayerWithForcedDrawsContent> grand_child =
622 make_scoped_refptr(new LayerWithForcedDrawsContent()); 626 make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
623 root->AddChild(parent); 627 root->AddChild(parent);
624 parent->AddChild(child); 628 parent->AddChild(child);
625 child->AddChild(grand_child); 629 child->AddChild(grand_child);
626 child->SetReplicaLayer(child_replica.get()); 630 child->SetReplicaLayer(child_replica.get());
627 631
628 scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost()); 632 scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost());
629 host->SetRootLayer(root); 633 host->SetRootLayer(root);
630 634
631 // One-time setup of root layer 635 // One-time setup of root layer
632 gfx::Transform identity_matrix; 636 gfx::Transform identity_matrix;
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
713 // transforms described w.r.t. that surface 717 // transforms described w.r.t. that surface
714 // - A render surface described w.r.t. an ancestor render surface: should 718 // - A render surface described w.r.t. an ancestor render surface: should
715 // have a draw transform described w.r.t. that ancestor surface 719 // have a draw transform described w.r.t. that ancestor surface
716 // - Replicas of a render surface are described w.r.t. the replica's 720 // - Replicas of a render surface are described w.r.t. the replica's
717 // transform around its anchor, along with the surface itself. 721 // transform around its anchor, along with the surface itself.
718 // - Sanity check on recursion: verify transforms of layers described w.r.t. 722 // - Sanity check on recursion: verify transforms of layers described w.r.t.
719 // a render surface that is described w.r.t. an ancestor render surface. 723 // a render surface that is described w.r.t. an ancestor render surface.
720 // - verifying that each layer has a reference to the correct render surface 724 // - verifying that each layer has a reference to the correct render surface
721 // and render target values. 725 // and render target values.
722 726
723 scoped_refptr<Layer> root = Layer::Create(); 727 scoped_refptr<Layer> root = Layer::Create(layer_settings());
724 scoped_refptr<Layer> parent = Layer::Create(); 728 scoped_refptr<Layer> parent = Layer::Create(layer_settings());
725 scoped_refptr<Layer> render_surface1 = Layer::Create(); 729 scoped_refptr<Layer> render_surface1 = Layer::Create(layer_settings());
726 scoped_refptr<Layer> render_surface2 = Layer::Create(); 730 scoped_refptr<Layer> render_surface2 = Layer::Create(layer_settings());
727 scoped_refptr<Layer> child_of_root = Layer::Create(); 731 scoped_refptr<Layer> child_of_root = Layer::Create(layer_settings());
728 scoped_refptr<Layer> child_of_rs1 = Layer::Create(); 732 scoped_refptr<Layer> child_of_rs1 = Layer::Create(layer_settings());
729 scoped_refptr<Layer> child_of_rs2 = Layer::Create(); 733 scoped_refptr<Layer> child_of_rs2 = Layer::Create(layer_settings());
730 scoped_refptr<Layer> replica_of_rs1 = Layer::Create(); 734 scoped_refptr<Layer> replica_of_rs1 = Layer::Create(layer_settings());
731 scoped_refptr<Layer> replica_of_rs2 = Layer::Create(); 735 scoped_refptr<Layer> replica_of_rs2 = Layer::Create(layer_settings());
732 scoped_refptr<Layer> grand_child_of_root = Layer::Create(); 736 scoped_refptr<Layer> grand_child_of_root = Layer::Create(layer_settings());
733 scoped_refptr<LayerWithForcedDrawsContent> grand_child_of_rs1 = 737 scoped_refptr<LayerWithForcedDrawsContent> grand_child_of_rs1 =
734 make_scoped_refptr(new LayerWithForcedDrawsContent()); 738 make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
735 scoped_refptr<LayerWithForcedDrawsContent> grand_child_of_rs2 = 739 scoped_refptr<LayerWithForcedDrawsContent> grand_child_of_rs2 =
736 make_scoped_refptr(new LayerWithForcedDrawsContent()); 740 make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
737 root->AddChild(parent); 741 root->AddChild(parent);
738 parent->AddChild(render_surface1); 742 parent->AddChild(render_surface1);
739 parent->AddChild(child_of_root); 743 parent->AddChild(child_of_root);
740 render_surface1->AddChild(child_of_rs1); 744 render_surface1->AddChild(child_of_rs1);
741 render_surface1->AddChild(render_surface2); 745 render_surface1->AddChild(render_surface2);
742 render_surface2->AddChild(child_of_rs2); 746 render_surface2->AddChild(child_of_rs2);
743 child_of_root->AddChild(grand_child_of_root); 747 child_of_root->AddChild(grand_child_of_root);
744 child_of_rs1->AddChild(grand_child_of_rs1); 748 child_of_rs1->AddChild(grand_child_of_rs1);
745 child_of_rs2->AddChild(grand_child_of_rs2); 749 child_of_rs2->AddChild(grand_child_of_rs2);
746 render_surface1->SetReplicaLayer(replica_of_rs1.get()); 750 render_surface1->SetReplicaLayer(replica_of_rs1.get());
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after
999 EXPECT_FLOAT_EQ( 1003 EXPECT_FLOAT_EQ(
1000 5.0, grand_child_of_rs2->screen_space_transform().matrix().get(1, 3)); 1004 5.0, grand_child_of_rs2->screen_space_transform().matrix().get(1, 3));
1001 } 1005 }
1002 1006
1003 TEST_F(LayerTreeHostCommonTest, TransformsForFlatteningLayer) { 1007 TEST_F(LayerTreeHostCommonTest, TransformsForFlatteningLayer) {
1004 // For layers that flatten their subtree, there should be an orthographic 1008 // For layers that flatten their subtree, there should be an orthographic
1005 // projection (for x and y values) in the middle of the transform sequence. 1009 // projection (for x and y values) in the middle of the transform sequence.
1006 // Note that the way the code is currently implemented, it is not expected to 1010 // Note that the way the code is currently implemented, it is not expected to
1007 // use a canonical orthographic projection. 1011 // use a canonical orthographic projection.
1008 1012
1009 scoped_refptr<Layer> root = Layer::Create(); 1013 scoped_refptr<Layer> root = Layer::Create(layer_settings());
1010 scoped_refptr<Layer> child = Layer::Create(); 1014 scoped_refptr<Layer> child = Layer::Create(layer_settings());
1011 scoped_refptr<LayerWithForcedDrawsContent> grand_child = 1015 scoped_refptr<LayerWithForcedDrawsContent> grand_child =
1012 make_scoped_refptr(new LayerWithForcedDrawsContent()); 1016 make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
1013 scoped_refptr<LayerWithForcedDrawsContent> great_grand_child = 1017 scoped_refptr<LayerWithForcedDrawsContent> great_grand_child =
1014 make_scoped_refptr(new LayerWithForcedDrawsContent()); 1018 make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
1015 1019
1016 gfx::Transform rotation_about_y_axis; 1020 gfx::Transform rotation_about_y_axis;
1017 rotation_about_y_axis.RotateAboutYAxis(30.0); 1021 rotation_about_y_axis.RotateAboutYAxis(30.0);
1018 1022
1019 const gfx::Transform identity_matrix; 1023 const gfx::Transform identity_matrix;
1020 SetLayerPropertiesForTesting(root.get(), 1024 SetLayerPropertiesForTesting(root.get(),
1021 identity_matrix, 1025 identity_matrix,
1022 gfx::Point3F(), 1026 gfx::Point3F(),
1023 gfx::PointF(), 1027 gfx::PointF(),
1024 gfx::Size(100, 100), 1028 gfx::Size(100, 100),
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
1095 TEST_F(LayerTreeHostCommonTest, TransformsForDegenerateIntermediateLayer) { 1099 TEST_F(LayerTreeHostCommonTest, TransformsForDegenerateIntermediateLayer) {
1096 // A layer that is empty in one axis, but not the other, was accidentally 1100 // A layer that is empty in one axis, but not the other, was accidentally
1097 // skipping a necessary translation. Without that translation, the coordinate 1101 // skipping a necessary translation. Without that translation, the coordinate
1098 // space of the layer's draw transform is incorrect. 1102 // space of the layer's draw transform is incorrect.
1099 // 1103 //
1100 // Normally this isn't a problem, because the layer wouldn't be drawn anyway, 1104 // Normally this isn't a problem, because the layer wouldn't be drawn anyway,
1101 // but if that layer becomes a render surface, then its draw transform is 1105 // but if that layer becomes a render surface, then its draw transform is
1102 // implicitly inherited by the rest of the subtree, which then is positioned 1106 // implicitly inherited by the rest of the subtree, which then is positioned
1103 // incorrectly as a result. 1107 // incorrectly as a result.
1104 1108
1105 scoped_refptr<Layer> root = Layer::Create(); 1109 scoped_refptr<Layer> root = Layer::Create(layer_settings());
1106 scoped_refptr<Layer> child = Layer::Create(); 1110 scoped_refptr<Layer> child = Layer::Create(layer_settings());
1107 scoped_refptr<LayerWithForcedDrawsContent> grand_child = 1111 scoped_refptr<LayerWithForcedDrawsContent> grand_child =
1108 make_scoped_refptr(new LayerWithForcedDrawsContent()); 1112 make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
1109 1113
1110 // The child height is zero, but has non-zero width that should be accounted 1114 // The child height is zero, but has non-zero width that should be accounted
1111 // for while computing draw transforms. 1115 // for while computing draw transforms.
1112 const gfx::Transform identity_matrix; 1116 const gfx::Transform identity_matrix;
1113 SetLayerPropertiesForTesting(root.get(), 1117 SetLayerPropertiesForTesting(root.get(),
1114 identity_matrix, 1118 identity_matrix,
1115 gfx::Point3F(), 1119 gfx::Point3F(),
1116 gfx::PointF(), 1120 gfx::PointF(),
1117 gfx::Size(100, 100), 1121 gfx::Size(100, 100),
1118 true, 1122 true,
(...skipping 29 matching lines...) Expand all
1148 EXPECT_TRANSFORMATION_MATRIX_EQ(identity_matrix, child->draw_transform()); 1152 EXPECT_TRANSFORMATION_MATRIX_EQ(identity_matrix, child->draw_transform());
1149 EXPECT_TRANSFORMATION_MATRIX_EQ(identity_matrix, 1153 EXPECT_TRANSFORMATION_MATRIX_EQ(identity_matrix,
1150 grand_child->draw_transform()); 1154 grand_child->draw_transform());
1151 } 1155 }
1152 1156
1153 TEST_F(LayerTreeHostCommonTest, TransformAboveRootLayer) { 1157 TEST_F(LayerTreeHostCommonTest, TransformAboveRootLayer) {
1154 // Transformations applied at the root of the tree should be forwarded 1158 // Transformations applied at the root of the tree should be forwarded
1155 // to child layers instead of applied to the root RenderSurface. 1159 // to child layers instead of applied to the root RenderSurface.
1156 const gfx::Transform identity_matrix; 1160 const gfx::Transform identity_matrix;
1157 scoped_refptr<LayerWithForcedDrawsContent> root = 1161 scoped_refptr<LayerWithForcedDrawsContent> root =
1158 new LayerWithForcedDrawsContent; 1162 new LayerWithForcedDrawsContent(layer_settings());
1159 scoped_refptr<LayerWithForcedDrawsContent> child = 1163 scoped_refptr<LayerWithForcedDrawsContent> child =
1160 new LayerWithForcedDrawsContent; 1164 new LayerWithForcedDrawsContent(layer_settings());
1161 child->SetScrollClipLayerId(root->id()); 1165 child->SetScrollClipLayerId(root->id());
1162 root->AddChild(child); 1166 root->AddChild(child);
1163 1167
1164 scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost()); 1168 scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost());
1165 host->SetRootLayer(root); 1169 host->SetRootLayer(root);
1166 1170
1167 SetLayerPropertiesForTesting(root.get(), 1171 SetLayerPropertiesForTesting(root.get(),
1168 identity_matrix, 1172 identity_matrix,
1169 gfx::Point3F(), 1173 gfx::Point3F(),
1170 gfx::PointF(), 1174 gfx::PointF(),
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
1302 EXPECT_TRANSFORMATION_MATRIX_EQ( 1306 EXPECT_TRANSFORMATION_MATRIX_EQ(
1303 compositeSquared, root->draw_properties().target_space_transform); 1307 compositeSquared, root->draw_properties().target_space_transform);
1304 EXPECT_TRANSFORMATION_MATRIX_EQ( 1308 EXPECT_TRANSFORMATION_MATRIX_EQ(
1305 compositeSquared, child->draw_properties().target_space_transform); 1309 compositeSquared, child->draw_properties().target_space_transform);
1306 EXPECT_EQ(identity_matrix, root->render_surface()->draw_transform()); 1310 EXPECT_EQ(identity_matrix, root->render_surface()->draw_transform());
1307 } 1311 }
1308 } 1312 }
1309 1313
1310 TEST_F(LayerTreeHostCommonTest, 1314 TEST_F(LayerTreeHostCommonTest,
1311 RenderSurfaceListForRenderSurfaceWithClippedLayer) { 1315 RenderSurfaceListForRenderSurfaceWithClippedLayer) {
1312 scoped_refptr<Layer> parent = Layer::Create(); 1316 scoped_refptr<Layer> parent = Layer::Create(layer_settings());
1313 scoped_refptr<Layer> render_surface1 = Layer::Create(); 1317 scoped_refptr<Layer> render_surface1 = Layer::Create(layer_settings());
1314 scoped_refptr<LayerWithForcedDrawsContent> child = 1318 scoped_refptr<LayerWithForcedDrawsContent> child =
1315 make_scoped_refptr(new LayerWithForcedDrawsContent()); 1319 make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
1316 1320
1317 scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost()); 1321 scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost());
1318 host->SetRootLayer(parent); 1322 host->SetRootLayer(parent);
1319 1323
1320 const gfx::Transform identity_matrix; 1324 const gfx::Transform identity_matrix;
1321 SetLayerPropertiesForTesting(parent.get(), 1325 SetLayerPropertiesForTesting(parent.get(),
1322 identity_matrix, 1326 identity_matrix,
1323 gfx::Point3F(), 1327 gfx::Point3F(),
1324 gfx::PointF(), 1328 gfx::PointF(),
1325 gfx::Size(10, 10), 1329 gfx::Size(10, 10),
(...skipping 30 matching lines...) Expand all
1356 // The child layer's content is entirely outside the parent's clip rect, so 1360 // The child layer's content is entirely outside the parent's clip rect, so
1357 // the intermediate render surface should not be listed here, even if it was 1361 // the intermediate render surface should not be listed here, even if it was
1358 // forced to be created. Render surfaces without children or visible content 1362 // forced to be created. Render surfaces without children or visible content
1359 // are unexpected at draw time (e.g. we might try to create a content texture 1363 // are unexpected at draw time (e.g. we might try to create a content texture
1360 // of size 0). 1364 // of size 0).
1361 ASSERT_TRUE(parent->render_surface()); 1365 ASSERT_TRUE(parent->render_surface());
1362 EXPECT_EQ(1U, render_surface_layer_list.size()); 1366 EXPECT_EQ(1U, render_surface_layer_list.size());
1363 } 1367 }
1364 1368
1365 TEST_F(LayerTreeHostCommonTest, RenderSurfaceListForTransparentChild) { 1369 TEST_F(LayerTreeHostCommonTest, RenderSurfaceListForTransparentChild) {
1366 scoped_refptr<Layer> parent = Layer::Create(); 1370 scoped_refptr<Layer> parent = Layer::Create(layer_settings());
1367 scoped_refptr<Layer> render_surface1 = Layer::Create(); 1371 scoped_refptr<Layer> render_surface1 = Layer::Create(layer_settings());
1368 scoped_refptr<LayerWithForcedDrawsContent> child = 1372 scoped_refptr<LayerWithForcedDrawsContent> child =
1369 make_scoped_refptr(new LayerWithForcedDrawsContent()); 1373 make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
1370 1374
1371 scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost()); 1375 scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost());
1372 host->SetRootLayer(parent); 1376 host->SetRootLayer(parent);
1373 1377
1374 const gfx::Transform identity_matrix; 1378 const gfx::Transform identity_matrix;
1375 SetLayerPropertiesForTesting(render_surface1.get(), 1379 SetLayerPropertiesForTesting(render_surface1.get(),
1376 identity_matrix, 1380 identity_matrix,
1377 gfx::Point3F(), 1381 gfx::Point3F(),
1378 gfx::PointF(), 1382 gfx::PointF(),
1379 gfx::Size(10, 10), 1383 gfx::Size(10, 10),
(...skipping 22 matching lines...) Expand all
1402 // not have gotten added anywhere. Also, the drawable content rect should not 1406 // not have gotten added anywhere. Also, the drawable content rect should not
1403 // have been extended by the children. 1407 // have been extended by the children.
1404 ASSERT_TRUE(parent->render_surface()); 1408 ASSERT_TRUE(parent->render_surface());
1405 EXPECT_EQ(0U, parent->render_surface()->layer_list().size()); 1409 EXPECT_EQ(0U, parent->render_surface()->layer_list().size());
1406 EXPECT_EQ(1U, render_surface_layer_list.size()); 1410 EXPECT_EQ(1U, render_surface_layer_list.size());
1407 EXPECT_EQ(parent->id(), render_surface_layer_list.at(0)->id()); 1411 EXPECT_EQ(parent->id(), render_surface_layer_list.at(0)->id());
1408 EXPECT_EQ(gfx::Rect(), parent->drawable_content_rect()); 1412 EXPECT_EQ(gfx::Rect(), parent->drawable_content_rect());
1409 } 1413 }
1410 1414
1411 TEST_F(LayerTreeHostCommonTest, RenderSurfaceForBlendMode) { 1415 TEST_F(LayerTreeHostCommonTest, RenderSurfaceForBlendMode) {
1412 scoped_refptr<Layer> parent = Layer::Create(); 1416 scoped_refptr<Layer> parent = Layer::Create(layer_settings());
1413 scoped_refptr<LayerWithForcedDrawsContent> child = 1417 scoped_refptr<LayerWithForcedDrawsContent> child =
1414 make_scoped_refptr(new LayerWithForcedDrawsContent()); 1418 make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
1415 1419
1416 scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost()); 1420 scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost());
1417 host->SetRootLayer(parent); 1421 host->SetRootLayer(parent);
1418 1422
1419 const gfx::Transform identity_matrix; 1423 const gfx::Transform identity_matrix;
1420 const SkXfermode::Mode blend_mode = SkXfermode::kMultiply_Mode; 1424 const SkXfermode::Mode blend_mode = SkXfermode::kMultiply_Mode;
1421 SetLayerPropertiesForTesting(child.get(), identity_matrix, gfx::Point3F(), 1425 SetLayerPropertiesForTesting(child.get(), identity_matrix, gfx::Point3F(),
1422 gfx::PointF(), gfx::Size(10, 10), true, false); 1426 gfx::PointF(), gfx::Size(10, 10), true, false);
1423 1427
1424 parent->AddChild(child); 1428 parent->AddChild(child);
1425 child->SetBlendMode(blend_mode); 1429 child->SetBlendMode(blend_mode);
1426 1430
1427 RenderSurfaceLayerList render_surface_layer_list; 1431 RenderSurfaceLayerList render_surface_layer_list;
1428 LayerTreeHostCommon::CalcDrawPropsMainInputsForTesting inputs( 1432 LayerTreeHostCommon::CalcDrawPropsMainInputsForTesting inputs(
1429 parent.get(), parent->bounds(), &render_surface_layer_list); 1433 parent.get(), parent->bounds(), &render_surface_layer_list);
1430 LayerTreeHostCommon::CalculateDrawProperties(&inputs); 1434 LayerTreeHostCommon::CalculateDrawProperties(&inputs);
1431 1435
1432 // Since the child layer has a blend mode other than normal, it should get 1436 // Since the child layer has a blend mode other than normal, it should get
1433 // its own render surface. Also, layer's draw_properties should contain the 1437 // its own render surface. Also, layer's draw_properties should contain the
1434 // default blend mode, since the render surface becomes responsible for 1438 // default blend mode, since the render surface becomes responsible for
1435 // applying the blend mode. 1439 // applying the blend mode.
1436 ASSERT_TRUE(child->render_surface()); 1440 ASSERT_TRUE(child->render_surface());
1437 EXPECT_EQ(1U, child->render_surface()->layer_list().size()); 1441 EXPECT_EQ(1U, child->render_surface()->layer_list().size());
1438 EXPECT_EQ(SkXfermode::kSrcOver_Mode, child->draw_properties().blend_mode); 1442 EXPECT_EQ(SkXfermode::kSrcOver_Mode, child->draw_properties().blend_mode);
1439 } 1443 }
1440 1444
1441 TEST_F(LayerTreeHostCommonTest, ForceRenderSurface) { 1445 TEST_F(LayerTreeHostCommonTest, ForceRenderSurface) {
1442 scoped_refptr<Layer> parent = Layer::Create(); 1446 scoped_refptr<Layer> parent = Layer::Create(layer_settings());
1443 scoped_refptr<Layer> render_surface1 = Layer::Create(); 1447 scoped_refptr<Layer> render_surface1 = Layer::Create(layer_settings());
1444 scoped_refptr<LayerWithForcedDrawsContent> child = 1448 scoped_refptr<LayerWithForcedDrawsContent> child =
1445 make_scoped_refptr(new LayerWithForcedDrawsContent()); 1449 make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
1446 render_surface1->SetForceRenderSurface(true); 1450 render_surface1->SetForceRenderSurface(true);
1447 1451
1448 scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost()); 1452 scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost());
1449 host->SetRootLayer(parent); 1453 host->SetRootLayer(parent);
1450 1454
1451 const gfx::Transform identity_matrix; 1455 const gfx::Transform identity_matrix;
1452 SetLayerPropertiesForTesting(parent.get(), 1456 SetLayerPropertiesForTesting(parent.get(),
1453 identity_matrix, 1457 identity_matrix,
1454 gfx::Point3F(), 1458 gfx::Point3F(),
1455 gfx::PointF(), 1459 gfx::PointF(),
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
1501 EXPECT_TRUE(parent->render_surface()); 1505 EXPECT_TRUE(parent->render_surface());
1502 EXPECT_FALSE(render_surface1->render_surface()); 1506 EXPECT_FALSE(render_surface1->render_surface());
1503 EXPECT_EQ(1U, render_surface_layer_list.size()); 1507 EXPECT_EQ(1U, render_surface_layer_list.size());
1504 } 1508 }
1505 } 1509 }
1506 1510
1507 TEST_F(LayerTreeHostCommonTest, RenderSurfacesFlattenScreenSpaceTransform) { 1511 TEST_F(LayerTreeHostCommonTest, RenderSurfacesFlattenScreenSpaceTransform) {
1508 // Render surfaces act as a flattening point for their subtree, so should 1512 // Render surfaces act as a flattening point for their subtree, so should
1509 // always flatten the target-to-screen space transform seen by descendants. 1513 // always flatten the target-to-screen space transform seen by descendants.
1510 1514
1511 scoped_refptr<Layer> root = Layer::Create(); 1515 scoped_refptr<Layer> root = Layer::Create(layer_settings());
1512 scoped_refptr<Layer> parent = Layer::Create(); 1516 scoped_refptr<Layer> parent = Layer::Create(layer_settings());
1513 scoped_refptr<LayerWithForcedDrawsContent> child = 1517 scoped_refptr<LayerWithForcedDrawsContent> child =
1514 make_scoped_refptr(new LayerWithForcedDrawsContent()); 1518 make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
1515 scoped_refptr<LayerWithForcedDrawsContent> grand_child = 1519 scoped_refptr<LayerWithForcedDrawsContent> grand_child =
1516 make_scoped_refptr(new LayerWithForcedDrawsContent()); 1520 make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
1517 1521
1518 gfx::Transform rotation_about_y_axis; 1522 gfx::Transform rotation_about_y_axis;
1519 rotation_about_y_axis.RotateAboutYAxis(30.0); 1523 rotation_about_y_axis.RotateAboutYAxis(30.0);
1520 // Make |parent| have a render surface. 1524 // Make |parent| have a render surface.
1521 parent->SetOpacity(0.9f); 1525 parent->SetOpacity(0.9f);
1522 1526
1523 const gfx::Transform identity_matrix; 1527 const gfx::Transform identity_matrix;
1524 SetLayerPropertiesForTesting(root.get(), identity_matrix, gfx::Point3F(), 1528 SetLayerPropertiesForTesting(root.get(), identity_matrix, gfx::Point3F(),
1525 gfx::PointF(), gfx::Size(100, 100), true, false); 1529 gfx::PointF(), gfx::Size(100, 100), true, false);
1526 SetLayerPropertiesForTesting(parent.get(), rotation_about_y_axis, 1530 SetLayerPropertiesForTesting(parent.get(), rotation_about_y_axis,
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
1583 // - child has masksToBounds=true to cause clipping. 1587 // - child has masksToBounds=true to cause clipping.
1584 // - grand_child is positioned outside of the child's bounds 1588 // - grand_child is positioned outside of the child's bounds
1585 // - great_grand_child is also kept outside child's bounds. 1589 // - great_grand_child is also kept outside child's bounds.
1586 // 1590 //
1587 // In this configuration, grand_child and great_grand_child are completely 1591 // In this configuration, grand_child and great_grand_child are completely
1588 // outside the clip rect, and they should never get scheduled on the list of 1592 // outside the clip rect, and they should never get scheduled on the list of
1589 // render surfaces. 1593 // render surfaces.
1590 // 1594 //
1591 1595
1592 const gfx::Transform identity_matrix; 1596 const gfx::Transform identity_matrix;
1593 scoped_refptr<Layer> parent = Layer::Create(); 1597 scoped_refptr<Layer> parent = Layer::Create(layer_settings());
1594 scoped_refptr<Layer> child = Layer::Create(); 1598 scoped_refptr<Layer> child = Layer::Create(layer_settings());
1595 scoped_refptr<Layer> grand_child = Layer::Create(); 1599 scoped_refptr<Layer> grand_child = Layer::Create(layer_settings());
1596 scoped_refptr<Layer> great_grand_child = Layer::Create(); 1600 scoped_refptr<Layer> great_grand_child = Layer::Create(layer_settings());
1597 scoped_refptr<LayerWithForcedDrawsContent> leaf_node1 = 1601 scoped_refptr<LayerWithForcedDrawsContent> leaf_node1 =
1598 make_scoped_refptr(new LayerWithForcedDrawsContent()); 1602 make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
1599 scoped_refptr<LayerWithForcedDrawsContent> leaf_node2 = 1603 scoped_refptr<LayerWithForcedDrawsContent> leaf_node2 =
1600 make_scoped_refptr(new LayerWithForcedDrawsContent()); 1604 make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
1601 parent->AddChild(child); 1605 parent->AddChild(child);
1602 child->AddChild(grand_child); 1606 child->AddChild(grand_child);
1603 grand_child->AddChild(great_grand_child); 1607 grand_child->AddChild(great_grand_child);
1604 1608
1605 scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost()); 1609 scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost());
1606 host->SetRootLayer(parent); 1610 host->SetRootLayer(parent);
1607 1611
1608 // leaf_node1 ensures that parent and child are kept on the 1612 // leaf_node1 ensures that parent and child are kept on the
1609 // render_surface_layer_list, even though grand_child and great_grand_child 1613 // render_surface_layer_list, even though grand_child and great_grand_child
1610 // should be clipped. 1614 // should be clipped.
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
1684 // - grand_child is a render surface, and the only visible content in child. 1688 // - grand_child is a render surface, and the only visible content in child.
1685 // It is positioned outside of the clip rect from parent. 1689 // It is positioned outside of the clip rect from parent.
1686 1690
1687 // In this configuration, grand_child should be outside the clipped 1691 // In this configuration, grand_child should be outside the clipped
1688 // content rect of the child, making grand_child not appear in the 1692 // content rect of the child, making grand_child not appear in the
1689 // render_surface_layer_list. However, when we place an animation on the 1693 // render_surface_layer_list. However, when we place an animation on the
1690 // child, this clipping should be avoided and we should keep the grand_child 1694 // child, this clipping should be avoided and we should keep the grand_child
1691 // in the render_surface_layer_list. 1695 // in the render_surface_layer_list.
1692 1696
1693 const gfx::Transform identity_matrix; 1697 const gfx::Transform identity_matrix;
1694 scoped_refptr<Layer> parent = Layer::Create(); 1698 scoped_refptr<Layer> parent = Layer::Create(layer_settings());
1695 scoped_refptr<Layer> child = Layer::Create(); 1699 scoped_refptr<Layer> child = Layer::Create(layer_settings());
1696 scoped_refptr<Layer> grand_child = Layer::Create(); 1700 scoped_refptr<Layer> grand_child = Layer::Create(layer_settings());
1697 scoped_refptr<LayerWithForcedDrawsContent> leaf_node = 1701 scoped_refptr<LayerWithForcedDrawsContent> leaf_node =
1698 make_scoped_refptr(new LayerWithForcedDrawsContent()); 1702 make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
1699 parent->AddChild(child); 1703 parent->AddChild(child);
1700 child->AddChild(grand_child); 1704 child->AddChild(grand_child);
1701 grand_child->AddChild(leaf_node); 1705 grand_child->AddChild(leaf_node);
1702 1706
1703 scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost()); 1707 scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost());
1704 host->SetRootLayer(parent); 1708 host->SetRootLayer(parent);
1705 1709
1706 SetLayerPropertiesForTesting(parent.get(), 1710 SetLayerPropertiesForTesting(parent.get(),
1707 identity_matrix, 1711 identity_matrix,
1708 gfx::Point3F(), 1712 gfx::Point3F(),
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
1779 // - a surface is clipped by an ancestor that contributes to the same 1783 // - a surface is clipped by an ancestor that contributes to the same
1780 // render target. 1784 // render target.
1781 // 1785 //
1782 // In particular, for a layer that owns a render surface: 1786 // In particular, for a layer that owns a render surface:
1783 // - the render surface inherits any clip from ancestors, and does NOT 1787 // - the render surface inherits any clip from ancestors, and does NOT
1784 // pass that clipped status to the layer itself. 1788 // pass that clipped status to the layer itself.
1785 // - but if the layer itself masks to bounds, it is considered clipped 1789 // - but if the layer itself masks to bounds, it is considered clipped
1786 // and propagates the clip to the subtree. 1790 // and propagates the clip to the subtree.
1787 1791
1788 const gfx::Transform identity_matrix; 1792 const gfx::Transform identity_matrix;
1789 scoped_refptr<Layer> root = Layer::Create(); 1793 scoped_refptr<Layer> root = Layer::Create(layer_settings());
1790 scoped_refptr<Layer> parent = Layer::Create(); 1794 scoped_refptr<Layer> parent = Layer::Create(layer_settings());
1791 scoped_refptr<Layer> child1 = Layer::Create(); 1795 scoped_refptr<Layer> child1 = Layer::Create(layer_settings());
1792 scoped_refptr<Layer> child2 = Layer::Create(); 1796 scoped_refptr<Layer> child2 = Layer::Create(layer_settings());
1793 scoped_refptr<Layer> grand_child = Layer::Create(); 1797 scoped_refptr<Layer> grand_child = Layer::Create(layer_settings());
1794 scoped_refptr<LayerWithForcedDrawsContent> leaf_node1 = 1798 scoped_refptr<LayerWithForcedDrawsContent> leaf_node1 =
1795 make_scoped_refptr(new LayerWithForcedDrawsContent()); 1799 make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
1796 scoped_refptr<LayerWithForcedDrawsContent> leaf_node2 = 1800 scoped_refptr<LayerWithForcedDrawsContent> leaf_node2 =
1797 make_scoped_refptr(new LayerWithForcedDrawsContent()); 1801 make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
1798 root->AddChild(parent); 1802 root->AddChild(parent);
1799 parent->AddChild(child1); 1803 parent->AddChild(child1);
1800 parent->AddChild(child2); 1804 parent->AddChild(child2);
1801 child1->AddChild(grand_child); 1805 child1->AddChild(grand_child);
1802 child2->AddChild(leaf_node2); 1806 child2->AddChild(leaf_node2);
1803 grand_child->AddChild(leaf_node1); 1807 grand_child->AddChild(leaf_node1);
1804 1808
1805 scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost()); 1809 scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost());
1806 host->SetRootLayer(root); 1810 host->SetRootLayer(root);
1807 1811
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
1940 // grand_child2 - partially clipped but NOT masksToBounds; the clip rect 1944 // grand_child2 - partially clipped but NOT masksToBounds; the clip rect
1941 // will be the intersection of layer bounds and the mask region. 1945 // will be the intersection of layer bounds and the mask region.
1942 // grand_child3 - partially clipped and masksToBounds; the 1946 // grand_child3 - partially clipped and masksToBounds; the
1943 // DrawableContentRect will still be the intersection of layer bounds and 1947 // DrawableContentRect will still be the intersection of layer bounds and
1944 // the mask region. 1948 // the mask region.
1945 // grand_child4 - outside parent's clip rect; the DrawableContentRect should 1949 // grand_child4 - outside parent's clip rect; the DrawableContentRect should
1946 // be empty. 1950 // be empty.
1947 // 1951 //
1948 1952
1949 const gfx::Transform identity_matrix; 1953 const gfx::Transform identity_matrix;
1950 scoped_refptr<Layer> parent = Layer::Create(); 1954 scoped_refptr<Layer> parent = Layer::Create(layer_settings());
1951 scoped_refptr<Layer> child = Layer::Create(); 1955 scoped_refptr<Layer> child = Layer::Create(layer_settings());
1952 scoped_refptr<Layer> grand_child1 = Layer::Create(); 1956 scoped_refptr<Layer> grand_child1 = Layer::Create(layer_settings());
1953 scoped_refptr<Layer> grand_child2 = Layer::Create(); 1957 scoped_refptr<Layer> grand_child2 = Layer::Create(layer_settings());
1954 scoped_refptr<Layer> grand_child3 = Layer::Create(); 1958 scoped_refptr<Layer> grand_child3 = Layer::Create(layer_settings());
1955 scoped_refptr<Layer> grand_child4 = Layer::Create(); 1959 scoped_refptr<Layer> grand_child4 = Layer::Create(layer_settings());
1956 1960
1957 parent->AddChild(child); 1961 parent->AddChild(child);
1958 child->AddChild(grand_child1); 1962 child->AddChild(grand_child1);
1959 child->AddChild(grand_child2); 1963 child->AddChild(grand_child2);
1960 child->AddChild(grand_child3); 1964 child->AddChild(grand_child3);
1961 child->AddChild(grand_child4); 1965 child->AddChild(grand_child4);
1962 1966
1963 scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost()); 1967 scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost());
1964 host->SetRootLayer(parent); 1968 host->SetRootLayer(parent);
1965 1969
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
2030 2034
2031 TEST_F(LayerTreeHostCommonTest, ClipRectIsPropagatedCorrectlyToSurfaces) { 2035 TEST_F(LayerTreeHostCommonTest, ClipRectIsPropagatedCorrectlyToSurfaces) {
2032 // Verify that render surfaces (and their layers) get the appropriate 2036 // Verify that render surfaces (and their layers) get the appropriate
2033 // clip rects when their parent masksToBounds is true. 2037 // clip rects when their parent masksToBounds is true.
2034 // 2038 //
2035 // Layers that own render surfaces (at least for now) do not inherit any 2039 // Layers that own render surfaces (at least for now) do not inherit any
2036 // clipping; instead the surface will enforce the clip for the entire subtree. 2040 // clipping; instead the surface will enforce the clip for the entire subtree.
2037 // They may still have a clip rect of their own layer bounds, however, if 2041 // They may still have a clip rect of their own layer bounds, however, if
2038 // masksToBounds was true. 2042 // masksToBounds was true.
2039 const gfx::Transform identity_matrix; 2043 const gfx::Transform identity_matrix;
2040 scoped_refptr<Layer> parent = Layer::Create(); 2044 scoped_refptr<Layer> parent = Layer::Create(layer_settings());
2041 scoped_refptr<Layer> child = Layer::Create(); 2045 scoped_refptr<Layer> child = Layer::Create(layer_settings());
2042 scoped_refptr<Layer> grand_child1 = Layer::Create(); 2046 scoped_refptr<Layer> grand_child1 = Layer::Create(layer_settings());
2043 scoped_refptr<Layer> grand_child2 = Layer::Create(); 2047 scoped_refptr<Layer> grand_child2 = Layer::Create(layer_settings());
2044 scoped_refptr<Layer> grand_child3 = Layer::Create(); 2048 scoped_refptr<Layer> grand_child3 = Layer::Create(layer_settings());
2045 scoped_refptr<Layer> grand_child4 = Layer::Create(); 2049 scoped_refptr<Layer> grand_child4 = Layer::Create(layer_settings());
2046 scoped_refptr<LayerWithForcedDrawsContent> leaf_node1 = 2050 scoped_refptr<LayerWithForcedDrawsContent> leaf_node1 =
2047 make_scoped_refptr(new LayerWithForcedDrawsContent()); 2051 make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
2048 scoped_refptr<LayerWithForcedDrawsContent> leaf_node2 = 2052 scoped_refptr<LayerWithForcedDrawsContent> leaf_node2 =
2049 make_scoped_refptr(new LayerWithForcedDrawsContent()); 2053 make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
2050 scoped_refptr<LayerWithForcedDrawsContent> leaf_node3 = 2054 scoped_refptr<LayerWithForcedDrawsContent> leaf_node3 =
2051 make_scoped_refptr(new LayerWithForcedDrawsContent()); 2055 make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
2052 scoped_refptr<LayerWithForcedDrawsContent> leaf_node4 = 2056 scoped_refptr<LayerWithForcedDrawsContent> leaf_node4 =
2053 make_scoped_refptr(new LayerWithForcedDrawsContent()); 2057 make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
2054 2058
2055 parent->AddChild(child); 2059 parent->AddChild(child);
2056 child->AddChild(grand_child1); 2060 child->AddChild(grand_child1);
2057 child->AddChild(grand_child2); 2061 child->AddChild(grand_child2);
2058 child->AddChild(grand_child3); 2062 child->AddChild(grand_child3);
2059 child->AddChild(grand_child4); 2063 child->AddChild(grand_child4);
2060 2064
2061 scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost()); 2065 scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost());
2062 host->SetRootLayer(parent); 2066 host->SetRootLayer(parent);
2063 2067
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
2168 // masksToBounds. 2172 // masksToBounds.
2169 EXPECT_EQ(gfx::Rect(0, 0, 20, 20), 2173 EXPECT_EQ(gfx::Rect(0, 0, 20, 20),
2170 grand_child1->render_surface()->clip_rect()); 2174 grand_child1->render_surface()->clip_rect());
2171 EXPECT_EQ(gfx::Rect(0, 0, 20, 20), 2175 EXPECT_EQ(gfx::Rect(0, 0, 20, 20),
2172 grand_child2->render_surface()->clip_rect()); 2176 grand_child2->render_surface()->clip_rect());
2173 EXPECT_EQ(gfx::Rect(0, 0, 20, 20), 2177 EXPECT_EQ(gfx::Rect(0, 0, 20, 20),
2174 grand_child3->render_surface()->clip_rect()); 2178 grand_child3->render_surface()->clip_rect());
2175 } 2179 }
2176 2180
2177 TEST_F(LayerTreeHostCommonTest, AnimationsForRenderSurfaceHierarchy) { 2181 TEST_F(LayerTreeHostCommonTest, AnimationsForRenderSurfaceHierarchy) {
2178 scoped_refptr<Layer> parent = Layer::Create(); 2182 scoped_refptr<Layer> parent = Layer::Create(layer_settings());
2179 scoped_refptr<Layer> render_surface1 = Layer::Create(); 2183 scoped_refptr<Layer> render_surface1 = Layer::Create(layer_settings());
2180 scoped_refptr<Layer> render_surface2 = Layer::Create(); 2184 scoped_refptr<Layer> render_surface2 = Layer::Create(layer_settings());
2181 scoped_refptr<Layer> child_of_root = Layer::Create(); 2185 scoped_refptr<Layer> child_of_root = Layer::Create(layer_settings());
2182 scoped_refptr<Layer> child_of_rs1 = Layer::Create(); 2186 scoped_refptr<Layer> child_of_rs1 = Layer::Create(layer_settings());
2183 scoped_refptr<Layer> child_of_rs2 = Layer::Create(); 2187 scoped_refptr<Layer> child_of_rs2 = Layer::Create(layer_settings());
2184 scoped_refptr<Layer> grand_child_of_root = Layer::Create(); 2188 scoped_refptr<Layer> grand_child_of_root = Layer::Create(layer_settings());
2185 scoped_refptr<LayerWithForcedDrawsContent> grand_child_of_rs1 = 2189 scoped_refptr<LayerWithForcedDrawsContent> grand_child_of_rs1 =
2186 make_scoped_refptr(new LayerWithForcedDrawsContent()); 2190 make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
2187 scoped_refptr<LayerWithForcedDrawsContent> grand_child_of_rs2 = 2191 scoped_refptr<LayerWithForcedDrawsContent> grand_child_of_rs2 =
2188 make_scoped_refptr(new LayerWithForcedDrawsContent()); 2192 make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
2189 parent->AddChild(render_surface1); 2193 parent->AddChild(render_surface1);
2190 parent->AddChild(child_of_root); 2194 parent->AddChild(child_of_root);
2191 render_surface1->AddChild(child_of_rs1); 2195 render_surface1->AddChild(child_of_rs1);
2192 render_surface1->AddChild(render_surface2); 2196 render_surface1->AddChild(render_surface2);
2193 render_surface2->AddChild(child_of_rs2); 2197 render_surface2->AddChild(child_of_rs2);
2194 child_of_root->AddChild(grand_child_of_root); 2198 child_of_root->AddChild(grand_child_of_root);
2195 child_of_rs1->AddChild(grand_child_of_rs1); 2199 child_of_rs1->AddChild(grand_child_of_rs1);
2196 child_of_rs2->AddChild(grand_child_of_rs2); 2200 child_of_rs2->AddChild(grand_child_of_rs2);
2197 2201
2198 scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost()); 2202 scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost());
(...skipping 466 matching lines...) Expand 10 before | Expand all | Expand 10 after
2665 // Only the corner of the layer is not visible on the surface because of being 2669 // Only the corner of the layer is not visible on the surface because of being
2666 // clipped. But, the net result of rounding visible region to an axis-aligned 2670 // clipped. But, the net result of rounding visible region to an axis-aligned
2667 // rect is that the entire layer should still be considered visible. 2671 // rect is that the entire layer should still be considered visible.
2668 gfx::Rect expected = gfx::Rect(-10, -10, 20, 20); 2672 gfx::Rect expected = gfx::Rect(-10, -10, 20, 20);
2669 gfx::Rect actual = LayerTreeHostCommon::CalculateVisibleRect( 2673 gfx::Rect actual = LayerTreeHostCommon::CalculateVisibleRect(
2670 target_surface_rect, layer_content_rect, layer_to_surface_transform); 2674 target_surface_rect, layer_content_rect, layer_to_surface_transform);
2671 EXPECT_EQ(expected, actual); 2675 EXPECT_EQ(expected, actual);
2672 } 2676 }
2673 2677
2674 TEST_F(LayerTreeHostCommonTest, DrawableAndVisibleContentRectsForSimpleLayers) { 2678 TEST_F(LayerTreeHostCommonTest, DrawableAndVisibleContentRectsForSimpleLayers) {
2675 scoped_refptr<Layer> root = Layer::Create(); 2679 scoped_refptr<Layer> root = Layer::Create(layer_settings());
2676 scoped_refptr<LayerWithForcedDrawsContent> child1 = 2680 scoped_refptr<LayerWithForcedDrawsContent> child1 =
2677 make_scoped_refptr(new LayerWithForcedDrawsContent()); 2681 make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
2678 scoped_refptr<LayerWithForcedDrawsContent> child2 = 2682 scoped_refptr<LayerWithForcedDrawsContent> child2 =
2679 make_scoped_refptr(new LayerWithForcedDrawsContent()); 2683 make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
2680 scoped_refptr<LayerWithForcedDrawsContent> child3 = 2684 scoped_refptr<LayerWithForcedDrawsContent> child3 =
2681 make_scoped_refptr(new LayerWithForcedDrawsContent()); 2685 make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
2682 root->AddChild(child1); 2686 root->AddChild(child1);
2683 root->AddChild(child2); 2687 root->AddChild(child2);
2684 root->AddChild(child3); 2688 root->AddChild(child3);
2685 2689
2686 scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost()); 2690 scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost());
2687 host->SetRootLayer(root); 2691 host->SetRootLayer(root);
2688 2692
2689 gfx::Transform identity_matrix; 2693 gfx::Transform identity_matrix;
2690 SetLayerPropertiesForTesting(root.get(), 2694 SetLayerPropertiesForTesting(root.get(),
2691 identity_matrix, 2695 identity_matrix,
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
2731 EXPECT_TRUE(child3->visible_content_rect().IsEmpty()); 2735 EXPECT_TRUE(child3->visible_content_rect().IsEmpty());
2732 2736
2733 // layer drawable_content_rects are not clipped. 2737 // layer drawable_content_rects are not clipped.
2734 EXPECT_EQ(gfx::Rect(0, 0, 50, 50), child1->drawable_content_rect()); 2738 EXPECT_EQ(gfx::Rect(0, 0, 50, 50), child1->drawable_content_rect());
2735 EXPECT_EQ(gfx::Rect(75, 75, 50, 50), child2->drawable_content_rect()); 2739 EXPECT_EQ(gfx::Rect(75, 75, 50, 50), child2->drawable_content_rect());
2736 EXPECT_EQ(gfx::Rect(125, 125, 50, 50), child3->drawable_content_rect()); 2740 EXPECT_EQ(gfx::Rect(125, 125, 50, 50), child3->drawable_content_rect());
2737 } 2741 }
2738 2742
2739 TEST_F(LayerTreeHostCommonTest, 2743 TEST_F(LayerTreeHostCommonTest,
2740 DrawableAndVisibleContentRectsForLayersClippedByLayer) { 2744 DrawableAndVisibleContentRectsForLayersClippedByLayer) {
2741 scoped_refptr<Layer> root = Layer::Create(); 2745 scoped_refptr<Layer> root = Layer::Create(layer_settings());
2742 scoped_refptr<Layer> child = Layer::Create(); 2746 scoped_refptr<Layer> child = Layer::Create(layer_settings());
2743 scoped_refptr<LayerWithForcedDrawsContent> grand_child1 = 2747 scoped_refptr<LayerWithForcedDrawsContent> grand_child1 =
2744 make_scoped_refptr(new LayerWithForcedDrawsContent()); 2748 make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
2745 scoped_refptr<LayerWithForcedDrawsContent> grand_child2 = 2749 scoped_refptr<LayerWithForcedDrawsContent> grand_child2 =
2746 make_scoped_refptr(new LayerWithForcedDrawsContent()); 2750 make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
2747 scoped_refptr<LayerWithForcedDrawsContent> grand_child3 = 2751 scoped_refptr<LayerWithForcedDrawsContent> grand_child3 =
2748 make_scoped_refptr(new LayerWithForcedDrawsContent()); 2752 make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
2749 root->AddChild(child); 2753 root->AddChild(child);
2750 child->AddChild(grand_child1); 2754 child->AddChild(grand_child1);
2751 child->AddChild(grand_child2); 2755 child->AddChild(grand_child2);
2752 child->AddChild(grand_child3); 2756 child->AddChild(grand_child3);
2753 2757
2754 scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost()); 2758 scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost());
2755 host->SetRootLayer(root); 2759 host->SetRootLayer(root);
2756 2760
2757 gfx::Transform identity_matrix; 2761 gfx::Transform identity_matrix;
2758 SetLayerPropertiesForTesting(root.get(), 2762 SetLayerPropertiesForTesting(root.get(),
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
2809 EXPECT_EQ(gfx::Rect(0, 0, 25, 25), grand_child2->visible_content_rect()); 2813 EXPECT_EQ(gfx::Rect(0, 0, 25, 25), grand_child2->visible_content_rect());
2810 EXPECT_TRUE(grand_child3->visible_content_rect().IsEmpty()); 2814 EXPECT_TRUE(grand_child3->visible_content_rect().IsEmpty());
2811 2815
2812 // All grandchild DrawableContentRects should also be clipped by child. 2816 // All grandchild DrawableContentRects should also be clipped by child.
2813 EXPECT_EQ(gfx::Rect(5, 5, 50, 50), grand_child1->drawable_content_rect()); 2817 EXPECT_EQ(gfx::Rect(5, 5, 50, 50), grand_child1->drawable_content_rect());
2814 EXPECT_EQ(gfx::Rect(75, 75, 25, 25), grand_child2->drawable_content_rect()); 2818 EXPECT_EQ(gfx::Rect(75, 75, 25, 25), grand_child2->drawable_content_rect());
2815 EXPECT_TRUE(grand_child3->drawable_content_rect().IsEmpty()); 2819 EXPECT_TRUE(grand_child3->drawable_content_rect().IsEmpty());
2816 } 2820 }
2817 2821
2818 TEST_F(LayerTreeHostCommonTest, VisibleContentRectWithClippingAndScaling) { 2822 TEST_F(LayerTreeHostCommonTest, VisibleContentRectWithClippingAndScaling) {
2819 scoped_refptr<Layer> root = Layer::Create(); 2823 scoped_refptr<Layer> root = Layer::Create(layer_settings());
2820 scoped_refptr<Layer> child = Layer::Create(); 2824 scoped_refptr<Layer> child = Layer::Create(layer_settings());
2821 scoped_refptr<LayerWithForcedDrawsContent> grand_child = 2825 scoped_refptr<LayerWithForcedDrawsContent> grand_child =
2822 make_scoped_refptr(new LayerWithForcedDrawsContent()); 2826 make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
2823 root->AddChild(child); 2827 root->AddChild(child);
2824 child->AddChild(grand_child); 2828 child->AddChild(grand_child);
2825 2829
2826 scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost()); 2830 scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost());
2827 host->SetRootLayer(root); 2831 host->SetRootLayer(root);
2828 2832
2829 gfx::Transform identity_matrix; 2833 gfx::Transform identity_matrix;
2830 gfx::Transform child_scale_matrix; 2834 gfx::Transform child_scale_matrix;
2831 child_scale_matrix.Scale(0.25f, 0.25f); 2835 child_scale_matrix.Scale(0.25f, 0.25f);
2832 gfx::Transform grand_child_scale_matrix; 2836 gfx::Transform grand_child_scale_matrix;
(...skipping 10 matching lines...) Expand all
2843 ExecuteCalculateDrawProperties(root.get()); 2847 ExecuteCalculateDrawProperties(root.get());
2844 2848
2845 // The visible rect is expanded to integer coordinates in target space before 2849 // The visible rect is expanded to integer coordinates in target space before
2846 // being projected back to layer space, where it is once again expanded to 2850 // being projected back to layer space, where it is once again expanded to
2847 // integer coordinates. 2851 // integer coordinates.
2848 EXPECT_EQ(gfx::Rect(49, 49), grand_child->visible_rect_from_property_trees()); 2852 EXPECT_EQ(gfx::Rect(49, 49), grand_child->visible_rect_from_property_trees());
2849 } 2853 }
2850 2854
2851 TEST_F(LayerTreeHostCommonTest, 2855 TEST_F(LayerTreeHostCommonTest,
2852 DrawableAndVisibleContentRectsForLayersInUnclippedRenderSurface) { 2856 DrawableAndVisibleContentRectsForLayersInUnclippedRenderSurface) {
2853 scoped_refptr<Layer> root = Layer::Create(); 2857 scoped_refptr<Layer> root = Layer::Create(layer_settings());
2854 scoped_refptr<Layer> render_surface1 = Layer::Create(); 2858 scoped_refptr<Layer> render_surface1 = Layer::Create(layer_settings());
2855 scoped_refptr<LayerWithForcedDrawsContent> child1 = 2859 scoped_refptr<LayerWithForcedDrawsContent> child1 =
2856 make_scoped_refptr(new LayerWithForcedDrawsContent()); 2860 make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
2857 scoped_refptr<LayerWithForcedDrawsContent> child2 = 2861 scoped_refptr<LayerWithForcedDrawsContent> child2 =
2858 make_scoped_refptr(new LayerWithForcedDrawsContent()); 2862 make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
2859 scoped_refptr<LayerWithForcedDrawsContent> child3 = 2863 scoped_refptr<LayerWithForcedDrawsContent> child3 =
2860 make_scoped_refptr(new LayerWithForcedDrawsContent()); 2864 make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
2861 root->AddChild(render_surface1); 2865 root->AddChild(render_surface1);
2862 render_surface1->AddChild(child1); 2866 render_surface1->AddChild(child1);
2863 render_surface1->AddChild(child2); 2867 render_surface1->AddChild(child2);
2864 render_surface1->AddChild(child3); 2868 render_surface1->AddChild(child3);
2865 2869
2866 scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost()); 2870 scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost());
2867 host->SetRootLayer(root); 2871 host->SetRootLayer(root);
2868 2872
2869 gfx::Transform identity_matrix; 2873 gfx::Transform identity_matrix;
2870 SetLayerPropertiesForTesting(root.get(), 2874 SetLayerPropertiesForTesting(root.get(),
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
2926 EXPECT_EQ(gfx::Rect(0, 0, 50, 50), child2->visible_content_rect()); 2930 EXPECT_EQ(gfx::Rect(0, 0, 50, 50), child2->visible_content_rect());
2927 EXPECT_EQ(gfx::Rect(0, 0, 50, 50), child3->visible_content_rect()); 2931 EXPECT_EQ(gfx::Rect(0, 0, 50, 50), child3->visible_content_rect());
2928 2932
2929 EXPECT_EQ(gfx::Rect(5, 5, 50, 50), child1->drawable_content_rect()); 2933 EXPECT_EQ(gfx::Rect(5, 5, 50, 50), child1->drawable_content_rect());
2930 EXPECT_EQ(gfx::Rect(75, 75, 50, 50), child2->drawable_content_rect()); 2934 EXPECT_EQ(gfx::Rect(75, 75, 50, 50), child2->drawable_content_rect());
2931 EXPECT_EQ(gfx::Rect(125, 125, 50, 50), child3->drawable_content_rect()); 2935 EXPECT_EQ(gfx::Rect(125, 125, 50, 50), child3->drawable_content_rect());
2932 } 2936 }
2933 2937
2934 TEST_F(LayerTreeHostCommonTest, 2938 TEST_F(LayerTreeHostCommonTest,
2935 VisibleContentRectsForClippedSurfaceWithEmptyClip) { 2939 VisibleContentRectsForClippedSurfaceWithEmptyClip) {
2936 scoped_refptr<Layer> root = Layer::Create(); 2940 scoped_refptr<Layer> root = Layer::Create(layer_settings());
2937 scoped_refptr<LayerWithForcedDrawsContent> child1 = 2941 scoped_refptr<LayerWithForcedDrawsContent> child1 =
2938 make_scoped_refptr(new LayerWithForcedDrawsContent()); 2942 make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
2939 scoped_refptr<LayerWithForcedDrawsContent> child2 = 2943 scoped_refptr<LayerWithForcedDrawsContent> child2 =
2940 make_scoped_refptr(new LayerWithForcedDrawsContent()); 2944 make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
2941 scoped_refptr<LayerWithForcedDrawsContent> child3 = 2945 scoped_refptr<LayerWithForcedDrawsContent> child3 =
2942 make_scoped_refptr(new LayerWithForcedDrawsContent()); 2946 make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
2943 root->AddChild(child1); 2947 root->AddChild(child1);
2944 root->AddChild(child2); 2948 root->AddChild(child2);
2945 root->AddChild(child3); 2949 root->AddChild(child3);
2946 2950
2947 scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost()); 2951 scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost());
2948 host->SetRootLayer(root); 2952 host->SetRootLayer(root);
2949 2953
2950 gfx::Transform identity_matrix; 2954 gfx::Transform identity_matrix;
2951 SetLayerPropertiesForTesting(root.get(), identity_matrix, gfx::Point3F(), 2955 SetLayerPropertiesForTesting(root.get(), identity_matrix, gfx::Point3F(),
2952 gfx::PointF(), gfx::Size(100, 100), true, false); 2956 gfx::PointF(), gfx::Size(100, 100), true, false);
(...skipping 23 matching lines...) Expand all
2976 // Visible content rect calculation will check if the target surface is 2980 // Visible content rect calculation will check if the target surface is
2977 // clipped or not. An empty clip rect does not indicate the render surface 2981 // clipped or not. An empty clip rect does not indicate the render surface
2978 // is unclipped. 2982 // is unclipped.
2979 EXPECT_EQ(empty, child1->visible_content_rect()); 2983 EXPECT_EQ(empty, child1->visible_content_rect());
2980 EXPECT_EQ(empty, child2->visible_content_rect()); 2984 EXPECT_EQ(empty, child2->visible_content_rect());
2981 EXPECT_EQ(empty, child3->visible_content_rect()); 2985 EXPECT_EQ(empty, child3->visible_content_rect());
2982 } 2986 }
2983 2987
2984 TEST_F(LayerTreeHostCommonTest, 2988 TEST_F(LayerTreeHostCommonTest,
2985 DrawableAndVisibleContentRectsForLayersWithUninvertibleTransform) { 2989 DrawableAndVisibleContentRectsForLayersWithUninvertibleTransform) {
2986 scoped_refptr<Layer> root = Layer::Create(); 2990 scoped_refptr<Layer> root = Layer::Create(layer_settings());
2987 scoped_refptr<LayerWithForcedDrawsContent> child = 2991 scoped_refptr<LayerWithForcedDrawsContent> child =
2988 make_scoped_refptr(new LayerWithForcedDrawsContent()); 2992 make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
2989 root->AddChild(child); 2993 root->AddChild(child);
2990 2994
2991 scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost()); 2995 scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost());
2992 host->SetRootLayer(root); 2996 host->SetRootLayer(root);
2993 2997
2994 // Case 1: a truly degenerate matrix 2998 // Case 1: a truly degenerate matrix
2995 gfx::Transform identity_matrix; 2999 gfx::Transform identity_matrix;
2996 gfx::Transform uninvertible_matrix(0.0, 0.0, 0.0, 0.0, 0.0, 0.0); 3000 gfx::Transform uninvertible_matrix(0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
2997 ASSERT_FALSE(uninvertible_matrix.IsInvertible()); 3001 ASSERT_FALSE(uninvertible_matrix.IsInvertible());
2998 3002
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
3050 false); 3054 false);
3051 3055
3052 ExecuteCalculateDrawProperties(root.get()); 3056 ExecuteCalculateDrawProperties(root.get());
3053 3057
3054 EXPECT_TRUE(child->visible_content_rect().IsEmpty()); 3058 EXPECT_TRUE(child->visible_content_rect().IsEmpty());
3055 EXPECT_TRUE(child->drawable_content_rect().IsEmpty()); 3059 EXPECT_TRUE(child->drawable_content_rect().IsEmpty());
3056 } 3060 }
3057 3061
3058 TEST_F(LayerTreeHostCommonTest, 3062 TEST_F(LayerTreeHostCommonTest,
3059 SingularTransformDoesNotPreventClearingDrawProperties) { 3063 SingularTransformDoesNotPreventClearingDrawProperties) {
3060 scoped_refptr<Layer> root = Layer::Create(); 3064 scoped_refptr<Layer> root = Layer::Create(layer_settings());
3061 scoped_refptr<LayerWithForcedDrawsContent> child = 3065 scoped_refptr<LayerWithForcedDrawsContent> child =
3062 make_scoped_refptr(new LayerWithForcedDrawsContent()); 3066 make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
3063 root->AddChild(child); 3067 root->AddChild(child);
3064 3068
3065 scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost()); 3069 scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost());
3066 host->SetRootLayer(root); 3070 host->SetRootLayer(root);
3067 3071
3068 gfx::Transform identity_matrix; 3072 gfx::Transform identity_matrix;
3069 gfx::Transform uninvertible_matrix(0.0, 0.0, 0.0, 0.0, 0.0, 0.0); 3073 gfx::Transform uninvertible_matrix(0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
3070 ASSERT_FALSE(uninvertible_matrix.IsInvertible()); 3074 ASSERT_FALSE(uninvertible_matrix.IsInvertible());
3071 3075
3072 SetLayerPropertiesForTesting(root.get(), 3076 SetLayerPropertiesForTesting(root.get(),
(...skipping 24 matching lines...) Expand all
3097 3101
3098 EXPECT_TRUE(root->TransformIsAnimating()); 3102 EXPECT_TRUE(root->TransformIsAnimating());
3099 3103
3100 ExecuteCalculateDrawProperties(root.get()); 3104 ExecuteCalculateDrawProperties(root.get());
3101 3105
3102 EXPECT_FALSE(child->draw_properties().sorted_for_recursion); 3106 EXPECT_FALSE(child->draw_properties().sorted_for_recursion);
3103 } 3107 }
3104 3108
3105 TEST_F(LayerTreeHostCommonTest, 3109 TEST_F(LayerTreeHostCommonTest,
3106 SingularNonAnimatingTransformDoesNotPreventClearingDrawProperties) { 3110 SingularNonAnimatingTransformDoesNotPreventClearingDrawProperties) {
3107 scoped_refptr<Layer> root = Layer::Create(); 3111 scoped_refptr<Layer> root = Layer::Create(layer_settings());
3108 3112
3109 scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost()); 3113 scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost());
3110 host->SetRootLayer(root); 3114 host->SetRootLayer(root);
3111 3115
3112 gfx::Transform identity_matrix; 3116 gfx::Transform identity_matrix;
3113 gfx::Transform uninvertible_matrix(0.0, 0.0, 0.0, 0.0, 0.0, 0.0); 3117 gfx::Transform uninvertible_matrix(0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
3114 ASSERT_FALSE(uninvertible_matrix.IsInvertible()); 3118 ASSERT_FALSE(uninvertible_matrix.IsInvertible());
3115 3119
3116 SetLayerPropertiesForTesting(root.get(), 3120 SetLayerPropertiesForTesting(root.get(),
3117 uninvertible_matrix, 3121 uninvertible_matrix,
3118 gfx::Point3F(), 3122 gfx::Point3F(),
3119 gfx::PointF(), 3123 gfx::PointF(),
3120 gfx::Size(100, 100), 3124 gfx::Size(100, 100),
3121 true, 3125 true,
3122 false); 3126 false);
3123 3127
3124 root->draw_properties().sorted_for_recursion = true; 3128 root->draw_properties().sorted_for_recursion = true;
3125 3129
3126 EXPECT_FALSE(root->TransformIsAnimating()); 3130 EXPECT_FALSE(root->TransformIsAnimating());
3127 3131
3128 ExecuteCalculateDrawProperties(root.get()); 3132 ExecuteCalculateDrawProperties(root.get());
3129 3133
3130 EXPECT_FALSE(root->draw_properties().sorted_for_recursion); 3134 EXPECT_FALSE(root->draw_properties().sorted_for_recursion);
3131 } 3135 }
3132 3136
3133 TEST_F(LayerTreeHostCommonTest, 3137 TEST_F(LayerTreeHostCommonTest,
3134 DrawableAndVisibleContentRectsForLayersInClippedRenderSurface) { 3138 DrawableAndVisibleContentRectsForLayersInClippedRenderSurface) {
3135 scoped_refptr<Layer> root = Layer::Create(); 3139 scoped_refptr<Layer> root = Layer::Create(layer_settings());
3136 scoped_refptr<Layer> render_surface1 = Layer::Create(); 3140 scoped_refptr<Layer> render_surface1 = Layer::Create(layer_settings());
3137 scoped_refptr<LayerWithForcedDrawsContent> child1 = 3141 scoped_refptr<LayerWithForcedDrawsContent> child1 =
3138 make_scoped_refptr(new LayerWithForcedDrawsContent()); 3142 make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
3139 scoped_refptr<LayerWithForcedDrawsContent> child2 = 3143 scoped_refptr<LayerWithForcedDrawsContent> child2 =
3140 make_scoped_refptr(new LayerWithForcedDrawsContent()); 3144 make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
3141 scoped_refptr<LayerWithForcedDrawsContent> child3 = 3145 scoped_refptr<LayerWithForcedDrawsContent> child3 =
3142 make_scoped_refptr(new LayerWithForcedDrawsContent()); 3146 make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
3143 root->AddChild(render_surface1); 3147 root->AddChild(render_surface1);
3144 render_surface1->AddChild(child1); 3148 render_surface1->AddChild(child1);
3145 render_surface1->AddChild(child2); 3149 render_surface1->AddChild(child2);
3146 render_surface1->AddChild(child3); 3150 render_surface1->AddChild(child3);
3147 3151
3148 scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost()); 3152 scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost());
3149 host->SetRootLayer(root); 3153 host->SetRootLayer(root);
3150 3154
3151 gfx::Transform identity_matrix; 3155 gfx::Transform identity_matrix;
3152 SetLayerPropertiesForTesting(root.get(), 3156 SetLayerPropertiesForTesting(root.get(),
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
3212 3216
3213 // But the DrawableContentRects are unclipped. 3217 // But the DrawableContentRects are unclipped.
3214 EXPECT_EQ(gfx::Rect(5, 5, 50, 50), child1->drawable_content_rect()); 3218 EXPECT_EQ(gfx::Rect(5, 5, 50, 50), child1->drawable_content_rect());
3215 EXPECT_EQ(gfx::Rect(75, 75, 50, 50), child2->drawable_content_rect()); 3219 EXPECT_EQ(gfx::Rect(75, 75, 50, 50), child2->drawable_content_rect());
3216 EXPECT_EQ(gfx::Rect(125, 125, 50, 50), child3->drawable_content_rect()); 3220 EXPECT_EQ(gfx::Rect(125, 125, 50, 50), child3->drawable_content_rect());
3217 } 3221 }
3218 3222
3219 TEST_F(LayerTreeHostCommonTest, 3223 TEST_F(LayerTreeHostCommonTest,
3220 DrawableAndVisibleContentRectsForSurfaceHierarchy) { 3224 DrawableAndVisibleContentRectsForSurfaceHierarchy) {
3221 // Check that clipping does not propagate down surfaces. 3225 // Check that clipping does not propagate down surfaces.
3222 scoped_refptr<Layer> root = Layer::Create(); 3226 scoped_refptr<Layer> root = Layer::Create(layer_settings());
3223 scoped_refptr<Layer> render_surface1 = Layer::Create(); 3227 scoped_refptr<Layer> render_surface1 = Layer::Create(layer_settings());
3224 scoped_refptr<Layer> render_surface2 = Layer::Create(); 3228 scoped_refptr<Layer> render_surface2 = Layer::Create(layer_settings());
3225 scoped_refptr<LayerWithForcedDrawsContent> child1 = 3229 scoped_refptr<LayerWithForcedDrawsContent> child1 =
3226 make_scoped_refptr(new LayerWithForcedDrawsContent()); 3230 make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
3227 scoped_refptr<LayerWithForcedDrawsContent> child2 = 3231 scoped_refptr<LayerWithForcedDrawsContent> child2 =
3228 make_scoped_refptr(new LayerWithForcedDrawsContent()); 3232 make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
3229 scoped_refptr<LayerWithForcedDrawsContent> child3 = 3233 scoped_refptr<LayerWithForcedDrawsContent> child3 =
3230 make_scoped_refptr(new LayerWithForcedDrawsContent()); 3234 make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
3231 root->AddChild(render_surface1); 3235 root->AddChild(render_surface1);
3232 render_surface1->AddChild(render_surface2); 3236 render_surface1->AddChild(render_surface2);
3233 render_surface2->AddChild(child1); 3237 render_surface2->AddChild(child1);
3234 render_surface2->AddChild(child2); 3238 render_surface2->AddChild(child2);
3235 render_surface2->AddChild(child3); 3239 render_surface2->AddChild(child3);
3236 3240
3237 scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost()); 3241 scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost());
3238 host->SetRootLayer(root); 3242 host->SetRootLayer(root);
3239 3243
3240 gfx::Transform identity_matrix; 3244 gfx::Transform identity_matrix;
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
3318 EXPECT_EQ(gfx::Rect(5, 5, 50, 50), child1->drawable_content_rect()); 3322 EXPECT_EQ(gfx::Rect(5, 5, 50, 50), child1->drawable_content_rect());
3319 EXPECT_EQ(gfx::Rect(75, 75, 50, 50), child2->drawable_content_rect()); 3323 EXPECT_EQ(gfx::Rect(75, 75, 50, 50), child2->drawable_content_rect());
3320 EXPECT_EQ(gfx::Rect(125, 125, 50, 50), child3->drawable_content_rect()); 3324 EXPECT_EQ(gfx::Rect(125, 125, 50, 50), child3->drawable_content_rect());
3321 } 3325 }
3322 3326
3323 TEST_F(LayerTreeHostCommonTest, 3327 TEST_F(LayerTreeHostCommonTest,
3324 DrawableAndVisibleContentRectsWithTransformOnUnclippedSurface) { 3328 DrawableAndVisibleContentRectsWithTransformOnUnclippedSurface) {
3325 // Layers that have non-axis aligned bounds (due to transforms) have an 3329 // Layers that have non-axis aligned bounds (due to transforms) have an
3326 // expanded, axis-aligned DrawableContentRect and visible content rect. 3330 // expanded, axis-aligned DrawableContentRect and visible content rect.
3327 3331
3328 scoped_refptr<Layer> root = Layer::Create(); 3332 scoped_refptr<Layer> root = Layer::Create(layer_settings());
3329 scoped_refptr<Layer> render_surface1 = Layer::Create(); 3333 scoped_refptr<Layer> render_surface1 = Layer::Create(layer_settings());
3330 scoped_refptr<LayerWithForcedDrawsContent> child1 = 3334 scoped_refptr<LayerWithForcedDrawsContent> child1 =
3331 make_scoped_refptr(new LayerWithForcedDrawsContent()); 3335 make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
3332 root->AddChild(render_surface1); 3336 root->AddChild(render_surface1);
3333 render_surface1->AddChild(child1); 3337 render_surface1->AddChild(child1);
3334 3338
3335 scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost()); 3339 scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost());
3336 host->SetRootLayer(root); 3340 host->SetRootLayer(root);
3337 3341
3338 gfx::Transform identity_matrix; 3342 gfx::Transform identity_matrix;
3339 gfx::Transform child_rotation; 3343 gfx::Transform child_rotation;
3340 child_rotation.Rotate(45.0); 3344 child_rotation.Rotate(45.0);
3341 SetLayerPropertiesForTesting(root.get(), 3345 SetLayerPropertiesForTesting(root.get(),
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
3387 // All layers that draw content into the unclipped surface are also unclipped. 3391 // All layers that draw content into the unclipped surface are also unclipped.
3388 EXPECT_EQ(gfx::Rect(0, 0, 50, 50), child1->visible_content_rect()); 3392 EXPECT_EQ(gfx::Rect(0, 0, 50, 50), child1->visible_content_rect());
3389 EXPECT_EQ(expected_surface_drawable_content, child1->drawable_content_rect()); 3393 EXPECT_EQ(expected_surface_drawable_content, child1->drawable_content_rect());
3390 } 3394 }
3391 3395
3392 TEST_F(LayerTreeHostCommonTest, 3396 TEST_F(LayerTreeHostCommonTest,
3393 DrawableAndVisibleContentRectsWithTransformOnClippedSurface) { 3397 DrawableAndVisibleContentRectsWithTransformOnClippedSurface) {
3394 // Layers that have non-axis aligned bounds (due to transforms) have an 3398 // Layers that have non-axis aligned bounds (due to transforms) have an
3395 // expanded, axis-aligned DrawableContentRect and visible content rect. 3399 // expanded, axis-aligned DrawableContentRect and visible content rect.
3396 3400
3397 scoped_refptr<Layer> root = Layer::Create(); 3401 scoped_refptr<Layer> root = Layer::Create(layer_settings());
3398 scoped_refptr<Layer> render_surface1 = Layer::Create(); 3402 scoped_refptr<Layer> render_surface1 = Layer::Create(layer_settings());
3399 scoped_refptr<LayerWithForcedDrawsContent> child1 = 3403 scoped_refptr<LayerWithForcedDrawsContent> child1 =
3400 make_scoped_refptr(new LayerWithForcedDrawsContent()); 3404 make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
3401 root->AddChild(render_surface1); 3405 root->AddChild(render_surface1);
3402 render_surface1->AddChild(child1); 3406 render_surface1->AddChild(child1);
3403 3407
3404 scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost()); 3408 scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost());
3405 host->SetRootLayer(root); 3409 host->SetRootLayer(root);
3406 3410
3407 gfx::Transform identity_matrix; 3411 gfx::Transform identity_matrix;
3408 gfx::Transform child_rotation; 3412 gfx::Transform child_rotation;
3409 child_rotation.Rotate(45.0); 3413 child_rotation.Rotate(45.0);
3410 SetLayerPropertiesForTesting(root.get(), 3414 SetLayerPropertiesForTesting(root.get(),
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
3455 // Given the floating point math, this number is a little bit fuzzy. 3459 // Given the floating point math, this number is a little bit fuzzy.
3456 EXPECT_EQ(gfx::Rect(0, 0, 26, 50), child1->visible_content_rect()); 3460 EXPECT_EQ(gfx::Rect(0, 0, 26, 50), child1->visible_content_rect());
3457 3461
3458 // The child's DrawableContentRect is unclipped. 3462 // The child's DrawableContentRect is unclipped.
3459 EXPECT_EQ(unclipped_surface_content, child1->drawable_content_rect()); 3463 EXPECT_EQ(unclipped_surface_content, child1->drawable_content_rect());
3460 } 3464 }
3461 3465
3462 TEST_F(LayerTreeHostCommonTest, DrawableAndVisibleContentRectsInHighDPI) { 3466 TEST_F(LayerTreeHostCommonTest, DrawableAndVisibleContentRectsInHighDPI) {
3463 MockContentLayerClient client; 3467 MockContentLayerClient client;
3464 3468
3465 scoped_refptr<Layer> root = Layer::Create(); 3469 scoped_refptr<Layer> root = Layer::Create(layer_settings());
3466 scoped_refptr<FakePictureLayer> render_surface1 = 3470 scoped_refptr<FakePictureLayer> render_surface1 =
3467 CreateDrawablePictureLayer(&client); 3471 CreateDrawablePictureLayer(layer_settings(), &client);
3468 scoped_refptr<FakePictureLayer> render_surface2 = 3472 scoped_refptr<FakePictureLayer> render_surface2 =
3469 CreateDrawablePictureLayer(&client); 3473 CreateDrawablePictureLayer(layer_settings(), &client);
3470 scoped_refptr<FakePictureLayer> child1 = CreateDrawablePictureLayer(&client); 3474 scoped_refptr<FakePictureLayer> child1 =
3471 scoped_refptr<FakePictureLayer> child2 = CreateDrawablePictureLayer(&client); 3475 CreateDrawablePictureLayer(layer_settings(), &client);
3472 scoped_refptr<FakePictureLayer> child3 = CreateDrawablePictureLayer(&client); 3476 scoped_refptr<FakePictureLayer> child2 =
3477 CreateDrawablePictureLayer(layer_settings(), &client);
3478 scoped_refptr<FakePictureLayer> child3 =
3479 CreateDrawablePictureLayer(layer_settings(), &client);
3473 root->AddChild(render_surface1); 3480 root->AddChild(render_surface1);
3474 render_surface1->AddChild(render_surface2); 3481 render_surface1->AddChild(render_surface2);
3475 render_surface2->AddChild(child1); 3482 render_surface2->AddChild(child1);
3476 render_surface2->AddChild(child2); 3483 render_surface2->AddChild(child2);
3477 render_surface2->AddChild(child3); 3484 render_surface2->AddChild(child3);
3478 3485
3479 scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost()); 3486 scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost());
3480 host->SetRootLayer(root); 3487 host->SetRootLayer(root);
3481 3488
3482 gfx::Transform identity_matrix; 3489 gfx::Transform identity_matrix;
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
3561 EXPECT_EQ(gfx::Rect(0, 0, 50, 50), child2->visible_content_rect()); 3568 EXPECT_EQ(gfx::Rect(0, 0, 50, 50), child2->visible_content_rect());
3562 EXPECT_EQ(gfx::Rect(0, 0, 50, 50), child3->visible_content_rect()); 3569 EXPECT_EQ(gfx::Rect(0, 0, 50, 50), child3->visible_content_rect());
3563 } 3570 }
3564 3571
3565 TEST_F(LayerTreeHostCommonTest, BackFaceCullingWithoutPreserves3d) { 3572 TEST_F(LayerTreeHostCommonTest, BackFaceCullingWithoutPreserves3d) {
3566 // Verify the behavior of back-face culling when there are no preserve-3d 3573 // Verify the behavior of back-face culling when there are no preserve-3d
3567 // layers. Note that 3d transforms still apply in this case, but they are 3574 // layers. Note that 3d transforms still apply in this case, but they are
3568 // "flattened" to each parent layer according to current W3C spec. 3575 // "flattened" to each parent layer according to current W3C spec.
3569 3576
3570 const gfx::Transform identity_matrix; 3577 const gfx::Transform identity_matrix;
3571 scoped_refptr<Layer> parent = Layer::Create(); 3578 scoped_refptr<Layer> parent = Layer::Create(layer_settings());
3572 scoped_refptr<LayerWithForcedDrawsContent> front_facing_child = 3579 scoped_refptr<LayerWithForcedDrawsContent> front_facing_child =
3573 make_scoped_refptr(new LayerWithForcedDrawsContent()); 3580 make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
3574 scoped_refptr<LayerWithForcedDrawsContent> back_facing_child = 3581 scoped_refptr<LayerWithForcedDrawsContent> back_facing_child =
3575 make_scoped_refptr(new LayerWithForcedDrawsContent()); 3582 make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
3576 scoped_refptr<LayerWithForcedDrawsContent> front_facing_surface = 3583 scoped_refptr<LayerWithForcedDrawsContent> front_facing_surface =
3577 make_scoped_refptr(new LayerWithForcedDrawsContent()); 3584 make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
3578 scoped_refptr<LayerWithForcedDrawsContent> back_facing_surface = 3585 scoped_refptr<LayerWithForcedDrawsContent> back_facing_surface =
3579 make_scoped_refptr(new LayerWithForcedDrawsContent()); 3586 make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
3580 scoped_refptr<LayerWithForcedDrawsContent> 3587 scoped_refptr<LayerWithForcedDrawsContent>
3581 front_facing_child_of_front_facing_surface = 3588 front_facing_child_of_front_facing_surface =
3582 make_scoped_refptr(new LayerWithForcedDrawsContent()); 3589 make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
3583 scoped_refptr<LayerWithForcedDrawsContent> 3590 scoped_refptr<LayerWithForcedDrawsContent>
3584 back_facing_child_of_front_facing_surface = 3591 back_facing_child_of_front_facing_surface =
3585 make_scoped_refptr(new LayerWithForcedDrawsContent()); 3592 make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
3586 scoped_refptr<LayerWithForcedDrawsContent> 3593 scoped_refptr<LayerWithForcedDrawsContent>
3587 front_facing_child_of_back_facing_surface = 3594 front_facing_child_of_back_facing_surface =
3588 make_scoped_refptr(new LayerWithForcedDrawsContent()); 3595 make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
3589 scoped_refptr<LayerWithForcedDrawsContent> 3596 scoped_refptr<LayerWithForcedDrawsContent>
3590 back_facing_child_of_back_facing_surface = 3597 back_facing_child_of_back_facing_surface =
3591 make_scoped_refptr(new LayerWithForcedDrawsContent()); 3598 make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
3592 3599
3593 parent->AddChild(front_facing_child); 3600 parent->AddChild(front_facing_child);
3594 parent->AddChild(back_facing_child); 3601 parent->AddChild(back_facing_child);
3595 parent->AddChild(front_facing_surface); 3602 parent->AddChild(front_facing_surface);
3596 parent->AddChild(back_facing_surface); 3603 parent->AddChild(back_facing_surface);
3597 front_facing_surface->AddChild(front_facing_child_of_front_facing_surface); 3604 front_facing_surface->AddChild(front_facing_child_of_front_facing_surface);
3598 front_facing_surface->AddChild(back_facing_child_of_front_facing_surface); 3605 front_facing_surface->AddChild(back_facing_child_of_front_facing_surface);
3599 back_facing_surface->AddChild(front_facing_child_of_back_facing_surface); 3606 back_facing_surface->AddChild(front_facing_child_of_back_facing_surface);
3600 back_facing_surface->AddChild(back_facing_child_of_back_facing_surface); 3607 back_facing_surface->AddChild(back_facing_child_of_back_facing_surface);
3601 3608
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
3763 ->layer_list() 3770 ->layer_list()
3764 .at(0) 3771 .at(0)
3765 ->id()); 3772 ->id());
3766 } 3773 }
3767 3774
3768 TEST_F(LayerTreeHostCommonTest, BackFaceCullingWithPreserves3d) { 3775 TEST_F(LayerTreeHostCommonTest, BackFaceCullingWithPreserves3d) {
3769 // Verify the behavior of back-face culling when preserves-3d transform style 3776 // Verify the behavior of back-face culling when preserves-3d transform style
3770 // is used. 3777 // is used.
3771 3778
3772 const gfx::Transform identity_matrix; 3779 const gfx::Transform identity_matrix;
3773 scoped_refptr<Layer> parent = Layer::Create(); 3780 scoped_refptr<Layer> parent = Layer::Create(layer_settings());
3774 scoped_refptr<LayerWithForcedDrawsContent> front_facing_child = 3781 scoped_refptr<LayerWithForcedDrawsContent> front_facing_child =
3775 make_scoped_refptr(new LayerWithForcedDrawsContent()); 3782 make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
3776 scoped_refptr<LayerWithForcedDrawsContent> back_facing_child = 3783 scoped_refptr<LayerWithForcedDrawsContent> back_facing_child =
3777 make_scoped_refptr(new LayerWithForcedDrawsContent()); 3784 make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
3778 scoped_refptr<LayerWithForcedDrawsContent> front_facing_surface = 3785 scoped_refptr<LayerWithForcedDrawsContent> front_facing_surface =
3779 make_scoped_refptr(new LayerWithForcedDrawsContent()); 3786 make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
3780 scoped_refptr<LayerWithForcedDrawsContent> back_facing_surface = 3787 scoped_refptr<LayerWithForcedDrawsContent> back_facing_surface =
3781 make_scoped_refptr(new LayerWithForcedDrawsContent()); 3788 make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
3782 scoped_refptr<LayerWithForcedDrawsContent> 3789 scoped_refptr<LayerWithForcedDrawsContent>
3783 front_facing_child_of_front_facing_surface = 3790 front_facing_child_of_front_facing_surface =
3784 make_scoped_refptr(new LayerWithForcedDrawsContent()); 3791 make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
3785 scoped_refptr<LayerWithForcedDrawsContent> 3792 scoped_refptr<LayerWithForcedDrawsContent>
3786 back_facing_child_of_front_facing_surface = 3793 back_facing_child_of_front_facing_surface =
3787 make_scoped_refptr(new LayerWithForcedDrawsContent()); 3794 make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
3788 scoped_refptr<LayerWithForcedDrawsContent> 3795 scoped_refptr<LayerWithForcedDrawsContent>
3789 front_facing_child_of_back_facing_surface = 3796 front_facing_child_of_back_facing_surface =
3790 make_scoped_refptr(new LayerWithForcedDrawsContent()); 3797 make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
3791 scoped_refptr<LayerWithForcedDrawsContent> 3798 scoped_refptr<LayerWithForcedDrawsContent>
3792 back_facing_child_of_back_facing_surface = 3799 back_facing_child_of_back_facing_surface =
3793 make_scoped_refptr(new LayerWithForcedDrawsContent()); 3800 make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
3794 scoped_refptr<LayerWithForcedDrawsContent> dummy_replica_layer1 = 3801 scoped_refptr<LayerWithForcedDrawsContent> dummy_replica_layer1 =
3795 make_scoped_refptr(new LayerWithForcedDrawsContent()); 3802 make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
3796 scoped_refptr<LayerWithForcedDrawsContent> dummy_replica_layer2 = 3803 scoped_refptr<LayerWithForcedDrawsContent> dummy_replica_layer2 =
3797 make_scoped_refptr(new LayerWithForcedDrawsContent()); 3804 make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
3798 3805
3799 parent->AddChild(front_facing_child); 3806 parent->AddChild(front_facing_child);
3800 parent->AddChild(back_facing_child); 3807 parent->AddChild(back_facing_child);
3801 parent->AddChild(front_facing_surface); 3808 parent->AddChild(front_facing_surface);
3802 parent->AddChild(back_facing_surface); 3809 parent->AddChild(back_facing_surface);
3803 front_facing_surface->AddChild(front_facing_child_of_front_facing_surface); 3810 front_facing_surface->AddChild(front_facing_child_of_front_facing_surface);
3804 front_facing_surface->AddChild(back_facing_child_of_front_facing_surface); 3811 front_facing_surface->AddChild(back_facing_child_of_front_facing_surface);
3805 back_facing_surface->AddChild(front_facing_child_of_back_facing_surface); 3812 back_facing_surface->AddChild(front_facing_child_of_back_facing_surface);
3806 back_facing_surface->AddChild(back_facing_child_of_back_facing_surface); 3813 back_facing_surface->AddChild(back_facing_child_of_back_facing_surface);
3807 3814
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
3948 } 3955 }
3949 3956
3950 TEST_F(LayerTreeHostCommonTest, BackFaceCullingWithAnimatingTransforms) { 3957 TEST_F(LayerTreeHostCommonTest, BackFaceCullingWithAnimatingTransforms) {
3951 // Verify that layers are appropriately culled when their back face is showing 3958 // Verify that layers are appropriately culled when their back face is showing
3952 // and they are not double sided, while animations are going on. 3959 // and they are not double sided, while animations are going on.
3953 // 3960 //
3954 // Layers that are animating do not get culled on the main thread, as their 3961 // Layers that are animating do not get culled on the main thread, as their
3955 // transforms should be treated as "unknown" so we can not be sure that their 3962 // transforms should be treated as "unknown" so we can not be sure that their
3956 // back face is really showing. 3963 // back face is really showing.
3957 const gfx::Transform identity_matrix; 3964 const gfx::Transform identity_matrix;
3958 scoped_refptr<Layer> parent = Layer::Create(); 3965 scoped_refptr<Layer> parent = Layer::Create(layer_settings());
3959 scoped_refptr<LayerWithForcedDrawsContent> child = 3966 scoped_refptr<LayerWithForcedDrawsContent> child =
3960 make_scoped_refptr(new LayerWithForcedDrawsContent()); 3967 make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
3961 scoped_refptr<LayerWithForcedDrawsContent> animating_surface = 3968 scoped_refptr<LayerWithForcedDrawsContent> animating_surface =
3962 make_scoped_refptr(new LayerWithForcedDrawsContent()); 3969 make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
3963 scoped_refptr<LayerWithForcedDrawsContent> child_of_animating_surface = 3970 scoped_refptr<LayerWithForcedDrawsContent> child_of_animating_surface =
3964 make_scoped_refptr(new LayerWithForcedDrawsContent()); 3971 make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
3965 scoped_refptr<LayerWithForcedDrawsContent> animating_child = 3972 scoped_refptr<LayerWithForcedDrawsContent> animating_child =
3966 make_scoped_refptr(new LayerWithForcedDrawsContent()); 3973 make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
3967 scoped_refptr<LayerWithForcedDrawsContent> child2 = 3974 scoped_refptr<LayerWithForcedDrawsContent> child2 =
3968 make_scoped_refptr(new LayerWithForcedDrawsContent()); 3975 make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
3969 3976
3970 parent->AddChild(child); 3977 parent->AddChild(child);
3971 parent->AddChild(animating_surface); 3978 parent->AddChild(animating_surface);
3972 animating_surface->AddChild(child_of_animating_surface); 3979 animating_surface->AddChild(child_of_animating_surface);
3973 parent->AddChild(animating_child); 3980 parent->AddChild(animating_child);
3974 parent->AddChild(child2); 3981 parent->AddChild(child2);
3975 3982
3976 scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost()); 3983 scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost());
3977 host->SetRootLayer(parent); 3984 host->SetRootLayer(parent);
3978 3985
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
4097 EXPECT_EQ(child_of_animating_surface->visible_content_rect(), 4104 EXPECT_EQ(child_of_animating_surface->visible_content_rect(),
4098 gfx::Rect(child_of_animating_surface->content_bounds())); 4105 gfx::Rect(child_of_animating_surface->content_bounds()));
4099 } 4106 }
4100 4107
4101 TEST_F(LayerTreeHostCommonTest, 4108 TEST_F(LayerTreeHostCommonTest,
4102 BackFaceCullingWithPreserves3dForFlatteningSurface) { 4109 BackFaceCullingWithPreserves3dForFlatteningSurface) {
4103 // Verify the behavior of back-face culling for a render surface that is 4110 // Verify the behavior of back-face culling for a render surface that is
4104 // created when it flattens its subtree, and its parent has preserves-3d. 4111 // created when it flattens its subtree, and its parent has preserves-3d.
4105 4112
4106 const gfx::Transform identity_matrix; 4113 const gfx::Transform identity_matrix;
4107 scoped_refptr<Layer> parent = Layer::Create(); 4114 scoped_refptr<Layer> parent = Layer::Create(layer_settings());
4108 scoped_refptr<LayerWithForcedDrawsContent> front_facing_surface = 4115 scoped_refptr<LayerWithForcedDrawsContent> front_facing_surface =
4109 make_scoped_refptr(new LayerWithForcedDrawsContent()); 4116 make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
4110 scoped_refptr<LayerWithForcedDrawsContent> back_facing_surface = 4117 scoped_refptr<LayerWithForcedDrawsContent> back_facing_surface =
4111 make_scoped_refptr(new LayerWithForcedDrawsContent()); 4118 make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
4112 scoped_refptr<LayerWithForcedDrawsContent> child1 = 4119 scoped_refptr<LayerWithForcedDrawsContent> child1 =
4113 make_scoped_refptr(new LayerWithForcedDrawsContent()); 4120 make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
4114 scoped_refptr<LayerWithForcedDrawsContent> child2 = 4121 scoped_refptr<LayerWithForcedDrawsContent> child2 =
4115 make_scoped_refptr(new LayerWithForcedDrawsContent()); 4122 make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
4116 4123
4117 parent->AddChild(front_facing_surface); 4124 parent->AddChild(front_facing_surface);
4118 parent->AddChild(back_facing_surface); 4125 parent->AddChild(back_facing_surface);
4119 front_facing_surface->AddChild(child1); 4126 front_facing_surface->AddChild(child1);
4120 back_facing_surface->AddChild(child2); 4127 back_facing_surface->AddChild(child2);
4121 4128
4122 scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost()); 4129 scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost());
4123 host->SetRootLayer(parent); 4130 host->SetRootLayer(parent);
4124 4131
4125 // RenderSurfaces are not double-sided 4132 // RenderSurfaces are not double-sided
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
4207 EXPECT_EQ(front_facing_surface->id(), 4214 EXPECT_EQ(front_facing_surface->id(),
4208 render_surface_layer_list.at(1) 4215 render_surface_layer_list.at(1)
4209 ->render_surface()->layer_list().at(0)->id()); 4216 ->render_surface()->layer_list().at(0)->id());
4210 EXPECT_EQ(child1->id(), 4217 EXPECT_EQ(child1->id(),
4211 render_surface_layer_list.at(1) 4218 render_surface_layer_list.at(1)
4212 ->render_surface()->layer_list().at(1)->id()); 4219 ->render_surface()->layer_list().at(1)->id());
4213 } 4220 }
4214 4221
4215 class NoScaleContentLayer : public ContentLayer { 4222 class NoScaleContentLayer : public ContentLayer {
4216 public: 4223 public:
4217 static scoped_refptr<NoScaleContentLayer> Create(ContentLayerClient* client) { 4224 static scoped_refptr<NoScaleContentLayer> Create(
4218 return make_scoped_refptr(new NoScaleContentLayer(client)); 4225 const LayerSettings& settings,
4226 ContentLayerClient* client) {
4227 return make_scoped_refptr(new NoScaleContentLayer(settings, client));
4219 } 4228 }
4220 4229
4221 void CalculateContentsScale(float ideal_contents_scale, 4230 void CalculateContentsScale(float ideal_contents_scale,
4222 float* contents_scale_x, 4231 float* contents_scale_x,
4223 float* contents_scale_y, 4232 float* contents_scale_y,
4224 gfx::Size* content_bounds) override { 4233 gfx::Size* content_bounds) override {
4225 // Skip over the ContentLayer to the base Layer class. 4234 // Skip over the ContentLayer to the base Layer class.
4226 Layer::CalculateContentsScale(ideal_contents_scale, 4235 Layer::CalculateContentsScale(ideal_contents_scale,
4227 contents_scale_x, 4236 contents_scale_x,
4228 contents_scale_y, 4237 contents_scale_y,
4229 content_bounds); 4238 content_bounds);
4230 } 4239 }
4231 4240
4232 protected: 4241 protected:
4233 explicit NoScaleContentLayer(ContentLayerClient* client) 4242 NoScaleContentLayer(const LayerSettings& settings, ContentLayerClient* client)
4234 : ContentLayer(client) {} 4243 : ContentLayer(settings, client) {}
4235 ~NoScaleContentLayer() override {} 4244 ~NoScaleContentLayer() override {}
4236 }; 4245 };
4237 4246
4238 scoped_refptr<NoScaleContentLayer> CreateNoScaleDrawableContentLayer( 4247 scoped_refptr<NoScaleContentLayer> CreateNoScaleDrawableContentLayer(
4248 const LayerSettings& settings,
4239 ContentLayerClient* delegate) { 4249 ContentLayerClient* delegate) {
4240 scoped_refptr<NoScaleContentLayer> to_return = 4250 scoped_refptr<NoScaleContentLayer> to_return =
4241 NoScaleContentLayer::Create(delegate); 4251 NoScaleContentLayer::Create(settings, delegate);
4242 to_return->SetIsDrawable(true); 4252 to_return->SetIsDrawable(true);
4243 return to_return; 4253 return to_return;
4244 } 4254 }
4245 4255
4246 TEST_F(LayerTreeHostCommonTest, LayerTransformsInHighDPI) { 4256 TEST_F(LayerTreeHostCommonTest, LayerTransformsInHighDPI) {
4247 // Verify draw and screen space transforms of layers not in a surface. 4257 // Verify draw and screen space transforms of layers not in a surface.
4248 MockContentLayerClient delegate; 4258 MockContentLayerClient delegate;
4249 gfx::Transform identity_matrix; 4259 gfx::Transform identity_matrix;
4250 4260
4251 scoped_refptr<FakePictureLayer> parent = 4261 scoped_refptr<FakePictureLayer> parent =
4252 CreateDrawablePictureLayer(&delegate); 4262 CreateDrawablePictureLayer(layer_settings(), &delegate);
4253 SetLayerPropertiesForTesting(parent.get(), 4263 SetLayerPropertiesForTesting(parent.get(),
4254 identity_matrix, 4264 identity_matrix,
4255 gfx::Point3F(), 4265 gfx::Point3F(),
4256 gfx::PointF(), 4266 gfx::PointF(),
4257 gfx::Size(100, 100), 4267 gfx::Size(100, 100),
4258 false, 4268 false,
4259 true); 4269 true);
4260 4270
4261 scoped_refptr<FakePictureLayer> child = CreateDrawablePictureLayer(&delegate); 4271 scoped_refptr<FakePictureLayer> child =
4272 CreateDrawablePictureLayer(layer_settings(), &delegate);
4262 SetLayerPropertiesForTesting(child.get(), 4273 SetLayerPropertiesForTesting(child.get(),
4263 identity_matrix, 4274 identity_matrix,
4264 gfx::Point3F(), 4275 gfx::Point3F(),
4265 gfx::PointF(2.f, 2.f), 4276 gfx::PointF(2.f, 2.f),
4266 gfx::Size(10, 10), 4277 gfx::Size(10, 10),
4267 false, 4278 false,
4268 true); 4279 true);
4269 4280
4270 scoped_refptr<FakePictureLayer> child_empty = 4281 scoped_refptr<FakePictureLayer> child_empty =
4271 CreateDrawablePictureLayer(&delegate); 4282 CreateDrawablePictureLayer(layer_settings(), &delegate);
4272 SetLayerPropertiesForTesting(child_empty.get(), 4283 SetLayerPropertiesForTesting(child_empty.get(),
4273 identity_matrix, 4284 identity_matrix,
4274 gfx::Point3F(), 4285 gfx::Point3F(),
4275 gfx::PointF(2.f, 2.f), 4286 gfx::PointF(2.f, 2.f),
4276 gfx::Size(), 4287 gfx::Size(),
4277 false, 4288 false,
4278 true); 4289 true);
4279 4290
4280 parent->AddChild(child); 4291 parent->AddChild(child);
4281 parent->AddChild(child_empty); 4292 parent->AddChild(child_empty);
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
4362 // Verify draw and screen space transforms of layers in a surface. 4373 // Verify draw and screen space transforms of layers in a surface.
4363 MockContentLayerClient delegate; 4374 MockContentLayerClient delegate;
4364 gfx::Transform identity_matrix; 4375 gfx::Transform identity_matrix;
4365 4376
4366 gfx::Transform perspective_matrix; 4377 gfx::Transform perspective_matrix;
4367 perspective_matrix.ApplyPerspectiveDepth(2.0); 4378 perspective_matrix.ApplyPerspectiveDepth(2.0);
4368 4379
4369 gfx::Transform scale_small_matrix; 4380 gfx::Transform scale_small_matrix;
4370 scale_small_matrix.Scale(SK_MScalar1 / 10.f, SK_MScalar1 / 12.f); 4381 scale_small_matrix.Scale(SK_MScalar1 / 10.f, SK_MScalar1 / 12.f);
4371 4382
4372 scoped_refptr<Layer> root = Layer::Create(); 4383 scoped_refptr<Layer> root = Layer::Create(layer_settings());
4373 4384
4374 scoped_refptr<FakePictureLayer> parent = 4385 scoped_refptr<FakePictureLayer> parent =
4375 CreateDrawablePictureLayer(&delegate); 4386 CreateDrawablePictureLayer(layer_settings(), &delegate);
4376 SetLayerPropertiesForTesting(parent.get(), 4387 SetLayerPropertiesForTesting(parent.get(),
4377 identity_matrix, 4388 identity_matrix,
4378 gfx::Point3F(), 4389 gfx::Point3F(),
4379 gfx::PointF(), 4390 gfx::PointF(),
4380 gfx::Size(100, 100), 4391 gfx::Size(100, 100),
4381 false, 4392 false,
4382 true); 4393 true);
4383 4394
4384 scoped_refptr<FakePictureLayer> perspective_surface = 4395 scoped_refptr<FakePictureLayer> perspective_surface =
4385 CreateDrawablePictureLayer(&delegate); 4396 CreateDrawablePictureLayer(layer_settings(), &delegate);
4386 SetLayerPropertiesForTesting(perspective_surface.get(), 4397 SetLayerPropertiesForTesting(perspective_surface.get(),
4387 perspective_matrix * scale_small_matrix, 4398 perspective_matrix * scale_small_matrix,
4388 gfx::Point3F(), 4399 gfx::Point3F(),
4389 gfx::PointF(2.f, 2.f), 4400 gfx::PointF(2.f, 2.f),
4390 gfx::Size(10, 10), 4401 gfx::Size(10, 10),
4391 false, 4402 false,
4392 true); 4403 true);
4393 4404
4394 scoped_refptr<FakePictureLayer> scale_surface = 4405 scoped_refptr<FakePictureLayer> scale_surface =
4395 CreateDrawablePictureLayer(&delegate); 4406 CreateDrawablePictureLayer(layer_settings(), &delegate);
4396 SetLayerPropertiesForTesting(scale_surface.get(), 4407 SetLayerPropertiesForTesting(scale_surface.get(),
4397 scale_small_matrix, 4408 scale_small_matrix,
4398 gfx::Point3F(), 4409 gfx::Point3F(),
4399 gfx::PointF(2.f, 2.f), 4410 gfx::PointF(2.f, 2.f),
4400 gfx::Size(10, 10), 4411 gfx::Size(10, 10),
4401 false, 4412 false,
4402 true); 4413 true);
4403 4414
4404 perspective_surface->SetForceRenderSurface(true); 4415 perspective_surface->SetForceRenderSurface(true);
4405 scale_surface->SetForceRenderSurface(true); 4416 scale_surface->SetForceRenderSurface(true);
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
4478 perspective_surface->draw_transform()); 4489 perspective_surface->draw_transform());
4479 } 4490 }
4480 4491
4481 // TODO(sohanjg): Remove this test when ContentLayer is removed. 4492 // TODO(sohanjg): Remove this test when ContentLayer is removed.
4482 TEST_F(LayerTreeHostCommonTest, 4493 TEST_F(LayerTreeHostCommonTest,
4483 LayerTransformsInHighDPIAccurateScaleZeroChildPosition) { 4494 LayerTransformsInHighDPIAccurateScaleZeroChildPosition) {
4484 // Verify draw and screen space transforms of layers not in a surface. 4495 // Verify draw and screen space transforms of layers not in a surface.
4485 MockContentLayerClient delegate; 4496 MockContentLayerClient delegate;
4486 gfx::Transform identity_matrix; 4497 gfx::Transform identity_matrix;
4487 4498
4488 scoped_refptr<ContentLayer> parent = CreateDrawableContentLayer(&delegate); 4499 scoped_refptr<ContentLayer> parent =
4500 CreateDrawableContentLayer(layer_settings(), &delegate);
4489 SetLayerPropertiesForTesting(parent.get(), 4501 SetLayerPropertiesForTesting(parent.get(),
4490 identity_matrix, 4502 identity_matrix,
4491 gfx::Point3F(), 4503 gfx::Point3F(),
4492 gfx::PointF(), 4504 gfx::PointF(),
4493 gfx::Size(133, 133), 4505 gfx::Size(133, 133),
4494 false, 4506 false,
4495 true); 4507 true);
4496 4508
4497 scoped_refptr<ContentLayer> child = CreateDrawableContentLayer(&delegate); 4509 scoped_refptr<ContentLayer> child =
4510 CreateDrawableContentLayer(layer_settings(), &delegate);
4498 SetLayerPropertiesForTesting(child.get(), 4511 SetLayerPropertiesForTesting(child.get(),
4499 identity_matrix, 4512 identity_matrix,
4500 gfx::Point3F(), 4513 gfx::Point3F(),
4501 gfx::PointF(), 4514 gfx::PointF(),
4502 gfx::Size(13, 13), 4515 gfx::Size(13, 13),
4503 false, 4516 false,
4504 true); 4517 true);
4505 4518
4506 scoped_refptr<NoScaleContentLayer> child_no_scale = 4519 scoped_refptr<NoScaleContentLayer> child_no_scale =
4507 CreateNoScaleDrawableContentLayer(&delegate); 4520 CreateNoScaleDrawableContentLayer(layer_settings(), &delegate);
4508 SetLayerPropertiesForTesting(child_no_scale.get(), 4521 SetLayerPropertiesForTesting(child_no_scale.get(),
4509 identity_matrix, 4522 identity_matrix,
4510 gfx::Point3F(), 4523 gfx::Point3F(),
4511 gfx::PointF(), 4524 gfx::PointF(),
4512 gfx::Size(13, 13), 4525 gfx::Size(13, 13),
4513 false, 4526 false,
4514 true); 4527 true);
4515 4528
4516 parent->AddChild(child); 4529 parent->AddChild(child);
4517 parent->AddChild(child_no_scale); 4530 parent->AddChild(child_no_scale);
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
4600 gfx::Transform identity_matrix; 4613 gfx::Transform identity_matrix;
4601 4614
4602 gfx::Transform parent_scale_matrix; 4615 gfx::Transform parent_scale_matrix;
4603 SkMScalar initial_parent_scale = 1.75; 4616 SkMScalar initial_parent_scale = 1.75;
4604 parent_scale_matrix.Scale(initial_parent_scale, initial_parent_scale); 4617 parent_scale_matrix.Scale(initial_parent_scale, initial_parent_scale);
4605 4618
4606 gfx::Transform child_scale_matrix; 4619 gfx::Transform child_scale_matrix;
4607 SkMScalar initial_child_scale = 1.25; 4620 SkMScalar initial_child_scale = 1.25;
4608 child_scale_matrix.Scale(initial_child_scale, initial_child_scale); 4621 child_scale_matrix.Scale(initial_child_scale, initial_child_scale);
4609 4622
4610 scoped_refptr<Layer> root = Layer::Create(); 4623 scoped_refptr<Layer> root = Layer::Create(layer_settings());
4611 root->SetBounds(gfx::Size(100, 100)); 4624 root->SetBounds(gfx::Size(100, 100));
4612 4625
4613 scoped_refptr<ContentLayer> parent = CreateDrawableContentLayer(&delegate); 4626 scoped_refptr<ContentLayer> parent =
4627 CreateDrawableContentLayer(layer_settings(), &delegate);
4614 SetLayerPropertiesForTesting(parent.get(), 4628 SetLayerPropertiesForTesting(parent.get(),
4615 parent_scale_matrix, 4629 parent_scale_matrix,
4616 gfx::Point3F(), 4630 gfx::Point3F(),
4617 gfx::PointF(), 4631 gfx::PointF(),
4618 gfx::Size(100, 100), 4632 gfx::Size(100, 100),
4619 false, 4633 false,
4620 true); 4634 true);
4621 4635
4622 scoped_refptr<ContentLayer> child_scale = 4636 scoped_refptr<ContentLayer> child_scale =
4623 CreateDrawableContentLayer(&delegate); 4637 CreateDrawableContentLayer(layer_settings(), &delegate);
4624 SetLayerPropertiesForTesting(child_scale.get(), 4638 SetLayerPropertiesForTesting(child_scale.get(),
4625 child_scale_matrix, 4639 child_scale_matrix,
4626 gfx::Point3F(), 4640 gfx::Point3F(),
4627 gfx::PointF(2.f, 2.f), 4641 gfx::PointF(2.f, 2.f),
4628 gfx::Size(10, 10), 4642 gfx::Size(10, 10),
4629 false, 4643 false,
4630 true); 4644 true);
4631 4645
4632 scoped_refptr<ContentLayer> child_empty = 4646 scoped_refptr<ContentLayer> child_empty =
4633 CreateDrawableContentLayer(&delegate); 4647 CreateDrawableContentLayer(layer_settings(), &delegate);
4634 SetLayerPropertiesForTesting(child_empty.get(), 4648 SetLayerPropertiesForTesting(child_empty.get(),
4635 child_scale_matrix, 4649 child_scale_matrix,
4636 gfx::Point3F(), 4650 gfx::Point3F(),
4637 gfx::PointF(2.f, 2.f), 4651 gfx::PointF(2.f, 2.f),
4638 gfx::Size(), 4652 gfx::Size(),
4639 false, 4653 false,
4640 true); 4654 true);
4641 4655
4642 scoped_refptr<NoScaleContentLayer> child_no_scale = 4656 scoped_refptr<NoScaleContentLayer> child_no_scale =
4643 CreateNoScaleDrawableContentLayer(&delegate); 4657 CreateNoScaleDrawableContentLayer(layer_settings(), &delegate);
4644 SetLayerPropertiesForTesting(child_no_scale.get(), 4658 SetLayerPropertiesForTesting(child_no_scale.get(),
4645 child_scale_matrix, 4659 child_scale_matrix,
4646 gfx::Point3F(), 4660 gfx::Point3F(),
4647 gfx::PointF(12.f, 12.f), 4661 gfx::PointF(12.f, 12.f),
4648 gfx::Size(10, 10), 4662 gfx::Size(10, 10),
4649 false, 4663 false,
4650 true); 4664 true);
4651 4665
4652 root->AddChild(parent); 4666 root->AddChild(parent);
4653 4667
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
4788 gfx::Transform identity_matrix; 4802 gfx::Transform identity_matrix;
4789 4803
4790 gfx::Transform parent_scale_matrix; 4804 gfx::Transform parent_scale_matrix;
4791 SkMScalar initial_parent_scale = 1.75; 4805 SkMScalar initial_parent_scale = 1.75;
4792 parent_scale_matrix.Scale(initial_parent_scale, initial_parent_scale); 4806 parent_scale_matrix.Scale(initial_parent_scale, initial_parent_scale);
4793 4807
4794 gfx::Transform child_scale_matrix; 4808 gfx::Transform child_scale_matrix;
4795 SkMScalar initial_child_scale = 1.25; 4809 SkMScalar initial_child_scale = 1.25;
4796 child_scale_matrix.Scale(initial_child_scale, initial_child_scale); 4810 child_scale_matrix.Scale(initial_child_scale, initial_child_scale);
4797 4811
4798 scoped_refptr<Layer> root = Layer::Create(); 4812 scoped_refptr<Layer> root = Layer::Create(layer_settings());
4799 root->SetBounds(gfx::Size(100, 100)); 4813 root->SetBounds(gfx::Size(100, 100));
4800 4814
4801 scoped_refptr<ContentLayer> parent = CreateDrawableContentLayer(&delegate); 4815 scoped_refptr<ContentLayer> parent =
4816 CreateDrawableContentLayer(layer_settings(), &delegate);
4802 SetLayerPropertiesForTesting(parent.get(), 4817 SetLayerPropertiesForTesting(parent.get(),
4803 parent_scale_matrix, 4818 parent_scale_matrix,
4804 gfx::Point3F(), 4819 gfx::Point3F(),
4805 gfx::PointF(), 4820 gfx::PointF(),
4806 gfx::Size(100, 100), 4821 gfx::Size(100, 100),
4807 false, 4822 false,
4808 true); 4823 true);
4809 4824
4810 scoped_refptr<ContentLayer> child_scale = 4825 scoped_refptr<ContentLayer> child_scale =
4811 CreateDrawableContentLayer(&delegate); 4826 CreateDrawableContentLayer(layer_settings(), &delegate);
4812 SetLayerPropertiesForTesting(child_scale.get(), 4827 SetLayerPropertiesForTesting(child_scale.get(),
4813 child_scale_matrix, 4828 child_scale_matrix,
4814 gfx::Point3F(), 4829 gfx::Point3F(),
4815 gfx::PointF(2.f, 2.f), 4830 gfx::PointF(2.f, 2.f),
4816 gfx::Size(10, 10), 4831 gfx::Size(10, 10),
4817 false, 4832 false,
4818 true); 4833 true);
4819 4834
4820 scoped_refptr<ContentLayer> child_empty = 4835 scoped_refptr<ContentLayer> child_empty =
4821 CreateDrawableContentLayer(&delegate); 4836 CreateDrawableContentLayer(layer_settings(), &delegate);
4822 SetLayerPropertiesForTesting(child_empty.get(), 4837 SetLayerPropertiesForTesting(child_empty.get(),
4823 child_scale_matrix, 4838 child_scale_matrix,
4824 gfx::Point3F(), 4839 gfx::Point3F(),
4825 gfx::PointF(2.f, 2.f), 4840 gfx::PointF(2.f, 2.f),
4826 gfx::Size(), 4841 gfx::Size(),
4827 false, 4842 false,
4828 true); 4843 true);
4829 4844
4830 scoped_refptr<NoScaleContentLayer> child_no_scale = 4845 scoped_refptr<NoScaleContentLayer> child_no_scale =
4831 CreateNoScaleDrawableContentLayer(&delegate); 4846 CreateNoScaleDrawableContentLayer(layer_settings(), &delegate);
4832 SetLayerPropertiesForTesting(child_no_scale.get(), 4847 SetLayerPropertiesForTesting(child_no_scale.get(),
4833 child_scale_matrix, 4848 child_scale_matrix,
4834 gfx::Point3F(), 4849 gfx::Point3F(),
4835 gfx::PointF(12.f, 12.f), 4850 gfx::PointF(12.f, 12.f),
4836 gfx::Size(10, 10), 4851 gfx::Size(10, 10),
4837 false, 4852 false,
4838 true); 4853 true);
4839 4854
4840 root->AddChild(parent); 4855 root->AddChild(parent);
4841 4856
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
4892 gfx::Transform identity_matrix; 4907 gfx::Transform identity_matrix;
4893 4908
4894 gfx::Transform parent_scale_matrix; 4909 gfx::Transform parent_scale_matrix;
4895 SkMScalar initial_parent_scale = 1.75; 4910 SkMScalar initial_parent_scale = 1.75;
4896 parent_scale_matrix.Scale(initial_parent_scale, initial_parent_scale); 4911 parent_scale_matrix.Scale(initial_parent_scale, initial_parent_scale);
4897 4912
4898 gfx::Transform child_scale_matrix; 4913 gfx::Transform child_scale_matrix;
4899 SkMScalar initial_child_scale = 0.25; 4914 SkMScalar initial_child_scale = 0.25;
4900 child_scale_matrix.Scale(initial_child_scale, initial_child_scale); 4915 child_scale_matrix.Scale(initial_child_scale, initial_child_scale);
4901 4916
4902 scoped_refptr<Layer> root = Layer::Create(); 4917 scoped_refptr<Layer> root = Layer::Create(layer_settings());
4903 root->SetBounds(gfx::Size(100, 100)); 4918 root->SetBounds(gfx::Size(100, 100));
4904 4919
4905 scoped_refptr<FakePictureLayer> parent = 4920 scoped_refptr<FakePictureLayer> parent =
4906 CreateDrawablePictureLayer(&delegate); 4921 CreateDrawablePictureLayer(layer_settings(), &delegate);
4907 SetLayerPropertiesForTesting(parent.get(), 4922 SetLayerPropertiesForTesting(parent.get(),
4908 parent_scale_matrix, 4923 parent_scale_matrix,
4909 gfx::Point3F(), 4924 gfx::Point3F(),
4910 gfx::PointF(), 4925 gfx::PointF(),
4911 gfx::Size(100, 100), 4926 gfx::Size(100, 100),
4912 false, 4927 false,
4913 true); 4928 true);
4914 4929
4915 scoped_refptr<FakePictureLayer> child_scale = 4930 scoped_refptr<FakePictureLayer> child_scale =
4916 CreateDrawablePictureLayer(&delegate); 4931 CreateDrawablePictureLayer(layer_settings(), &delegate);
4917 SetLayerPropertiesForTesting(child_scale.get(), 4932 SetLayerPropertiesForTesting(child_scale.get(),
4918 child_scale_matrix, 4933 child_scale_matrix,
4919 gfx::Point3F(), 4934 gfx::Point3F(),
4920 gfx::PointF(2.f, 2.f), 4935 gfx::PointF(2.f, 2.f),
4921 gfx::Size(10, 10), 4936 gfx::Size(10, 10),
4922 false, 4937 false,
4923 true); 4938 true);
4924 4939
4925 root->AddChild(parent); 4940 root->AddChild(parent);
4926 4941
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
4960 gfx::Transform identity_matrix; 4975 gfx::Transform identity_matrix;
4961 4976
4962 gfx::Transform parent_scale_matrix; 4977 gfx::Transform parent_scale_matrix;
4963 SkMScalar initial_parent_scale = 2.0; 4978 SkMScalar initial_parent_scale = 2.0;
4964 parent_scale_matrix.Scale(initial_parent_scale, initial_parent_scale); 4979 parent_scale_matrix.Scale(initial_parent_scale, initial_parent_scale);
4965 4980
4966 gfx::Transform child_scale_matrix; 4981 gfx::Transform child_scale_matrix;
4967 SkMScalar initial_child_scale = 3.0; 4982 SkMScalar initial_child_scale = 3.0;
4968 child_scale_matrix.Scale(initial_child_scale, initial_child_scale); 4983 child_scale_matrix.Scale(initial_child_scale, initial_child_scale);
4969 4984
4970 scoped_refptr<Layer> root = Layer::Create(); 4985 scoped_refptr<Layer> root = Layer::Create(layer_settings());
4971 root->SetBounds(gfx::Size(100, 100)); 4986 root->SetBounds(gfx::Size(100, 100));
4972 4987
4973 scoped_refptr<ContentLayer> parent = CreateDrawableContentLayer(&delegate); 4988 scoped_refptr<ContentLayer> parent =
4989 CreateDrawableContentLayer(layer_settings(), &delegate);
4974 SetLayerPropertiesForTesting(parent.get(), 4990 SetLayerPropertiesForTesting(parent.get(),
4975 parent_scale_matrix, 4991 parent_scale_matrix,
4976 gfx::Point3F(), 4992 gfx::Point3F(),
4977 gfx::PointF(), 4993 gfx::PointF(),
4978 gfx::Size(100, 100), 4994 gfx::Size(100, 100),
4979 false, 4995 false,
4980 true); 4996 true);
4981 4997
4982 scoped_refptr<ContentLayer> surface_scale = 4998 scoped_refptr<ContentLayer> surface_scale =
4983 CreateDrawableContentLayer(&delegate); 4999 CreateDrawableContentLayer(layer_settings(), &delegate);
4984 SetLayerPropertiesForTesting(surface_scale.get(), 5000 SetLayerPropertiesForTesting(surface_scale.get(),
4985 child_scale_matrix, 5001 child_scale_matrix,
4986 gfx::Point3F(), 5002 gfx::Point3F(),
4987 gfx::PointF(2.f, 2.f), 5003 gfx::PointF(2.f, 2.f),
4988 gfx::Size(10, 10), 5004 gfx::Size(10, 10),
4989 false, 5005 false,
4990 true); 5006 true);
4991 5007
4992 scoped_refptr<ContentLayer> surface_scale_child_scale = 5008 scoped_refptr<ContentLayer> surface_scale_child_scale =
4993 CreateDrawableContentLayer(&delegate); 5009 CreateDrawableContentLayer(layer_settings(), &delegate);
4994 SetLayerPropertiesForTesting(surface_scale_child_scale.get(), 5010 SetLayerPropertiesForTesting(surface_scale_child_scale.get(),
4995 child_scale_matrix, 5011 child_scale_matrix,
4996 gfx::Point3F(), 5012 gfx::Point3F(),
4997 gfx::PointF(), 5013 gfx::PointF(),
4998 gfx::Size(10, 10), 5014 gfx::Size(10, 10),
4999 false, 5015 false,
5000 true); 5016 true);
5001 5017
5002 scoped_refptr<NoScaleContentLayer> surface_scale_child_no_scale = 5018 scoped_refptr<NoScaleContentLayer> surface_scale_child_no_scale =
5003 CreateNoScaleDrawableContentLayer(&delegate); 5019 CreateNoScaleDrawableContentLayer(layer_settings(), &delegate);
5004 SetLayerPropertiesForTesting(surface_scale_child_no_scale.get(), 5020 SetLayerPropertiesForTesting(surface_scale_child_no_scale.get(),
5005 child_scale_matrix, 5021 child_scale_matrix,
5006 gfx::Point3F(), 5022 gfx::Point3F(),
5007 gfx::PointF(), 5023 gfx::PointF(),
5008 gfx::Size(10, 10), 5024 gfx::Size(10, 10),
5009 false, 5025 false,
5010 true); 5026 true);
5011 5027
5012 scoped_refptr<NoScaleContentLayer> surface_no_scale = 5028 scoped_refptr<NoScaleContentLayer> surface_no_scale =
5013 CreateNoScaleDrawableContentLayer(&delegate); 5029 CreateNoScaleDrawableContentLayer(layer_settings(), &delegate);
5014 SetLayerPropertiesForTesting(surface_no_scale.get(), 5030 SetLayerPropertiesForTesting(surface_no_scale.get(),
5015 child_scale_matrix, 5031 child_scale_matrix,
5016 gfx::Point3F(), 5032 gfx::Point3F(),
5017 gfx::PointF(12.f, 12.f), 5033 gfx::PointF(12.f, 12.f),
5018 gfx::Size(10, 10), 5034 gfx::Size(10, 10),
5019 false, 5035 false,
5020 true); 5036 true);
5021 5037
5022 scoped_refptr<ContentLayer> surface_no_scale_child_scale = 5038 scoped_refptr<ContentLayer> surface_no_scale_child_scale =
5023 CreateDrawableContentLayer(&delegate); 5039 CreateDrawableContentLayer(layer_settings(), &delegate);
5024 SetLayerPropertiesForTesting(surface_no_scale_child_scale.get(), 5040 SetLayerPropertiesForTesting(surface_no_scale_child_scale.get(),
5025 child_scale_matrix, 5041 child_scale_matrix,
5026 gfx::Point3F(), 5042 gfx::Point3F(),
5027 gfx::PointF(), 5043 gfx::PointF(),
5028 gfx::Size(10, 10), 5044 gfx::Size(10, 10),
5029 false, 5045 false,
5030 true); 5046 true);
5031 5047
5032 scoped_refptr<NoScaleContentLayer> surface_no_scale_child_no_scale = 5048 scoped_refptr<NoScaleContentLayer> surface_no_scale_child_no_scale =
5033 CreateNoScaleDrawableContentLayer(&delegate); 5049 CreateNoScaleDrawableContentLayer(layer_settings(), &delegate);
5034 SetLayerPropertiesForTesting(surface_no_scale_child_no_scale.get(), 5050 SetLayerPropertiesForTesting(surface_no_scale_child_no_scale.get(),
5035 child_scale_matrix, 5051 child_scale_matrix,
5036 gfx::Point3F(), 5052 gfx::Point3F(),
5037 gfx::PointF(), 5053 gfx::PointF(),
5038 gfx::Size(10, 10), 5054 gfx::Size(10, 10),
5039 false, 5055 false,
5040 true); 5056 true);
5041 5057
5042 root->AddChild(parent); 5058 root->AddChild(parent);
5043 5059
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
5162 gfx::Transform identity_matrix; 5178 gfx::Transform identity_matrix;
5163 5179
5164 gfx::Transform parent_scale_matrix; 5180 gfx::Transform parent_scale_matrix;
5165 SkMScalar initial_parent_scale = 2.0; 5181 SkMScalar initial_parent_scale = 2.0;
5166 parent_scale_matrix.Scale(initial_parent_scale, initial_parent_scale); 5182 parent_scale_matrix.Scale(initial_parent_scale, initial_parent_scale);
5167 5183
5168 gfx::Transform child_scale_matrix; 5184 gfx::Transform child_scale_matrix;
5169 SkMScalar initial_child_scale = 3.0; 5185 SkMScalar initial_child_scale = 3.0;
5170 child_scale_matrix.Scale(initial_child_scale, initial_child_scale); 5186 child_scale_matrix.Scale(initial_child_scale, initial_child_scale);
5171 5187
5172 scoped_refptr<Layer> root = Layer::Create(); 5188 scoped_refptr<Layer> root = Layer::Create(layer_settings());
5173 root->SetBounds(gfx::Size(100, 100)); 5189 root->SetBounds(gfx::Size(100, 100));
5174 5190
5175 scoped_refptr<ContentLayer> parent = CreateDrawableContentLayer(&delegate); 5191 scoped_refptr<ContentLayer> parent =
5192 CreateDrawableContentLayer(layer_settings(), &delegate);
5176 SetLayerPropertiesForTesting(parent.get(), 5193 SetLayerPropertiesForTesting(parent.get(),
5177 parent_scale_matrix, 5194 parent_scale_matrix,
5178 gfx::Point3F(), 5195 gfx::Point3F(),
5179 gfx::PointF(), 5196 gfx::PointF(),
5180 gfx::Size(100, 100), 5197 gfx::Size(100, 100),
5181 false, 5198 false,
5182 true); 5199 true);
5183 5200
5184 scoped_refptr<ContentLayer> surface_scale = 5201 scoped_refptr<ContentLayer> surface_scale =
5185 CreateDrawableContentLayer(&delegate); 5202 CreateDrawableContentLayer(layer_settings(), &delegate);
5186 SetLayerPropertiesForTesting(surface_scale.get(), 5203 SetLayerPropertiesForTesting(surface_scale.get(),
5187 child_scale_matrix, 5204 child_scale_matrix,
5188 gfx::Point3F(), 5205 gfx::Point3F(),
5189 gfx::PointF(2.f, 2.f), 5206 gfx::PointF(2.f, 2.f),
5190 gfx::Size(10, 10), 5207 gfx::Size(10, 10),
5191 false, 5208 false,
5192 true); 5209 true);
5193 5210
5194 scoped_refptr<ContentLayer> surface_scale_child_scale = 5211 scoped_refptr<ContentLayer> surface_scale_child_scale =
5195 CreateDrawableContentLayer(&delegate); 5212 CreateDrawableContentLayer(layer_settings(), &delegate);
5196 SetLayerPropertiesForTesting(surface_scale_child_scale.get(), 5213 SetLayerPropertiesForTesting(surface_scale_child_scale.get(),
5197 child_scale_matrix, 5214 child_scale_matrix,
5198 gfx::Point3F(), 5215 gfx::Point3F(),
5199 gfx::PointF(), 5216 gfx::PointF(),
5200 gfx::Size(10, 10), 5217 gfx::Size(10, 10),
5201 false, 5218 false,
5202 true); 5219 true);
5203 5220
5204 scoped_refptr<NoScaleContentLayer> surface_scale_child_no_scale = 5221 scoped_refptr<NoScaleContentLayer> surface_scale_child_no_scale =
5205 CreateNoScaleDrawableContentLayer(&delegate); 5222 CreateNoScaleDrawableContentLayer(layer_settings(), &delegate);
5206 SetLayerPropertiesForTesting(surface_scale_child_no_scale.get(), 5223 SetLayerPropertiesForTesting(surface_scale_child_no_scale.get(),
5207 child_scale_matrix, 5224 child_scale_matrix,
5208 gfx::Point3F(), 5225 gfx::Point3F(),
5209 gfx::PointF(), 5226 gfx::PointF(),
5210 gfx::Size(10, 10), 5227 gfx::Size(10, 10),
5211 false, 5228 false,
5212 true); 5229 true);
5213 5230
5214 scoped_refptr<NoScaleContentLayer> surface_no_scale = 5231 scoped_refptr<NoScaleContentLayer> surface_no_scale =
5215 CreateNoScaleDrawableContentLayer(&delegate); 5232 CreateNoScaleDrawableContentLayer(layer_settings(), &delegate);
5216 SetLayerPropertiesForTesting(surface_no_scale.get(), 5233 SetLayerPropertiesForTesting(surface_no_scale.get(),
5217 child_scale_matrix, 5234 child_scale_matrix,
5218 gfx::Point3F(), 5235 gfx::Point3F(),
5219 gfx::PointF(12.f, 12.f), 5236 gfx::PointF(12.f, 12.f),
5220 gfx::Size(10, 10), 5237 gfx::Size(10, 10),
5221 false, 5238 false,
5222 true); 5239 true);
5223 5240
5224 scoped_refptr<ContentLayer> surface_no_scale_child_scale = 5241 scoped_refptr<ContentLayer> surface_no_scale_child_scale =
5225 CreateDrawableContentLayer(&delegate); 5242 CreateDrawableContentLayer(layer_settings(), &delegate);
5226 SetLayerPropertiesForTesting(surface_no_scale_child_scale.get(), 5243 SetLayerPropertiesForTesting(surface_no_scale_child_scale.get(),
5227 child_scale_matrix, 5244 child_scale_matrix,
5228 gfx::Point3F(), 5245 gfx::Point3F(),
5229 gfx::PointF(), 5246 gfx::PointF(),
5230 gfx::Size(10, 10), 5247 gfx::Size(10, 10),
5231 false, 5248 false,
5232 true); 5249 true);
5233 5250
5234 scoped_refptr<NoScaleContentLayer> surface_no_scale_child_no_scale = 5251 scoped_refptr<NoScaleContentLayer> surface_no_scale_child_no_scale =
5235 CreateNoScaleDrawableContentLayer(&delegate); 5252 CreateNoScaleDrawableContentLayer(layer_settings(), &delegate);
5236 SetLayerPropertiesForTesting(surface_no_scale_child_no_scale.get(), 5253 SetLayerPropertiesForTesting(surface_no_scale_child_no_scale.get(),
5237 child_scale_matrix, 5254 child_scale_matrix,
5238 gfx::Point3F(), 5255 gfx::Point3F(),
5239 gfx::PointF(), 5256 gfx::PointF(),
5240 gfx::Size(10, 10), 5257 gfx::Size(10, 10),
5241 false, 5258 false,
5242 true); 5259 true);
5243 5260
5244 root->AddChild(parent); 5261 root->AddChild(parent);
5245 5262
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
5370 gfx::Transform identity_matrix; 5387 gfx::Transform identity_matrix;
5371 5388
5372 gfx::Transform parent_scale_matrix; 5389 gfx::Transform parent_scale_matrix;
5373 SkMScalar initial_parent_scale = 1.75; 5390 SkMScalar initial_parent_scale = 1.75;
5374 parent_scale_matrix.Scale(initial_parent_scale, initial_parent_scale); 5391 parent_scale_matrix.Scale(initial_parent_scale, initial_parent_scale);
5375 5392
5376 gfx::Transform child_scale_matrix; 5393 gfx::Transform child_scale_matrix;
5377 SkMScalar initial_child_scale = 1.25; 5394 SkMScalar initial_child_scale = 1.25;
5378 child_scale_matrix.Scale(initial_child_scale, initial_child_scale); 5395 child_scale_matrix.Scale(initial_child_scale, initial_child_scale);
5379 5396
5380 scoped_refptr<Layer> root = Layer::Create(); 5397 scoped_refptr<Layer> root = Layer::Create(layer_settings());
5381 root->SetBounds(gfx::Size(100, 100)); 5398 root->SetBounds(gfx::Size(100, 100));
5382 5399
5383 scoped_refptr<FakePictureLayer> parent = 5400 scoped_refptr<FakePictureLayer> parent =
5384 CreateDrawablePictureLayer(&delegate); 5401 CreateDrawablePictureLayer(layer_settings(), &delegate);
5385 SetLayerPropertiesForTesting(parent.get(), 5402 SetLayerPropertiesForTesting(parent.get(),
5386 parent_scale_matrix, 5403 parent_scale_matrix,
5387 gfx::Point3F(), 5404 gfx::Point3F(),
5388 gfx::PointF(), 5405 gfx::PointF(),
5389 gfx::Size(100, 100), 5406 gfx::Size(100, 100),
5390 false, 5407 false,
5391 true); 5408 true);
5392 5409
5393 scoped_refptr<FakePictureLayer> child_scale = 5410 scoped_refptr<FakePictureLayer> child_scale =
5394 CreateDrawablePictureLayer(&delegate); 5411 CreateDrawablePictureLayer(layer_settings(), &delegate);
5395 SetLayerPropertiesForTesting(child_scale.get(), 5412 SetLayerPropertiesForTesting(child_scale.get(),
5396 child_scale_matrix, 5413 child_scale_matrix,
5397 gfx::Point3F(), 5414 gfx::Point3F(),
5398 gfx::PointF(2.f, 2.f), 5415 gfx::PointF(2.f, 2.f),
5399 gfx::Size(10, 10), 5416 gfx::Size(10, 10),
5400 false, 5417 false,
5401 true); 5418 true);
5402 5419
5403 root->AddChild(parent); 5420 root->AddChild(parent);
5404 5421
(...skipping 14 matching lines...) Expand all
5419 // they are static. 5436 // they are static.
5420 EXPECT_IDEAL_SCALE_EQ(initial_child_scale * initial_parent_scale, 5437 EXPECT_IDEAL_SCALE_EQ(initial_child_scale * initial_parent_scale,
5421 child_scale); 5438 child_scale);
5422 } 5439 }
5423 } 5440 }
5424 5441
5425 // TODO(sohanjg): Remove this test when ContentLayer is removed. 5442 // TODO(sohanjg): Remove this test when ContentLayer is removed.
5426 TEST_F(LayerTreeHostCommonTest, 5443 TEST_F(LayerTreeHostCommonTest,
5427 ChangeInContentBoundsOrScaleTriggersPushProperties) { 5444 ChangeInContentBoundsOrScaleTriggersPushProperties) {
5428 MockContentLayerClient delegate; 5445 MockContentLayerClient delegate;
5429 scoped_refptr<Layer> root = Layer::Create(); 5446 scoped_refptr<Layer> root = Layer::Create(layer_settings());
5430 scoped_refptr<Layer> child = CreateDrawableContentLayer(&delegate); 5447 scoped_refptr<Layer> child =
5448 CreateDrawableContentLayer(layer_settings(), &delegate);
5431 root->AddChild(child); 5449 root->AddChild(child);
5432 5450
5433 scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost()); 5451 scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost());
5434 host->SetRootLayer(root); 5452 host->SetRootLayer(root);
5435 5453
5436 gfx::Transform identity_matrix; 5454 gfx::Transform identity_matrix;
5437 SetLayerPropertiesForTesting(root.get(), 5455 SetLayerPropertiesForTesting(root.get(),
5438 identity_matrix, 5456 identity_matrix,
5439 gfx::Point3F(), 5457 gfx::Point3F(),
5440 gfx::PointF(), 5458 gfx::PointF(),
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
5473 ExecuteCalculateDrawProperties(root.get(), 2.f); 5491 ExecuteCalculateDrawProperties(root.get(), 2.f);
5474 EXPECT_FALSE(root->needs_push_properties()); 5492 EXPECT_FALSE(root->needs_push_properties());
5475 EXPECT_FALSE(child->needs_push_properties()); 5493 EXPECT_FALSE(child->needs_push_properties());
5476 } 5494 }
5477 5495
5478 TEST_F(LayerTreeHostCommonTest, RenderSurfaceTransformsInHighDPI) { 5496 TEST_F(LayerTreeHostCommonTest, RenderSurfaceTransformsInHighDPI) {
5479 MockContentLayerClient delegate; 5497 MockContentLayerClient delegate;
5480 gfx::Transform identity_matrix; 5498 gfx::Transform identity_matrix;
5481 5499
5482 scoped_refptr<FakePictureLayer> parent = 5500 scoped_refptr<FakePictureLayer> parent =
5483 CreateDrawablePictureLayer(&delegate); 5501 CreateDrawablePictureLayer(layer_settings(), &delegate);
5484 SetLayerPropertiesForTesting(parent.get(), 5502 SetLayerPropertiesForTesting(parent.get(),
5485 identity_matrix, 5503 identity_matrix,
5486 gfx::Point3F(), 5504 gfx::Point3F(),
5487 gfx::PointF(), 5505 gfx::PointF(),
5488 gfx::Size(30, 30), 5506 gfx::Size(30, 30),
5489 false, 5507 false,
5490 true); 5508 true);
5491 5509
5492 scoped_refptr<FakePictureLayer> child = CreateDrawablePictureLayer(&delegate); 5510 scoped_refptr<FakePictureLayer> child =
5511 CreateDrawablePictureLayer(layer_settings(), &delegate);
5493 SetLayerPropertiesForTesting(child.get(), 5512 SetLayerPropertiesForTesting(child.get(),
5494 identity_matrix, 5513 identity_matrix,
5495 gfx::Point3F(), 5514 gfx::Point3F(),
5496 gfx::PointF(2.f, 2.f), 5515 gfx::PointF(2.f, 2.f),
5497 gfx::Size(10, 10), 5516 gfx::Size(10, 10),
5498 false, 5517 false,
5499 true); 5518 true);
5500 5519
5501 gfx::Transform replica_transform; 5520 gfx::Transform replica_transform;
5502 replica_transform.Scale(1.0, -1.0); 5521 replica_transform.Scale(1.0, -1.0);
5503 scoped_refptr<FakePictureLayer> replica = 5522 scoped_refptr<FakePictureLayer> replica =
5504 CreateDrawablePictureLayer(&delegate); 5523 CreateDrawablePictureLayer(layer_settings(), &delegate);
5505 SetLayerPropertiesForTesting(replica.get(), 5524 SetLayerPropertiesForTesting(replica.get(),
5506 replica_transform, 5525 replica_transform,
5507 gfx::Point3F(), 5526 gfx::Point3F(),
5508 gfx::PointF(2.f, 2.f), 5527 gfx::PointF(2.f, 2.f),
5509 gfx::Size(10, 10), 5528 gfx::Size(10, 10),
5510 false, 5529 false,
5511 true); 5530 true);
5512 5531
5513 // This layer should end up in the same surface as child, with the same draw 5532 // This layer should end up in the same surface as child, with the same draw
5514 // and screen space transforms. 5533 // and screen space transforms.
5515 scoped_refptr<FakePictureLayer> duplicate_child_non_owner = 5534 scoped_refptr<FakePictureLayer> duplicate_child_non_owner =
5516 CreateDrawablePictureLayer(&delegate); 5535 CreateDrawablePictureLayer(layer_settings(), &delegate);
5517 SetLayerPropertiesForTesting(duplicate_child_non_owner.get(), 5536 SetLayerPropertiesForTesting(duplicate_child_non_owner.get(),
5518 identity_matrix, 5537 identity_matrix,
5519 gfx::Point3F(), 5538 gfx::Point3F(),
5520 gfx::PointF(), 5539 gfx::PointF(),
5521 gfx::Size(10, 10), 5540 gfx::Size(10, 10),
5522 false, 5541 false,
5523 true); 5542 true);
5524 5543
5525 parent->AddChild(child); 5544 parent->AddChild(child);
5526 child->AddChild(duplicate_child_non_owner); 5545 child->AddChild(duplicate_child_non_owner);
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
5613 expected_replica_screen_space_transform, 5632 expected_replica_screen_space_transform,
5614 child->render_surface()->replica_screen_space_transform()); 5633 child->render_surface()->replica_screen_space_transform());
5615 } 5634 }
5616 5635
5617 TEST_F(LayerTreeHostCommonTest, 5636 TEST_F(LayerTreeHostCommonTest,
5618 RenderSurfaceTransformsInHighDPIAccurateScaleZeroPosition) { 5637 RenderSurfaceTransformsInHighDPIAccurateScaleZeroPosition) {
5619 MockContentLayerClient delegate; 5638 MockContentLayerClient delegate;
5620 gfx::Transform identity_matrix; 5639 gfx::Transform identity_matrix;
5621 5640
5622 scoped_refptr<FakePictureLayer> parent = 5641 scoped_refptr<FakePictureLayer> parent =
5623 CreateDrawablePictureLayer(&delegate); 5642 CreateDrawablePictureLayer(layer_settings(), &delegate);
5624 SetLayerPropertiesForTesting(parent.get(), 5643 SetLayerPropertiesForTesting(parent.get(),
5625 identity_matrix, 5644 identity_matrix,
5626 gfx::Point3F(), 5645 gfx::Point3F(),
5627 gfx::PointF(), 5646 gfx::PointF(),
5628 gfx::Size(33, 31), 5647 gfx::Size(33, 31),
5629 false, 5648 false,
5630 true); 5649 true);
5631 5650
5632 scoped_refptr<FakePictureLayer> child = CreateDrawablePictureLayer(&delegate); 5651 scoped_refptr<FakePictureLayer> child =
5652 CreateDrawablePictureLayer(layer_settings(), &delegate);
5633 SetLayerPropertiesForTesting(child.get(), 5653 SetLayerPropertiesForTesting(child.get(),
5634 identity_matrix, 5654 identity_matrix,
5635 gfx::Point3F(), 5655 gfx::Point3F(),
5636 gfx::PointF(), 5656 gfx::PointF(),
5637 gfx::Size(13, 11), 5657 gfx::Size(13, 11),
5638 false, 5658 false,
5639 true); 5659 true);
5640 5660
5641 gfx::Transform replica_transform; 5661 gfx::Transform replica_transform;
5642 replica_transform.Scale(1.0, -1.0); 5662 replica_transform.Scale(1.0, -1.0);
5643 scoped_refptr<FakePictureLayer> replica = 5663 scoped_refptr<FakePictureLayer> replica =
5644 CreateDrawablePictureLayer(&delegate); 5664 CreateDrawablePictureLayer(layer_settings(), &delegate);
5645 SetLayerPropertiesForTesting(replica.get(), 5665 SetLayerPropertiesForTesting(replica.get(),
5646 replica_transform, 5666 replica_transform,
5647 gfx::Point3F(), 5667 gfx::Point3F(),
5648 gfx::PointF(), 5668 gfx::PointF(),
5649 gfx::Size(13, 11), 5669 gfx::Size(13, 11),
5650 false, 5670 false,
5651 true); 5671 true);
5652 5672
5653 parent->AddChild(child); 5673 parent->AddChild(child);
5654 child->SetReplicaLayer(replica.get()); 5674 child->SetReplicaLayer(replica.get());
(...skipping 29 matching lines...) Expand all
5684 child->render_surface()->replica_draw_transform()); 5704 child->render_surface()->replica_draw_transform());
5685 5705
5686 gfx::Transform expected_replica_screen_space_transform; 5706 gfx::Transform expected_replica_screen_space_transform;
5687 expected_replica_screen_space_transform.matrix().set(1, 1, -1.0); 5707 expected_replica_screen_space_transform.matrix().set(1, 1, -1.0);
5688 EXPECT_TRANSFORMATION_MATRIX_EQ( 5708 EXPECT_TRANSFORMATION_MATRIX_EQ(
5689 expected_replica_screen_space_transform, 5709 expected_replica_screen_space_transform,
5690 child->render_surface()->replica_screen_space_transform()); 5710 child->render_surface()->replica_screen_space_transform());
5691 } 5711 }
5692 5712
5693 TEST_F(LayerTreeHostCommonTest, SubtreeSearch) { 5713 TEST_F(LayerTreeHostCommonTest, SubtreeSearch) {
5694 scoped_refptr<Layer> root = Layer::Create(); 5714 scoped_refptr<Layer> root = Layer::Create(layer_settings());
5695 scoped_refptr<Layer> child = Layer::Create(); 5715 scoped_refptr<Layer> child = Layer::Create(layer_settings());
5696 scoped_refptr<Layer> grand_child = Layer::Create(); 5716 scoped_refptr<Layer> grand_child = Layer::Create(layer_settings());
5697 scoped_refptr<Layer> mask_layer = Layer::Create(); 5717 scoped_refptr<Layer> mask_layer = Layer::Create(layer_settings());
5698 scoped_refptr<Layer> replica_layer = Layer::Create(); 5718 scoped_refptr<Layer> replica_layer = Layer::Create(layer_settings());
5699 5719
5700 grand_child->SetReplicaLayer(replica_layer.get()); 5720 grand_child->SetReplicaLayer(replica_layer.get());
5701 child->AddChild(grand_child.get()); 5721 child->AddChild(grand_child.get());
5702 child->SetMaskLayer(mask_layer.get()); 5722 child->SetMaskLayer(mask_layer.get());
5703 root->AddChild(child.get()); 5723 root->AddChild(child.get());
5704 5724
5705 scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost()); 5725 scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost());
5706 host->SetRootLayer(root); 5726 host->SetRootLayer(root);
5707 5727
5708 int nonexistent_id = -1; 5728 int nonexistent_id = -1;
5709 EXPECT_EQ(root.get(), 5729 EXPECT_EQ(root.get(),
5710 LayerTreeHostCommon::FindLayerInSubtree(root.get(), root->id())); 5730 LayerTreeHostCommon::FindLayerInSubtree(root.get(), root->id()));
5711 EXPECT_EQ(child.get(), 5731 EXPECT_EQ(child.get(),
5712 LayerTreeHostCommon::FindLayerInSubtree(root.get(), child->id())); 5732 LayerTreeHostCommon::FindLayerInSubtree(root.get(), child->id()));
5713 EXPECT_EQ( 5733 EXPECT_EQ(
5714 grand_child.get(), 5734 grand_child.get(),
5715 LayerTreeHostCommon::FindLayerInSubtree(root.get(), grand_child->id())); 5735 LayerTreeHostCommon::FindLayerInSubtree(root.get(), grand_child->id()));
5716 EXPECT_EQ( 5736 EXPECT_EQ(
5717 mask_layer.get(), 5737 mask_layer.get(),
5718 LayerTreeHostCommon::FindLayerInSubtree(root.get(), mask_layer->id())); 5738 LayerTreeHostCommon::FindLayerInSubtree(root.get(), mask_layer->id()));
5719 EXPECT_EQ( 5739 EXPECT_EQ(
5720 replica_layer.get(), 5740 replica_layer.get(),
5721 LayerTreeHostCommon::FindLayerInSubtree(root.get(), replica_layer->id())); 5741 LayerTreeHostCommon::FindLayerInSubtree(root.get(), replica_layer->id()));
5722 EXPECT_EQ( 5742 EXPECT_EQ(
5723 0, LayerTreeHostCommon::FindLayerInSubtree(root.get(), nonexistent_id)); 5743 0, LayerTreeHostCommon::FindLayerInSubtree(root.get(), nonexistent_id));
5724 } 5744 }
5725 5745
5726 TEST_F(LayerTreeHostCommonTest, TransparentChildRenderSurfaceCreation) { 5746 TEST_F(LayerTreeHostCommonTest, TransparentChildRenderSurfaceCreation) {
5727 scoped_refptr<Layer> root = Layer::Create(); 5747 scoped_refptr<Layer> root = Layer::Create(layer_settings());
5728 scoped_refptr<Layer> child = Layer::Create(); 5748 scoped_refptr<Layer> child = Layer::Create(layer_settings());
5729 scoped_refptr<LayerWithForcedDrawsContent> grand_child = 5749 scoped_refptr<LayerWithForcedDrawsContent> grand_child =
5730 make_scoped_refptr(new LayerWithForcedDrawsContent()); 5750 make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
5731 5751
5732 const gfx::Transform identity_matrix; 5752 const gfx::Transform identity_matrix;
5733 SetLayerPropertiesForTesting(root.get(), 5753 SetLayerPropertiesForTesting(root.get(),
5734 identity_matrix, 5754 identity_matrix,
5735 gfx::Point3F(), 5755 gfx::Point3F(),
5736 gfx::PointF(), 5756 gfx::PointF(),
5737 gfx::Size(100, 100), 5757 gfx::Size(100, 100),
5738 true, 5758 true,
5739 false); 5759 false);
5740 SetLayerPropertiesForTesting(child.get(), 5760 SetLayerPropertiesForTesting(child.get(),
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
5991 testing::Bool(), 6011 testing::Bool(),
5992 testing::Bool())); 6012 testing::Bool()));
5993 6013
5994 TEST_F(LayerTreeHostCommonTest, SubtreeHidden_SingleLayer) { 6014 TEST_F(LayerTreeHostCommonTest, SubtreeHidden_SingleLayer) {
5995 FakeImplProxy proxy; 6015 FakeImplProxy proxy;
5996 TestSharedBitmapManager shared_bitmap_manager; 6016 TestSharedBitmapManager shared_bitmap_manager;
5997 FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager, nullptr); 6017 FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager, nullptr);
5998 host_impl.CreatePendingTree(); 6018 host_impl.CreatePendingTree();
5999 const gfx::Transform identity_matrix; 6019 const gfx::Transform identity_matrix;
6000 6020
6001 scoped_refptr<Layer> root = Layer::Create(); 6021 scoped_refptr<Layer> root = Layer::Create(layer_settings());
6002 SetLayerPropertiesForTesting(root.get(), 6022 SetLayerPropertiesForTesting(root.get(),
6003 identity_matrix, 6023 identity_matrix,
6004 gfx::Point3F(), 6024 gfx::Point3F(),
6005 gfx::PointF(), 6025 gfx::PointF(),
6006 gfx::Size(50, 50), 6026 gfx::Size(50, 50),
6007 true, 6027 true,
6008 false); 6028 false);
6009 root->SetIsDrawable(true); 6029 root->SetIsDrawable(true);
6010 6030
6011 scoped_refptr<Layer> child = Layer::Create(); 6031 scoped_refptr<Layer> child = Layer::Create(layer_settings());
6012 SetLayerPropertiesForTesting(child.get(), 6032 SetLayerPropertiesForTesting(child.get(),
6013 identity_matrix, 6033 identity_matrix,
6014 gfx::Point3F(), 6034 gfx::Point3F(),
6015 gfx::PointF(), 6035 gfx::PointF(),
6016 gfx::Size(40, 40), 6036 gfx::Size(40, 40),
6017 true, 6037 true,
6018 false); 6038 false);
6019 child->SetIsDrawable(true); 6039 child->SetIsDrawable(true);
6020 6040
6021 scoped_refptr<Layer> grand_child = Layer::Create(); 6041 scoped_refptr<Layer> grand_child = Layer::Create(layer_settings());
6022 SetLayerPropertiesForTesting(grand_child.get(), 6042 SetLayerPropertiesForTesting(grand_child.get(),
6023 identity_matrix, 6043 identity_matrix,
6024 gfx::Point3F(), 6044 gfx::Point3F(),
6025 gfx::PointF(), 6045 gfx::PointF(),
6026 gfx::Size(30, 30), 6046 gfx::Size(30, 30),
6027 true, 6047 true,
6028 false); 6048 false);
6029 grand_child->SetIsDrawable(true); 6049 grand_child->SetIsDrawable(true);
6030 grand_child->SetHideLayerAndSubtree(true); 6050 grand_child->SetHideLayerAndSubtree(true);
6031 6051
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
6094 EXPECT_EQ(2, root->render_surface()->layer_list().at(1)->id()); 6114 EXPECT_EQ(2, root->render_surface()->layer_list().at(1)->id());
6095 } 6115 }
6096 6116
6097 TEST_F(LayerTreeHostCommonTest, SubtreeHidden_TwoLayers) { 6117 TEST_F(LayerTreeHostCommonTest, SubtreeHidden_TwoLayers) {
6098 FakeImplProxy proxy; 6118 FakeImplProxy proxy;
6099 TestSharedBitmapManager shared_bitmap_manager; 6119 TestSharedBitmapManager shared_bitmap_manager;
6100 FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager, nullptr); 6120 FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager, nullptr);
6101 host_impl.CreatePendingTree(); 6121 host_impl.CreatePendingTree();
6102 const gfx::Transform identity_matrix; 6122 const gfx::Transform identity_matrix;
6103 6123
6104 scoped_refptr<Layer> root = Layer::Create(); 6124 scoped_refptr<Layer> root = Layer::Create(layer_settings());
6105 SetLayerPropertiesForTesting(root.get(), 6125 SetLayerPropertiesForTesting(root.get(),
6106 identity_matrix, 6126 identity_matrix,
6107 gfx::Point3F(), 6127 gfx::Point3F(),
6108 gfx::PointF(), 6128 gfx::PointF(),
6109 gfx::Size(50, 50), 6129 gfx::Size(50, 50),
6110 true, 6130 true,
6111 false); 6131 false);
6112 root->SetIsDrawable(true); 6132 root->SetIsDrawable(true);
6113 6133
6114 scoped_refptr<Layer> child = Layer::Create(); 6134 scoped_refptr<Layer> child = Layer::Create(layer_settings());
6115 SetLayerPropertiesForTesting(child.get(), 6135 SetLayerPropertiesForTesting(child.get(),
6116 identity_matrix, 6136 identity_matrix,
6117 gfx::Point3F(), 6137 gfx::Point3F(),
6118 gfx::PointF(), 6138 gfx::PointF(),
6119 gfx::Size(40, 40), 6139 gfx::Size(40, 40),
6120 true, 6140 true,
6121 false); 6141 false);
6122 child->SetIsDrawable(true); 6142 child->SetIsDrawable(true);
6123 child->SetHideLayerAndSubtree(true); 6143 child->SetHideLayerAndSubtree(true);
6124 6144
6125 scoped_refptr<Layer> grand_child = Layer::Create(); 6145 scoped_refptr<Layer> grand_child = Layer::Create(layer_settings());
6126 SetLayerPropertiesForTesting(grand_child.get(), 6146 SetLayerPropertiesForTesting(grand_child.get(),
6127 identity_matrix, 6147 identity_matrix,
6128 gfx::Point3F(), 6148 gfx::Point3F(),
6129 gfx::PointF(), 6149 gfx::PointF(),
6130 gfx::Size(30, 30), 6150 gfx::Size(30, 30),
6131 true, 6151 true,
6132 false); 6152 false);
6133 grand_child->SetIsDrawable(true); 6153 grand_child->SetIsDrawable(true);
6134 6154
6135 child->AddChild(grand_child); 6155 child->AddChild(grand_child);
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
6196 6216
6197 void EmptyCopyOutputCallback(scoped_ptr<CopyOutputResult> result) {} 6217 void EmptyCopyOutputCallback(scoped_ptr<CopyOutputResult> result) {}
6198 6218
6199 TEST_F(LayerTreeHostCommonTest, SubtreeHiddenWithCopyRequest) { 6219 TEST_F(LayerTreeHostCommonTest, SubtreeHiddenWithCopyRequest) {
6200 FakeImplProxy proxy; 6220 FakeImplProxy proxy;
6201 TestSharedBitmapManager shared_bitmap_manager; 6221 TestSharedBitmapManager shared_bitmap_manager;
6202 FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager, nullptr); 6222 FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager, nullptr);
6203 host_impl.CreatePendingTree(); 6223 host_impl.CreatePendingTree();
6204 const gfx::Transform identity_matrix; 6224 const gfx::Transform identity_matrix;
6205 6225
6206 scoped_refptr<Layer> root = Layer::Create(); 6226 scoped_refptr<Layer> root = Layer::Create(layer_settings());
6207 SetLayerPropertiesForTesting(root.get(), 6227 SetLayerPropertiesForTesting(root.get(),
6208 identity_matrix, 6228 identity_matrix,
6209 gfx::Point3F(), 6229 gfx::Point3F(),
6210 gfx::PointF(), 6230 gfx::PointF(),
6211 gfx::Size(50, 50), 6231 gfx::Size(50, 50),
6212 true, 6232 true,
6213 false); 6233 false);
6214 root->SetIsDrawable(true); 6234 root->SetIsDrawable(true);
6215 6235
6216 scoped_refptr<Layer> copy_grand_parent = Layer::Create(); 6236 scoped_refptr<Layer> copy_grand_parent = Layer::Create(layer_settings());
6217 SetLayerPropertiesForTesting(copy_grand_parent.get(), 6237 SetLayerPropertiesForTesting(copy_grand_parent.get(),
6218 identity_matrix, 6238 identity_matrix,
6219 gfx::Point3F(), 6239 gfx::Point3F(),
6220 gfx::PointF(), 6240 gfx::PointF(),
6221 gfx::Size(40, 40), 6241 gfx::Size(40, 40),
6222 true, 6242 true,
6223 false); 6243 false);
6224 copy_grand_parent->SetIsDrawable(true); 6244 copy_grand_parent->SetIsDrawable(true);
6225 6245
6226 scoped_refptr<Layer> copy_parent = Layer::Create(); 6246 scoped_refptr<Layer> copy_parent = Layer::Create(layer_settings());
6227 SetLayerPropertiesForTesting(copy_parent.get(), 6247 SetLayerPropertiesForTesting(copy_parent.get(),
6228 identity_matrix, 6248 identity_matrix,
6229 gfx::Point3F(), 6249 gfx::Point3F(),
6230 gfx::PointF(), 6250 gfx::PointF(),
6231 gfx::Size(30, 30), 6251 gfx::Size(30, 30),
6232 true, 6252 true,
6233 false); 6253 false);
6234 copy_parent->SetIsDrawable(true); 6254 copy_parent->SetIsDrawable(true);
6235 copy_parent->SetForceRenderSurface(true); 6255 copy_parent->SetForceRenderSurface(true);
6236 6256
6237 scoped_refptr<Layer> copy_layer = Layer::Create(); 6257 scoped_refptr<Layer> copy_layer = Layer::Create(layer_settings());
6238 SetLayerPropertiesForTesting(copy_layer.get(), 6258 SetLayerPropertiesForTesting(copy_layer.get(),
6239 identity_matrix, 6259 identity_matrix,
6240 gfx::Point3F(), 6260 gfx::Point3F(),
6241 gfx::PointF(), 6261 gfx::PointF(),
6242 gfx::Size(20, 20), 6262 gfx::Size(20, 20),
6243 true, 6263 true,
6244 false); 6264 false);
6245 copy_layer->SetIsDrawable(true); 6265 copy_layer->SetIsDrawable(true);
6246 6266
6247 scoped_refptr<Layer> copy_child = Layer::Create(); 6267 scoped_refptr<Layer> copy_child = Layer::Create(layer_settings());
6248 SetLayerPropertiesForTesting(copy_child.get(), 6268 SetLayerPropertiesForTesting(copy_child.get(),
6249 identity_matrix, 6269 identity_matrix,
6250 gfx::Point3F(), 6270 gfx::Point3F(),
6251 gfx::PointF(), 6271 gfx::PointF(),
6252 gfx::Size(20, 20), 6272 gfx::Size(20, 20),
6253 true, 6273 true,
6254 false); 6274 false);
6255 copy_child->SetIsDrawable(true); 6275 copy_child->SetIsDrawable(true);
6256 6276
6257 scoped_refptr<Layer> copy_grand_parent_sibling_before = Layer::Create(); 6277 scoped_refptr<Layer> copy_grand_parent_sibling_before =
6278 Layer::Create(layer_settings());
6258 SetLayerPropertiesForTesting(copy_grand_parent_sibling_before.get(), 6279 SetLayerPropertiesForTesting(copy_grand_parent_sibling_before.get(),
6259 identity_matrix, 6280 identity_matrix,
6260 gfx::Point3F(), 6281 gfx::Point3F(),
6261 gfx::PointF(), 6282 gfx::PointF(),
6262 gfx::Size(40, 40), 6283 gfx::Size(40, 40),
6263 true, 6284 true,
6264 false); 6285 false);
6265 copy_grand_parent_sibling_before->SetIsDrawable(true); 6286 copy_grand_parent_sibling_before->SetIsDrawable(true);
6266 6287
6267 scoped_refptr<Layer> copy_grand_parent_sibling_after = Layer::Create(); 6288 scoped_refptr<Layer> copy_grand_parent_sibling_after =
6289 Layer::Create(layer_settings());
6268 SetLayerPropertiesForTesting(copy_grand_parent_sibling_after.get(), 6290 SetLayerPropertiesForTesting(copy_grand_parent_sibling_after.get(),
6269 identity_matrix, 6291 identity_matrix,
6270 gfx::Point3F(), 6292 gfx::Point3F(),
6271 gfx::PointF(), 6293 gfx::PointF(),
6272 gfx::Size(40, 40), 6294 gfx::Size(40, 40),
6273 true, 6295 true,
6274 false); 6296 false);
6275 copy_grand_parent_sibling_after->SetIsDrawable(true); 6297 copy_grand_parent_sibling_after->SetIsDrawable(true);
6276 6298
6277 copy_layer->AddChild(copy_child); 6299 copy_layer->AddChild(copy_child);
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
6343 copy_layer->render_surface()->layer_list().at(1)->id()); 6365 copy_layer->render_surface()->layer_list().at(1)->id());
6344 } 6366 }
6345 6367
6346 TEST_F(LayerTreeHostCommonTest, ClippedOutCopyRequest) { 6368 TEST_F(LayerTreeHostCommonTest, ClippedOutCopyRequest) {
6347 FakeImplProxy proxy; 6369 FakeImplProxy proxy;
6348 TestSharedBitmapManager shared_bitmap_manager; 6370 TestSharedBitmapManager shared_bitmap_manager;
6349 FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager, nullptr); 6371 FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager, nullptr);
6350 host_impl.CreatePendingTree(); 6372 host_impl.CreatePendingTree();
6351 const gfx::Transform identity_matrix; 6373 const gfx::Transform identity_matrix;
6352 6374
6353 scoped_refptr<Layer> root = Layer::Create(); 6375 scoped_refptr<Layer> root = Layer::Create(layer_settings());
6354 SetLayerPropertiesForTesting(root.get(), 6376 SetLayerPropertiesForTesting(root.get(),
6355 identity_matrix, 6377 identity_matrix,
6356 gfx::Point3F(), 6378 gfx::Point3F(),
6357 gfx::PointF(), 6379 gfx::PointF(),
6358 gfx::Size(50, 50), 6380 gfx::Size(50, 50),
6359 true, 6381 true,
6360 false); 6382 false);
6361 root->SetIsDrawable(true); 6383 root->SetIsDrawable(true);
6362 6384
6363 scoped_refptr<Layer> copy_parent = Layer::Create(); 6385 scoped_refptr<Layer> copy_parent = Layer::Create(layer_settings());
6364 SetLayerPropertiesForTesting(copy_parent.get(), 6386 SetLayerPropertiesForTesting(copy_parent.get(),
6365 identity_matrix, 6387 identity_matrix,
6366 gfx::Point3F(), 6388 gfx::Point3F(),
6367 gfx::PointF(), 6389 gfx::PointF(),
6368 gfx::Size(), 6390 gfx::Size(),
6369 true, 6391 true,
6370 false); 6392 false);
6371 copy_parent->SetIsDrawable(true); 6393 copy_parent->SetIsDrawable(true);
6372 copy_parent->SetMasksToBounds(true); 6394 copy_parent->SetMasksToBounds(true);
6373 6395
6374 scoped_refptr<Layer> copy_layer = Layer::Create(); 6396 scoped_refptr<Layer> copy_layer = Layer::Create(layer_settings());
6375 SetLayerPropertiesForTesting(copy_layer.get(), 6397 SetLayerPropertiesForTesting(copy_layer.get(),
6376 identity_matrix, 6398 identity_matrix,
6377 gfx::Point3F(), 6399 gfx::Point3F(),
6378 gfx::PointF(), 6400 gfx::PointF(),
6379 gfx::Size(30, 30), 6401 gfx::Size(30, 30),
6380 true, 6402 true,
6381 false); 6403 false);
6382 copy_layer->SetIsDrawable(true); 6404 copy_layer->SetIsDrawable(true);
6383 6405
6384 scoped_refptr<Layer> copy_child = Layer::Create(); 6406 scoped_refptr<Layer> copy_child = Layer::Create(layer_settings());
6385 SetLayerPropertiesForTesting(copy_child.get(), 6407 SetLayerPropertiesForTesting(copy_child.get(),
6386 identity_matrix, 6408 identity_matrix,
6387 gfx::Point3F(), 6409 gfx::Point3F(),
6388 gfx::PointF(), 6410 gfx::PointF(),
6389 gfx::Size(20, 20), 6411 gfx::Size(20, 20),
6390 true, 6412 true,
6391 false); 6413 false);
6392 copy_child->SetIsDrawable(true); 6414 copy_child->SetIsDrawable(true);
6393 6415
6394 copy_layer->AddChild(copy_child); 6416 copy_layer->AddChild(copy_child);
(...skipping 23 matching lines...) Expand all
6418 EXPECT_EQ(root->id(), root->render_surface()->layer_list().at(0)->id()); 6440 EXPECT_EQ(root->id(), root->render_surface()->layer_list().at(0)->id());
6419 } 6441 }
6420 6442
6421 TEST_F(LayerTreeHostCommonTest, VisibleContentRectInsideSurface) { 6443 TEST_F(LayerTreeHostCommonTest, VisibleContentRectInsideSurface) {
6422 FakeImplProxy proxy; 6444 FakeImplProxy proxy;
6423 TestSharedBitmapManager shared_bitmap_manager; 6445 TestSharedBitmapManager shared_bitmap_manager;
6424 FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager, nullptr); 6446 FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager, nullptr);
6425 host_impl.CreatePendingTree(); 6447 host_impl.CreatePendingTree();
6426 const gfx::Transform identity_matrix; 6448 const gfx::Transform identity_matrix;
6427 6449
6428 scoped_refptr<Layer> root = Layer::Create(); 6450 scoped_refptr<Layer> root = Layer::Create(layer_settings());
6429 SetLayerPropertiesForTesting(root.get(), 6451 SetLayerPropertiesForTesting(root.get(),
6430 identity_matrix, 6452 identity_matrix,
6431 gfx::Point3F(), 6453 gfx::Point3F(),
6432 gfx::PointF(), 6454 gfx::PointF(),
6433 gfx::Size(50, 50), 6455 gfx::Size(50, 50),
6434 true, 6456 true,
6435 false); 6457 false);
6436 root->SetIsDrawable(true); 6458 root->SetIsDrawable(true);
6437 6459
6438 // The surface is moved slightly outside of the viewport. 6460 // The surface is moved slightly outside of the viewport.
6439 scoped_refptr<Layer> surface = Layer::Create(); 6461 scoped_refptr<Layer> surface = Layer::Create(layer_settings());
6440 SetLayerPropertiesForTesting(surface.get(), 6462 SetLayerPropertiesForTesting(surface.get(),
6441 identity_matrix, 6463 identity_matrix,
6442 gfx::Point3F(), 6464 gfx::Point3F(),
6443 gfx::PointF(-10, -20), 6465 gfx::PointF(-10, -20),
6444 gfx::Size(), 6466 gfx::Size(),
6445 true, 6467 true,
6446 false); 6468 false);
6447 surface->SetForceRenderSurface(true); 6469 surface->SetForceRenderSurface(true);
6448 6470
6449 scoped_refptr<Layer> surface_child = Layer::Create(); 6471 scoped_refptr<Layer> surface_child = Layer::Create(layer_settings());
6450 SetLayerPropertiesForTesting(surface_child.get(), 6472 SetLayerPropertiesForTesting(surface_child.get(),
6451 identity_matrix, 6473 identity_matrix,
6452 gfx::Point3F(), 6474 gfx::Point3F(),
6453 gfx::PointF(), 6475 gfx::PointF(),
6454 gfx::Size(50, 50), 6476 gfx::Size(50, 50),
6455 true, 6477 true,
6456 false); 6478 false);
6457 surface_child->SetIsDrawable(true); 6479 surface_child->SetIsDrawable(true);
6458 6480
6459 surface->AddChild(surface_child); 6481 surface->AddChild(surface_child);
(...skipping 19 matching lines...) Expand all
6479 // problem. Constructs the following layer tree. 6501 // problem. Constructs the following layer tree.
6480 // 6502 //
6481 // root (a render surface) 6503 // root (a render surface)
6482 // + render_surface 6504 // + render_surface
6483 // + clip_parent (scaled) 6505 // + clip_parent (scaled)
6484 // + intervening_clipping_layer 6506 // + intervening_clipping_layer
6485 // + clip_child 6507 // + clip_child
6486 // 6508 //
6487 // The render surface should be resized correctly and the clip child should 6509 // The render surface should be resized correctly and the clip child should
6488 // inherit the right clip rect. 6510 // inherit the right clip rect.
6489 scoped_refptr<Layer> root = Layer::Create(); 6511 scoped_refptr<Layer> root = Layer::Create(layer_settings());
6490 scoped_refptr<Layer> render_surface = Layer::Create(); 6512 scoped_refptr<Layer> render_surface = Layer::Create(layer_settings());
6491 scoped_refptr<Layer> clip_parent = Layer::Create(); 6513 scoped_refptr<Layer> clip_parent = Layer::Create(layer_settings());
6492 scoped_refptr<Layer> intervening = Layer::Create(); 6514 scoped_refptr<Layer> intervening = Layer::Create(layer_settings());
6493 scoped_refptr<LayerWithForcedDrawsContent> clip_child = 6515 scoped_refptr<LayerWithForcedDrawsContent> clip_child =
6494 make_scoped_refptr(new LayerWithForcedDrawsContent); 6516 make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
6495 6517
6496 root->AddChild(render_surface); 6518 root->AddChild(render_surface);
6497 render_surface->AddChild(clip_parent); 6519 render_surface->AddChild(clip_parent);
6498 clip_parent->AddChild(intervening); 6520 clip_parent->AddChild(intervening);
6499 intervening->AddChild(clip_child); 6521 intervening->AddChild(clip_child);
6500 6522
6501 clip_child->SetClipParent(clip_parent.get()); 6523 clip_child->SetClipParent(clip_parent.get());
6502 6524
6503 intervening->SetMasksToBounds(true); 6525 intervening->SetMasksToBounds(true);
6504 clip_parent->SetMasksToBounds(true); 6526 clip_parent->SetMasksToBounds(true);
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
6581 // case. In the following tree, both render surfaces should be resized to 6603 // case. In the following tree, both render surfaces should be resized to
6582 // accomodate for the clip child, despite an intervening clip. 6604 // accomodate for the clip child, despite an intervening clip.
6583 // 6605 //
6584 // root (a render surface) 6606 // root (a render surface)
6585 // + clip_parent (masks to bounds) 6607 // + clip_parent (masks to bounds)
6586 // + render_surface1 (sets opacity) 6608 // + render_surface1 (sets opacity)
6587 // + intervening (masks to bounds) 6609 // + intervening (masks to bounds)
6588 // + render_surface2 (also sets opacity) 6610 // + render_surface2 (also sets opacity)
6589 // + clip_child 6611 // + clip_child
6590 // 6612 //
6591 scoped_refptr<Layer> root = Layer::Create(); 6613 scoped_refptr<Layer> root = Layer::Create(layer_settings());
6592 scoped_refptr<Layer> clip_parent = Layer::Create(); 6614 scoped_refptr<Layer> clip_parent = Layer::Create(layer_settings());
6593 scoped_refptr<Layer> render_surface1 = Layer::Create(); 6615 scoped_refptr<Layer> render_surface1 = Layer::Create(layer_settings());
6594 scoped_refptr<Layer> intervening = Layer::Create(); 6616 scoped_refptr<Layer> intervening = Layer::Create(layer_settings());
6595 scoped_refptr<Layer> render_surface2 = Layer::Create(); 6617 scoped_refptr<Layer> render_surface2 = Layer::Create(layer_settings());
6596 scoped_refptr<LayerWithForcedDrawsContent> clip_child = 6618 scoped_refptr<LayerWithForcedDrawsContent> clip_child =
6597 make_scoped_refptr(new LayerWithForcedDrawsContent); 6619 make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
6598 6620
6599 root->AddChild(clip_parent); 6621 root->AddChild(clip_parent);
6600 clip_parent->AddChild(render_surface1); 6622 clip_parent->AddChild(render_surface1);
6601 render_surface1->AddChild(intervening); 6623 render_surface1->AddChild(intervening);
6602 intervening->AddChild(render_surface2); 6624 intervening->AddChild(render_surface2);
6603 render_surface2->AddChild(clip_child); 6625 render_surface2->AddChild(clip_child);
6604 6626
6605 clip_child->SetClipParent(clip_parent.get()); 6627 clip_child->SetClipParent(clip_parent.get());
6606 6628
6607 intervening->SetMasksToBounds(true); 6629 intervening->SetMasksToBounds(true);
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
6708 // is a scroll involved. Note, we do _not_ have to consider any other sort 6730 // is a scroll involved. Note, we do _not_ have to consider any other sort
6709 // of transform. 6731 // of transform.
6710 // 6732 //
6711 // root (a render surface) 6733 // root (a render surface)
6712 // + clip_parent (masks to bounds) 6734 // + clip_parent (masks to bounds)
6713 // + render_surface1 (sets opacity) 6735 // + render_surface1 (sets opacity)
6714 // + intervening (masks to bounds AND scrolls) 6736 // + intervening (masks to bounds AND scrolls)
6715 // + render_surface2 (also sets opacity) 6737 // + render_surface2 (also sets opacity)
6716 // + clip_child 6738 // + clip_child
6717 // 6739 //
6718 scoped_refptr<Layer> root = Layer::Create(); 6740 scoped_refptr<Layer> root = Layer::Create(layer_settings());
6719 scoped_refptr<Layer> clip_parent = Layer::Create(); 6741 scoped_refptr<Layer> clip_parent = Layer::Create(layer_settings());
6720 scoped_refptr<Layer> render_surface1 = Layer::Create(); 6742 scoped_refptr<Layer> render_surface1 = Layer::Create(layer_settings());
6721 scoped_refptr<Layer> intervening = Layer::Create(); 6743 scoped_refptr<Layer> intervening = Layer::Create(layer_settings());
6722 scoped_refptr<Layer> render_surface2 = Layer::Create(); 6744 scoped_refptr<Layer> render_surface2 = Layer::Create(layer_settings());
6723 scoped_refptr<LayerWithForcedDrawsContent> clip_child = 6745 scoped_refptr<LayerWithForcedDrawsContent> clip_child =
6724 make_scoped_refptr(new LayerWithForcedDrawsContent); 6746 make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
6725 6747
6726 root->AddChild(clip_parent); 6748 root->AddChild(clip_parent);
6727 clip_parent->AddChild(render_surface1); 6749 clip_parent->AddChild(render_surface1);
6728 render_surface1->AddChild(intervening); 6750 render_surface1->AddChild(intervening);
6729 intervening->AddChild(render_surface2); 6751 intervening->AddChild(render_surface2);
6730 render_surface2->AddChild(clip_child); 6752 render_surface2->AddChild(clip_child);
6731 6753
6732 clip_child->SetClipParent(clip_parent.get()); 6754 clip_child->SetClipParent(clip_parent.get());
6733 6755
6734 intervening->SetMasksToBounds(true); 6756 intervening->SetMasksToBounds(true);
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
6834 6856
6835 TEST_F(LayerTreeHostCommonTest, DescendantsOfClipChildren) { 6857 TEST_F(LayerTreeHostCommonTest, DescendantsOfClipChildren) {
6836 // Ensures that descendants of the clip child inherit the correct clip. 6858 // Ensures that descendants of the clip child inherit the correct clip.
6837 // 6859 //
6838 // root (a render surface) 6860 // root (a render surface)
6839 // + clip_parent (masks to bounds) 6861 // + clip_parent (masks to bounds)
6840 // + intervening (masks to bounds) 6862 // + intervening (masks to bounds)
6841 // + clip_child 6863 // + clip_child
6842 // + child 6864 // + child
6843 // 6865 //
6844 scoped_refptr<Layer> root = Layer::Create(); 6866 scoped_refptr<Layer> root = Layer::Create(layer_settings());
6845 scoped_refptr<Layer> clip_parent = Layer::Create(); 6867 scoped_refptr<Layer> clip_parent = Layer::Create(layer_settings());
6846 scoped_refptr<Layer> intervening = Layer::Create(); 6868 scoped_refptr<Layer> intervening = Layer::Create(layer_settings());
6847 scoped_refptr<Layer> clip_child = Layer::Create(); 6869 scoped_refptr<Layer> clip_child = Layer::Create(layer_settings());
6848 scoped_refptr<LayerWithForcedDrawsContent> child = 6870 scoped_refptr<LayerWithForcedDrawsContent> child =
6849 make_scoped_refptr(new LayerWithForcedDrawsContent); 6871 make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
6850 6872
6851 root->AddChild(clip_parent); 6873 root->AddChild(clip_parent);
6852 clip_parent->AddChild(intervening); 6874 clip_parent->AddChild(intervening);
6853 intervening->AddChild(clip_child); 6875 intervening->AddChild(clip_child);
6854 clip_child->AddChild(child); 6876 clip_child->AddChild(child);
6855 6877
6856 clip_child->SetClipParent(clip_parent.get()); 6878 clip_child->SetClipParent(clip_parent.get());
6857 6879
6858 intervening->SetMasksToBounds(true); 6880 intervening->SetMasksToBounds(true);
6859 clip_parent->SetMasksToBounds(true); 6881 clip_parent->SetMasksToBounds(true);
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
6918 // render surfaces. 6940 // render surfaces.
6919 // 6941 //
6920 // root (a render surface) 6942 // root (a render surface)
6921 // + clip_parent (masks to bounds) 6943 // + clip_parent (masks to bounds)
6922 // + render_surface1 6944 // + render_surface1
6923 // + clip_child 6945 // + clip_child
6924 // + render_surface2 6946 // + render_surface2
6925 // + non_clip_child 6947 // + non_clip_child
6926 // 6948 //
6927 // In this example render_surface2 should be unaffected by clip_child. 6949 // In this example render_surface2 should be unaffected by clip_child.
6928 scoped_refptr<Layer> root = Layer::Create(); 6950 scoped_refptr<Layer> root = Layer::Create(layer_settings());
6929 scoped_refptr<Layer> clip_parent = Layer::Create(); 6951 scoped_refptr<Layer> clip_parent = Layer::Create(layer_settings());
6930 scoped_refptr<Layer> render_surface1 = Layer::Create(); 6952 scoped_refptr<Layer> render_surface1 = Layer::Create(layer_settings());
6931 scoped_refptr<LayerWithForcedDrawsContent> clip_child = 6953 scoped_refptr<LayerWithForcedDrawsContent> clip_child =
6932 make_scoped_refptr(new LayerWithForcedDrawsContent); 6954 make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
6933 scoped_refptr<Layer> render_surface2 = Layer::Create(); 6955 scoped_refptr<Layer> render_surface2 = Layer::Create(layer_settings());
6934 scoped_refptr<LayerWithForcedDrawsContent> non_clip_child = 6956 scoped_refptr<LayerWithForcedDrawsContent> non_clip_child =
6935 make_scoped_refptr(new LayerWithForcedDrawsContent); 6957 make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
6936 6958
6937 root->AddChild(clip_parent); 6959 root->AddChild(clip_parent);
6938 clip_parent->AddChild(render_surface1); 6960 clip_parent->AddChild(render_surface1);
6939 render_surface1->AddChild(clip_child); 6961 render_surface1->AddChild(clip_child);
6940 clip_parent->AddChild(render_surface2); 6962 clip_parent->AddChild(render_surface2);
6941 render_surface2->AddChild(non_clip_child); 6963 render_surface2->AddChild(non_clip_child);
6942 6964
6943 clip_child->SetClipParent(clip_parent.get()); 6965 clip_child->SetClipParent(clip_parent.get());
6944 6966
6945 clip_parent->SetMasksToBounds(true); 6967 clip_parent->SetMasksToBounds(true);
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
7127 // Only root layer has a render surface. 7149 // Only root layer has a render surface.
7128 EXPECT_EQ(1, count_represents_target_render_surface); 7150 EXPECT_EQ(1, count_represents_target_render_surface);
7129 // No layer contributes a render surface to root render surface. 7151 // No layer contributes a render surface to root render surface.
7130 EXPECT_EQ(0, count_represents_contributing_render_surface); 7152 EXPECT_EQ(0, count_represents_contributing_render_surface);
7131 // All 4 layers represent itself. 7153 // All 4 layers represent itself.
7132 EXPECT_EQ(4, count_represents_itself); 7154 EXPECT_EQ(4, count_represents_itself);
7133 } 7155 }
7134 } 7156 }
7135 7157
7136 TEST_F(LayerTreeHostCommonTest, DoNotIncludeBackfaceInvisibleSurfaces) { 7158 TEST_F(LayerTreeHostCommonTest, DoNotIncludeBackfaceInvisibleSurfaces) {
7137 scoped_refptr<Layer> root = Layer::Create(); 7159 scoped_refptr<Layer> root = Layer::Create(layer_settings());
7138 scoped_refptr<Layer> render_surface = Layer::Create(); 7160 scoped_refptr<Layer> render_surface = Layer::Create(layer_settings());
7139 scoped_refptr<LayerWithForcedDrawsContent> child = 7161 scoped_refptr<LayerWithForcedDrawsContent> child =
7140 make_scoped_refptr(new LayerWithForcedDrawsContent); 7162 make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
7141 7163
7142 root->AddChild(render_surface); 7164 root->AddChild(render_surface);
7143 render_surface->AddChild(child); 7165 render_surface->AddChild(child);
7144 7166
7145 gfx::Transform identity_transform; 7167 gfx::Transform identity_transform;
7146 SetLayerPropertiesForTesting(root.get(), 7168 SetLayerPropertiesForTesting(root.get(),
7147 identity_transform, 7169 identity_transform,
7148 gfx::Point3F(), 7170 gfx::Point3F(),
7149 gfx::PointF(), 7171 gfx::PointF(),
7150 gfx::Size(50, 50), 7172 gfx::Size(50, 50),
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
7199 TEST_F(LayerTreeHostCommonTest, ClippedByScrollParent) { 7221 TEST_F(LayerTreeHostCommonTest, ClippedByScrollParent) {
7200 // Checks that the simple case (being clipped by a scroll parent that would 7222 // Checks that the simple case (being clipped by a scroll parent that would
7201 // have been processed before you anyhow) results in the right clips. 7223 // have been processed before you anyhow) results in the right clips.
7202 // 7224 //
7203 // + root 7225 // + root
7204 // + scroll_parent_border 7226 // + scroll_parent_border
7205 // | + scroll_parent_clip 7227 // | + scroll_parent_clip
7206 // | + scroll_parent 7228 // | + scroll_parent
7207 // + scroll_child 7229 // + scroll_child
7208 // 7230 //
7209 scoped_refptr<Layer> root = Layer::Create(); 7231 scoped_refptr<Layer> root = Layer::Create(layer_settings());
7210 scoped_refptr<Layer> scroll_parent_border = Layer::Create(); 7232 scoped_refptr<Layer> scroll_parent_border = Layer::Create(layer_settings());
7211 scoped_refptr<Layer> scroll_parent_clip = Layer::Create(); 7233 scoped_refptr<Layer> scroll_parent_clip = Layer::Create(layer_settings());
7212 scoped_refptr<LayerWithForcedDrawsContent> scroll_parent = 7234 scoped_refptr<LayerWithForcedDrawsContent> scroll_parent =
7213 make_scoped_refptr(new LayerWithForcedDrawsContent); 7235 make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
7214 scoped_refptr<LayerWithForcedDrawsContent> scroll_child = 7236 scoped_refptr<LayerWithForcedDrawsContent> scroll_child =
7215 make_scoped_refptr(new LayerWithForcedDrawsContent); 7237 make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
7216 7238
7217 root->AddChild(scroll_child); 7239 root->AddChild(scroll_child);
7218 7240
7219 root->AddChild(scroll_parent_border); 7241 root->AddChild(scroll_parent_border);
7220 scroll_parent_border->AddChild(scroll_parent_clip); 7242 scroll_parent_border->AddChild(scroll_parent_clip);
7221 scroll_parent_clip->AddChild(scroll_parent); 7243 scroll_parent_clip->AddChild(scroll_parent);
7222 7244
7223 scroll_parent_clip->SetMasksToBounds(true); 7245 scroll_parent_clip->SetMasksToBounds(true);
7224 7246
7225 scroll_child->SetScrollParent(scroll_parent.get()); 7247 scroll_child->SetScrollParent(scroll_parent.get());
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
7268 7290
7269 EXPECT_TRUE(root->render_surface()); 7291 EXPECT_TRUE(root->render_surface());
7270 7292
7271 EXPECT_EQ(gfx::Rect(0, 0, 30, 30).ToString(), 7293 EXPECT_EQ(gfx::Rect(0, 0, 30, 30).ToString(),
7272 scroll_child->clip_rect().ToString()); 7294 scroll_child->clip_rect().ToString());
7273 EXPECT_TRUE(scroll_child->is_clipped()); 7295 EXPECT_TRUE(scroll_child->is_clipped());
7274 } 7296 }
7275 7297
7276 TEST_F(LayerTreeHostCommonTest, SingularTransformSubtreesDoNotDraw) { 7298 TEST_F(LayerTreeHostCommonTest, SingularTransformSubtreesDoNotDraw) {
7277 scoped_refptr<LayerWithForcedDrawsContent> root = 7299 scoped_refptr<LayerWithForcedDrawsContent> root =
7278 make_scoped_refptr(new LayerWithForcedDrawsContent); 7300 make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
7279 scoped_refptr<LayerWithForcedDrawsContent> parent = 7301 scoped_refptr<LayerWithForcedDrawsContent> parent =
7280 make_scoped_refptr(new LayerWithForcedDrawsContent); 7302 make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
7281 scoped_refptr<LayerWithForcedDrawsContent> child = 7303 scoped_refptr<LayerWithForcedDrawsContent> child =
7282 make_scoped_refptr(new LayerWithForcedDrawsContent); 7304 make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
7283 7305
7284 root->AddChild(parent); 7306 root->AddChild(parent);
7285 parent->AddChild(child); 7307 parent->AddChild(child);
7286 7308
7287 gfx::Transform identity_transform; 7309 gfx::Transform identity_transform;
7288 SetLayerPropertiesForTesting(root.get(), 7310 SetLayerPropertiesForTesting(root.get(),
7289 identity_transform, 7311 identity_transform,
7290 gfx::Point3F(), 7312 gfx::Point3F(),
7291 gfx::PointF(), 7313 gfx::PointF(),
7292 gfx::Size(50, 50), 7314 gfx::Size(50, 50),
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
7340 TEST_F(LayerTreeHostCommonTest, ClippedByOutOfOrderScrollParent) { 7362 TEST_F(LayerTreeHostCommonTest, ClippedByOutOfOrderScrollParent) {
7341 // Checks that clipping by a scroll parent that follows you in paint order 7363 // Checks that clipping by a scroll parent that follows you in paint order
7342 // still results in correct clipping. 7364 // still results in correct clipping.
7343 // 7365 //
7344 // + root 7366 // + root
7345 // + scroll_child 7367 // + scroll_child
7346 // + scroll_parent_border 7368 // + scroll_parent_border
7347 // + scroll_parent_clip 7369 // + scroll_parent_clip
7348 // + scroll_parent 7370 // + scroll_parent
7349 // 7371 //
7350 scoped_refptr<Layer> root = Layer::Create(); 7372 scoped_refptr<Layer> root = Layer::Create(layer_settings());
7351 scoped_refptr<Layer> scroll_parent_border = Layer::Create(); 7373 scoped_refptr<Layer> scroll_parent_border = Layer::Create(layer_settings());
7352 scoped_refptr<Layer> scroll_parent_clip = Layer::Create(); 7374 scoped_refptr<Layer> scroll_parent_clip = Layer::Create(layer_settings());
7353 scoped_refptr<LayerWithForcedDrawsContent> scroll_parent = 7375 scoped_refptr<LayerWithForcedDrawsContent> scroll_parent =
7354 make_scoped_refptr(new LayerWithForcedDrawsContent); 7376 make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
7355 scoped_refptr<LayerWithForcedDrawsContent> scroll_child = 7377 scoped_refptr<LayerWithForcedDrawsContent> scroll_child =
7356 make_scoped_refptr(new LayerWithForcedDrawsContent); 7378 make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
7357 7379
7358 root->AddChild(scroll_parent_border); 7380 root->AddChild(scroll_parent_border);
7359 scroll_parent_border->AddChild(scroll_parent_clip); 7381 scroll_parent_border->AddChild(scroll_parent_clip);
7360 scroll_parent_clip->AddChild(scroll_parent); 7382 scroll_parent_clip->AddChild(scroll_parent);
7361 7383
7362 root->AddChild(scroll_child); 7384 root->AddChild(scroll_child);
7363 7385
7364 scroll_parent_clip->SetMasksToBounds(true); 7386 scroll_parent_clip->SetMasksToBounds(true);
7365 7387
7366 scroll_child->SetScrollParent(scroll_parent.get()); 7388 scroll_child->SetScrollParent(scroll_parent.get());
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
7420 // 7442 //
7421 // + root 7443 // + root
7422 // + scroll_child 7444 // + scroll_child
7423 // + scroll_parent_border 7445 // + scroll_parent_border
7424 // | + scroll_parent_clip 7446 // | + scroll_parent_clip
7425 // | + scroll_parent 7447 // | + scroll_parent
7426 // + scroll_grandparent_border 7448 // + scroll_grandparent_border
7427 // + scroll_grandparent_clip 7449 // + scroll_grandparent_clip
7428 // + scroll_grandparent 7450 // + scroll_grandparent
7429 // 7451 //
7430 scoped_refptr<Layer> root = Layer::Create(); 7452 scoped_refptr<Layer> root = Layer::Create(layer_settings());
7431 scoped_refptr<Layer> scroll_parent_border = Layer::Create(); 7453 scoped_refptr<Layer> scroll_parent_border = Layer::Create(layer_settings());
7432 scoped_refptr<Layer> scroll_parent_clip = Layer::Create(); 7454 scoped_refptr<Layer> scroll_parent_clip = Layer::Create(layer_settings());
7433 scoped_refptr<LayerWithForcedDrawsContent> scroll_parent = 7455 scoped_refptr<LayerWithForcedDrawsContent> scroll_parent =
7434 make_scoped_refptr(new LayerWithForcedDrawsContent); 7456 make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
7435 7457
7436 scoped_refptr<Layer> scroll_grandparent_border = Layer::Create(); 7458 scoped_refptr<Layer> scroll_grandparent_border =
7437 scoped_refptr<Layer> scroll_grandparent_clip = Layer::Create(); 7459 Layer::Create(layer_settings());
7460 scoped_refptr<Layer> scroll_grandparent_clip =
7461 Layer::Create(layer_settings());
7438 scoped_refptr<LayerWithForcedDrawsContent> scroll_grandparent = 7462 scoped_refptr<LayerWithForcedDrawsContent> scroll_grandparent =
7439 make_scoped_refptr(new LayerWithForcedDrawsContent); 7463 make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
7440 7464
7441 scoped_refptr<LayerWithForcedDrawsContent> scroll_child = 7465 scoped_refptr<LayerWithForcedDrawsContent> scroll_child =
7442 make_scoped_refptr(new LayerWithForcedDrawsContent); 7466 make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
7443 7467
7444 root->AddChild(scroll_child); 7468 root->AddChild(scroll_child);
7445 7469
7446 root->AddChild(scroll_parent_border); 7470 root->AddChild(scroll_parent_border);
7447 scroll_parent_border->AddChild(scroll_parent_clip); 7471 scroll_parent_border->AddChild(scroll_parent_clip);
7448 scroll_parent_clip->AddChild(scroll_parent); 7472 scroll_parent_clip->AddChild(scroll_parent);
7449 7473
7450 root->AddChild(scroll_grandparent_border); 7474 root->AddChild(scroll_grandparent_border);
7451 scroll_grandparent_border->AddChild(scroll_grandparent_clip); 7475 scroll_grandparent_border->AddChild(scroll_grandparent_clip);
7452 scroll_grandparent_clip->AddChild(scroll_grandparent); 7476 scroll_grandparent_clip->AddChild(scroll_grandparent);
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
7545 // + scroll_parent_border 7569 // + scroll_parent_border
7546 // + scroll_parent_clip 7570 // + scroll_parent_clip
7547 // + scroll_parent 7571 // + scroll_parent
7548 // + render_surface1 7572 // + render_surface1
7549 // + scroll_grandparent_border 7573 // + scroll_grandparent_border
7550 // + scroll_grandparent_clip 7574 // + scroll_grandparent_clip
7551 // + scroll_grandparent 7575 // + scroll_grandparent
7552 // + render_surface2 7576 // + render_surface2
7553 // 7577 //
7554 scoped_refptr<LayerWithForcedDrawsContent> root = 7578 scoped_refptr<LayerWithForcedDrawsContent> root =
7555 make_scoped_refptr(new LayerWithForcedDrawsContent); 7579 make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
7556 7580
7557 scoped_refptr<Layer> scroll_parent_border = Layer::Create(); 7581 scoped_refptr<Layer> scroll_parent_border = Layer::Create(layer_settings());
7558 scoped_refptr<Layer> scroll_parent_clip = Layer::Create(); 7582 scoped_refptr<Layer> scroll_parent_clip = Layer::Create(layer_settings());
7559 scoped_refptr<LayerWithForcedDrawsContent> scroll_parent = 7583 scoped_refptr<LayerWithForcedDrawsContent> scroll_parent =
7560 make_scoped_refptr(new LayerWithForcedDrawsContent); 7584 make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
7561 scoped_refptr<LayerWithForcedDrawsContent> render_surface1 = 7585 scoped_refptr<LayerWithForcedDrawsContent> render_surface1 =
7562 make_scoped_refptr(new LayerWithForcedDrawsContent); 7586 make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
7563 7587
7564 scoped_refptr<Layer> scroll_grandparent_border = Layer::Create(); 7588 scoped_refptr<Layer> scroll_grandparent_border =
7565 scoped_refptr<Layer> scroll_grandparent_clip = Layer::Create(); 7589 Layer::Create(layer_settings());
7590 scoped_refptr<Layer> scroll_grandparent_clip =
7591 Layer::Create(layer_settings());
7566 scoped_refptr<LayerWithForcedDrawsContent> scroll_grandparent = 7592 scoped_refptr<LayerWithForcedDrawsContent> scroll_grandparent =
7567 make_scoped_refptr(new LayerWithForcedDrawsContent); 7593 make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
7568 scoped_refptr<LayerWithForcedDrawsContent> render_surface2 = 7594 scoped_refptr<LayerWithForcedDrawsContent> render_surface2 =
7569 make_scoped_refptr(new LayerWithForcedDrawsContent); 7595 make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
7570 7596
7571 scoped_refptr<LayerWithForcedDrawsContent> scroll_child = 7597 scoped_refptr<LayerWithForcedDrawsContent> scroll_child =
7572 make_scoped_refptr(new LayerWithForcedDrawsContent); 7598 make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
7573 7599
7574 root->AddChild(scroll_child); 7600 root->AddChild(scroll_child);
7575 7601
7576 root->AddChild(scroll_parent_border); 7602 root->AddChild(scroll_parent_border);
7577 scroll_parent_border->AddChild(scroll_parent_clip); 7603 scroll_parent_border->AddChild(scroll_parent_clip);
7578 scroll_parent_clip->AddChild(scroll_parent); 7604 scroll_parent_clip->AddChild(scroll_parent);
7579 scroll_parent->AddChild(render_surface2); 7605 scroll_parent->AddChild(render_surface2);
7580 7606
7581 root->AddChild(scroll_grandparent_border); 7607 root->AddChild(scroll_grandparent_border);
7582 scroll_grandparent_border->AddChild(scroll_grandparent_clip); 7608 scroll_grandparent_border->AddChild(scroll_grandparent_clip);
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
7696 TEST_F(LayerTreeHostCommonTest, FixedPositionWithInterveningRenderSurface) { 7722 TEST_F(LayerTreeHostCommonTest, FixedPositionWithInterveningRenderSurface) {
7697 // Ensures that when we have a render surface between a fixed position layer 7723 // Ensures that when we have a render surface between a fixed position layer
7698 // and its container, we compute the fixed position layer's draw transform 7724 // and its container, we compute the fixed position layer's draw transform
7699 // with respect to that intervening render surface, not with respect to its 7725 // with respect to that intervening render surface, not with respect to its
7700 // container's render target. 7726 // container's render target.
7701 // 7727 //
7702 // + root 7728 // + root
7703 // + render_surface 7729 // + render_surface
7704 // + fixed 7730 // + fixed
7705 // 7731 //
7706 scoped_refptr<Layer> root = Layer::Create(); 7732 scoped_refptr<Layer> root = Layer::Create(layer_settings());
7707 scoped_refptr<LayerWithForcedDrawsContent> render_surface = 7733 scoped_refptr<LayerWithForcedDrawsContent> render_surface =
7708 make_scoped_refptr(new LayerWithForcedDrawsContent()); 7734 make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
7709 scoped_refptr<LayerWithForcedDrawsContent> fixed = 7735 scoped_refptr<LayerWithForcedDrawsContent> fixed =
7710 make_scoped_refptr(new LayerWithForcedDrawsContent()); 7736 make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
7711 7737
7712 root->AddChild(render_surface); 7738 root->AddChild(render_surface);
7713 render_surface->AddChild(fixed); 7739 render_surface->AddChild(fixed);
7714 7740
7715 root->SetIsContainerForFixedPositionLayers(true); 7741 root->SetIsContainerForFixedPositionLayers(true);
7716 render_surface->SetForceRenderSurface(true); 7742 render_surface->SetForceRenderSurface(true);
7717 7743
7718 LayerPositionConstraint constraint; 7744 LayerPositionConstraint constraint;
7719 constraint.set_is_fixed_position(true); 7745 constraint.set_is_fixed_position(true);
7720 fixed->SetPositionConstraint(constraint); 7746 fixed->SetPositionConstraint(constraint);
(...skipping 944 matching lines...) Expand 10 before | Expand all | Expand 10 after
8665 4.f, child1_layer->mask_layer()->draw_properties().device_scale_factor); 8691 4.f, child1_layer->mask_layer()->draw_properties().device_scale_factor);
8666 EXPECT_FLOAT_EQ(4.f, 8692 EXPECT_FLOAT_EQ(4.f,
8667 child1_layer->replica_layer() 8693 child1_layer->replica_layer()
8668 ->mask_layer() 8694 ->mask_layer()
8669 ->draw_properties() 8695 ->draw_properties()
8670 .device_scale_factor); 8696 .device_scale_factor);
8671 EXPECT_FLOAT_EQ(4.f, child2_layer->draw_properties().device_scale_factor); 8697 EXPECT_FLOAT_EQ(4.f, child2_layer->draw_properties().device_scale_factor);
8672 } 8698 }
8673 8699
8674 TEST_F(LayerTreeHostCommonTest, VisibleContentRectInChildRenderSurface) { 8700 TEST_F(LayerTreeHostCommonTest, VisibleContentRectInChildRenderSurface) {
8675 scoped_refptr<Layer> root = Layer::Create(); 8701 scoped_refptr<Layer> root = Layer::Create(layer_settings());
8676 SetLayerPropertiesForTesting(root.get(), 8702 SetLayerPropertiesForTesting(root.get(),
8677 gfx::Transform(), 8703 gfx::Transform(),
8678 gfx::Point3F(), 8704 gfx::Point3F(),
8679 gfx::PointF(), 8705 gfx::PointF(),
8680 gfx::Size(768 / 2, 3000), 8706 gfx::Size(768 / 2, 3000),
8681 true, 8707 true,
8682 false); 8708 false);
8683 root->SetIsDrawable(true); 8709 root->SetIsDrawable(true);
8684 8710
8685 scoped_refptr<Layer> clip = Layer::Create(); 8711 scoped_refptr<Layer> clip = Layer::Create(layer_settings());
8686 SetLayerPropertiesForTesting(clip.get(), 8712 SetLayerPropertiesForTesting(clip.get(),
8687 gfx::Transform(), 8713 gfx::Transform(),
8688 gfx::Point3F(), 8714 gfx::Point3F(),
8689 gfx::PointF(), 8715 gfx::PointF(),
8690 gfx::Size(768 / 2, 10000), 8716 gfx::Size(768 / 2, 10000),
8691 true, 8717 true,
8692 false); 8718 false);
8693 clip->SetMasksToBounds(true); 8719 clip->SetMasksToBounds(true);
8694 8720
8695 scoped_refptr<Layer> content = Layer::Create(); 8721 scoped_refptr<Layer> content = Layer::Create(layer_settings());
8696 SetLayerPropertiesForTesting(content.get(), 8722 SetLayerPropertiesForTesting(content.get(),
8697 gfx::Transform(), 8723 gfx::Transform(),
8698 gfx::Point3F(), 8724 gfx::Point3F(),
8699 gfx::PointF(), 8725 gfx::PointF(),
8700 gfx::Size(768 / 2, 10000), 8726 gfx::Size(768 / 2, 10000),
8701 true, 8727 true,
8702 false); 8728 false);
8703 content->SetIsDrawable(true); 8729 content->SetIsDrawable(true);
8704 content->SetForceRenderSurface(true); 8730 content->SetForceRenderSurface(true);
8705 8731
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
8788 8814
8789 LayerTreeHostCommon::CalculateDrawProperties(&inputs); 8815 LayerTreeHostCommon::CalculateDrawProperties(&inputs);
8790 8816
8791 gfx::Rect affected_by_delta(0, 0, root_size.width(), 8817 gfx::Rect affected_by_delta(0, 0, root_size.width(),
8792 root_size.height() + 50); 8818 root_size.height() + 50);
8793 EXPECT_EQ(affected_by_delta, sublayer->visible_content_rect()); 8819 EXPECT_EQ(affected_by_delta, sublayer->visible_content_rect());
8794 } 8820 }
8795 8821
8796 TEST_F(LayerTreeHostCommonTest, VisibleContentRectForAnimatedLayer) { 8822 TEST_F(LayerTreeHostCommonTest, VisibleContentRectForAnimatedLayer) {
8797 const gfx::Transform identity_matrix; 8823 const gfx::Transform identity_matrix;
8798 scoped_refptr<Layer> root = Layer::Create(); 8824 scoped_refptr<Layer> root = Layer::Create(layer_settings());
8799 scoped_refptr<LayerWithForcedDrawsContent> animated = 8825 scoped_refptr<LayerWithForcedDrawsContent> animated =
8800 make_scoped_refptr(new LayerWithForcedDrawsContent()); 8826 make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
8801 8827
8802 root->AddChild(animated); 8828 root->AddChild(animated);
8803 8829
8804 scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost()); 8830 scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost());
8805 host->SetRootLayer(root); 8831 host->SetRootLayer(root);
8806 8832
8807 SetLayerPropertiesForTesting(root.get(), identity_matrix, gfx::Point3F(), 8833 SetLayerPropertiesForTesting(root.get(), identity_matrix, gfx::Point3F(),
8808 gfx::PointF(), gfx::Size(100, 100), true, false); 8834 gfx::PointF(), gfx::Size(100, 100), true, false);
8809 SetLayerPropertiesForTesting(animated.get(), identity_matrix, gfx::Point3F(), 8835 SetLayerPropertiesForTesting(animated.get(), identity_matrix, gfx::Point3F(),
8810 gfx::PointF(), gfx::Size(20, 20), true, false); 8836 gfx::PointF(), gfx::Size(20, 20), true, false);
8811 8837
8812 root->SetMasksToBounds(true); 8838 root->SetMasksToBounds(true);
8813 root->SetForceRenderSurface(true); 8839 root->SetForceRenderSurface(true);
8814 animated->SetOpacity(0.f); 8840 animated->SetOpacity(0.f);
8815 8841
8816 AddOpacityTransitionToController(animated->layer_animation_controller(), 10.0, 8842 AddOpacityTransitionToController(animated->layer_animation_controller(), 10.0,
8817 0.f, 1.f, false); 8843 0.f, 1.f, false);
8818 8844
8819 ExecuteCalculateDrawProperties(root.get()); 8845 ExecuteCalculateDrawProperties(root.get());
8820 8846
8821 EXPECT_FALSE(animated->visible_rect_from_property_trees().IsEmpty()); 8847 EXPECT_FALSE(animated->visible_rect_from_property_trees().IsEmpty());
8822 } 8848 }
8823 8849
8824 TEST_F(LayerTreeHostCommonTest, 8850 TEST_F(LayerTreeHostCommonTest,
8825 VisibleContentRectForAnimatedLayerWithSingularTransform) { 8851 VisibleContentRectForAnimatedLayerWithSingularTransform) {
8826 const gfx::Transform identity_matrix; 8852 const gfx::Transform identity_matrix;
8827 scoped_refptr<Layer> root = Layer::Create(); 8853 scoped_refptr<Layer> root = Layer::Create(layer_settings());
8828 scoped_refptr<Layer> clip = Layer::Create(); 8854 scoped_refptr<Layer> clip = Layer::Create(layer_settings());
8829 scoped_refptr<LayerWithForcedDrawsContent> animated = 8855 scoped_refptr<LayerWithForcedDrawsContent> animated =
8830 make_scoped_refptr(new LayerWithForcedDrawsContent()); 8856 make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
8831 scoped_refptr<LayerWithForcedDrawsContent> surface = 8857 scoped_refptr<LayerWithForcedDrawsContent> surface =
8832 make_scoped_refptr(new LayerWithForcedDrawsContent()); 8858 make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
8833 scoped_refptr<LayerWithForcedDrawsContent> descendant_of_animation = 8859 scoped_refptr<LayerWithForcedDrawsContent> descendant_of_animation =
8834 make_scoped_refptr(new LayerWithForcedDrawsContent()); 8860 make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
8835 8861
8836 root->AddChild(clip); 8862 root->AddChild(clip);
8837 clip->AddChild(animated); 8863 clip->AddChild(animated);
8838 animated->AddChild(surface); 8864 animated->AddChild(surface);
8839 surface->AddChild(descendant_of_animation); 8865 surface->AddChild(descendant_of_animation);
8840 8866
8841 clip->SetMasksToBounds(true); 8867 clip->SetMasksToBounds(true);
8842 surface->SetForceRenderSurface(true); 8868 surface->SetForceRenderSurface(true);
8843 8869
8844 scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost()); 8870 scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost());
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
8894 // means the clip cannot be projected into |surface|'s space, so we treat 8920 // means the clip cannot be projected into |surface|'s space, so we treat
8895 // |surface| and layers that draw into it as fully visible. 8921 // |surface| and layers that draw into it as fully visible.
8896 EXPECT_EQ(gfx::Rect(100, 100), surface->visible_rect_from_property_trees()); 8922 EXPECT_EQ(gfx::Rect(100, 100), surface->visible_rect_from_property_trees());
8897 EXPECT_EQ(gfx::Rect(200, 200), 8923 EXPECT_EQ(gfx::Rect(200, 200),
8898 descendant_of_animation->visible_rect_from_property_trees()); 8924 descendant_of_animation->visible_rect_from_property_trees());
8899 } 8925 }
8900 8926
8901 // Verify that having an animated filter (but no current filter, as these 8927 // Verify that having an animated filter (but no current filter, as these
8902 // are mutually exclusive) correctly creates a render surface. 8928 // are mutually exclusive) correctly creates a render surface.
8903 TEST_F(LayerTreeHostCommonTest, AnimatedFilterCreatesRenderSurface) { 8929 TEST_F(LayerTreeHostCommonTest, AnimatedFilterCreatesRenderSurface) {
8904 scoped_refptr<Layer> root = Layer::Create(); 8930 scoped_refptr<Layer> root = Layer::Create(layer_settings());
8905 scoped_refptr<Layer> child = Layer::Create(); 8931 scoped_refptr<Layer> child = Layer::Create(layer_settings());
8906 scoped_refptr<Layer> grandchild = Layer::Create(); 8932 scoped_refptr<Layer> grandchild = Layer::Create(layer_settings());
8907 root->AddChild(child); 8933 root->AddChild(child);
8908 child->AddChild(grandchild); 8934 child->AddChild(grandchild);
8909 8935
8910 gfx::Transform identity_transform; 8936 gfx::Transform identity_transform;
8911 SetLayerPropertiesForTesting(root.get(), identity_transform, gfx::Point3F(), 8937 SetLayerPropertiesForTesting(root.get(), identity_transform, gfx::Point3F(),
8912 gfx::PointF(), gfx::Size(50, 50), true, false); 8938 gfx::PointF(), gfx::Size(50, 50), true, false);
8913 SetLayerPropertiesForTesting(child.get(), identity_transform, gfx::Point3F(), 8939 SetLayerPropertiesForTesting(child.get(), identity_transform, gfx::Point3F(),
8914 gfx::PointF(), gfx::Size(50, 50), true, false); 8940 gfx::PointF(), gfx::Size(50, 50), true, false);
8915 SetLayerPropertiesForTesting(grandchild.get(), identity_transform, 8941 SetLayerPropertiesForTesting(grandchild.get(), identity_transform,
8916 gfx::Point3F(), gfx::PointF(), gfx::Size(50, 50), 8942 gfx::Point3F(), gfx::PointF(), gfx::Size(50, 50),
(...skipping 14 matching lines...) Expand all
8931 EXPECT_TRUE(grandchild->filters().IsEmpty()); 8957 EXPECT_TRUE(grandchild->filters().IsEmpty());
8932 8958
8933 EXPECT_FALSE(root->FilterIsAnimating()); 8959 EXPECT_FALSE(root->FilterIsAnimating());
8934 EXPECT_TRUE(child->FilterIsAnimating()); 8960 EXPECT_TRUE(child->FilterIsAnimating());
8935 EXPECT_FALSE(grandchild->FilterIsAnimating()); 8961 EXPECT_FALSE(grandchild->FilterIsAnimating());
8936 } 8962 }
8937 8963
8938 // Ensures that the property tree code accounts for offsets between fixed 8964 // Ensures that the property tree code accounts for offsets between fixed
8939 // position layers and their respective containers. 8965 // position layers and their respective containers.
8940 TEST_F(LayerTreeHostCommonTest, PropertyTreesAccountForFixedParentOffset) { 8966 TEST_F(LayerTreeHostCommonTest, PropertyTreesAccountForFixedParentOffset) {
8941 scoped_refptr<Layer> root = Layer::Create(); 8967 scoped_refptr<Layer> root = Layer::Create(layer_settings());
8942 scoped_refptr<Layer> child = Layer::Create(); 8968 scoped_refptr<Layer> child = Layer::Create(layer_settings());
8943 scoped_refptr<LayerWithForcedDrawsContent> grandchild = 8969 scoped_refptr<LayerWithForcedDrawsContent> grandchild =
8944 make_scoped_refptr(new LayerWithForcedDrawsContent()); 8970 make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
8945 8971
8946 root->AddChild(child); 8972 root->AddChild(child);
8947 child->AddChild(grandchild); 8973 child->AddChild(grandchild);
8948 8974
8949 gfx::Transform identity_transform; 8975 gfx::Transform identity_transform;
8950 SetLayerPropertiesForTesting(root.get(), identity_transform, gfx::Point3F(), 8976 SetLayerPropertiesForTesting(root.get(), identity_transform, gfx::Point3F(),
8951 gfx::PointF(), gfx::Size(50, 50), true, false); 8977 gfx::PointF(), gfx::Size(50, 50), true, false);
8952 SetLayerPropertiesForTesting(child.get(), identity_transform, gfx::Point3F(), 8978 SetLayerPropertiesForTesting(child.get(), identity_transform, gfx::Point3F(),
8953 gfx::PointF(1000, 1000), gfx::Size(50, 50), true, 8979 gfx::PointF(1000, 1000), gfx::Size(50, 50), true,
8954 false); 8980 false);
(...skipping 21 matching lines...) Expand all
8976 TEST_F(LayerTreeHostCommonTest, CombineClipsUsingContentTarget) { 9002 TEST_F(LayerTreeHostCommonTest, CombineClipsUsingContentTarget) {
8977 // In the following layer tree, the layer |box|'s render target is |surface|. 9003 // In the following layer tree, the layer |box|'s render target is |surface|.
8978 // |surface| also creates a transform node. We want to combine clips for |box| 9004 // |surface| also creates a transform node. We want to combine clips for |box|
8979 // in the space of its target (i.e., |surface|), not its target's target. This 9005 // in the space of its target (i.e., |surface|), not its target's target. This
8980 // test ensures that happens. 9006 // test ensures that happens.
8981 9007
8982 gfx::Transform rotate; 9008 gfx::Transform rotate;
8983 rotate.Rotate(5); 9009 rotate.Rotate(5);
8984 gfx::Transform identity; 9010 gfx::Transform identity;
8985 9011
8986 scoped_refptr<Layer> root = Layer::Create(); 9012 scoped_refptr<Layer> root = Layer::Create(layer_settings());
8987 SetLayerPropertiesForTesting(root.get(), identity, gfx::Point3F(), 9013 SetLayerPropertiesForTesting(root.get(), identity, gfx::Point3F(),
8988 gfx::PointF(), gfx::Size(2500, 1500), true, 9014 gfx::PointF(), gfx::Size(2500, 1500), true,
8989 false); 9015 false);
8990 9016
8991 scoped_refptr<Layer> frame_clip = Layer::Create(); 9017 scoped_refptr<Layer> frame_clip = Layer::Create(layer_settings());
8992 SetLayerPropertiesForTesting(frame_clip.get(), identity, gfx::Point3F(), 9018 SetLayerPropertiesForTesting(frame_clip.get(), identity, gfx::Point3F(),
8993 gfx::PointF(), gfx::Size(2500, 1500), true, 9019 gfx::PointF(), gfx::Size(2500, 1500), true,
8994 false); 9020 false);
8995 frame_clip->SetMasksToBounds(true); 9021 frame_clip->SetMasksToBounds(true);
8996 9022
8997 scoped_refptr<Layer> rotated = Layer::Create(); 9023 scoped_refptr<Layer> rotated = Layer::Create(layer_settings());
8998 SetLayerPropertiesForTesting(rotated.get(), rotate, 9024 SetLayerPropertiesForTesting(rotated.get(), rotate,
8999 gfx::Point3F(1250, 250, 0), gfx::PointF(), 9025 gfx::Point3F(1250, 250, 0), gfx::PointF(),
9000 gfx::Size(2500, 500), true, false); 9026 gfx::Size(2500, 500), true, false);
9001 9027
9002 scoped_refptr<Layer> surface = Layer::Create(); 9028 scoped_refptr<Layer> surface = Layer::Create(layer_settings());
9003 SetLayerPropertiesForTesting(surface.get(), rotate, gfx::Point3F(), 9029 SetLayerPropertiesForTesting(surface.get(), rotate, gfx::Point3F(),
9004 gfx::PointF(), gfx::Size(2500, 500), true, 9030 gfx::PointF(), gfx::Size(2500, 500), true,
9005 false); 9031 false);
9006 surface->SetOpacity(0.5); 9032 surface->SetOpacity(0.5);
9007 9033
9008 scoped_refptr<LayerWithForcedDrawsContent> container = 9034 scoped_refptr<LayerWithForcedDrawsContent> container =
9009 make_scoped_refptr(new LayerWithForcedDrawsContent()); 9035 make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
9010 SetLayerPropertiesForTesting(container.get(), identity, gfx::Point3F(), 9036 SetLayerPropertiesForTesting(container.get(), identity, gfx::Point3F(),
9011 gfx::PointF(), gfx::Size(300, 300), true, false); 9037 gfx::PointF(), gfx::Size(300, 300), true, false);
9012 9038
9013 scoped_refptr<LayerWithForcedDrawsContent> box = 9039 scoped_refptr<LayerWithForcedDrawsContent> box =
9014 make_scoped_refptr(new LayerWithForcedDrawsContent()); 9040 make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
9015 SetLayerPropertiesForTesting(box.get(), identity, gfx::Point3F(), 9041 SetLayerPropertiesForTesting(box.get(), identity, gfx::Point3F(),
9016 gfx::PointF(), gfx::Size(100, 100), true, false); 9042 gfx::PointF(), gfx::Size(100, 100), true, false);
9017 9043
9018 root->AddChild(frame_clip); 9044 root->AddChild(frame_clip);
9019 frame_clip->AddChild(rotated); 9045 frame_clip->AddChild(rotated);
9020 rotated->AddChild(surface); 9046 rotated->AddChild(surface);
9021 surface->AddChild(container); 9047 surface->AddChild(container);
9022 surface->AddChild(box); 9048 surface->AddChild(box);
9023 9049
9024 scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost()); 9050 scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost());
9025 host->SetRootLayer(root); 9051 host->SetRootLayer(root);
9026 9052
9027 ExecuteCalculateDrawProperties(root.get()); 9053 ExecuteCalculateDrawProperties(root.get());
9028 } 9054 }
9029 9055
9030 TEST_F(LayerTreeHostCommonTest, OnlyApplyFixedPositioningOnce) { 9056 TEST_F(LayerTreeHostCommonTest, OnlyApplyFixedPositioningOnce) {
9031 gfx::Transform identity; 9057 gfx::Transform identity;
9032 gfx::Transform translate_z; 9058 gfx::Transform translate_z;
9033 translate_z.Translate3d(0, 0, 10); 9059 translate_z.Translate3d(0, 0, 10);
9034 9060
9035 scoped_refptr<Layer> root = Layer::Create(); 9061 scoped_refptr<Layer> root = Layer::Create(layer_settings());
9036 SetLayerPropertiesForTesting(root.get(), identity, gfx::Point3F(), 9062 SetLayerPropertiesForTesting(root.get(), identity, gfx::Point3F(),
9037 gfx::PointF(), gfx::Size(800, 800), true, false); 9063 gfx::PointF(), gfx::Size(800, 800), true, false);
9038 root->SetIsContainerForFixedPositionLayers(true); 9064 root->SetIsContainerForFixedPositionLayers(true);
9039 9065
9040 scoped_refptr<Layer> frame_clip = Layer::Create(); 9066 scoped_refptr<Layer> frame_clip = Layer::Create(layer_settings());
9041 SetLayerPropertiesForTesting(frame_clip.get(), translate_z, gfx::Point3F(), 9067 SetLayerPropertiesForTesting(frame_clip.get(), translate_z, gfx::Point3F(),
9042 gfx::PointF(500, 100), gfx::Size(100, 100), true, 9068 gfx::PointF(500, 100), gfx::Size(100, 100), true,
9043 false); 9069 false);
9044 frame_clip->SetMasksToBounds(true); 9070 frame_clip->SetMasksToBounds(true);
9045 9071
9046 scoped_refptr<LayerWithForcedDrawsContent> fixed = 9072 scoped_refptr<LayerWithForcedDrawsContent> fixed =
9047 make_scoped_refptr(new LayerWithForcedDrawsContent()); 9073 make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
9048 SetLayerPropertiesForTesting(fixed.get(), identity, gfx::Point3F(), 9074 SetLayerPropertiesForTesting(fixed.get(), identity, gfx::Point3F(),
9049 gfx::PointF(), gfx::Size(1000, 1000), true, 9075 gfx::PointF(), gfx::Size(1000, 1000), true,
9050 false); 9076 false);
9051 9077
9052 LayerPositionConstraint constraint; 9078 LayerPositionConstraint constraint;
9053 constraint.set_is_fixed_position(true); 9079 constraint.set_is_fixed_position(true);
9054 fixed->SetPositionConstraint(constraint); 9080 fixed->SetPositionConstraint(constraint);
9055 9081
9056 root->AddChild(frame_clip); 9082 root->AddChild(frame_clip);
9057 frame_clip->AddChild(fixed); 9083 frame_clip->AddChild(fixed);
9058 9084
9059 scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost()); 9085 scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost());
9060 host->SetRootLayer(root); 9086 host->SetRootLayer(root);
9061 9087
9062 ExecuteCalculateDrawProperties(root.get()); 9088 ExecuteCalculateDrawProperties(root.get());
9063 9089
9064 gfx::Rect expected(0, 0, 100, 100); 9090 gfx::Rect expected(0, 0, 100, 100);
9065 EXPECT_EQ(expected, fixed->visible_rect_from_property_trees()); 9091 EXPECT_EQ(expected, fixed->visible_rect_from_property_trees());
9066 } 9092 }
9067 9093
9068 TEST_F(LayerTreeHostCommonTest, 9094 TEST_F(LayerTreeHostCommonTest,
9069 PropertyTreesAccountForScrollCompensationAdjustment) { 9095 PropertyTreesAccountForScrollCompensationAdjustment) {
9070 gfx::Transform identity; 9096 gfx::Transform identity;
9071 gfx::Transform translate_z; 9097 gfx::Transform translate_z;
9072 translate_z.Translate3d(0, 0, 10); 9098 translate_z.Translate3d(0, 0, 10);
9073 9099
9074 scoped_refptr<Layer> root = Layer::Create(); 9100 scoped_refptr<Layer> root = Layer::Create(layer_settings());
9075 SetLayerPropertiesForTesting(root.get(), identity, gfx::Point3F(), 9101 SetLayerPropertiesForTesting(root.get(), identity, gfx::Point3F(),
9076 gfx::PointF(), gfx::Size(800, 800), true, false); 9102 gfx::PointF(), gfx::Size(800, 800), true, false);
9077 root->SetIsContainerForFixedPositionLayers(true); 9103 root->SetIsContainerForFixedPositionLayers(true);
9078 9104
9079 scoped_refptr<Layer> frame_clip = Layer::Create(); 9105 scoped_refptr<Layer> frame_clip = Layer::Create(layer_settings());
9080 SetLayerPropertiesForTesting(frame_clip.get(), translate_z, gfx::Point3F(), 9106 SetLayerPropertiesForTesting(frame_clip.get(), translate_z, gfx::Point3F(),
9081 gfx::PointF(500, 100), gfx::Size(100, 100), true, 9107 gfx::PointF(500, 100), gfx::Size(100, 100), true,
9082 false); 9108 false);
9083 frame_clip->SetMasksToBounds(true); 9109 frame_clip->SetMasksToBounds(true);
9084 9110
9085 scoped_refptr<LayerWithForcedDrawsContent> scroller = 9111 scoped_refptr<LayerWithForcedDrawsContent> scroller =
9086 make_scoped_refptr(new LayerWithForcedDrawsContent()); 9112 make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
9087 SetLayerPropertiesForTesting(scroller.get(), identity, gfx::Point3F(), 9113 SetLayerPropertiesForTesting(scroller.get(), identity, gfx::Point3F(),
9088 gfx::PointF(), gfx::Size(1000, 1000), true, 9114 gfx::PointF(), gfx::Size(1000, 1000), true,
9089 false); 9115 false);
9090 9116
9091 scroller->SetScrollCompensationAdjustment(gfx::Vector2dF(0.3f, 0.7f)); 9117 scroller->SetScrollCompensationAdjustment(gfx::Vector2dF(0.3f, 0.7f));
9092 scroller->SetScrollOffset(gfx::ScrollOffset(0.3, 0.7)); 9118 scroller->SetScrollOffset(gfx::ScrollOffset(0.3, 0.7));
9093 scroller->SetScrollClipLayerId(frame_clip->id()); 9119 scroller->SetScrollClipLayerId(frame_clip->id());
9094 9120
9095 scoped_refptr<LayerWithForcedDrawsContent> fixed = 9121 scoped_refptr<LayerWithForcedDrawsContent> fixed =
9096 make_scoped_refptr(new LayerWithForcedDrawsContent()); 9122 make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
9097 SetLayerPropertiesForTesting(fixed.get(), identity, gfx::Point3F(), 9123 SetLayerPropertiesForTesting(fixed.get(), identity, gfx::Point3F(),
9098 gfx::PointF(), gfx::Size(50, 50), true, false); 9124 gfx::PointF(), gfx::Size(50, 50), true, false);
9099 9125
9100 LayerPositionConstraint constraint; 9126 LayerPositionConstraint constraint;
9101 constraint.set_is_fixed_position(true); 9127 constraint.set_is_fixed_position(true);
9102 fixed->SetPositionConstraint(constraint); 9128 fixed->SetPositionConstraint(constraint);
9103 9129
9104 scoped_refptr<LayerWithForcedDrawsContent> fixed_child = 9130 scoped_refptr<LayerWithForcedDrawsContent> fixed_child =
9105 make_scoped_refptr(new LayerWithForcedDrawsContent()); 9131 make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
9106 SetLayerPropertiesForTesting(fixed_child.get(), identity, gfx::Point3F(), 9132 SetLayerPropertiesForTesting(fixed_child.get(), identity, gfx::Point3F(),
9107 gfx::PointF(), gfx::Size(10, 10), true, false); 9133 gfx::PointF(), gfx::Size(10, 10), true, false);
9108 9134
9109 fixed_child->SetPositionConstraint(constraint); 9135 fixed_child->SetPositionConstraint(constraint);
9110 9136
9111 root->AddChild(frame_clip); 9137 root->AddChild(frame_clip);
9112 frame_clip->AddChild(scroller); 9138 frame_clip->AddChild(scroller);
9113 scroller->AddChild(fixed); 9139 scroller->AddChild(fixed);
9114 fixed->AddChild(fixed_child); 9140 fixed->AddChild(fixed_child);
9115 9141
9116 scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost()); 9142 scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost());
9117 host->SetRootLayer(root); 9143 host->SetRootLayer(root);
9118 9144
9119 ExecuteCalculateDrawProperties(root.get()); 9145 ExecuteCalculateDrawProperties(root.get());
9120 9146
9121 gfx::Rect expected(0, 0, 50, 50); 9147 gfx::Rect expected(0, 0, 50, 50);
9122 EXPECT_EQ(expected, fixed->visible_rect_from_property_trees()); 9148 EXPECT_EQ(expected, fixed->visible_rect_from_property_trees());
9123 9149
9124 expected = gfx::Rect(0, 0, 10, 10); 9150 expected = gfx::Rect(0, 0, 10, 10);
9125 EXPECT_EQ(expected, fixed_child->visible_rect_from_property_trees()); 9151 EXPECT_EQ(expected, fixed_child->visible_rect_from_property_trees());
9126 } 9152 }
9127 9153
9128 TEST_F(LayerTreeHostCommonTest, FixedClipsShouldBeAssociatedWithTheRightNode) { 9154 TEST_F(LayerTreeHostCommonTest, FixedClipsShouldBeAssociatedWithTheRightNode) {
9129 gfx::Transform identity; 9155 gfx::Transform identity;
9130 9156
9131 scoped_refptr<Layer> root = Layer::Create(); 9157 scoped_refptr<Layer> root = Layer::Create(layer_settings());
9132 SetLayerPropertiesForTesting(root.get(), identity, gfx::Point3F(), 9158 SetLayerPropertiesForTesting(root.get(), identity, gfx::Point3F(),
9133 gfx::PointF(), gfx::Size(800, 800), true, false); 9159 gfx::PointF(), gfx::Size(800, 800), true, false);
9134 root->SetIsContainerForFixedPositionLayers(true); 9160 root->SetIsContainerForFixedPositionLayers(true);
9135 9161
9136 scoped_refptr<Layer> frame_clip = Layer::Create(); 9162 scoped_refptr<Layer> frame_clip = Layer::Create(layer_settings());
9137 SetLayerPropertiesForTesting(frame_clip.get(), identity, gfx::Point3F(), 9163 SetLayerPropertiesForTesting(frame_clip.get(), identity, gfx::Point3F(),
9138 gfx::PointF(500, 100), gfx::Size(100, 100), true, 9164 gfx::PointF(500, 100), gfx::Size(100, 100), true,
9139 false); 9165 false);
9140 frame_clip->SetMasksToBounds(true); 9166 frame_clip->SetMasksToBounds(true);
9141 9167
9142 scoped_refptr<LayerWithForcedDrawsContent> scroller = 9168 scoped_refptr<LayerWithForcedDrawsContent> scroller =
9143 make_scoped_refptr(new LayerWithForcedDrawsContent()); 9169 make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
9144 SetLayerPropertiesForTesting(scroller.get(), identity, gfx::Point3F(), 9170 SetLayerPropertiesForTesting(scroller.get(), identity, gfx::Point3F(),
9145 gfx::PointF(), gfx::Size(1000, 1000), true, 9171 gfx::PointF(), gfx::Size(1000, 1000), true,
9146 false); 9172 false);
9147 9173
9148 scroller->SetScrollOffset(gfx::ScrollOffset(100, 100)); 9174 scroller->SetScrollOffset(gfx::ScrollOffset(100, 100));
9149 scroller->SetScrollClipLayerId(frame_clip->id()); 9175 scroller->SetScrollClipLayerId(frame_clip->id());
9150 9176
9151 scoped_refptr<LayerWithForcedDrawsContent> fixed = 9177 scoped_refptr<LayerWithForcedDrawsContent> fixed =
9152 make_scoped_refptr(new LayerWithForcedDrawsContent()); 9178 make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
9153 SetLayerPropertiesForTesting(fixed.get(), identity, gfx::Point3F(), 9179 SetLayerPropertiesForTesting(fixed.get(), identity, gfx::Point3F(),
9154 gfx::PointF(100, 100), gfx::Size(50, 50), true, 9180 gfx::PointF(100, 100), gfx::Size(50, 50), true,
9155 false); 9181 false);
9156 9182
9157 LayerPositionConstraint constraint; 9183 LayerPositionConstraint constraint;
9158 constraint.set_is_fixed_position(true); 9184 constraint.set_is_fixed_position(true);
9159 fixed->SetPositionConstraint(constraint); 9185 fixed->SetPositionConstraint(constraint);
9160 fixed->SetForceRenderSurface(true); 9186 fixed->SetForceRenderSurface(true);
9161 fixed->SetMasksToBounds(true); 9187 fixed->SetMasksToBounds(true);
9162 9188
(...skipping 11 matching lines...) Expand all
9174 } 9200 }
9175 9201
9176 TEST_F(LayerTreeHostCommonTest, ChangingAxisAlignmentTriggersRebuild) { 9202 TEST_F(LayerTreeHostCommonTest, ChangingAxisAlignmentTriggersRebuild) {
9177 gfx::Transform identity; 9203 gfx::Transform identity;
9178 gfx::Transform translate; 9204 gfx::Transform translate;
9179 gfx::Transform rotate; 9205 gfx::Transform rotate;
9180 9206
9181 translate.Translate(10, 10); 9207 translate.Translate(10, 10);
9182 rotate.Rotate(45); 9208 rotate.Rotate(45);
9183 9209
9184 scoped_refptr<Layer> root = Layer::Create(); 9210 scoped_refptr<Layer> root = Layer::Create(layer_settings());
9185 SetLayerPropertiesForTesting(root.get(), identity, gfx::Point3F(), 9211 SetLayerPropertiesForTesting(root.get(), identity, gfx::Point3F(),
9186 gfx::PointF(), gfx::Size(800, 800), true, false); 9212 gfx::PointF(), gfx::Size(800, 800), true, false);
9187 root->SetIsContainerForFixedPositionLayers(true); 9213 root->SetIsContainerForFixedPositionLayers(true);
9188 9214
9189 scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost()); 9215 scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost());
9190 host->SetRootLayer(root); 9216 host->SetRootLayer(root);
9191 9217
9192 ExecuteCalculateDrawProperties(root.get()); 9218 ExecuteCalculateDrawProperties(root.get());
9193 9219
9194 root->SetTransform(translate); 9220 root->SetTransform(translate);
9195 EXPECT_FALSE(host->property_trees()->needs_rebuild); 9221 EXPECT_FALSE(host->property_trees()->needs_rebuild);
9196 9222
9197 root->SetTransform(rotate); 9223 root->SetTransform(rotate);
9198 EXPECT_TRUE(host->property_trees()->needs_rebuild); 9224 EXPECT_TRUE(host->property_trees()->needs_rebuild);
9199 } 9225 }
9200 9226
9201 TEST_F(LayerTreeHostCommonTest, ChangeTransformOrigin) { 9227 TEST_F(LayerTreeHostCommonTest, ChangeTransformOrigin) {
9202 scoped_refptr<Layer> root = Layer::Create(); 9228 scoped_refptr<Layer> root = Layer::Create(layer_settings());
9203 scoped_refptr<LayerWithForcedDrawsContent> child = 9229 scoped_refptr<LayerWithForcedDrawsContent> child =
9204 make_scoped_refptr(new LayerWithForcedDrawsContent()); 9230 make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
9205 root->AddChild(child); 9231 root->AddChild(child);
9206 9232
9207 scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost()); 9233 scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost());
9208 host->SetRootLayer(root); 9234 host->SetRootLayer(root);
9209 9235
9210 gfx::Transform identity_matrix; 9236 gfx::Transform identity_matrix;
9211 gfx::Transform scale_matrix; 9237 gfx::Transform scale_matrix;
9212 scale_matrix.Scale(2.f, 2.f); 9238 scale_matrix.Scale(2.f, 2.f);
9213 SetLayerPropertiesForTesting(root.get(), identity_matrix, gfx::Point3F(), 9239 SetLayerPropertiesForTesting(root.get(), identity_matrix, gfx::Point3F(),
9214 gfx::PointF(), gfx::Size(100, 100), true, false); 9240 gfx::PointF(), gfx::Size(100, 100), true, false);
9215 SetLayerPropertiesForTesting(child.get(), scale_matrix, gfx::Point3F(), 9241 SetLayerPropertiesForTesting(child.get(), scale_matrix, gfx::Point3F(),
9216 gfx::PointF(), gfx::Size(10, 10), true, false); 9242 gfx::PointF(), gfx::Size(10, 10), true, false);
9217 9243
9218 ExecuteCalculateDrawProperties(root.get()); 9244 ExecuteCalculateDrawProperties(root.get());
9219 EXPECT_EQ(gfx::Rect(10, 10), child->visible_rect_from_property_trees()); 9245 EXPECT_EQ(gfx::Rect(10, 10), child->visible_rect_from_property_trees());
9220 9246
9221 child->SetTransformOrigin(gfx::Point3F(10.f, 10.f, 10.f)); 9247 child->SetTransformOrigin(gfx::Point3F(10.f, 10.f, 10.f));
9222 9248
9223 ExecuteCalculateDrawProperties(root.get()); 9249 ExecuteCalculateDrawProperties(root.get());
9224 EXPECT_EQ(gfx::Rect(5, 5, 5, 5), child->visible_rect_from_property_trees()); 9250 EXPECT_EQ(gfx::Rect(5, 5, 5, 5), child->visible_rect_from_property_trees());
9225 } 9251 }
9226 9252
9227 TEST_F(LayerTreeHostCommonTest, UpdateScrollChildPosition) { 9253 TEST_F(LayerTreeHostCommonTest, UpdateScrollChildPosition) {
9228 scoped_refptr<Layer> root = Layer::Create(); 9254 scoped_refptr<Layer> root = Layer::Create(layer_settings());
9229 scoped_refptr<LayerWithForcedDrawsContent> scroll_parent = 9255 scoped_refptr<LayerWithForcedDrawsContent> scroll_parent =
9230 make_scoped_refptr(new LayerWithForcedDrawsContent); 9256 make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
9231 scoped_refptr<LayerWithForcedDrawsContent> scroll_child = 9257 scoped_refptr<LayerWithForcedDrawsContent> scroll_child =
9232 make_scoped_refptr(new LayerWithForcedDrawsContent); 9258 make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
9233 9259
9234 root->AddChild(scroll_child); 9260 root->AddChild(scroll_child);
9235 root->AddChild(scroll_parent); 9261 root->AddChild(scroll_parent);
9236 scroll_child->SetScrollParent(scroll_parent.get()); 9262 scroll_child->SetScrollParent(scroll_parent.get());
9237 scroll_parent->SetScrollClipLayerId(root->id()); 9263 scroll_parent->SetScrollClipLayerId(root->id());
9238 9264
9239 scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost()); 9265 scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost());
9240 host->SetRootLayer(root); 9266 host->SetRootLayer(root);
9241 9267
9242 gfx::Transform identity_transform; 9268 gfx::Transform identity_transform;
(...skipping 17 matching lines...) Expand all
9260 EXPECT_EQ(gfx::Rect(0, 5, 25, 25), 9286 EXPECT_EQ(gfx::Rect(0, 5, 25, 25),
9261 scroll_child->visible_rect_from_property_trees()); 9287 scroll_child->visible_rect_from_property_trees());
9262 } 9288 }
9263 9289
9264 static void CopyOutputCallback(scoped_ptr<CopyOutputResult> result) { 9290 static void CopyOutputCallback(scoped_ptr<CopyOutputResult> result) {
9265 } 9291 }
9266 9292
9267 TEST_F(LayerTreeHostCommonTest, SkippingSubtreeMain) { 9293 TEST_F(LayerTreeHostCommonTest, SkippingSubtreeMain) {
9268 gfx::Transform identity; 9294 gfx::Transform identity;
9269 FakeContentLayerClient client; 9295 FakeContentLayerClient client;
9270 scoped_refptr<Layer> root = Layer::Create(); 9296 scoped_refptr<Layer> root = Layer::Create(layer_settings());
9271 scoped_refptr<LayerWithForcedDrawsContent> child = 9297 scoped_refptr<LayerWithForcedDrawsContent> child =
9272 make_scoped_refptr(new LayerWithForcedDrawsContent()); 9298 make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
9273 scoped_refptr<LayerWithForcedDrawsContent> grandchild = 9299 scoped_refptr<LayerWithForcedDrawsContent> grandchild =
9274 make_scoped_refptr(new LayerWithForcedDrawsContent()); 9300 make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
9275 scoped_refptr<FakeContentLayer> greatgrandchild( 9301 scoped_refptr<FakeContentLayer> greatgrandchild(
9276 FakeContentLayer::Create(&client)); 9302 FakeContentLayer::Create(layer_settings(), &client));
9277 SetLayerPropertiesForTesting(root.get(), identity, gfx::Point3F(), 9303 SetLayerPropertiesForTesting(root.get(), identity, gfx::Point3F(),
9278 gfx::PointF(), gfx::Size(100, 100), true, false); 9304 gfx::PointF(), gfx::Size(100, 100), true, false);
9279 SetLayerPropertiesForTesting(child.get(), identity, gfx::Point3F(), 9305 SetLayerPropertiesForTesting(child.get(), identity, gfx::Point3F(),
9280 gfx::PointF(), gfx::Size(10, 10), true, false); 9306 gfx::PointF(), gfx::Size(10, 10), true, false);
9281 SetLayerPropertiesForTesting(grandchild.get(), identity, gfx::Point3F(), 9307 SetLayerPropertiesForTesting(grandchild.get(), identity, gfx::Point3F(),
9282 gfx::PointF(), gfx::Size(10, 10), true, false); 9308 gfx::PointF(), gfx::Size(10, 10), true, false);
9283 SetLayerPropertiesForTesting(greatgrandchild.get(), identity, gfx::Point3F(), 9309 SetLayerPropertiesForTesting(greatgrandchild.get(), identity, gfx::Point3F(),
9284 gfx::PointF(), gfx::Size(10, 10), true, false); 9310 gfx::PointF(), gfx::Size(10, 10), true, false);
9285 9311
9286 root->AddChild(child); 9312 root->AddChild(child);
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
9422 9448
9423 greatgrandchild_ptr->PassCopyRequests(&requests); 9449 greatgrandchild_ptr->PassCopyRequests(&requests);
9424 ExecuteCalculateDrawProperties(root.get()); 9450 ExecuteCalculateDrawProperties(root.get());
9425 EXPECT_EQ(gfx::Rect(10, 10), 9451 EXPECT_EQ(gfx::Rect(10, 10),
9426 grandchild_ptr->visible_rect_from_property_trees()); 9452 grandchild_ptr->visible_rect_from_property_trees());
9427 } 9453 }
9428 9454
9429 TEST_F(LayerTreeHostCommonTest, SkippingLayer) { 9455 TEST_F(LayerTreeHostCommonTest, SkippingLayer) {
9430 gfx::Transform identity; 9456 gfx::Transform identity;
9431 FakeContentLayerClient client; 9457 FakeContentLayerClient client;
9432 scoped_refptr<Layer> root = Layer::Create(); 9458 scoped_refptr<Layer> root = Layer::Create(layer_settings());
9433 scoped_refptr<LayerWithForcedDrawsContent> child = 9459 scoped_refptr<LayerWithForcedDrawsContent> child =
9434 make_scoped_refptr(new LayerWithForcedDrawsContent()); 9460 make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
9435 SetLayerPropertiesForTesting(root.get(), identity, gfx::Point3F(), 9461 SetLayerPropertiesForTesting(root.get(), identity, gfx::Point3F(),
9436 gfx::PointF(), gfx::Size(100, 100), true, false); 9462 gfx::PointF(), gfx::Size(100, 100), true, false);
9437 SetLayerPropertiesForTesting(child.get(), identity, gfx::Point3F(), 9463 SetLayerPropertiesForTesting(child.get(), identity, gfx::Point3F(),
9438 gfx::PointF(), gfx::Size(10, 10), true, false); 9464 gfx::PointF(), gfx::Size(10, 10), true, false);
9439 root->AddChild(child); 9465 root->AddChild(child);
9440 9466
9441 scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost()); 9467 scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost());
9442 host->SetRootLayer(root); 9468 host->SetRootLayer(root);
9443 9469
9444 ExecuteCalculateDrawProperties(root.get()); 9470 ExecuteCalculateDrawProperties(root.get());
(...skipping 19 matching lines...) Expand all
9464 child->SetDoubleSided(true); 9490 child->SetDoubleSided(true);
9465 child->SetTransform(identity); 9491 child->SetTransform(identity);
9466 9492
9467 child->SetOpacity(0.f); 9493 child->SetOpacity(0.f);
9468 ExecuteCalculateDrawProperties(root.get()); 9494 ExecuteCalculateDrawProperties(root.get());
9469 EXPECT_EQ(gfx::Rect(0, 0), child->visible_rect_from_property_trees()); 9495 EXPECT_EQ(gfx::Rect(0, 0), child->visible_rect_from_property_trees());
9470 } 9496 }
9471 9497
9472 } // namespace 9498 } // namespace
9473 } // namespace cc 9499 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698