OLD | NEW |
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 Loading... |
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 Loading... |
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 Loading... |
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 Loading... |
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 Loading... |
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 Loading... |
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 Loading... |
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 Loading... |
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 Loading... |
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 Loading... |
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 Loading... |
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 Loading... |
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 Loading... |
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 Loading... |
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 Loading... |
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 761 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4991 grand_child->SetDrawsContent(true); | 4991 grand_child->SetDrawsContent(true); |
4992 | 4992 |
4993 const gfx::Transform identity_matrix; | 4993 const gfx::Transform identity_matrix; |
4994 SetLayerPropertiesForTesting(root, identity_matrix, gfx::Point3F(), | 4994 SetLayerPropertiesForTesting(root, identity_matrix, gfx::Point3F(), |
4995 gfx::PointF(), gfx::Size(100, 100), true, false); | 4995 gfx::PointF(), gfx::Size(100, 100), true, false); |
4996 SetLayerPropertiesForTesting(child, identity_matrix, gfx::Point3F(), | 4996 SetLayerPropertiesForTesting(child, identity_matrix, gfx::Point3F(), |
4997 gfx::PointF(), gfx::Size(10, 10), true, false); | 4997 gfx::PointF(), gfx::Size(10, 10), true, false); |
4998 SetLayerPropertiesForTesting(grand_child, identity_matrix, gfx::Point3F(), | 4998 SetLayerPropertiesForTesting(grand_child, identity_matrix, gfx::Point3F(), |
4999 gfx::PointF(), gfx::Size(10, 10), true, false); | 4999 gfx::PointF(), gfx::Size(10, 10), true, false); |
5000 | 5000 |
5001 child->SetOpacity(0.5f); | 5001 child->test_properties()->opacity = 0.5f; |
5002 | 5002 |
5003 ExecuteCalculateDrawProperties(root); | 5003 ExecuteCalculateDrawProperties(root); |
5004 | 5004 |
5005 EXPECT_FALSE(child->has_render_surface()); | 5005 EXPECT_FALSE(child->has_render_surface()); |
5006 } | 5006 } |
5007 | 5007 |
5008 TEST_F(LayerTreeHostCommonTest, OpacityAnimatingOnPendingTree) { | 5008 TEST_F(LayerTreeHostCommonTest, OpacityAnimatingOnPendingTree) { |
5009 FakeImplTaskRunnerProvider task_runner_provider; | 5009 FakeImplTaskRunnerProvider task_runner_provider; |
5010 TestSharedBitmapManager shared_bitmap_manager; | 5010 TestSharedBitmapManager shared_bitmap_manager; |
5011 TestTaskGraphRunner task_graph_runner; | 5011 TestTaskGraphRunner task_graph_runner; |
5012 FakeLayerTreeHostImpl host_impl(host()->settings(), &task_runner_provider, | 5012 FakeLayerTreeHostImpl host_impl(host()->settings(), &task_runner_provider, |
5013 &shared_bitmap_manager, &task_graph_runner); | 5013 &shared_bitmap_manager, &task_graph_runner); |
5014 host_impl.CreatePendingTree(); | 5014 host_impl.CreatePendingTree(); |
5015 std::unique_ptr<LayerImpl> root = | 5015 std::unique_ptr<LayerImpl> root = |
5016 LayerImpl::Create(host_impl.pending_tree(), 1); | 5016 LayerImpl::Create(host_impl.pending_tree(), 1); |
5017 | 5017 |
5018 const gfx::Transform identity_matrix; | 5018 const gfx::Transform identity_matrix; |
5019 SetLayerPropertiesForTesting(root.get(), identity_matrix, gfx::Point3F(), | 5019 SetLayerPropertiesForTesting(root.get(), identity_matrix, gfx::Point3F(), |
5020 gfx::PointF(), gfx::Size(100, 100), true, false, | 5020 gfx::PointF(), gfx::Size(100, 100), true, false, |
5021 false); | 5021 false); |
5022 root->SetDrawsContent(true); | 5022 root->SetDrawsContent(true); |
5023 | 5023 |
5024 std::unique_ptr<LayerImpl> child = | 5024 std::unique_ptr<LayerImpl> child = |
5025 LayerImpl::Create(host_impl.pending_tree(), 2); | 5025 LayerImpl::Create(host_impl.pending_tree(), 2); |
5026 SetLayerPropertiesForTesting(child.get(), identity_matrix, gfx::Point3F(), | 5026 SetLayerPropertiesForTesting(child.get(), identity_matrix, gfx::Point3F(), |
5027 gfx::PointF(), gfx::Size(50, 50), true, false, | 5027 gfx::PointF(), gfx::Size(50, 50), true, false, |
5028 false); | 5028 false); |
5029 child->SetDrawsContent(true); | 5029 child->SetDrawsContent(true); |
5030 child->SetOpacity(0.0f); | 5030 child->test_properties()->opacity = 0.0f; |
5031 | 5031 |
5032 const int child_id = child->id(); | 5032 const int child_id = child->id(); |
5033 root->AddChild(std::move(child)); | 5033 root->AddChild(std::move(child)); |
5034 root->SetHasRenderSurface(true); | 5034 root->SetHasRenderSurface(true); |
5035 LayerImpl* root_layer = root.get(); | 5035 LayerImpl* root_layer = root.get(); |
5036 host_impl.pending_tree()->SetRootLayer(std::move(root)); | 5036 host_impl.pending_tree()->SetRootLayer(std::move(root)); |
5037 host_impl.pending_tree()->BuildPropertyTreesForTesting(); | 5037 host_impl.pending_tree()->BuildPropertyTreesForTesting(); |
5038 // Add opacity animation. | 5038 // Add opacity animation. |
5039 scoped_refptr<AnimationTimeline> timeline = | 5039 scoped_refptr<AnimationTimeline> timeline = |
5040 AnimationTimeline::Create(AnimationIdProvider::NextTimelineId()); | 5040 AnimationTimeline::Create(AnimationIdProvider::NextTimelineId()); |
5041 host_impl.animation_host()->AddAnimationTimeline(timeline); | 5041 host_impl.animation_host()->AddAnimationTimeline(timeline); |
5042 | 5042 |
5043 AddOpacityTransitionToLayerWithPlayer(child_id, timeline, 10.0, 0.0f, 1.0f, | 5043 AddOpacityTransitionToLayerWithPlayer(child_id, timeline, 10.0, 0.0f, 1.0f, |
5044 false); | 5044 false); |
5045 | 5045 |
5046 LayerImplList render_surface_layer_list; | 5046 LayerImplList render_surface_layer_list; |
5047 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( | 5047 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( |
5048 root_layer, root_layer->bounds(), &render_surface_layer_list); | 5048 root_layer, root_layer->bounds(), &render_surface_layer_list); |
5049 inputs.can_adjust_raster_scales = true; | 5049 inputs.can_adjust_raster_scales = true; |
5050 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); | 5050 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); |
5051 | 5051 |
5052 // We should have one render surface and two layers. The child | 5052 // We should have one render surface and two layers. The child |
5053 // layer should be included even though it is transparent. | 5053 // layer should be included even though it is transparent. |
5054 ASSERT_EQ(1u, render_surface_layer_list.size()); | 5054 ASSERT_EQ(1u, render_surface_layer_list.size()); |
5055 ASSERT_EQ(2u, root_layer->render_surface()->layer_list().size()); | 5055 ASSERT_EQ(2u, root_layer->render_surface()->layer_list().size()); |
5056 | 5056 |
5057 // If the root itself is hidden, the child should not be drawn even if it has | 5057 // If the root itself is hidden, the child should not be drawn even if it has |
5058 // an animating opacity. | 5058 // an animating opacity. |
5059 root_layer->SetOpacity(0.0f); | 5059 root_layer->test_properties()->opacity = 0.0f; |
5060 root_layer->layer_tree_impl()->property_trees()->needs_rebuild = true; | 5060 root_layer->layer_tree_impl()->property_trees()->needs_rebuild = true; |
5061 LayerImplList render_surface_layer_list2; | 5061 LayerImplList render_surface_layer_list2; |
5062 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs2( | 5062 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs2( |
5063 root_layer, root_layer->bounds(), &render_surface_layer_list2); | 5063 root_layer, root_layer->bounds(), &render_surface_layer_list2); |
5064 inputs2.can_adjust_raster_scales = true; | 5064 inputs2.can_adjust_raster_scales = true; |
5065 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs2); | 5065 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs2); |
5066 | 5066 |
5067 LayerImpl* child_ptr = root_layer->layer_tree_impl()->LayerById(2); | 5067 LayerImpl* child_ptr = root_layer->layer_tree_impl()->LayerById(2); |
5068 EffectTree& tree = | 5068 EffectTree& tree = |
5069 root_layer->layer_tree_impl()->property_trees()->effect_tree; | 5069 root_layer->layer_tree_impl()->property_trees()->effect_tree; |
5070 EffectNode* node = tree.Node(child_ptr->effect_tree_index()); | 5070 EffectNode* node = tree.Node(child_ptr->effect_tree_index()); |
5071 EXPECT_FALSE(node->data.is_drawn); | 5071 EXPECT_FALSE(node->data.is_drawn); |
5072 | 5072 |
5073 // A layer should be drawn and it should contribute to drawn surface when | 5073 // A layer should be drawn and it should contribute to drawn surface when |
5074 // it has animating opacity even if it has opacity 0. | 5074 // it has animating opacity even if it has opacity 0. |
5075 root_layer->SetOpacity(1.0f); | 5075 root_layer->test_properties()->opacity = 1.0f; |
5076 child_ptr->SetOpacity(0.0f); | 5076 child_ptr->test_properties()->opacity = 0.0f; |
5077 root_layer->layer_tree_impl()->property_trees()->needs_rebuild = true; | 5077 root_layer->layer_tree_impl()->property_trees()->needs_rebuild = true; |
5078 LayerImplList render_surface_layer_list3; | 5078 LayerImplList render_surface_layer_list3; |
5079 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs3( | 5079 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs3( |
5080 root_layer, root_layer->bounds(), &render_surface_layer_list3); | 5080 root_layer, root_layer->bounds(), &render_surface_layer_list3); |
5081 inputs3.can_adjust_raster_scales = true; | 5081 inputs3.can_adjust_raster_scales = true; |
5082 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs3); | 5082 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs3); |
5083 | 5083 |
5084 child_ptr = root_layer->layer_tree_impl()->LayerById(2); | 5084 child_ptr = root_layer->layer_tree_impl()->LayerById(2); |
5085 tree = root_layer->layer_tree_impl()->property_trees()->effect_tree; | 5085 tree = root_layer->layer_tree_impl()->property_trees()->effect_tree; |
5086 node = tree.Node(child_ptr->effect_tree_index()); | 5086 node = tree.Node(child_ptr->effect_tree_index()); |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5242 child_->layer_tree_impl()->property_trees()->needs_rebuild = true; | 5242 child_->layer_tree_impl()->property_trees()->needs_rebuild = true; |
5243 ExecuteCalculateDrawProperties(root_, 1.f, 1.f, NULL, can_use_lcd_text_, | 5243 ExecuteCalculateDrawProperties(root_, 1.f, 1.f, NULL, can_use_lcd_text_, |
5244 layers_always_allowed_lcd_text_); | 5244 layers_always_allowed_lcd_text_); |
5245 EXPECT_EQ(expect_lcd_text, root_->can_use_lcd_text()); | 5245 EXPECT_EQ(expect_lcd_text, root_->can_use_lcd_text()); |
5246 EXPECT_EQ(expect_not_lcd_text, child_->can_use_lcd_text()); | 5246 EXPECT_EQ(expect_not_lcd_text, child_->can_use_lcd_text()); |
5247 EXPECT_EQ(expect_not_lcd_text, grand_child_->can_use_lcd_text()); | 5247 EXPECT_EQ(expect_not_lcd_text, grand_child_->can_use_lcd_text()); |
5248 | 5248 |
5249 // Case 7: Translucent. | 5249 // Case 7: Translucent. |
5250 child_->SetTransform(identity_matrix); | 5250 child_->SetTransform(identity_matrix); |
5251 child_->layer_tree_impl()->property_trees()->needs_rebuild = true; | 5251 child_->layer_tree_impl()->property_trees()->needs_rebuild = true; |
5252 child_->SetOpacity(0.5f); | 5252 child_->test_properties()->opacity = 0.5f; |
5253 ExecuteCalculateDrawProperties(root_, 1.f, 1.f, NULL, can_use_lcd_text_, | 5253 ExecuteCalculateDrawProperties(root_, 1.f, 1.f, NULL, can_use_lcd_text_, |
5254 layers_always_allowed_lcd_text_); | 5254 layers_always_allowed_lcd_text_); |
5255 EXPECT_EQ(expect_lcd_text, root_->can_use_lcd_text()); | 5255 EXPECT_EQ(expect_lcd_text, root_->can_use_lcd_text()); |
5256 EXPECT_EQ(expect_not_lcd_text, child_->can_use_lcd_text()); | 5256 EXPECT_EQ(expect_not_lcd_text, child_->can_use_lcd_text()); |
5257 EXPECT_EQ(expect_not_lcd_text, grand_child_->can_use_lcd_text()); | 5257 EXPECT_EQ(expect_not_lcd_text, grand_child_->can_use_lcd_text()); |
5258 | 5258 |
5259 // Case 8: Sanity check: restore transform and opacity. | 5259 // Case 8: Sanity check: restore transform and opacity. |
5260 child_->SetTransform(identity_matrix); | 5260 child_->SetTransform(identity_matrix); |
5261 child_->layer_tree_impl()->property_trees()->needs_rebuild = true; | 5261 child_->layer_tree_impl()->property_trees()->needs_rebuild = true; |
5262 child_->SetOpacity(1.f); | 5262 child_->test_properties()->opacity = 1.f; |
5263 ExecuteCalculateDrawProperties(root_, 1.f, 1.f, NULL, can_use_lcd_text_, | 5263 ExecuteCalculateDrawProperties(root_, 1.f, 1.f, NULL, can_use_lcd_text_, |
5264 layers_always_allowed_lcd_text_); | 5264 layers_always_allowed_lcd_text_); |
5265 EXPECT_EQ(expect_lcd_text, root_->can_use_lcd_text()); | 5265 EXPECT_EQ(expect_lcd_text, root_->can_use_lcd_text()); |
5266 EXPECT_EQ(expect_lcd_text, child_->can_use_lcd_text()); | 5266 EXPECT_EQ(expect_lcd_text, child_->can_use_lcd_text()); |
5267 EXPECT_EQ(expect_lcd_text, grand_child_->can_use_lcd_text()); | 5267 EXPECT_EQ(expect_lcd_text, grand_child_->can_use_lcd_text()); |
5268 | 5268 |
5269 // Case 9: Non-opaque content. | 5269 // Case 9: Non-opaque content. |
5270 child_->SetContentsOpaque(false); | 5270 child_->SetContentsOpaque(false); |
5271 ExecuteCalculateDrawProperties(root_, 1.f, 1.f, NULL, can_use_lcd_text_, | 5271 ExecuteCalculateDrawProperties(root_, 1.f, 1.f, NULL, can_use_lcd_text_, |
5272 layers_always_allowed_lcd_text_); | 5272 layers_always_allowed_lcd_text_); |
(...skipping 15 matching lines...) Expand all Loading... |
5288 bool expect_not_lcd_text = layers_always_allowed_lcd_text_; | 5288 bool expect_not_lcd_text = layers_always_allowed_lcd_text_; |
5289 | 5289 |
5290 // Sanity check: Make sure can_use_lcd_text_ is set on each node. | 5290 // Sanity check: Make sure can_use_lcd_text_ is set on each node. |
5291 ExecuteCalculateDrawProperties(root_, 1.f, 1.f, NULL, can_use_lcd_text_, | 5291 ExecuteCalculateDrawProperties(root_, 1.f, 1.f, NULL, can_use_lcd_text_, |
5292 layers_always_allowed_lcd_text_); | 5292 layers_always_allowed_lcd_text_); |
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_lcd_text, child_->can_use_lcd_text()); | 5294 EXPECT_EQ(expect_lcd_text, child_->can_use_lcd_text()); |
5295 EXPECT_EQ(expect_lcd_text, grand_child_->can_use_lcd_text()); | 5295 EXPECT_EQ(expect_lcd_text, grand_child_->can_use_lcd_text()); |
5296 | 5296 |
5297 // Add opacity animation. | 5297 // Add opacity animation. |
5298 child_->SetOpacity(0.9f); | 5298 child_->test_properties()->opacity = 0.9f; |
5299 child_->layer_tree_impl()->property_trees()->needs_rebuild = true; | 5299 child_->layer_tree_impl()->property_trees()->needs_rebuild = true; |
5300 AddOpacityTransitionToLayerWithPlayer(child_->id(), timeline(), 10.0, 0.9f, | 5300 AddOpacityTransitionToLayerWithPlayer(child_->id(), timeline(), 10.0, 0.9f, |
5301 0.1f, false); | 5301 0.1f, false); |
5302 ExecuteCalculateDrawProperties(root_, 1.f, 1.f, NULL, can_use_lcd_text_, | 5302 ExecuteCalculateDrawProperties(root_, 1.f, 1.f, NULL, can_use_lcd_text_, |
5303 layers_always_allowed_lcd_text_); | 5303 layers_always_allowed_lcd_text_); |
5304 // Text LCD should be adjusted while animation is active. | 5304 // Text LCD should be adjusted while animation is active. |
5305 EXPECT_EQ(expect_lcd_text, root_->can_use_lcd_text()); | 5305 EXPECT_EQ(expect_lcd_text, root_->can_use_lcd_text()); |
5306 EXPECT_EQ(expect_not_lcd_text, child_->can_use_lcd_text()); | 5306 EXPECT_EQ(expect_not_lcd_text, child_->can_use_lcd_text()); |
5307 EXPECT_EQ(expect_not_lcd_text, grand_child_->can_use_lcd_text()); | 5307 EXPECT_EQ(expect_not_lcd_text, grand_child_->can_use_lcd_text()); |
5308 } | 5308 } |
(...skipping 3395 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8704 host_impl.active_tree()->property_trees()->needs_rebuild = true; | 8704 host_impl.active_tree()->property_trees()->needs_rebuild = true; |
8705 ExecuteCalculateDrawPropertiesWithPropertyTrees(root_ptr); | 8705 ExecuteCalculateDrawPropertiesWithPropertyTrees(root_ptr); |
8706 EXPECT_EQ(gfx::Rect(0, 0), grandchild_ptr->visible_layer_rect()); | 8706 EXPECT_EQ(gfx::Rect(0, 0), grandchild_ptr->visible_layer_rect()); |
8707 child_ptr->SetTransform(identity); | 8707 child_ptr->SetTransform(identity); |
8708 | 8708 |
8709 child_ptr->test_properties()->hide_layer_and_subtree = true; | 8709 child_ptr->test_properties()->hide_layer_and_subtree = true; |
8710 ExecuteCalculateDrawPropertiesWithPropertyTrees(root_ptr); | 8710 ExecuteCalculateDrawPropertiesWithPropertyTrees(root_ptr); |
8711 EXPECT_EQ(gfx::Rect(0, 0), grandchild_ptr->visible_layer_rect()); | 8711 EXPECT_EQ(gfx::Rect(0, 0), grandchild_ptr->visible_layer_rect()); |
8712 child_ptr->test_properties()->hide_layer_and_subtree = false; | 8712 child_ptr->test_properties()->hide_layer_and_subtree = false; |
8713 | 8713 |
8714 child_ptr->SetOpacity(0.f); | 8714 child_ptr->OnOpacityAnimated(0.f); |
8715 ExecuteCalculateDrawPropertiesWithPropertyTrees(root_ptr); | 8715 ExecuteCalculateDrawPropertiesWithPropertyTrees(root_ptr); |
8716 EXPECT_EQ(gfx::Rect(0, 0), grandchild_ptr->visible_layer_rect()); | 8716 EXPECT_EQ(gfx::Rect(0, 0), grandchild_ptr->visible_layer_rect()); |
8717 child_ptr->SetOpacity(1.f); | 8717 child_ptr->test_properties()->opacity = 1.f; |
8718 | 8718 |
8719 root_ptr->SetTransform(singular); | 8719 root_ptr->SetTransform(singular); |
8720 // Force transform tree to have a node for child, so that ancestor's | 8720 // Force transform tree to have a node for child, so that ancestor's |
8721 // invertible transform can be tested. | 8721 // invertible transform can be tested. |
8722 child_ptr->SetTransform(rotate); | 8722 child_ptr->SetTransform(rotate); |
8723 host_impl.active_tree()->property_trees()->needs_rebuild = true; | 8723 host_impl.active_tree()->property_trees()->needs_rebuild = true; |
8724 ExecuteCalculateDrawPropertiesWithPropertyTrees(root_ptr); | 8724 ExecuteCalculateDrawPropertiesWithPropertyTrees(root_ptr); |
8725 EXPECT_EQ(gfx::Rect(0, 0), grandchild_ptr->visible_layer_rect()); | 8725 EXPECT_EQ(gfx::Rect(0, 0), grandchild_ptr->visible_layer_rect()); |
8726 root_ptr->SetTransform(identity); | 8726 root_ptr->SetTransform(identity); |
8727 child_ptr->SetTransform(identity); | 8727 child_ptr->SetTransform(identity); |
8728 | 8728 |
8729 root_ptr->SetOpacity(0.f); | 8729 root_ptr->test_properties()->opacity = 0.f; |
8730 child_ptr->SetOpacity(0.7f); | 8730 child_ptr->test_properties()->opacity = 0.7f; |
8731 host_impl.active_tree()->property_trees()->needs_rebuild = true; | 8731 host_impl.active_tree()->property_trees()->needs_rebuild = true; |
8732 ExecuteCalculateDrawPropertiesWithPropertyTrees(root_ptr); | 8732 ExecuteCalculateDrawPropertiesWithPropertyTrees(root_ptr); |
8733 EXPECT_EQ(gfx::Rect(0, 0), grandchild_ptr->visible_layer_rect()); | 8733 EXPECT_EQ(gfx::Rect(0, 0), grandchild_ptr->visible_layer_rect()); |
8734 root_ptr->SetOpacity(1.f); | 8734 root_ptr->test_properties()->opacity = 1.f; |
8735 | 8735 |
8736 child_ptr->SetOpacity(0.f); | 8736 child_ptr->test_properties()->opacity = 0.f; |
8737 // Now, even though child has zero opacity, we will configure |grandchild| and | 8737 // Now, even though child has zero opacity, we will configure |grandchild| and |
8738 // |greatgrandchild| in several ways that should force the subtree to be | 8738 // |greatgrandchild| in several ways that should force the subtree to be |
8739 // processed anyhow. | 8739 // processed anyhow. |
8740 grandchild_ptr->test_properties()->copy_requests.push_back( | 8740 grandchild_ptr->test_properties()->copy_requests.push_back( |
8741 CopyOutputRequest::CreateEmptyRequest()); | 8741 CopyOutputRequest::CreateEmptyRequest()); |
8742 root_ptr->layer_tree_impl()->property_trees()->needs_rebuild = true; | 8742 root_ptr->layer_tree_impl()->property_trees()->needs_rebuild = true; |
8743 ExecuteCalculateDrawPropertiesWithPropertyTrees(root_ptr); | 8743 ExecuteCalculateDrawPropertiesWithPropertyTrees(root_ptr); |
8744 EXPECT_EQ(gfx::Rect(10, 10), grandchild_ptr->visible_layer_rect()); | 8744 EXPECT_EQ(gfx::Rect(10, 10), grandchild_ptr->visible_layer_rect()); |
8745 | 8745 |
8746 host_impl.active_tree()->property_trees()->effect_tree.ClearCopyRequests(); | 8746 host_impl.active_tree()->property_trees()->effect_tree.ClearCopyRequests(); |
8747 child_ptr->SetOpacity(1.f); | 8747 child_ptr->test_properties()->opacity = 1.f; |
8748 | 8748 |
8749 // A double sided render surface with backface visible should not be skipped | 8749 // A double sided render surface with backface visible should not be skipped |
8750 grandchild_ptr->set_visible_layer_rect(gfx::Rect()); | 8750 grandchild_ptr->set_visible_layer_rect(gfx::Rect()); |
8751 child_ptr->SetHasRenderSurface(true); | 8751 child_ptr->SetHasRenderSurface(true); |
8752 child_ptr->test_properties()->double_sided = true; | 8752 child_ptr->test_properties()->double_sided = true; |
8753 child_ptr->SetTransform(rotate_back_and_translate); | 8753 child_ptr->SetTransform(rotate_back_and_translate); |
8754 root_ptr->layer_tree_impl()->property_trees()->needs_rebuild = true; | 8754 root_ptr->layer_tree_impl()->property_trees()->needs_rebuild = true; |
8755 ExecuteCalculateDrawPropertiesWithPropertyTrees(root_ptr); | 8755 ExecuteCalculateDrawPropertiesWithPropertyTrees(root_ptr); |
8756 EXPECT_EQ(gfx::Rect(10, 10), grandchild_ptr->visible_layer_rect()); | 8756 EXPECT_EQ(gfx::Rect(10, 10), grandchild_ptr->visible_layer_rect()); |
8757 child_ptr->SetTransform(identity); | 8757 child_ptr->SetTransform(identity); |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8896 FloatKeyframe::Create(base::TimeDelta::FromSecondsD(1.0), 0.3f, nullptr)); | 8896 FloatKeyframe::Create(base::TimeDelta::FromSecondsD(1.0), 0.3f, nullptr)); |
8897 std::unique_ptr<Animation> animation( | 8897 std::unique_ptr<Animation> animation( |
8898 Animation::Create(std::move(curve), 3, 3, TargetProperty::OPACITY)); | 8898 Animation::Create(std::move(curve), 3, 3, TargetProperty::OPACITY)); |
8899 scoped_refptr<AnimationPlayer> player(AnimationPlayer::Create(1)); | 8899 scoped_refptr<AnimationPlayer> player(AnimationPlayer::Create(1)); |
8900 host_impl.active_tree()->animation_host()->RegisterPlayerForElement( | 8900 host_impl.active_tree()->animation_host()->RegisterPlayerForElement( |
8901 root_ptr->id(), player.get()); | 8901 root_ptr->id(), player.get()); |
8902 host_impl.active_tree() | 8902 host_impl.active_tree() |
8903 ->animation_host() | 8903 ->animation_host() |
8904 ->GetElementAnimationsForElementId(root_ptr->id()) | 8904 ->GetElementAnimationsForElementId(root_ptr->id()) |
8905 ->AddAnimation(std::move(animation)); | 8905 ->AddAnimation(std::move(animation)); |
8906 root_ptr->SetOpacity(0); | 8906 root_ptr->test_properties()->opacity = 0.f; |
8907 grandchild_ptr->set_visible_layer_rect(gfx::Rect()); | 8907 grandchild_ptr->set_visible_layer_rect(gfx::Rect()); |
8908 root_ptr->layer_tree_impl()->property_trees()->needs_rebuild = true; | 8908 root_ptr->layer_tree_impl()->property_trees()->needs_rebuild = true; |
8909 ExecuteCalculateDrawPropertiesWithPropertyTrees(root_ptr); | 8909 ExecuteCalculateDrawPropertiesWithPropertyTrees(root_ptr); |
8910 EXPECT_EQ(gfx::Rect(10, 10), grandchild_ptr->visible_layer_rect()); | 8910 EXPECT_EQ(gfx::Rect(10, 10), grandchild_ptr->visible_layer_rect()); |
8911 | 8911 |
8912 host_impl.active_tree()->animation_host()->UnregisterPlayerForElement( | 8912 host_impl.active_tree()->animation_host()->UnregisterPlayerForElement( |
8913 root_ptr->id(), player.get()); | 8913 root_ptr->id(), player.get()); |
8914 } | 8914 } |
8915 | 8915 |
8916 TEST_F(LayerTreeHostCommonTest, SkippingLayer) { | 8916 TEST_F(LayerTreeHostCommonTest, SkippingLayer) { |
(...skipping 26 matching lines...) Expand all Loading... |
8943 gfx::Transform rotate; | 8943 gfx::Transform rotate; |
8944 child->test_properties()->double_sided = false; | 8944 child->test_properties()->double_sided = false; |
8945 rotate.RotateAboutXAxis(180.f); | 8945 rotate.RotateAboutXAxis(180.f); |
8946 child->SetTransform(rotate); | 8946 child->SetTransform(rotate); |
8947 root->layer_tree_impl()->property_trees()->needs_rebuild = true; | 8947 root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
8948 ExecuteCalculateDrawProperties(root); | 8948 ExecuteCalculateDrawProperties(root); |
8949 EXPECT_EQ(gfx::Rect(0, 0), child->visible_layer_rect()); | 8949 EXPECT_EQ(gfx::Rect(0, 0), child->visible_layer_rect()); |
8950 child->test_properties()->double_sided = true; | 8950 child->test_properties()->double_sided = true; |
8951 child->SetTransform(identity); | 8951 child->SetTransform(identity); |
8952 | 8952 |
8953 child->SetOpacity(0.f); | 8953 child->test_properties()->opacity = 0.f; |
8954 root->layer_tree_impl()->property_trees()->needs_rebuild = true; | 8954 root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
8955 ExecuteCalculateDrawProperties(root); | 8955 ExecuteCalculateDrawProperties(root); |
8956 EXPECT_EQ(gfx::Rect(0, 0), child->visible_layer_rect()); | 8956 EXPECT_EQ(gfx::Rect(0, 0), child->visible_layer_rect()); |
8957 } | 8957 } |
8958 | 8958 |
8959 TEST_F(LayerTreeHostCommonTest, LayerTreeRebuildTest) { | 8959 TEST_F(LayerTreeHostCommonTest, LayerTreeRebuildTest) { |
8960 // Ensure that the treewalk in LayerTreeHostCommom:: | 8960 // Ensure that the treewalk in LayerTreeHostCommom:: |
8961 // PreCalculateMetaInformation happens when its required. | 8961 // PreCalculateMetaInformation happens when its required. |
8962 scoped_refptr<Layer> root = Layer::Create(); | 8962 scoped_refptr<Layer> root = Layer::Create(); |
8963 scoped_refptr<Layer> parent = Layer::Create(); | 8963 scoped_refptr<Layer> parent = Layer::Create(); |
(...skipping 477 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9441 gfx::PointF(), gfx::Size(30, 30), true, false, | 9441 gfx::PointF(), gfx::Size(30, 30), true, false, |
9442 true); | 9442 true); |
9443 gfx::Transform translation; | 9443 gfx::Transform translation; |
9444 translation.Translate(10, 10); | 9444 translation.Translate(10, 10); |
9445 SetLayerPropertiesForTesting(test_layer, translation, gfx::Point3F(), | 9445 SetLayerPropertiesForTesting(test_layer, translation, gfx::Point3F(), |
9446 gfx::PointF(), gfx::Size(20, 20), true, false, | 9446 gfx::PointF(), gfx::Size(20, 20), true, false, |
9447 false); | 9447 false); |
9448 | 9448 |
9449 render_surface->SetMasksToBounds(true); | 9449 render_surface->SetMasksToBounds(true); |
9450 test_layer->SetDrawsContent(true); | 9450 test_layer->SetDrawsContent(true); |
9451 test_layer->SetOpacity(0); | 9451 test_layer->test_properties()->opacity = 0.f; |
9452 test_layer->SetTouchEventHandlerRegion(gfx::Rect(0, 0, 20, 20)); | 9452 test_layer->SetTouchEventHandlerRegion(gfx::Rect(0, 0, 20, 20)); |
9453 | 9453 |
9454 ExecuteCalculateDrawProperties(root); | 9454 ExecuteCalculateDrawProperties(root); |
9455 EXPECT_EQ(translation, test_layer->ScreenSpaceTransform()); | 9455 EXPECT_EQ(translation, test_layer->ScreenSpaceTransform()); |
9456 } | 9456 } |
9457 | 9457 |
9458 TEST_F(LayerTreeHostCommonTest, ClipChildVisibleRect) { | 9458 TEST_F(LayerTreeHostCommonTest, ClipChildVisibleRect) { |
9459 LayerImpl* root = root_layer(); | 9459 LayerImpl* root = root_layer(); |
9460 LayerImpl* clip_parent = AddChildToRoot<LayerImpl>(); | 9460 LayerImpl* clip_parent = AddChildToRoot<LayerImpl>(); |
9461 LayerImpl* render_surface = AddChild<LayerImpl>(clip_parent); | 9461 LayerImpl* render_surface = AddChild<LayerImpl>(clip_parent); |
(...skipping 630 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10092 EXPECT_EQ(scroll_child6.id, grand_child10->scroll_tree_index()); | 10092 EXPECT_EQ(scroll_child6.id, grand_child10->scroll_tree_index()); |
10093 EXPECT_EQ(scroll_root1.id, parent3->scroll_tree_index()); | 10093 EXPECT_EQ(scroll_root1.id, parent3->scroll_tree_index()); |
10094 EXPECT_EQ(scroll_child7.id, child8->scroll_tree_index()); | 10094 EXPECT_EQ(scroll_child7.id, child8->scroll_tree_index()); |
10095 EXPECT_EQ(scroll_root1.id, parent4->scroll_tree_index()); | 10095 EXPECT_EQ(scroll_root1.id, parent4->scroll_tree_index()); |
10096 EXPECT_EQ(scroll_root1.id, child9->scroll_tree_index()); | 10096 EXPECT_EQ(scroll_root1.id, child9->scroll_tree_index()); |
10097 EXPECT_EQ(scroll_root1.id, grand_child12->scroll_tree_index()); | 10097 EXPECT_EQ(scroll_root1.id, grand_child12->scroll_tree_index()); |
10098 } | 10098 } |
10099 | 10099 |
10100 } // namespace | 10100 } // namespace |
10101 } // namespace cc | 10101 } // namespace cc |
OLD | NEW |