OLD | NEW |
---|---|
1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "config.h" | 5 #include "config.h" |
6 | 6 |
7 #include "cc/layer_tree_host_common.h" | 7 #include "cc/layer_tree_host_common.h" |
8 | 8 |
9 #include "cc/content_layer.h" | 9 #include "cc/content_layer.h" |
10 #include "cc/content_layer_client.h" | 10 #include "cc/content_layer_client.h" |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
44 setLayerPropertiesForTestingInternal<Layer>(layer, transform, sublayerTransf orm, anchor, position, bounds, preserves3D); | 44 setLayerPropertiesForTestingInternal<Layer>(layer, transform, sublayerTransf orm, anchor, position, bounds, preserves3D); |
45 layer->setAutomaticallyComputeRasterScale(true); | 45 layer->setAutomaticallyComputeRasterScale(true); |
46 } | 46 } |
47 | 47 |
48 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) | 48 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) |
49 { | 49 { |
50 setLayerPropertiesForTestingInternal<LayerImpl>(layer, transform, sublayerTr ansform, anchor, position, bounds, preserves3D); | 50 setLayerPropertiesForTestingInternal<LayerImpl>(layer, transform, sublayerTr ansform, anchor, position, bounds, preserves3D); |
51 layer->setContentBounds(bounds); | 51 layer->setContentBounds(bounds); |
52 } | 52 } |
53 | 53 |
54 void executeCalculateDrawTransformsAndVisibility(Layer* rootLayer, float deviceS caleFactor = 1, float pageScaleFactor = 1) | 54 void executeCalculateDrawTransformsAndVisibility(Layer* rootLayer, float deviceS caleFactor = 1, float pageScaleFactor = 1, bool canUseLCDText = false) |
55 { | 55 { |
56 WebTransformationMatrix identityMatrix; | 56 WebTransformationMatrix identityMatrix; |
57 std::vector<scoped_refptr<Layer> > dummyRenderSurfaceLayerList; | 57 std::vector<scoped_refptr<Layer> > dummyRenderSurfaceLayerList; |
58 int dummyMaxTextureSize = 512; | 58 int dummyMaxTextureSize = 512; |
59 gfx::Size deviceViewportSize = gfx::Size(rootLayer->bounds().width() * devic eScaleFactor, rootLayer->bounds().height() * deviceScaleFactor); | 59 gfx::Size deviceViewportSize = gfx::Size(rootLayer->bounds().width() * devic eScaleFactor, rootLayer->bounds().height() * deviceScaleFactor); |
60 | 60 |
61 // We are probably not testing what is intended if the rootLayer bounds are empty. | 61 // We are probably not testing what is intended if the rootLayer bounds are empty. |
62 DCHECK(!rootLayer->bounds().IsEmpty()); | 62 DCHECK(!rootLayer->bounds().IsEmpty()); |
63 LayerTreeHostCommon::calculateDrawTransforms(rootLayer, deviceViewportSize, deviceScaleFactor, pageScaleFactor, dummyMaxTextureSize, dummyRenderSurfaceLayer List); | 63 LayerTreeHostCommon::calculateDrawTransforms(rootLayer, deviceViewportSize, deviceScaleFactor, pageScaleFactor, dummyMaxTextureSize, canUseLCDText, dummyRen derSurfaceLayerList); |
64 } | 64 } |
65 | 65 |
66 void executeCalculateDrawTransformsAndVisibility(LayerImpl* rootLayer, float dev iceScaleFactor = 1, float pageScaleFactor = 1) | 66 void executeCalculateDrawTransformsAndVisibility(LayerImpl* rootLayer, float dev iceScaleFactor = 1, float pageScaleFactor = 1, bool canUseLCDText = false) |
67 { | 67 { |
68 // Note: this version skips layer sorting. | 68 // Note: this version skips layer sorting. |
69 | 69 |
70 WebTransformationMatrix identityMatrix; | 70 WebTransformationMatrix identityMatrix; |
71 std::vector<LayerImpl*> dummyRenderSurfaceLayerList; | 71 std::vector<LayerImpl*> dummyRenderSurfaceLayerList; |
72 int dummyMaxTextureSize = 512; | 72 int dummyMaxTextureSize = 512; |
73 gfx::Size deviceViewportSize = gfx::Size(rootLayer->bounds().width() * devic eScaleFactor, rootLayer->bounds().height() * deviceScaleFactor); | 73 gfx::Size deviceViewportSize = gfx::Size(rootLayer->bounds().width() * devic eScaleFactor, rootLayer->bounds().height() * deviceScaleFactor); |
74 | 74 |
75 // We are probably not testing what is intended if the rootLayer bounds are empty. | 75 // We are probably not testing what is intended if the rootLayer bounds are empty. |
76 DCHECK(!rootLayer->bounds().IsEmpty()); | 76 DCHECK(!rootLayer->bounds().IsEmpty()); |
77 LayerTreeHostCommon::calculateDrawTransforms(rootLayer, deviceViewportSize, deviceScaleFactor, pageScaleFactor, 0, dummyMaxTextureSize, dummyRenderSurfaceLa yerList); | 77 LayerTreeHostCommon::calculateDrawTransforms(rootLayer, deviceViewportSize, deviceScaleFactor, pageScaleFactor, 0, dummyMaxTextureSize, canUseLCDText, dummy RenderSurfaceLayerList); |
78 } | 78 } |
79 | 79 |
80 WebTransformationMatrix remove3DComponentOfMatrix(const WebTransformationMatrix& mat) | 80 WebTransformationMatrix remove3DComponentOfMatrix(const WebTransformationMatrix& mat) |
81 { | 81 { |
82 WebTransformationMatrix ret = mat; | 82 WebTransformationMatrix ret = mat; |
83 ret.setM13(0); | 83 ret.setM13(0); |
84 ret.setM23(0); | 84 ret.setM23(0); |
85 ret.setM31(0); | 85 ret.setM31(0); |
86 ret.setM32(0); | 86 ret.setM32(0); |
87 ret.setM33(1); | 87 ret.setM33(1); |
(...skipping 618 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
706 setLayerPropertiesForTesting(renderSurface1.get(), identityMatrix, identityM atrix, gfx::PointF(), gfx::PointF(), gfx::Size(10, 10), false); | 706 setLayerPropertiesForTesting(renderSurface1.get(), identityMatrix, identityM atrix, gfx::PointF(), gfx::PointF(), gfx::Size(10, 10), false); |
707 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, gf x::PointF(), gfx::PointF(30, 30), gfx::Size(10, 10), false); | 707 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, gf x::PointF(), gfx::PointF(30, 30), gfx::Size(10, 10), false); |
708 | 708 |
709 parent->addChild(renderSurface1); | 709 parent->addChild(renderSurface1); |
710 parent->setMasksToBounds(true); | 710 parent->setMasksToBounds(true); |
711 renderSurface1->addChild(child); | 711 renderSurface1->addChild(child); |
712 renderSurface1->setForceRenderSurface(true); | 712 renderSurface1->setForceRenderSurface(true); |
713 | 713 |
714 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; | 714 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; |
715 int dummyMaxTextureSize = 512; | 715 int dummyMaxTextureSize = 512; |
716 LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(), 1, 1, dummyMaxTextureSize, renderSurfaceLayerList); | 716 LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(), 1, 1, dummyMaxTextureSize, false, renderSurfaceLayerList); |
717 | 717 |
718 // The child layer's content is entirely outside the parent's clip rect, so the intermediate | 718 // The child layer's content is entirely outside the parent's clip rect, so the intermediate |
719 // render surface should not be listed here, even if it was forced to be cre ated. Render surfaces without children or visible | 719 // render surface should not be listed here, even if it was forced to be cre ated. Render surfaces without children or visible |
720 // content are unexpected at draw time (e.g. we might try to create a conten t texture of size 0). | 720 // content are unexpected at draw time (e.g. we might try to create a conten t texture of size 0). |
721 ASSERT_TRUE(parent->renderSurface()); | 721 ASSERT_TRUE(parent->renderSurface()); |
722 ASSERT_FALSE(renderSurface1->renderSurface()); | 722 ASSERT_FALSE(renderSurface1->renderSurface()); |
723 EXPECT_EQ(1U, renderSurfaceLayerList.size()); | 723 EXPECT_EQ(1U, renderSurfaceLayerList.size()); |
724 } | 724 } |
725 | 725 |
726 TEST(LayerTreeHostCommonTest, verifyRenderSurfaceListForTransparentChild) | 726 TEST(LayerTreeHostCommonTest, verifyRenderSurfaceListForTransparentChild) |
727 { | 727 { |
728 scoped_refptr<Layer> parent = Layer::create(); | 728 scoped_refptr<Layer> parent = Layer::create(); |
729 scoped_refptr<Layer> renderSurface1 = Layer::create(); | 729 scoped_refptr<Layer> renderSurface1 = Layer::create(); |
730 scoped_refptr<LayerWithForcedDrawsContent> child = make_scoped_refptr(new La yerWithForcedDrawsContent()); | 730 scoped_refptr<LayerWithForcedDrawsContent> child = make_scoped_refptr(new La yerWithForcedDrawsContent()); |
731 | 731 |
732 const WebTransformationMatrix identityMatrix; | 732 const WebTransformationMatrix identityMatrix; |
733 setLayerPropertiesForTesting(renderSurface1.get(), identityMatrix, identityM atrix, gfx::PointF(), gfx::PointF(), gfx::Size(10, 10), false); | 733 setLayerPropertiesForTesting(renderSurface1.get(), identityMatrix, identityM atrix, gfx::PointF(), gfx::PointF(), gfx::Size(10, 10), false); |
734 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, gf x::PointF(), gfx::PointF(), gfx::Size(10, 10), false); | 734 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, gf x::PointF(), gfx::PointF(), gfx::Size(10, 10), false); |
735 | 735 |
736 parent->addChild(renderSurface1); | 736 parent->addChild(renderSurface1); |
737 renderSurface1->addChild(child); | 737 renderSurface1->addChild(child); |
738 renderSurface1->setForceRenderSurface(true); | 738 renderSurface1->setForceRenderSurface(true); |
739 renderSurface1->setOpacity(0); | 739 renderSurface1->setOpacity(0); |
740 | 740 |
741 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; | 741 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; |
742 int dummyMaxTextureSize = 512; | 742 int dummyMaxTextureSize = 512; |
743 LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(), 1, 1, dummyMaxTextureSize, renderSurfaceLayerList); | 743 LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(), 1, 1, dummyMaxTextureSize, false, renderSurfaceLayerList); |
744 | 744 |
745 // Since the layer is transparent, renderSurface1->renderSurface() should no t have gotten added anywhere. | 745 // Since the layer is transparent, renderSurface1->renderSurface() should no t have gotten added anywhere. |
746 // Also, the drawable content rect should not have been extended by the chil dren. | 746 // Also, the drawable content rect should not have been extended by the chil dren. |
747 ASSERT_TRUE(parent->renderSurface()); | 747 ASSERT_TRUE(parent->renderSurface()); |
748 EXPECT_EQ(0U, parent->renderSurface()->layerList().size()); | 748 EXPECT_EQ(0U, parent->renderSurface()->layerList().size()); |
749 EXPECT_EQ(1U, renderSurfaceLayerList.size()); | 749 EXPECT_EQ(1U, renderSurfaceLayerList.size()); |
750 EXPECT_EQ(parent->id(), renderSurfaceLayerList[0]->id()); | 750 EXPECT_EQ(parent->id(), renderSurfaceLayerList[0]->id()); |
751 EXPECT_EQ(gfx::Rect(), parent->drawableContentRect()); | 751 EXPECT_EQ(gfx::Rect(), parent->drawableContentRect()); |
752 } | 752 } |
753 | 753 |
(...skipping 11 matching lines...) Expand all Loading... | |
765 | 765 |
766 parent->addChild(renderSurface1); | 766 parent->addChild(renderSurface1); |
767 renderSurface1->addChild(child); | 767 renderSurface1->addChild(child); |
768 | 768 |
769 // Sanity check before the actual test | 769 // Sanity check before the actual test |
770 EXPECT_FALSE(parent->renderSurface()); | 770 EXPECT_FALSE(parent->renderSurface()); |
771 EXPECT_FALSE(renderSurface1->renderSurface()); | 771 EXPECT_FALSE(renderSurface1->renderSurface()); |
772 | 772 |
773 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; | 773 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; |
774 int dummyMaxTextureSize = 512; | 774 int dummyMaxTextureSize = 512; |
775 LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(), 1, 1, dummyMaxTextureSize, renderSurfaceLayerList); | 775 LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(), 1, 1, dummyMaxTextureSize, false, renderSurfaceLayerList); |
776 | 776 |
777 // The root layer always creates a renderSurface | 777 // The root layer always creates a renderSurface |
778 EXPECT_TRUE(parent->renderSurface()); | 778 EXPECT_TRUE(parent->renderSurface()); |
779 EXPECT_TRUE(renderSurface1->renderSurface()); | 779 EXPECT_TRUE(renderSurface1->renderSurface()); |
780 EXPECT_EQ(2U, renderSurfaceLayerList.size()); | 780 EXPECT_EQ(2U, renderSurfaceLayerList.size()); |
781 | 781 |
782 renderSurfaceLayerList.clear(); | 782 renderSurfaceLayerList.clear(); |
783 renderSurface1->setForceRenderSurface(false); | 783 renderSurface1->setForceRenderSurface(false); |
784 LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(), 1, 1, dummyMaxTextureSize, renderSurfaceLayerList); | 784 LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(), 1, 1, dummyMaxTextureSize, false, renderSurfaceLayerList); |
785 EXPECT_TRUE(parent->renderSurface()); | 785 EXPECT_TRUE(parent->renderSurface()); |
786 EXPECT_FALSE(renderSurface1->renderSurface()); | 786 EXPECT_FALSE(renderSurface1->renderSurface()); |
787 EXPECT_EQ(1U, renderSurfaceLayerList.size()); | 787 EXPECT_EQ(1U, renderSurfaceLayerList.size()); |
788 } | 788 } |
789 | 789 |
790 TEST(LayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerWithD irectContainer) | 790 TEST(LayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerWithD irectContainer) |
791 { | 791 { |
792 // This test checks for correct scroll compensation when the fixed-position container | 792 // This test checks for correct scroll compensation when the fixed-position container |
793 // is the direct parent of the fixed-position layer. | 793 // is the direct parent of the fixed-position layer. |
794 scoped_ptr<LayerImpl> root = createTreeForFixedPositionTests(); | 794 scoped_ptr<LayerImpl> root = createTreeForFixedPositionTests(); |
(...skipping 573 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1368 setLayerPropertiesForTesting(leafNode1.get(), identityMatrix, identityMatrix , gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(500, 500), false); | 1368 setLayerPropertiesForTesting(leafNode1.get(), identityMatrix, identityMatrix , gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(500, 500), false); |
1369 setLayerPropertiesForTesting(leafNode2.get(), identityMatrix, identityMatrix , gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(20, 20), false); | 1369 setLayerPropertiesForTesting(leafNode2.get(), identityMatrix, identityMatrix , gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(20, 20), false); |
1370 | 1370 |
1371 child->setMasksToBounds(true); | 1371 child->setMasksToBounds(true); |
1372 child->setOpacity(0.4f); | 1372 child->setOpacity(0.4f); |
1373 grandChild->setOpacity(0.5); | 1373 grandChild->setOpacity(0.5); |
1374 greatGrandChild->setOpacity(0.4f); | 1374 greatGrandChild->setOpacity(0.4f); |
1375 | 1375 |
1376 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; | 1376 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; |
1377 int dummyMaxTextureSize = 512; | 1377 int dummyMaxTextureSize = 512; |
1378 LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(), 1, 1, dummyMaxTextureSize, renderSurfaceLayerList); | 1378 LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(), 1, 1, dummyMaxTextureSize, false, renderSurfaceLayerList); |
1379 | 1379 |
1380 ASSERT_EQ(2U, renderSurfaceLayerList.size()); | 1380 ASSERT_EQ(2U, renderSurfaceLayerList.size()); |
1381 EXPECT_EQ(parent->id(), renderSurfaceLayerList[0]->id()); | 1381 EXPECT_EQ(parent->id(), renderSurfaceLayerList[0]->id()); |
1382 EXPECT_EQ(child->id(), renderSurfaceLayerList[1]->id()); | 1382 EXPECT_EQ(child->id(), renderSurfaceLayerList[1]->id()); |
1383 } | 1383 } |
1384 | 1384 |
1385 TEST(LayerTreeHostCommonTest, verifyClipRectCullsSurfaceWithoutVisibleContent) | 1385 TEST(LayerTreeHostCommonTest, verifyClipRectCullsSurfaceWithoutVisibleContent) |
1386 { | 1386 { |
1387 // When a renderSurface has a clipRect, it is used to clip the contentRect | 1387 // When a renderSurface has a clipRect, it is used to clip the contentRect |
1388 // of the surface. When the renderSurface is animating its transforms, then | 1388 // of the surface. When the renderSurface is animating its transforms, then |
(...skipping 24 matching lines...) Expand all Loading... | |
1413 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, gf x::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(20, 20), false); | 1413 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, gf x::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(20, 20), false); |
1414 setLayerPropertiesForTesting(grandChild.get(), identityMatrix, identityMatri x, gfx::PointF(0, 0), gfx::PointF(200, 200), gfx::Size(10, 10), false); | 1414 setLayerPropertiesForTesting(grandChild.get(), identityMatrix, identityMatri x, gfx::PointF(0, 0), gfx::PointF(200, 200), gfx::Size(10, 10), false); |
1415 setLayerPropertiesForTesting(leafNode.get(), identityMatrix, identityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(10, 10), false); | 1415 setLayerPropertiesForTesting(leafNode.get(), identityMatrix, identityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(10, 10), false); |
1416 | 1416 |
1417 parent->setMasksToBounds(true); | 1417 parent->setMasksToBounds(true); |
1418 child->setOpacity(0.4f); | 1418 child->setOpacity(0.4f); |
1419 grandChild->setOpacity(0.4f); | 1419 grandChild->setOpacity(0.4f); |
1420 | 1420 |
1421 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; | 1421 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; |
1422 int dummyMaxTextureSize = 512; | 1422 int dummyMaxTextureSize = 512; |
1423 LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(), 1, 1, dummyMaxTextureSize, renderSurfaceLayerList); | 1423 LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(), 1, 1, dummyMaxTextureSize, false, renderSurfaceLayerList); |
1424 | 1424 |
1425 // Without an animation, we should cull child and grandChild from the render SurfaceLayerList. | 1425 // Without an animation, we should cull child and grandChild from the render SurfaceLayerList. |
1426 ASSERT_EQ(1U, renderSurfaceLayerList.size()); | 1426 ASSERT_EQ(1U, renderSurfaceLayerList.size()); |
1427 EXPECT_EQ(parent->id(), renderSurfaceLayerList[0]->id()); | 1427 EXPECT_EQ(parent->id(), renderSurfaceLayerList[0]->id()); |
1428 | 1428 |
1429 // Now put an animating transform on child. | 1429 // Now put an animating transform on child. |
1430 addAnimatedTransformToController(*child->layerAnimationController(), 10, 30, 0); | 1430 addAnimatedTransformToController(*child->layerAnimationController(), 10, 30, 0); |
1431 | 1431 |
1432 parent->clearRenderSurface(); | 1432 parent->clearRenderSurface(); |
1433 child->clearRenderSurface(); | 1433 child->clearRenderSurface(); |
1434 grandChild->clearRenderSurface(); | 1434 grandChild->clearRenderSurface(); |
1435 renderSurfaceLayerList.clear(); | 1435 renderSurfaceLayerList.clear(); |
1436 | 1436 |
1437 LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(), 1, 1, dummyMaxTextureSize, renderSurfaceLayerList); | 1437 LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(), 1, 1, dummyMaxTextureSize, false, renderSurfaceLayerList); |
1438 | 1438 |
1439 // With an animating transform, we should keep child and grandChild in the r enderSurfaceLayerList. | 1439 // With an animating transform, we should keep child and grandChild in the r enderSurfaceLayerList. |
1440 ASSERT_EQ(3U, renderSurfaceLayerList.size()); | 1440 ASSERT_EQ(3U, renderSurfaceLayerList.size()); |
1441 EXPECT_EQ(parent->id(), renderSurfaceLayerList[0]->id()); | 1441 EXPECT_EQ(parent->id(), renderSurfaceLayerList[0]->id()); |
1442 EXPECT_EQ(child->id(), renderSurfaceLayerList[1]->id()); | 1442 EXPECT_EQ(child->id(), renderSurfaceLayerList[1]->id()); |
1443 EXPECT_EQ(grandChild->id(), renderSurfaceLayerList[2]->id()); | 1443 EXPECT_EQ(grandChild->id(), renderSurfaceLayerList[2]->id()); |
1444 } | 1444 } |
1445 | 1445 |
1446 TEST(LayerTreeHostCommonTest, verifyDrawableContentRectForLayers) | 1446 TEST(LayerTreeHostCommonTest, verifyDrawableContentRectForLayers) |
1447 { | 1447 { |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1479 | 1479 |
1480 // Force everyone to be a render surface. | 1480 // Force everyone to be a render surface. |
1481 child->setOpacity(0.4f); | 1481 child->setOpacity(0.4f); |
1482 grandChild1->setOpacity(0.5); | 1482 grandChild1->setOpacity(0.5); |
1483 grandChild2->setOpacity(0.5); | 1483 grandChild2->setOpacity(0.5); |
1484 grandChild3->setOpacity(0.5); | 1484 grandChild3->setOpacity(0.5); |
1485 grandChild4->setOpacity(0.5); | 1485 grandChild4->setOpacity(0.5); |
1486 | 1486 |
1487 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; | 1487 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; |
1488 int dummyMaxTextureSize = 512; | 1488 int dummyMaxTextureSize = 512; |
1489 LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(), 1, 1, dummyMaxTextureSize, renderSurfaceLayerList); | 1489 LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(), 1, 1, dummyMaxTextureSize, false, renderSurfaceLayerList); |
1490 | 1490 |
1491 EXPECT_RECT_EQ(gfx::Rect(gfx::Point(5, 5), gfx::Size(10, 10)), grandChild1-> drawableContentRect()); | 1491 EXPECT_RECT_EQ(gfx::Rect(gfx::Point(5, 5), gfx::Size(10, 10)), grandChild1-> drawableContentRect()); |
1492 EXPECT_RECT_EQ(gfx::Rect(gfx::Point(15, 15), gfx::Size(5, 5)), grandChild3-> drawableContentRect()); | 1492 EXPECT_RECT_EQ(gfx::Rect(gfx::Point(15, 15), gfx::Size(5, 5)), grandChild3-> drawableContentRect()); |
1493 EXPECT_RECT_EQ(gfx::Rect(gfx::Point(15, 15), gfx::Size(5, 5)), grandChild3-> drawableContentRect()); | 1493 EXPECT_RECT_EQ(gfx::Rect(gfx::Point(15, 15), gfx::Size(5, 5)), grandChild3-> drawableContentRect()); |
1494 EXPECT_TRUE(grandChild4->drawableContentRect().IsEmpty()); | 1494 EXPECT_TRUE(grandChild4->drawableContentRect().IsEmpty()); |
1495 } | 1495 } |
1496 | 1496 |
1497 TEST(LayerTreeHostCommonTest, verifyClipRectIsPropagatedCorrectlyToSurfaces) | 1497 TEST(LayerTreeHostCommonTest, verifyClipRectIsPropagatedCorrectlyToSurfaces) |
1498 { | 1498 { |
1499 // Verify that renderSurfaces (and their layers) get the appropriate clipRec ts when their parent masksToBounds is true. | 1499 // 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 Loading... | |
1544 | 1544 |
1545 // Force everyone to be a render surface. | 1545 // Force everyone to be a render surface. |
1546 child->setOpacity(0.4f); | 1546 child->setOpacity(0.4f); |
1547 grandChild1->setOpacity(0.5); | 1547 grandChild1->setOpacity(0.5); |
1548 grandChild2->setOpacity(0.5); | 1548 grandChild2->setOpacity(0.5); |
1549 grandChild3->setOpacity(0.5); | 1549 grandChild3->setOpacity(0.5); |
1550 grandChild4->setOpacity(0.5); | 1550 grandChild4->setOpacity(0.5); |
1551 | 1551 |
1552 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; | 1552 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; |
1553 int dummyMaxTextureSize = 512; | 1553 int dummyMaxTextureSize = 512; |
1554 LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(), 1, 1, dummyMaxTextureSize, renderSurfaceLayerList); | 1554 LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(), 1, 1, dummyMaxTextureSize, false, renderSurfaceLayerList); |
1555 | 1555 |
1556 ASSERT_TRUE(grandChild1->renderSurface()); | 1556 ASSERT_TRUE(grandChild1->renderSurface()); |
1557 ASSERT_TRUE(grandChild2->renderSurface()); | 1557 ASSERT_TRUE(grandChild2->renderSurface()); |
1558 ASSERT_TRUE(grandChild3->renderSurface()); | 1558 ASSERT_TRUE(grandChild3->renderSurface()); |
1559 EXPECT_FALSE(grandChild4->renderSurface()); // Because grandChild4 is entire ly clipped, it is expected to not have a renderSurface. | 1559 EXPECT_FALSE(grandChild4->renderSurface()); // Because grandChild4 is entire ly clipped, it is expected to not have a renderSurface. |
1560 | 1560 |
1561 // Surfaces are clipped by their parent, but un-affected by the owning layer 's masksToBounds. | 1561 // Surfaces are clipped by their parent, but un-affected by the owning layer 's masksToBounds. |
1562 EXPECT_RECT_EQ(gfx::Rect(gfx::Point(0, 0), gfx::Size(20, 20)), grandChild1-> renderSurface()->clipRect()); | 1562 EXPECT_RECT_EQ(gfx::Rect(gfx::Point(0, 0), gfx::Size(20, 20)), grandChild1-> renderSurface()->clipRect()); |
1563 EXPECT_RECT_EQ(gfx::Rect(gfx::Point(0, 0), gfx::Size(20, 20)), grandChild2-> renderSurface()->clipRect()); | 1563 EXPECT_RECT_EQ(gfx::Rect(gfx::Point(0, 0), gfx::Size(20, 20)), grandChild2-> renderSurface()->clipRect()); |
1564 EXPECT_RECT_EQ(gfx::Rect(gfx::Point(0, 0), gfx::Size(20, 20)), grandChild3-> renderSurface()->clipRect()); | 1564 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 Loading... | |
2386 setLayerPropertiesForTesting(backFacingChild.get(), backfaceMatrix, identity Matrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); | 2386 setLayerPropertiesForTesting(backFacingChild.get(), backfaceMatrix, identity Matrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); |
2387 setLayerPropertiesForTesting(frontFacingSurface.get(), identityMatrix, ident ityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); | 2387 setLayerPropertiesForTesting(frontFacingSurface.get(), identityMatrix, ident ityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); |
2388 setLayerPropertiesForTesting(backFacingSurface.get(), backfaceMatrix, identi tyMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); | 2388 setLayerPropertiesForTesting(backFacingSurface.get(), backfaceMatrix, identi tyMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); |
2389 setLayerPropertiesForTesting(frontFacingChildOfFrontFacingSurface.get(), ide ntityMatrix, identityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100 , 100), false); | 2389 setLayerPropertiesForTesting(frontFacingChildOfFrontFacingSurface.get(), ide ntityMatrix, identityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100 , 100), false); |
2390 setLayerPropertiesForTesting(backFacingChildOfFrontFacingSurface.get(), back faceMatrix, identityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); | 2390 setLayerPropertiesForTesting(backFacingChildOfFrontFacingSurface.get(), back faceMatrix, identityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); |
2391 setLayerPropertiesForTesting(frontFacingChildOfBackFacingSurface.get(), iden tityMatrix, identityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); | 2391 setLayerPropertiesForTesting(frontFacingChildOfBackFacingSurface.get(), iden tityMatrix, identityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); |
2392 setLayerPropertiesForTesting(backFacingChildOfBackFacingSurface.get(), backf aceMatrix, identityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); | 2392 setLayerPropertiesForTesting(backFacingChildOfBackFacingSurface.get(), backf aceMatrix, identityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); |
2393 | 2393 |
2394 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; | 2394 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; |
2395 int dummyMaxTextureSize = 512; | 2395 int dummyMaxTextureSize = 512; |
2396 LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(), 1, 1, dummyMaxTextureSize, renderSurfaceLayerList); | 2396 LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(), 1, 1, dummyMaxTextureSize, false, renderSurfaceLayerList); |
2397 | 2397 |
2398 // Verify which renderSurfaces were created. | 2398 // Verify which renderSurfaces were created. |
2399 EXPECT_FALSE(frontFacingChild->renderSurface()); | 2399 EXPECT_FALSE(frontFacingChild->renderSurface()); |
2400 EXPECT_FALSE(backFacingChild->renderSurface()); | 2400 EXPECT_FALSE(backFacingChild->renderSurface()); |
2401 EXPECT_TRUE(frontFacingSurface->renderSurface()); | 2401 EXPECT_TRUE(frontFacingSurface->renderSurface()); |
2402 EXPECT_TRUE(backFacingSurface->renderSurface()); | 2402 EXPECT_TRUE(backFacingSurface->renderSurface()); |
2403 EXPECT_FALSE(frontFacingChildOfFrontFacingSurface->renderSurface()); | 2403 EXPECT_FALSE(frontFacingChildOfFrontFacingSurface->renderSurface()); |
2404 EXPECT_FALSE(backFacingChildOfFrontFacingSurface->renderSurface()); | 2404 EXPECT_FALSE(backFacingChildOfFrontFacingSurface->renderSurface()); |
2405 EXPECT_FALSE(frontFacingChildOfBackFacingSurface->renderSurface()); | 2405 EXPECT_FALSE(frontFacingChildOfBackFacingSurface->renderSurface()); |
2406 EXPECT_FALSE(backFacingChildOfBackFacingSurface->renderSurface()); | 2406 EXPECT_FALSE(backFacingChildOfBackFacingSurface->renderSurface()); |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2485 setLayerPropertiesForTesting(backFacingChild.get(), backfaceMatrix, identity Matrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); | 2485 setLayerPropertiesForTesting(backFacingChild.get(), backfaceMatrix, identity Matrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); |
2486 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. | 2486 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. |
2487 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. | 2487 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. |
2488 setLayerPropertiesForTesting(frontFacingChildOfFrontFacingSurface.get(), ide ntityMatrix, identityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100 , 100), false); | 2488 setLayerPropertiesForTesting(frontFacingChildOfFrontFacingSurface.get(), ide ntityMatrix, identityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100 , 100), false); |
2489 setLayerPropertiesForTesting(backFacingChildOfFrontFacingSurface.get(), back faceMatrix, identityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); | 2489 setLayerPropertiesForTesting(backFacingChildOfFrontFacingSurface.get(), back faceMatrix, identityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); |
2490 setLayerPropertiesForTesting(frontFacingChildOfBackFacingSurface.get(), iden tityMatrix, identityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); | 2490 setLayerPropertiesForTesting(frontFacingChildOfBackFacingSurface.get(), iden tityMatrix, identityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); |
2491 setLayerPropertiesForTesting(backFacingChildOfBackFacingSurface.get(), backf aceMatrix, identityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); | 2491 setLayerPropertiesForTesting(backFacingChildOfBackFacingSurface.get(), backf aceMatrix, identityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); |
2492 | 2492 |
2493 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; | 2493 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; |
2494 int dummyMaxTextureSize = 512; | 2494 int dummyMaxTextureSize = 512; |
2495 LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(), 1, 1, dummyMaxTextureSize, renderSurfaceLayerList); | 2495 LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(), 1, 1, dummyMaxTextureSize, false, renderSurfaceLayerList); |
2496 | 2496 |
2497 // Verify which renderSurfaces were created. | 2497 // Verify which renderSurfaces were created. |
2498 EXPECT_FALSE(frontFacingChild->renderSurface()); | 2498 EXPECT_FALSE(frontFacingChild->renderSurface()); |
2499 EXPECT_FALSE(backFacingChild->renderSurface()); | 2499 EXPECT_FALSE(backFacingChild->renderSurface()); |
2500 EXPECT_TRUE(frontFacingSurface->renderSurface()); | 2500 EXPECT_TRUE(frontFacingSurface->renderSurface()); |
2501 EXPECT_FALSE(backFacingSurface->renderSurface()); | 2501 EXPECT_FALSE(backFacingSurface->renderSurface()); |
2502 EXPECT_FALSE(frontFacingChildOfFrontFacingSurface->renderSurface()); | 2502 EXPECT_FALSE(frontFacingChildOfFrontFacingSurface->renderSurface()); |
2503 EXPECT_FALSE(backFacingChildOfFrontFacingSurface->renderSurface()); | 2503 EXPECT_FALSE(backFacingChildOfFrontFacingSurface->renderSurface()); |
2504 EXPECT_FALSE(frontFacingChildOfBackFacingSurface->renderSurface()); | 2504 EXPECT_FALSE(frontFacingChildOfBackFacingSurface->renderSurface()); |
2505 EXPECT_FALSE(backFacingChildOfBackFacingSurface->renderSurface()); | 2505 EXPECT_FALSE(backFacingChildOfBackFacingSurface->renderSurface()); |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2565 | 2565 |
2566 setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, g fx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); | 2566 setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, g fx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); |
2567 setLayerPropertiesForTesting(child.get(), backfaceMatrix, identityMatrix, gf x::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); | 2567 setLayerPropertiesForTesting(child.get(), backfaceMatrix, identityMatrix, gf x::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); |
2568 setLayerPropertiesForTesting(animatingSurface.get(), backfaceMatrix, identit yMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); | 2568 setLayerPropertiesForTesting(animatingSurface.get(), backfaceMatrix, identit yMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); |
2569 setLayerPropertiesForTesting(childOfAnimatingSurface.get(), backfaceMatrix, identityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false ); | 2569 setLayerPropertiesForTesting(childOfAnimatingSurface.get(), backfaceMatrix, identityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false ); |
2570 setLayerPropertiesForTesting(animatingChild.get(), backfaceMatrix, identityM atrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); | 2570 setLayerPropertiesForTesting(animatingChild.get(), backfaceMatrix, identityM atrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); |
2571 setLayerPropertiesForTesting(child2.get(), identityMatrix, identityMatrix, g fx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); | 2571 setLayerPropertiesForTesting(child2.get(), identityMatrix, identityMatrix, g fx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); |
2572 | 2572 |
2573 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; | 2573 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; |
2574 int dummyMaxTextureSize = 512; | 2574 int dummyMaxTextureSize = 512; |
2575 LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(), 1, 1, dummyMaxTextureSize, renderSurfaceLayerList); | 2575 LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(), 1, 1, dummyMaxTextureSize, false, renderSurfaceLayerList); |
2576 | 2576 |
2577 EXPECT_FALSE(child->renderSurface()); | 2577 EXPECT_FALSE(child->renderSurface()); |
2578 EXPECT_TRUE(animatingSurface->renderSurface()); | 2578 EXPECT_TRUE(animatingSurface->renderSurface()); |
2579 EXPECT_FALSE(childOfAnimatingSurface->renderSurface()); | 2579 EXPECT_FALSE(childOfAnimatingSurface->renderSurface()); |
2580 EXPECT_FALSE(animatingChild->renderSurface()); | 2580 EXPECT_FALSE(animatingChild->renderSurface()); |
2581 EXPECT_FALSE(child2->renderSurface()); | 2581 EXPECT_FALSE(child2->renderSurface()); |
2582 | 2582 |
2583 // Verify that the animatingChild and childOfAnimatingSurface were not culle d, but that child was. | 2583 // Verify that the animatingChild and childOfAnimatingSurface were not culle d, but that child was. |
2584 ASSERT_EQ(2u, renderSurfaceLayerList.size()); | 2584 ASSERT_EQ(2u, renderSurfaceLayerList.size()); |
2585 EXPECT_EQ(parent->id(), renderSurfaceLayerList[0]->id()); | 2585 EXPECT_EQ(parent->id(), renderSurfaceLayerList[0]->id()); |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2631 backfaceMatrix.translate(-50, -50); | 2631 backfaceMatrix.translate(-50, -50); |
2632 | 2632 |
2633 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. | 2633 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. |
2634 setLayerPropertiesForTesting(frontFacingSurface.get(), identityMatrix, ident ityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); // surface transform style is flat. | 2634 setLayerPropertiesForTesting(frontFacingSurface.get(), identityMatrix, ident ityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); // surface transform style is flat. |
2635 setLayerPropertiesForTesting(backFacingSurface.get(), backfaceMatrix, ident ityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); // surface transform style is flat. | 2635 setLayerPropertiesForTesting(backFacingSurface.get(), backfaceMatrix, ident ityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); // surface transform style is flat. |
2636 setLayerPropertiesForTesting(child1.get(), identityMatrix, identityMatrix, g fx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); | 2636 setLayerPropertiesForTesting(child1.get(), identityMatrix, identityMatrix, g fx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); |
2637 setLayerPropertiesForTesting(child2.get(), identityMatrix, identityMatrix, g fx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); | 2637 setLayerPropertiesForTesting(child2.get(), identityMatrix, identityMatrix, g fx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); |
2638 | 2638 |
2639 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; | 2639 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; |
2640 int dummyMaxTextureSize = 512; | 2640 int dummyMaxTextureSize = 512; |
2641 LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(), 1, 1, dummyMaxTextureSize, renderSurfaceLayerList); | 2641 LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(), 1, 1, dummyMaxTextureSize, false, renderSurfaceLayerList); |
2642 | 2642 |
2643 // Verify which renderSurfaces were created. | 2643 // Verify which renderSurfaces were created. |
2644 EXPECT_TRUE(frontFacingSurface->renderSurface()); | 2644 EXPECT_TRUE(frontFacingSurface->renderSurface()); |
2645 EXPECT_FALSE(backFacingSurface->renderSurface()); // because it should be cu lled | 2645 EXPECT_FALSE(backFacingSurface->renderSurface()); // because it should be cu lled |
2646 EXPECT_FALSE(child1->renderSurface()); | 2646 EXPECT_FALSE(child1->renderSurface()); |
2647 EXPECT_FALSE(child2->renderSurface()); | 2647 EXPECT_FALSE(child2->renderSurface()); |
2648 | 2648 |
2649 // Verify the renderSurfaceLayerList. The back-facing surface should be cull ed. | 2649 // Verify the renderSurfaceLayerList. The back-facing surface should be cull ed. |
2650 ASSERT_EQ(2u, renderSurfaceLayerList.size()); | 2650 ASSERT_EQ(2u, renderSurfaceLayerList.size()); |
2651 EXPECT_EQ(parent->id(), renderSurfaceLayerList[0]->id()); | 2651 EXPECT_EQ(parent->id(), renderSurfaceLayerList[0]->id()); |
(...skipping 29 matching lines...) Expand all Loading... | |
2681 | 2681 |
2682 WebTransformationMatrix identityMatrix; | 2682 WebTransformationMatrix identityMatrix; |
2683 gfx::PointF anchor(0, 0); | 2683 gfx::PointF anchor(0, 0); |
2684 gfx::PointF position(0, 0); | 2684 gfx::PointF position(0, 0); |
2685 gfx::Size bounds(100, 100); | 2685 gfx::Size bounds(100, 100); |
2686 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc hor, position, bounds, false); | 2686 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc hor, position, bounds, false); |
2687 root->setDrawsContent(true); | 2687 root->setDrawsContent(true); |
2688 | 2688 |
2689 std::vector<LayerImpl*> renderSurfaceLayerList; | 2689 std::vector<LayerImpl*> renderSurfaceLayerList; |
2690 int dummyMaxTextureSize = 512; | 2690 int dummyMaxTextureSize = 512; |
2691 LayerTreeHostCommon::calculateDrawTransforms(root.get(), root->bounds(), 1, 1, 0, dummyMaxTextureSize, renderSurfaceLayerList); | 2691 LayerTreeHostCommon::calculateDrawTransforms(root.get(), root->bounds(), 1, 1, 0, dummyMaxTextureSize, false, renderSurfaceLayerList); |
2692 | 2692 |
2693 // Sanity check the scenario we just created. | 2693 // Sanity check the scenario we just created. |
2694 ASSERT_EQ(1u, renderSurfaceLayerList.size()); | 2694 ASSERT_EQ(1u, renderSurfaceLayerList.size()); |
2695 ASSERT_EQ(1u, root->renderSurface()->layerList().size()); | 2695 ASSERT_EQ(1u, root->renderSurface()->layerList().size()); |
2696 | 2696 |
2697 // Hit testing for a point outside the layer should return a null pointer. | 2697 // Hit testing for a point outside the layer should return a null pointer. |
2698 gfx::Point testPoint(101, 101); | 2698 gfx::Point testPoint(101, 101); |
2699 LayerImpl* resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(test Point, renderSurfaceLayerList); | 2699 LayerImpl* resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(test Point, renderSurfaceLayerList); |
2700 EXPECT_FALSE(resultLayer); | 2700 EXPECT_FALSE(resultLayer); |
2701 | 2701 |
(...skipping 26 matching lines...) Expand all Loading... | |
2728 | 2728 |
2729 WebTransformationMatrix identityMatrix; | 2729 WebTransformationMatrix identityMatrix; |
2730 gfx::PointF anchor(0, 0); | 2730 gfx::PointF anchor(0, 0); |
2731 gfx::PointF position(0, 0); | 2731 gfx::PointF position(0, 0); |
2732 gfx::Size bounds(100, 100); | 2732 gfx::Size bounds(100, 100); |
2733 setLayerPropertiesForTesting(root.get(), uninvertibleTransform, identityMatr ix, anchor, position, bounds, false); | 2733 setLayerPropertiesForTesting(root.get(), uninvertibleTransform, identityMatr ix, anchor, position, bounds, false); |
2734 root->setDrawsContent(true); | 2734 root->setDrawsContent(true); |
2735 | 2735 |
2736 std::vector<LayerImpl*> renderSurfaceLayerList; | 2736 std::vector<LayerImpl*> renderSurfaceLayerList; |
2737 int dummyMaxTextureSize = 512; | 2737 int dummyMaxTextureSize = 512; |
2738 LayerTreeHostCommon::calculateDrawTransforms(root.get(), root->bounds(), 1, 1, 0, dummyMaxTextureSize, renderSurfaceLayerList); | 2738 LayerTreeHostCommon::calculateDrawTransforms(root.get(), root->bounds(), 1, 1, 0, dummyMaxTextureSize, false, renderSurfaceLayerList); |
2739 | 2739 |
2740 // Sanity check the scenario we just created. | 2740 // Sanity check the scenario we just created. |
2741 ASSERT_EQ(1u, renderSurfaceLayerList.size()); | 2741 ASSERT_EQ(1u, renderSurfaceLayerList.size()); |
2742 ASSERT_EQ(1u, root->renderSurface()->layerList().size()); | 2742 ASSERT_EQ(1u, root->renderSurface()->layerList().size()); |
2743 ASSERT_FALSE(root->screenSpaceTransform().isInvertible()); | 2743 ASSERT_FALSE(root->screenSpaceTransform().isInvertible()); |
2744 | 2744 |
2745 // Hit testing any point should not hit the layer. If the invertible matrix is | 2745 // Hit testing any point should not hit the layer. If the invertible matrix is |
2746 // accidentally ignored and treated like an identity, then the hit testing w ill | 2746 // accidentally ignored and treated like an identity, then the hit testing w ill |
2747 // incorrectly hit the layer when it shouldn't. | 2747 // incorrectly hit the layer when it shouldn't. |
2748 gfx::Point testPoint(1, 1); | 2748 gfx::Point testPoint(1, 1); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2780 | 2780 |
2781 WebTransformationMatrix identityMatrix; | 2781 WebTransformationMatrix identityMatrix; |
2782 gfx::PointF anchor(0, 0); | 2782 gfx::PointF anchor(0, 0); |
2783 gfx::PointF position(50, 50); // this layer is positioned, and hit testing s hould correctly know where the layer is located. | 2783 gfx::PointF position(50, 50); // this layer is positioned, and hit testing s hould correctly know where the layer is located. |
2784 gfx::Size bounds(100, 100); | 2784 gfx::Size bounds(100, 100); |
2785 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc hor, position, bounds, false); | 2785 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc hor, position, bounds, false); |
2786 root->setDrawsContent(true); | 2786 root->setDrawsContent(true); |
2787 | 2787 |
2788 std::vector<LayerImpl*> renderSurfaceLayerList; | 2788 std::vector<LayerImpl*> renderSurfaceLayerList; |
2789 int dummyMaxTextureSize = 512; | 2789 int dummyMaxTextureSize = 512; |
2790 LayerTreeHostCommon::calculateDrawTransforms(root.get(), root->bounds(), 1, 1, 0, dummyMaxTextureSize, renderSurfaceLayerList); | 2790 LayerTreeHostCommon::calculateDrawTransforms(root.get(), root->bounds(), 1, 1, 0, dummyMaxTextureSize, false, renderSurfaceLayerList); |
2791 | 2791 |
2792 // Sanity check the scenario we just created. | 2792 // Sanity check the scenario we just created. |
2793 ASSERT_EQ(1u, renderSurfaceLayerList.size()); | 2793 ASSERT_EQ(1u, renderSurfaceLayerList.size()); |
2794 ASSERT_EQ(1u, root->renderSurface()->layerList().size()); | 2794 ASSERT_EQ(1u, root->renderSurface()->layerList().size()); |
2795 | 2795 |
2796 // Hit testing for a point outside the layer should return a null pointer. | 2796 // Hit testing for a point outside the layer should return a null pointer. |
2797 gfx::Point testPoint(49, 49); | 2797 gfx::Point testPoint(49, 49); |
2798 LayerImpl* resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(test Point, renderSurfaceLayerList); | 2798 LayerImpl* resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(test Point, renderSurfaceLayerList); |
2799 EXPECT_FALSE(resultLayer); | 2799 EXPECT_FALSE(resultLayer); |
2800 | 2800 |
(...skipping 24 matching lines...) Expand all Loading... | |
2825 rotation45DegreesAboutCenter.rotate3d(0, 0, 45); | 2825 rotation45DegreesAboutCenter.rotate3d(0, 0, 45); |
2826 rotation45DegreesAboutCenter.translate(-50, -50); | 2826 rotation45DegreesAboutCenter.translate(-50, -50); |
2827 gfx::PointF anchor(0, 0); | 2827 gfx::PointF anchor(0, 0); |
2828 gfx::PointF position(0, 0); | 2828 gfx::PointF position(0, 0); |
2829 gfx::Size bounds(100, 100); | 2829 gfx::Size bounds(100, 100); |
2830 setLayerPropertiesForTesting(root.get(), rotation45DegreesAboutCenter, ident ityMatrix, anchor, position, bounds, false); | 2830 setLayerPropertiesForTesting(root.get(), rotation45DegreesAboutCenter, ident ityMatrix, anchor, position, bounds, false); |
2831 root->setDrawsContent(true); | 2831 root->setDrawsContent(true); |
2832 | 2832 |
2833 std::vector<LayerImpl*> renderSurfaceLayerList; | 2833 std::vector<LayerImpl*> renderSurfaceLayerList; |
2834 int dummyMaxTextureSize = 512; | 2834 int dummyMaxTextureSize = 512; |
2835 LayerTreeHostCommon::calculateDrawTransforms(root.get(), root->bounds(), 1, 1, 0, dummyMaxTextureSize, renderSurfaceLayerList); | 2835 LayerTreeHostCommon::calculateDrawTransforms(root.get(), root->bounds(), 1, 1, 0, dummyMaxTextureSize, false, renderSurfaceLayerList); |
2836 | 2836 |
2837 // Sanity check the scenario we just created. | 2837 // Sanity check the scenario we just created. |
2838 ASSERT_EQ(1u, renderSurfaceLayerList.size()); | 2838 ASSERT_EQ(1u, renderSurfaceLayerList.size()); |
2839 ASSERT_EQ(1u, root->renderSurface()->layerList().size()); | 2839 ASSERT_EQ(1u, root->renderSurface()->layerList().size()); |
2840 | 2840 |
2841 // Hit testing for points outside the layer. | 2841 // Hit testing for points outside the layer. |
2842 // These corners would have been inside the un-transformed layer, but they s hould not hit the correctly transformed layer. | 2842 // These corners would have been inside the un-transformed layer, but they s hould not hit the correctly transformed layer. |
2843 gfx::Point testPoint(99, 99); | 2843 gfx::Point testPoint(99, 99); |
2844 LayerImpl* resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(test Point, renderSurfaceLayerList); | 2844 LayerImpl* resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(test Point, renderSurfaceLayerList); |
2845 EXPECT_FALSE(resultLayer); | 2845 EXPECT_FALSE(resultLayer); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2879 translationByZ.translate3d(0, 0, -1); | 2879 translationByZ.translate3d(0, 0, -1); |
2880 | 2880 |
2881 gfx::PointF anchor(0, 0); | 2881 gfx::PointF anchor(0, 0); |
2882 gfx::PointF position(0, 0); | 2882 gfx::PointF position(0, 0); |
2883 gfx::Size bounds(100, 100); | 2883 gfx::Size bounds(100, 100); |
2884 setLayerPropertiesForTesting(root.get(), perspectiveProjectionAboutCenter * translationByZ, identityMatrix, anchor, position, bounds, false); | 2884 setLayerPropertiesForTesting(root.get(), perspectiveProjectionAboutCenter * translationByZ, identityMatrix, anchor, position, bounds, false); |
2885 root->setDrawsContent(true); | 2885 root->setDrawsContent(true); |
2886 | 2886 |
2887 std::vector<LayerImpl*> renderSurfaceLayerList; | 2887 std::vector<LayerImpl*> renderSurfaceLayerList; |
2888 int dummyMaxTextureSize = 512; | 2888 int dummyMaxTextureSize = 512; |
2889 LayerTreeHostCommon::calculateDrawTransforms(root.get(), root->bounds(), 1, 1, 0, dummyMaxTextureSize, renderSurfaceLayerList); | 2889 LayerTreeHostCommon::calculateDrawTransforms(root.get(), root->bounds(), 1, 1, 0, dummyMaxTextureSize, false, renderSurfaceLayerList); |
2890 | 2890 |
2891 // Sanity check the scenario we just created. | 2891 // Sanity check the scenario we just created. |
2892 ASSERT_EQ(1u, renderSurfaceLayerList.size()); | 2892 ASSERT_EQ(1u, renderSurfaceLayerList.size()); |
2893 ASSERT_EQ(1u, root->renderSurface()->layerList().size()); | 2893 ASSERT_EQ(1u, root->renderSurface()->layerList().size()); |
2894 | 2894 |
2895 // Hit testing for points outside the layer. | 2895 // Hit testing for points outside the layer. |
2896 // These corners would have been inside the un-transformed layer, but they s hould not hit the correctly transformed layer. | 2896 // These corners would have been inside the un-transformed layer, but they s hould not hit the correctly transformed layer. |
2897 gfx::Point testPoint(24, 24); | 2897 gfx::Point testPoint(24, 24); |
2898 LayerImpl* resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(test Point, renderSurfaceLayerList); | 2898 LayerImpl* resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(test Point, renderSurfaceLayerList); |
2899 EXPECT_FALSE(resultLayer); | 2899 EXPECT_FALSE(resultLayer); |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2942 // override contentBounds and contentsScale | 2942 // override contentBounds and contentsScale |
2943 testLayer->setContentBounds(gfx::Size(100, 100)); | 2943 testLayer->setContentBounds(gfx::Size(100, 100)); |
2944 testLayer->setContentsScale(2, 2); | 2944 testLayer->setContentsScale(2, 2); |
2945 | 2945 |
2946 testLayer->setDrawsContent(true); | 2946 testLayer->setDrawsContent(true); |
2947 root->addChild(testLayer.Pass()); | 2947 root->addChild(testLayer.Pass()); |
2948 } | 2948 } |
2949 | 2949 |
2950 std::vector<LayerImpl*> renderSurfaceLayerList; | 2950 std::vector<LayerImpl*> renderSurfaceLayerList; |
2951 int dummyMaxTextureSize = 512; | 2951 int dummyMaxTextureSize = 512; |
2952 LayerTreeHostCommon::calculateDrawTransforms(root.get(), root->bounds(), 1, 1, 0, dummyMaxTextureSize, renderSurfaceLayerList); | 2952 LayerTreeHostCommon::calculateDrawTransforms(root.get(), root->bounds(), 1, 1, 0, dummyMaxTextureSize, false, renderSurfaceLayerList); |
2953 | 2953 |
2954 // Sanity check the scenario we just created. | 2954 // Sanity check the scenario we just created. |
2955 // The visibleContentRect for testLayer is actually 100x100, even though its layout size is 50x50, positioned at 25x25. | 2955 // The visibleContentRect for testLayer is actually 100x100, even though its layout size is 50x50, positioned at 25x25. |
2956 LayerImpl* testLayer = root->children()[0]; | 2956 LayerImpl* testLayer = root->children()[0]; |
2957 EXPECT_RECT_EQ(gfx::Rect(gfx::Point(), gfx::Size(100, 100)), testLayer->visi bleContentRect()); | 2957 EXPECT_RECT_EQ(gfx::Rect(gfx::Point(), gfx::Size(100, 100)), testLayer->visi bleContentRect()); |
2958 ASSERT_EQ(1u, renderSurfaceLayerList.size()); | 2958 ASSERT_EQ(1u, renderSurfaceLayerList.size()); |
2959 ASSERT_EQ(1u, root->renderSurface()->layerList().size()); | 2959 ASSERT_EQ(1u, root->renderSurface()->layerList().size()); |
2960 | 2960 |
2961 // 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). | 2961 // 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). |
2962 gfx::Point testPoint(101, 101); | 2962 gfx::Point testPoint(101, 101); |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3004 position = gfx::PointF(-50, -50); | 3004 position = gfx::PointF(-50, -50); |
3005 bounds = gfx::Size(300, 300); | 3005 bounds = gfx::Size(300, 300); |
3006 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix , anchor, position, bounds, false); | 3006 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix , anchor, position, bounds, false); |
3007 child->setDrawsContent(true); | 3007 child->setDrawsContent(true); |
3008 clippingLayer->addChild(child.Pass()); | 3008 clippingLayer->addChild(child.Pass()); |
3009 root->addChild(clippingLayer.Pass()); | 3009 root->addChild(clippingLayer.Pass()); |
3010 } | 3010 } |
3011 | 3011 |
3012 std::vector<LayerImpl*> renderSurfaceLayerList; | 3012 std::vector<LayerImpl*> renderSurfaceLayerList; |
3013 int dummyMaxTextureSize = 512; | 3013 int dummyMaxTextureSize = 512; |
3014 LayerTreeHostCommon::calculateDrawTransforms(root.get(), root->bounds(), 1, 1, 0, dummyMaxTextureSize, renderSurfaceLayerList); | 3014 LayerTreeHostCommon::calculateDrawTransforms(root.get(), root->bounds(), 1, 1, 0, dummyMaxTextureSize, false, renderSurfaceLayerList); |
3015 | 3015 |
3016 // Sanity check the scenario we just created. | 3016 // Sanity check the scenario we just created. |
3017 ASSERT_EQ(1u, renderSurfaceLayerList.size()); | 3017 ASSERT_EQ(1u, renderSurfaceLayerList.size()); |
3018 ASSERT_EQ(1u, root->renderSurface()->layerList().size()); | 3018 ASSERT_EQ(1u, root->renderSurface()->layerList().size()); |
3019 ASSERT_EQ(456, root->renderSurface()->layerList()[0]->id()); | 3019 ASSERT_EQ(456, root->renderSurface()->layerList()[0]->id()); |
3020 | 3020 |
3021 // Hit testing for a point outside the layer should return a null pointer. | 3021 // Hit testing for a point outside the layer should return a null pointer. |
3022 // Despite the child layer being very large, it should be clipped to the roo t layer's bounds. | 3022 // Despite the child layer being very large, it should be clipped to the roo t layer's bounds. |
3023 gfx::Point testPoint(24, 24); | 3023 gfx::Point testPoint(24, 24); |
3024 LayerImpl* resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(test Point, renderSurfaceLayerList); | 3024 LayerImpl* resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(test Point, renderSurfaceLayerList); |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3092 setLayerPropertiesForTesting(rotatedLeaf.get(), rotatedLeafTransform, id entityMatrix, anchor, position, bounds, false); | 3092 setLayerPropertiesForTesting(rotatedLeaf.get(), rotatedLeafTransform, id entityMatrix, anchor, position, bounds, false); |
3093 rotatedLeaf->setDrawsContent(true); | 3093 rotatedLeaf->setDrawsContent(true); |
3094 | 3094 |
3095 grandChild->addChild(rotatedLeaf.Pass()); | 3095 grandChild->addChild(rotatedLeaf.Pass()); |
3096 child->addChild(grandChild.Pass()); | 3096 child->addChild(grandChild.Pass()); |
3097 root->addChild(child.Pass()); | 3097 root->addChild(child.Pass()); |
3098 } | 3098 } |
3099 | 3099 |
3100 std::vector<LayerImpl*> renderSurfaceLayerList; | 3100 std::vector<LayerImpl*> renderSurfaceLayerList; |
3101 int dummyMaxTextureSize = 512; | 3101 int dummyMaxTextureSize = 512; |
3102 LayerTreeHostCommon::calculateDrawTransforms(root.get(), root->bounds(), 1, 1, 0, dummyMaxTextureSize, renderSurfaceLayerList); | 3102 LayerTreeHostCommon::calculateDrawTransforms(root.get(), root->bounds(), 1, 1, 0, dummyMaxTextureSize, false, renderSurfaceLayerList); |
3103 | 3103 |
3104 // Sanity check the scenario we just created. | 3104 // Sanity check the scenario we just created. |
3105 // The grandChild is expected to create a renderSurface because it masksToBo unds and is not axis aligned. | 3105 // The grandChild is expected to create a renderSurface because it masksToBo unds and is not axis aligned. |
3106 ASSERT_EQ(2u, renderSurfaceLayerList.size()); | 3106 ASSERT_EQ(2u, renderSurfaceLayerList.size()); |
3107 ASSERT_EQ(1u, renderSurfaceLayerList[0]->renderSurface()->layerList().size() ); | 3107 ASSERT_EQ(1u, renderSurfaceLayerList[0]->renderSurface()->layerList().size() ); |
3108 ASSERT_EQ(789, renderSurfaceLayerList[0]->renderSurface()->layerList()[0]->i d()); // grandChild's surface. | 3108 ASSERT_EQ(789, renderSurfaceLayerList[0]->renderSurface()->layerList()[0]->i d()); // grandChild's surface. |
3109 ASSERT_EQ(1u, renderSurfaceLayerList[1]->renderSurface()->layerList().size() ); | 3109 ASSERT_EQ(1u, renderSurfaceLayerList[1]->renderSurface()->layerList().size() ); |
3110 ASSERT_EQ(2468, renderSurfaceLayerList[1]->renderSurface()->layerList()[0]-> id()); | 3110 ASSERT_EQ(2468, renderSurfaceLayerList[1]->renderSurface()->layerList()[0]-> id()); |
3111 | 3111 |
3112 // (11, 89) is close to the the bottom left corner within the clip, but it i s not inside the layer. | 3112 // (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 Loading... | |
3172 position = gfx::PointF(60, 60); // 70, 70 in screen space | 3172 position = gfx::PointF(60, 60); // 70, 70 in screen space |
3173 bounds = gfx::Size(20, 20); | 3173 bounds = gfx::Size(20, 20); |
3174 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix , anchor, position, bounds, false); | 3174 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix , anchor, position, bounds, false); |
3175 child->setDrawsContent(true); | 3175 child->setDrawsContent(true); |
3176 intermediateLayer->addChild(child.Pass()); | 3176 intermediateLayer->addChild(child.Pass()); |
3177 root->addChild(intermediateLayer.Pass()); | 3177 root->addChild(intermediateLayer.Pass()); |
3178 } | 3178 } |
3179 | 3179 |
3180 std::vector<LayerImpl*> renderSurfaceLayerList; | 3180 std::vector<LayerImpl*> renderSurfaceLayerList; |
3181 int dummyMaxTextureSize = 512; | 3181 int dummyMaxTextureSize = 512; |
3182 LayerTreeHostCommon::calculateDrawTransforms(root.get(), root->bounds(), 1, 1, 0, dummyMaxTextureSize, renderSurfaceLayerList); | 3182 LayerTreeHostCommon::calculateDrawTransforms(root.get(), root->bounds(), 1, 1, 0, dummyMaxTextureSize, false, renderSurfaceLayerList); |
3183 | 3183 |
3184 // Sanity check the scenario we just created. | 3184 // Sanity check the scenario we just created. |
3185 ASSERT_EQ(1u, renderSurfaceLayerList.size()); | 3185 ASSERT_EQ(1u, renderSurfaceLayerList.size()); |
3186 ASSERT_EQ(1u, root->renderSurface()->layerList().size()); | 3186 ASSERT_EQ(1u, root->renderSurface()->layerList().size()); |
3187 ASSERT_EQ(456, root->renderSurface()->layerList()[0]->id()); | 3187 ASSERT_EQ(456, root->renderSurface()->layerList()[0]->id()); |
3188 | 3188 |
3189 // Hit testing for a point outside the layer should return a null pointer. | 3189 // Hit testing for a point outside the layer should return a null pointer. |
3190 gfx::Point testPoint(69, 69); | 3190 gfx::Point testPoint(69, 69); |
3191 LayerImpl* resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(test Point, renderSurfaceLayerList); | 3191 LayerImpl* resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(test Point, renderSurfaceLayerList); |
3192 EXPECT_FALSE(resultLayer); | 3192 EXPECT_FALSE(resultLayer); |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3250 root->addChild(child1.Pass()); | 3250 root->addChild(child1.Pass()); |
3251 root->addChild(child2.Pass()); | 3251 root->addChild(child2.Pass()); |
3252 } | 3252 } |
3253 | 3253 |
3254 LayerImpl* child1 = root->children()[0]; | 3254 LayerImpl* child1 = root->children()[0]; |
3255 LayerImpl* child2 = root->children()[1]; | 3255 LayerImpl* child2 = root->children()[1]; |
3256 LayerImpl* grandChild1 = child1->children()[0]; | 3256 LayerImpl* grandChild1 = child1->children()[0]; |
3257 | 3257 |
3258 std::vector<LayerImpl*> renderSurfaceLayerList; | 3258 std::vector<LayerImpl*> renderSurfaceLayerList; |
3259 int dummyMaxTextureSize = 512; | 3259 int dummyMaxTextureSize = 512; |
3260 LayerTreeHostCommon::calculateDrawTransforms(root.get(), root->bounds(), 1, 1, 0, dummyMaxTextureSize, renderSurfaceLayerList); | 3260 LayerTreeHostCommon::calculateDrawTransforms(root.get(), root->bounds(), 1, 1, 0, dummyMaxTextureSize, false, renderSurfaceLayerList); |
3261 | 3261 |
3262 // Sanity check the scenario we just created. | 3262 // Sanity check the scenario we just created. |
3263 ASSERT_TRUE(child1); | 3263 ASSERT_TRUE(child1); |
3264 ASSERT_TRUE(child2); | 3264 ASSERT_TRUE(child2); |
3265 ASSERT_TRUE(grandChild1); | 3265 ASSERT_TRUE(grandChild1); |
3266 ASSERT_EQ(1u, renderSurfaceLayerList.size()); | 3266 ASSERT_EQ(1u, renderSurfaceLayerList.size()); |
3267 ASSERT_EQ(4u, root->renderSurface()->layerList().size()); | 3267 ASSERT_EQ(4u, root->renderSurface()->layerList().size()); |
3268 ASSERT_EQ(1, root->renderSurface()->layerList()[0]->id()); // root layer | 3268 ASSERT_EQ(1, root->renderSurface()->layerList()[0]->id()); // root layer |
3269 ASSERT_EQ(2, root->renderSurface()->layerList()[1]->id()); // child1 | 3269 ASSERT_EQ(2, root->renderSurface()->layerList()[1]->id()); // child1 |
3270 ASSERT_EQ(4, root->renderSurface()->layerList()[2]->id()); // grandChild1 | 3270 ASSERT_EQ(4, root->renderSurface()->layerList()[2]->id()); // grandChild1 |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3356 root->addChild(child1.Pass()); | 3356 root->addChild(child1.Pass()); |
3357 root->addChild(child2.Pass()); | 3357 root->addChild(child2.Pass()); |
3358 } | 3358 } |
3359 | 3359 |
3360 LayerImpl* child1 = root->children()[0]; | 3360 LayerImpl* child1 = root->children()[0]; |
3361 LayerImpl* child2 = root->children()[1]; | 3361 LayerImpl* child2 = root->children()[1]; |
3362 LayerImpl* grandChild1 = child1->children()[0]; | 3362 LayerImpl* grandChild1 = child1->children()[0]; |
3363 | 3363 |
3364 std::vector<LayerImpl*> renderSurfaceLayerList; | 3364 std::vector<LayerImpl*> renderSurfaceLayerList; |
3365 int dummyMaxTextureSize = 512; | 3365 int dummyMaxTextureSize = 512; |
3366 LayerTreeHostCommon::calculateDrawTransforms(root.get(), root->bounds(), 1, 1, 0, dummyMaxTextureSize, renderSurfaceLayerList); | 3366 LayerTreeHostCommon::calculateDrawTransforms(root.get(), root->bounds(), 1, 1, 0, dummyMaxTextureSize, false, renderSurfaceLayerList); |
3367 | 3367 |
3368 // Sanity check the scenario we just created. | 3368 // Sanity check the scenario we just created. |
3369 ASSERT_TRUE(child1); | 3369 ASSERT_TRUE(child1); |
3370 ASSERT_TRUE(child2); | 3370 ASSERT_TRUE(child2); |
3371 ASSERT_TRUE(grandChild1); | 3371 ASSERT_TRUE(grandChild1); |
3372 ASSERT_TRUE(child1->renderSurface()); | 3372 ASSERT_TRUE(child1->renderSurface()); |
3373 ASSERT_TRUE(child2->renderSurface()); | 3373 ASSERT_TRUE(child2->renderSurface()); |
3374 ASSERT_TRUE(grandChild1->renderSurface()); | 3374 ASSERT_TRUE(grandChild1->renderSurface()); |
3375 ASSERT_EQ(4u, renderSurfaceLayerList.size()); | 3375 ASSERT_EQ(4u, renderSurfaceLayerList.size()); |
3376 ASSERT_EQ(3u, root->renderSurface()->layerList().size()); // The root surfac e has the root layer, and child1's and child2's renderSurfaces. | 3376 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 Loading... | |
3457 | 3457 |
3458 parent->addChild(child); | 3458 parent->addChild(child); |
3459 parent->addChild(childNoScale); | 3459 parent->addChild(childNoScale); |
3460 | 3460 |
3461 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; | 3461 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; |
3462 int dummyMaxTextureSize = 512; | 3462 int dummyMaxTextureSize = 512; |
3463 | 3463 |
3464 const double deviceScaleFactor = 2.5; | 3464 const double deviceScaleFactor = 2.5; |
3465 const double pageScaleFactor = 1; | 3465 const double pageScaleFactor = 1; |
3466 | 3466 |
3467 LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(), deviceScaleFactor, pageScaleFactor, dummyMaxTextureSize, renderSurfaceLayerList ); | 3467 LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(), deviceScaleFactor, pageScaleFactor, dummyMaxTextureSize, false, renderSurfaceLa yerList); |
3468 | 3468 |
3469 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor, parent); | 3469 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor, parent); |
3470 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor, child); | 3470 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor, child); |
3471 EXPECT_CONTENTS_SCALE_EQ(1, childNoScale); | 3471 EXPECT_CONTENTS_SCALE_EQ(1, childNoScale); |
3472 | 3472 |
3473 EXPECT_EQ(1u, renderSurfaceLayerList.size()); | 3473 EXPECT_EQ(1u, renderSurfaceLayerList.size()); |
3474 | 3474 |
3475 // Verify parent transforms | 3475 // Verify parent transforms |
3476 WebTransformationMatrix expectedParentTransform; | 3476 WebTransformationMatrix expectedParentTransform; |
3477 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedParentTransform, parent->screenSpace Transform()); | 3477 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedParentTransform, parent->screenSpace Transform()); |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3532 | 3532 |
3533 parent->addChild(child); | 3533 parent->addChild(child); |
3534 parent->addChild(childNoScale); | 3534 parent->addChild(childNoScale); |
3535 | 3535 |
3536 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; | 3536 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; |
3537 int dummyMaxTextureSize = 512; | 3537 int dummyMaxTextureSize = 512; |
3538 | 3538 |
3539 const float deviceScaleFactor = 1.7f; | 3539 const float deviceScaleFactor = 1.7f; |
3540 const float pageScaleFactor = 1; | 3540 const float pageScaleFactor = 1; |
3541 | 3541 |
3542 LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(), deviceScaleFactor, pageScaleFactor, dummyMaxTextureSize, renderSurfaceLayerList ); | 3542 LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(), deviceScaleFactor, pageScaleFactor, dummyMaxTextureSize, false, renderSurfaceLa yerList); |
3543 | 3543 |
3544 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor, parent); | 3544 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor, parent); |
3545 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor, child); | 3545 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor, child); |
3546 EXPECT_CONTENTS_SCALE_EQ(1, childNoScale); | 3546 EXPECT_CONTENTS_SCALE_EQ(1, childNoScale); |
3547 | 3547 |
3548 EXPECT_EQ(1u, renderSurfaceLayerList.size()); | 3548 EXPECT_EQ(1u, renderSurfaceLayerList.size()); |
3549 | 3549 |
3550 // Verify parent transforms | 3550 // Verify parent transforms |
3551 WebTransformationMatrix expectedParentTransform; | 3551 WebTransformationMatrix expectedParentTransform; |
3552 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedParentTransform, parent->screenSpace Transform()); | 3552 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedParentTransform, parent->screenSpace Transform()); |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3633 int dummyMaxTextureSize = 512; | 3633 int dummyMaxTextureSize = 512; |
3634 | 3634 |
3635 double deviceScaleFactor = 2.5; | 3635 double deviceScaleFactor = 2.5; |
3636 double pageScaleFactor = 1.5; | 3636 double pageScaleFactor = 1.5; |
3637 | 3637 |
3638 // FIXME: Remove this when pageScaleFactor is applied in the compositor. | 3638 // FIXME: Remove this when pageScaleFactor is applied in the compositor. |
3639 WebTransformationMatrix pageScaleMatrix; | 3639 WebTransformationMatrix pageScaleMatrix; |
3640 pageScaleMatrix.scale(pageScaleFactor); | 3640 pageScaleMatrix.scale(pageScaleFactor); |
3641 parent->setSublayerTransform(pageScaleMatrix); | 3641 parent->setSublayerTransform(pageScaleMatrix); |
3642 | 3642 |
3643 LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(), deviceScaleFactor, pageScaleFactor, dummyMaxTextureSize, renderSurfaceLayerList ); | 3643 LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(), deviceScaleFactor, pageScaleFactor, dummyMaxTextureSize, false, renderSurfaceLa yerList); |
3644 | 3644 |
3645 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * initialParentScale, parent); | 3645 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * initialParentScale, parent); |
3646 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor * initialParent Scale * initialChildScale, childScale); | 3646 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor * initialParent Scale * initialChildScale, childScale); |
3647 EXPECT_CONTENTS_SCALE_EQ(1, childNoScale); | 3647 EXPECT_CONTENTS_SCALE_EQ(1, childNoScale); |
3648 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor * fixedRasterSc ale, childNoAutoScale); | 3648 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor * fixedRasterSc ale, childNoAutoScale); |
3649 | 3649 |
3650 // The parent is scaled up and shouldn't need to scale during draw. The chil d that can scale its contents should | 3650 // The parent is scaled up and shouldn't need to scale during draw. The chil d that can scale its contents should |
3651 // also not need to scale during draw. The other should. | 3651 // also not need to scale during draw. The other should. |
3652 // There is some rounding error due to contentBounds being a rounded integer . | 3652 // There is some rounding error due to contentBounds being a rounded integer . |
3653 EXPECT_NEAR(parent->drawTransform().m11(), 1, 0.01); | 3653 EXPECT_NEAR(parent->drawTransform().m11(), 1, 0.01); |
3654 EXPECT_NEAR(parent->drawTransform().m22(), 1, 0.01); | 3654 EXPECT_NEAR(parent->drawTransform().m22(), 1, 0.01); |
3655 EXPECT_NEAR(childScale->drawTransform().m11(), 1, 0.01); | 3655 EXPECT_NEAR(childScale->drawTransform().m11(), 1, 0.01); |
3656 EXPECT_NEAR(childScale->drawTransform().m22(), 1, 0.01); | 3656 EXPECT_NEAR(childScale->drawTransform().m22(), 1, 0.01); |
3657 EXPECT_FLOAT_EQ(deviceScaleFactor * pageScaleFactor * initialParentScale * i nitialChildScale, childNoScale->drawTransform().m11()); | 3657 EXPECT_FLOAT_EQ(deviceScaleFactor * pageScaleFactor * initialParentScale * i nitialChildScale, childNoScale->drawTransform().m11()); |
3658 EXPECT_FLOAT_EQ(deviceScaleFactor * pageScaleFactor * initialParentScale * i nitialChildScale, childNoScale->drawTransform().m22()); | 3658 EXPECT_FLOAT_EQ(deviceScaleFactor * pageScaleFactor * initialParentScale * i nitialChildScale, childNoScale->drawTransform().m22()); |
3659 EXPECT_NEAR(childNoAutoScale->drawTransform().m11(), initialParentScale * in itialChildScale / fixedRasterScale, 0.01); | 3659 EXPECT_NEAR(childNoAutoScale->drawTransform().m11(), initialParentScale * in itialChildScale / fixedRasterScale, 0.01); |
3660 EXPECT_NEAR(childNoAutoScale->drawTransform().m22(), initialParentScale * in itialChildScale / fixedRasterScale, 0.01); | 3660 EXPECT_NEAR(childNoAutoScale->drawTransform().m22(), initialParentScale * in itialChildScale / fixedRasterScale, 0.01); |
3661 | 3661 |
3662 // If the transform changes, we expect the contentsScale to remain unchanged . | 3662 // If the transform changes, we expect the contentsScale to remain unchanged . |
3663 childScale->setTransform(identityMatrix); | 3663 childScale->setTransform(identityMatrix); |
3664 | 3664 |
3665 renderSurfaceLayerList.clear(); | 3665 renderSurfaceLayerList.clear(); |
3666 LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(), deviceScaleFactor, pageScaleFactor, dummyMaxTextureSize, renderSurfaceLayerList ); | 3666 LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(), deviceScaleFactor, pageScaleFactor, dummyMaxTextureSize, false, renderSurfaceLa yerList); |
3667 | 3667 |
3668 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * initialParentScale, parent); | 3668 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * initialParentScale, parent); |
3669 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor * initialParent Scale * initialChildScale, childScale); | 3669 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor * initialParent Scale * initialChildScale, childScale); |
3670 EXPECT_CONTENTS_SCALE_EQ(1, childNoScale); | 3670 EXPECT_CONTENTS_SCALE_EQ(1, childNoScale); |
3671 | 3671 |
3672 // But if the deviceScaleFactor or pageScaleFactor changes, then it should b e updated, but using the initial transform. | 3672 // But if the deviceScaleFactor or pageScaleFactor changes, then it should b e updated, but using the initial transform. |
3673 deviceScaleFactor = 2.25; | 3673 deviceScaleFactor = 2.25; |
3674 pageScaleFactor = 1.25; | 3674 pageScaleFactor = 1.25; |
3675 | 3675 |
3676 // FIXME: Remove this when pageScaleFactor is applied in the compositor. | 3676 // FIXME: Remove this when pageScaleFactor is applied in the compositor. |
3677 pageScaleMatrix = identityMatrix; | 3677 pageScaleMatrix = identityMatrix; |
3678 pageScaleMatrix.scale(pageScaleFactor); | 3678 pageScaleMatrix.scale(pageScaleFactor); |
3679 parent->setSublayerTransform(pageScaleMatrix); | 3679 parent->setSublayerTransform(pageScaleMatrix); |
3680 | 3680 |
3681 renderSurfaceLayerList.clear(); | 3681 renderSurfaceLayerList.clear(); |
3682 LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(), deviceScaleFactor, pageScaleFactor, dummyMaxTextureSize, renderSurfaceLayerList ); | 3682 LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(), deviceScaleFactor, pageScaleFactor, dummyMaxTextureSize, false, renderSurfaceLa yerList); |
3683 | 3683 |
3684 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * initialParentScale, parent); | 3684 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * initialParentScale, parent); |
3685 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor * initialParent Scale * initialChildScale, childScale); | 3685 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor * initialParent Scale * initialChildScale, childScale); |
3686 EXPECT_CONTENTS_SCALE_EQ(1, childNoScale); | 3686 EXPECT_CONTENTS_SCALE_EQ(1, childNoScale); |
3687 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor * fixedRasterSc ale, childNoAutoScale); | 3687 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor * fixedRasterSc ale, childNoAutoScale); |
3688 } | 3688 } |
3689 | 3689 |
3690 TEST(LayerTreeHostCommonTest, verifyContentsScaleForSurfaces) | 3690 TEST(LayerTreeHostCommonTest, verifyContentsScaleForSurfaces) |
3691 { | 3691 { |
3692 MockContentLayerClient delegate; | 3692 MockContentLayerClient delegate; |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3758 int dummyMaxTextureSize = 512; | 3758 int dummyMaxTextureSize = 512; |
3759 | 3759 |
3760 double deviceScaleFactor = 5; | 3760 double deviceScaleFactor = 5; |
3761 double pageScaleFactor = 7; | 3761 double pageScaleFactor = 7; |
3762 | 3762 |
3763 // FIXME: Remove this when pageScaleFactor is applied in the compositor. | 3763 // FIXME: Remove this when pageScaleFactor is applied in the compositor. |
3764 WebTransformationMatrix pageScaleMatrix; | 3764 WebTransformationMatrix pageScaleMatrix; |
3765 pageScaleMatrix.scale(pageScaleFactor); | 3765 pageScaleMatrix.scale(pageScaleFactor); |
3766 parent->setSublayerTransform(pageScaleMatrix); | 3766 parent->setSublayerTransform(pageScaleMatrix); |
3767 | 3767 |
3768 LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(), deviceScaleFactor, pageScaleFactor, dummyMaxTextureSize, renderSurfaceLayerList ); | 3768 LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(), deviceScaleFactor, pageScaleFactor, dummyMaxTextureSize, false, renderSurfaceLa yerList); |
3769 | 3769 |
3770 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * initialParentScale, parent); | 3770 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * initialParentScale, parent); |
3771 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor * initialParent Scale * initialChildScale, surfaceScale); | 3771 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor * initialParent Scale * initialChildScale, surfaceScale); |
3772 EXPECT_CONTENTS_SCALE_EQ(1, surfaceNoScale); | 3772 EXPECT_CONTENTS_SCALE_EQ(1, surfaceNoScale); |
3773 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor * fixedRasterSc ale, surfaceNoAutoScale); | 3773 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor * fixedRasterSc ale, surfaceNoAutoScale); |
3774 | 3774 |
3775 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor * initialParent Scale * initialChildScale * initialChildScale, surfaceScaleChildScale); | 3775 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor * initialParent Scale * initialChildScale * initialChildScale, surfaceScaleChildScale); |
3776 EXPECT_CONTENTS_SCALE_EQ(1, surfaceScaleChildNoScale); | 3776 EXPECT_CONTENTS_SCALE_EQ(1, surfaceScaleChildNoScale); |
3777 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor * initialParent Scale * initialChildScale * initialChildScale, surfaceNoScaleChildScale); | 3777 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor * initialParent Scale * initialChildScale * initialChildScale, surfaceNoScaleChildScale); |
3778 EXPECT_CONTENTS_SCALE_EQ(1, surfaceNoScaleChildNoScale); | 3778 EXPECT_CONTENTS_SCALE_EQ(1, surfaceNoScaleChildNoScale); |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3852 setLayerPropertiesForTesting(childScale.get(), childScaleMatrix, identityMat rix, gfx::PointF(0, 0), gfx::PointF(2, 2), gfx::Size(10, 10), true); | 3852 setLayerPropertiesForTesting(childScale.get(), childScaleMatrix, identityMat rix, gfx::PointF(0, 0), gfx::PointF(2, 2), gfx::Size(10, 10), true); |
3853 | 3853 |
3854 parent->addChild(childScale); | 3854 parent->addChild(childScale); |
3855 | 3855 |
3856 // Now put an animating transform on child. | 3856 // Now put an animating transform on child. |
3857 int animationId = addAnimatedTransformToController(*childScale->layerAnimati onController(), 10, 30, 0); | 3857 int animationId = addAnimatedTransformToController(*childScale->layerAnimati onController(), 10, 30, 0); |
3858 | 3858 |
3859 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; | 3859 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; |
3860 int dummyMaxTextureSize = 512; | 3860 int dummyMaxTextureSize = 512; |
3861 | 3861 |
3862 LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(), 1, 1, dummyMaxTextureSize, renderSurfaceLayerList); | 3862 LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(), 1, 1, dummyMaxTextureSize, false, renderSurfaceLayerList); |
3863 | 3863 |
3864 EXPECT_CONTENTS_SCALE_EQ(initialParentScale, parent); | 3864 EXPECT_CONTENTS_SCALE_EQ(initialParentScale, parent); |
3865 // The layers with animating transforms should not compute a contentsScale o ther than 1 until they finish animating. | 3865 // The layers with animating transforms should not compute a contentsScale o ther than 1 until they finish animating. |
3866 EXPECT_CONTENTS_SCALE_EQ(1, childScale); | 3866 EXPECT_CONTENTS_SCALE_EQ(1, childScale); |
3867 | 3867 |
3868 // Remove the animation, now it can save a raster scale. | 3868 // Remove the animation, now it can save a raster scale. |
3869 childScale->layerAnimationController()->removeAnimation(animationId); | 3869 childScale->layerAnimationController()->removeAnimation(animationId); |
3870 | 3870 |
3871 LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(), 1, 1, dummyMaxTextureSize, renderSurfaceLayerList); | 3871 LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(), 1, 1, dummyMaxTextureSize, false, renderSurfaceLayerList); |
3872 | 3872 |
3873 EXPECT_CONTENTS_SCALE_EQ(initialParentScale, parent); | 3873 EXPECT_CONTENTS_SCALE_EQ(initialParentScale, parent); |
3874 // The layers with animating transforms should not compute a contentsScale o ther than 1 until they finish animating. | 3874 // The layers with animating transforms should not compute a contentsScale o ther than 1 until they finish animating. |
3875 EXPECT_CONTENTS_SCALE_EQ(initialParentScale * initialChildScale, childScale) ; | 3875 EXPECT_CONTENTS_SCALE_EQ(initialParentScale * initialChildScale, childScale) ; |
3876 } | 3876 } |
3877 | 3877 |
3878 | 3878 |
3879 TEST(LayerTreeHostCommonTest, verifyRenderSurfaceTransformsInHighDPI) | 3879 TEST(LayerTreeHostCommonTest, verifyRenderSurfaceTransformsInHighDPI) |
3880 { | 3880 { |
3881 MockContentLayerClient delegate; | 3881 MockContentLayerClient delegate; |
(...skipping 21 matching lines...) Expand all Loading... | |
3903 | 3903 |
3904 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; | 3904 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; |
3905 int dummyMaxTextureSize = 512; | 3905 int dummyMaxTextureSize = 512; |
3906 | 3906 |
3907 const double deviceScaleFactor = 1.5; | 3907 const double deviceScaleFactor = 1.5; |
3908 parent->setContentsScale(deviceScaleFactor); | 3908 parent->setContentsScale(deviceScaleFactor); |
3909 child->setContentsScale(deviceScaleFactor); | 3909 child->setContentsScale(deviceScaleFactor); |
3910 duplicateChildNonOwner->setContentsScale(deviceScaleFactor); | 3910 duplicateChildNonOwner->setContentsScale(deviceScaleFactor); |
3911 replica->setContentsScale(deviceScaleFactor); | 3911 replica->setContentsScale(deviceScaleFactor); |
3912 | 3912 |
3913 LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(), deviceScaleFactor, 1, dummyMaxTextureSize, renderSurfaceLayerList); | 3913 LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(), deviceScaleFactor, 1, dummyMaxTextureSize, false, renderSurfaceLayerList); |
3914 | 3914 |
3915 // We should have two render surfaces. The root's render surface and child's | 3915 // We should have two render surfaces. The root's render surface and child's |
3916 // render surface (it needs one because it has a replica layer). | 3916 // render surface (it needs one because it has a replica layer). |
3917 EXPECT_EQ(2u, renderSurfaceLayerList.size()); | 3917 EXPECT_EQ(2u, renderSurfaceLayerList.size()); |
3918 | 3918 |
3919 WebTransformationMatrix expectedParentTransform; | 3919 WebTransformationMatrix expectedParentTransform; |
3920 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedParentTransform, parent->screenSpace Transform()); | 3920 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedParentTransform, parent->screenSpace Transform()); |
3921 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedParentTransform, parent->drawTransfo rm()); | 3921 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedParentTransform, parent->drawTransfo rm()); |
3922 | 3922 |
3923 WebTransformationMatrix expectedDrawTransform; | 3923 WebTransformationMatrix expectedDrawTransform; |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3986 | 3986 |
3987 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; | 3987 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; |
3988 int dummyMaxTextureSize = 512; | 3988 int dummyMaxTextureSize = 512; |
3989 | 3989 |
3990 const float deviceScaleFactor = 1.7f; | 3990 const float deviceScaleFactor = 1.7f; |
3991 parent->setContentsScale(deviceScaleFactor); | 3991 parent->setContentsScale(deviceScaleFactor); |
3992 child->setContentsScale(deviceScaleFactor); | 3992 child->setContentsScale(deviceScaleFactor); |
3993 duplicateChildNonOwner->setContentsScale(deviceScaleFactor); | 3993 duplicateChildNonOwner->setContentsScale(deviceScaleFactor); |
3994 replica->setContentsScale(deviceScaleFactor); | 3994 replica->setContentsScale(deviceScaleFactor); |
3995 | 3995 |
3996 LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(), deviceScaleFactor, 1, dummyMaxTextureSize, renderSurfaceLayerList); | 3996 LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(), deviceScaleFactor, 1, dummyMaxTextureSize, false, renderSurfaceLayerList); |
3997 | 3997 |
3998 // We should have two render surfaces. The root's render surface and child's | 3998 // We should have two render surfaces. The root's render surface and child's |
3999 // render surface (it needs one because it has a replica layer). | 3999 // render surface (it needs one because it has a replica layer). |
4000 EXPECT_EQ(2u, renderSurfaceLayerList.size()); | 4000 EXPECT_EQ(2u, renderSurfaceLayerList.size()); |
4001 | 4001 |
4002 WebTransformationMatrix identityTransform; | 4002 WebTransformationMatrix identityTransform; |
4003 | 4003 |
4004 EXPECT_TRANSFORMATION_MATRIX_EQ(identityTransform, parent->screenSpaceTransf orm()); | 4004 EXPECT_TRANSFORMATION_MATRIX_EQ(identityTransform, parent->screenSpaceTransf orm()); |
4005 EXPECT_TRANSFORMATION_MATRIX_EQ(identityTransform, parent->drawTransform()); | 4005 EXPECT_TRANSFORMATION_MATRIX_EQ(identityTransform, parent->drawTransform()); |
4006 EXPECT_TRANSFORMATION_MATRIX_EQ(identityTransform, child->drawTransform()); | 4006 EXPECT_TRANSFORMATION_MATRIX_EQ(identityTransform, child->drawTransform()); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4038 | 4038 |
4039 int nonexistentId = -1; | 4039 int nonexistentId = -1; |
4040 EXPECT_EQ(root, LayerTreeHostCommon::findLayerInSubtree(root.get(), root->id ())); | 4040 EXPECT_EQ(root, LayerTreeHostCommon::findLayerInSubtree(root.get(), root->id ())); |
4041 EXPECT_EQ(child, LayerTreeHostCommon::findLayerInSubtree(root.get(), child-> id())); | 4041 EXPECT_EQ(child, LayerTreeHostCommon::findLayerInSubtree(root.get(), child-> id())); |
4042 EXPECT_EQ(grandChild, LayerTreeHostCommon::findLayerInSubtree(root.get(), gr andChild->id())); | 4042 EXPECT_EQ(grandChild, LayerTreeHostCommon::findLayerInSubtree(root.get(), gr andChild->id())); |
4043 EXPECT_EQ(maskLayer, LayerTreeHostCommon::findLayerInSubtree(root.get(), mas kLayer->id())); | 4043 EXPECT_EQ(maskLayer, LayerTreeHostCommon::findLayerInSubtree(root.get(), mas kLayer->id())); |
4044 EXPECT_EQ(replicaLayer, LayerTreeHostCommon::findLayerInSubtree(root.get(), replicaLayer->id())); | 4044 EXPECT_EQ(replicaLayer, LayerTreeHostCommon::findLayerInSubtree(root.get(), replicaLayer->id())); |
4045 EXPECT_EQ(0, LayerTreeHostCommon::findLayerInSubtree(root.get(), nonexistent Id)); | 4045 EXPECT_EQ(0, LayerTreeHostCommon::findLayerInSubtree(root.get(), nonexistent Id)); |
4046 } | 4046 } |
4047 | 4047 |
4048 class LCDTextTest : public testing::TestWithParam<int> { | |
4049 public: | |
4050 enum Param { | |
4051 LAYER_REGULAR, | |
4052 LAYER_PRESERVES_3D, | |
4053 LAYER_FORCES_RENDER_SURFACE | |
4054 }; | |
4055 | |
4056 protected: | |
4057 virtual void SetUp() | |
4058 { | |
4059 m_root = Layer::create(); | |
4060 m_child = Layer::create(); | |
4061 m_grandChild = Layer::create(); | |
4062 m_child->addChild(m_grandChild.get()); | |
4063 m_root->addChild(m_child.get()); | |
4064 | |
4065 WebTransformationMatrix identityMatrix; | |
4066 setLayerPropertiesForTesting(m_root, identityMatrix, identityMatrix, gfx ::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(1, 1), false); | |
4067 setLayerPropertiesForTesting(m_child, identityMatrix, identityMatrix, gf x::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(1, 1), false); | |
4068 setLayerPropertiesForTesting(m_grandChild, identityMatrix, identityMatri x, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(1, 1), false); | |
4069 | |
4070 switch (GetParam()) { | |
4071 case LAYER_REGULAR: | |
4072 break; | |
4073 case LAYER_PRESERVES_3D: | |
4074 m_child->setPreserves3D(true); | |
4075 break; | |
4076 case LAYER_FORCES_RENDER_SURFACE: | |
4077 m_child->setForceRenderSurface(true); | |
4078 break; | |
4079 default: | |
4080 ASSERT(false); | |
4081 break; | |
4082 } | |
4083 } | |
4084 | |
4085 scoped_refptr<Layer> m_root; | |
4086 scoped_refptr<Layer> m_child; | |
4087 scoped_refptr<Layer> m_grandChild; | |
4088 }; | |
4089 | |
4090 TEST_P(LCDTextTest, verifyCanUseLCDText) | |
4091 { | |
4092 bool canUseLCDText = true; | |
danakj
2012/11/10 01:12:35
Can you add a simple test or parameterize this to
alokp
2012/11/12 01:04:45
Done.
danakj
2012/11/12 01:25:47
Awesome, thanks.
| |
4093 | |
4094 // Case 1: Identity transform. | |
4095 WebTransformationMatrix identityMatrix; | |
4096 executeCalculateDrawTransformsAndVisibility(m_root, 1, 1, canUseLCDText); | |
4097 EXPECT_EQ(canUseLCDText, m_root->canUseLCDText()); | |
4098 EXPECT_EQ(canUseLCDText, m_child->canUseLCDText()); | |
4099 EXPECT_EQ(canUseLCDText, m_grandChild->canUseLCDText()); | |
4100 | |
4101 // Case 2: Integral translation. | |
4102 WebTransformationMatrix integralTranslation; | |
4103 integralTranslation.translate(1, 2); | |
4104 m_child->setTransform(integralTranslation); | |
4105 executeCalculateDrawTransformsAndVisibility(m_root, 1, 1, canUseLCDText); | |
4106 EXPECT_EQ(canUseLCDText, m_root->canUseLCDText()); | |
4107 EXPECT_EQ(canUseLCDText, m_child->canUseLCDText()); | |
4108 EXPECT_EQ(canUseLCDText, m_grandChild->canUseLCDText()); | |
4109 | |
4110 // Case 3: Non-integral translation. | |
4111 WebTransformationMatrix nonIntegralTranslation; | |
4112 nonIntegralTranslation.translate(1.5, 2.5); | |
4113 m_child->setTransform(nonIntegralTranslation); | |
4114 executeCalculateDrawTransformsAndVisibility(m_root, 1, 1, canUseLCDText); | |
4115 EXPECT_EQ(canUseLCDText, m_root->canUseLCDText()); | |
4116 EXPECT_EQ(false, m_child->canUseLCDText()); | |
4117 EXPECT_EQ(false, m_grandChild->canUseLCDText()); | |
4118 | |
4119 // Case 4: Rotation. | |
4120 WebTransformationMatrix rotation; | |
4121 rotation.rotate(10); | |
4122 m_child->setTransform(rotation); | |
4123 executeCalculateDrawTransformsAndVisibility(m_root, 1, 1, canUseLCDText); | |
4124 EXPECT_EQ(canUseLCDText, m_root->canUseLCDText()); | |
4125 EXPECT_EQ(false, m_child->canUseLCDText()); | |
4126 EXPECT_EQ(false, m_grandChild->canUseLCDText()); | |
4127 | |
4128 // Case 5: Scale. | |
4129 WebTransformationMatrix scale; | |
4130 scale.scale(2); | |
4131 m_child->setTransform(scale); | |
4132 executeCalculateDrawTransformsAndVisibility(m_root, 1, 1, canUseLCDText); | |
4133 EXPECT_EQ(canUseLCDText, m_root->canUseLCDText()); | |
4134 EXPECT_EQ(false, m_child->canUseLCDText()); | |
4135 EXPECT_EQ(false, m_grandChild->canUseLCDText()); | |
4136 | |
4137 // Case 6: Skew. | |
4138 WebTransformationMatrix skew; | |
4139 skew.skewX(10); | |
4140 m_child->setTransform(skew); | |
4141 executeCalculateDrawTransformsAndVisibility(m_root, 1, 1, canUseLCDText); | |
4142 EXPECT_EQ(canUseLCDText, m_root->canUseLCDText()); | |
4143 EXPECT_EQ(false, m_child->canUseLCDText()); | |
4144 EXPECT_EQ(false, m_grandChild->canUseLCDText()); | |
4145 | |
4146 // Case 7: Translucent. | |
4147 m_child->setTransform(identityMatrix); | |
4148 m_child->setOpacity(0.5); | |
4149 executeCalculateDrawTransformsAndVisibility(m_root, 1, 1, canUseLCDText); | |
4150 EXPECT_EQ(canUseLCDText, m_root->canUseLCDText()); | |
4151 EXPECT_EQ(false, m_child->canUseLCDText()); | |
4152 EXPECT_EQ(m_child->forceRenderSurface() || m_child->preserves3D() ? false : canUseLCDText, m_grandChild->canUseLCDText()); | |
4153 | |
4154 // Case 8: Sanity check: restore transform and opacity. | |
4155 m_child->setTransform(identityMatrix); | |
4156 m_child->setOpacity(1); | |
4157 executeCalculateDrawTransformsAndVisibility(m_root, 1, 1, canUseLCDText); | |
4158 EXPECT_EQ(canUseLCDText, m_root->canUseLCDText()); | |
4159 EXPECT_EQ(canUseLCDText, m_child->canUseLCDText()); | |
4160 EXPECT_EQ(canUseLCDText, m_grandChild->canUseLCDText()); | |
4161 } | |
4162 | |
4163 TEST_P(LCDTextTest, verifyCanUseLCDTextWithAnimation) | |
4164 { | |
4165 m_root->setCanUseLCDText(true); | |
4166 m_child->setCanUseLCDText(true); | |
4167 m_grandChild->setCanUseLCDText(true); | |
4168 | |
4169 m_child->setOpacity(0.9f); | |
4170 addOpacityTransitionToController(*(m_child->layerAnimationController()), 10, 0.9f, 0.1f, false); | |
4171 | |
4172 executeCalculateDrawTransformsAndVisibility(m_root, 1, 1, true); | |
4173 // Text AA should not be adjusted while animation is active. | |
4174 // LCD text remains enabled even when it should not be. | |
4175 EXPECT_EQ(true, m_root->canUseLCDText()); | |
4176 EXPECT_EQ(true, m_child->canUseLCDText()); | |
4177 EXPECT_EQ(true, m_grandChild->canUseLCDText()); | |
4178 } | |
4179 | |
4180 INSTANTIATE_TEST_CASE_P(All, LCDTextTest, | |
4181 testing::Values(LCDTextTest::LAYER_REGULAR, | |
4182 LCDTextTest::LAYER_PRESERVES_3D, | |
4183 LCDTextTest::LAYER_FORCES_RENDER_SURFACE )); | |
4184 | |
4048 } // anonymous namespace | 4185 } // anonymous namespace |
OLD | NEW |