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

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

Issue 2018833002: cc : Delete LayerImpl::opacity (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2011 The Chromium Authors. All rights reserved. 1 // Copyright 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "cc/trees/layer_tree_host_common.h" 5 #include "cc/trees/layer_tree_host_common.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <memory> 10 #include <memory>
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 LayerImpl* parent = root_layer(); 173 LayerImpl* parent = root_layer();
174 LayerImpl* child = AddChild<LayerImpl>(parent); 174 LayerImpl* child = AddChild<LayerImpl>(parent);
175 child->SetDrawsContent(true); 175 child->SetDrawsContent(true);
176 176
177 gfx::Transform identity_matrix; 177 gfx::Transform identity_matrix;
178 SetLayerPropertiesForTesting(parent, identity_matrix, gfx::Point3F(), 178 SetLayerPropertiesForTesting(parent, identity_matrix, gfx::Point3F(),
179 gfx::PointF(), gfx::Size(100, 100), true, false); 179 gfx::PointF(), gfx::Size(100, 100), true, false);
180 SetLayerPropertiesForTesting(child, identity_matrix, gfx::Point3F(), 180 SetLayerPropertiesForTesting(child, identity_matrix, gfx::Point3F(),
181 gfx::PointF(10, 10), gfx::Size(100, 100), true, 181 gfx::PointF(10, 10), gfx::Size(100, 100), true,
182 false); 182 false);
183 child->SetOpacity(0.f); 183 child->test_properties()->opacity = 0.f;
184 ExecuteCalculateDrawProperties(parent); 184 ExecuteCalculateDrawProperties(parent);
185 EffectTree& effect_tree = 185 EffectTree& effect_tree =
186 parent->layer_tree_impl()->property_trees()->effect_tree; 186 parent->layer_tree_impl()->property_trees()->effect_tree;
187 EffectNode* node = effect_tree.Node(child->effect_tree_index()); 187 EffectNode* node = effect_tree.Node(child->effect_tree_index());
188 const int transform_tree_size = parent->layer_tree_impl() 188 const int transform_tree_size = parent->layer_tree_impl()
189 ->property_trees() 189 ->property_trees()
190 ->transform_tree.next_available_id(); 190 ->transform_tree.next_available_id();
191 EXPECT_LT(node->data.transform_id, transform_tree_size); 191 EXPECT_LT(node->data.transform_id, transform_tree_size);
192 } 192 }
193 193
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after
503 LayerImpl* child = AddChild<LayerImpl>(parent); 503 LayerImpl* child = AddChild<LayerImpl>(parent);
504 LayerImpl* grand_child = AddChild<LayerImpl>(child); 504 LayerImpl* grand_child = AddChild<LayerImpl>(child);
505 grand_child->SetDrawsContent(true); 505 grand_child->SetDrawsContent(true);
506 506
507 gfx::Transform identity_matrix; 507 gfx::Transform identity_matrix;
508 SetLayerPropertiesForTesting(root, identity_matrix, gfx::Point3F(), 508 SetLayerPropertiesForTesting(root, identity_matrix, gfx::Point3F(),
509 gfx::PointF(), gfx::Size(1, 2), true, false, 509 gfx::PointF(), gfx::Size(1, 2), true, false,
510 true); 510 true);
511 511
512 // Child is set up so that a new render surface should be created. 512 // Child is set up so that a new render surface should be created.
513 child->SetOpacity(0.5f); 513 child->test_properties()->opacity = 0.5f;
514 child->SetDrawsContent(true); 514 child->SetDrawsContent(true);
515 515
516 gfx::Transform parent_layer_transform; 516 gfx::Transform parent_layer_transform;
517 parent_layer_transform.Scale3d(1.f, 0.9f, 1.f); 517 parent_layer_transform.Scale3d(1.f, 0.9f, 1.f);
518 gfx::Transform parent_translation_to_anchor; 518 gfx::Transform parent_translation_to_anchor;
519 parent_translation_to_anchor.Translate(25.0, 30.0); 519 parent_translation_to_anchor.Translate(25.0, 30.0);
520 520
521 gfx::Transform parent_composite_transform = 521 gfx::Transform parent_composite_transform =
522 parent_translation_to_anchor * parent_layer_transform * 522 parent_translation_to_anchor * parent_layer_transform *
523 Inverse(parent_translation_to_anchor); 523 Inverse(parent_translation_to_anchor);
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
629 std::unique_ptr<LayerImpl> child_replica = 629 std::unique_ptr<LayerImpl> child_replica =
630 LayerImpl::Create(host_impl()->active_tree(), 100); 630 LayerImpl::Create(host_impl()->active_tree(), 100);
631 631
632 // One-time setup of root layer 632 // One-time setup of root layer
633 gfx::Transform identity_matrix; 633 gfx::Transform identity_matrix;
634 SetLayerPropertiesForTesting(root, identity_matrix, gfx::Point3F(), 634 SetLayerPropertiesForTesting(root, identity_matrix, gfx::Point3F(),
635 gfx::PointF(), gfx::Size(1, 2), true, false, 635 gfx::PointF(), gfx::Size(1, 2), true, false,
636 true); 636 true);
637 637
638 // Child is set up so that a new render surface should be created. 638 // Child is set up so that a new render surface should be created.
639 child->SetOpacity(0.5f); 639 child->test_properties()->opacity = 0.5f;
640 640
641 gfx::Transform parent_layer_transform; 641 gfx::Transform parent_layer_transform;
642 parent_layer_transform.Scale3d(2.0, 2.0, 1.0); 642 parent_layer_transform.Scale3d(2.0, 2.0, 1.0);
643 gfx::Transform parent_translation_to_anchor; 643 gfx::Transform parent_translation_to_anchor;
644 parent_translation_to_anchor.Translate(2.5, 3.0); 644 parent_translation_to_anchor.Translate(2.5, 3.0);
645 gfx::Transform parent_composite_transform = 645 gfx::Transform parent_composite_transform =
646 parent_translation_to_anchor * parent_layer_transform * 646 parent_translation_to_anchor * parent_layer_transform *
647 Inverse(parent_translation_to_anchor); 647 Inverse(parent_translation_to_anchor);
648 gfx::Transform replica_layer_transform; 648 gfx::Transform replica_layer_transform;
649 replica_layer_transform.Scale3d(3.0, 3.0, 1.0); 649 replica_layer_transform.Scale3d(3.0, 3.0, 1.0);
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
722 LayerImpl* grand_child_of_rs2 = AddChild<LayerImpl>(child_of_rs2); 722 LayerImpl* grand_child_of_rs2 = AddChild<LayerImpl>(child_of_rs2);
723 grand_child_of_rs2->SetDrawsContent(true); 723 grand_child_of_rs2->SetDrawsContent(true);
724 724
725 std::unique_ptr<LayerImpl> replica_of_rs1 = 725 std::unique_ptr<LayerImpl> replica_of_rs1 =
726 LayerImpl::Create(host_impl()->active_tree(), 101); 726 LayerImpl::Create(host_impl()->active_tree(), 101);
727 std::unique_ptr<LayerImpl> replica_of_rs2 = 727 std::unique_ptr<LayerImpl> replica_of_rs2 =
728 LayerImpl::Create(host_impl()->active_tree(), 102); 728 LayerImpl::Create(host_impl()->active_tree(), 102);
729 729
730 // In combination with descendant draws content, opacity != 1 forces the layer 730 // In combination with descendant draws content, opacity != 1 forces the layer
731 // to have a new render surface. 731 // to have a new render surface.
732 render_surface1->SetOpacity(0.5f); 732 render_surface1->test_properties()->opacity = 0.5f;
733 render_surface2->SetOpacity(0.33f); 733 render_surface2->test_properties()->opacity = 0.33f;
734 734
735 // One-time setup of root layer 735 // One-time setup of root layer
736 gfx::Transform identity_matrix; 736 gfx::Transform identity_matrix;
737 SetLayerPropertiesForTesting(root, identity_matrix, gfx::Point3F(), 737 SetLayerPropertiesForTesting(root, identity_matrix, gfx::Point3F(),
738 gfx::PointF(), gfx::Size(1, 2), true, false, 738 gfx::PointF(), gfx::Size(1, 2), true, false,
739 true); 739 true);
740 740
741 // All layers in the tree are initialized with an anchor at .25 and a size of 741 // All layers in the tree are initialized with an anchor at .25 and a size of
742 // (10,10). matrix "A" is the composite layer transform used in all layers, 742 // (10,10). matrix "A" is the composite layer transform used in all layers,
743 // Matrix "R" is the composite replica transform used in all replica layers. 743 // Matrix "R" is the composite replica transform used in all replica layers.
(...skipping 543 matching lines...) Expand 10 before | Expand all | Expand 10 after
1287 LayerImpl* child = AddChild<LayerImpl>(render_surface1); 1287 LayerImpl* child = AddChild<LayerImpl>(render_surface1);
1288 child->SetDrawsContent(true); 1288 child->SetDrawsContent(true);
1289 1289
1290 const gfx::Transform identity_matrix; 1290 const gfx::Transform identity_matrix;
1291 SetLayerPropertiesForTesting(render_surface1, identity_matrix, gfx::Point3F(), 1291 SetLayerPropertiesForTesting(render_surface1, identity_matrix, gfx::Point3F(),
1292 gfx::PointF(), gfx::Size(10, 10), true, false, 1292 gfx::PointF(), gfx::Size(10, 10), true, false,
1293 true); 1293 true);
1294 SetLayerPropertiesForTesting(child, identity_matrix, gfx::Point3F(), 1294 SetLayerPropertiesForTesting(child, identity_matrix, gfx::Point3F(),
1295 gfx::PointF(), gfx::Size(10, 10), true, false, 1295 gfx::PointF(), gfx::Size(10, 10), true, false,
1296 false); 1296 false);
1297 render_surface1->SetOpacity(0.f); 1297 render_surface1->test_properties()->opacity = 0.f;
1298 1298
1299 LayerImplList render_surface_layer_list; 1299 LayerImplList render_surface_layer_list;
1300 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( 1300 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs(
1301 parent, parent->bounds(), &render_surface_layer_list); 1301 parent, parent->bounds(), &render_surface_layer_list);
1302 inputs.can_adjust_raster_scales = true; 1302 inputs.can_adjust_raster_scales = true;
1303 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); 1303 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs);
1304 1304
1305 // Since the layer is transparent, render_surface1->render_surface() should 1305 // Since the layer is transparent, render_surface1->render_surface() should
1306 // not have gotten added anywhere. Also, the drawable content rect should not 1306 // not have gotten added anywhere. Also, the drawable content rect should not
1307 // have been extended by the children. 1307 // have been extended by the children.
(...skipping 14 matching lines...) Expand all
1322 const gfx::Transform identity_matrix; 1322 const gfx::Transform identity_matrix;
1323 SetLayerPropertiesForTesting(parent, identity_matrix, gfx::Point3F(), 1323 SetLayerPropertiesForTesting(parent, identity_matrix, gfx::Point3F(),
1324 gfx::PointF(), gfx::Size(10, 10), true, false, 1324 gfx::PointF(), gfx::Size(10, 10), true, false,
1325 true); 1325 true);
1326 SetLayerPropertiesForTesting(render_surface1, identity_matrix, gfx::Point3F(), 1326 SetLayerPropertiesForTesting(render_surface1, identity_matrix, gfx::Point3F(),
1327 gfx::PointF(), gfx::Size(10, 10), true, false, 1327 gfx::PointF(), gfx::Size(10, 10), true, false,
1328 true); 1328 true);
1329 SetLayerPropertiesForTesting(child, identity_matrix, gfx::Point3F(), 1329 SetLayerPropertiesForTesting(child, identity_matrix, gfx::Point3F(),
1330 gfx::PointF(), gfx::Size(10, 10), true, false, 1330 gfx::PointF(), gfx::Size(10, 10), true, false,
1331 false); 1331 false);
1332 render_surface1->SetOpacity(0.f); 1332 render_surface1->test_properties()->opacity = 0.f;
1333 render_surface1->SetDrawsContent(true); 1333 render_surface1->SetDrawsContent(true);
1334 child->SetDrawsContent(true); 1334 child->SetDrawsContent(true);
1335 FilterOperations filters; 1335 FilterOperations filters;
1336 filters.Append(FilterOperation::CreateBlurFilter(1.5f)); 1336 filters.Append(FilterOperation::CreateBlurFilter(1.5f));
1337 render_surface1->SetBackgroundFilters(filters); 1337 render_surface1->SetBackgroundFilters(filters);
1338 1338
1339 { 1339 {
1340 LayerImplList render_surface_layer_list; 1340 LayerImplList render_surface_layer_list;
1341 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( 1341 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs(
1342 parent, parent->bounds(), &render_surface_layer_list); 1342 parent, parent->bounds(), &render_surface_layer_list);
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
1419 const gfx::Transform identity_matrix; 1419 const gfx::Transform identity_matrix;
1420 const SkXfermode::Mode blend_mode = SkXfermode::kMultiply_Mode; 1420 const SkXfermode::Mode blend_mode = SkXfermode::kMultiply_Mode;
1421 SetLayerPropertiesForTesting(parent, identity_matrix, gfx::Point3F(), 1421 SetLayerPropertiesForTesting(parent, identity_matrix, gfx::Point3F(),
1422 gfx::PointF(), gfx::Size(10, 10), true, false, 1422 gfx::PointF(), gfx::Size(10, 10), true, false,
1423 true); 1423 true);
1424 SetLayerPropertiesForTesting(child, identity_matrix, gfx::Point3F(), 1424 SetLayerPropertiesForTesting(child, identity_matrix, gfx::Point3F(),
1425 gfx::PointF(), gfx::Size(10, 10), true, false, 1425 gfx::PointF(), gfx::Size(10, 10), true, false,
1426 true); 1426 true);
1427 1427
1428 child->SetBlendMode(blend_mode); 1428 child->SetBlendMode(blend_mode);
1429 child->SetOpacity(0.5f); 1429 child->test_properties()->opacity = 0.5f;
1430 1430
1431 ExecuteCalculateDrawProperties(parent); 1431 ExecuteCalculateDrawProperties(parent);
1432 1432
1433 // Since the child layer has a blend mode other than normal, it should get 1433 // Since the child layer has a blend mode other than normal, it should get
1434 // its own render surface. Also, layer's draw_properties should contain the 1434 // its own render surface. Also, layer's draw_properties should contain the
1435 // default blend mode, since the render surface becomes responsible for 1435 // default blend mode, since the render surface becomes responsible for
1436 // applying the blend mode. 1436 // applying the blend mode.
1437 ASSERT_TRUE(child->render_surface()); 1437 ASSERT_TRUE(child->render_surface());
1438 EXPECT_EQ(1.0f, child->draw_opacity()); 1438 EXPECT_EQ(1.0f, child->draw_opacity());
1439 EXPECT_EQ(0.5f, child->render_surface()->draw_opacity()); 1439 EXPECT_EQ(0.5f, child->render_surface()->draw_opacity());
(...skipping 15 matching lines...) Expand all
1455 true); 1455 true);
1456 SetLayerPropertiesForTesting(not_surface, identity_matrix, gfx::Point3F(), 1456 SetLayerPropertiesForTesting(not_surface, identity_matrix, gfx::Point3F(),
1457 gfx::PointF(), gfx::Size(10, 10), true, false, 1457 gfx::PointF(), gfx::Size(10, 10), true, false,
1458 false); 1458 false);
1459 SetLayerPropertiesForTesting(surface2, identity_matrix, gfx::Point3F(), 1459 SetLayerPropertiesForTesting(surface2, identity_matrix, gfx::Point3F(),
1460 gfx::PointF(), gfx::Size(10, 10), true, false, 1460 gfx::PointF(), gfx::Size(10, 10), true, false,
1461 true); 1461 true);
1462 surface1->SetDrawsContent(true); 1462 surface1->SetDrawsContent(true);
1463 surface2->SetDrawsContent(true); 1463 surface2->SetDrawsContent(true);
1464 1464
1465 surface1->SetOpacity(0.5f); 1465 surface1->test_properties()->opacity = 0.5f;
1466 not_surface->SetOpacity(0.5f); 1466 not_surface->test_properties()->opacity = 0.5f;
1467 surface2->SetOpacity(0.5f); 1467 surface2->test_properties()->opacity = 0.5f;
1468 1468
1469 ExecuteCalculateDrawProperties(root); 1469 ExecuteCalculateDrawProperties(root);
1470 1470
1471 ASSERT_TRUE(surface1->render_surface()); 1471 ASSERT_TRUE(surface1->render_surface());
1472 ASSERT_FALSE(not_surface->render_surface()); 1472 ASSERT_FALSE(not_surface->render_surface());
1473 ASSERT_TRUE(surface2->render_surface()); 1473 ASSERT_TRUE(surface2->render_surface());
1474 EXPECT_EQ(0.5f, surface1->render_surface()->draw_opacity()); 1474 EXPECT_EQ(0.5f, surface1->render_surface()->draw_opacity());
1475 // surface2's draw opacity should include the opacity of not-surface and 1475 // surface2's draw opacity should include the opacity of not-surface and
1476 // itself, but not the opacity of surface1. 1476 // itself, but not the opacity of surface1.
1477 EXPECT_EQ(0.25f, surface2->render_surface()->draw_opacity()); 1477 EXPECT_EQ(0.25f, surface2->render_surface()->draw_opacity());
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
1517 SetLayerPropertiesForTesting(grand_child, identity_matrix, gfx::Point3F(), 1517 SetLayerPropertiesForTesting(grand_child, identity_matrix, gfx::Point3F(),
1518 gfx::PointF(), gfx::Size(100, 100), true, false, 1518 gfx::PointF(), gfx::Size(100, 100), true, false,
1519 true); 1519 true);
1520 SetLayerPropertiesForTesting(leaf_node1, identity_matrix, gfx::Point3F(), 1520 SetLayerPropertiesForTesting(leaf_node1, identity_matrix, gfx::Point3F(),
1521 gfx::PointF(), gfx::Size(100, 100), true, false, 1521 gfx::PointF(), gfx::Size(100, 100), true, false,
1522 false); 1522 false);
1523 SetLayerPropertiesForTesting(leaf_node2, identity_matrix, gfx::Point3F(), 1523 SetLayerPropertiesForTesting(leaf_node2, identity_matrix, gfx::Point3F(),
1524 gfx::PointF(), gfx::Size(100, 100), true, false, 1524 gfx::PointF(), gfx::Size(100, 100), true, false,
1525 false); 1525 false);
1526 1526
1527 child1->SetOpacity(0.5f); 1527 child1->test_properties()->opacity = 0.5f;
1528 grand_child->SetOpacity(0.5f); 1528 grand_child->test_properties()->opacity = 0.5f;
1529 leaf_node1->SetOpacity(0.5f); 1529 leaf_node1->test_properties()->opacity = 0.5f;
1530 leaf_node2->SetOpacity(0.5f); 1530 leaf_node2->test_properties()->opacity = 0.5f;
1531 1531
1532 // With surfaces enabled, each layer's draw opacity is the product of layer 1532 // With surfaces enabled, each layer's draw opacity is the product of layer
1533 // opacities on the path from the layer to its render target, not including 1533 // opacities on the path from the layer to its render target, not including
1534 // the opacity of the layer that owns the target surface (since that opacity 1534 // the opacity of the layer that owns the target surface (since that opacity
1535 // is applied by the surface). 1535 // is applied by the surface).
1536 ExecuteCalculateDrawProperties(root); 1536 ExecuteCalculateDrawProperties(root);
1537 EXPECT_EQ(1.f, root->draw_opacity()); 1537 EXPECT_EQ(1.f, root->draw_opacity());
1538 EXPECT_EQ(1.f, parent->draw_opacity()); 1538 EXPECT_EQ(1.f, parent->draw_opacity());
1539 EXPECT_EQ(1.f, child1->draw_opacity()); 1539 EXPECT_EQ(1.f, child1->draw_opacity());
1540 EXPECT_EQ(1.f, child2->draw_opacity()); 1540 EXPECT_EQ(1.f, child2->draw_opacity());
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
1595 LayerImpl* parent = AddChild<LayerImpl>(root); 1595 LayerImpl* parent = AddChild<LayerImpl>(root);
1596 LayerImpl* child = AddChild<LayerImpl>(parent); 1596 LayerImpl* child = AddChild<LayerImpl>(parent);
1597 LayerImpl* grand_child = AddChild<LayerImpl>(child); 1597 LayerImpl* grand_child = AddChild<LayerImpl>(child);
1598 1598
1599 child->SetDrawsContent(true); 1599 child->SetDrawsContent(true);
1600 grand_child->SetDrawsContent(true); 1600 grand_child->SetDrawsContent(true);
1601 1601
1602 gfx::Transform rotation_about_y_axis; 1602 gfx::Transform rotation_about_y_axis;
1603 rotation_about_y_axis.RotateAboutYAxis(30.0); 1603 rotation_about_y_axis.RotateAboutYAxis(30.0);
1604 // Make |parent| have a render surface. 1604 // Make |parent| have a render surface.
1605 parent->SetOpacity(0.9f); 1605 parent->test_properties()->opacity = 0.9f;
1606 1606
1607 const gfx::Transform identity_matrix; 1607 const gfx::Transform identity_matrix;
1608 SetLayerPropertiesForTesting(root, identity_matrix, gfx::Point3F(), 1608 SetLayerPropertiesForTesting(root, identity_matrix, gfx::Point3F(),
1609 gfx::PointF(), gfx::Size(100, 100), true, false, 1609 gfx::PointF(), gfx::Size(100, 100), true, false,
1610 true); 1610 true);
1611 SetLayerPropertiesForTesting(parent, rotation_about_y_axis, gfx::Point3F(), 1611 SetLayerPropertiesForTesting(parent, rotation_about_y_axis, gfx::Point3F(),
1612 gfx::PointF(), gfx::Size(10, 10), true, false, 1612 gfx::PointF(), gfx::Size(10, 10), true, false,
1613 true); 1613 true);
1614 SetLayerPropertiesForTesting(child, identity_matrix, gfx::Point3F(), 1614 SetLayerPropertiesForTesting(child, identity_matrix, gfx::Point3F(),
1615 gfx::PointF(), gfx::Size(10, 10), true, false, 1615 gfx::PointF(), gfx::Size(10, 10), true, false,
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
1695 gfx::Point3F(), gfx::PointF(), gfx::Size(10, 10), 1695 gfx::Point3F(), gfx::PointF(), gfx::Size(10, 10),
1696 true, false, false); 1696 true, false, false);
1697 SetLayerPropertiesForTesting(leaf_node1, identity_matrix, gfx::Point3F(), 1697 SetLayerPropertiesForTesting(leaf_node1, identity_matrix, gfx::Point3F(),
1698 gfx::PointF(), gfx::Size(500, 500), true, false, 1698 gfx::PointF(), gfx::Size(500, 500), true, false,
1699 false); 1699 false);
1700 SetLayerPropertiesForTesting(leaf_node2, identity_matrix, gfx::Point3F(), 1700 SetLayerPropertiesForTesting(leaf_node2, identity_matrix, gfx::Point3F(),
1701 gfx::PointF(), gfx::Size(20, 20), true, false, 1701 gfx::PointF(), gfx::Size(20, 20), true, false,
1702 false); 1702 false);
1703 1703
1704 child->SetMasksToBounds(true); 1704 child->SetMasksToBounds(true);
1705 child->SetOpacity(0.4f); 1705 child->test_properties()->opacity = 0.4f;
1706 grand_child->SetOpacity(0.5f); 1706 grand_child->test_properties()->opacity = 0.5f;
1707 great_grand_child->SetOpacity(0.4f); 1707 great_grand_child->test_properties()->opacity = 0.4f;
1708 1708
1709 ExecuteCalculateDrawProperties(parent); 1709 ExecuteCalculateDrawProperties(parent);
1710 1710
1711 ASSERT_EQ(2U, render_surface_layer_list_impl()->size()); 1711 ASSERT_EQ(2U, render_surface_layer_list_impl()->size());
1712 EXPECT_EQ(parent->id(), render_surface_layer_list_impl()->at(0)->id()); 1712 EXPECT_EQ(parent->id(), render_surface_layer_list_impl()->at(0)->id());
1713 EXPECT_EQ(child->id(), render_surface_layer_list_impl()->at(1)->id()); 1713 EXPECT_EQ(child->id(), render_surface_layer_list_impl()->at(1)->id());
1714 } 1714 }
1715 1715
1716 TEST_F(LayerTreeHostCommonTest, ClipRectCullsSurfaceWithoutVisibleContent) { 1716 TEST_F(LayerTreeHostCommonTest, ClipRectCullsSurfaceWithoutVisibleContent) {
1717 // When a render surface has a clip rect, it is used to clip the content rect 1717 // When a render surface has a clip rect, it is used to clip the content rect
(...skipping 25 matching lines...) Expand all
1743 gfx::PointF(), gfx::Size(20, 20), true, false, 1743 gfx::PointF(), gfx::Size(20, 20), true, false,
1744 true); 1744 true);
1745 SetLayerPropertiesForTesting(grand_child, identity_matrix, gfx::Point3F(), 1745 SetLayerPropertiesForTesting(grand_child, identity_matrix, gfx::Point3F(),
1746 gfx::PointF(200.f, 200.f), gfx::Size(10, 10), 1746 gfx::PointF(200.f, 200.f), gfx::Size(10, 10),
1747 true, false, true); 1747 true, false, true);
1748 SetLayerPropertiesForTesting(leaf_node, identity_matrix, gfx::Point3F(), 1748 SetLayerPropertiesForTesting(leaf_node, identity_matrix, gfx::Point3F(),
1749 gfx::PointF(), gfx::Size(10, 10), true, false, 1749 gfx::PointF(), gfx::Size(10, 10), true, false,
1750 false); 1750 false);
1751 1751
1752 parent->SetMasksToBounds(true); 1752 parent->SetMasksToBounds(true);
1753 child->SetOpacity(0.4f); 1753 child->test_properties()->opacity = 0.4f;
1754 grand_child->SetOpacity(0.4f); 1754 grand_child->test_properties()->opacity = 0.4f;
1755 1755
1756 ExecuteCalculateDrawProperties(parent); 1756 ExecuteCalculateDrawProperties(parent);
1757 1757
1758 // We should cull child and grand_child from the 1758 // We should cull child and grand_child from the
1759 // render_surface_layer_list. 1759 // render_surface_layer_list.
1760 ASSERT_EQ(1U, render_surface_layer_list_impl()->size()); 1760 ASSERT_EQ(1U, render_surface_layer_list_impl()->size());
1761 EXPECT_EQ(parent->id(), render_surface_layer_list_impl()->at(0)->id()); 1761 EXPECT_EQ(parent->id(), render_surface_layer_list_impl()->at(0)->id());
1762 } 1762 }
1763 1763
1764 TEST_F(LayerTreeHostCommonTest, IsClippedIsSetCorrectlyLayerImpl) { 1764 TEST_F(LayerTreeHostCommonTest, IsClippedIsSetCorrectlyLayerImpl) {
(...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after
2137 gfx::PointF(15.f, 15.f), gfx::Size(10, 10), true, 2137 gfx::PointF(15.f, 15.f), gfx::Size(10, 10), true,
2138 false, false); 2138 false, false);
2139 SetLayerPropertiesForTesting(grand_child4, identity_matrix, gfx::Point3F(), 2139 SetLayerPropertiesForTesting(grand_child4, identity_matrix, gfx::Point3F(),
2140 gfx::PointF(45.f, 45.f), gfx::Size(10, 10), true, 2140 gfx::PointF(45.f, 45.f), gfx::Size(10, 10), true,
2141 false, false); 2141 false, false);
2142 2142
2143 child->SetMasksToBounds(true); 2143 child->SetMasksToBounds(true);
2144 grand_child3->SetMasksToBounds(true); 2144 grand_child3->SetMasksToBounds(true);
2145 2145
2146 // Force child to be a render surface. 2146 // Force child to be a render surface.
2147 child->SetOpacity(0.4f); 2147 child->test_properties()->opacity = 0.4f;
2148 2148
2149 ExecuteCalculateDrawProperties(parent); 2149 ExecuteCalculateDrawProperties(parent);
2150 2150
2151 EXPECT_EQ(gfx::Rect(5, 5, 10, 10), grand_child1->drawable_content_rect()); 2151 EXPECT_EQ(gfx::Rect(5, 5, 10, 10), grand_child1->drawable_content_rect());
2152 EXPECT_EQ(gfx::Rect(15, 15, 5, 5), grand_child3->drawable_content_rect()); 2152 EXPECT_EQ(gfx::Rect(15, 15, 5, 5), grand_child3->drawable_content_rect());
2153 EXPECT_EQ(gfx::Rect(15, 15, 5, 5), grand_child3->drawable_content_rect()); 2153 EXPECT_EQ(gfx::Rect(15, 15, 5, 5), grand_child3->drawable_content_rect());
2154 EXPECT_TRUE(grand_child4->drawable_content_rect().IsEmpty()); 2154 EXPECT_TRUE(grand_child4->drawable_content_rect().IsEmpty());
2155 } 2155 }
2156 2156
2157 TEST_F(LayerTreeHostCommonTest, ClipRectIsPropagatedCorrectlyToSurfaces) { 2157 TEST_F(LayerTreeHostCommonTest, ClipRectIsPropagatedCorrectlyToSurfaces) {
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
2210 false); 2210 false);
2211 SetLayerPropertiesForTesting(leaf_node4, identity_matrix, gfx::Point3F(), 2211 SetLayerPropertiesForTesting(leaf_node4, identity_matrix, gfx::Point3F(),
2212 gfx::PointF(), gfx::Size(10, 10), true, false, 2212 gfx::PointF(), gfx::Size(10, 10), true, false,
2213 false); 2213 false);
2214 2214
2215 child->SetMasksToBounds(true); 2215 child->SetMasksToBounds(true);
2216 grand_child3->SetMasksToBounds(true); 2216 grand_child3->SetMasksToBounds(true);
2217 grand_child4->SetMasksToBounds(true); 2217 grand_child4->SetMasksToBounds(true);
2218 2218
2219 // Force everyone to be a render surface. 2219 // Force everyone to be a render surface.
2220 child->SetOpacity(0.4f); 2220 child->test_properties()->opacity = 0.4f;
2221 grand_child1->SetOpacity(0.5f); 2221 grand_child1->test_properties()->opacity = 0.5f;
2222 grand_child2->SetOpacity(0.5f); 2222 grand_child2->test_properties()->opacity = 0.5f;
2223 grand_child3->SetOpacity(0.5f); 2223 grand_child3->test_properties()->opacity = 0.5f;
2224 grand_child4->SetOpacity(0.5f); 2224 grand_child4->test_properties()->opacity = 0.5f;
2225 2225
2226 ExecuteCalculateDrawProperties(parent); 2226 ExecuteCalculateDrawProperties(parent);
2227 2227
2228 ASSERT_TRUE(grand_child1->render_surface()); 2228 ASSERT_TRUE(grand_child1->render_surface());
2229 ASSERT_TRUE(grand_child2->render_surface()); 2229 ASSERT_TRUE(grand_child2->render_surface());
2230 ASSERT_TRUE(grand_child3->render_surface()); 2230 ASSERT_TRUE(grand_child3->render_surface());
2231 2231
2232 // Surfaces are clipped by their parent, but un-affected by the owning layer's 2232 // Surfaces are clipped by their parent, but un-affected by the owning layer's
2233 // masksToBounds. 2233 // masksToBounds.
2234 EXPECT_EQ(gfx::Rect(0, 0, 20, 20), 2234 EXPECT_EQ(gfx::Rect(0, 0, 20, 20),
(...skipping 1973 matching lines...) Expand 10 before | Expand all | Expand 10 after
4208 back_facing_child_of_front_facing_surface->SetDrawsContent(true); 4208 back_facing_child_of_front_facing_surface->SetDrawsContent(true);
4209 front_facing_child_of_back_facing_surface->SetDrawsContent(true); 4209 front_facing_child_of_back_facing_surface->SetDrawsContent(true);
4210 back_facing_child_of_back_facing_surface->SetDrawsContent(true); 4210 back_facing_child_of_back_facing_surface->SetDrawsContent(true);
4211 4211
4212 gfx::Transform backface_matrix; 4212 gfx::Transform backface_matrix;
4213 backface_matrix.Translate(50.0, 50.0); 4213 backface_matrix.Translate(50.0, 50.0);
4214 backface_matrix.RotateAboutYAxis(180.0); 4214 backface_matrix.RotateAboutYAxis(180.0);
4215 backface_matrix.Translate(-50.0, -50.0); 4215 backface_matrix.Translate(-50.0, -50.0);
4216 4216
4217 // Having a descendant and opacity will force these to have render surfaces. 4217 // Having a descendant and opacity will force these to have render surfaces.
4218 front_facing_surface->SetOpacity(0.5f); 4218 front_facing_surface->test_properties()->opacity = 0.5f;
4219 back_facing_surface->SetOpacity(0.5f); 4219 back_facing_surface->test_properties()->opacity = 0.5f;
4220 4220
4221 // Nothing preserves 3d. According to current W3C CSS gfx::Transforms spec, 4221 // Nothing preserves 3d. According to current W3C CSS gfx::Transforms spec,
4222 // these layers should blindly use their own local transforms to determine 4222 // these layers should blindly use their own local transforms to determine
4223 // back-face culling. 4223 // back-face culling.
4224 SetLayerPropertiesForTesting(parent, identity_matrix, gfx::Point3F(), 4224 SetLayerPropertiesForTesting(parent, identity_matrix, gfx::Point3F(),
4225 gfx::PointF(), gfx::Size(100, 100), true, false); 4225 gfx::PointF(), gfx::Size(100, 100), true, false);
4226 SetLayerPropertiesForTesting(front_facing_child, identity_matrix, 4226 SetLayerPropertiesForTesting(front_facing_child, identity_matrix,
4227 gfx::Point3F(), gfx::PointF(), 4227 gfx::Point3F(), gfx::PointF(),
4228 gfx::Size(100, 100), true, false); 4228 gfx::Size(100, 100), true, false);
4229 SetLayerPropertiesForTesting(back_facing_child, backface_matrix, 4229 SetLayerPropertiesForTesting(back_facing_child, backface_matrix,
(...skipping 749 matching lines...) Expand 10 before | Expand all | Expand 10 after
4979 grand_child->SetDrawsContent(true); 4979 grand_child->SetDrawsContent(true);
4980 4980
4981 const gfx::Transform identity_matrix; 4981 const gfx::Transform identity_matrix;
4982 SetLayerPropertiesForTesting(root, identity_matrix, gfx::Point3F(), 4982 SetLayerPropertiesForTesting(root, identity_matrix, gfx::Point3F(),
4983 gfx::PointF(), gfx::Size(100, 100), true, false); 4983 gfx::PointF(), gfx::Size(100, 100), true, false);
4984 SetLayerPropertiesForTesting(child, identity_matrix, gfx::Point3F(), 4984 SetLayerPropertiesForTesting(child, identity_matrix, gfx::Point3F(),
4985 gfx::PointF(), gfx::Size(10, 10), true, false); 4985 gfx::PointF(), gfx::Size(10, 10), true, false);
4986 SetLayerPropertiesForTesting(grand_child, identity_matrix, gfx::Point3F(), 4986 SetLayerPropertiesForTesting(grand_child, identity_matrix, gfx::Point3F(),
4987 gfx::PointF(), gfx::Size(10, 10), true, false); 4987 gfx::PointF(), gfx::Size(10, 10), true, false);
4988 4988
4989 child->SetOpacity(0.5f); 4989 child->test_properties()->opacity = 0.5f;
4990 4990
4991 ExecuteCalculateDrawProperties(root); 4991 ExecuteCalculateDrawProperties(root);
4992 4992
4993 EXPECT_FALSE(child->has_render_surface()); 4993 EXPECT_FALSE(child->has_render_surface());
4994 } 4994 }
4995 4995
4996 TEST_F(LayerTreeHostCommonTest, OpacityAnimatingOnPendingTree) { 4996 TEST_F(LayerTreeHostCommonTest, OpacityAnimatingOnPendingTree) {
4997 FakeImplTaskRunnerProvider task_runner_provider; 4997 FakeImplTaskRunnerProvider task_runner_provider;
4998 TestSharedBitmapManager shared_bitmap_manager; 4998 TestSharedBitmapManager shared_bitmap_manager;
4999 TestTaskGraphRunner task_graph_runner; 4999 TestTaskGraphRunner task_graph_runner;
5000 FakeLayerTreeHostImpl host_impl(host()->settings(), &task_runner_provider, 5000 FakeLayerTreeHostImpl host_impl(host()->settings(), &task_runner_provider,
5001 &shared_bitmap_manager, &task_graph_runner); 5001 &shared_bitmap_manager, &task_graph_runner);
5002 host_impl.CreatePendingTree(); 5002 host_impl.CreatePendingTree();
5003 std::unique_ptr<LayerImpl> root = 5003 std::unique_ptr<LayerImpl> root =
5004 LayerImpl::Create(host_impl.pending_tree(), 1); 5004 LayerImpl::Create(host_impl.pending_tree(), 1);
5005 5005
5006 const gfx::Transform identity_matrix; 5006 const gfx::Transform identity_matrix;
5007 SetLayerPropertiesForTesting(root.get(), identity_matrix, gfx::Point3F(), 5007 SetLayerPropertiesForTesting(root.get(), identity_matrix, gfx::Point3F(),
5008 gfx::PointF(), gfx::Size(100, 100), true, false, 5008 gfx::PointF(), gfx::Size(100, 100), true, false,
5009 false); 5009 false);
5010 root->SetDrawsContent(true); 5010 root->SetDrawsContent(true);
5011 5011
5012 std::unique_ptr<LayerImpl> child = 5012 std::unique_ptr<LayerImpl> child =
5013 LayerImpl::Create(host_impl.pending_tree(), 2); 5013 LayerImpl::Create(host_impl.pending_tree(), 2);
5014 SetLayerPropertiesForTesting(child.get(), identity_matrix, gfx::Point3F(), 5014 SetLayerPropertiesForTesting(child.get(), identity_matrix, gfx::Point3F(),
5015 gfx::PointF(), gfx::Size(50, 50), true, false, 5015 gfx::PointF(), gfx::Size(50, 50), true, false,
5016 false); 5016 false);
5017 child->SetDrawsContent(true); 5017 child->SetDrawsContent(true);
5018 child->SetOpacity(0.0f); 5018 child->test_properties()->opacity = 0.0f;
5019 5019
5020 const int child_id = child->id(); 5020 const int child_id = child->id();
5021 root->AddChild(std::move(child)); 5021 root->AddChild(std::move(child));
5022 root->SetHasRenderSurface(true); 5022 root->SetHasRenderSurface(true);
5023 LayerImpl* root_layer = root.get(); 5023 LayerImpl* root_layer = root.get();
5024 host_impl.pending_tree()->SetRootLayer(std::move(root)); 5024 host_impl.pending_tree()->SetRootLayer(std::move(root));
5025 host_impl.pending_tree()->BuildPropertyTreesForTesting(); 5025 host_impl.pending_tree()->BuildPropertyTreesForTesting();
5026 // Add opacity animation. 5026 // Add opacity animation.
5027 scoped_refptr<AnimationTimeline> timeline = 5027 scoped_refptr<AnimationTimeline> timeline =
5028 AnimationTimeline::Create(AnimationIdProvider::NextTimelineId()); 5028 AnimationTimeline::Create(AnimationIdProvider::NextTimelineId());
5029 host_impl.animation_host()->AddAnimationTimeline(timeline); 5029 host_impl.animation_host()->AddAnimationTimeline(timeline);
5030 5030
5031 AddOpacityTransitionToLayerWithPlayer(child_id, timeline, 10.0, 0.0f, 1.0f, 5031 AddOpacityTransitionToLayerWithPlayer(child_id, timeline, 10.0, 0.0f, 1.0f,
5032 false); 5032 false);
5033 5033
5034 LayerImplList render_surface_layer_list; 5034 LayerImplList render_surface_layer_list;
5035 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( 5035 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs(
5036 root_layer, root_layer->bounds(), &render_surface_layer_list); 5036 root_layer, root_layer->bounds(), &render_surface_layer_list);
5037 inputs.can_adjust_raster_scales = true; 5037 inputs.can_adjust_raster_scales = true;
5038 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); 5038 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs);
5039 5039
5040 // We should have one render surface and two layers. The child 5040 // We should have one render surface and two layers. The child
5041 // layer should be included even though it is transparent. 5041 // layer should be included even though it is transparent.
5042 ASSERT_EQ(1u, render_surface_layer_list.size()); 5042 ASSERT_EQ(1u, render_surface_layer_list.size());
5043 ASSERT_EQ(2u, root_layer->render_surface()->layer_list().size()); 5043 ASSERT_EQ(2u, root_layer->render_surface()->layer_list().size());
5044 5044
5045 // If the root itself is hidden, the child should not be drawn even if it has 5045 // If the root itself is hidden, the child should not be drawn even if it has
5046 // an animating opacity. 5046 // an animating opacity.
5047 root_layer->SetOpacity(0.0f); 5047 root_layer->test_properties()->opacity = 0.0f;
5048 root_layer->layer_tree_impl()->property_trees()->needs_rebuild = true; 5048 root_layer->layer_tree_impl()->property_trees()->needs_rebuild = true;
5049 LayerImplList render_surface_layer_list2; 5049 LayerImplList render_surface_layer_list2;
5050 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs2( 5050 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs2(
5051 root_layer, root_layer->bounds(), &render_surface_layer_list2); 5051 root_layer, root_layer->bounds(), &render_surface_layer_list2);
5052 inputs2.can_adjust_raster_scales = true; 5052 inputs2.can_adjust_raster_scales = true;
5053 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs2); 5053 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs2);
5054 5054
5055 LayerImpl* child_ptr = root_layer->layer_tree_impl()->LayerById(2); 5055 LayerImpl* child_ptr = root_layer->layer_tree_impl()->LayerById(2);
5056 EffectTree& tree = 5056 EffectTree& tree =
5057 root_layer->layer_tree_impl()->property_trees()->effect_tree; 5057 root_layer->layer_tree_impl()->property_trees()->effect_tree;
5058 EffectNode* node = tree.Node(child_ptr->effect_tree_index()); 5058 EffectNode* node = tree.Node(child_ptr->effect_tree_index());
5059 EXPECT_FALSE(node->data.is_drawn); 5059 EXPECT_FALSE(node->data.is_drawn);
5060 5060
5061 // A layer should be drawn and it should contribute to drawn surface when 5061 // A layer should be drawn and it should contribute to drawn surface when
5062 // it has animating opacity even if it has opacity 0. 5062 // it has animating opacity even if it has opacity 0.
5063 root_layer->SetOpacity(1.0f); 5063 root_layer->test_properties()->opacity = 1.0f;
5064 child_ptr->SetOpacity(0.0f); 5064 child_ptr->test_properties()->opacity = 0.0f;
5065 root_layer->layer_tree_impl()->property_trees()->needs_rebuild = true; 5065 root_layer->layer_tree_impl()->property_trees()->needs_rebuild = true;
5066 LayerImplList render_surface_layer_list3; 5066 LayerImplList render_surface_layer_list3;
5067 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs3( 5067 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs3(
5068 root_layer, root_layer->bounds(), &render_surface_layer_list3); 5068 root_layer, root_layer->bounds(), &render_surface_layer_list3);
5069 inputs3.can_adjust_raster_scales = true; 5069 inputs3.can_adjust_raster_scales = true;
5070 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs3); 5070 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs3);
5071 5071
5072 child_ptr = root_layer->layer_tree_impl()->LayerById(2); 5072 child_ptr = root_layer->layer_tree_impl()->LayerById(2);
5073 tree = root_layer->layer_tree_impl()->property_trees()->effect_tree; 5073 tree = root_layer->layer_tree_impl()->property_trees()->effect_tree;
5074 node = tree.Node(child_ptr->effect_tree_index()); 5074 node = tree.Node(child_ptr->effect_tree_index());
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
5230 child_->layer_tree_impl()->property_trees()->needs_rebuild = true; 5230 child_->layer_tree_impl()->property_trees()->needs_rebuild = true;
5231 ExecuteCalculateDrawProperties(root_, 1.f, 1.f, NULL, can_use_lcd_text_, 5231 ExecuteCalculateDrawProperties(root_, 1.f, 1.f, NULL, can_use_lcd_text_,
5232 layers_always_allowed_lcd_text_); 5232 layers_always_allowed_lcd_text_);
5233 EXPECT_EQ(expect_lcd_text, root_->can_use_lcd_text()); 5233 EXPECT_EQ(expect_lcd_text, root_->can_use_lcd_text());
5234 EXPECT_EQ(expect_not_lcd_text, child_->can_use_lcd_text()); 5234 EXPECT_EQ(expect_not_lcd_text, child_->can_use_lcd_text());
5235 EXPECT_EQ(expect_not_lcd_text, grand_child_->can_use_lcd_text()); 5235 EXPECT_EQ(expect_not_lcd_text, grand_child_->can_use_lcd_text());
5236 5236
5237 // Case 7: Translucent. 5237 // Case 7: Translucent.
5238 child_->SetTransform(identity_matrix); 5238 child_->SetTransform(identity_matrix);
5239 child_->layer_tree_impl()->property_trees()->needs_rebuild = true; 5239 child_->layer_tree_impl()->property_trees()->needs_rebuild = true;
5240 child_->SetOpacity(0.5f); 5240 child_->test_properties()->opacity = 0.5f;
5241 ExecuteCalculateDrawProperties(root_, 1.f, 1.f, NULL, can_use_lcd_text_, 5241 ExecuteCalculateDrawProperties(root_, 1.f, 1.f, NULL, can_use_lcd_text_,
5242 layers_always_allowed_lcd_text_); 5242 layers_always_allowed_lcd_text_);
5243 EXPECT_EQ(expect_lcd_text, root_->can_use_lcd_text()); 5243 EXPECT_EQ(expect_lcd_text, root_->can_use_lcd_text());
5244 EXPECT_EQ(expect_not_lcd_text, child_->can_use_lcd_text()); 5244 EXPECT_EQ(expect_not_lcd_text, child_->can_use_lcd_text());
5245 EXPECT_EQ(expect_not_lcd_text, grand_child_->can_use_lcd_text()); 5245 EXPECT_EQ(expect_not_lcd_text, grand_child_->can_use_lcd_text());
5246 5246
5247 // Case 8: Sanity check: restore transform and opacity. 5247 // Case 8: Sanity check: restore transform and opacity.
5248 child_->SetTransform(identity_matrix); 5248 child_->SetTransform(identity_matrix);
5249 child_->layer_tree_impl()->property_trees()->needs_rebuild = true; 5249 child_->layer_tree_impl()->property_trees()->needs_rebuild = true;
5250 child_->SetOpacity(1.f); 5250 child_->test_properties()->opacity = 1.f;
5251 ExecuteCalculateDrawProperties(root_, 1.f, 1.f, NULL, can_use_lcd_text_, 5251 ExecuteCalculateDrawProperties(root_, 1.f, 1.f, NULL, can_use_lcd_text_,
5252 layers_always_allowed_lcd_text_); 5252 layers_always_allowed_lcd_text_);
5253 EXPECT_EQ(expect_lcd_text, root_->can_use_lcd_text()); 5253 EXPECT_EQ(expect_lcd_text, root_->can_use_lcd_text());
5254 EXPECT_EQ(expect_lcd_text, child_->can_use_lcd_text()); 5254 EXPECT_EQ(expect_lcd_text, child_->can_use_lcd_text());
5255 EXPECT_EQ(expect_lcd_text, grand_child_->can_use_lcd_text()); 5255 EXPECT_EQ(expect_lcd_text, grand_child_->can_use_lcd_text());
5256 5256
5257 // Case 9: Non-opaque content. 5257 // Case 9: Non-opaque content.
5258 child_->SetContentsOpaque(false); 5258 child_->SetContentsOpaque(false);
5259 ExecuteCalculateDrawProperties(root_, 1.f, 1.f, NULL, can_use_lcd_text_, 5259 ExecuteCalculateDrawProperties(root_, 1.f, 1.f, NULL, can_use_lcd_text_,
5260 layers_always_allowed_lcd_text_); 5260 layers_always_allowed_lcd_text_);
(...skipping 15 matching lines...) Expand all
5276 bool expect_not_lcd_text = layers_always_allowed_lcd_text_; 5276 bool expect_not_lcd_text = layers_always_allowed_lcd_text_;
5277 5277
5278 // Sanity check: Make sure can_use_lcd_text_ is set on each node. 5278 // Sanity check: Make sure can_use_lcd_text_ is set on each node.
5279 ExecuteCalculateDrawProperties(root_, 1.f, 1.f, NULL, can_use_lcd_text_, 5279 ExecuteCalculateDrawProperties(root_, 1.f, 1.f, NULL, can_use_lcd_text_,
5280 layers_always_allowed_lcd_text_); 5280 layers_always_allowed_lcd_text_);
5281 EXPECT_EQ(expect_lcd_text, root_->can_use_lcd_text()); 5281 EXPECT_EQ(expect_lcd_text, root_->can_use_lcd_text());
5282 EXPECT_EQ(expect_lcd_text, child_->can_use_lcd_text()); 5282 EXPECT_EQ(expect_lcd_text, child_->can_use_lcd_text());
5283 EXPECT_EQ(expect_lcd_text, grand_child_->can_use_lcd_text()); 5283 EXPECT_EQ(expect_lcd_text, grand_child_->can_use_lcd_text());
5284 5284
5285 // Add opacity animation. 5285 // Add opacity animation.
5286 child_->SetOpacity(0.9f); 5286 child_->test_properties()->opacity = 0.9f;
5287 child_->layer_tree_impl()->property_trees()->needs_rebuild = true; 5287 child_->layer_tree_impl()->property_trees()->needs_rebuild = true;
5288 AddOpacityTransitionToLayerWithPlayer(child_->id(), timeline(), 10.0, 0.9f, 5288 AddOpacityTransitionToLayerWithPlayer(child_->id(), timeline(), 10.0, 0.9f,
5289 0.1f, false); 5289 0.1f, false);
5290 ExecuteCalculateDrawProperties(root_, 1.f, 1.f, NULL, can_use_lcd_text_, 5290 ExecuteCalculateDrawProperties(root_, 1.f, 1.f, NULL, can_use_lcd_text_,
5291 layers_always_allowed_lcd_text_); 5291 layers_always_allowed_lcd_text_);
5292 // Text LCD should be adjusted while animation is active. 5292 // Text LCD should be adjusted while animation is active.
5293 EXPECT_EQ(expect_lcd_text, root_->can_use_lcd_text()); 5293 EXPECT_EQ(expect_lcd_text, root_->can_use_lcd_text());
5294 EXPECT_EQ(expect_not_lcd_text, child_->can_use_lcd_text()); 5294 EXPECT_EQ(expect_not_lcd_text, child_->can_use_lcd_text());
5295 EXPECT_EQ(expect_not_lcd_text, grand_child_->can_use_lcd_text()); 5295 EXPECT_EQ(expect_not_lcd_text, grand_child_->can_use_lcd_text());
5296 } 5296 }
(...skipping 3401 matching lines...) Expand 10 before | Expand all | Expand 10 after
8698 host_impl.active_tree()->property_trees()->needs_rebuild = true; 8698 host_impl.active_tree()->property_trees()->needs_rebuild = true;
8699 ExecuteCalculateDrawPropertiesWithPropertyTrees(root_ptr); 8699 ExecuteCalculateDrawPropertiesWithPropertyTrees(root_ptr);
8700 EXPECT_EQ(gfx::Rect(0, 0), grandchild_ptr->visible_layer_rect()); 8700 EXPECT_EQ(gfx::Rect(0, 0), grandchild_ptr->visible_layer_rect());
8701 child_ptr->SetTransform(identity); 8701 child_ptr->SetTransform(identity);
8702 8702
8703 child_ptr->test_properties()->hide_layer_and_subtree = true; 8703 child_ptr->test_properties()->hide_layer_and_subtree = true;
8704 ExecuteCalculateDrawPropertiesWithPropertyTrees(root_ptr); 8704 ExecuteCalculateDrawPropertiesWithPropertyTrees(root_ptr);
8705 EXPECT_EQ(gfx::Rect(0, 0), grandchild_ptr->visible_layer_rect()); 8705 EXPECT_EQ(gfx::Rect(0, 0), grandchild_ptr->visible_layer_rect());
8706 child_ptr->test_properties()->hide_layer_and_subtree = false; 8706 child_ptr->test_properties()->hide_layer_and_subtree = false;
8707 8707
8708 child_ptr->SetOpacity(0.f); 8708 child_ptr->OnOpacityAnimated(0.f);
8709 ExecuteCalculateDrawPropertiesWithPropertyTrees(root_ptr); 8709 ExecuteCalculateDrawPropertiesWithPropertyTrees(root_ptr);
8710 EXPECT_EQ(gfx::Rect(0, 0), grandchild_ptr->visible_layer_rect()); 8710 EXPECT_EQ(gfx::Rect(0, 0), grandchild_ptr->visible_layer_rect());
8711 child_ptr->SetOpacity(1.f); 8711 child_ptr->test_properties()->opacity = 1.f;
8712 8712
8713 root_ptr->SetTransform(singular); 8713 root_ptr->SetTransform(singular);
8714 // Force transform tree to have a node for child, so that ancestor's 8714 // Force transform tree to have a node for child, so that ancestor's
8715 // invertible transform can be tested. 8715 // invertible transform can be tested.
8716 child_ptr->SetTransform(rotate); 8716 child_ptr->SetTransform(rotate);
8717 host_impl.active_tree()->property_trees()->needs_rebuild = true; 8717 host_impl.active_tree()->property_trees()->needs_rebuild = true;
8718 ExecuteCalculateDrawPropertiesWithPropertyTrees(root_ptr); 8718 ExecuteCalculateDrawPropertiesWithPropertyTrees(root_ptr);
8719 EXPECT_EQ(gfx::Rect(0, 0), grandchild_ptr->visible_layer_rect()); 8719 EXPECT_EQ(gfx::Rect(0, 0), grandchild_ptr->visible_layer_rect());
8720 root_ptr->SetTransform(identity); 8720 root_ptr->SetTransform(identity);
8721 child_ptr->SetTransform(identity); 8721 child_ptr->SetTransform(identity);
8722 8722
8723 root_ptr->SetOpacity(0.f); 8723 root_ptr->test_properties()->opacity = 0.f;
8724 child_ptr->SetOpacity(0.7f); 8724 child_ptr->test_properties()->opacity = 0.7f;
8725 host_impl.active_tree()->property_trees()->needs_rebuild = true; 8725 host_impl.active_tree()->property_trees()->needs_rebuild = true;
8726 ExecuteCalculateDrawPropertiesWithPropertyTrees(root_ptr); 8726 ExecuteCalculateDrawPropertiesWithPropertyTrees(root_ptr);
8727 EXPECT_EQ(gfx::Rect(0, 0), grandchild_ptr->visible_layer_rect()); 8727 EXPECT_EQ(gfx::Rect(0, 0), grandchild_ptr->visible_layer_rect());
8728 root_ptr->SetOpacity(1.f); 8728 root_ptr->test_properties()->opacity = 1.f;
8729 8729
8730 child_ptr->SetOpacity(0.f); 8730 child_ptr->test_properties()->opacity = 0.f;
8731 // Now, even though child has zero opacity, we will configure |grandchild| and 8731 // Now, even though child has zero opacity, we will configure |grandchild| and
8732 // |greatgrandchild| in several ways that should force the subtree to be 8732 // |greatgrandchild| in several ways that should force the subtree to be
8733 // processed anyhow. 8733 // processed anyhow.
8734 std::vector<std::unique_ptr<CopyOutputRequest>> requests; 8734 std::vector<std::unique_ptr<CopyOutputRequest>> requests;
8735 requests.push_back(CopyOutputRequest::CreateEmptyRequest()); 8735 requests.push_back(CopyOutputRequest::CreateEmptyRequest());
8736 8736
8737 grandchild_ptr->PassCopyRequests(&requests); 8737 grandchild_ptr->PassCopyRequests(&requests);
8738 root_ptr->layer_tree_impl()->property_trees()->needs_rebuild = true; 8738 root_ptr->layer_tree_impl()->property_trees()->needs_rebuild = true;
8739 ExecuteCalculateDrawPropertiesWithPropertyTrees(root_ptr); 8739 ExecuteCalculateDrawPropertiesWithPropertyTrees(root_ptr);
8740 EXPECT_EQ(gfx::Rect(10, 10), grandchild_ptr->visible_layer_rect()); 8740 EXPECT_EQ(gfx::Rect(10, 10), grandchild_ptr->visible_layer_rect());
8741 requests.clear(); 8741 requests.clear();
8742 grandchild_ptr->PassCopyRequests(&requests); 8742 grandchild_ptr->PassCopyRequests(&requests);
8743 child_ptr->SetOpacity(1.f); 8743 child_ptr->test_properties()->opacity = 1.f;
8744 8744
8745 // A double sided render surface with backface visible should not be skipped 8745 // A double sided render surface with backface visible should not be skipped
8746 grandchild_ptr->set_visible_layer_rect(gfx::Rect()); 8746 grandchild_ptr->set_visible_layer_rect(gfx::Rect());
8747 child_ptr->SetHasRenderSurface(true); 8747 child_ptr->SetHasRenderSurface(true);
8748 child_ptr->test_properties()->double_sided = true; 8748 child_ptr->test_properties()->double_sided = true;
8749 child_ptr->SetTransform(rotate_back_and_translate); 8749 child_ptr->SetTransform(rotate_back_and_translate);
8750 root_ptr->layer_tree_impl()->property_trees()->needs_rebuild = true; 8750 root_ptr->layer_tree_impl()->property_trees()->needs_rebuild = true;
8751 ExecuteCalculateDrawPropertiesWithPropertyTrees(root_ptr); 8751 ExecuteCalculateDrawPropertiesWithPropertyTrees(root_ptr);
8752 EXPECT_EQ(gfx::Rect(10, 10), grandchild_ptr->visible_layer_rect()); 8752 EXPECT_EQ(gfx::Rect(10, 10), grandchild_ptr->visible_layer_rect());
8753 child_ptr->SetTransform(identity); 8753 child_ptr->SetTransform(identity);
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
8892 FloatKeyframe::Create(base::TimeDelta::FromSecondsD(1.0), 0.3f, nullptr)); 8892 FloatKeyframe::Create(base::TimeDelta::FromSecondsD(1.0), 0.3f, nullptr));
8893 std::unique_ptr<Animation> animation( 8893 std::unique_ptr<Animation> animation(
8894 Animation::Create(std::move(curve), 3, 3, TargetProperty::OPACITY)); 8894 Animation::Create(std::move(curve), 3, 3, TargetProperty::OPACITY));
8895 scoped_refptr<AnimationPlayer> player(AnimationPlayer::Create(1)); 8895 scoped_refptr<AnimationPlayer> player(AnimationPlayer::Create(1));
8896 host_impl.active_tree()->animation_host()->RegisterPlayerForElement( 8896 host_impl.active_tree()->animation_host()->RegisterPlayerForElement(
8897 root_ptr->id(), player.get()); 8897 root_ptr->id(), player.get());
8898 host_impl.active_tree() 8898 host_impl.active_tree()
8899 ->animation_host() 8899 ->animation_host()
8900 ->GetElementAnimationsForElementId(root_ptr->id()) 8900 ->GetElementAnimationsForElementId(root_ptr->id())
8901 ->AddAnimation(std::move(animation)); 8901 ->AddAnimation(std::move(animation));
8902 root_ptr->SetOpacity(0); 8902 root_ptr->test_properties()->opacity = 0.f;
8903 grandchild_ptr->set_visible_layer_rect(gfx::Rect()); 8903 grandchild_ptr->set_visible_layer_rect(gfx::Rect());
8904 root_ptr->layer_tree_impl()->property_trees()->needs_rebuild = true; 8904 root_ptr->layer_tree_impl()->property_trees()->needs_rebuild = true;
8905 ExecuteCalculateDrawPropertiesWithPropertyTrees(root_ptr); 8905 ExecuteCalculateDrawPropertiesWithPropertyTrees(root_ptr);
8906 EXPECT_EQ(gfx::Rect(10, 10), grandchild_ptr->visible_layer_rect()); 8906 EXPECT_EQ(gfx::Rect(10, 10), grandchild_ptr->visible_layer_rect());
8907 8907
8908 host_impl.active_tree()->animation_host()->UnregisterPlayerForElement( 8908 host_impl.active_tree()->animation_host()->UnregisterPlayerForElement(
8909 root_ptr->id(), player.get()); 8909 root_ptr->id(), player.get());
8910 } 8910 }
8911 8911
8912 TEST_F(LayerTreeHostCommonTest, SkippingLayer) { 8912 TEST_F(LayerTreeHostCommonTest, SkippingLayer) {
(...skipping 26 matching lines...) Expand all
8939 gfx::Transform rotate; 8939 gfx::Transform rotate;
8940 child->test_properties()->double_sided = false; 8940 child->test_properties()->double_sided = false;
8941 rotate.RotateAboutXAxis(180.f); 8941 rotate.RotateAboutXAxis(180.f);
8942 child->SetTransform(rotate); 8942 child->SetTransform(rotate);
8943 root->layer_tree_impl()->property_trees()->needs_rebuild = true; 8943 root->layer_tree_impl()->property_trees()->needs_rebuild = true;
8944 ExecuteCalculateDrawProperties(root); 8944 ExecuteCalculateDrawProperties(root);
8945 EXPECT_EQ(gfx::Rect(0, 0), child->visible_layer_rect()); 8945 EXPECT_EQ(gfx::Rect(0, 0), child->visible_layer_rect());
8946 child->test_properties()->double_sided = true; 8946 child->test_properties()->double_sided = true;
8947 child->SetTransform(identity); 8947 child->SetTransform(identity);
8948 8948
8949 child->SetOpacity(0.f); 8949 child->test_properties()->opacity = 0.f;
8950 root->layer_tree_impl()->property_trees()->needs_rebuild = true; 8950 root->layer_tree_impl()->property_trees()->needs_rebuild = true;
8951 ExecuteCalculateDrawProperties(root); 8951 ExecuteCalculateDrawProperties(root);
8952 EXPECT_EQ(gfx::Rect(0, 0), child->visible_layer_rect()); 8952 EXPECT_EQ(gfx::Rect(0, 0), child->visible_layer_rect());
8953 } 8953 }
8954 8954
8955 TEST_F(LayerTreeHostCommonTest, LayerTreeRebuildTest) { 8955 TEST_F(LayerTreeHostCommonTest, LayerTreeRebuildTest) {
8956 // Ensure that the treewalk in LayerTreeHostCommom:: 8956 // Ensure that the treewalk in LayerTreeHostCommom::
8957 // PreCalculateMetaInformation happens when its required. 8957 // PreCalculateMetaInformation happens when its required.
8958 scoped_refptr<Layer> root = Layer::Create(); 8958 scoped_refptr<Layer> root = Layer::Create();
8959 scoped_refptr<Layer> parent = Layer::Create(); 8959 scoped_refptr<Layer> parent = Layer::Create();
(...skipping 477 matching lines...) Expand 10 before | Expand all | Expand 10 after
9437 gfx::PointF(), gfx::Size(30, 30), true, false, 9437 gfx::PointF(), gfx::Size(30, 30), true, false,
9438 true); 9438 true);
9439 gfx::Transform translation; 9439 gfx::Transform translation;
9440 translation.Translate(10, 10); 9440 translation.Translate(10, 10);
9441 SetLayerPropertiesForTesting(test_layer, translation, gfx::Point3F(), 9441 SetLayerPropertiesForTesting(test_layer, translation, gfx::Point3F(),
9442 gfx::PointF(), gfx::Size(20, 20), true, false, 9442 gfx::PointF(), gfx::Size(20, 20), true, false,
9443 false); 9443 false);
9444 9444
9445 render_surface->SetMasksToBounds(true); 9445 render_surface->SetMasksToBounds(true);
9446 test_layer->SetDrawsContent(true); 9446 test_layer->SetDrawsContent(true);
9447 test_layer->SetOpacity(0); 9447 test_layer->test_properties()->opacity = 0.f;
9448 test_layer->SetTouchEventHandlerRegion(gfx::Rect(0, 0, 20, 20)); 9448 test_layer->SetTouchEventHandlerRegion(gfx::Rect(0, 0, 20, 20));
9449 9449
9450 ExecuteCalculateDrawProperties(root); 9450 ExecuteCalculateDrawProperties(root);
9451 EXPECT_EQ(translation, test_layer->ScreenSpaceTransform()); 9451 EXPECT_EQ(translation, test_layer->ScreenSpaceTransform());
9452 } 9452 }
9453 9453
9454 TEST_F(LayerTreeHostCommonTest, ClipChildVisibleRect) { 9454 TEST_F(LayerTreeHostCommonTest, ClipChildVisibleRect) {
9455 LayerImpl* root = root_layer(); 9455 LayerImpl* root = root_layer();
9456 LayerImpl* clip_parent = AddChildToRoot<LayerImpl>(); 9456 LayerImpl* clip_parent = AddChildToRoot<LayerImpl>();
9457 LayerImpl* render_surface = AddChild<LayerImpl>(clip_parent); 9457 LayerImpl* render_surface = AddChild<LayerImpl>(clip_parent);
(...skipping 630 matching lines...) Expand 10 before | Expand all | Expand 10 after
10088 EXPECT_EQ(scroll_child6.id, grand_child10->scroll_tree_index()); 10088 EXPECT_EQ(scroll_child6.id, grand_child10->scroll_tree_index());
10089 EXPECT_EQ(scroll_root1.id, parent3->scroll_tree_index()); 10089 EXPECT_EQ(scroll_root1.id, parent3->scroll_tree_index());
10090 EXPECT_EQ(scroll_child7.id, child8->scroll_tree_index()); 10090 EXPECT_EQ(scroll_child7.id, child8->scroll_tree_index());
10091 EXPECT_EQ(scroll_root1.id, parent4->scroll_tree_index()); 10091 EXPECT_EQ(scroll_root1.id, parent4->scroll_tree_index());
10092 EXPECT_EQ(scroll_root1.id, child9->scroll_tree_index()); 10092 EXPECT_EQ(scroll_root1.id, child9->scroll_tree_index());
10093 EXPECT_EQ(scroll_root1.id, grand_child12->scroll_tree_index()); 10093 EXPECT_EQ(scroll_root1.id, grand_child12->scroll_tree_index());
10094 } 10094 }
10095 10095
10096 } // namespace 10096 } // namespace
10097 } // namespace cc 10097 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698