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

Side by Side Diff: cc/layer_tree_host_common_unittest.cc

Issue 11316171: Don't create render passes for transparent images. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressing code review. Created 8 years 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 | Annotate | Revision Log
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/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 323 matching lines...) Expand 10 before | Expand all | Expand 10 after
334 root->addChild(parent); 334 root->addChild(parent);
335 parent->addChild(child); 335 parent->addChild(child);
336 child->addChild(grandChild); 336 child->addChild(grandChild);
337 337
338 // One-time setup of root layer 338 // One-time setup of root layer
339 WebTransformationMatrix identityMatrix; 339 WebTransformationMatrix identityMatrix;
340 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, gfx ::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(1, 2), false); 340 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, gfx ::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(1, 2), false);
341 341
342 // Child is set up so that a new render surface should be created. 342 // Child is set up so that a new render surface should be created.
343 child->setOpacity(0.5); 343 child->setOpacity(0.5);
344 child->setForceRenderSurface(true);
344 345
345 WebTransformationMatrix parentLayerTransform; 346 WebTransformationMatrix parentLayerTransform;
346 parentLayerTransform.scale3d(1, 0.9, 1); 347 parentLayerTransform.scale3d(1, 0.9, 1);
347 WebTransformationMatrix parentTranslationToAnchor; 348 WebTransformationMatrix parentTranslationToAnchor;
348 parentTranslationToAnchor.translate(25, 30); 349 parentTranslationToAnchor.translate(25, 30);
349 WebTransformationMatrix parentSublayerMatrix; 350 WebTransformationMatrix parentSublayerMatrix;
350 parentSublayerMatrix.scale3d(0.9, 1, 3.3); 351 parentSublayerMatrix.scale3d(0.9, 1, 3.3);
351 WebTransformationMatrix parentTranslationToCenter; 352 WebTransformationMatrix parentTranslationToCenter;
352 parentTranslationToCenter.translate(50, 60); 353 parentTranslationToCenter.translate(50, 60);
353 WebTransformationMatrix parentCompositeTransform = parentTranslationToAnchor * parentLayerTransform * parentTranslationToAnchor.inverse() 354 WebTransformationMatrix parentCompositeTransform = parentTranslationToAnchor * parentLayerTransform * parentTranslationToAnchor.inverse()
(...skipping 1008 matching lines...) Expand 10 before | Expand all | Expand 10 after
1362 1363
1363 setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, g fx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(500, 500), false); 1364 setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, g fx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(500, 500), false);
1364 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, gf x::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(20, 20), false); 1365 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, gf x::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(20, 20), false);
1365 setLayerPropertiesForTesting(grandChild.get(), identityMatrix, identityMatri x, gfx::PointF(0, 0), gfx::PointF(45, 45), gfx::Size(10, 10), false); 1366 setLayerPropertiesForTesting(grandChild.get(), identityMatrix, identityMatri x, gfx::PointF(0, 0), gfx::PointF(45, 45), gfx::Size(10, 10), false);
1366 setLayerPropertiesForTesting(greatGrandChild.get(), identityMatrix, identity Matrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(10, 10), false); 1367 setLayerPropertiesForTesting(greatGrandChild.get(), identityMatrix, identity Matrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(10, 10), false);
1367 setLayerPropertiesForTesting(leafNode1.get(), identityMatrix, identityMatrix , gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(500, 500), false); 1368 setLayerPropertiesForTesting(leafNode1.get(), identityMatrix, identityMatrix , gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(500, 500), false);
1368 setLayerPropertiesForTesting(leafNode2.get(), identityMatrix, identityMatrix , gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(20, 20), false); 1369 setLayerPropertiesForTesting(leafNode2.get(), identityMatrix, identityMatrix , gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(20, 20), false);
1369 1370
1370 child->setMasksToBounds(true); 1371 child->setMasksToBounds(true);
1371 child->setOpacity(0.4f); 1372 child->setOpacity(0.4f);
1373 child->setForceRenderSurface(true);
1372 grandChild->setOpacity(0.5); 1374 grandChild->setOpacity(0.5);
1373 greatGrandChild->setOpacity(0.4f); 1375 greatGrandChild->setOpacity(0.4f);
1374 1376
1375 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; 1377 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList;
1376 int dummyMaxTextureSize = 512; 1378 int dummyMaxTextureSize = 512;
1377 LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(), 1, 1, dummyMaxTextureSize, renderSurfaceLayerList); 1379 LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(), 1, 1, dummyMaxTextureSize, renderSurfaceLayerList);
1378 1380
1379 ASSERT_EQ(2U, renderSurfaceLayerList.size()); 1381 ASSERT_EQ(2U, renderSurfaceLayerList.size());
1380 EXPECT_EQ(parent->id(), renderSurfaceLayerList[0]->id()); 1382 EXPECT_EQ(parent->id(), renderSurfaceLayerList[0]->id());
1381 EXPECT_EQ(child->id(), renderSurfaceLayerList[1]->id()); 1383 EXPECT_EQ(child->id(), renderSurfaceLayerList[1]->id());
(...skipping 26 matching lines...) Expand all
1408 child->addChild(grandChild); 1410 child->addChild(grandChild);
1409 grandChild->addChild(leafNode); 1411 grandChild->addChild(leafNode);
1410 1412
1411 setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, g fx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); 1413 setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, g fx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false);
1412 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, gf x::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(20, 20), false); 1414 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, gf x::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(20, 20), false);
1413 setLayerPropertiesForTesting(grandChild.get(), identityMatrix, identityMatri x, gfx::PointF(0, 0), gfx::PointF(200, 200), gfx::Size(10, 10), false); 1415 setLayerPropertiesForTesting(grandChild.get(), identityMatrix, identityMatri x, gfx::PointF(0, 0), gfx::PointF(200, 200), gfx::Size(10, 10), false);
1414 setLayerPropertiesForTesting(leafNode.get(), identityMatrix, identityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(10, 10), false); 1416 setLayerPropertiesForTesting(leafNode.get(), identityMatrix, identityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(10, 10), false);
1415 1417
1416 parent->setMasksToBounds(true); 1418 parent->setMasksToBounds(true);
1417 child->setOpacity(0.4f); 1419 child->setOpacity(0.4f);
1420 child->setForceRenderSurface(true);
1418 grandChild->setOpacity(0.4f); 1421 grandChild->setOpacity(0.4f);
1422 grandChild->setForceRenderSurface(true);
1419 1423
1420 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; 1424 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList;
1421 int dummyMaxTextureSize = 512; 1425 int dummyMaxTextureSize = 512;
1422 LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(), 1, 1, dummyMaxTextureSize, renderSurfaceLayerList); 1426 LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(), 1, 1, dummyMaxTextureSize, renderSurfaceLayerList);
1423 1427
1424 // Without an animation, we should cull child and grandChild from the render SurfaceLayerList. 1428 // Without an animation, we should cull child and grandChild from the render SurfaceLayerList.
1425 ASSERT_EQ(1U, renderSurfaceLayerList.size()); 1429 ASSERT_EQ(1U, renderSurfaceLayerList.size());
1426 EXPECT_EQ(parent->id(), renderSurfaceLayerList[0]->id()); 1430 EXPECT_EQ(parent->id(), renderSurfaceLayerList[0]->id());
1427 1431
1428 // Now put an animating transform on child. 1432 // Now put an animating transform on child.
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
1636 setLayerPropertiesForTesting(leafNode2.get(), identityMatrix, identityMatrix , gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(10, 10), false); 1640 setLayerPropertiesForTesting(leafNode2.get(), identityMatrix, identityMatrix , gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(10, 10), false);
1637 setLayerPropertiesForTesting(leafNode3.get(), identityMatrix, identityMatrix , gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(10, 10), false); 1641 setLayerPropertiesForTesting(leafNode3.get(), identityMatrix, identityMatrix , gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(10, 10), false);
1638 setLayerPropertiesForTesting(leafNode4.get(), identityMatrix, identityMatrix , gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(10, 10), false); 1642 setLayerPropertiesForTesting(leafNode4.get(), identityMatrix, identityMatrix , gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(10, 10), false);
1639 1643
1640 child->setMasksToBounds(true); 1644 child->setMasksToBounds(true);
1641 grandChild3->setMasksToBounds(true); 1645 grandChild3->setMasksToBounds(true);
1642 grandChild4->setMasksToBounds(true); 1646 grandChild4->setMasksToBounds(true);
1643 1647
1644 // Force everyone to be a render surface. 1648 // Force everyone to be a render surface.
1645 child->setOpacity(0.4f); 1649 child->setOpacity(0.4f);
1650 child->setForceRenderSurface(true);
1646 grandChild1->setOpacity(0.5); 1651 grandChild1->setOpacity(0.5);
1652 grandChild1->setForceRenderSurface(true);
1647 grandChild2->setOpacity(0.5); 1653 grandChild2->setOpacity(0.5);
1654 grandChild2->setForceRenderSurface(true);
1648 grandChild3->setOpacity(0.5); 1655 grandChild3->setOpacity(0.5);
1656 grandChild3->setForceRenderSurface(true);
1649 grandChild4->setOpacity(0.5); 1657 grandChild4->setOpacity(0.5);
1658 grandChild4->setForceRenderSurface(true);
1650 1659
1651 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; 1660 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList;
1652 int dummyMaxTextureSize = 512; 1661 int dummyMaxTextureSize = 512;
1653 LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(), 1, 1, dummyMaxTextureSize, renderSurfaceLayerList); 1662 LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(), 1, 1, dummyMaxTextureSize, renderSurfaceLayerList);
1654 1663
1655 ASSERT_TRUE(grandChild1->renderSurface()); 1664 ASSERT_TRUE(grandChild1->renderSurface());
1656 ASSERT_TRUE(grandChild2->renderSurface()); 1665 ASSERT_TRUE(grandChild2->renderSurface());
1657 ASSERT_TRUE(grandChild3->renderSurface()); 1666 ASSERT_TRUE(grandChild3->renderSurface());
1658 EXPECT_FALSE(grandChild4->renderSurface()); // Because grandChild4 is entire ly clipped, it is expected to not have a renderSurface. 1667 EXPECT_FALSE(grandChild4->renderSurface()); // Because grandChild4 is entire ly clipped, it is expected to not have a renderSurface.
1659 1668
(...skipping 2958 matching lines...) Expand 10 before | Expand all | Expand 10 after
4618 4627
4619 int nonexistentId = -1; 4628 int nonexistentId = -1;
4620 EXPECT_EQ(root, LayerTreeHostCommon::findLayerInSubtree(root.get(), root->id ())); 4629 EXPECT_EQ(root, LayerTreeHostCommon::findLayerInSubtree(root.get(), root->id ()));
4621 EXPECT_EQ(child, LayerTreeHostCommon::findLayerInSubtree(root.get(), child-> id())); 4630 EXPECT_EQ(child, LayerTreeHostCommon::findLayerInSubtree(root.get(), child-> id()));
4622 EXPECT_EQ(grandChild, LayerTreeHostCommon::findLayerInSubtree(root.get(), gr andChild->id())); 4631 EXPECT_EQ(grandChild, LayerTreeHostCommon::findLayerInSubtree(root.get(), gr andChild->id()));
4623 EXPECT_EQ(maskLayer, LayerTreeHostCommon::findLayerInSubtree(root.get(), mas kLayer->id())); 4632 EXPECT_EQ(maskLayer, LayerTreeHostCommon::findLayerInSubtree(root.get(), mas kLayer->id()));
4624 EXPECT_EQ(replicaLayer, LayerTreeHostCommon::findLayerInSubtree(root.get(), replicaLayer->id())); 4633 EXPECT_EQ(replicaLayer, LayerTreeHostCommon::findLayerInSubtree(root.get(), replicaLayer->id()));
4625 EXPECT_EQ(0, LayerTreeHostCommon::findLayerInSubtree(root.get(), nonexistent Id)); 4634 EXPECT_EQ(0, LayerTreeHostCommon::findLayerInSubtree(root.get(), nonexistent Id));
4626 } 4635 }
4627 4636
4637 TEST(LayerTreeHostCommonTest, verifyTransparentChildRenderSurfaceCreation)
4638 {
4639 scoped_refptr<Layer> root = Layer::create();
4640 scoped_refptr<Layer> child = Layer::create();
4641 scoped_refptr<LayerWithForcedDrawsContent> grandChild = make_scoped_refptr(n ew LayerWithForcedDrawsContent());
4642
4643 const WebTransformationMatrix identityMatrix;
4644 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, gfx ::PointF(), gfx::PointF(), gfx::Size(100, 100), false);
4645 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, gf x::PointF(), gfx::PointF(), gfx::Size(10, 10), false);
4646 setLayerPropertiesForTesting(grandChild.get(), identityMatrix, identityMatri x, gfx::PointF(), gfx::PointF(), gfx::Size(10, 10), false);
4647
4648 root->addChild(child);
4649 child->addChild(grandChild);
4650 child->setOpacity(0.5f);
4651
4652 executeCalculateDrawTransformsAndVisibility(root.get());
4653
4654 EXPECT_FALSE(child->renderSurface());
4655 }
4656
4628 } // namespace 4657 } // namespace
4629 } // namespace cc 4658 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698