Chromium Code Reviews| 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 <algorithm> | 7 #include <algorithm> |
| 8 #include <set> | 8 #include <set> |
| 9 | 9 |
| 10 #include "cc/animation/layer_animation_controller.h" | 10 #include "cc/animation/layer_animation_controller.h" |
| (...skipping 1460 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1471 LayerTreeHostCommon::CalcDrawPropsMainInputsForTesting inputs( | 1471 LayerTreeHostCommon::CalcDrawPropsMainInputsForTesting inputs( |
| 1472 parent.get(), parent->bounds(), &render_surface_layer_list); | 1472 parent.get(), parent->bounds(), &render_surface_layer_list); |
| 1473 inputs.can_adjust_raster_scales = true; | 1473 inputs.can_adjust_raster_scales = true; |
| 1474 LayerTreeHostCommon::CalculateDrawProperties(&inputs); | 1474 LayerTreeHostCommon::CalculateDrawProperties(&inputs); |
| 1475 EXPECT_TRUE(parent->render_surface()); | 1475 EXPECT_TRUE(parent->render_surface()); |
| 1476 EXPECT_FALSE(render_surface1->render_surface()); | 1476 EXPECT_FALSE(render_surface1->render_surface()); |
| 1477 EXPECT_EQ(1U, render_surface_layer_list.size()); | 1477 EXPECT_EQ(1U, render_surface_layer_list.size()); |
| 1478 } | 1478 } |
| 1479 } | 1479 } |
| 1480 | 1480 |
| 1481 TEST_F(LayerTreeHostCommonTest, RenderSurfacesFlattenScreenSpaceTransform) { | |
| 1482 // Render surfaces act as a flattening point for their subtree, so should | |
| 1483 // always flatten the target-to-screen space transform seen by descendants. | |
| 1484 | |
| 1485 scoped_refptr<Layer> root = Layer::Create(); | |
| 1486 scoped_refptr<Layer> parent = Layer::Create(); | |
| 1487 scoped_refptr<LayerWithForcedDrawsContent> child = | |
| 1488 make_scoped_refptr(new LayerWithForcedDrawsContent()); | |
| 1489 scoped_refptr<LayerWithForcedDrawsContent> grand_child = | |
| 1490 make_scoped_refptr(new LayerWithForcedDrawsContent()); | |
| 1491 | |
| 1492 gfx::Transform rotation_about_y_axis; | |
| 1493 rotation_about_y_axis.RotateAboutYAxis(30.0); | |
| 1494 // Make |parent| have a render surface. | |
| 1495 parent->SetOpacity(0.9); | |
| 1496 | |
| 1497 const gfx::Transform identity_matrix; | |
| 1498 SetLayerPropertiesForTesting(root.get(), identity_matrix, gfx::Point3F(), | |
| 1499 gfx::PointF(), gfx::Size(100, 100), true, false); | |
| 1500 SetLayerPropertiesForTesting(parent.get(), rotation_about_y_axis, | |
| 1501 gfx::Point3F(), gfx::PointF(), gfx::Size(10, 10), | |
| 1502 true, false); | |
| 1503 SetLayerPropertiesForTesting(child.get(), identity_matrix, gfx::Point3F(), | |
| 1504 gfx::PointF(), gfx::Size(10, 10), true, false); | |
| 1505 SetLayerPropertiesForTesting(grand_child.get(), identity_matrix, | |
| 1506 gfx::Point3F(), gfx::PointF(), gfx::Size(10, 10), | |
| 1507 true, false); | |
| 1508 | |
| 1509 root->AddChild(parent); | |
| 1510 parent->AddChild(child); | |
| 1511 child->AddChild(grand_child); | |
| 1512 | |
| 1513 grand_child->SetShouldFlattenTransform(false); | |
| 1514 | |
| 1515 scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost()); | |
| 1516 host->SetRootLayer(root); | |
| 1517 | |
| 1518 // Only grand_child should preserve 3d. | |
| 1519 EXPECT_TRUE(root->should_flatten_transform()); | |
| 1520 EXPECT_TRUE(parent->should_flatten_transform()); | |
| 1521 EXPECT_TRUE(child->should_flatten_transform()); | |
| 1522 EXPECT_FALSE(grand_child->should_flatten_transform()); | |
| 1523 | |
| 1524 gfx::Transform expected_child_draw_transform = identity_matrix; | |
| 1525 gfx::Transform expected_grand_child_draw_transform = identity_matrix; | |
| 1526 | |
| 1527 gfx::Transform flattened_rotation_about_y = rotation_about_y_axis; | |
| 1528 flattened_rotation_about_y.FlattenTo2d(); | |
| 1529 | |
| 1530 ExecuteCalculateDrawProperties(root.get()); | |
| 1531 | |
| 1532 EXPECT_TRUE(parent->render_surface()); | |
| 1533 EXPECT_FALSE(child->render_surface()); | |
| 1534 EXPECT_FALSE(grand_child->render_surface()); | |
| 1535 | |
| 1536 EXPECT_TRANSFORMATION_MATRIX_EQ(identity_matrix, child->draw_transform()); | |
| 1537 EXPECT_TRANSFORMATION_MATRIX_EQ(identity_matrix, | |
| 1538 grand_child->draw_transform()); | |
| 1539 | |
| 1540 // The screen-space transform inherited by |child| and |grand_child| should | |
| 1541 // have been flattened at their render target. In particular, the fact that | |
| 1542 // |grand_child| happens to preserve 3d shouldn't affect this flattening. | |
| 1543 EXPECT_TRANSFORMATION_MATRIX_EQ(flattened_rotation_about_y, | |
| 1544 child->screen_space_transform()); | |
| 1545 EXPECT_TRANSFORMATION_MATRIX_EQ(flattened_rotation_about_y, | |
| 1546 grand_child->screen_space_transform()); | |
|
ajuma
2015/03/10 20:29:30
Without the change made in this CL, |grand_child|'
| |
| 1547 } | |
| 1548 | |
| 1481 TEST_F(LayerTreeHostCommonTest, ClipRectCullsRenderSurfaces) { | 1549 TEST_F(LayerTreeHostCommonTest, ClipRectCullsRenderSurfaces) { |
| 1482 // The entire subtree of layers that are outside the clip rect should be | 1550 // The entire subtree of layers that are outside the clip rect should be |
| 1483 // culled away, and should not affect the render_surface_layer_list. | 1551 // culled away, and should not affect the render_surface_layer_list. |
| 1484 // | 1552 // |
| 1485 // The test tree is set up as follows: | 1553 // The test tree is set up as follows: |
| 1486 // - all layers except the leaf_nodes are forced to be a new render surface | 1554 // - all layers except the leaf_nodes are forced to be a new render surface |
| 1487 // that have something to draw. | 1555 // that have something to draw. |
| 1488 // - parent is a large container layer. | 1556 // - parent is a large container layer. |
| 1489 // - child has masksToBounds=true to cause clipping. | 1557 // - child has masksToBounds=true to cause clipping. |
| 1490 // - grand_child is positioned outside of the child's bounds | 1558 // - grand_child is positioned outside of the child's bounds |
| (...skipping 7408 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 8899 surface->AddChild(box); | 8967 surface->AddChild(box); |
| 8900 | 8968 |
| 8901 scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost()); | 8969 scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost()); |
| 8902 host->SetRootLayer(root); | 8970 host->SetRootLayer(root); |
| 8903 | 8971 |
| 8904 ExecuteCalculateDrawProperties(root.get()); | 8972 ExecuteCalculateDrawProperties(root.get()); |
| 8905 } | 8973 } |
| 8906 | 8974 |
| 8907 } // namespace | 8975 } // namespace |
| 8908 } // namespace cc | 8976 } // namespace cc |
| OLD | NEW |