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/layer_tree_host_common.h" | 5 #include "cc/layer_tree_host_common.h" |
6 | 6 |
7 #include "cc/content_layer.h" | 7 #include "cc/content_layer.h" |
8 #include "cc/content_layer_client.h" | 8 #include "cc/content_layer_client.h" |
9 #include "cc/layer.h" | 9 #include "cc/layer.h" |
10 #include "cc/layer_animation_controller.h" | 10 #include "cc/layer_animation_controller.h" |
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
320 root->addChild(parent); | 320 root->addChild(parent); |
321 parent->addChild(child); | 321 parent->addChild(child); |
322 child->addChild(grandChild); | 322 child->addChild(grandChild); |
323 | 323 |
324 // One-time setup of root layer | 324 // One-time setup of root layer |
325 gfx::Transform identityMatrix; | 325 gfx::Transform identityMatrix; |
326 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, gfx
::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(1, 2), false); | 326 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, gfx
::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(1, 2), false); |
327 | 327 |
328 // Child is set up so that a new render surface should be created. | 328 // Child is set up so that a new render surface should be created. |
329 child->setOpacity(0.5); | 329 child->setOpacity(0.5); |
| 330 child->setForceRenderSurface(true); |
330 | 331 |
331 gfx::Transform parentLayerTransform; | 332 gfx::Transform parentLayerTransform; |
332 parentLayerTransform.Scale3d(1, 0.9, 1); | 333 parentLayerTransform.Scale3d(1, 0.9, 1); |
333 gfx::Transform parentTranslationToAnchor; | 334 gfx::Transform parentTranslationToAnchor; |
334 parentTranslationToAnchor.Translate(25, 30); | 335 parentTranslationToAnchor.Translate(25, 30); |
335 gfx::Transform parentSublayerMatrix; | 336 gfx::Transform parentSublayerMatrix; |
336 parentSublayerMatrix.Scale3d(0.9, 1, 3.3); | 337 parentSublayerMatrix.Scale3d(0.9, 1, 3.3); |
337 gfx::Transform parentTranslationToCenter; | 338 gfx::Transform parentTranslationToCenter; |
338 parentTranslationToCenter.Translate(50, 60); | 339 parentTranslationToCenter.Translate(50, 60); |
339 gfx::Transform parentCompositeTransform = parentTranslationToAnchor * parent
LayerTransform * MathUtil::inverse(parentTranslationToAnchor) | 340 gfx::Transform parentCompositeTransform = parentTranslationToAnchor * parent
LayerTransform * MathUtil::inverse(parentTranslationToAnchor) |
(...skipping 1008 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1348 | 1349 |
1349 setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, g
fx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(500, 500), false); | 1350 setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, g
fx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(500, 500), false); |
1350 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, gf
x::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(20, 20), false); | 1351 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, gf
x::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(20, 20), false); |
1351 setLayerPropertiesForTesting(grandChild.get(), identityMatrix, identityMatri
x, gfx::PointF(0, 0), gfx::PointF(45, 45), gfx::Size(10, 10), false); | 1352 setLayerPropertiesForTesting(grandChild.get(), identityMatrix, identityMatri
x, gfx::PointF(0, 0), gfx::PointF(45, 45), gfx::Size(10, 10), false); |
1352 setLayerPropertiesForTesting(greatGrandChild.get(), identityMatrix, identity
Matrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(10, 10), false); | 1353 setLayerPropertiesForTesting(greatGrandChild.get(), identityMatrix, identity
Matrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(10, 10), false); |
1353 setLayerPropertiesForTesting(leafNode1.get(), identityMatrix, identityMatrix
, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(500, 500), false); | 1354 setLayerPropertiesForTesting(leafNode1.get(), identityMatrix, identityMatrix
, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(500, 500), false); |
1354 setLayerPropertiesForTesting(leafNode2.get(), identityMatrix, identityMatrix
, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(20, 20), false); | 1355 setLayerPropertiesForTesting(leafNode2.get(), identityMatrix, identityMatrix
, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(20, 20), false); |
1355 | 1356 |
1356 child->setMasksToBounds(true); | 1357 child->setMasksToBounds(true); |
1357 child->setOpacity(0.4f); | 1358 child->setOpacity(0.4f); |
| 1359 child->setForceRenderSurface(true); |
1358 grandChild->setOpacity(0.5); | 1360 grandChild->setOpacity(0.5); |
1359 greatGrandChild->setOpacity(0.4f); | 1361 greatGrandChild->setOpacity(0.4f); |
1360 | 1362 |
1361 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; | 1363 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; |
1362 int dummyMaxTextureSize = 512; | 1364 int dummyMaxTextureSize = 512; |
1363 LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(),
1, 1, dummyMaxTextureSize, renderSurfaceLayerList); | 1365 LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(),
1, 1, dummyMaxTextureSize, renderSurfaceLayerList); |
1364 | 1366 |
1365 ASSERT_EQ(2U, renderSurfaceLayerList.size()); | 1367 ASSERT_EQ(2U, renderSurfaceLayerList.size()); |
1366 EXPECT_EQ(parent->id(), renderSurfaceLayerList[0]->id()); | 1368 EXPECT_EQ(parent->id(), renderSurfaceLayerList[0]->id()); |
1367 EXPECT_EQ(child->id(), renderSurfaceLayerList[1]->id()); | 1369 EXPECT_EQ(child->id(), renderSurfaceLayerList[1]->id()); |
(...skipping 26 matching lines...) Expand all Loading... |
1394 child->addChild(grandChild); | 1396 child->addChild(grandChild); |
1395 grandChild->addChild(leafNode); | 1397 grandChild->addChild(leafNode); |
1396 | 1398 |
1397 setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, g
fx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); | 1399 setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, g
fx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); |
1398 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, gf
x::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(20, 20), false); | 1400 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, gf
x::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(20, 20), false); |
1399 setLayerPropertiesForTesting(grandChild.get(), identityMatrix, identityMatri
x, gfx::PointF(0, 0), gfx::PointF(200, 200), gfx::Size(10, 10), false); | 1401 setLayerPropertiesForTesting(grandChild.get(), identityMatrix, identityMatri
x, gfx::PointF(0, 0), gfx::PointF(200, 200), gfx::Size(10, 10), false); |
1400 setLayerPropertiesForTesting(leafNode.get(), identityMatrix, identityMatrix,
gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(10, 10), false); | 1402 setLayerPropertiesForTesting(leafNode.get(), identityMatrix, identityMatrix,
gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(10, 10), false); |
1401 | 1403 |
1402 parent->setMasksToBounds(true); | 1404 parent->setMasksToBounds(true); |
1403 child->setOpacity(0.4f); | 1405 child->setOpacity(0.4f); |
| 1406 child->setForceRenderSurface(true); |
1404 grandChild->setOpacity(0.4f); | 1407 grandChild->setOpacity(0.4f); |
| 1408 grandChild->setForceRenderSurface(true); |
1405 | 1409 |
1406 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; | 1410 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; |
1407 int dummyMaxTextureSize = 512; | 1411 int dummyMaxTextureSize = 512; |
1408 LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(),
1, 1, dummyMaxTextureSize, renderSurfaceLayerList); | 1412 LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(),
1, 1, dummyMaxTextureSize, renderSurfaceLayerList); |
1409 | 1413 |
1410 // Without an animation, we should cull child and grandChild from the render
SurfaceLayerList. | 1414 // Without an animation, we should cull child and grandChild from the render
SurfaceLayerList. |
1411 ASSERT_EQ(1U, renderSurfaceLayerList.size()); | 1415 ASSERT_EQ(1U, renderSurfaceLayerList.size()); |
1412 EXPECT_EQ(parent->id(), renderSurfaceLayerList[0]->id()); | 1416 EXPECT_EQ(parent->id(), renderSurfaceLayerList[0]->id()); |
1413 | 1417 |
1414 // Now put an animating transform on child. | 1418 // Now put an animating transform on child. |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1622 setLayerPropertiesForTesting(leafNode2.get(), identityMatrix, identityMatrix
, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(10, 10), false); | 1626 setLayerPropertiesForTesting(leafNode2.get(), identityMatrix, identityMatrix
, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(10, 10), false); |
1623 setLayerPropertiesForTesting(leafNode3.get(), identityMatrix, identityMatrix
, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(10, 10), false); | 1627 setLayerPropertiesForTesting(leafNode3.get(), identityMatrix, identityMatrix
, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(10, 10), false); |
1624 setLayerPropertiesForTesting(leafNode4.get(), identityMatrix, identityMatrix
, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(10, 10), false); | 1628 setLayerPropertiesForTesting(leafNode4.get(), identityMatrix, identityMatrix
, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(10, 10), false); |
1625 | 1629 |
1626 child->setMasksToBounds(true); | 1630 child->setMasksToBounds(true); |
1627 grandChild3->setMasksToBounds(true); | 1631 grandChild3->setMasksToBounds(true); |
1628 grandChild4->setMasksToBounds(true); | 1632 grandChild4->setMasksToBounds(true); |
1629 | 1633 |
1630 // Force everyone to be a render surface. | 1634 // Force everyone to be a render surface. |
1631 child->setOpacity(0.4f); | 1635 child->setOpacity(0.4f); |
| 1636 child->setForceRenderSurface(true); |
1632 grandChild1->setOpacity(0.5); | 1637 grandChild1->setOpacity(0.5); |
| 1638 grandChild1->setForceRenderSurface(true); |
1633 grandChild2->setOpacity(0.5); | 1639 grandChild2->setOpacity(0.5); |
| 1640 grandChild2->setForceRenderSurface(true); |
1634 grandChild3->setOpacity(0.5); | 1641 grandChild3->setOpacity(0.5); |
| 1642 grandChild3->setForceRenderSurface(true); |
1635 grandChild4->setOpacity(0.5); | 1643 grandChild4->setOpacity(0.5); |
| 1644 grandChild4->setForceRenderSurface(true); |
1636 | 1645 |
1637 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; | 1646 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; |
1638 int dummyMaxTextureSize = 512; | 1647 int dummyMaxTextureSize = 512; |
1639 LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(),
1, 1, dummyMaxTextureSize, renderSurfaceLayerList); | 1648 LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(),
1, 1, dummyMaxTextureSize, renderSurfaceLayerList); |
1640 | 1649 |
1641 ASSERT_TRUE(grandChild1->renderSurface()); | 1650 ASSERT_TRUE(grandChild1->renderSurface()); |
1642 ASSERT_TRUE(grandChild2->renderSurface()); | 1651 ASSERT_TRUE(grandChild2->renderSurface()); |
1643 ASSERT_TRUE(grandChild3->renderSurface()); | 1652 ASSERT_TRUE(grandChild3->renderSurface()); |
1644 EXPECT_FALSE(grandChild4->renderSurface()); // Because grandChild4 is entire
ly clipped, it is expected to not have a renderSurface. | 1653 EXPECT_FALSE(grandChild4->renderSurface()); // Because grandChild4 is entire
ly clipped, it is expected to not have a renderSurface. |
1645 | 1654 |
(...skipping 2958 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4604 | 4613 |
4605 int nonexistentId = -1; | 4614 int nonexistentId = -1; |
4606 EXPECT_EQ(root, LayerTreeHostCommon::findLayerInSubtree(root.get(), root->id
())); | 4615 EXPECT_EQ(root, LayerTreeHostCommon::findLayerInSubtree(root.get(), root->id
())); |
4607 EXPECT_EQ(child, LayerTreeHostCommon::findLayerInSubtree(root.get(), child->
id())); | 4616 EXPECT_EQ(child, LayerTreeHostCommon::findLayerInSubtree(root.get(), child->
id())); |
4608 EXPECT_EQ(grandChild, LayerTreeHostCommon::findLayerInSubtree(root.get(), gr
andChild->id())); | 4617 EXPECT_EQ(grandChild, LayerTreeHostCommon::findLayerInSubtree(root.get(), gr
andChild->id())); |
4609 EXPECT_EQ(maskLayer, LayerTreeHostCommon::findLayerInSubtree(root.get(), mas
kLayer->id())); | 4618 EXPECT_EQ(maskLayer, LayerTreeHostCommon::findLayerInSubtree(root.get(), mas
kLayer->id())); |
4610 EXPECT_EQ(replicaLayer, LayerTreeHostCommon::findLayerInSubtree(root.get(),
replicaLayer->id())); | 4619 EXPECT_EQ(replicaLayer, LayerTreeHostCommon::findLayerInSubtree(root.get(),
replicaLayer->id())); |
4611 EXPECT_EQ(0, LayerTreeHostCommon::findLayerInSubtree(root.get(), nonexistent
Id)); | 4620 EXPECT_EQ(0, LayerTreeHostCommon::findLayerInSubtree(root.get(), nonexistent
Id)); |
4612 } | 4621 } |
4613 | 4622 |
| 4623 TEST(LayerTreeHostCommonTest, verifyTransparentChildRenderSurfaceCreation) |
| 4624 { |
| 4625 scoped_refptr<Layer> root = Layer::create(); |
| 4626 scoped_refptr<Layer> child = Layer::create(); |
| 4627 scoped_refptr<LayerWithForcedDrawsContent> grandChild = make_scoped_refptr(n
ew LayerWithForcedDrawsContent()); |
| 4628 |
| 4629 const gfx::Transform identityMatrix; |
| 4630 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, gfx
::PointF(), gfx::PointF(), gfx::Size(100, 100), false); |
| 4631 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, gf
x::PointF(), gfx::PointF(), gfx::Size(10, 10), false); |
| 4632 setLayerPropertiesForTesting(grandChild.get(), identityMatrix, identityMatri
x, gfx::PointF(), gfx::PointF(), gfx::Size(10, 10), false); |
| 4633 |
| 4634 root->addChild(child); |
| 4635 child->addChild(grandChild); |
| 4636 child->setOpacity(0.5f); |
| 4637 |
| 4638 executeCalculateDrawTransformsAndVisibility(root.get()); |
| 4639 |
| 4640 EXPECT_FALSE(child->renderSurface()); |
| 4641 } |
| 4642 |
4614 } // namespace | 4643 } // namespace |
4615 } // namespace cc | 4644 } // namespace cc |
OLD | NEW |