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

Side by Side Diff: cc/layer_tree_host_common_unittest.cc

Issue 11360093: Mark layers that can use LCD text based on layer transform and opacity. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase with TOT, addressed comments Created 8 years, 1 month 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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 setLayerPropertiesForTestingInternal<Layer>(layer, transform, sublayerTransf orm, anchor, position, bounds, preserves3D); 42 setLayerPropertiesForTestingInternal<Layer>(layer, transform, sublayerTransf orm, anchor, position, bounds, preserves3D);
43 layer->setAutomaticallyComputeRasterScale(true); 43 layer->setAutomaticallyComputeRasterScale(true);
44 } 44 }
45 45
46 void setLayerPropertiesForTesting(LayerImpl* layer, const WebTransformationMatri x& transform, const WebTransformationMatrix& sublayerTransform, const gfx::Point F& anchor, const gfx::PointF& position, const gfx::Size& bounds, bool preserves3 D) 46 void setLayerPropertiesForTesting(LayerImpl* layer, const WebTransformationMatri x& transform, const WebTransformationMatrix& sublayerTransform, const gfx::Point F& anchor, const gfx::PointF& position, const gfx::Size& bounds, bool preserves3 D)
47 { 47 {
48 setLayerPropertiesForTestingInternal<LayerImpl>(layer, transform, sublayerTr ansform, anchor, position, bounds, preserves3D); 48 setLayerPropertiesForTestingInternal<LayerImpl>(layer, transform, sublayerTr ansform, anchor, position, bounds, preserves3D);
49 layer->setContentBounds(bounds); 49 layer->setContentBounds(bounds);
50 } 50 }
51 51
52 void executeCalculateDrawTransformsAndVisibility(Layer* rootLayer, float deviceS caleFactor = 1, float pageScaleFactor = 1) 52 void executeCalculateDrawTransformsAndVisibility(Layer* rootLayer, float deviceS caleFactor = 1, float pageScaleFactor = 1, bool canUseLCDText = false)
53 { 53 {
54 WebTransformationMatrix identityMatrix; 54 WebTransformationMatrix identityMatrix;
55 std::vector<scoped_refptr<Layer> > dummyRenderSurfaceLayerList; 55 std::vector<scoped_refptr<Layer> > dummyRenderSurfaceLayerList;
56 int dummyMaxTextureSize = 512; 56 int dummyMaxTextureSize = 512;
57 gfx::Size deviceViewportSize = gfx::Size(rootLayer->bounds().width() * devic eScaleFactor, rootLayer->bounds().height() * deviceScaleFactor); 57 gfx::Size deviceViewportSize = gfx::Size(rootLayer->bounds().width() * devic eScaleFactor, rootLayer->bounds().height() * deviceScaleFactor);
58 58
59 // We are probably not testing what is intended if the rootLayer bounds are empty. 59 // We are probably not testing what is intended if the rootLayer bounds are empty.
60 DCHECK(!rootLayer->bounds().IsEmpty()); 60 DCHECK(!rootLayer->bounds().IsEmpty());
61 LayerTreeHostCommon::calculateDrawTransforms(rootLayer, deviceViewportSize, deviceScaleFactor, pageScaleFactor, dummyMaxTextureSize, dummyRenderSurfaceLayer List); 61 LayerTreeHostCommon::calculateDrawTransforms(rootLayer, deviceViewportSize, deviceScaleFactor, pageScaleFactor, dummyMaxTextureSize, canUseLCDText, dummyRen derSurfaceLayerList);
62 } 62 }
63 63
64 void executeCalculateDrawTransformsAndVisibility(LayerImpl* rootLayer, float dev iceScaleFactor = 1, float pageScaleFactor = 1) 64 void executeCalculateDrawTransformsAndVisibility(LayerImpl* rootLayer, float dev iceScaleFactor = 1, float pageScaleFactor = 1, bool canUseLCDText = false)
65 { 65 {
66 // Note: this version skips layer sorting. 66 // Note: this version skips layer sorting.
67 67
68 WebTransformationMatrix identityMatrix; 68 WebTransformationMatrix identityMatrix;
69 std::vector<LayerImpl*> dummyRenderSurfaceLayerList; 69 std::vector<LayerImpl*> dummyRenderSurfaceLayerList;
70 int dummyMaxTextureSize = 512; 70 int dummyMaxTextureSize = 512;
71 gfx::Size deviceViewportSize = gfx::Size(rootLayer->bounds().width() * devic eScaleFactor, rootLayer->bounds().height() * deviceScaleFactor); 71 gfx::Size deviceViewportSize = gfx::Size(rootLayer->bounds().width() * devic eScaleFactor, rootLayer->bounds().height() * deviceScaleFactor);
72 72
73 // We are probably not testing what is intended if the rootLayer bounds are empty. 73 // We are probably not testing what is intended if the rootLayer bounds are empty.
74 DCHECK(!rootLayer->bounds().IsEmpty()); 74 DCHECK(!rootLayer->bounds().IsEmpty());
75 LayerTreeHostCommon::calculateDrawTransforms(rootLayer, deviceViewportSize, deviceScaleFactor, pageScaleFactor, 0, dummyMaxTextureSize, dummyRenderSurfaceLa yerList); 75 LayerTreeHostCommon::calculateDrawTransforms(rootLayer, deviceViewportSize, deviceScaleFactor, pageScaleFactor, 0, dummyMaxTextureSize, canUseLCDText, dummy RenderSurfaceLayerList);
76 } 76 }
77 77
78 WebTransformationMatrix remove3DComponentOfMatrix(const WebTransformationMatrix& mat) 78 WebTransformationMatrix remove3DComponentOfMatrix(const WebTransformationMatrix& mat)
79 { 79 {
80 WebTransformationMatrix ret = mat; 80 WebTransformationMatrix ret = mat;
81 ret.setM13(0); 81 ret.setM13(0);
82 ret.setM23(0); 82 ret.setM23(0);
83 ret.setM31(0); 83 ret.setM31(0);
84 ret.setM32(0); 84 ret.setM32(0);
85 ret.setM33(1); 85 ret.setM33(1);
(...skipping 618 matching lines...) Expand 10 before | Expand all | Expand 10 after
704 setLayerPropertiesForTesting(renderSurface1.get(), identityMatrix, identityM atrix, gfx::PointF(), gfx::PointF(), gfx::Size(10, 10), false); 704 setLayerPropertiesForTesting(renderSurface1.get(), identityMatrix, identityM atrix, gfx::PointF(), gfx::PointF(), gfx::Size(10, 10), false);
705 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, gf x::PointF(), gfx::PointF(30, 30), gfx::Size(10, 10), false); 705 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, gf x::PointF(), gfx::PointF(30, 30), gfx::Size(10, 10), false);
706 706
707 parent->addChild(renderSurface1); 707 parent->addChild(renderSurface1);
708 parent->setMasksToBounds(true); 708 parent->setMasksToBounds(true);
709 renderSurface1->addChild(child); 709 renderSurface1->addChild(child);
710 renderSurface1->setForceRenderSurface(true); 710 renderSurface1->setForceRenderSurface(true);
711 711
712 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; 712 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList;
713 int dummyMaxTextureSize = 512; 713 int dummyMaxTextureSize = 512;
714 LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(), 1, 1, dummyMaxTextureSize, renderSurfaceLayerList); 714 LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(), 1, 1, dummyMaxTextureSize, false, renderSurfaceLayerList);
715 715
716 // The child layer's content is entirely outside the parent's clip rect, so the intermediate 716 // The child layer's content is entirely outside the parent's clip rect, so the intermediate
717 // render surface should not be listed here, even if it was forced to be cre ated. Render surfaces without children or visible 717 // render surface should not be listed here, even if it was forced to be cre ated. Render surfaces without children or visible
718 // content are unexpected at draw time (e.g. we might try to create a conten t texture of size 0). 718 // content are unexpected at draw time (e.g. we might try to create a conten t texture of size 0).
719 ASSERT_TRUE(parent->renderSurface()); 719 ASSERT_TRUE(parent->renderSurface());
720 ASSERT_FALSE(renderSurface1->renderSurface()); 720 ASSERT_FALSE(renderSurface1->renderSurface());
721 EXPECT_EQ(1U, renderSurfaceLayerList.size()); 721 EXPECT_EQ(1U, renderSurfaceLayerList.size());
722 } 722 }
723 723
724 TEST(LayerTreeHostCommonTest, verifyRenderSurfaceListForTransparentChild) 724 TEST(LayerTreeHostCommonTest, verifyRenderSurfaceListForTransparentChild)
725 { 725 {
726 scoped_refptr<Layer> parent = Layer::create(); 726 scoped_refptr<Layer> parent = Layer::create();
727 scoped_refptr<Layer> renderSurface1 = Layer::create(); 727 scoped_refptr<Layer> renderSurface1 = Layer::create();
728 scoped_refptr<LayerWithForcedDrawsContent> child = make_scoped_refptr(new La yerWithForcedDrawsContent()); 728 scoped_refptr<LayerWithForcedDrawsContent> child = make_scoped_refptr(new La yerWithForcedDrawsContent());
729 729
730 const WebTransformationMatrix identityMatrix; 730 const WebTransformationMatrix identityMatrix;
731 setLayerPropertiesForTesting(renderSurface1.get(), identityMatrix, identityM atrix, gfx::PointF(), gfx::PointF(), gfx::Size(10, 10), false); 731 setLayerPropertiesForTesting(renderSurface1.get(), identityMatrix, identityM atrix, gfx::PointF(), gfx::PointF(), gfx::Size(10, 10), false);
732 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, gf x::PointF(), gfx::PointF(), gfx::Size(10, 10), false); 732 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, gf x::PointF(), gfx::PointF(), gfx::Size(10, 10), false);
733 733
734 parent->addChild(renderSurface1); 734 parent->addChild(renderSurface1);
735 renderSurface1->addChild(child); 735 renderSurface1->addChild(child);
736 renderSurface1->setForceRenderSurface(true); 736 renderSurface1->setForceRenderSurface(true);
737 renderSurface1->setOpacity(0); 737 renderSurface1->setOpacity(0);
738 738
739 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; 739 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList;
740 int dummyMaxTextureSize = 512; 740 int dummyMaxTextureSize = 512;
741 LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(), 1, 1, dummyMaxTextureSize, renderSurfaceLayerList); 741 LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(), 1, 1, dummyMaxTextureSize, false, renderSurfaceLayerList);
742 742
743 // Since the layer is transparent, renderSurface1->renderSurface() should no t have gotten added anywhere. 743 // Since the layer is transparent, renderSurface1->renderSurface() should no t have gotten added anywhere.
744 // Also, the drawable content rect should not have been extended by the chil dren. 744 // Also, the drawable content rect should not have been extended by the chil dren.
745 ASSERT_TRUE(parent->renderSurface()); 745 ASSERT_TRUE(parent->renderSurface());
746 EXPECT_EQ(0U, parent->renderSurface()->layerList().size()); 746 EXPECT_EQ(0U, parent->renderSurface()->layerList().size());
747 EXPECT_EQ(1U, renderSurfaceLayerList.size()); 747 EXPECT_EQ(1U, renderSurfaceLayerList.size());
748 EXPECT_EQ(parent->id(), renderSurfaceLayerList[0]->id()); 748 EXPECT_EQ(parent->id(), renderSurfaceLayerList[0]->id());
749 EXPECT_EQ(gfx::Rect(), parent->drawableContentRect()); 749 EXPECT_EQ(gfx::Rect(), parent->drawableContentRect());
750 } 750 }
751 751
(...skipping 11 matching lines...) Expand all
763 763
764 parent->addChild(renderSurface1); 764 parent->addChild(renderSurface1);
765 renderSurface1->addChild(child); 765 renderSurface1->addChild(child);
766 766
767 // Sanity check before the actual test 767 // Sanity check before the actual test
768 EXPECT_FALSE(parent->renderSurface()); 768 EXPECT_FALSE(parent->renderSurface());
769 EXPECT_FALSE(renderSurface1->renderSurface()); 769 EXPECT_FALSE(renderSurface1->renderSurface());
770 770
771 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; 771 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList;
772 int dummyMaxTextureSize = 512; 772 int dummyMaxTextureSize = 512;
773 LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(), 1, 1, dummyMaxTextureSize, renderSurfaceLayerList); 773 LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(), 1, 1, dummyMaxTextureSize, false, renderSurfaceLayerList);
774 774
775 // The root layer always creates a renderSurface 775 // The root layer always creates a renderSurface
776 EXPECT_TRUE(parent->renderSurface()); 776 EXPECT_TRUE(parent->renderSurface());
777 EXPECT_TRUE(renderSurface1->renderSurface()); 777 EXPECT_TRUE(renderSurface1->renderSurface());
778 EXPECT_EQ(2U, renderSurfaceLayerList.size()); 778 EXPECT_EQ(2U, renderSurfaceLayerList.size());
779 779
780 renderSurfaceLayerList.clear(); 780 renderSurfaceLayerList.clear();
781 renderSurface1->setForceRenderSurface(false); 781 renderSurface1->setForceRenderSurface(false);
782 LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(), 1, 1, dummyMaxTextureSize, renderSurfaceLayerList); 782 LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(), 1, 1, dummyMaxTextureSize, false, renderSurfaceLayerList);
783 EXPECT_TRUE(parent->renderSurface()); 783 EXPECT_TRUE(parent->renderSurface());
784 EXPECT_FALSE(renderSurface1->renderSurface()); 784 EXPECT_FALSE(renderSurface1->renderSurface());
785 EXPECT_EQ(1U, renderSurfaceLayerList.size()); 785 EXPECT_EQ(1U, renderSurfaceLayerList.size());
786 } 786 }
787 787
788 TEST(LayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerWithD irectContainer) 788 TEST(LayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerWithD irectContainer)
789 { 789 {
790 // This test checks for correct scroll compensation when the fixed-position container 790 // This test checks for correct scroll compensation when the fixed-position container
791 // is the direct parent of the fixed-position layer. 791 // is the direct parent of the fixed-position layer.
792 scoped_ptr<LayerImpl> root = createTreeForFixedPositionTests(); 792 scoped_ptr<LayerImpl> root = createTreeForFixedPositionTests();
(...skipping 573 matching lines...) Expand 10 before | Expand all | Expand 10 after
1366 setLayerPropertiesForTesting(leafNode1.get(), identityMatrix, identityMatrix , gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(500, 500), false); 1366 setLayerPropertiesForTesting(leafNode1.get(), identityMatrix, identityMatrix , gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(500, 500), false);
1367 setLayerPropertiesForTesting(leafNode2.get(), identityMatrix, identityMatrix , gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(20, 20), false); 1367 setLayerPropertiesForTesting(leafNode2.get(), identityMatrix, identityMatrix , gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(20, 20), false);
1368 1368
1369 child->setMasksToBounds(true); 1369 child->setMasksToBounds(true);
1370 child->setOpacity(0.4f); 1370 child->setOpacity(0.4f);
1371 grandChild->setOpacity(0.5); 1371 grandChild->setOpacity(0.5);
1372 greatGrandChild->setOpacity(0.4f); 1372 greatGrandChild->setOpacity(0.4f);
1373 1373
1374 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; 1374 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList;
1375 int dummyMaxTextureSize = 512; 1375 int dummyMaxTextureSize = 512;
1376 LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(), 1, 1, dummyMaxTextureSize, renderSurfaceLayerList); 1376 LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(), 1, 1, dummyMaxTextureSize, false, renderSurfaceLayerList);
1377 1377
1378 ASSERT_EQ(2U, renderSurfaceLayerList.size()); 1378 ASSERT_EQ(2U, renderSurfaceLayerList.size());
1379 EXPECT_EQ(parent->id(), renderSurfaceLayerList[0]->id()); 1379 EXPECT_EQ(parent->id(), renderSurfaceLayerList[0]->id());
1380 EXPECT_EQ(child->id(), renderSurfaceLayerList[1]->id()); 1380 EXPECT_EQ(child->id(), renderSurfaceLayerList[1]->id());
1381 } 1381 }
1382 1382
1383 TEST(LayerTreeHostCommonTest, verifyClipRectCullsSurfaceWithoutVisibleContent) 1383 TEST(LayerTreeHostCommonTest, verifyClipRectCullsSurfaceWithoutVisibleContent)
1384 { 1384 {
1385 // When a renderSurface has a clipRect, it is used to clip the contentRect 1385 // When a renderSurface has a clipRect, it is used to clip the contentRect
1386 // of the surface. When the renderSurface is animating its transforms, then 1386 // of the surface. When the renderSurface is animating its transforms, then
(...skipping 24 matching lines...) Expand all
1411 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, gf x::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(20, 20), false); 1411 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, gf x::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(20, 20), false);
1412 setLayerPropertiesForTesting(grandChild.get(), identityMatrix, identityMatri x, gfx::PointF(0, 0), gfx::PointF(200, 200), gfx::Size(10, 10), false); 1412 setLayerPropertiesForTesting(grandChild.get(), identityMatrix, identityMatri x, gfx::PointF(0, 0), gfx::PointF(200, 200), gfx::Size(10, 10), false);
1413 setLayerPropertiesForTesting(leafNode.get(), identityMatrix, identityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(10, 10), false); 1413 setLayerPropertiesForTesting(leafNode.get(), identityMatrix, identityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(10, 10), false);
1414 1414
1415 parent->setMasksToBounds(true); 1415 parent->setMasksToBounds(true);
1416 child->setOpacity(0.4f); 1416 child->setOpacity(0.4f);
1417 grandChild->setOpacity(0.4f); 1417 grandChild->setOpacity(0.4f);
1418 1418
1419 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; 1419 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList;
1420 int dummyMaxTextureSize = 512; 1420 int dummyMaxTextureSize = 512;
1421 LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(), 1, 1, dummyMaxTextureSize, renderSurfaceLayerList); 1421 LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(), 1, 1, dummyMaxTextureSize, false, renderSurfaceLayerList);
1422 1422
1423 // Without an animation, we should cull child and grandChild from the render SurfaceLayerList. 1423 // Without an animation, we should cull child and grandChild from the render SurfaceLayerList.
1424 ASSERT_EQ(1U, renderSurfaceLayerList.size()); 1424 ASSERT_EQ(1U, renderSurfaceLayerList.size());
1425 EXPECT_EQ(parent->id(), renderSurfaceLayerList[0]->id()); 1425 EXPECT_EQ(parent->id(), renderSurfaceLayerList[0]->id());
1426 1426
1427 // Now put an animating transform on child. 1427 // Now put an animating transform on child.
1428 addAnimatedTransformToController(*child->layerAnimationController(), 10, 30, 0); 1428 addAnimatedTransformToController(*child->layerAnimationController(), 10, 30, 0);
1429 1429
1430 parent->clearRenderSurface(); 1430 parent->clearRenderSurface();
1431 child->clearRenderSurface(); 1431 child->clearRenderSurface();
1432 grandChild->clearRenderSurface(); 1432 grandChild->clearRenderSurface();
1433 renderSurfaceLayerList.clear(); 1433 renderSurfaceLayerList.clear();
1434 1434
1435 LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(), 1, 1, dummyMaxTextureSize, renderSurfaceLayerList); 1435 LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(), 1, 1, dummyMaxTextureSize, false, renderSurfaceLayerList);
1436 1436
1437 // With an animating transform, we should keep child and grandChild in the r enderSurfaceLayerList. 1437 // With an animating transform, we should keep child and grandChild in the r enderSurfaceLayerList.
1438 ASSERT_EQ(3U, renderSurfaceLayerList.size()); 1438 ASSERT_EQ(3U, renderSurfaceLayerList.size());
1439 EXPECT_EQ(parent->id(), renderSurfaceLayerList[0]->id()); 1439 EXPECT_EQ(parent->id(), renderSurfaceLayerList[0]->id());
1440 EXPECT_EQ(child->id(), renderSurfaceLayerList[1]->id()); 1440 EXPECT_EQ(child->id(), renderSurfaceLayerList[1]->id());
1441 EXPECT_EQ(grandChild->id(), renderSurfaceLayerList[2]->id()); 1441 EXPECT_EQ(grandChild->id(), renderSurfaceLayerList[2]->id());
1442 } 1442 }
1443 1443
1444 TEST(LayerTreeHostCommonTest, verifyDrawableContentRectForLayers) 1444 TEST(LayerTreeHostCommonTest, verifyDrawableContentRectForLayers)
1445 { 1445 {
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
1477 1477
1478 // Force everyone to be a render surface. 1478 // Force everyone to be a render surface.
1479 child->setOpacity(0.4f); 1479 child->setOpacity(0.4f);
1480 grandChild1->setOpacity(0.5); 1480 grandChild1->setOpacity(0.5);
1481 grandChild2->setOpacity(0.5); 1481 grandChild2->setOpacity(0.5);
1482 grandChild3->setOpacity(0.5); 1482 grandChild3->setOpacity(0.5);
1483 grandChild4->setOpacity(0.5); 1483 grandChild4->setOpacity(0.5);
1484 1484
1485 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; 1485 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList;
1486 int dummyMaxTextureSize = 512; 1486 int dummyMaxTextureSize = 512;
1487 LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(), 1, 1, dummyMaxTextureSize, renderSurfaceLayerList); 1487 LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(), 1, 1, dummyMaxTextureSize, false, renderSurfaceLayerList);
1488 1488
1489 EXPECT_RECT_EQ(gfx::Rect(gfx::Point(5, 5), gfx::Size(10, 10)), grandChild1-> drawableContentRect()); 1489 EXPECT_RECT_EQ(gfx::Rect(gfx::Point(5, 5), gfx::Size(10, 10)), grandChild1-> drawableContentRect());
1490 EXPECT_RECT_EQ(gfx::Rect(gfx::Point(15, 15), gfx::Size(5, 5)), grandChild3-> drawableContentRect()); 1490 EXPECT_RECT_EQ(gfx::Rect(gfx::Point(15, 15), gfx::Size(5, 5)), grandChild3-> drawableContentRect());
1491 EXPECT_RECT_EQ(gfx::Rect(gfx::Point(15, 15), gfx::Size(5, 5)), grandChild3-> drawableContentRect()); 1491 EXPECT_RECT_EQ(gfx::Rect(gfx::Point(15, 15), gfx::Size(5, 5)), grandChild3-> drawableContentRect());
1492 EXPECT_TRUE(grandChild4->drawableContentRect().IsEmpty()); 1492 EXPECT_TRUE(grandChild4->drawableContentRect().IsEmpty());
1493 } 1493 }
1494 1494
1495 TEST(LayerTreeHostCommonTest, verifyClipRectIsPropagatedCorrectlyToSurfaces) 1495 TEST(LayerTreeHostCommonTest, verifyClipRectIsPropagatedCorrectlyToSurfaces)
1496 { 1496 {
1497 // Verify that renderSurfaces (and their layers) get the appropriate clipRec ts when their parent masksToBounds is true. 1497 // Verify that renderSurfaces (and their layers) get the appropriate clipRec ts when their parent masksToBounds is true.
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
1542 1542
1543 // Force everyone to be a render surface. 1543 // Force everyone to be a render surface.
1544 child->setOpacity(0.4f); 1544 child->setOpacity(0.4f);
1545 grandChild1->setOpacity(0.5); 1545 grandChild1->setOpacity(0.5);
1546 grandChild2->setOpacity(0.5); 1546 grandChild2->setOpacity(0.5);
1547 grandChild3->setOpacity(0.5); 1547 grandChild3->setOpacity(0.5);
1548 grandChild4->setOpacity(0.5); 1548 grandChild4->setOpacity(0.5);
1549 1549
1550 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; 1550 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList;
1551 int dummyMaxTextureSize = 512; 1551 int dummyMaxTextureSize = 512;
1552 LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(), 1, 1, dummyMaxTextureSize, renderSurfaceLayerList); 1552 LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(), 1, 1, dummyMaxTextureSize, false, renderSurfaceLayerList);
1553 1553
1554 ASSERT_TRUE(grandChild1->renderSurface()); 1554 ASSERT_TRUE(grandChild1->renderSurface());
1555 ASSERT_TRUE(grandChild2->renderSurface()); 1555 ASSERT_TRUE(grandChild2->renderSurface());
1556 ASSERT_TRUE(grandChild3->renderSurface()); 1556 ASSERT_TRUE(grandChild3->renderSurface());
1557 EXPECT_FALSE(grandChild4->renderSurface()); // Because grandChild4 is entire ly clipped, it is expected to not have a renderSurface. 1557 EXPECT_FALSE(grandChild4->renderSurface()); // Because grandChild4 is entire ly clipped, it is expected to not have a renderSurface.
1558 1558
1559 // Surfaces are clipped by their parent, but un-affected by the owning layer 's masksToBounds. 1559 // Surfaces are clipped by their parent, but un-affected by the owning layer 's masksToBounds.
1560 EXPECT_RECT_EQ(gfx::Rect(gfx::Point(0, 0), gfx::Size(20, 20)), grandChild1-> renderSurface()->clipRect()); 1560 EXPECT_RECT_EQ(gfx::Rect(gfx::Point(0, 0), gfx::Size(20, 20)), grandChild1-> renderSurface()->clipRect());
1561 EXPECT_RECT_EQ(gfx::Rect(gfx::Point(0, 0), gfx::Size(20, 20)), grandChild2-> renderSurface()->clipRect()); 1561 EXPECT_RECT_EQ(gfx::Rect(gfx::Point(0, 0), gfx::Size(20, 20)), grandChild2-> renderSurface()->clipRect());
1562 EXPECT_RECT_EQ(gfx::Rect(gfx::Point(0, 0), gfx::Size(20, 20)), grandChild3-> renderSurface()->clipRect()); 1562 EXPECT_RECT_EQ(gfx::Rect(gfx::Point(0, 0), gfx::Size(20, 20)), grandChild3-> renderSurface()->clipRect());
(...skipping 821 matching lines...) Expand 10 before | Expand all | Expand 10 after
2384 setLayerPropertiesForTesting(backFacingChild.get(), backfaceMatrix, identity Matrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); 2384 setLayerPropertiesForTesting(backFacingChild.get(), backfaceMatrix, identity Matrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false);
2385 setLayerPropertiesForTesting(frontFacingSurface.get(), identityMatrix, ident ityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); 2385 setLayerPropertiesForTesting(frontFacingSurface.get(), identityMatrix, ident ityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false);
2386 setLayerPropertiesForTesting(backFacingSurface.get(), backfaceMatrix, identi tyMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); 2386 setLayerPropertiesForTesting(backFacingSurface.get(), backfaceMatrix, identi tyMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false);
2387 setLayerPropertiesForTesting(frontFacingChildOfFrontFacingSurface.get(), ide ntityMatrix, identityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100 , 100), false); 2387 setLayerPropertiesForTesting(frontFacingChildOfFrontFacingSurface.get(), ide ntityMatrix, identityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100 , 100), false);
2388 setLayerPropertiesForTesting(backFacingChildOfFrontFacingSurface.get(), back faceMatrix, identityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); 2388 setLayerPropertiesForTesting(backFacingChildOfFrontFacingSurface.get(), back faceMatrix, identityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false);
2389 setLayerPropertiesForTesting(frontFacingChildOfBackFacingSurface.get(), iden tityMatrix, identityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); 2389 setLayerPropertiesForTesting(frontFacingChildOfBackFacingSurface.get(), iden tityMatrix, identityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false);
2390 setLayerPropertiesForTesting(backFacingChildOfBackFacingSurface.get(), backf aceMatrix, identityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); 2390 setLayerPropertiesForTesting(backFacingChildOfBackFacingSurface.get(), backf aceMatrix, identityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false);
2391 2391
2392 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; 2392 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList;
2393 int dummyMaxTextureSize = 512; 2393 int dummyMaxTextureSize = 512;
2394 LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(), 1, 1, dummyMaxTextureSize, renderSurfaceLayerList); 2394 LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(), 1, 1, dummyMaxTextureSize, false, renderSurfaceLayerList);
2395 2395
2396 // Verify which renderSurfaces were created. 2396 // Verify which renderSurfaces were created.
2397 EXPECT_FALSE(frontFacingChild->renderSurface()); 2397 EXPECT_FALSE(frontFacingChild->renderSurface());
2398 EXPECT_FALSE(backFacingChild->renderSurface()); 2398 EXPECT_FALSE(backFacingChild->renderSurface());
2399 EXPECT_TRUE(frontFacingSurface->renderSurface()); 2399 EXPECT_TRUE(frontFacingSurface->renderSurface());
2400 EXPECT_TRUE(backFacingSurface->renderSurface()); 2400 EXPECT_TRUE(backFacingSurface->renderSurface());
2401 EXPECT_FALSE(frontFacingChildOfFrontFacingSurface->renderSurface()); 2401 EXPECT_FALSE(frontFacingChildOfFrontFacingSurface->renderSurface());
2402 EXPECT_FALSE(backFacingChildOfFrontFacingSurface->renderSurface()); 2402 EXPECT_FALSE(backFacingChildOfFrontFacingSurface->renderSurface());
2403 EXPECT_FALSE(frontFacingChildOfBackFacingSurface->renderSurface()); 2403 EXPECT_FALSE(frontFacingChildOfBackFacingSurface->renderSurface());
2404 EXPECT_FALSE(backFacingChildOfBackFacingSurface->renderSurface()); 2404 EXPECT_FALSE(backFacingChildOfBackFacingSurface->renderSurface());
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
2483 setLayerPropertiesForTesting(backFacingChild.get(), backfaceMatrix, identity Matrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); 2483 setLayerPropertiesForTesting(backFacingChild.get(), backfaceMatrix, identity Matrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false);
2484 setLayerPropertiesForTesting(frontFacingSurface.get(), identityMatrix, ident ityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), true); // surface transform style is preserve-3d. 2484 setLayerPropertiesForTesting(frontFacingSurface.get(), identityMatrix, ident ityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), true); // surface transform style is preserve-3d.
2485 setLayerPropertiesForTesting(backFacingSurface.get(), backfaceMatrix, identi tyMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), true); // s urface transform style is preserve-3d. 2485 setLayerPropertiesForTesting(backFacingSurface.get(), backfaceMatrix, identi tyMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), true); // s urface transform style is preserve-3d.
2486 setLayerPropertiesForTesting(frontFacingChildOfFrontFacingSurface.get(), ide ntityMatrix, identityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100 , 100), false); 2486 setLayerPropertiesForTesting(frontFacingChildOfFrontFacingSurface.get(), ide ntityMatrix, identityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100 , 100), false);
2487 setLayerPropertiesForTesting(backFacingChildOfFrontFacingSurface.get(), back faceMatrix, identityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); 2487 setLayerPropertiesForTesting(backFacingChildOfFrontFacingSurface.get(), back faceMatrix, identityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false);
2488 setLayerPropertiesForTesting(frontFacingChildOfBackFacingSurface.get(), iden tityMatrix, identityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); 2488 setLayerPropertiesForTesting(frontFacingChildOfBackFacingSurface.get(), iden tityMatrix, identityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false);
2489 setLayerPropertiesForTesting(backFacingChildOfBackFacingSurface.get(), backf aceMatrix, identityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); 2489 setLayerPropertiesForTesting(backFacingChildOfBackFacingSurface.get(), backf aceMatrix, identityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false);
2490 2490
2491 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; 2491 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList;
2492 int dummyMaxTextureSize = 512; 2492 int dummyMaxTextureSize = 512;
2493 LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(), 1, 1, dummyMaxTextureSize, renderSurfaceLayerList); 2493 LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(), 1, 1, dummyMaxTextureSize, false, renderSurfaceLayerList);
2494 2494
2495 // Verify which renderSurfaces were created. 2495 // Verify which renderSurfaces were created.
2496 EXPECT_FALSE(frontFacingChild->renderSurface()); 2496 EXPECT_FALSE(frontFacingChild->renderSurface());
2497 EXPECT_FALSE(backFacingChild->renderSurface()); 2497 EXPECT_FALSE(backFacingChild->renderSurface());
2498 EXPECT_TRUE(frontFacingSurface->renderSurface()); 2498 EXPECT_TRUE(frontFacingSurface->renderSurface());
2499 EXPECT_FALSE(backFacingSurface->renderSurface()); 2499 EXPECT_FALSE(backFacingSurface->renderSurface());
2500 EXPECT_FALSE(frontFacingChildOfFrontFacingSurface->renderSurface()); 2500 EXPECT_FALSE(frontFacingChildOfFrontFacingSurface->renderSurface());
2501 EXPECT_FALSE(backFacingChildOfFrontFacingSurface->renderSurface()); 2501 EXPECT_FALSE(backFacingChildOfFrontFacingSurface->renderSurface());
2502 EXPECT_FALSE(frontFacingChildOfBackFacingSurface->renderSurface()); 2502 EXPECT_FALSE(frontFacingChildOfBackFacingSurface->renderSurface());
2503 EXPECT_FALSE(backFacingChildOfBackFacingSurface->renderSurface()); 2503 EXPECT_FALSE(backFacingChildOfBackFacingSurface->renderSurface());
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
2563 2563
2564 setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, g fx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); 2564 setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, g fx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false);
2565 setLayerPropertiesForTesting(child.get(), backfaceMatrix, identityMatrix, gf x::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); 2565 setLayerPropertiesForTesting(child.get(), backfaceMatrix, identityMatrix, gf x::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false);
2566 setLayerPropertiesForTesting(animatingSurface.get(), backfaceMatrix, identit yMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); 2566 setLayerPropertiesForTesting(animatingSurface.get(), backfaceMatrix, identit yMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false);
2567 setLayerPropertiesForTesting(childOfAnimatingSurface.get(), backfaceMatrix, identityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false ); 2567 setLayerPropertiesForTesting(childOfAnimatingSurface.get(), backfaceMatrix, identityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false );
2568 setLayerPropertiesForTesting(animatingChild.get(), backfaceMatrix, identityM atrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); 2568 setLayerPropertiesForTesting(animatingChild.get(), backfaceMatrix, identityM atrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false);
2569 setLayerPropertiesForTesting(child2.get(), identityMatrix, identityMatrix, g fx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); 2569 setLayerPropertiesForTesting(child2.get(), identityMatrix, identityMatrix, g fx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false);
2570 2570
2571 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; 2571 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList;
2572 int dummyMaxTextureSize = 512; 2572 int dummyMaxTextureSize = 512;
2573 LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(), 1, 1, dummyMaxTextureSize, renderSurfaceLayerList); 2573 LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(), 1, 1, dummyMaxTextureSize, false, renderSurfaceLayerList);
2574 2574
2575 EXPECT_FALSE(child->renderSurface()); 2575 EXPECT_FALSE(child->renderSurface());
2576 EXPECT_TRUE(animatingSurface->renderSurface()); 2576 EXPECT_TRUE(animatingSurface->renderSurface());
2577 EXPECT_FALSE(childOfAnimatingSurface->renderSurface()); 2577 EXPECT_FALSE(childOfAnimatingSurface->renderSurface());
2578 EXPECT_FALSE(animatingChild->renderSurface()); 2578 EXPECT_FALSE(animatingChild->renderSurface());
2579 EXPECT_FALSE(child2->renderSurface()); 2579 EXPECT_FALSE(child2->renderSurface());
2580 2580
2581 // Verify that the animatingChild and childOfAnimatingSurface were not culle d, but that child was. 2581 // Verify that the animatingChild and childOfAnimatingSurface were not culle d, but that child was.
2582 ASSERT_EQ(2u, renderSurfaceLayerList.size()); 2582 ASSERT_EQ(2u, renderSurfaceLayerList.size());
2583 EXPECT_EQ(parent->id(), renderSurfaceLayerList[0]->id()); 2583 EXPECT_EQ(parent->id(), renderSurfaceLayerList[0]->id());
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
2629 backfaceMatrix.translate(-50, -50); 2629 backfaceMatrix.translate(-50, -50);
2630 2630
2631 setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, g fx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), true); // parent trans form style is preserve3d. 2631 setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, g fx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), true); // parent trans form style is preserve3d.
2632 setLayerPropertiesForTesting(frontFacingSurface.get(), identityMatrix, ident ityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); // surface transform style is flat. 2632 setLayerPropertiesForTesting(frontFacingSurface.get(), identityMatrix, ident ityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); // surface transform style is flat.
2633 setLayerPropertiesForTesting(backFacingSurface.get(), backfaceMatrix, ident ityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); // surface transform style is flat. 2633 setLayerPropertiesForTesting(backFacingSurface.get(), backfaceMatrix, ident ityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); // surface transform style is flat.
2634 setLayerPropertiesForTesting(child1.get(), identityMatrix, identityMatrix, g fx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); 2634 setLayerPropertiesForTesting(child1.get(), identityMatrix, identityMatrix, g fx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false);
2635 setLayerPropertiesForTesting(child2.get(), identityMatrix, identityMatrix, g fx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); 2635 setLayerPropertiesForTesting(child2.get(), identityMatrix, identityMatrix, g fx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false);
2636 2636
2637 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; 2637 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList;
2638 int dummyMaxTextureSize = 512; 2638 int dummyMaxTextureSize = 512;
2639 LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(), 1, 1, dummyMaxTextureSize, renderSurfaceLayerList); 2639 LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(), 1, 1, dummyMaxTextureSize, false, renderSurfaceLayerList);
2640 2640
2641 // Verify which renderSurfaces were created. 2641 // Verify which renderSurfaces were created.
2642 EXPECT_TRUE(frontFacingSurface->renderSurface()); 2642 EXPECT_TRUE(frontFacingSurface->renderSurface());
2643 EXPECT_FALSE(backFacingSurface->renderSurface()); // because it should be cu lled 2643 EXPECT_FALSE(backFacingSurface->renderSurface()); // because it should be cu lled
2644 EXPECT_FALSE(child1->renderSurface()); 2644 EXPECT_FALSE(child1->renderSurface());
2645 EXPECT_FALSE(child2->renderSurface()); 2645 EXPECT_FALSE(child2->renderSurface());
2646 2646
2647 // Verify the renderSurfaceLayerList. The back-facing surface should be cull ed. 2647 // Verify the renderSurfaceLayerList. The back-facing surface should be cull ed.
2648 ASSERT_EQ(2u, renderSurfaceLayerList.size()); 2648 ASSERT_EQ(2u, renderSurfaceLayerList.size());
2649 EXPECT_EQ(parent->id(), renderSurfaceLayerList[0]->id()); 2649 EXPECT_EQ(parent->id(), renderSurfaceLayerList[0]->id());
(...skipping 29 matching lines...) Expand all
2679 2679
2680 WebTransformationMatrix identityMatrix; 2680 WebTransformationMatrix identityMatrix;
2681 gfx::PointF anchor(0, 0); 2681 gfx::PointF anchor(0, 0);
2682 gfx::PointF position(0, 0); 2682 gfx::PointF position(0, 0);
2683 gfx::Size bounds(100, 100); 2683 gfx::Size bounds(100, 100);
2684 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc hor, position, bounds, false); 2684 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc hor, position, bounds, false);
2685 root->setDrawsContent(true); 2685 root->setDrawsContent(true);
2686 2686
2687 std::vector<LayerImpl*> renderSurfaceLayerList; 2687 std::vector<LayerImpl*> renderSurfaceLayerList;
2688 int dummyMaxTextureSize = 512; 2688 int dummyMaxTextureSize = 512;
2689 LayerTreeHostCommon::calculateDrawTransforms(root.get(), root->bounds(), 1, 1, 0, dummyMaxTextureSize, renderSurfaceLayerList); 2689 LayerTreeHostCommon::calculateDrawTransforms(root.get(), root->bounds(), 1, 1, 0, dummyMaxTextureSize, false, renderSurfaceLayerList);
2690 2690
2691 // Sanity check the scenario we just created. 2691 // Sanity check the scenario we just created.
2692 ASSERT_EQ(1u, renderSurfaceLayerList.size()); 2692 ASSERT_EQ(1u, renderSurfaceLayerList.size());
2693 ASSERT_EQ(1u, root->renderSurface()->layerList().size()); 2693 ASSERT_EQ(1u, root->renderSurface()->layerList().size());
2694 2694
2695 // Hit testing for a point outside the layer should return a null pointer. 2695 // Hit testing for a point outside the layer should return a null pointer.
2696 gfx::Point testPoint(101, 101); 2696 gfx::Point testPoint(101, 101);
2697 LayerImpl* resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(test Point, renderSurfaceLayerList); 2697 LayerImpl* resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(test Point, renderSurfaceLayerList);
2698 EXPECT_FALSE(resultLayer); 2698 EXPECT_FALSE(resultLayer);
2699 2699
(...skipping 26 matching lines...) Expand all
2726 2726
2727 WebTransformationMatrix identityMatrix; 2727 WebTransformationMatrix identityMatrix;
2728 gfx::PointF anchor(0, 0); 2728 gfx::PointF anchor(0, 0);
2729 gfx::PointF position(0, 0); 2729 gfx::PointF position(0, 0);
2730 gfx::Size bounds(100, 100); 2730 gfx::Size bounds(100, 100);
2731 setLayerPropertiesForTesting(root.get(), uninvertibleTransform, identityMatr ix, anchor, position, bounds, false); 2731 setLayerPropertiesForTesting(root.get(), uninvertibleTransform, identityMatr ix, anchor, position, bounds, false);
2732 root->setDrawsContent(true); 2732 root->setDrawsContent(true);
2733 2733
2734 std::vector<LayerImpl*> renderSurfaceLayerList; 2734 std::vector<LayerImpl*> renderSurfaceLayerList;
2735 int dummyMaxTextureSize = 512; 2735 int dummyMaxTextureSize = 512;
2736 LayerTreeHostCommon::calculateDrawTransforms(root.get(), root->bounds(), 1, 1, 0, dummyMaxTextureSize, renderSurfaceLayerList); 2736 LayerTreeHostCommon::calculateDrawTransforms(root.get(), root->bounds(), 1, 1, 0, dummyMaxTextureSize, false, renderSurfaceLayerList);
2737 2737
2738 // Sanity check the scenario we just created. 2738 // Sanity check the scenario we just created.
2739 ASSERT_EQ(1u, renderSurfaceLayerList.size()); 2739 ASSERT_EQ(1u, renderSurfaceLayerList.size());
2740 ASSERT_EQ(1u, root->renderSurface()->layerList().size()); 2740 ASSERT_EQ(1u, root->renderSurface()->layerList().size());
2741 ASSERT_FALSE(root->screenSpaceTransform().isInvertible()); 2741 ASSERT_FALSE(root->screenSpaceTransform().isInvertible());
2742 2742
2743 // Hit testing any point should not hit the layer. If the invertible matrix is 2743 // Hit testing any point should not hit the layer. If the invertible matrix is
2744 // accidentally ignored and treated like an identity, then the hit testing w ill 2744 // accidentally ignored and treated like an identity, then the hit testing w ill
2745 // incorrectly hit the layer when it shouldn't. 2745 // incorrectly hit the layer when it shouldn't.
2746 gfx::Point testPoint(1, 1); 2746 gfx::Point testPoint(1, 1);
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
2778 2778
2779 WebTransformationMatrix identityMatrix; 2779 WebTransformationMatrix identityMatrix;
2780 gfx::PointF anchor(0, 0); 2780 gfx::PointF anchor(0, 0);
2781 gfx::PointF position(50, 50); // this layer is positioned, and hit testing s hould correctly know where the layer is located. 2781 gfx::PointF position(50, 50); // this layer is positioned, and hit testing s hould correctly know where the layer is located.
2782 gfx::Size bounds(100, 100); 2782 gfx::Size bounds(100, 100);
2783 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc hor, position, bounds, false); 2783 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc hor, position, bounds, false);
2784 root->setDrawsContent(true); 2784 root->setDrawsContent(true);
2785 2785
2786 std::vector<LayerImpl*> renderSurfaceLayerList; 2786 std::vector<LayerImpl*> renderSurfaceLayerList;
2787 int dummyMaxTextureSize = 512; 2787 int dummyMaxTextureSize = 512;
2788 LayerTreeHostCommon::calculateDrawTransforms(root.get(), root->bounds(), 1, 1, 0, dummyMaxTextureSize, renderSurfaceLayerList); 2788 LayerTreeHostCommon::calculateDrawTransforms(root.get(), root->bounds(), 1, 1, 0, dummyMaxTextureSize, false, renderSurfaceLayerList);
2789 2789
2790 // Sanity check the scenario we just created. 2790 // Sanity check the scenario we just created.
2791 ASSERT_EQ(1u, renderSurfaceLayerList.size()); 2791 ASSERT_EQ(1u, renderSurfaceLayerList.size());
2792 ASSERT_EQ(1u, root->renderSurface()->layerList().size()); 2792 ASSERT_EQ(1u, root->renderSurface()->layerList().size());
2793 2793
2794 // Hit testing for a point outside the layer should return a null pointer. 2794 // Hit testing for a point outside the layer should return a null pointer.
2795 gfx::Point testPoint(49, 49); 2795 gfx::Point testPoint(49, 49);
2796 LayerImpl* resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(test Point, renderSurfaceLayerList); 2796 LayerImpl* resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(test Point, renderSurfaceLayerList);
2797 EXPECT_FALSE(resultLayer); 2797 EXPECT_FALSE(resultLayer);
2798 2798
(...skipping 24 matching lines...) Expand all
2823 rotation45DegreesAboutCenter.rotate3d(0, 0, 45); 2823 rotation45DegreesAboutCenter.rotate3d(0, 0, 45);
2824 rotation45DegreesAboutCenter.translate(-50, -50); 2824 rotation45DegreesAboutCenter.translate(-50, -50);
2825 gfx::PointF anchor(0, 0); 2825 gfx::PointF anchor(0, 0);
2826 gfx::PointF position(0, 0); 2826 gfx::PointF position(0, 0);
2827 gfx::Size bounds(100, 100); 2827 gfx::Size bounds(100, 100);
2828 setLayerPropertiesForTesting(root.get(), rotation45DegreesAboutCenter, ident ityMatrix, anchor, position, bounds, false); 2828 setLayerPropertiesForTesting(root.get(), rotation45DegreesAboutCenter, ident ityMatrix, anchor, position, bounds, false);
2829 root->setDrawsContent(true); 2829 root->setDrawsContent(true);
2830 2830
2831 std::vector<LayerImpl*> renderSurfaceLayerList; 2831 std::vector<LayerImpl*> renderSurfaceLayerList;
2832 int dummyMaxTextureSize = 512; 2832 int dummyMaxTextureSize = 512;
2833 LayerTreeHostCommon::calculateDrawTransforms(root.get(), root->bounds(), 1, 1, 0, dummyMaxTextureSize, renderSurfaceLayerList); 2833 LayerTreeHostCommon::calculateDrawTransforms(root.get(), root->bounds(), 1, 1, 0, dummyMaxTextureSize, false, renderSurfaceLayerList);
2834 2834
2835 // Sanity check the scenario we just created. 2835 // Sanity check the scenario we just created.
2836 ASSERT_EQ(1u, renderSurfaceLayerList.size()); 2836 ASSERT_EQ(1u, renderSurfaceLayerList.size());
2837 ASSERT_EQ(1u, root->renderSurface()->layerList().size()); 2837 ASSERT_EQ(1u, root->renderSurface()->layerList().size());
2838 2838
2839 // Hit testing for points outside the layer. 2839 // Hit testing for points outside the layer.
2840 // These corners would have been inside the un-transformed layer, but they s hould not hit the correctly transformed layer. 2840 // These corners would have been inside the un-transformed layer, but they s hould not hit the correctly transformed layer.
2841 gfx::Point testPoint(99, 99); 2841 gfx::Point testPoint(99, 99);
2842 LayerImpl* resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(test Point, renderSurfaceLayerList); 2842 LayerImpl* resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(test Point, renderSurfaceLayerList);
2843 EXPECT_FALSE(resultLayer); 2843 EXPECT_FALSE(resultLayer);
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
2877 translationByZ.translate3d(0, 0, -1); 2877 translationByZ.translate3d(0, 0, -1);
2878 2878
2879 gfx::PointF anchor(0, 0); 2879 gfx::PointF anchor(0, 0);
2880 gfx::PointF position(0, 0); 2880 gfx::PointF position(0, 0);
2881 gfx::Size bounds(100, 100); 2881 gfx::Size bounds(100, 100);
2882 setLayerPropertiesForTesting(root.get(), perspectiveProjectionAboutCenter * translationByZ, identityMatrix, anchor, position, bounds, false); 2882 setLayerPropertiesForTesting(root.get(), perspectiveProjectionAboutCenter * translationByZ, identityMatrix, anchor, position, bounds, false);
2883 root->setDrawsContent(true); 2883 root->setDrawsContent(true);
2884 2884
2885 std::vector<LayerImpl*> renderSurfaceLayerList; 2885 std::vector<LayerImpl*> renderSurfaceLayerList;
2886 int dummyMaxTextureSize = 512; 2886 int dummyMaxTextureSize = 512;
2887 LayerTreeHostCommon::calculateDrawTransforms(root.get(), root->bounds(), 1, 1, 0, dummyMaxTextureSize, renderSurfaceLayerList); 2887 LayerTreeHostCommon::calculateDrawTransforms(root.get(), root->bounds(), 1, 1, 0, dummyMaxTextureSize, false, renderSurfaceLayerList);
2888 2888
2889 // Sanity check the scenario we just created. 2889 // Sanity check the scenario we just created.
2890 ASSERT_EQ(1u, renderSurfaceLayerList.size()); 2890 ASSERT_EQ(1u, renderSurfaceLayerList.size());
2891 ASSERT_EQ(1u, root->renderSurface()->layerList().size()); 2891 ASSERT_EQ(1u, root->renderSurface()->layerList().size());
2892 2892
2893 // Hit testing for points outside the layer. 2893 // Hit testing for points outside the layer.
2894 // These corners would have been inside the un-transformed layer, but they s hould not hit the correctly transformed layer. 2894 // These corners would have been inside the un-transformed layer, but they s hould not hit the correctly transformed layer.
2895 gfx::Point testPoint(24, 24); 2895 gfx::Point testPoint(24, 24);
2896 LayerImpl* resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(test Point, renderSurfaceLayerList); 2896 LayerImpl* resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(test Point, renderSurfaceLayerList);
2897 EXPECT_FALSE(resultLayer); 2897 EXPECT_FALSE(resultLayer);
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
2940 // override contentBounds and contentsScale 2940 // override contentBounds and contentsScale
2941 testLayer->setContentBounds(gfx::Size(100, 100)); 2941 testLayer->setContentBounds(gfx::Size(100, 100));
2942 testLayer->setContentsScale(2, 2); 2942 testLayer->setContentsScale(2, 2);
2943 2943
2944 testLayer->setDrawsContent(true); 2944 testLayer->setDrawsContent(true);
2945 root->addChild(testLayer.Pass()); 2945 root->addChild(testLayer.Pass());
2946 } 2946 }
2947 2947
2948 std::vector<LayerImpl*> renderSurfaceLayerList; 2948 std::vector<LayerImpl*> renderSurfaceLayerList;
2949 int dummyMaxTextureSize = 512; 2949 int dummyMaxTextureSize = 512;
2950 LayerTreeHostCommon::calculateDrawTransforms(root.get(), root->bounds(), 1, 1, 0, dummyMaxTextureSize, renderSurfaceLayerList); 2950 LayerTreeHostCommon::calculateDrawTransforms(root.get(), root->bounds(), 1, 1, 0, dummyMaxTextureSize, false, renderSurfaceLayerList);
2951 2951
2952 // Sanity check the scenario we just created. 2952 // Sanity check the scenario we just created.
2953 // The visibleContentRect for testLayer is actually 100x100, even though its layout size is 50x50, positioned at 25x25. 2953 // The visibleContentRect for testLayer is actually 100x100, even though its layout size is 50x50, positioned at 25x25.
2954 LayerImpl* testLayer = root->children()[0]; 2954 LayerImpl* testLayer = root->children()[0];
2955 EXPECT_RECT_EQ(gfx::Rect(gfx::Point(), gfx::Size(100, 100)), testLayer->visi bleContentRect()); 2955 EXPECT_RECT_EQ(gfx::Rect(gfx::Point(), gfx::Size(100, 100)), testLayer->visi bleContentRect());
2956 ASSERT_EQ(1u, renderSurfaceLayerList.size()); 2956 ASSERT_EQ(1u, renderSurfaceLayerList.size());
2957 ASSERT_EQ(1u, root->renderSurface()->layerList().size()); 2957 ASSERT_EQ(1u, root->renderSurface()->layerList().size());
2958 2958
2959 // Hit testing for a point outside the layer should return a null pointer (t he root layer does not draw content, so it will not be hit tested either). 2959 // Hit testing for a point outside the layer should return a null pointer (t he root layer does not draw content, so it will not be hit tested either).
2960 gfx::Point testPoint(101, 101); 2960 gfx::Point testPoint(101, 101);
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
3002 position = gfx::PointF(-50, -50); 3002 position = gfx::PointF(-50, -50);
3003 bounds = gfx::Size(300, 300); 3003 bounds = gfx::Size(300, 300);
3004 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix , anchor, position, bounds, false); 3004 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix , anchor, position, bounds, false);
3005 child->setDrawsContent(true); 3005 child->setDrawsContent(true);
3006 clippingLayer->addChild(child.Pass()); 3006 clippingLayer->addChild(child.Pass());
3007 root->addChild(clippingLayer.Pass()); 3007 root->addChild(clippingLayer.Pass());
3008 } 3008 }
3009 3009
3010 std::vector<LayerImpl*> renderSurfaceLayerList; 3010 std::vector<LayerImpl*> renderSurfaceLayerList;
3011 int dummyMaxTextureSize = 512; 3011 int dummyMaxTextureSize = 512;
3012 LayerTreeHostCommon::calculateDrawTransforms(root.get(), root->bounds(), 1, 1, 0, dummyMaxTextureSize, renderSurfaceLayerList); 3012 LayerTreeHostCommon::calculateDrawTransforms(root.get(), root->bounds(), 1, 1, 0, dummyMaxTextureSize, false, renderSurfaceLayerList);
3013 3013
3014 // Sanity check the scenario we just created. 3014 // Sanity check the scenario we just created.
3015 ASSERT_EQ(1u, renderSurfaceLayerList.size()); 3015 ASSERT_EQ(1u, renderSurfaceLayerList.size());
3016 ASSERT_EQ(1u, root->renderSurface()->layerList().size()); 3016 ASSERT_EQ(1u, root->renderSurface()->layerList().size());
3017 ASSERT_EQ(456, root->renderSurface()->layerList()[0]->id()); 3017 ASSERT_EQ(456, root->renderSurface()->layerList()[0]->id());
3018 3018
3019 // Hit testing for a point outside the layer should return a null pointer. 3019 // Hit testing for a point outside the layer should return a null pointer.
3020 // Despite the child layer being very large, it should be clipped to the roo t layer's bounds. 3020 // Despite the child layer being very large, it should be clipped to the roo t layer's bounds.
3021 gfx::Point testPoint(24, 24); 3021 gfx::Point testPoint(24, 24);
3022 LayerImpl* resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(test Point, renderSurfaceLayerList); 3022 LayerImpl* resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(test Point, renderSurfaceLayerList);
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
3090 setLayerPropertiesForTesting(rotatedLeaf.get(), rotatedLeafTransform, id entityMatrix, anchor, position, bounds, false); 3090 setLayerPropertiesForTesting(rotatedLeaf.get(), rotatedLeafTransform, id entityMatrix, anchor, position, bounds, false);
3091 rotatedLeaf->setDrawsContent(true); 3091 rotatedLeaf->setDrawsContent(true);
3092 3092
3093 grandChild->addChild(rotatedLeaf.Pass()); 3093 grandChild->addChild(rotatedLeaf.Pass());
3094 child->addChild(grandChild.Pass()); 3094 child->addChild(grandChild.Pass());
3095 root->addChild(child.Pass()); 3095 root->addChild(child.Pass());
3096 } 3096 }
3097 3097
3098 std::vector<LayerImpl*> renderSurfaceLayerList; 3098 std::vector<LayerImpl*> renderSurfaceLayerList;
3099 int dummyMaxTextureSize = 512; 3099 int dummyMaxTextureSize = 512;
3100 LayerTreeHostCommon::calculateDrawTransforms(root.get(), root->bounds(), 1, 1, 0, dummyMaxTextureSize, renderSurfaceLayerList); 3100 LayerTreeHostCommon::calculateDrawTransforms(root.get(), root->bounds(), 1, 1, 0, dummyMaxTextureSize, false, renderSurfaceLayerList);
3101 3101
3102 // Sanity check the scenario we just created. 3102 // Sanity check the scenario we just created.
3103 // The grandChild is expected to create a renderSurface because it masksToBo unds and is not axis aligned. 3103 // The grandChild is expected to create a renderSurface because it masksToBo unds and is not axis aligned.
3104 ASSERT_EQ(2u, renderSurfaceLayerList.size()); 3104 ASSERT_EQ(2u, renderSurfaceLayerList.size());
3105 ASSERT_EQ(1u, renderSurfaceLayerList[0]->renderSurface()->layerList().size() ); 3105 ASSERT_EQ(1u, renderSurfaceLayerList[0]->renderSurface()->layerList().size() );
3106 ASSERT_EQ(789, renderSurfaceLayerList[0]->renderSurface()->layerList()[0]->i d()); // grandChild's surface. 3106 ASSERT_EQ(789, renderSurfaceLayerList[0]->renderSurface()->layerList()[0]->i d()); // grandChild's surface.
3107 ASSERT_EQ(1u, renderSurfaceLayerList[1]->renderSurface()->layerList().size() ); 3107 ASSERT_EQ(1u, renderSurfaceLayerList[1]->renderSurface()->layerList().size() );
3108 ASSERT_EQ(2468, renderSurfaceLayerList[1]->renderSurface()->layerList()[0]-> id()); 3108 ASSERT_EQ(2468, renderSurfaceLayerList[1]->renderSurface()->layerList()[0]-> id());
3109 3109
3110 // (11, 89) is close to the the bottom left corner within the clip, but it i s not inside the layer. 3110 // (11, 89) is close to the the bottom left corner within the clip, but it i s not inside the layer.
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
3170 position = gfx::PointF(60, 60); // 70, 70 in screen space 3170 position = gfx::PointF(60, 60); // 70, 70 in screen space
3171 bounds = gfx::Size(20, 20); 3171 bounds = gfx::Size(20, 20);
3172 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix , anchor, position, bounds, false); 3172 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix , anchor, position, bounds, false);
3173 child->setDrawsContent(true); 3173 child->setDrawsContent(true);
3174 intermediateLayer->addChild(child.Pass()); 3174 intermediateLayer->addChild(child.Pass());
3175 root->addChild(intermediateLayer.Pass()); 3175 root->addChild(intermediateLayer.Pass());
3176 } 3176 }
3177 3177
3178 std::vector<LayerImpl*> renderSurfaceLayerList; 3178 std::vector<LayerImpl*> renderSurfaceLayerList;
3179 int dummyMaxTextureSize = 512; 3179 int dummyMaxTextureSize = 512;
3180 LayerTreeHostCommon::calculateDrawTransforms(root.get(), root->bounds(), 1, 1, 0, dummyMaxTextureSize, renderSurfaceLayerList); 3180 LayerTreeHostCommon::calculateDrawTransforms(root.get(), root->bounds(), 1, 1, 0, dummyMaxTextureSize, false, renderSurfaceLayerList);
3181 3181
3182 // Sanity check the scenario we just created. 3182 // Sanity check the scenario we just created.
3183 ASSERT_EQ(1u, renderSurfaceLayerList.size()); 3183 ASSERT_EQ(1u, renderSurfaceLayerList.size());
3184 ASSERT_EQ(1u, root->renderSurface()->layerList().size()); 3184 ASSERT_EQ(1u, root->renderSurface()->layerList().size());
3185 ASSERT_EQ(456, root->renderSurface()->layerList()[0]->id()); 3185 ASSERT_EQ(456, root->renderSurface()->layerList()[0]->id());
3186 3186
3187 // Hit testing for a point outside the layer should return a null pointer. 3187 // Hit testing for a point outside the layer should return a null pointer.
3188 gfx::Point testPoint(69, 69); 3188 gfx::Point testPoint(69, 69);
3189 LayerImpl* resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(test Point, renderSurfaceLayerList); 3189 LayerImpl* resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(test Point, renderSurfaceLayerList);
3190 EXPECT_FALSE(resultLayer); 3190 EXPECT_FALSE(resultLayer);
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
3248 root->addChild(child1.Pass()); 3248 root->addChild(child1.Pass());
3249 root->addChild(child2.Pass()); 3249 root->addChild(child2.Pass());
3250 } 3250 }
3251 3251
3252 LayerImpl* child1 = root->children()[0]; 3252 LayerImpl* child1 = root->children()[0];
3253 LayerImpl* child2 = root->children()[1]; 3253 LayerImpl* child2 = root->children()[1];
3254 LayerImpl* grandChild1 = child1->children()[0]; 3254 LayerImpl* grandChild1 = child1->children()[0];
3255 3255
3256 std::vector<LayerImpl*> renderSurfaceLayerList; 3256 std::vector<LayerImpl*> renderSurfaceLayerList;
3257 int dummyMaxTextureSize = 512; 3257 int dummyMaxTextureSize = 512;
3258 LayerTreeHostCommon::calculateDrawTransforms(root.get(), root->bounds(), 1, 1, 0, dummyMaxTextureSize, renderSurfaceLayerList); 3258 LayerTreeHostCommon::calculateDrawTransforms(root.get(), root->bounds(), 1, 1, 0, dummyMaxTextureSize, false, renderSurfaceLayerList);
3259 3259
3260 // Sanity check the scenario we just created. 3260 // Sanity check the scenario we just created.
3261 ASSERT_TRUE(child1); 3261 ASSERT_TRUE(child1);
3262 ASSERT_TRUE(child2); 3262 ASSERT_TRUE(child2);
3263 ASSERT_TRUE(grandChild1); 3263 ASSERT_TRUE(grandChild1);
3264 ASSERT_EQ(1u, renderSurfaceLayerList.size()); 3264 ASSERT_EQ(1u, renderSurfaceLayerList.size());
3265 ASSERT_EQ(4u, root->renderSurface()->layerList().size()); 3265 ASSERT_EQ(4u, root->renderSurface()->layerList().size());
3266 ASSERT_EQ(1, root->renderSurface()->layerList()[0]->id()); // root layer 3266 ASSERT_EQ(1, root->renderSurface()->layerList()[0]->id()); // root layer
3267 ASSERT_EQ(2, root->renderSurface()->layerList()[1]->id()); // child1 3267 ASSERT_EQ(2, root->renderSurface()->layerList()[1]->id()); // child1
3268 ASSERT_EQ(4, root->renderSurface()->layerList()[2]->id()); // grandChild1 3268 ASSERT_EQ(4, root->renderSurface()->layerList()[2]->id()); // grandChild1
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
3354 root->addChild(child1.Pass()); 3354 root->addChild(child1.Pass());
3355 root->addChild(child2.Pass()); 3355 root->addChild(child2.Pass());
3356 } 3356 }
3357 3357
3358 LayerImpl* child1 = root->children()[0]; 3358 LayerImpl* child1 = root->children()[0];
3359 LayerImpl* child2 = root->children()[1]; 3359 LayerImpl* child2 = root->children()[1];
3360 LayerImpl* grandChild1 = child1->children()[0]; 3360 LayerImpl* grandChild1 = child1->children()[0];
3361 3361
3362 std::vector<LayerImpl*> renderSurfaceLayerList; 3362 std::vector<LayerImpl*> renderSurfaceLayerList;
3363 int dummyMaxTextureSize = 512; 3363 int dummyMaxTextureSize = 512;
3364 LayerTreeHostCommon::calculateDrawTransforms(root.get(), root->bounds(), 1, 1, 0, dummyMaxTextureSize, renderSurfaceLayerList); 3364 LayerTreeHostCommon::calculateDrawTransforms(root.get(), root->bounds(), 1, 1, 0, dummyMaxTextureSize, false, renderSurfaceLayerList);
3365 3365
3366 // Sanity check the scenario we just created. 3366 // Sanity check the scenario we just created.
3367 ASSERT_TRUE(child1); 3367 ASSERT_TRUE(child1);
3368 ASSERT_TRUE(child2); 3368 ASSERT_TRUE(child2);
3369 ASSERT_TRUE(grandChild1); 3369 ASSERT_TRUE(grandChild1);
3370 ASSERT_TRUE(child1->renderSurface()); 3370 ASSERT_TRUE(child1->renderSurface());
3371 ASSERT_TRUE(child2->renderSurface()); 3371 ASSERT_TRUE(child2->renderSurface());
3372 ASSERT_TRUE(grandChild1->renderSurface()); 3372 ASSERT_TRUE(grandChild1->renderSurface());
3373 ASSERT_EQ(4u, renderSurfaceLayerList.size()); 3373 ASSERT_EQ(4u, renderSurfaceLayerList.size());
3374 ASSERT_EQ(3u, root->renderSurface()->layerList().size()); // The root surfac e has the root layer, and child1's and child2's renderSurfaces. 3374 ASSERT_EQ(3u, root->renderSurface()->layerList().size()); // The root surfac e has the root layer, and child1's and child2's renderSurfaces.
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
3455 3455
3456 parent->addChild(child); 3456 parent->addChild(child);
3457 parent->addChild(childNoScale); 3457 parent->addChild(childNoScale);
3458 3458
3459 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; 3459 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList;
3460 int dummyMaxTextureSize = 512; 3460 int dummyMaxTextureSize = 512;
3461 3461
3462 const double deviceScaleFactor = 2.5; 3462 const double deviceScaleFactor = 2.5;
3463 const double pageScaleFactor = 1; 3463 const double pageScaleFactor = 1;
3464 3464
3465 LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(), deviceScaleFactor, pageScaleFactor, dummyMaxTextureSize, renderSurfaceLayerList ); 3465 LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(), deviceScaleFactor, pageScaleFactor, dummyMaxTextureSize, false, renderSurfaceLa yerList);
3466 3466
3467 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor, parent); 3467 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor, parent);
3468 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor, child); 3468 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor, child);
3469 EXPECT_CONTENTS_SCALE_EQ(1, childNoScale); 3469 EXPECT_CONTENTS_SCALE_EQ(1, childNoScale);
3470 3470
3471 EXPECT_EQ(1u, renderSurfaceLayerList.size()); 3471 EXPECT_EQ(1u, renderSurfaceLayerList.size());
3472 3472
3473 // Verify parent transforms 3473 // Verify parent transforms
3474 WebTransformationMatrix expectedParentTransform; 3474 WebTransformationMatrix expectedParentTransform;
3475 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedParentTransform, parent->screenSpace Transform()); 3475 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedParentTransform, parent->screenSpace Transform());
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
3529 3529
3530 parent->addChild(child); 3530 parent->addChild(child);
3531 parent->addChild(childNoScale); 3531 parent->addChild(childNoScale);
3532 3532
3533 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; 3533 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList;
3534 int dummyMaxTextureSize = 512; 3534 int dummyMaxTextureSize = 512;
3535 3535
3536 const float deviceScaleFactor = 1.7f; 3536 const float deviceScaleFactor = 1.7f;
3537 const float pageScaleFactor = 1; 3537 const float pageScaleFactor = 1;
3538 3538
3539 LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(), deviceScaleFactor, pageScaleFactor, dummyMaxTextureSize, renderSurfaceLayerList ); 3539 LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(), deviceScaleFactor, pageScaleFactor, dummyMaxTextureSize, false, renderSurfaceLa yerList);
3540 3540
3541 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor, parent); 3541 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor, parent);
3542 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor, child); 3542 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor, child);
3543 EXPECT_CONTENTS_SCALE_EQ(1, childNoScale); 3543 EXPECT_CONTENTS_SCALE_EQ(1, childNoScale);
3544 3544
3545 EXPECT_EQ(1u, renderSurfaceLayerList.size()); 3545 EXPECT_EQ(1u, renderSurfaceLayerList.size());
3546 3546
3547 // Verify parent transforms 3547 // Verify parent transforms
3548 WebTransformationMatrix expectedParentTransform; 3548 WebTransformationMatrix expectedParentTransform;
3549 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedParentTransform, parent->screenSpace Transform()); 3549 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedParentTransform, parent->screenSpace Transform());
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
3630 int dummyMaxTextureSize = 512; 3630 int dummyMaxTextureSize = 512;
3631 3631
3632 double deviceScaleFactor = 2.5; 3632 double deviceScaleFactor = 2.5;
3633 double pageScaleFactor = 1.5; 3633 double pageScaleFactor = 1.5;
3634 3634
3635 // FIXME: Remove this when pageScaleFactor is applied in the compositor. 3635 // FIXME: Remove this when pageScaleFactor is applied in the compositor.
3636 WebTransformationMatrix pageScaleMatrix; 3636 WebTransformationMatrix pageScaleMatrix;
3637 pageScaleMatrix.scale(pageScaleFactor); 3637 pageScaleMatrix.scale(pageScaleFactor);
3638 parent->setSublayerTransform(pageScaleMatrix); 3638 parent->setSublayerTransform(pageScaleMatrix);
3639 3639
3640 LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(), deviceScaleFactor, pageScaleFactor, dummyMaxTextureSize, renderSurfaceLayerList ); 3640 LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(), deviceScaleFactor, pageScaleFactor, dummyMaxTextureSize, false, renderSurfaceLa yerList);
3641 3641
3642 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * initialParentScale, parent); 3642 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * initialParentScale, parent);
3643 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor * initialParent Scale * initialChildScale, childScale); 3643 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor * initialParent Scale * initialChildScale, childScale);
3644 EXPECT_CONTENTS_SCALE_EQ(1, childNoScale); 3644 EXPECT_CONTENTS_SCALE_EQ(1, childNoScale);
3645 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor * fixedRasterSc ale, childNoAutoScale); 3645 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor * fixedRasterSc ale, childNoAutoScale);
3646 3646
3647 // The parent is scaled up and shouldn't need to scale during draw. The chil d that can scale its contents should 3647 // The parent is scaled up and shouldn't need to scale during draw. The chil d that can scale its contents should
3648 // also not need to scale during draw. The other should. 3648 // also not need to scale during draw. The other should.
3649 // There is some rounding error due to contentBounds being a rounded integer . 3649 // There is some rounding error due to contentBounds being a rounded integer .
3650 EXPECT_NEAR(parent->drawTransform().m11(), 1, 0.01); 3650 EXPECT_NEAR(parent->drawTransform().m11(), 1, 0.01);
3651 EXPECT_NEAR(parent->drawTransform().m22(), 1, 0.01); 3651 EXPECT_NEAR(parent->drawTransform().m22(), 1, 0.01);
3652 EXPECT_NEAR(childScale->drawTransform().m11(), 1, 0.01); 3652 EXPECT_NEAR(childScale->drawTransform().m11(), 1, 0.01);
3653 EXPECT_NEAR(childScale->drawTransform().m22(), 1, 0.01); 3653 EXPECT_NEAR(childScale->drawTransform().m22(), 1, 0.01);
3654 EXPECT_FLOAT_EQ(deviceScaleFactor * pageScaleFactor * initialParentScale * i nitialChildScale, childNoScale->drawTransform().m11()); 3654 EXPECT_FLOAT_EQ(deviceScaleFactor * pageScaleFactor * initialParentScale * i nitialChildScale, childNoScale->drawTransform().m11());
3655 EXPECT_FLOAT_EQ(deviceScaleFactor * pageScaleFactor * initialParentScale * i nitialChildScale, childNoScale->drawTransform().m22()); 3655 EXPECT_FLOAT_EQ(deviceScaleFactor * pageScaleFactor * initialParentScale * i nitialChildScale, childNoScale->drawTransform().m22());
3656 EXPECT_NEAR(childNoAutoScale->drawTransform().m11(), initialParentScale * in itialChildScale / fixedRasterScale, 0.01); 3656 EXPECT_NEAR(childNoAutoScale->drawTransform().m11(), initialParentScale * in itialChildScale / fixedRasterScale, 0.01);
3657 EXPECT_NEAR(childNoAutoScale->drawTransform().m22(), initialParentScale * in itialChildScale / fixedRasterScale, 0.01); 3657 EXPECT_NEAR(childNoAutoScale->drawTransform().m22(), initialParentScale * in itialChildScale / fixedRasterScale, 0.01);
3658 3658
3659 // If the transform changes, we expect the contentsScale to remain unchanged . 3659 // If the transform changes, we expect the contentsScale to remain unchanged .
3660 childScale->setTransform(identityMatrix); 3660 childScale->setTransform(identityMatrix);
3661 3661
3662 renderSurfaceLayerList.clear(); 3662 renderSurfaceLayerList.clear();
3663 LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(), deviceScaleFactor, pageScaleFactor, dummyMaxTextureSize, renderSurfaceLayerList ); 3663 LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(), deviceScaleFactor, pageScaleFactor, dummyMaxTextureSize, false, renderSurfaceLa yerList);
3664 3664
3665 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * initialParentScale, parent); 3665 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * initialParentScale, parent);
3666 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor * initialParent Scale * initialChildScale, childScale); 3666 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor * initialParent Scale * initialChildScale, childScale);
3667 EXPECT_CONTENTS_SCALE_EQ(1, childNoScale); 3667 EXPECT_CONTENTS_SCALE_EQ(1, childNoScale);
3668 3668
3669 // But if the deviceScaleFactor or pageScaleFactor changes, then it should b e updated, but using the initial transform. 3669 // But if the deviceScaleFactor or pageScaleFactor changes, then it should b e updated, but using the initial transform.
3670 deviceScaleFactor = 2.25; 3670 deviceScaleFactor = 2.25;
3671 pageScaleFactor = 1.25; 3671 pageScaleFactor = 1.25;
3672 3672
3673 // FIXME: Remove this when pageScaleFactor is applied in the compositor. 3673 // FIXME: Remove this when pageScaleFactor is applied in the compositor.
3674 pageScaleMatrix = identityMatrix; 3674 pageScaleMatrix = identityMatrix;
3675 pageScaleMatrix.scale(pageScaleFactor); 3675 pageScaleMatrix.scale(pageScaleFactor);
3676 parent->setSublayerTransform(pageScaleMatrix); 3676 parent->setSublayerTransform(pageScaleMatrix);
3677 3677
3678 renderSurfaceLayerList.clear(); 3678 renderSurfaceLayerList.clear();
3679 LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(), deviceScaleFactor, pageScaleFactor, dummyMaxTextureSize, renderSurfaceLayerList ); 3679 LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(), deviceScaleFactor, pageScaleFactor, dummyMaxTextureSize, false, renderSurfaceLa yerList);
3680 3680
3681 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * initialParentScale, parent); 3681 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * initialParentScale, parent);
3682 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor * initialParent Scale * initialChildScale, childScale); 3682 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor * initialParent Scale * initialChildScale, childScale);
3683 EXPECT_CONTENTS_SCALE_EQ(1, childNoScale); 3683 EXPECT_CONTENTS_SCALE_EQ(1, childNoScale);
3684 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor * fixedRasterSc ale, childNoAutoScale); 3684 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor * fixedRasterSc ale, childNoAutoScale);
3685 } 3685 }
3686 3686
3687 TEST(LayerTreeHostCommonTest, verifySmallContentsScale) 3687 TEST(LayerTreeHostCommonTest, verifySmallContentsScale)
3688 { 3688 {
3689 MockContentLayerClient delegate; 3689 MockContentLayerClient delegate;
(...skipping 23 matching lines...) Expand all
3713 int dummyMaxTextureSize = 512; 3713 int dummyMaxTextureSize = 512;
3714 3714
3715 double deviceScaleFactor = 2.5; 3715 double deviceScaleFactor = 2.5;
3716 double pageScaleFactor = 0.01; 3716 double pageScaleFactor = 0.01;
3717 3717
3718 // FIXME: Remove this when pageScaleFactor is applied in the compositor. 3718 // FIXME: Remove this when pageScaleFactor is applied in the compositor.
3719 WebTransformationMatrix pageScaleMatrix; 3719 WebTransformationMatrix pageScaleMatrix;
3720 pageScaleMatrix.scale(pageScaleFactor); 3720 pageScaleMatrix.scale(pageScaleFactor);
3721 parent->setSublayerTransform(pageScaleMatrix); 3721 parent->setSublayerTransform(pageScaleMatrix);
3722 3722
3723 LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(), deviceScaleFactor, pageScaleFactor, dummyMaxTextureSize, renderSurfaceLayerList ); 3723 LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(), deviceScaleFactor, pageScaleFactor, dummyMaxTextureSize, false, renderSurfaceLa yerList);
3724 3724
3725 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * initialParentScale, parent); 3725 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * initialParentScale, parent);
3726 // The child's scale is < 1, so we should not save and use that scale factor . 3726 // The child's scale is < 1, so we should not save and use that scale factor .
3727 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor * 1, childScale ); 3727 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor * 1, childScale );
3728 3728
3729 // When chilld's total scale becomes >= 1, we should save and use that scale factor. 3729 // When chilld's total scale becomes >= 1, we should save and use that scale factor.
3730 childScaleMatrix.makeIdentity(); 3730 childScaleMatrix.makeIdentity();
3731 const double finalChildScale = 0.75; 3731 const double finalChildScale = 0.75;
3732 childScaleMatrix.scale(finalChildScale); 3732 childScaleMatrix.scale(finalChildScale);
3733 childScale->setTransform(childScaleMatrix); 3733 childScale->setTransform(childScaleMatrix);
3734 3734
3735 renderSurfaceLayerList.clear(); 3735 renderSurfaceLayerList.clear();
3736 LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(), deviceScaleFactor, pageScaleFactor, dummyMaxTextureSize, renderSurfaceLayerList ); 3736 LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(), deviceScaleFactor, pageScaleFactor, dummyMaxTextureSize, false, renderSurfaceLa yerList);
3737 3737
3738 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * initialParentScale, parent); 3738 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * initialParentScale, parent);
3739 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor * initialParent Scale * finalChildScale, childScale); 3739 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor * initialParent Scale * finalChildScale, childScale);
3740 } 3740 }
3741 3741
3742 TEST(LayerTreeHostCommonTest, verifyContentsScaleForSurfaces) 3742 TEST(LayerTreeHostCommonTest, verifyContentsScaleForSurfaces)
3743 { 3743 {
3744 MockContentLayerClient delegate; 3744 MockContentLayerClient delegate;
3745 WebTransformationMatrix identityMatrix; 3745 WebTransformationMatrix identityMatrix;
3746 3746
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
3810 int dummyMaxTextureSize = 512; 3810 int dummyMaxTextureSize = 512;
3811 3811
3812 double deviceScaleFactor = 5; 3812 double deviceScaleFactor = 5;
3813 double pageScaleFactor = 7; 3813 double pageScaleFactor = 7;
3814 3814
3815 // FIXME: Remove this when pageScaleFactor is applied in the compositor. 3815 // FIXME: Remove this when pageScaleFactor is applied in the compositor.
3816 WebTransformationMatrix pageScaleMatrix; 3816 WebTransformationMatrix pageScaleMatrix;
3817 pageScaleMatrix.scale(pageScaleFactor); 3817 pageScaleMatrix.scale(pageScaleFactor);
3818 parent->setSublayerTransform(pageScaleMatrix); 3818 parent->setSublayerTransform(pageScaleMatrix);
3819 3819
3820 LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(), deviceScaleFactor, pageScaleFactor, dummyMaxTextureSize, renderSurfaceLayerList ); 3820 LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(), deviceScaleFactor, pageScaleFactor, dummyMaxTextureSize, false, renderSurfaceLa yerList);
3821 3821
3822 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * initialParentScale, parent); 3822 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * initialParentScale, parent);
3823 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor * initialParent Scale * initialChildScale, surfaceScale); 3823 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor * initialParent Scale * initialChildScale, surfaceScale);
3824 EXPECT_CONTENTS_SCALE_EQ(1, surfaceNoScale); 3824 EXPECT_CONTENTS_SCALE_EQ(1, surfaceNoScale);
3825 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor * fixedRasterSc ale, surfaceNoAutoScale); 3825 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor * fixedRasterSc ale, surfaceNoAutoScale);
3826 3826
3827 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor * initialParent Scale * initialChildScale * initialChildScale, surfaceScaleChildScale); 3827 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor * initialParent Scale * initialChildScale * initialChildScale, surfaceScaleChildScale);
3828 EXPECT_CONTENTS_SCALE_EQ(1, surfaceScaleChildNoScale); 3828 EXPECT_CONTENTS_SCALE_EQ(1, surfaceScaleChildNoScale);
3829 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor * initialParent Scale * initialChildScale * initialChildScale, surfaceNoScaleChildScale); 3829 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor * initialParent Scale * initialChildScale * initialChildScale, surfaceNoScaleChildScale);
3830 EXPECT_CONTENTS_SCALE_EQ(1, surfaceNoScaleChildNoScale); 3830 EXPECT_CONTENTS_SCALE_EQ(1, surfaceNoScaleChildNoScale);
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
3904 setLayerPropertiesForTesting(childScale.get(), childScaleMatrix, identityMat rix, gfx::PointF(0, 0), gfx::PointF(2, 2), gfx::Size(10, 10), true); 3904 setLayerPropertiesForTesting(childScale.get(), childScaleMatrix, identityMat rix, gfx::PointF(0, 0), gfx::PointF(2, 2), gfx::Size(10, 10), true);
3905 3905
3906 parent->addChild(childScale); 3906 parent->addChild(childScale);
3907 3907
3908 // Now put an animating transform on child. 3908 // Now put an animating transform on child.
3909 int animationId = addAnimatedTransformToController(*childScale->layerAnimati onController(), 10, 30, 0); 3909 int animationId = addAnimatedTransformToController(*childScale->layerAnimati onController(), 10, 30, 0);
3910 3910
3911 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; 3911 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList;
3912 int dummyMaxTextureSize = 512; 3912 int dummyMaxTextureSize = 512;
3913 3913
3914 LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(), 1, 1, dummyMaxTextureSize, renderSurfaceLayerList); 3914 LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(), 1, 1, dummyMaxTextureSize, false, renderSurfaceLayerList);
3915 3915
3916 EXPECT_CONTENTS_SCALE_EQ(initialParentScale, parent); 3916 EXPECT_CONTENTS_SCALE_EQ(initialParentScale, parent);
3917 // The layers with animating transforms should not compute a contentsScale o ther than 1 until they finish animating. 3917 // The layers with animating transforms should not compute a contentsScale o ther than 1 until they finish animating.
3918 EXPECT_CONTENTS_SCALE_EQ(1, childScale); 3918 EXPECT_CONTENTS_SCALE_EQ(1, childScale);
3919 3919
3920 // Remove the animation, now it can save a raster scale. 3920 // Remove the animation, now it can save a raster scale.
3921 childScale->layerAnimationController()->removeAnimation(animationId); 3921 childScale->layerAnimationController()->removeAnimation(animationId);
3922 3922
3923 LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(), 1, 1, dummyMaxTextureSize, renderSurfaceLayerList); 3923 LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(), 1, 1, dummyMaxTextureSize, false, renderSurfaceLayerList);
3924 3924
3925 EXPECT_CONTENTS_SCALE_EQ(initialParentScale, parent); 3925 EXPECT_CONTENTS_SCALE_EQ(initialParentScale, parent);
3926 // The layers with animating transforms should not compute a contentsScale o ther than 1 until they finish animating. 3926 // The layers with animating transforms should not compute a contentsScale o ther than 1 until they finish animating.
3927 EXPECT_CONTENTS_SCALE_EQ(initialParentScale * initialChildScale, childScale) ; 3927 EXPECT_CONTENTS_SCALE_EQ(initialParentScale * initialChildScale, childScale) ;
3928 } 3928 }
3929 3929
3930 3930
3931 TEST(LayerTreeHostCommonTest, verifyRenderSurfaceTransformsInHighDPI) 3931 TEST(LayerTreeHostCommonTest, verifyRenderSurfaceTransformsInHighDPI)
3932 { 3932 {
3933 MockContentLayerClient delegate; 3933 MockContentLayerClient delegate;
(...skipping 21 matching lines...) Expand all
3955 3955
3956 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; 3956 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList;
3957 int dummyMaxTextureSize = 512; 3957 int dummyMaxTextureSize = 512;
3958 3958
3959 const double deviceScaleFactor = 1.5; 3959 const double deviceScaleFactor = 1.5;
3960 parent->setContentsScale(deviceScaleFactor); 3960 parent->setContentsScale(deviceScaleFactor);
3961 child->setContentsScale(deviceScaleFactor); 3961 child->setContentsScale(deviceScaleFactor);
3962 duplicateChildNonOwner->setContentsScale(deviceScaleFactor); 3962 duplicateChildNonOwner->setContentsScale(deviceScaleFactor);
3963 replica->setContentsScale(deviceScaleFactor); 3963 replica->setContentsScale(deviceScaleFactor);
3964 3964
3965 LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(), deviceScaleFactor, 1, dummyMaxTextureSize, renderSurfaceLayerList); 3965 LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(), deviceScaleFactor, 1, dummyMaxTextureSize, false, renderSurfaceLayerList);
3966 3966
3967 // We should have two render surfaces. The root's render surface and child's 3967 // We should have two render surfaces. The root's render surface and child's
3968 // render surface (it needs one because it has a replica layer). 3968 // render surface (it needs one because it has a replica layer).
3969 EXPECT_EQ(2u, renderSurfaceLayerList.size()); 3969 EXPECT_EQ(2u, renderSurfaceLayerList.size());
3970 3970
3971 WebTransformationMatrix expectedParentTransform; 3971 WebTransformationMatrix expectedParentTransform;
3972 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedParentTransform, parent->screenSpace Transform()); 3972 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedParentTransform, parent->screenSpace Transform());
3973 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedParentTransform, parent->drawTransfo rm()); 3973 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedParentTransform, parent->drawTransfo rm());
3974 3974
3975 WebTransformationMatrix expectedDrawTransform; 3975 WebTransformationMatrix expectedDrawTransform;
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
4038 4038
4039 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; 4039 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList;
4040 int dummyMaxTextureSize = 512; 4040 int dummyMaxTextureSize = 512;
4041 4041
4042 const float deviceScaleFactor = 1.7f; 4042 const float deviceScaleFactor = 1.7f;
4043 parent->setContentsScale(deviceScaleFactor); 4043 parent->setContentsScale(deviceScaleFactor);
4044 child->setContentsScale(deviceScaleFactor); 4044 child->setContentsScale(deviceScaleFactor);
4045 duplicateChildNonOwner->setContentsScale(deviceScaleFactor); 4045 duplicateChildNonOwner->setContentsScale(deviceScaleFactor);
4046 replica->setContentsScale(deviceScaleFactor); 4046 replica->setContentsScale(deviceScaleFactor);
4047 4047
4048 LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(), deviceScaleFactor, 1, dummyMaxTextureSize, renderSurfaceLayerList); 4048 LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(), deviceScaleFactor, 1, dummyMaxTextureSize, false, renderSurfaceLayerList);
4049 4049
4050 // We should have two render surfaces. The root's render surface and child's 4050 // We should have two render surfaces. The root's render surface and child's
4051 // render surface (it needs one because it has a replica layer). 4051 // render surface (it needs one because it has a replica layer).
4052 EXPECT_EQ(2u, renderSurfaceLayerList.size()); 4052 EXPECT_EQ(2u, renderSurfaceLayerList.size());
4053 4053
4054 WebTransformationMatrix identityTransform; 4054 WebTransformationMatrix identityTransform;
4055 4055
4056 EXPECT_TRANSFORMATION_MATRIX_EQ(identityTransform, parent->screenSpaceTransf orm()); 4056 EXPECT_TRANSFORMATION_MATRIX_EQ(identityTransform, parent->screenSpaceTransf orm());
4057 EXPECT_TRANSFORMATION_MATRIX_EQ(identityTransform, parent->drawTransform()); 4057 EXPECT_TRANSFORMATION_MATRIX_EQ(identityTransform, parent->drawTransform());
4058 EXPECT_TRANSFORMATION_MATRIX_EQ(identityTransform, child->drawTransform()); 4058 EXPECT_TRANSFORMATION_MATRIX_EQ(identityTransform, child->drawTransform());
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
4090 4090
4091 int nonexistentId = -1; 4091 int nonexistentId = -1;
4092 EXPECT_EQ(root, LayerTreeHostCommon::findLayerInSubtree(root.get(), root->id ())); 4092 EXPECT_EQ(root, LayerTreeHostCommon::findLayerInSubtree(root.get(), root->id ()));
4093 EXPECT_EQ(child, LayerTreeHostCommon::findLayerInSubtree(root.get(), child-> id())); 4093 EXPECT_EQ(child, LayerTreeHostCommon::findLayerInSubtree(root.get(), child-> id()));
4094 EXPECT_EQ(grandChild, LayerTreeHostCommon::findLayerInSubtree(root.get(), gr andChild->id())); 4094 EXPECT_EQ(grandChild, LayerTreeHostCommon::findLayerInSubtree(root.get(), gr andChild->id()));
4095 EXPECT_EQ(maskLayer, LayerTreeHostCommon::findLayerInSubtree(root.get(), mas kLayer->id())); 4095 EXPECT_EQ(maskLayer, LayerTreeHostCommon::findLayerInSubtree(root.get(), mas kLayer->id()));
4096 EXPECT_EQ(replicaLayer, LayerTreeHostCommon::findLayerInSubtree(root.get(), replicaLayer->id())); 4096 EXPECT_EQ(replicaLayer, LayerTreeHostCommon::findLayerInSubtree(root.get(), replicaLayer->id()));
4097 EXPECT_EQ(0, LayerTreeHostCommon::findLayerInSubtree(root.get(), nonexistent Id)); 4097 EXPECT_EQ(0, LayerTreeHostCommon::findLayerInSubtree(root.get(), nonexistent Id));
4098 } 4098 }
4099 4099
4100 typedef std::tr1::tuple<bool, int> LCDTextTestParam;
4101 class LCDTextTest : public testing::TestWithParam<LCDTextTestParam> {
4102 public:
4103 enum LayerProperty {
4104 LAYER_REGULAR,
4105 LAYER_PRESERVES_3D,
4106 LAYER_FORCES_RENDER_SURFACE
4107 };
4108
4109 protected:
4110 virtual void SetUp()
4111 {
4112 m_canUseLCDText = std::tr1::get<0>(GetParam());
4113
4114 m_root = Layer::create();
4115 m_child = Layer::create();
4116 m_grandChild = Layer::create();
4117 m_child->addChild(m_grandChild.get());
4118 m_root->addChild(m_child.get());
4119
4120 WebTransformationMatrix identityMatrix;
4121 setLayerPropertiesForTesting(m_root, identityMatrix, identityMatrix, gfx ::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(1, 1), false);
4122 setLayerPropertiesForTesting(m_child, identityMatrix, identityMatrix, gf x::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(1, 1), false);
4123 setLayerPropertiesForTesting(m_grandChild, identityMatrix, identityMatri x, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(1, 1), false);
4124
4125 switch (std::tr1::get<1>(GetParam())) {
4126 case LAYER_REGULAR:
4127 break;
4128 case LAYER_PRESERVES_3D:
enne (OOO) 2012/11/14 17:42:15 How does preserves 3d enter into this?
alokp 2012/11/16 04:41:11 drawOpacity and drawOpacityAnimating is inherited
enne (OOO) 2012/11/16 17:36:38 It still feels like overtesting to me. We have ot
alokp 2012/11/16 21:33:52 Done.
4129 m_child->setPreserves3D(true);
4130 break;
4131 case LAYER_FORCES_RENDER_SURFACE:
4132 m_child->setForceRenderSurface(true);
4133 break;
4134 default:
4135 NOTREACHED();
4136 }
4137 }
4138
4139 bool m_canUseLCDText;
4140 scoped_refptr<Layer> m_root;
4141 scoped_refptr<Layer> m_child;
4142 scoped_refptr<Layer> m_grandChild;
4143 };
4144
4145 TEST_P(LCDTextTest, verifyCanUseLCDText)
4146 {
4147 // Case 1: Identity transform.
4148 WebTransformationMatrix identityMatrix;
4149 executeCalculateDrawTransformsAndVisibility(m_root, 1, 1, m_canUseLCDText);
4150 EXPECT_EQ(m_canUseLCDText, m_root->canUseLCDText());
4151 EXPECT_EQ(m_canUseLCDText, m_child->canUseLCDText());
4152 EXPECT_EQ(m_canUseLCDText, m_grandChild->canUseLCDText());
4153
4154 // Case 2: Integral translation.
4155 WebTransformationMatrix integralTranslation;
4156 integralTranslation.translate(1, 2);
4157 m_child->setTransform(integralTranslation);
4158 executeCalculateDrawTransformsAndVisibility(m_root, 1, 1, m_canUseLCDText);
4159 EXPECT_EQ(m_canUseLCDText, m_root->canUseLCDText());
4160 EXPECT_EQ(m_canUseLCDText, m_child->canUseLCDText());
4161 EXPECT_EQ(m_canUseLCDText, m_grandChild->canUseLCDText());
4162
4163 // Case 3: Non-integral translation.
4164 WebTransformationMatrix nonIntegralTranslation;
4165 nonIntegralTranslation.translate(1.5, 2.5);
4166 m_child->setTransform(nonIntegralTranslation);
4167 executeCalculateDrawTransformsAndVisibility(m_root, 1, 1, m_canUseLCDText);
4168 EXPECT_EQ(m_canUseLCDText, m_root->canUseLCDText());
4169 EXPECT_EQ(false, m_child->canUseLCDText());
4170 EXPECT_EQ(false, m_grandChild->canUseLCDText());
4171
4172 // Case 4: Rotation.
4173 WebTransformationMatrix rotation;
4174 rotation.rotate(10);
4175 m_child->setTransform(rotation);
4176 executeCalculateDrawTransformsAndVisibility(m_root, 1, 1, m_canUseLCDText);
4177 EXPECT_EQ(m_canUseLCDText, m_root->canUseLCDText());
4178 EXPECT_EQ(false, m_child->canUseLCDText());
4179 EXPECT_EQ(false, m_grandChild->canUseLCDText());
4180
4181 // Case 5: Scale.
4182 WebTransformationMatrix scale;
4183 scale.scale(2);
4184 m_child->setTransform(scale);
4185 executeCalculateDrawTransformsAndVisibility(m_root, 1, 1, m_canUseLCDText);
4186 EXPECT_EQ(m_canUseLCDText, m_root->canUseLCDText());
4187 EXPECT_EQ(false, m_child->canUseLCDText());
4188 EXPECT_EQ(false, m_grandChild->canUseLCDText());
4189
4190 // Case 6: Skew.
4191 WebTransformationMatrix skew;
4192 skew.skewX(10);
4193 m_child->setTransform(skew);
4194 executeCalculateDrawTransformsAndVisibility(m_root, 1, 1, m_canUseLCDText);
4195 EXPECT_EQ(m_canUseLCDText, m_root->canUseLCDText());
4196 EXPECT_EQ(false, m_child->canUseLCDText());
4197 EXPECT_EQ(false, m_grandChild->canUseLCDText());
4198
4199 // Case 7: Translucent.
4200 m_child->setTransform(identityMatrix);
4201 m_child->setOpacity(0.5);
4202 executeCalculateDrawTransformsAndVisibility(m_root, 1, 1, m_canUseLCDText);
4203 EXPECT_EQ(m_canUseLCDText, m_root->canUseLCDText());
4204 EXPECT_EQ(false, m_child->canUseLCDText());
4205 EXPECT_EQ(m_child->forceRenderSurface() || m_child->preserves3D() ? false : m_canUseLCDText, m_grandChild->canUseLCDText());
4206
4207 // Case 8: Sanity check: restore transform and opacity.
4208 m_child->setTransform(identityMatrix);
4209 m_child->setOpacity(1);
4210 executeCalculateDrawTransformsAndVisibility(m_root, 1, 1, m_canUseLCDText);
4211 EXPECT_EQ(m_canUseLCDText, m_root->canUseLCDText());
4212 EXPECT_EQ(m_canUseLCDText, m_child->canUseLCDText());
4213 EXPECT_EQ(m_canUseLCDText, m_grandChild->canUseLCDText());
4214 }
4215
4216 TEST_P(LCDTextTest, verifyCanUseLCDTextWithAnimation)
4217 {
4218 // Sanity check: Make sure m_canUseLCDText is set on each node.
4219 executeCalculateDrawTransformsAndVisibility(m_root, 1, 1, m_canUseLCDText);
4220 EXPECT_EQ(m_canUseLCDText, m_root->canUseLCDText());
4221 EXPECT_EQ(m_canUseLCDText, m_child->canUseLCDText());
4222 EXPECT_EQ(m_canUseLCDText, m_grandChild->canUseLCDText());
4223
4224 // Add opacity animation.
4225 m_child->setOpacity(0.9f);
4226 addOpacityTransitionToController(*(m_child->layerAnimationController()), 10, 0.9f, 0.1f, false);
4227
4228 executeCalculateDrawTransformsAndVisibility(m_root, 1, 1, m_canUseLCDText);
4229 // Text AA should not be adjusted while animation is active.
4230 // Make sure LCD text AA setting remains unchanged.
4231 EXPECT_EQ(m_canUseLCDText, m_root->canUseLCDText());
4232 EXPECT_EQ(m_canUseLCDText, m_child->canUseLCDText());
4233 EXPECT_EQ(m_canUseLCDText, m_grandChild->canUseLCDText());
4234 }
4235
4236 INSTANTIATE_TEST_CASE_P(All,
4237 LCDTextTest,
4238 testing::Combine(testing::Bool(),
4239 testing::Values(LCDTextTest::LAYER_REGU LAR,
4240 LCDTextTest::LAYER_PRES ERVES_3D,
4241 LCDTextTest::LAYER_FORC ES_RENDER_SURFACE)));
4242
4100 } // namespace 4243 } // namespace
4101 } // namespace cc 4244 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698