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

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

Issue 1416293005: Fix some unit tests that fail when we enable impl property trees (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cc/layers/layer_position_constraint_unittest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 The Chromium Authors. All rights reserved. 1 // Copyright 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "cc/trees/layer_tree_host_common.h" 5 #include "cc/trees/layer_tree_host_common.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <set> 8 #include <set>
9 9
10 #include "cc/animation/keyframed_animation_curve.h" 10 #include "cc/animation/keyframed_animation_curve.h"
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 EXPECT_TRANSFORMATION_MATRIX_EQ(identity_matrix, 139 EXPECT_TRANSFORMATION_MATRIX_EQ(identity_matrix,
140 grand_child->draw_transform()); 140 grand_child->draw_transform());
141 EXPECT_TRANSFORMATION_MATRIX_EQ(identity_matrix, 141 EXPECT_TRANSFORMATION_MATRIX_EQ(identity_matrix,
142 grand_child->screen_space_transform()); 142 grand_child->screen_space_transform());
143 } 143 }
144 144
145 TEST_F(LayerTreeHostCommonTest, DoNotSkipLayersWithHandlers) { 145 TEST_F(LayerTreeHostCommonTest, DoNotSkipLayersWithHandlers) {
146 LayerImpl* parent = root_layer(); 146 LayerImpl* parent = root_layer();
147 LayerImpl* child = AddChild<LayerImpl>(parent); 147 LayerImpl* child = AddChild<LayerImpl>(parent);
148 LayerImpl* grand_child = AddChild<LayerImpl>(child); 148 LayerImpl* grand_child = AddChild<LayerImpl>(child);
149 child->SetDrawsContent(true);
150 grand_child->SetDrawsContent(true);
149 151
150 gfx::Transform identity_matrix; 152 gfx::Transform identity_matrix;
151 SetLayerPropertiesForTesting(parent, identity_matrix, gfx::Point3F(), 153 SetLayerPropertiesForTesting(parent, identity_matrix, gfx::Point3F(),
152 gfx::PointF(), gfx::Size(100, 100), true, false, 154 gfx::PointF(), gfx::Size(100, 100), true, false,
153 true); 155 true);
154 SetLayerPropertiesForTesting(child, identity_matrix, gfx::Point3F(), 156 SetLayerPropertiesForTesting(child, identity_matrix, gfx::Point3F(),
155 gfx::PointF(10, 10), gfx::Size(100, 100), true, 157 gfx::PointF(10, 10), gfx::Size(100, 100), true,
156 false, false); 158 false, false);
157 // This would have previously caused us to skip our subtree, but this would be 159 // This would have previously caused us to skip our subtree, but this would be
158 // wrong; we need up-to-date draw properties to do hit testing on the layers 160 // wrong; we need up-to-date draw properties to do hit testing on the layers
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after
461 LayerImpl* grand_child = AddChild<LayerImpl>(child); 463 LayerImpl* grand_child = AddChild<LayerImpl>(child);
462 grand_child->SetDrawsContent(true); 464 grand_child->SetDrawsContent(true);
463 465
464 gfx::Transform identity_matrix; 466 gfx::Transform identity_matrix;
465 SetLayerPropertiesForTesting(root, identity_matrix, gfx::Point3F(), 467 SetLayerPropertiesForTesting(root, identity_matrix, gfx::Point3F(),
466 gfx::PointF(), gfx::Size(1, 2), true, false, 468 gfx::PointF(), gfx::Size(1, 2), true, false,
467 true); 469 true);
468 470
469 // Child is set up so that a new render surface should be created. 471 // Child is set up so that a new render surface should be created.
470 child->SetOpacity(0.5f); 472 child->SetOpacity(0.5f);
473 child->SetDrawsContent(true);
471 474
472 gfx::Transform parent_layer_transform; 475 gfx::Transform parent_layer_transform;
473 parent_layer_transform.Scale3d(1.f, 0.9f, 1.f); 476 parent_layer_transform.Scale3d(1.f, 0.9f, 1.f);
474 gfx::Transform parent_translation_to_anchor; 477 gfx::Transform parent_translation_to_anchor;
475 parent_translation_to_anchor.Translate(25.0, 30.0); 478 parent_translation_to_anchor.Translate(25.0, 30.0);
476 479
477 gfx::Transform parent_composite_transform = 480 gfx::Transform parent_composite_transform =
478 parent_translation_to_anchor * parent_layer_transform * 481 parent_translation_to_anchor * parent_layer_transform *
479 Inverse(parent_translation_to_anchor); 482 Inverse(parent_translation_to_anchor);
480 gfx::Vector2dF parent_composite_scale = 483 gfx::Vector2dF parent_composite_scale =
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
655 // have a draw transform described w.r.t. that ancestor surface 658 // have a draw transform described w.r.t. that ancestor surface
656 // - Replicas of a render surface are described w.r.t. the replica's 659 // - Replicas of a render surface are described w.r.t. the replica's
657 // transform around its anchor, along with the surface itself. 660 // transform around its anchor, along with the surface itself.
658 // - Sanity check on recursion: verify transforms of layers described w.r.t. 661 // - Sanity check on recursion: verify transforms of layers described w.r.t.
659 // a render surface that is described w.r.t. an ancestor render surface. 662 // a render surface that is described w.r.t. an ancestor render surface.
660 // - verifying that each layer has a reference to the correct render surface 663 // - verifying that each layer has a reference to the correct render surface
661 // and render target values. 664 // and render target values.
662 665
663 LayerImpl* root = root_layer(); 666 LayerImpl* root = root_layer();
664 LayerImpl* parent = AddChildToRoot<LayerImpl>(); 667 LayerImpl* parent = AddChildToRoot<LayerImpl>();
668 parent->SetDrawsContent(true);
665 LayerImpl* render_surface1 = AddChild<LayerImpl>(parent); 669 LayerImpl* render_surface1 = AddChild<LayerImpl>(parent);
670 render_surface1->SetDrawsContent(true);
666 LayerImpl* render_surface2 = AddChild<LayerImpl>(render_surface1); 671 LayerImpl* render_surface2 = AddChild<LayerImpl>(render_surface1);
672 render_surface2->SetDrawsContent(true);
667 LayerImpl* child_of_root = AddChild<LayerImpl>(parent); 673 LayerImpl* child_of_root = AddChild<LayerImpl>(parent);
674 child_of_root->SetDrawsContent(true);
668 LayerImpl* child_of_rs1 = AddChild<LayerImpl>(render_surface1); 675 LayerImpl* child_of_rs1 = AddChild<LayerImpl>(render_surface1);
676 child_of_rs1->SetDrawsContent(true);
669 LayerImpl* child_of_rs2 = AddChild<LayerImpl>(render_surface2); 677 LayerImpl* child_of_rs2 = AddChild<LayerImpl>(render_surface2);
678 child_of_rs2->SetDrawsContent(true);
670 LayerImpl* grand_child_of_root = AddChild<LayerImpl>(child_of_root); 679 LayerImpl* grand_child_of_root = AddChild<LayerImpl>(child_of_root);
680 grand_child_of_root->SetDrawsContent(true);
671 LayerImpl* grand_child_of_rs1 = AddChild<LayerImpl>(child_of_rs1); 681 LayerImpl* grand_child_of_rs1 = AddChild<LayerImpl>(child_of_rs1);
672 grand_child_of_rs1->SetDrawsContent(true); 682 grand_child_of_rs1->SetDrawsContent(true);
673 LayerImpl* grand_child_of_rs2 = AddChild<LayerImpl>(child_of_rs2); 683 LayerImpl* grand_child_of_rs2 = AddChild<LayerImpl>(child_of_rs2);
674 grand_child_of_rs2->SetDrawsContent(true); 684 grand_child_of_rs2->SetDrawsContent(true);
675 685
676 scoped_ptr<LayerImpl> replica_of_rs1 = 686 scoped_ptr<LayerImpl> replica_of_rs1 =
677 LayerImpl::Create(host_impl()->active_tree(), 101); 687 LayerImpl::Create(host_impl()->active_tree(), 101);
678 scoped_ptr<LayerImpl> replica_of_rs2 = 688 scoped_ptr<LayerImpl> replica_of_rs2 =
679 LayerImpl::Create(host_impl()->active_tree(), 102); 689 LayerImpl::Create(host_impl()->active_tree(), 102);
680 690
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
884 } 894 }
885 895
886 TEST_F(LayerTreeHostCommonTest, TransformsForFlatteningLayer) { 896 TEST_F(LayerTreeHostCommonTest, TransformsForFlatteningLayer) {
887 // For layers that flatten their subtree, there should be an orthographic 897 // For layers that flatten their subtree, there should be an orthographic
888 // projection (for x and y values) in the middle of the transform sequence. 898 // projection (for x and y values) in the middle of the transform sequence.
889 // Note that the way the code is currently implemented, it is not expected to 899 // Note that the way the code is currently implemented, it is not expected to
890 // use a canonical orthographic projection. 900 // use a canonical orthographic projection.
891 901
892 LayerImpl* root = root_layer(); 902 LayerImpl* root = root_layer();
893 LayerImpl* child = AddChildToRoot<LayerImpl>(); 903 LayerImpl* child = AddChildToRoot<LayerImpl>();
904 child->SetDrawsContent(true);
894 LayerImpl* grand_child = AddChild<LayerImpl>(child); 905 LayerImpl* grand_child = AddChild<LayerImpl>(child);
895 grand_child->SetDrawsContent(true); 906 grand_child->SetDrawsContent(true);
896 LayerImpl* great_grand_child = AddChild<LayerImpl>(grand_child); 907 LayerImpl* great_grand_child = AddChild<LayerImpl>(grand_child);
897 great_grand_child->SetDrawsContent(true); 908 great_grand_child->SetDrawsContent(true);
898 909
899 gfx::Transform rotation_about_y_axis; 910 gfx::Transform rotation_about_y_axis;
900 rotation_about_y_axis.RotateAboutYAxis(30.0); 911 rotation_about_y_axis.RotateAboutYAxis(30.0);
901 912
902 const gfx::Transform identity_matrix; 913 const gfx::Transform identity_matrix;
903 SetLayerPropertiesForTesting(root, identity_matrix, gfx::Point3F(), 914 SetLayerPropertiesForTesting(root, identity_matrix, gfx::Point3F(),
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after
1248 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( 1259 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs(
1249 parent, parent->bounds(), &render_surface_layer_list); 1260 parent, parent->bounds(), &render_surface_layer_list);
1250 inputs.can_adjust_raster_scales = true; 1261 inputs.can_adjust_raster_scales = true;
1251 LayerTreeHostCommon::CalculateDrawProperties(&inputs); 1262 LayerTreeHostCommon::CalculateDrawProperties(&inputs);
1252 1263
1253 // The layer is fully transparent, but has a background filter, so it 1264 // The layer is fully transparent, but has a background filter, so it
1254 // shouldn't be skipped. 1265 // shouldn't be skipped.
1255 ASSERT_TRUE(parent->render_surface()); 1266 ASSERT_TRUE(parent->render_surface());
1256 EXPECT_EQ(1U, parent->render_surface()->layer_list().size()); 1267 EXPECT_EQ(1U, parent->render_surface()->layer_list().size());
1257 EXPECT_EQ(2U, render_surface_layer_list.size()); 1268 EXPECT_EQ(2U, render_surface_layer_list.size());
1258 EXPECT_EQ(gfx::Rect(0, 0, 10, 10), parent->drawable_content_rect()); 1269 EXPECT_EQ(gfx::RectF(0, 0, 10, 10),
1270 parent->render_surface()->DrawableContentRect());
1259 } 1271 }
1260 1272
1261 TEST_F(LayerTreeHostCommonTest, RenderSurfaceForBlendMode) { 1273 TEST_F(LayerTreeHostCommonTest, RenderSurfaceForBlendMode) {
1262 LayerImpl* parent = root_layer(); 1274 LayerImpl* parent = root_layer();
1263 LayerImpl* child = AddChild<LayerImpl>(parent); 1275 LayerImpl* child = AddChild<LayerImpl>(parent);
1264 child->SetDrawsContent(true); 1276 child->SetDrawsContent(true);
1265 1277
1266 const gfx::Transform identity_matrix; 1278 const gfx::Transform identity_matrix;
1267 const SkXfermode::Mode blend_mode = SkXfermode::kMultiply_Mode; 1279 const SkXfermode::Mode blend_mode = SkXfermode::kMultiply_Mode;
1268 SetLayerPropertiesForTesting(parent, identity_matrix, gfx::Point3F(), 1280 SetLayerPropertiesForTesting(parent, identity_matrix, gfx::Point3F(),
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after
1607 // 1619 //
1608 // In particular, for a layer that owns a render surface: 1620 // In particular, for a layer that owns a render surface:
1609 // - the render surface inherits any clip from ancestors, and does NOT 1621 // - the render surface inherits any clip from ancestors, and does NOT
1610 // pass that clipped status to the layer itself. 1622 // pass that clipped status to the layer itself.
1611 // - but if the layer itself masks to bounds, it is considered clipped 1623 // - but if the layer itself masks to bounds, it is considered clipped
1612 // and propagates the clip to the subtree. 1624 // and propagates the clip to the subtree.
1613 1625
1614 const gfx::Transform identity_matrix; 1626 const gfx::Transform identity_matrix;
1615 LayerImpl* root = root_layer(); 1627 LayerImpl* root = root_layer();
1616 LayerImpl* parent = AddChild<LayerImpl>(root); 1628 LayerImpl* parent = AddChild<LayerImpl>(root);
1629 parent->SetDrawsContent(true);
1617 LayerImpl* child1 = AddChild<LayerImpl>(parent); 1630 LayerImpl* child1 = AddChild<LayerImpl>(parent);
1631 child1->SetDrawsContent(true);
1618 LayerImpl* child2 = AddChild<LayerImpl>(parent); 1632 LayerImpl* child2 = AddChild<LayerImpl>(parent);
1633 child2->SetDrawsContent(true);
1619 LayerImpl* grand_child = AddChild<LayerImpl>(child1); 1634 LayerImpl* grand_child = AddChild<LayerImpl>(child1);
1635 grand_child->SetDrawsContent(true);
1620 LayerImpl* leaf_node1 = AddChild<LayerImpl>(grand_child); 1636 LayerImpl* leaf_node1 = AddChild<LayerImpl>(grand_child);
1621 leaf_node1->SetDrawsContent(true); 1637 leaf_node1->SetDrawsContent(true);
1622 LayerImpl* leaf_node2 = AddChild<LayerImpl>(child2); 1638 LayerImpl* leaf_node2 = AddChild<LayerImpl>(child2);
1623 leaf_node2->SetDrawsContent(true); 1639 leaf_node2->SetDrawsContent(true);
1624 1640
1625 SetLayerPropertiesForTesting(root, identity_matrix, gfx::Point3F(), 1641 SetLayerPropertiesForTesting(root, identity_matrix, gfx::Point3F(),
1626 gfx::PointF(), gfx::Size(100, 100), true, false, 1642 gfx::PointF(), gfx::Size(100, 100), true, false,
1627 true); 1643 true);
1628 SetLayerPropertiesForTesting(parent, identity_matrix, gfx::Point3F(), 1644 SetLayerPropertiesForTesting(parent, identity_matrix, gfx::Point3F(),
1629 gfx::PointF(), gfx::Size(100, 100), true, false, 1645 gfx::PointF(), gfx::Size(100, 100), true, false,
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after
1886 // grand_child3 - partially clipped and masksToBounds; the 1902 // grand_child3 - partially clipped and masksToBounds; the
1887 // DrawableContentRect will still be the intersection of layer bounds and 1903 // DrawableContentRect will still be the intersection of layer bounds and
1888 // the mask region. 1904 // the mask region.
1889 // grand_child4 - outside parent's clip rect; the DrawableContentRect should 1905 // grand_child4 - outside parent's clip rect; the DrawableContentRect should
1890 // be empty. 1906 // be empty.
1891 1907
1892 const gfx::Transform identity_matrix; 1908 const gfx::Transform identity_matrix;
1893 LayerImpl* parent = root_layer(); 1909 LayerImpl* parent = root_layer();
1894 LayerImpl* child = AddChild<LayerImpl>(parent); 1910 LayerImpl* child = AddChild<LayerImpl>(parent);
1895 LayerImpl* grand_child1 = AddChild<LayerImpl>(child); 1911 LayerImpl* grand_child1 = AddChild<LayerImpl>(child);
1912 grand_child1->SetDrawsContent(true);
1896 LayerImpl* grand_child2 = AddChild<LayerImpl>(child); 1913 LayerImpl* grand_child2 = AddChild<LayerImpl>(child);
1914 grand_child2->SetDrawsContent(true);
1897 LayerImpl* grand_child3 = AddChild<LayerImpl>(child); 1915 LayerImpl* grand_child3 = AddChild<LayerImpl>(child);
1916 grand_child3->SetDrawsContent(true);
1898 LayerImpl* grand_child4 = AddChild<LayerImpl>(child); 1917 LayerImpl* grand_child4 = AddChild<LayerImpl>(child);
1918 grand_child4->SetDrawsContent(true);
1899 1919
1900 SetLayerPropertiesForTesting(parent, identity_matrix, gfx::Point3F(), 1920 SetLayerPropertiesForTesting(parent, identity_matrix, gfx::Point3F(),
1901 gfx::PointF(), gfx::Size(500, 500), true, false, 1921 gfx::PointF(), gfx::Size(500, 500), true, false,
1902 true); 1922 true);
1903 SetLayerPropertiesForTesting(child, identity_matrix, gfx::Point3F(), 1923 SetLayerPropertiesForTesting(child, identity_matrix, gfx::Point3F(),
1904 gfx::PointF(), gfx::Size(20, 20), true, false, 1924 gfx::PointF(), gfx::Size(20, 20), true, false,
1905 true); 1925 true);
1906 SetLayerPropertiesForTesting(grand_child1, identity_matrix, gfx::Point3F(), 1926 SetLayerPropertiesForTesting(grand_child1, identity_matrix, gfx::Point3F(),
1907 gfx::PointF(5.f, 5.f), gfx::Size(10, 10), true, 1927 gfx::PointF(5.f, 5.f), gfx::Size(10, 10), true,
1908 false, false); 1928 false, false);
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after
2200 LayerImpl* parent = root_layer(); 2220 LayerImpl* parent = root_layer();
2201 LayerImpl* render_surface1 = AddChildToRoot<LayerImpl>(); 2221 LayerImpl* render_surface1 = AddChildToRoot<LayerImpl>();
2202 LayerImpl* child_of_rs1 = AddChild<LayerImpl>(render_surface1); 2222 LayerImpl* child_of_rs1 = AddChild<LayerImpl>(render_surface1);
2203 LayerImpl* grand_child_of_rs1 = AddChild<LayerImpl>(child_of_rs1); 2223 LayerImpl* grand_child_of_rs1 = AddChild<LayerImpl>(child_of_rs1);
2204 LayerImpl* render_surface2 = AddChild<LayerImpl>(render_surface1); 2224 LayerImpl* render_surface2 = AddChild<LayerImpl>(render_surface1);
2205 LayerImpl* child_of_rs2 = AddChild<LayerImpl>(render_surface2); 2225 LayerImpl* child_of_rs2 = AddChild<LayerImpl>(render_surface2);
2206 LayerImpl* grand_child_of_rs2 = AddChild<LayerImpl>(child_of_rs2); 2226 LayerImpl* grand_child_of_rs2 = AddChild<LayerImpl>(child_of_rs2);
2207 LayerImpl* child_of_root = AddChildToRoot<LayerImpl>(); 2227 LayerImpl* child_of_root = AddChildToRoot<LayerImpl>();
2208 LayerImpl* grand_child_of_root = AddChild<LayerImpl>(child_of_root); 2228 LayerImpl* grand_child_of_root = AddChild<LayerImpl>(child_of_root);
2209 2229
2230 parent->SetDrawsContent(true);
2231 render_surface1->SetDrawsContent(true);
2232 child_of_rs1->SetDrawsContent(true);
2210 grand_child_of_rs1->SetDrawsContent(true); 2233 grand_child_of_rs1->SetDrawsContent(true);
2234 render_surface2->SetDrawsContent(true);
2235 child_of_rs2->SetDrawsContent(true);
2211 grand_child_of_rs2->SetDrawsContent(true); 2236 grand_child_of_rs2->SetDrawsContent(true);
2237 child_of_root->SetDrawsContent(true);
2238 grand_child_of_root->SetDrawsContent(true);
2212 2239
2213 gfx::Transform layer_transform; 2240 gfx::Transform layer_transform;
2214 layer_transform.Translate(1.0, 1.0); 2241 layer_transform.Translate(1.0, 1.0);
2215 2242
2216 SetLayerPropertiesForTesting( 2243 SetLayerPropertiesForTesting(
2217 parent, layer_transform, gfx::Point3F(0.25f, 0.f, 0.f), 2244 parent, layer_transform, gfx::Point3F(0.25f, 0.f, 0.f),
2218 gfx::PointF(2.5f, 0.f), gfx::Size(10, 10), true, false, true); 2245 gfx::PointF(2.5f, 0.f), gfx::Size(10, 10), true, false, true);
2219 SetLayerPropertiesForTesting( 2246 SetLayerPropertiesForTesting(
2220 render_surface1, layer_transform, gfx::Point3F(0.25f, 0.f, 0.f), 2247 render_surface1, layer_transform, gfx::Point3F(0.25f, 0.f, 0.f),
2221 gfx::PointF(2.5f, 0.f), gfx::Size(10, 10), true, false, true); 2248 gfx::PointF(2.5f, 0.f), gfx::Size(10, 10), true, false, true);
(...skipping 500 matching lines...) Expand 10 before | Expand all | Expand 10 after
2722 gfx::PointF(75.f, 75.f), gfx::Size(50, 50), true, 2749 gfx::PointF(75.f, 75.f), gfx::Size(50, 50), true,
2723 false, false); 2750 false, false);
2724 SetLayerPropertiesForTesting(child3_layer, identity_matrix, gfx::Point3F(), 2751 SetLayerPropertiesForTesting(child3_layer, identity_matrix, gfx::Point3F(),
2725 gfx::PointF(125.f, 125.f), gfx::Size(50, 50), 2752 gfx::PointF(125.f, 125.f), gfx::Size(50, 50),
2726 true, false, false); 2753 true, false, false);
2727 2754
2728 ExecuteCalculateDrawProperties(root); 2755 ExecuteCalculateDrawProperties(root);
2729 2756
2730 EXPECT_EQ(gfx::RectF(100.f, 100.f), 2757 EXPECT_EQ(gfx::RectF(100.f, 100.f),
2731 root->render_surface()->DrawableContentRect()); 2758 root->render_surface()->DrawableContentRect());
2732 EXPECT_EQ(gfx::Rect(100, 100), root->drawable_content_rect());
2733 2759
2734 // Layers that do not draw content should have empty visible_layer_rects. 2760 // Layers that do not draw content should have empty visible_layer_rects.
2735 EXPECT_EQ(gfx::Rect(0, 0, 0, 0), root->visible_layer_rect()); 2761 EXPECT_EQ(gfx::Rect(0, 0, 0, 0), root->visible_layer_rect());
2736 2762
2737 // layer visible_layer_rects are clipped by their target surface. 2763 // layer visible_layer_rects are clipped by their target surface.
2738 EXPECT_EQ(gfx::Rect(0, 0, 50, 50), child1_layer->visible_layer_rect()); 2764 EXPECT_EQ(gfx::Rect(0, 0, 50, 50), child1_layer->visible_layer_rect());
2739 EXPECT_EQ(gfx::Rect(0, 0, 25, 25), child2_layer->visible_layer_rect()); 2765 EXPECT_EQ(gfx::Rect(0, 0, 25, 25), child2_layer->visible_layer_rect());
2740 EXPECT_TRUE(child3_layer->visible_layer_rect().IsEmpty()); 2766 EXPECT_TRUE(child3_layer->visible_layer_rect().IsEmpty());
2741 2767
2742 // layer drawable_content_rects are not clipped. 2768 // layer drawable_content_rects are not clipped.
(...skipping 28 matching lines...) Expand all
2771 false, false); 2797 false, false);
2772 SetLayerPropertiesForTesting(grand_child3, identity_matrix, gfx::Point3F(), 2798 SetLayerPropertiesForTesting(grand_child3, identity_matrix, gfx::Point3F(),
2773 gfx::PointF(125.f, 125.f), gfx::Size(50, 50), 2799 gfx::PointF(125.f, 125.f), gfx::Size(50, 50),
2774 true, false, false); 2800 true, false, false);
2775 2801
2776 child->SetMasksToBounds(true); 2802 child->SetMasksToBounds(true);
2777 ExecuteCalculateDrawProperties(root); 2803 ExecuteCalculateDrawProperties(root);
2778 2804
2779 EXPECT_EQ(gfx::RectF(100.f, 100.f), 2805 EXPECT_EQ(gfx::RectF(100.f, 100.f),
2780 root->render_surface()->DrawableContentRect()); 2806 root->render_surface()->DrawableContentRect());
2781 EXPECT_EQ(gfx::Rect(100, 100), root->drawable_content_rect());
2782 2807
2783 // Layers that do not draw content should have empty visible content rects. 2808 // Layers that do not draw content should have empty visible content rects.
2784 EXPECT_EQ(gfx::Rect(0, 0, 0, 0), root->visible_layer_rect()); 2809 EXPECT_EQ(gfx::Rect(0, 0, 0, 0), root->visible_layer_rect());
2785 EXPECT_EQ(gfx::Rect(0, 0, 0, 0), child->visible_layer_rect()); 2810 EXPECT_EQ(gfx::Rect(0, 0, 0, 0), child->visible_layer_rect());
2786 2811
2787 // All grandchild visible content rects should be clipped by child. 2812 // All grandchild visible content rects should be clipped by child.
2788 EXPECT_EQ(gfx::Rect(0, 0, 50, 50), grand_child1->visible_layer_rect()); 2813 EXPECT_EQ(gfx::Rect(0, 0, 50, 50), grand_child1->visible_layer_rect());
2789 EXPECT_EQ(gfx::Rect(0, 0, 25, 25), grand_child2->visible_layer_rect()); 2814 EXPECT_EQ(gfx::Rect(0, 0, 25, 25), grand_child2->visible_layer_rect());
2790 EXPECT_TRUE(grand_child3->visible_layer_rect().IsEmpty()); 2815 EXPECT_TRUE(grand_child3->visible_layer_rect().IsEmpty());
2791 2816
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
2854 SetLayerPropertiesForTesting(child3, identity_matrix, gfx::Point3F(), 2879 SetLayerPropertiesForTesting(child3, identity_matrix, gfx::Point3F(),
2855 gfx::PointF(125.f, 125.f), gfx::Size(50, 50), 2880 gfx::PointF(125.f, 125.f), gfx::Size(50, 50),
2856 true, false, false); 2881 true, false, false);
2857 2882
2858 ExecuteCalculateDrawProperties(root); 2883 ExecuteCalculateDrawProperties(root);
2859 2884
2860 ASSERT_TRUE(render_surface->render_surface()); 2885 ASSERT_TRUE(render_surface->render_surface());
2861 2886
2862 EXPECT_EQ(gfx::RectF(100.f, 100.f), 2887 EXPECT_EQ(gfx::RectF(100.f, 100.f),
2863 root->render_surface()->DrawableContentRect()); 2888 root->render_surface()->DrawableContentRect());
2864 EXPECT_EQ(gfx::Rect(100, 100), root->drawable_content_rect());
2865 2889
2866 // Layers that do not draw content should have empty visible content rects. 2890 // Layers that do not draw content should have empty visible content rects.
2867 EXPECT_EQ(gfx::Rect(0, 0, 0, 0), root->visible_layer_rect()); 2891 EXPECT_EQ(gfx::Rect(0, 0, 0, 0), root->visible_layer_rect());
2868 EXPECT_EQ(gfx::Rect(0, 0, 0, 0), render_surface->visible_layer_rect()); 2892 EXPECT_EQ(gfx::Rect(0, 0, 0, 0), render_surface->visible_layer_rect());
2869 2893
2870 // An unclipped surface grows its DrawableContentRect to include all drawable 2894 // An unclipped surface grows its DrawableContentRect to include all drawable
2871 // regions of the subtree. 2895 // regions of the subtree.
2872 EXPECT_EQ(gfx::RectF(5.f, 5.f, 170.f, 170.f), 2896 EXPECT_EQ(gfx::RectF(5.f, 5.f, 170.f, 170.f),
2873 render_surface->render_surface()->DrawableContentRect()); 2897 render_surface->render_surface()->DrawableContentRect());
2874 2898
(...skipping 506 matching lines...) Expand 10 before | Expand all | Expand 10 after
3381 true, false, false); 3405 true, false, false);
3382 3406
3383 root->SetMasksToBounds(true); 3407 root->SetMasksToBounds(true);
3384 3408
3385 ExecuteCalculateDrawProperties(root); 3409 ExecuteCalculateDrawProperties(root);
3386 3410
3387 ASSERT_TRUE(render_surface->render_surface()); 3411 ASSERT_TRUE(render_surface->render_surface());
3388 3412
3389 EXPECT_EQ(gfx::RectF(100.f, 100.f), 3413 EXPECT_EQ(gfx::RectF(100.f, 100.f),
3390 root->render_surface()->DrawableContentRect()); 3414 root->render_surface()->DrawableContentRect());
3391 EXPECT_EQ(gfx::Rect(100, 100), root->drawable_content_rect());
3392 3415
3393 // Layers that do not draw content should have empty visible content rects. 3416 // Layers that do not draw content should have empty visible content rects.
3394 EXPECT_EQ(gfx::Rect(0, 0, 0, 0), root->visible_layer_rect()); 3417 EXPECT_EQ(gfx::Rect(0, 0, 0, 0), root->visible_layer_rect());
3395 EXPECT_EQ(gfx::Rect(0, 0, 0, 0), render_surface->visible_layer_rect()); 3418 EXPECT_EQ(gfx::Rect(0, 0, 0, 0), render_surface->visible_layer_rect());
3396 3419
3397 // A clipped surface grows its DrawableContentRect to include all drawable 3420 // A clipped surface grows its DrawableContentRect to include all drawable
3398 // regions of the subtree, but also gets clamped by the ancestor's clip. 3421 // regions of the subtree, but also gets clamped by the ancestor's clip.
3399 EXPECT_EQ(gfx::RectF(5.f, 5.f, 95.f, 95.f), 3422 EXPECT_EQ(gfx::RectF(5.f, 5.f, 95.f, 95.f),
3400 render_surface->render_surface()->DrawableContentRect()); 3423 render_surface->render_surface()->DrawableContentRect());
3401 3424
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
3446 3469
3447 root->SetMasksToBounds(true); 3470 root->SetMasksToBounds(true);
3448 3471
3449 ExecuteCalculateDrawProperties(root); 3472 ExecuteCalculateDrawProperties(root);
3450 3473
3451 ASSERT_TRUE(render_surface1->render_surface()); 3474 ASSERT_TRUE(render_surface1->render_surface());
3452 ASSERT_TRUE(render_surface2->render_surface()); 3475 ASSERT_TRUE(render_surface2->render_surface());
3453 3476
3454 EXPECT_EQ(gfx::RectF(100.f, 100.f), 3477 EXPECT_EQ(gfx::RectF(100.f, 100.f),
3455 root->render_surface()->DrawableContentRect()); 3478 root->render_surface()->DrawableContentRect());
3456 EXPECT_EQ(gfx::Rect(100, 100), root->drawable_content_rect());
3457 3479
3458 // Layers that do not draw content should have empty visible content rects. 3480 // Layers that do not draw content should have empty visible content rects.
3459 EXPECT_EQ(gfx::Rect(0, 0, 0, 0), root->visible_layer_rect()); 3481 EXPECT_EQ(gfx::Rect(0, 0, 0, 0), root->visible_layer_rect());
3460 EXPECT_EQ(gfx::Rect(0, 0, 0, 0), render_surface1->visible_layer_rect()); 3482 EXPECT_EQ(gfx::Rect(0, 0, 0, 0), render_surface1->visible_layer_rect());
3461 EXPECT_EQ(gfx::Rect(0, 0, 0, 0), render_surface2->visible_layer_rect()); 3483 EXPECT_EQ(gfx::Rect(0, 0, 0, 0), render_surface2->visible_layer_rect());
3462 3484
3463 // A clipped surface grows its DrawableContentRect to include all drawable 3485 // A clipped surface grows its DrawableContentRect to include all drawable
3464 // regions of the subtree, but also gets clamped by the ancestor's clip. 3486 // regions of the subtree, but also gets clamped by the ancestor's clip.
3465 EXPECT_EQ(gfx::RectF(5.f, 5.f, 95.f, 95.f), 3487 EXPECT_EQ(gfx::RectF(5.f, 5.f, 95.f, 95.f),
3466 render_surface1->render_surface()->DrawableContentRect()); 3488 render_surface1->render_surface()->DrawableContentRect());
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after
3739 SetLayerPropertiesForTesting( 3761 SetLayerPropertiesForTesting(
3740 child1, child_rotation, gfx::Point3F(25, 25, 0.f), 3762 child1, child_rotation, gfx::Point3F(25, 25, 0.f),
3741 gfx::PointF(25.f, 25.f), gfx::Size(50, 50), true, false, false); 3763 gfx::PointF(25.f, 25.f), gfx::Size(50, 50), true, false, false);
3742 3764
3743 ExecuteCalculateDrawProperties(root); 3765 ExecuteCalculateDrawProperties(root);
3744 3766
3745 ASSERT_TRUE(render_surface->render_surface()); 3767 ASSERT_TRUE(render_surface->render_surface());
3746 3768
3747 EXPECT_EQ(gfx::RectF(100.f, 100.f), 3769 EXPECT_EQ(gfx::RectF(100.f, 100.f),
3748 root->render_surface()->DrawableContentRect()); 3770 root->render_surface()->DrawableContentRect());
3749 EXPECT_EQ(gfx::Rect(0, 0, 100, 100), root->drawable_content_rect());
3750 3771
3751 // Layers that do not draw content should have empty visible content rects. 3772 // Layers that do not draw content should have empty visible content rects.
3752 EXPECT_EQ(gfx::Rect(0, 0, 0, 0), root->visible_layer_rect()); 3773 EXPECT_EQ(gfx::Rect(0, 0, 0, 0), root->visible_layer_rect());
3753 EXPECT_EQ(gfx::Rect(0, 0, 0, 0), render_surface->visible_layer_rect()); 3774 EXPECT_EQ(gfx::Rect(0, 0, 0, 0), render_surface->visible_layer_rect());
3754 3775
3755 // The unclipped surface grows its DrawableContentRect to include all drawable 3776 // The unclipped surface grows its DrawableContentRect to include all drawable
3756 // regions of the subtree. 3777 // regions of the subtree.
3757 int diagonal_radius = ceil(sqrt(2.0) * 25.0); 3778 int diagonal_radius = ceil(sqrt(2.0) * 25.0);
3758 gfx::Rect expected_surface_drawable_content = 3779 gfx::Rect expected_surface_drawable_content =
3759 gfx::Rect(50 - diagonal_radius, 3780 gfx::Rect(50 - diagonal_radius,
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
3864 3885
3865 ExecuteCalculateDrawProperties(root, device_scale_factor); 3886 ExecuteCalculateDrawProperties(root, device_scale_factor);
3866 3887
3867 ASSERT_TRUE(render_surface1->render_surface()); 3888 ASSERT_TRUE(render_surface1->render_surface());
3868 ASSERT_TRUE(render_surface2->render_surface()); 3889 ASSERT_TRUE(render_surface2->render_surface());
3869 3890
3870 // drawable_content_rects for all layers and surfaces are scaled by 3891 // drawable_content_rects for all layers and surfaces are scaled by
3871 // device_scale_factor. 3892 // device_scale_factor.
3872 EXPECT_EQ(gfx::RectF(200.f, 200.f), 3893 EXPECT_EQ(gfx::RectF(200.f, 200.f),
3873 root->render_surface()->DrawableContentRect()); 3894 root->render_surface()->DrawableContentRect());
3874 EXPECT_EQ(gfx::Rect(0, 0, 200, 200), root->drawable_content_rect());
3875 EXPECT_EQ(gfx::RectF(10.f, 10.f, 190.f, 190.f), 3895 EXPECT_EQ(gfx::RectF(10.f, 10.f, 190.f, 190.f),
3876 render_surface1->render_surface()->DrawableContentRect()); 3896 render_surface1->render_surface()->DrawableContentRect());
3877 3897
3878 // render_surface2 lives in the "unclipped universe" of render_surface1, and 3898 // render_surface2 lives in the "unclipped universe" of render_surface1, and
3879 // is only implicitly clipped by render_surface1. 3899 // is only implicitly clipped by render_surface1.
3880 EXPECT_EQ(gfx::RectF(10.f, 10.f, 350.f, 350.f), 3900 EXPECT_EQ(gfx::RectF(10.f, 10.f, 350.f, 350.f),
3881 render_surface2->render_surface()->DrawableContentRect()); 3901 render_surface2->render_surface()->DrawableContentRect());
3882 3902
3883 EXPECT_EQ(gfx::Rect(10, 10, 100, 100), child1->drawable_content_rect()); 3903 EXPECT_EQ(gfx::Rect(10, 10, 100, 100), child1->drawable_content_rect());
3884 EXPECT_EQ(gfx::Rect(150, 150, 100, 100), child2->drawable_content_rect()); 3904 EXPECT_EQ(gfx::Rect(150, 150, 100, 100), child2->drawable_content_rect());
(...skipping 526 matching lines...) Expand 10 before | Expand all | Expand 10 after
4411 EXPECT_EQ(2u, update_layer_list().size()); 4431 EXPECT_EQ(2u, update_layer_list().size());
4412 EXPECT_TRUE(UpdateLayerListContains(front_facing_surface->id())); 4432 EXPECT_TRUE(UpdateLayerListContains(front_facing_surface->id()));
4413 EXPECT_TRUE(UpdateLayerListContains(child1->id())); 4433 EXPECT_TRUE(UpdateLayerListContains(child1->id()));
4414 } 4434 }
4415 4435
4416 TEST_F(LayerTreeHostCommonScalingTest, LayerTransformsInHighDPI) { 4436 TEST_F(LayerTreeHostCommonScalingTest, LayerTransformsInHighDPI) {
4417 // Verify draw and screen space transforms of layers not in a surface. 4437 // Verify draw and screen space transforms of layers not in a surface.
4418 gfx::Transform identity_matrix; 4438 gfx::Transform identity_matrix;
4419 4439
4420 LayerImpl* parent = root_layer(); 4440 LayerImpl* parent = root_layer();
4441 parent->SetDrawsContent(true);
4421 SetLayerPropertiesForTesting(parent, identity_matrix, gfx::Point3F(), 4442 SetLayerPropertiesForTesting(parent, identity_matrix, gfx::Point3F(),
4422 gfx::PointF(), gfx::Size(100, 100), false, true, 4443 gfx::PointF(), gfx::Size(100, 100), false, true,
4423 true); 4444 true);
4424 4445
4425 LayerImpl* child = AddChildToRoot<LayerImpl>(); 4446 LayerImpl* child = AddChildToRoot<LayerImpl>();
4447 child->SetDrawsContent(true);
4426 SetLayerPropertiesForTesting(child, identity_matrix, gfx::Point3F(), 4448 SetLayerPropertiesForTesting(child, identity_matrix, gfx::Point3F(),
4427 gfx::PointF(2.f, 2.f), gfx::Size(10, 10), false, 4449 gfx::PointF(2.f, 2.f), gfx::Size(10, 10), false,
4428 true, false); 4450 true, false);
4429 4451
4430 LayerImpl* child_empty = AddChildToRoot<LayerImpl>(); 4452 LayerImpl* child2 = AddChildToRoot<LayerImpl>();
4431 SetLayerPropertiesForTesting(child_empty, identity_matrix, gfx::Point3F(), 4453 child2->SetDrawsContent(true);
4432 gfx::PointF(2.f, 2.f), gfx::Size(), false, true, 4454 SetLayerPropertiesForTesting(child2, identity_matrix, gfx::Point3F(),
4433 false); 4455 gfx::PointF(2.f, 2.f), gfx::Size(5, 5), false,
4456 true, false);
4434 4457
4435 float device_scale_factor = 2.5f; 4458 float device_scale_factor = 2.5f;
4436 gfx::Size viewport_size(100, 100); 4459 gfx::Size viewport_size(100, 100);
4437 ExecuteCalculateDrawProperties(parent, device_scale_factor); 4460 ExecuteCalculateDrawProperties(parent, device_scale_factor);
4438 4461
4439 EXPECT_IDEAL_SCALE_EQ(device_scale_factor, parent); 4462 EXPECT_IDEAL_SCALE_EQ(device_scale_factor, parent);
4440 EXPECT_IDEAL_SCALE_EQ(device_scale_factor, child); 4463 EXPECT_IDEAL_SCALE_EQ(device_scale_factor, child);
4441 EXPECT_IDEAL_SCALE_EQ(device_scale_factor, child_empty); 4464 EXPECT_IDEAL_SCALE_EQ(device_scale_factor, child2);
4442 4465
4443 EXPECT_EQ(1u, render_surface_layer_list_impl()->size()); 4466 EXPECT_EQ(1u, render_surface_layer_list_impl()->size());
4444 4467
4445 // Verify parent transforms 4468 // Verify parent transforms
4446 gfx::Transform expected_parent_transform; 4469 gfx::Transform expected_parent_transform;
4447 expected_parent_transform.Scale(device_scale_factor, device_scale_factor); 4470 expected_parent_transform.Scale(device_scale_factor, device_scale_factor);
4448 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_parent_transform, 4471 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_parent_transform,
4449 parent->screen_space_transform()); 4472 parent->screen_space_transform());
4450 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_parent_transform, 4473 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_parent_transform,
4451 parent->draw_transform()); 4474 parent->draw_transform());
4452 4475
4453 // Verify results of transformed parent rects 4476 // Verify results of transformed parent rects
4454 gfx::RectF parent_bounds(gfx::SizeF(parent->bounds())); 4477 gfx::RectF parent_bounds(gfx::SizeF(parent->bounds()));
4455 4478
4456 gfx::RectF parent_draw_rect = 4479 gfx::RectF parent_draw_rect =
4457 MathUtil::MapClippedRect(parent->draw_transform(), parent_bounds); 4480 MathUtil::MapClippedRect(parent->draw_transform(), parent_bounds);
4458 gfx::RectF parent_screen_space_rect = 4481 gfx::RectF parent_screen_space_rect =
4459 MathUtil::MapClippedRect(parent->screen_space_transform(), parent_bounds); 4482 MathUtil::MapClippedRect(parent->screen_space_transform(), parent_bounds);
4460 4483
4461 gfx::RectF expected_parent_draw_rect(gfx::SizeF(parent->bounds())); 4484 gfx::RectF expected_parent_draw_rect(gfx::SizeF(parent->bounds()));
4462 expected_parent_draw_rect.Scale(device_scale_factor); 4485 expected_parent_draw_rect.Scale(device_scale_factor);
4463 EXPECT_FLOAT_RECT_EQ(expected_parent_draw_rect, parent_draw_rect); 4486 EXPECT_FLOAT_RECT_EQ(expected_parent_draw_rect, parent_draw_rect);
4464 EXPECT_FLOAT_RECT_EQ(expected_parent_draw_rect, parent_screen_space_rect); 4487 EXPECT_FLOAT_RECT_EQ(expected_parent_draw_rect, parent_screen_space_rect);
4465 4488
4466 // Verify child and child_empty transforms. They should match. 4489 // Verify child and child2 transforms. They should match.
4467 gfx::Transform expected_child_transform; 4490 gfx::Transform expected_child_transform;
4468 expected_child_transform.Scale(device_scale_factor, device_scale_factor); 4491 expected_child_transform.Scale(device_scale_factor, device_scale_factor);
4469 expected_child_transform.Translate(child->position().x(), 4492 expected_child_transform.Translate(child->position().x(),
4470 child->position().y()); 4493 child->position().y());
4471 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_child_transform, 4494 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_child_transform,
4472 child->draw_transform()); 4495 child->draw_transform());
4473 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_child_transform, 4496 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_child_transform,
4474 child->screen_space_transform()); 4497 child->screen_space_transform());
4475 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_child_transform, 4498 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_child_transform,
4476 child_empty->draw_transform()); 4499 child2->draw_transform());
4477 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_child_transform, 4500 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_child_transform,
4478 child_empty->screen_space_transform()); 4501 child2->screen_space_transform());
4479 4502
4480 // Verify results of transformed child and child_empty rects. They should 4503 // Verify results of transformed child and child2 rects. They should
4481 // match. 4504 // match.
4482 gfx::RectF child_bounds(gfx::SizeF(child->bounds())); 4505 gfx::RectF child_bounds(gfx::SizeF(child->bounds()));
4483 4506
4484 gfx::RectF child_draw_rect = 4507 gfx::RectF child_draw_rect =
4485 MathUtil::MapClippedRect(child->draw_transform(), child_bounds); 4508 MathUtil::MapClippedRect(child->draw_transform(), child_bounds);
4486 gfx::RectF child_screen_space_rect = 4509 gfx::RectF child_screen_space_rect =
4487 MathUtil::MapClippedRect(child->screen_space_transform(), child_bounds); 4510 MathUtil::MapClippedRect(child->screen_space_transform(), child_bounds);
4488 4511
4489 gfx::RectF child_empty_draw_rect = 4512 gfx::RectF child2_draw_rect =
4490 MathUtil::MapClippedRect(child_empty->draw_transform(), child_bounds); 4513 MathUtil::MapClippedRect(child2->draw_transform(), child_bounds);
4491 gfx::RectF child_empty_screen_space_rect = MathUtil::MapClippedRect( 4514 gfx::RectF child2_screen_space_rect =
4492 child_empty->screen_space_transform(), child_bounds); 4515 MathUtil::MapClippedRect(child2->screen_space_transform(), child_bounds);
4493 4516
4494 gfx::RectF expected_child_draw_rect(child->position(), 4517 gfx::RectF expected_child_draw_rect(child->position(),
4495 gfx::SizeF(child->bounds())); 4518 gfx::SizeF(child->bounds()));
4496 expected_child_draw_rect.Scale(device_scale_factor); 4519 expected_child_draw_rect.Scale(device_scale_factor);
4497 EXPECT_FLOAT_RECT_EQ(expected_child_draw_rect, child_draw_rect); 4520 EXPECT_FLOAT_RECT_EQ(expected_child_draw_rect, child_draw_rect);
4498 EXPECT_FLOAT_RECT_EQ(expected_child_draw_rect, child_screen_space_rect); 4521 EXPECT_FLOAT_RECT_EQ(expected_child_draw_rect, child_screen_space_rect);
4499 EXPECT_FLOAT_RECT_EQ(expected_child_draw_rect, child_empty_draw_rect); 4522 EXPECT_FLOAT_RECT_EQ(expected_child_draw_rect, child2_draw_rect);
4500 EXPECT_FLOAT_RECT_EQ(expected_child_draw_rect, child_empty_screen_space_rect); 4523 EXPECT_FLOAT_RECT_EQ(expected_child_draw_rect, child2_screen_space_rect);
4501 } 4524 }
4502 4525
4503 TEST_F(LayerTreeHostCommonScalingTest, SurfaceLayerTransformsInHighDPI) { 4526 TEST_F(LayerTreeHostCommonScalingTest, SurfaceLayerTransformsInHighDPI) {
4504 // Verify draw and screen space transforms of layers in a surface. 4527 // Verify draw and screen space transforms of layers in a surface.
4505 gfx::Transform identity_matrix; 4528 gfx::Transform identity_matrix;
4506 gfx::Transform perspective_matrix; 4529 gfx::Transform perspective_matrix;
4507 perspective_matrix.ApplyPerspectiveDepth(2.0); 4530 perspective_matrix.ApplyPerspectiveDepth(2.0);
4508 4531
4509 gfx::Transform scale_small_matrix; 4532 gfx::Transform scale_small_matrix;
4510 scale_small_matrix.Scale(SK_MScalar1 / 10.f, SK_MScalar1 / 12.f); 4533 scale_small_matrix.Scale(SK_MScalar1 / 10.f, SK_MScalar1 / 12.f);
4511 4534
4512 LayerImpl* root = root_layer(); 4535 LayerImpl* root = root_layer();
4513 SetLayerPropertiesForTesting(root, identity_matrix, gfx::Point3F(), 4536 SetLayerPropertiesForTesting(root, identity_matrix, gfx::Point3F(),
4514 gfx::PointF(), gfx::Size(100, 100), false, true, 4537 gfx::PointF(), gfx::Size(100, 100), false, true,
4515 false); 4538 false);
4516 LayerImpl* parent = AddChildToRoot<LayerImpl>(); 4539 LayerImpl* parent = AddChildToRoot<LayerImpl>();
4540 parent->SetDrawsContent(true);
4517 SetLayerPropertiesForTesting(parent, identity_matrix, gfx::Point3F(), 4541 SetLayerPropertiesForTesting(parent, identity_matrix, gfx::Point3F(),
4518 gfx::PointF(), gfx::Size(100, 100), false, true, 4542 gfx::PointF(), gfx::Size(100, 100), false, true,
4519 false); 4543 false);
4520 4544
4521 LayerImpl* perspective_surface = AddChild<LayerImpl>(parent); 4545 LayerImpl* perspective_surface = AddChild<LayerImpl>(parent);
4522 SetLayerPropertiesForTesting(perspective_surface, 4546 SetLayerPropertiesForTesting(perspective_surface,
4523 perspective_matrix * scale_small_matrix, 4547 perspective_matrix * scale_small_matrix,
4524 gfx::Point3F(), gfx::PointF(2.f, 2.f), 4548 gfx::Point3F(), gfx::PointF(2.f, 2.f),
4525 gfx::Size(10, 10), false, true, true); 4549 gfx::Size(10, 10), false, true, true);
4526 perspective_surface->SetDrawsContent(true); 4550 perspective_surface->SetDrawsContent(true);
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
4597 parent_scale_matrix.Scale(initial_parent_scale, initial_parent_scale); 4621 parent_scale_matrix.Scale(initial_parent_scale, initial_parent_scale);
4598 4622
4599 gfx::Transform child_scale_matrix; 4623 gfx::Transform child_scale_matrix;
4600 SkMScalar initial_child_scale = 0.25; 4624 SkMScalar initial_child_scale = 0.25;
4601 child_scale_matrix.Scale(initial_child_scale, initial_child_scale); 4625 child_scale_matrix.Scale(initial_child_scale, initial_child_scale);
4602 4626
4603 LayerImpl* root = root_layer(); 4627 LayerImpl* root = root_layer();
4604 root->SetBounds(gfx::Size(100, 100)); 4628 root->SetBounds(gfx::Size(100, 100));
4605 4629
4606 LayerImpl* parent = AddChildToRoot<LayerImpl>(); 4630 LayerImpl* parent = AddChildToRoot<LayerImpl>();
4631 parent->SetDrawsContent(true);
4607 SetLayerPropertiesForTesting(parent, parent_scale_matrix, gfx::Point3F(), 4632 SetLayerPropertiesForTesting(parent, parent_scale_matrix, gfx::Point3F(),
4608 gfx::PointF(), gfx::Size(100, 100), false, true, 4633 gfx::PointF(), gfx::Size(100, 100), false, true,
4609 false); 4634 false);
4610 4635
4611 LayerImpl* child_scale = AddChild<LayerImpl>(parent); 4636 LayerImpl* child_scale = AddChild<LayerImpl>(parent);
4637 child_scale->SetDrawsContent(true);
4612 SetLayerPropertiesForTesting(child_scale, child_scale_matrix, gfx::Point3F(), 4638 SetLayerPropertiesForTesting(child_scale, child_scale_matrix, gfx::Point3F(),
4613 gfx::PointF(2.f, 2.f), gfx::Size(10, 10), false, 4639 gfx::PointF(2.f, 2.f), gfx::Size(10, 10), false,
4614 true, false); 4640 true, false);
4615 4641
4616 float device_scale_factor = 2.5f; 4642 float device_scale_factor = 2.5f;
4617 float page_scale_factor = 0.01f; 4643 float page_scale_factor = 0.01f;
4618 4644
4619 { 4645 {
4620 ExecuteCalculateDrawProperties(root, device_scale_factor, page_scale_factor, 4646 ExecuteCalculateDrawProperties(root, device_scale_factor, page_scale_factor,
4621 root); 4647 root);
(...skipping 17 matching lines...) Expand all
4639 parent_scale_matrix.Scale(initial_parent_scale, initial_parent_scale); 4665 parent_scale_matrix.Scale(initial_parent_scale, initial_parent_scale);
4640 4666
4641 gfx::Transform child_scale_matrix; 4667 gfx::Transform child_scale_matrix;
4642 SkMScalar initial_child_scale = 1.25; 4668 SkMScalar initial_child_scale = 1.25;
4643 child_scale_matrix.Scale(initial_child_scale, initial_child_scale); 4669 child_scale_matrix.Scale(initial_child_scale, initial_child_scale);
4644 4670
4645 LayerImpl* root = root_layer(); 4671 LayerImpl* root = root_layer();
4646 root->SetBounds(gfx::Size(100, 100)); 4672 root->SetBounds(gfx::Size(100, 100));
4647 4673
4648 LayerImpl* parent = AddChildToRoot<LayerImpl>(); 4674 LayerImpl* parent = AddChildToRoot<LayerImpl>();
4675 parent->SetDrawsContent(true);
4649 SetLayerPropertiesForTesting(parent, parent_scale_matrix, gfx::Point3F(), 4676 SetLayerPropertiesForTesting(parent, parent_scale_matrix, gfx::Point3F(),
4650 gfx::PointF(), gfx::Size(100, 100), false, true, 4677 gfx::PointF(), gfx::Size(100, 100), false, true,
4651 false); 4678 false);
4652 4679
4653 LayerImpl* child_scale = AddChild<LayerImpl>(parent); 4680 LayerImpl* child_scale = AddChild<LayerImpl>(parent);
4681 child_scale->SetDrawsContent(true);
4654 SetLayerPropertiesForTesting(child_scale, child_scale_matrix, gfx::Point3F(), 4682 SetLayerPropertiesForTesting(child_scale, child_scale_matrix, gfx::Point3F(),
4655 gfx::PointF(2.f, 2.f), gfx::Size(10, 10), false, 4683 gfx::PointF(2.f, 2.f), gfx::Size(10, 10), false,
4656 true, false); 4684 true, false);
4657 4685
4658 { 4686 {
4659 ExecuteCalculateDrawProperties(root); 4687 ExecuteCalculateDrawProperties(root);
4660 4688
4661 EXPECT_IDEAL_SCALE_EQ(initial_parent_scale, parent); 4689 EXPECT_IDEAL_SCALE_EQ(initial_parent_scale, parent);
4662 // Animating layers compute ideal scale in the same way as when 4690 // Animating layers compute ideal scale in the same way as when
4663 // they are static. 4691 // they are static.
(...skipping 935 matching lines...) Expand 10 before | Expand all | Expand 10 after
5599 // + intervening (masks to bounds) 5627 // + intervening (masks to bounds)
5600 // + render_surface2 (also sets opacity) 5628 // + render_surface2 (also sets opacity)
5601 // + clip_child 5629 // + clip_child
5602 // 5630 //
5603 LayerImpl* root = root_layer(); 5631 LayerImpl* root = root_layer();
5604 LayerImpl* clip_parent = AddChildToRoot<LayerImpl>(); 5632 LayerImpl* clip_parent = AddChildToRoot<LayerImpl>();
5605 LayerImpl* render_surface1 = AddChild<LayerImpl>(clip_parent); 5633 LayerImpl* render_surface1 = AddChild<LayerImpl>(clip_parent);
5606 LayerImpl* intervening = AddChild<LayerImpl>(render_surface1); 5634 LayerImpl* intervening = AddChild<LayerImpl>(render_surface1);
5607 LayerImpl* render_surface2 = AddChild<LayerImpl>(intervening); 5635 LayerImpl* render_surface2 = AddChild<LayerImpl>(intervening);
5608 LayerImpl* clip_child = AddChild<LayerImpl>(render_surface2); 5636 LayerImpl* clip_child = AddChild<LayerImpl>(render_surface2);
5637 render_surface1->SetDrawsContent(true);
5638 render_surface2->SetDrawsContent(true);
5609 clip_child->SetDrawsContent(true); 5639 clip_child->SetDrawsContent(true);
5610 5640
5611 clip_child->SetClipParent(clip_parent); 5641 clip_child->SetClipParent(clip_parent);
5612 5642
5613 intervening->SetMasksToBounds(true); 5643 intervening->SetMasksToBounds(true);
5614 clip_parent->SetMasksToBounds(true); 5644 clip_parent->SetMasksToBounds(true);
5615 5645
5616 gfx::Transform translation_transform; 5646 gfx::Transform translation_transform;
5617 translation_transform.Translate(2, 2); 5647 translation_transform.Translate(2, 2);
5618 5648
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
5690 // + intervening (masks to bounds AND scrolls) 5720 // + intervening (masks to bounds AND scrolls)
5691 // + render_surface2 (also sets opacity) 5721 // + render_surface2 (also sets opacity)
5692 // + clip_child 5722 // + clip_child
5693 // 5723 //
5694 LayerImpl* root = root_layer(); 5724 LayerImpl* root = root_layer();
5695 LayerImpl* clip_parent = AddChildToRoot<LayerImpl>(); 5725 LayerImpl* clip_parent = AddChildToRoot<LayerImpl>();
5696 LayerImpl* render_surface1 = AddChild<LayerImpl>(clip_parent); 5726 LayerImpl* render_surface1 = AddChild<LayerImpl>(clip_parent);
5697 LayerImpl* intervening = AddChild<LayerImpl>(render_surface1); 5727 LayerImpl* intervening = AddChild<LayerImpl>(render_surface1);
5698 LayerImpl* render_surface2 = AddChild<LayerImpl>(intervening); 5728 LayerImpl* render_surface2 = AddChild<LayerImpl>(intervening);
5699 LayerImpl* clip_child = AddChild<LayerImpl>(render_surface2); 5729 LayerImpl* clip_child = AddChild<LayerImpl>(render_surface2);
5730 render_surface1->SetDrawsContent(true);
5731 render_surface2->SetDrawsContent(true);
5700 clip_child->SetDrawsContent(true); 5732 clip_child->SetDrawsContent(true);
5701 5733
5702 clip_child->SetClipParent(clip_parent); 5734 clip_child->SetClipParent(clip_parent);
5703 5735
5704 intervening->SetMasksToBounds(true); 5736 intervening->SetMasksToBounds(true);
5705 clip_parent->SetMasksToBounds(true); 5737 clip_parent->SetMasksToBounds(true);
5706 intervening->SetScrollClipLayer(clip_parent->id()); 5738 intervening->SetScrollClipLayer(clip_parent->id());
5707 intervening->SetCurrentScrollOffset(gfx::ScrollOffset(3, 3)); 5739 intervening->SetCurrentScrollOffset(gfx::ScrollOffset(3, 3));
5708 5740
5709 gfx::Transform translation_transform; 5741 gfx::Transform translation_transform;
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
5779 // + clip_parent (masks to bounds) 5811 // + clip_parent (masks to bounds)
5780 // + intervening (masks to bounds) 5812 // + intervening (masks to bounds)
5781 // + clip_child 5813 // + clip_child
5782 // + child 5814 // + child
5783 // 5815 //
5784 LayerImpl* root = root_layer(); 5816 LayerImpl* root = root_layer();
5785 LayerImpl* clip_parent = AddChild<LayerImpl>(root); 5817 LayerImpl* clip_parent = AddChild<LayerImpl>(root);
5786 LayerImpl* intervening = AddChild<LayerImpl>(clip_parent); 5818 LayerImpl* intervening = AddChild<LayerImpl>(clip_parent);
5787 LayerImpl* clip_child = AddChild<LayerImpl>(intervening); 5819 LayerImpl* clip_child = AddChild<LayerImpl>(intervening);
5788 LayerImpl* child = AddChild<LayerImpl>(clip_child); 5820 LayerImpl* child = AddChild<LayerImpl>(clip_child);
5821 clip_child->SetDrawsContent(true);
5789 child->SetDrawsContent(true); 5822 child->SetDrawsContent(true);
5790 5823
5791 clip_child->SetClipParent(clip_parent); 5824 clip_child->SetClipParent(clip_parent);
5792 scoped_ptr<std::set<LayerImpl*>> clip_children(new std::set<LayerImpl*>); 5825 scoped_ptr<std::set<LayerImpl*>> clip_children(new std::set<LayerImpl*>);
5793 clip_children->insert(clip_child); 5826 clip_children->insert(clip_child);
5794 clip_parent->SetClipChildren(clip_children.release()); 5827 clip_parent->SetClipChildren(clip_children.release());
5795 5828
5796 intervening->SetMasksToBounds(true); 5829 intervening->SetMasksToBounds(true);
5797 clip_parent->SetMasksToBounds(true); 5830 clip_parent->SetMasksToBounds(true);
5798 5831
(...skipping 832 matching lines...) Expand 10 before | Expand all | Expand 10 after
6631 scoped_ptr<LayerImpl> scroller = 6664 scoped_ptr<LayerImpl> scroller =
6632 LayerImpl::Create(host_impl.active_tree(), 3); 6665 LayerImpl::Create(host_impl.active_tree(), 3);
6633 LayerImpl* scroll_layer = scroller.get(); 6666 LayerImpl* scroll_layer = scroller.get();
6634 scoped_ptr<LayerImpl> fixed = LayerImpl::Create(host_impl.active_tree(), 4); 6667 scoped_ptr<LayerImpl> fixed = LayerImpl::Create(host_impl.active_tree(), 4);
6635 LayerImpl* fixed_layer = fixed.get(); 6668 LayerImpl* fixed_layer = fixed.get();
6636 6669
6637 container->SetIsContainerForFixedPositionLayers(true); 6670 container->SetIsContainerForFixedPositionLayers(true);
6638 6671
6639 LayerPositionConstraint constraint; 6672 LayerPositionConstraint constraint;
6640 constraint.set_is_fixed_position(true); 6673 constraint.set_is_fixed_position(true);
6674 container->SetDrawsContent(true);
6675 fixed->SetDrawsContent(true);
6641 fixed->SetPositionConstraint(constraint); 6676 fixed->SetPositionConstraint(constraint);
6642 6677
6678 scroller->SetDrawsContent(true);
6643 scroller->SetScrollClipLayer(container->id()); 6679 scroller->SetScrollClipLayer(container->id());
6644 6680
6645 gfx::Transform identity_transform; 6681 gfx::Transform identity_transform;
6646 gfx::Transform container_transform; 6682 gfx::Transform container_transform;
6647 container_transform.Translate3d(10.0, 20.0, 0.0); 6683 container_transform.Translate3d(10.0, 20.0, 0.0);
6648 gfx::Vector2dF container_offset = container_transform.To2dTranslation(); 6684 gfx::Vector2dF container_offset = container_transform.To2dTranslation();
6649 6685
6650 SetLayerPropertiesForTesting(root.get(), identity_transform, gfx::Point3F(), 6686 SetLayerPropertiesForTesting(root.get(), identity_transform, gfx::Point3F(),
6651 gfx::PointF(), gfx::Size(50, 50), true, false, 6687 gfx::PointF(), gfx::Size(50, 50), true, false,
6652 true); 6688 true);
(...skipping 2384 matching lines...) Expand 10 before | Expand all | Expand 10 after
9037 SetLayerPropertiesForTesting(root, identity_matrix, gfx::Point3F(), 9073 SetLayerPropertiesForTesting(root, identity_matrix, gfx::Point3F(),
9038 gfx::PointF(), gfx::Size(30, 30), true, false, 9074 gfx::PointF(), gfx::Size(30, 30), true, false,
9039 true); 9075 true);
9040 SetLayerPropertiesForTesting(render_surface, identity_matrix, gfx::Point3F(), 9076 SetLayerPropertiesForTesting(render_surface, identity_matrix, gfx::Point3F(),
9041 gfx::PointF(), gfx::Size(50, 50), true, false, 9077 gfx::PointF(), gfx::Size(50, 50), true, false,
9042 true); 9078 true);
9043 SetLayerPropertiesForTesting(test_layer, identity_matrix, gfx::Point3F(), 9079 SetLayerPropertiesForTesting(test_layer, identity_matrix, gfx::Point3F(),
9044 gfx::PointF(), gfx::Size(50, 50), true, false, 9080 gfx::PointF(), gfx::Size(50, 50), true, false,
9045 false); 9081 false);
9046 root->SetMasksToBounds(true); 9082 root->SetMasksToBounds(true);
9083 root->SetDrawsContent(true);
9047 render_surface->SetMasksToBounds(true); 9084 render_surface->SetMasksToBounds(true);
9085 render_surface->SetDrawsContent(true);
9048 test_layer->SetMasksToBounds(true); 9086 test_layer->SetMasksToBounds(true);
9049 test_layer->SetDrawsContent(true); 9087 test_layer->SetDrawsContent(true);
9050 ExecuteCalculateDrawProperties(root); 9088 ExecuteCalculateDrawProperties(root);
9051 9089
9052 EXPECT_EQ(gfx::Rect(30, 30), root->clip_rect()); 9090 EXPECT_EQ(gfx::Rect(30, 30), root->clip_rect());
9053 EXPECT_EQ(gfx::Rect(50, 50), render_surface->clip_rect()); 9091 EXPECT_EQ(gfx::Rect(50, 50), render_surface->clip_rect());
9054 EXPECT_EQ(gfx::Rect(50, 50), test_layer->clip_rect()); 9092 EXPECT_EQ(gfx::Rect(50, 50), test_layer->clip_rect());
9055 } 9093 }
9056 9094
9057 TEST_F(LayerTreeHostCommonTest, TwoUnclippedRenderSurfaces) { 9095 TEST_F(LayerTreeHostCommonTest, TwoUnclippedRenderSurfaces) {
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
9107 true); 9145 true);
9108 SetLayerPropertiesForTesting(render_surface1, large_transform, gfx::Point3F(), 9146 SetLayerPropertiesForTesting(render_surface1, large_transform, gfx::Point3F(),
9109 gfx::PointF(), gfx::Size(30, 30), true, false, 9147 gfx::PointF(), gfx::Size(30, 30), true, false,
9110 true); 9148 true);
9111 SetLayerPropertiesForTesting(render_surface2, identity_matrix, gfx::Point3F(), 9149 SetLayerPropertiesForTesting(render_surface2, identity_matrix, gfx::Point3F(),
9112 gfx::PointF(), gfx::Size(30, 30), true, false, 9150 gfx::PointF(), gfx::Size(30, 30), true, false,
9113 true); 9151 true);
9114 9152
9115 ExecuteCalculateDrawProperties(root); 9153 ExecuteCalculateDrawProperties(root);
9116 9154
9117 EXPECT_TRUE(std::isinf( 9155 bool is_inf_or_nan =
9118 render_surface2->render_surface()->draw_transform().matrix().get(0, 0))); 9156 std::isinf(
9119 EXPECT_TRUE(std::isinf( 9157 render_surface2->render_surface()->draw_transform().matrix().get(
9120 render_surface2->render_surface()->draw_transform().matrix().get(1, 1))); 9158 0, 0)) ||
9159 std::isnan(
9160 render_surface2->render_surface()->draw_transform().matrix().get(0,
9161 0));
9162 EXPECT_TRUE(is_inf_or_nan);
9163 is_inf_or_nan =
9164 std::isinf(
9165 render_surface2->render_surface()->draw_transform().matrix().get(
9166 1, 1)) ||
9167 std::isnan(
9168 render_surface2->render_surface()->draw_transform().matrix().get(1,
9169 1));
9170 EXPECT_TRUE(is_inf_or_nan);
9121 EXPECT_EQ(gfx::RectF(), 9171 EXPECT_EQ(gfx::RectF(),
9122 render_surface2->render_surface()->DrawableContentRect()); 9172 render_surface2->render_surface()->DrawableContentRect());
9123 9173
9124 std::vector<LayerImpl*>* rsll = render_surface_layer_list_impl(); 9174 std::vector<LayerImpl*>* rsll = render_surface_layer_list_impl();
9125 bool root_in_rsll = 9175 bool root_in_rsll =
9126 std::find(rsll->begin(), rsll->end(), root) != rsll->end(); 9176 std::find(rsll->begin(), rsll->end(), root) != rsll->end();
9127 EXPECT_TRUE(root_in_rsll); 9177 EXPECT_TRUE(root_in_rsll);
9128 bool render_surface2_in_rsll = 9178 bool render_surface2_in_rsll =
9129 std::find(rsll->begin(), rsll->end(), render_surface2) != rsll->end(); 9179 std::find(rsll->begin(), rsll->end(), render_surface2) != rsll->end();
9130 EXPECT_FALSE(render_surface2_in_rsll); 9180 EXPECT_FALSE(render_surface2_in_rsll);
9131 } 9181 }
9132 9182
9133 } // namespace 9183 } // namespace
9134 } // namespace cc 9184 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layers/layer_position_constraint_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698