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 "CCLayerTreeHostCommon.h" | 7 #include "CCLayerTreeHostCommon.h" |
8 | 8 |
9 #include "CCAnimationTestCommon.h" | 9 #include "CCAnimationTestCommon.h" |
10 #include "CCGeometryTestUtils.h" | 10 #include "CCGeometryTestUtils.h" |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 { | 44 { |
45 setLayerPropertiesForTesting<LayerChromium>(layer, transform, sublayerTransf
orm, anchor, position, bounds, preserves3D); | 45 setLayerPropertiesForTesting<LayerChromium>(layer, transform, sublayerTransf
orm, anchor, position, bounds, preserves3D); |
46 } | 46 } |
47 | 47 |
48 void setLayerPropertiesForTesting(CCLayerImpl* layer, const WebTransformationMat
rix& transform, const WebTransformationMatrix& sublayerTransform, const FloatPoi
nt& anchor, const FloatPoint& position, const IntSize& bounds, bool preserves3D) | 48 void setLayerPropertiesForTesting(CCLayerImpl* layer, const WebTransformationMat
rix& transform, const WebTransformationMatrix& sublayerTransform, const FloatPoi
nt& anchor, const FloatPoint& position, const IntSize& bounds, bool preserves3D) |
49 { | 49 { |
50 setLayerPropertiesForTesting<CCLayerImpl>(layer, transform, sublayerTransfor
m, anchor, position, bounds, preserves3D); | 50 setLayerPropertiesForTesting<CCLayerImpl>(layer, transform, sublayerTransfor
m, anchor, position, bounds, preserves3D); |
51 layer->setContentBounds(bounds); | 51 layer->setContentBounds(bounds); |
52 } | 52 } |
53 | 53 |
54 void executeCalculateDrawTransformsAndVisibility(LayerChromium* rootLayer, float
deviceScaleFactor = 1) | 54 void executeCalculateDrawTransformsAndVisibility(LayerChromium* rootLayer, float
deviceScaleFactor = 1, float pageScaleFactor = 1) |
55 { | 55 { |
56 WebTransformationMatrix identityMatrix; | 56 WebTransformationMatrix identityMatrix; |
57 Vector<RefPtr<LayerChromium> > dummyRenderSurfaceLayerList; | 57 Vector<RefPtr<LayerChromium> > dummyRenderSurfaceLayerList; |
58 int dummyMaxTextureSize = 512; | 58 int dummyMaxTextureSize = 512; |
59 IntSize deviceViewportSize = IntSize(rootLayer->bounds().width() * deviceSca
leFactor, rootLayer->bounds().height() * deviceScaleFactor); | 59 IntSize deviceViewportSize = IntSize(rootLayer->bounds().width() * deviceSca
leFactor, 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 ASSERT(!rootLayer->bounds().isEmpty()); | 62 ASSERT(!rootLayer->bounds().isEmpty()); |
63 CCLayerTreeHostCommon::calculateDrawTransforms(rootLayer, deviceViewportSize
, deviceScaleFactor, dummyMaxTextureSize, dummyRenderSurfaceLayerList); | 63 CCLayerTreeHostCommon::calculateDrawTransforms(rootLayer, deviceViewportSize
, deviceScaleFactor, pageScaleFactor, dummyMaxTextureSize, dummyRenderSurfaceLay
erList); |
64 CCLayerTreeHostCommon::calculateVisibleRects(dummyRenderSurfaceLayerList); | 64 CCLayerTreeHostCommon::calculateVisibleRects(dummyRenderSurfaceLayerList); |
65 } | 65 } |
66 | 66 |
67 void executeCalculateDrawTransformsAndVisibility(CCLayerImpl* rootLayer, float d
eviceScaleFactor = 1) | 67 void executeCalculateDrawTransformsAndVisibility(CCLayerImpl* rootLayer, float d
eviceScaleFactor = 1, float pageScaleFactor = 1) |
68 { | 68 { |
69 // Note: this version skips layer sorting. | 69 // Note: this version skips layer sorting. |
70 | 70 |
71 WebTransformationMatrix identityMatrix; | 71 WebTransformationMatrix identityMatrix; |
72 Vector<CCLayerImpl*> dummyRenderSurfaceLayerList; | 72 Vector<CCLayerImpl*> dummyRenderSurfaceLayerList; |
73 int dummyMaxTextureSize = 512; | 73 int dummyMaxTextureSize = 512; |
74 IntSize deviceViewportSize = IntSize(rootLayer->bounds().width() * deviceSca
leFactor, rootLayer->bounds().height() * deviceScaleFactor); | 74 IntSize deviceViewportSize = IntSize(rootLayer->bounds().width() * deviceSca
leFactor, rootLayer->bounds().height() * deviceScaleFactor); |
75 | 75 |
76 // We are probably not testing what is intended if the rootLayer bounds are
empty. | 76 // We are probably not testing what is intended if the rootLayer bounds are
empty. |
77 ASSERT(!rootLayer->bounds().isEmpty()); | 77 ASSERT(!rootLayer->bounds().isEmpty()); |
78 CCLayerTreeHostCommon::calculateDrawTransforms(rootLayer, deviceViewportSize
, deviceScaleFactor, 0, dummyMaxTextureSize, dummyRenderSurfaceLayerList); | 78 CCLayerTreeHostCommon::calculateDrawTransforms(rootLayer, deviceViewportSize
, deviceScaleFactor, pageScaleFactor, 0, dummyMaxTextureSize, dummyRenderSurface
LayerList); |
79 CCLayerTreeHostCommon::calculateVisibleRects(dummyRenderSurfaceLayerList); | 79 CCLayerTreeHostCommon::calculateVisibleRects(dummyRenderSurfaceLayerList); |
80 } | 80 } |
81 | 81 |
82 WebTransformationMatrix remove3DComponentOfMatrix(const WebTransformationMatrix&
mat) | 82 WebTransformationMatrix remove3DComponentOfMatrix(const WebTransformationMatrix&
mat) |
83 { | 83 { |
84 WebTransformationMatrix ret = mat; | 84 WebTransformationMatrix ret = mat; |
85 ret.setM13(0); | 85 ret.setM13(0); |
86 ret.setM23(0); | 86 ret.setM23(0); |
87 ret.setM31(0); | 87 ret.setM31(0); |
88 ret.setM32(0); | 88 ret.setM32(0); |
(...skipping 558 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
647 setLayerPropertiesForTesting(renderSurface1.get(), identityMatrix, identityM
atrix, FloatPoint::zero(), FloatPoint::zero(), IntSize(10, 10), false); | 647 setLayerPropertiesForTesting(renderSurface1.get(), identityMatrix, identityM
atrix, FloatPoint::zero(), FloatPoint::zero(), IntSize(10, 10), false); |
648 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, Fl
oatPoint::zero(), FloatPoint(30, 30), IntSize(10, 10), false); | 648 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, Fl
oatPoint::zero(), FloatPoint(30, 30), IntSize(10, 10), false); |
649 | 649 |
650 parent->addChild(renderSurface1); | 650 parent->addChild(renderSurface1); |
651 parent->setMasksToBounds(true); | 651 parent->setMasksToBounds(true); |
652 renderSurface1->addChild(child); | 652 renderSurface1->addChild(child); |
653 renderSurface1->setForceRenderSurface(true); | 653 renderSurface1->setForceRenderSurface(true); |
654 | 654 |
655 Vector<RefPtr<LayerChromium> > renderSurfaceLayerList; | 655 Vector<RefPtr<LayerChromium> > renderSurfaceLayerList; |
656 int dummyMaxTextureSize = 512; | 656 int dummyMaxTextureSize = 512; |
657 CCLayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(
), 1, dummyMaxTextureSize, renderSurfaceLayerList); | 657 CCLayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(
), 1, 1, dummyMaxTextureSize, renderSurfaceLayerList); |
658 CCLayerTreeHostCommon::calculateVisibleRects(renderSurfaceLayerList); | 658 CCLayerTreeHostCommon::calculateVisibleRects(renderSurfaceLayerList); |
659 | 659 |
660 // The child layer's content is entirely outside the parent's clip rect, so
the intermediate | 660 // The child layer's content is entirely outside the parent's clip rect, so
the intermediate |
661 // render surface should not be listed here, even if it was forced to be cre
ated. Render surfaces without children or visible | 661 // render surface should not be listed here, even if it was forced to be cre
ated. Render surfaces without children or visible |
662 // content are unexpected at draw time (e.g. we might try to create a conten
t texture of size 0). | 662 // content are unexpected at draw time (e.g. we might try to create a conten
t texture of size 0). |
663 ASSERT_TRUE(parent->renderSurface()); | 663 ASSERT_TRUE(parent->renderSurface()); |
664 ASSERT_FALSE(renderSurface1->renderSurface()); | 664 ASSERT_FALSE(renderSurface1->renderSurface()); |
665 EXPECT_EQ(1U, renderSurfaceLayerList.size()); | 665 EXPECT_EQ(1U, renderSurfaceLayerList.size()); |
666 } | 666 } |
667 | 667 |
668 TEST(CCLayerTreeHostCommonTest, verifyRenderSurfaceListForTransparentChild) | 668 TEST(CCLayerTreeHostCommonTest, verifyRenderSurfaceListForTransparentChild) |
669 { | 669 { |
670 RefPtr<LayerChromium> parent = LayerChromium::create(); | 670 RefPtr<LayerChromium> parent = LayerChromium::create(); |
671 RefPtr<LayerChromium> renderSurface1 = LayerChromium::create(); | 671 RefPtr<LayerChromium> renderSurface1 = LayerChromium::create(); |
672 RefPtr<LayerChromiumWithForcedDrawsContent> child = adoptRef(new LayerChromi
umWithForcedDrawsContent()); | 672 RefPtr<LayerChromiumWithForcedDrawsContent> child = adoptRef(new LayerChromi
umWithForcedDrawsContent()); |
673 | 673 |
674 const WebTransformationMatrix identityMatrix; | 674 const WebTransformationMatrix identityMatrix; |
675 setLayerPropertiesForTesting(renderSurface1.get(), identityMatrix, identityM
atrix, FloatPoint::zero(), FloatPoint::zero(), IntSize(10, 10), false); | 675 setLayerPropertiesForTesting(renderSurface1.get(), identityMatrix, identityM
atrix, FloatPoint::zero(), FloatPoint::zero(), IntSize(10, 10), false); |
676 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, Fl
oatPoint::zero(), FloatPoint::zero(), IntSize(10, 10), false); | 676 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, Fl
oatPoint::zero(), FloatPoint::zero(), IntSize(10, 10), false); |
677 | 677 |
678 parent->addChild(renderSurface1); | 678 parent->addChild(renderSurface1); |
679 renderSurface1->addChild(child); | 679 renderSurface1->addChild(child); |
680 renderSurface1->setForceRenderSurface(true); | 680 renderSurface1->setForceRenderSurface(true); |
681 renderSurface1->setOpacity(0); | 681 renderSurface1->setOpacity(0); |
682 | 682 |
683 Vector<RefPtr<LayerChromium> > renderSurfaceLayerList; | 683 Vector<RefPtr<LayerChromium> > renderSurfaceLayerList; |
684 int dummyMaxTextureSize = 512; | 684 int dummyMaxTextureSize = 512; |
685 CCLayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(
), 1, dummyMaxTextureSize, renderSurfaceLayerList); | 685 CCLayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(
), 1, 1, dummyMaxTextureSize, renderSurfaceLayerList); |
686 CCLayerTreeHostCommon::calculateVisibleRects(renderSurfaceLayerList); | 686 CCLayerTreeHostCommon::calculateVisibleRects(renderSurfaceLayerList); |
687 | 687 |
688 // Since the layer is transparent, renderSurface1->renderSurface() should no
t have gotten added anywhere. | 688 // Since the layer is transparent, renderSurface1->renderSurface() should no
t have gotten added anywhere. |
689 // Also, the drawable content rect should not have been extended by the chil
dren. | 689 // Also, the drawable content rect should not have been extended by the chil
dren. |
690 ASSERT_TRUE(parent->renderSurface()); | 690 ASSERT_TRUE(parent->renderSurface()); |
691 EXPECT_EQ(0U, parent->renderSurface()->layerList().size()); | 691 EXPECT_EQ(0U, parent->renderSurface()->layerList().size()); |
692 EXPECT_EQ(1U, renderSurfaceLayerList.size()); | 692 EXPECT_EQ(1U, renderSurfaceLayerList.size()); |
693 EXPECT_EQ(parent->id(), renderSurfaceLayerList[0]->id()); | 693 EXPECT_EQ(parent->id(), renderSurfaceLayerList[0]->id()); |
694 EXPECT_EQ(IntRect(), parent->drawableContentRect()); | 694 EXPECT_EQ(IntRect(), parent->drawableContentRect()); |
695 } | 695 } |
(...skipping 12 matching lines...) Expand all Loading... |
708 | 708 |
709 parent->addChild(renderSurface1); | 709 parent->addChild(renderSurface1); |
710 renderSurface1->addChild(child); | 710 renderSurface1->addChild(child); |
711 | 711 |
712 // Sanity check before the actual test | 712 // Sanity check before the actual test |
713 EXPECT_FALSE(parent->renderSurface()); | 713 EXPECT_FALSE(parent->renderSurface()); |
714 EXPECT_FALSE(renderSurface1->renderSurface()); | 714 EXPECT_FALSE(renderSurface1->renderSurface()); |
715 | 715 |
716 Vector<RefPtr<LayerChromium> > renderSurfaceLayerList; | 716 Vector<RefPtr<LayerChromium> > renderSurfaceLayerList; |
717 int dummyMaxTextureSize = 512; | 717 int dummyMaxTextureSize = 512; |
718 CCLayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(
), 1, dummyMaxTextureSize, renderSurfaceLayerList); | 718 CCLayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(
), 1, 1, dummyMaxTextureSize, renderSurfaceLayerList); |
719 | 719 |
720 // The root layer always creates a renderSurface | 720 // The root layer always creates a renderSurface |
721 EXPECT_TRUE(parent->renderSurface()); | 721 EXPECT_TRUE(parent->renderSurface()); |
722 EXPECT_TRUE(renderSurface1->renderSurface()); | 722 EXPECT_TRUE(renderSurface1->renderSurface()); |
723 EXPECT_EQ(2U, renderSurfaceLayerList.size()); | 723 EXPECT_EQ(2U, renderSurfaceLayerList.size()); |
724 | 724 |
725 renderSurfaceLayerList.clear(); | 725 renderSurfaceLayerList.clear(); |
726 renderSurface1->setForceRenderSurface(false); | 726 renderSurface1->setForceRenderSurface(false); |
727 CCLayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(
), 1, dummyMaxTextureSize, renderSurfaceLayerList); | 727 CCLayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(
), 1, 1, dummyMaxTextureSize, renderSurfaceLayerList); |
728 EXPECT_TRUE(parent->renderSurface()); | 728 EXPECT_TRUE(parent->renderSurface()); |
729 EXPECT_FALSE(renderSurface1->renderSurface()); | 729 EXPECT_FALSE(renderSurface1->renderSurface()); |
730 EXPECT_EQ(1U, renderSurfaceLayerList.size()); | 730 EXPECT_EQ(1U, renderSurfaceLayerList.size()); |
731 } | 731 } |
732 | 732 |
733 TEST(CCLayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerWit
hDirectContainer) | 733 TEST(CCLayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerWit
hDirectContainer) |
734 { | 734 { |
735 // This test checks for correct scroll compensation when the fixed-position
container | 735 // This test checks for correct scroll compensation when the fixed-position
container |
736 // is the direct parent of the fixed-position layer. | 736 // is the direct parent of the fixed-position layer. |
737 | 737 |
(...skipping 593 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1331 setLayerPropertiesForTesting(leafNode1.get(), identityMatrix, identityMatrix
, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(500, 500), false); | 1331 setLayerPropertiesForTesting(leafNode1.get(), identityMatrix, identityMatrix
, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(500, 500), false); |
1332 setLayerPropertiesForTesting(leafNode2.get(), identityMatrix, identityMatrix
, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(20, 20), false); | 1332 setLayerPropertiesForTesting(leafNode2.get(), identityMatrix, identityMatrix
, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(20, 20), false); |
1333 | 1333 |
1334 child->setMasksToBounds(true); | 1334 child->setMasksToBounds(true); |
1335 child->setOpacity(0.4f); | 1335 child->setOpacity(0.4f); |
1336 grandChild->setOpacity(0.5); | 1336 grandChild->setOpacity(0.5); |
1337 greatGrandChild->setOpacity(0.4f); | 1337 greatGrandChild->setOpacity(0.4f); |
1338 | 1338 |
1339 Vector<RefPtr<LayerChromium> > renderSurfaceLayerList; | 1339 Vector<RefPtr<LayerChromium> > renderSurfaceLayerList; |
1340 int dummyMaxTextureSize = 512; | 1340 int dummyMaxTextureSize = 512; |
1341 CCLayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(
), 1, dummyMaxTextureSize, renderSurfaceLayerList); | 1341 CCLayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(
), 1, 1, dummyMaxTextureSize, renderSurfaceLayerList); |
1342 CCLayerTreeHostCommon::calculateVisibleRects(renderSurfaceLayerList); | 1342 CCLayerTreeHostCommon::calculateVisibleRects(renderSurfaceLayerList); |
1343 | 1343 |
1344 | 1344 |
1345 ASSERT_EQ(2U, renderSurfaceLayerList.size()); | 1345 ASSERT_EQ(2U, renderSurfaceLayerList.size()); |
1346 EXPECT_EQ(parent->id(), renderSurfaceLayerList[0]->id()); | 1346 EXPECT_EQ(parent->id(), renderSurfaceLayerList[0]->id()); |
1347 EXPECT_EQ(child->id(), renderSurfaceLayerList[1]->id()); | 1347 EXPECT_EQ(child->id(), renderSurfaceLayerList[1]->id()); |
1348 } | 1348 } |
1349 | 1349 |
1350 TEST(CCLayerTreeHostCommonTest, verifyClipRectCullsSurfaceWithoutVisibleContent) | 1350 TEST(CCLayerTreeHostCommonTest, verifyClipRectCullsSurfaceWithoutVisibleContent) |
1351 { | 1351 { |
(...skipping 26 matching lines...) Expand all Loading... |
1378 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, Fl
oatPoint(0, 0), FloatPoint(0, 0), IntSize(20, 20), false); | 1378 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, Fl
oatPoint(0, 0), FloatPoint(0, 0), IntSize(20, 20), false); |
1379 setLayerPropertiesForTesting(grandChild.get(), identityMatrix, identityMatri
x, FloatPoint(0, 0), FloatPoint(200, 200), IntSize(10, 10), false); | 1379 setLayerPropertiesForTesting(grandChild.get(), identityMatrix, identityMatri
x, FloatPoint(0, 0), FloatPoint(200, 200), IntSize(10, 10), false); |
1380 setLayerPropertiesForTesting(leafNode.get(), identityMatrix, identityMatrix,
FloatPoint(0, 0), FloatPoint(0, 0), IntSize(10, 10), false); | 1380 setLayerPropertiesForTesting(leafNode.get(), identityMatrix, identityMatrix,
FloatPoint(0, 0), FloatPoint(0, 0), IntSize(10, 10), false); |
1381 | 1381 |
1382 parent->setMasksToBounds(true); | 1382 parent->setMasksToBounds(true); |
1383 child->setOpacity(0.4f); | 1383 child->setOpacity(0.4f); |
1384 grandChild->setOpacity(0.4f); | 1384 grandChild->setOpacity(0.4f); |
1385 | 1385 |
1386 Vector<RefPtr<LayerChromium> > renderSurfaceLayerList; | 1386 Vector<RefPtr<LayerChromium> > renderSurfaceLayerList; |
1387 int dummyMaxTextureSize = 512; | 1387 int dummyMaxTextureSize = 512; |
1388 CCLayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(
), 1, dummyMaxTextureSize, renderSurfaceLayerList); | 1388 CCLayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(
), 1, 1, dummyMaxTextureSize, renderSurfaceLayerList); |
1389 | 1389 |
1390 // Without an animation, we should cull child and grandChild from the render
SurfaceLayerList. | 1390 // Without an animation, we should cull child and grandChild from the render
SurfaceLayerList. |
1391 ASSERT_EQ(1U, renderSurfaceLayerList.size()); | 1391 ASSERT_EQ(1U, renderSurfaceLayerList.size()); |
1392 EXPECT_EQ(parent->id(), renderSurfaceLayerList[0]->id()); | 1392 EXPECT_EQ(parent->id(), renderSurfaceLayerList[0]->id()); |
1393 | 1393 |
1394 // Now put an animating transform on child. | 1394 // Now put an animating transform on child. |
1395 addAnimatedTransformToController(*child->layerAnimationController(), 10, 30,
0); | 1395 addAnimatedTransformToController(*child->layerAnimationController(), 10, 30,
0); |
1396 | 1396 |
1397 parent->clearRenderSurface(); | 1397 parent->clearRenderSurface(); |
1398 child->clearRenderSurface(); | 1398 child->clearRenderSurface(); |
1399 grandChild->clearRenderSurface(); | 1399 grandChild->clearRenderSurface(); |
1400 renderSurfaceLayerList.clear(); | 1400 renderSurfaceLayerList.clear(); |
1401 | 1401 |
1402 CCLayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(
), 1, dummyMaxTextureSize, renderSurfaceLayerList); | 1402 CCLayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(
), 1, 1, dummyMaxTextureSize, renderSurfaceLayerList); |
1403 | 1403 |
1404 // With an animating transform, we should keep child and grandChild in the r
enderSurfaceLayerList. | 1404 // With an animating transform, we should keep child and grandChild in the r
enderSurfaceLayerList. |
1405 ASSERT_EQ(3U, renderSurfaceLayerList.size()); | 1405 ASSERT_EQ(3U, renderSurfaceLayerList.size()); |
1406 EXPECT_EQ(parent->id(), renderSurfaceLayerList[0]->id()); | 1406 EXPECT_EQ(parent->id(), renderSurfaceLayerList[0]->id()); |
1407 EXPECT_EQ(child->id(), renderSurfaceLayerList[1]->id()); | 1407 EXPECT_EQ(child->id(), renderSurfaceLayerList[1]->id()); |
1408 EXPECT_EQ(grandChild->id(), renderSurfaceLayerList[2]->id()); | 1408 EXPECT_EQ(grandChild->id(), renderSurfaceLayerList[2]->id()); |
1409 } | 1409 } |
1410 | 1410 |
1411 TEST(CCLayerTreeHostCommonTest, verifyDrawableContentRectForLayers) | 1411 TEST(CCLayerTreeHostCommonTest, verifyDrawableContentRectForLayers) |
1412 { | 1412 { |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1444 | 1444 |
1445 // Force everyone to be a render surface. | 1445 // Force everyone to be a render surface. |
1446 child->setOpacity(0.4f); | 1446 child->setOpacity(0.4f); |
1447 grandChild1->setOpacity(0.5); | 1447 grandChild1->setOpacity(0.5); |
1448 grandChild2->setOpacity(0.5); | 1448 grandChild2->setOpacity(0.5); |
1449 grandChild3->setOpacity(0.5); | 1449 grandChild3->setOpacity(0.5); |
1450 grandChild4->setOpacity(0.5); | 1450 grandChild4->setOpacity(0.5); |
1451 | 1451 |
1452 Vector<RefPtr<LayerChromium> > renderSurfaceLayerList; | 1452 Vector<RefPtr<LayerChromium> > renderSurfaceLayerList; |
1453 int dummyMaxTextureSize = 512; | 1453 int dummyMaxTextureSize = 512; |
1454 CCLayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(
), 1, dummyMaxTextureSize, renderSurfaceLayerList); | 1454 CCLayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(
), 1, 1, dummyMaxTextureSize, renderSurfaceLayerList); |
1455 CCLayerTreeHostCommon::calculateVisibleRects(renderSurfaceLayerList); | 1455 CCLayerTreeHostCommon::calculateVisibleRects(renderSurfaceLayerList); |
1456 | 1456 |
1457 EXPECT_RECT_EQ(IntRect(IntPoint(5, 5), IntSize(10, 10)), grandChild1->drawab
leContentRect()); | 1457 EXPECT_RECT_EQ(IntRect(IntPoint(5, 5), IntSize(10, 10)), grandChild1->drawab
leContentRect()); |
1458 EXPECT_RECT_EQ(IntRect(IntPoint(15, 15), IntSize(5, 5)), grandChild3->drawab
leContentRect()); | 1458 EXPECT_RECT_EQ(IntRect(IntPoint(15, 15), IntSize(5, 5)), grandChild3->drawab
leContentRect()); |
1459 EXPECT_RECT_EQ(IntRect(IntPoint(15, 15), IntSize(5, 5)), grandChild3->drawab
leContentRect()); | 1459 EXPECT_RECT_EQ(IntRect(IntPoint(15, 15), IntSize(5, 5)), grandChild3->drawab
leContentRect()); |
1460 EXPECT_TRUE(grandChild4->drawableContentRect().isEmpty()); | 1460 EXPECT_TRUE(grandChild4->drawableContentRect().isEmpty()); |
1461 } | 1461 } |
1462 | 1462 |
1463 TEST(CCLayerTreeHostCommonTest, verifyClipRectIsPropagatedCorrectlyToSurfaces) | 1463 TEST(CCLayerTreeHostCommonTest, verifyClipRectIsPropagatedCorrectlyToSurfaces) |
1464 { | 1464 { |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1510 | 1510 |
1511 // Force everyone to be a render surface. | 1511 // Force everyone to be a render surface. |
1512 child->setOpacity(0.4f); | 1512 child->setOpacity(0.4f); |
1513 grandChild1->setOpacity(0.5); | 1513 grandChild1->setOpacity(0.5); |
1514 grandChild2->setOpacity(0.5); | 1514 grandChild2->setOpacity(0.5); |
1515 grandChild3->setOpacity(0.5); | 1515 grandChild3->setOpacity(0.5); |
1516 grandChild4->setOpacity(0.5); | 1516 grandChild4->setOpacity(0.5); |
1517 | 1517 |
1518 Vector<RefPtr<LayerChromium> > renderSurfaceLayerList; | 1518 Vector<RefPtr<LayerChromium> > renderSurfaceLayerList; |
1519 int dummyMaxTextureSize = 512; | 1519 int dummyMaxTextureSize = 512; |
1520 CCLayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(
), 1, dummyMaxTextureSize, renderSurfaceLayerList); | 1520 CCLayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(
), 1, 1, dummyMaxTextureSize, renderSurfaceLayerList); |
1521 CCLayerTreeHostCommon::calculateVisibleRects(renderSurfaceLayerList); | 1521 CCLayerTreeHostCommon::calculateVisibleRects(renderSurfaceLayerList); |
1522 | 1522 |
1523 ASSERT_TRUE(grandChild1->renderSurface()); | 1523 ASSERT_TRUE(grandChild1->renderSurface()); |
1524 ASSERT_TRUE(grandChild2->renderSurface()); | 1524 ASSERT_TRUE(grandChild2->renderSurface()); |
1525 ASSERT_TRUE(grandChild3->renderSurface()); | 1525 ASSERT_TRUE(grandChild3->renderSurface()); |
1526 EXPECT_FALSE(grandChild4->renderSurface()); // Because grandChild4 is entire
ly clipped, it is expected to not have a renderSurface. | 1526 EXPECT_FALSE(grandChild4->renderSurface()); // Because grandChild4 is entire
ly clipped, it is expected to not have a renderSurface. |
1527 | 1527 |
1528 // Surfaces are clipped by their parent, but un-affected by the owning layer
's masksToBounds. | 1528 // Surfaces are clipped by their parent, but un-affected by the owning layer
's masksToBounds. |
1529 EXPECT_RECT_EQ(IntRect(IntPoint(0, 0), IntSize(20, 20)), grandChild1->render
Surface()->clipRect()); | 1529 EXPECT_RECT_EQ(IntRect(IntPoint(0, 0), IntSize(20, 20)), grandChild1->render
Surface()->clipRect()); |
1530 EXPECT_RECT_EQ(IntRect(IntPoint(0, 0), IntSize(20, 20)), grandChild2->render
Surface()->clipRect()); | 1530 EXPECT_RECT_EQ(IntRect(IntPoint(0, 0), IntSize(20, 20)), grandChild2->render
Surface()->clipRect()); |
(...skipping 822 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2353 setLayerPropertiesForTesting(backFacingChild.get(), backfaceMatrix, identity
Matrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100), false); | 2353 setLayerPropertiesForTesting(backFacingChild.get(), backfaceMatrix, identity
Matrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100), false); |
2354 setLayerPropertiesForTesting(frontFacingSurface.get(), identityMatrix, ident
ityMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100), false); | 2354 setLayerPropertiesForTesting(frontFacingSurface.get(), identityMatrix, ident
ityMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100), false); |
2355 setLayerPropertiesForTesting(backFacingSurface.get(), backfaceMatrix, identi
tyMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100), false); | 2355 setLayerPropertiesForTesting(backFacingSurface.get(), backfaceMatrix, identi
tyMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100), false); |
2356 setLayerPropertiesForTesting(frontFacingChildOfFrontFacingSurface.get(), ide
ntityMatrix, identityMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 10
0), false); | 2356 setLayerPropertiesForTesting(frontFacingChildOfFrontFacingSurface.get(), ide
ntityMatrix, identityMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 10
0), false); |
2357 setLayerPropertiesForTesting(backFacingChildOfFrontFacingSurface.get(), back
faceMatrix, identityMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100
), false); | 2357 setLayerPropertiesForTesting(backFacingChildOfFrontFacingSurface.get(), back
faceMatrix, identityMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100
), false); |
2358 setLayerPropertiesForTesting(frontFacingChildOfBackFacingSurface.get(), iden
tityMatrix, identityMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100
), false); | 2358 setLayerPropertiesForTesting(frontFacingChildOfBackFacingSurface.get(), iden
tityMatrix, identityMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100
), false); |
2359 setLayerPropertiesForTesting(backFacingChildOfBackFacingSurface.get(), backf
aceMatrix, identityMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100)
, false); | 2359 setLayerPropertiesForTesting(backFacingChildOfBackFacingSurface.get(), backf
aceMatrix, identityMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100)
, false); |
2360 | 2360 |
2361 Vector<RefPtr<LayerChromium> > renderSurfaceLayerList; | 2361 Vector<RefPtr<LayerChromium> > renderSurfaceLayerList; |
2362 int dummyMaxTextureSize = 512; | 2362 int dummyMaxTextureSize = 512; |
2363 CCLayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(
), 1, dummyMaxTextureSize, renderSurfaceLayerList); | 2363 CCLayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(
), 1, 1, dummyMaxTextureSize, renderSurfaceLayerList); |
2364 | 2364 |
2365 // Verify which renderSurfaces were created. | 2365 // Verify which renderSurfaces were created. |
2366 EXPECT_FALSE(frontFacingChild->renderSurface()); | 2366 EXPECT_FALSE(frontFacingChild->renderSurface()); |
2367 EXPECT_FALSE(backFacingChild->renderSurface()); | 2367 EXPECT_FALSE(backFacingChild->renderSurface()); |
2368 EXPECT_TRUE(frontFacingSurface->renderSurface()); | 2368 EXPECT_TRUE(frontFacingSurface->renderSurface()); |
2369 EXPECT_TRUE(backFacingSurface->renderSurface()); | 2369 EXPECT_TRUE(backFacingSurface->renderSurface()); |
2370 EXPECT_FALSE(frontFacingChildOfFrontFacingSurface->renderSurface()); | 2370 EXPECT_FALSE(frontFacingChildOfFrontFacingSurface->renderSurface()); |
2371 EXPECT_FALSE(backFacingChildOfFrontFacingSurface->renderSurface()); | 2371 EXPECT_FALSE(backFacingChildOfFrontFacingSurface->renderSurface()); |
2372 EXPECT_FALSE(frontFacingChildOfBackFacingSurface->renderSurface()); | 2372 EXPECT_FALSE(frontFacingChildOfBackFacingSurface->renderSurface()); |
2373 EXPECT_FALSE(backFacingChildOfBackFacingSurface->renderSurface()); | 2373 EXPECT_FALSE(backFacingChildOfBackFacingSurface->renderSurface()); |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2452 setLayerPropertiesForTesting(backFacingChild.get(), backfaceMatrix, identity
Matrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100), false); | 2452 setLayerPropertiesForTesting(backFacingChild.get(), backfaceMatrix, identity
Matrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100), false); |
2453 setLayerPropertiesForTesting(frontFacingSurface.get(), identityMatrix, ident
ityMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100), true); // surf
ace transform style is preserve-3d. | 2453 setLayerPropertiesForTesting(frontFacingSurface.get(), identityMatrix, ident
ityMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100), true); // surf
ace transform style is preserve-3d. |
2454 setLayerPropertiesForTesting(backFacingSurface.get(), backfaceMatrix, identi
tyMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100), true); // surfa
ce transform style is preserve-3d. | 2454 setLayerPropertiesForTesting(backFacingSurface.get(), backfaceMatrix, identi
tyMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100), true); // surfa
ce transform style is preserve-3d. |
2455 setLayerPropertiesForTesting(frontFacingChildOfFrontFacingSurface.get(), ide
ntityMatrix, identityMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 10
0), false); | 2455 setLayerPropertiesForTesting(frontFacingChildOfFrontFacingSurface.get(), ide
ntityMatrix, identityMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 10
0), false); |
2456 setLayerPropertiesForTesting(backFacingChildOfFrontFacingSurface.get(), back
faceMatrix, identityMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100
), false); | 2456 setLayerPropertiesForTesting(backFacingChildOfFrontFacingSurface.get(), back
faceMatrix, identityMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100
), false); |
2457 setLayerPropertiesForTesting(frontFacingChildOfBackFacingSurface.get(), iden
tityMatrix, identityMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100
), false); | 2457 setLayerPropertiesForTesting(frontFacingChildOfBackFacingSurface.get(), iden
tityMatrix, identityMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100
), false); |
2458 setLayerPropertiesForTesting(backFacingChildOfBackFacingSurface.get(), backf
aceMatrix, identityMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100)
, false); | 2458 setLayerPropertiesForTesting(backFacingChildOfBackFacingSurface.get(), backf
aceMatrix, identityMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100)
, false); |
2459 | 2459 |
2460 Vector<RefPtr<LayerChromium> > renderSurfaceLayerList; | 2460 Vector<RefPtr<LayerChromium> > renderSurfaceLayerList; |
2461 int dummyMaxTextureSize = 512; | 2461 int dummyMaxTextureSize = 512; |
2462 CCLayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(
), 1, dummyMaxTextureSize, renderSurfaceLayerList); | 2462 CCLayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(
), 1, 1, dummyMaxTextureSize, renderSurfaceLayerList); |
2463 | 2463 |
2464 // Verify which renderSurfaces were created. | 2464 // Verify which renderSurfaces were created. |
2465 EXPECT_FALSE(frontFacingChild->renderSurface()); | 2465 EXPECT_FALSE(frontFacingChild->renderSurface()); |
2466 EXPECT_FALSE(backFacingChild->renderSurface()); | 2466 EXPECT_FALSE(backFacingChild->renderSurface()); |
2467 EXPECT_TRUE(frontFacingSurface->renderSurface()); | 2467 EXPECT_TRUE(frontFacingSurface->renderSurface()); |
2468 EXPECT_FALSE(backFacingSurface->renderSurface()); | 2468 EXPECT_FALSE(backFacingSurface->renderSurface()); |
2469 EXPECT_FALSE(frontFacingChildOfFrontFacingSurface->renderSurface()); | 2469 EXPECT_FALSE(frontFacingChildOfFrontFacingSurface->renderSurface()); |
2470 EXPECT_FALSE(backFacingChildOfFrontFacingSurface->renderSurface()); | 2470 EXPECT_FALSE(backFacingChildOfFrontFacingSurface->renderSurface()); |
2471 EXPECT_FALSE(frontFacingChildOfBackFacingSurface->renderSurface()); | 2471 EXPECT_FALSE(frontFacingChildOfBackFacingSurface->renderSurface()); |
2472 EXPECT_FALSE(backFacingChildOfBackFacingSurface->renderSurface()); | 2472 EXPECT_FALSE(backFacingChildOfBackFacingSurface->renderSurface()); |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2532 | 2532 |
2533 setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, F
loatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100), false); | 2533 setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, F
loatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100), false); |
2534 setLayerPropertiesForTesting(child.get(), backfaceMatrix, identityMatrix, Fl
oatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100), false); | 2534 setLayerPropertiesForTesting(child.get(), backfaceMatrix, identityMatrix, Fl
oatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100), false); |
2535 setLayerPropertiesForTesting(animatingSurface.get(), backfaceMatrix, identit
yMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100), false); | 2535 setLayerPropertiesForTesting(animatingSurface.get(), backfaceMatrix, identit
yMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100), false); |
2536 setLayerPropertiesForTesting(childOfAnimatingSurface.get(), backfaceMatrix,
identityMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100), false); | 2536 setLayerPropertiesForTesting(childOfAnimatingSurface.get(), backfaceMatrix,
identityMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100), false); |
2537 setLayerPropertiesForTesting(animatingChild.get(), backfaceMatrix, identityM
atrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100), false); | 2537 setLayerPropertiesForTesting(animatingChild.get(), backfaceMatrix, identityM
atrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100), false); |
2538 setLayerPropertiesForTesting(child2.get(), identityMatrix, identityMatrix, F
loatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100), false); | 2538 setLayerPropertiesForTesting(child2.get(), identityMatrix, identityMatrix, F
loatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100), false); |
2539 | 2539 |
2540 Vector<RefPtr<LayerChromium> > renderSurfaceLayerList; | 2540 Vector<RefPtr<LayerChromium> > renderSurfaceLayerList; |
2541 int dummyMaxTextureSize = 512; | 2541 int dummyMaxTextureSize = 512; |
2542 CCLayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(
), 1, dummyMaxTextureSize, renderSurfaceLayerList); | 2542 CCLayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(
), 1, 1, dummyMaxTextureSize, renderSurfaceLayerList); |
2543 CCLayerTreeHostCommon::calculateVisibleRects(renderSurfaceLayerList); | 2543 CCLayerTreeHostCommon::calculateVisibleRects(renderSurfaceLayerList); |
2544 | 2544 |
2545 EXPECT_FALSE(child->renderSurface()); | 2545 EXPECT_FALSE(child->renderSurface()); |
2546 EXPECT_TRUE(animatingSurface->renderSurface()); | 2546 EXPECT_TRUE(animatingSurface->renderSurface()); |
2547 EXPECT_FALSE(childOfAnimatingSurface->renderSurface()); | 2547 EXPECT_FALSE(childOfAnimatingSurface->renderSurface()); |
2548 EXPECT_FALSE(animatingChild->renderSurface()); | 2548 EXPECT_FALSE(animatingChild->renderSurface()); |
2549 EXPECT_FALSE(child2->renderSurface()); | 2549 EXPECT_FALSE(child2->renderSurface()); |
2550 | 2550 |
2551 // Verify that the animatingChild and childOfAnimatingSurface were not culle
d, but that child was. | 2551 // Verify that the animatingChild and childOfAnimatingSurface were not culle
d, but that child was. |
2552 ASSERT_EQ(2u, renderSurfaceLayerList.size()); | 2552 ASSERT_EQ(2u, renderSurfaceLayerList.size()); |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2599 backfaceMatrix.translate(-50, -50); | 2599 backfaceMatrix.translate(-50, -50); |
2600 | 2600 |
2601 setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, F
loatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100), true); // parent transform
style is preserve3d. | 2601 setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, F
loatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100), true); // parent transform
style is preserve3d. |
2602 setLayerPropertiesForTesting(frontFacingSurface.get(), identityMatrix, ident
ityMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100), false); // sur
face transform style is flat. | 2602 setLayerPropertiesForTesting(frontFacingSurface.get(), identityMatrix, ident
ityMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100), false); // sur
face transform style is flat. |
2603 setLayerPropertiesForTesting(backFacingSurface.get(), backfaceMatrix, ident
ityMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100), false); // sur
face transform style is flat. | 2603 setLayerPropertiesForTesting(backFacingSurface.get(), backfaceMatrix, ident
ityMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100), false); // sur
face transform style is flat. |
2604 setLayerPropertiesForTesting(child1.get(), identityMatrix, identityMatrix, F
loatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100), false); | 2604 setLayerPropertiesForTesting(child1.get(), identityMatrix, identityMatrix, F
loatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100), false); |
2605 setLayerPropertiesForTesting(child2.get(), identityMatrix, identityMatrix, F
loatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100), false); | 2605 setLayerPropertiesForTesting(child2.get(), identityMatrix, identityMatrix, F
loatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100), false); |
2606 | 2606 |
2607 Vector<RefPtr<LayerChromium> > renderSurfaceLayerList; | 2607 Vector<RefPtr<LayerChromium> > renderSurfaceLayerList; |
2608 int dummyMaxTextureSize = 512; | 2608 int dummyMaxTextureSize = 512; |
2609 CCLayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(
), 1, dummyMaxTextureSize, renderSurfaceLayerList); | 2609 CCLayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(
), 1, 1, dummyMaxTextureSize, renderSurfaceLayerList); |
2610 | 2610 |
2611 // Verify which renderSurfaces were created. | 2611 // Verify which renderSurfaces were created. |
2612 EXPECT_TRUE(frontFacingSurface->renderSurface()); | 2612 EXPECT_TRUE(frontFacingSurface->renderSurface()); |
2613 EXPECT_FALSE(backFacingSurface->renderSurface()); // because it should be cu
lled | 2613 EXPECT_FALSE(backFacingSurface->renderSurface()); // because it should be cu
lled |
2614 EXPECT_FALSE(child1->renderSurface()); | 2614 EXPECT_FALSE(child1->renderSurface()); |
2615 EXPECT_FALSE(child2->renderSurface()); | 2615 EXPECT_FALSE(child2->renderSurface()); |
2616 | 2616 |
2617 // Verify the renderSurfaceLayerList. The back-facing surface should be cull
ed. | 2617 // Verify the renderSurfaceLayerList. The back-facing surface should be cull
ed. |
2618 ASSERT_EQ(2u, renderSurfaceLayerList.size()); | 2618 ASSERT_EQ(2u, renderSurfaceLayerList.size()); |
2619 EXPECT_EQ(parent->id(), renderSurfaceLayerList[0]->id()); | 2619 EXPECT_EQ(parent->id(), renderSurfaceLayerList[0]->id()); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2653 | 2653 |
2654 WebTransformationMatrix identityMatrix; | 2654 WebTransformationMatrix identityMatrix; |
2655 FloatPoint anchor(0, 0); | 2655 FloatPoint anchor(0, 0); |
2656 FloatPoint position(0, 0); | 2656 FloatPoint position(0, 0); |
2657 IntSize bounds(100, 100); | 2657 IntSize bounds(100, 100); |
2658 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc
hor, position, bounds, false); | 2658 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc
hor, position, bounds, false); |
2659 root->setDrawsContent(true); | 2659 root->setDrawsContent(true); |
2660 | 2660 |
2661 Vector<CCLayerImpl*> renderSurfaceLayerList; | 2661 Vector<CCLayerImpl*> renderSurfaceLayerList; |
2662 int dummyMaxTextureSize = 512; | 2662 int dummyMaxTextureSize = 512; |
2663 CCLayerTreeHostCommon::calculateDrawTransforms(root.get(), root->bounds(), 1
, 0, dummyMaxTextureSize, renderSurfaceLayerList); | 2663 CCLayerTreeHostCommon::calculateDrawTransforms(root.get(), root->bounds(), 1
, 1, 0, dummyMaxTextureSize, renderSurfaceLayerList); |
2664 CCLayerTreeHostCommon::calculateVisibleRects(renderSurfaceLayerList); | 2664 CCLayerTreeHostCommon::calculateVisibleRects(renderSurfaceLayerList); |
2665 | 2665 |
2666 // Sanity check the scenario we just created. | 2666 // Sanity check the scenario we just created. |
2667 ASSERT_EQ(1u, renderSurfaceLayerList.size()); | 2667 ASSERT_EQ(1u, renderSurfaceLayerList.size()); |
2668 ASSERT_EQ(1u, root->renderSurface()->layerList().size()); | 2668 ASSERT_EQ(1u, root->renderSurface()->layerList().size()); |
2669 | 2669 |
2670 // Hit testing for a point outside the layer should return a null pointer. | 2670 // Hit testing for a point outside the layer should return a null pointer. |
2671 IntPoint testPoint(101, 101); | 2671 IntPoint testPoint(101, 101); |
2672 CCLayerImpl* resultLayer = CCLayerTreeHostCommon::findLayerThatIsHitByPoint(
testPoint, renderSurfaceLayerList); | 2672 CCLayerImpl* resultLayer = CCLayerTreeHostCommon::findLayerThatIsHitByPoint(
testPoint, renderSurfaceLayerList); |
2673 EXPECT_FALSE(resultLayer); | 2673 EXPECT_FALSE(resultLayer); |
(...skipping 29 matching lines...) Expand all Loading... |
2703 | 2703 |
2704 WebTransformationMatrix identityMatrix; | 2704 WebTransformationMatrix identityMatrix; |
2705 FloatPoint anchor(0, 0); | 2705 FloatPoint anchor(0, 0); |
2706 FloatPoint position(0, 0); | 2706 FloatPoint position(0, 0); |
2707 IntSize bounds(100, 100); | 2707 IntSize bounds(100, 100); |
2708 setLayerPropertiesForTesting(root.get(), uninvertibleTransform, identityMatr
ix, anchor, position, bounds, false); | 2708 setLayerPropertiesForTesting(root.get(), uninvertibleTransform, identityMatr
ix, anchor, position, bounds, false); |
2709 root->setDrawsContent(true); | 2709 root->setDrawsContent(true); |
2710 | 2710 |
2711 Vector<CCLayerImpl*> renderSurfaceLayerList; | 2711 Vector<CCLayerImpl*> renderSurfaceLayerList; |
2712 int dummyMaxTextureSize = 512; | 2712 int dummyMaxTextureSize = 512; |
2713 CCLayerTreeHostCommon::calculateDrawTransforms(root.get(), root->bounds(), 1
, 0, dummyMaxTextureSize, renderSurfaceLayerList); | 2713 CCLayerTreeHostCommon::calculateDrawTransforms(root.get(), root->bounds(), 1
, 1, 0, dummyMaxTextureSize, renderSurfaceLayerList); |
2714 CCLayerTreeHostCommon::calculateVisibleRects(renderSurfaceLayerList); | 2714 CCLayerTreeHostCommon::calculateVisibleRects(renderSurfaceLayerList); |
2715 | 2715 |
2716 // Sanity check the scenario we just created. | 2716 // Sanity check the scenario we just created. |
2717 ASSERT_EQ(1u, renderSurfaceLayerList.size()); | 2717 ASSERT_EQ(1u, renderSurfaceLayerList.size()); |
2718 ASSERT_EQ(1u, root->renderSurface()->layerList().size()); | 2718 ASSERT_EQ(1u, root->renderSurface()->layerList().size()); |
2719 ASSERT_FALSE(root->screenSpaceTransform().isInvertible()); | 2719 ASSERT_FALSE(root->screenSpaceTransform().isInvertible()); |
2720 | 2720 |
2721 // Hit testing any point should not hit the layer. If the invertible matrix
is | 2721 // Hit testing any point should not hit the layer. If the invertible matrix
is |
2722 // accidentally ignored and treated like an identity, then the hit testing w
ill | 2722 // accidentally ignored and treated like an identity, then the hit testing w
ill |
2723 // incorrectly hit the layer when it shouldn't. | 2723 // incorrectly hit the layer when it shouldn't. |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2758 | 2758 |
2759 WebTransformationMatrix identityMatrix; | 2759 WebTransformationMatrix identityMatrix; |
2760 FloatPoint anchor(0, 0); | 2760 FloatPoint anchor(0, 0); |
2761 FloatPoint position(50, 50); // this layer is positioned, and hit testing sh
ould correctly know where the layer is located. | 2761 FloatPoint position(50, 50); // this layer is positioned, and hit testing sh
ould correctly know where the layer is located. |
2762 IntSize bounds(100, 100); | 2762 IntSize bounds(100, 100); |
2763 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc
hor, position, bounds, false); | 2763 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc
hor, position, bounds, false); |
2764 root->setDrawsContent(true); | 2764 root->setDrawsContent(true); |
2765 | 2765 |
2766 Vector<CCLayerImpl*> renderSurfaceLayerList; | 2766 Vector<CCLayerImpl*> renderSurfaceLayerList; |
2767 int dummyMaxTextureSize = 512; | 2767 int dummyMaxTextureSize = 512; |
2768 CCLayerTreeHostCommon::calculateDrawTransforms(root.get(), root->bounds(), 1
, 0, dummyMaxTextureSize, renderSurfaceLayerList); | 2768 CCLayerTreeHostCommon::calculateDrawTransforms(root.get(), root->bounds(), 1
, 1, 0, dummyMaxTextureSize, renderSurfaceLayerList); |
2769 CCLayerTreeHostCommon::calculateVisibleRects(renderSurfaceLayerList); | 2769 CCLayerTreeHostCommon::calculateVisibleRects(renderSurfaceLayerList); |
2770 | 2770 |
2771 // Sanity check the scenario we just created. | 2771 // Sanity check the scenario we just created. |
2772 ASSERT_EQ(1u, renderSurfaceLayerList.size()); | 2772 ASSERT_EQ(1u, renderSurfaceLayerList.size()); |
2773 ASSERT_EQ(1u, root->renderSurface()->layerList().size()); | 2773 ASSERT_EQ(1u, root->renderSurface()->layerList().size()); |
2774 | 2774 |
2775 // Hit testing for a point outside the layer should return a null pointer. | 2775 // Hit testing for a point outside the layer should return a null pointer. |
2776 IntPoint testPoint(49, 49); | 2776 IntPoint testPoint(49, 49); |
2777 CCLayerImpl* resultLayer = CCLayerTreeHostCommon::findLayerThatIsHitByPoint(
testPoint, renderSurfaceLayerList); | 2777 CCLayerImpl* resultLayer = CCLayerTreeHostCommon::findLayerThatIsHitByPoint(
testPoint, renderSurfaceLayerList); |
2778 EXPECT_FALSE(resultLayer); | 2778 EXPECT_FALSE(resultLayer); |
(...skipping 27 matching lines...) Expand all Loading... |
2806 rotation45DegreesAboutCenter.rotate3d(0, 0, 45); | 2806 rotation45DegreesAboutCenter.rotate3d(0, 0, 45); |
2807 rotation45DegreesAboutCenter.translate(-50, -50); | 2807 rotation45DegreesAboutCenter.translate(-50, -50); |
2808 FloatPoint anchor(0, 0); | 2808 FloatPoint anchor(0, 0); |
2809 FloatPoint position(0, 0); | 2809 FloatPoint position(0, 0); |
2810 IntSize bounds(100, 100); | 2810 IntSize bounds(100, 100); |
2811 setLayerPropertiesForTesting(root.get(), rotation45DegreesAboutCenter, ident
ityMatrix, anchor, position, bounds, false); | 2811 setLayerPropertiesForTesting(root.get(), rotation45DegreesAboutCenter, ident
ityMatrix, anchor, position, bounds, false); |
2812 root->setDrawsContent(true); | 2812 root->setDrawsContent(true); |
2813 | 2813 |
2814 Vector<CCLayerImpl*> renderSurfaceLayerList; | 2814 Vector<CCLayerImpl*> renderSurfaceLayerList; |
2815 int dummyMaxTextureSize = 512; | 2815 int dummyMaxTextureSize = 512; |
2816 CCLayerTreeHostCommon::calculateDrawTransforms(root.get(), root->bounds(), 1
, 0, dummyMaxTextureSize, renderSurfaceLayerList); | 2816 CCLayerTreeHostCommon::calculateDrawTransforms(root.get(), root->bounds(), 1
, 1, 0, dummyMaxTextureSize, renderSurfaceLayerList); |
2817 CCLayerTreeHostCommon::calculateVisibleRects(renderSurfaceLayerList); | 2817 CCLayerTreeHostCommon::calculateVisibleRects(renderSurfaceLayerList); |
2818 | 2818 |
2819 // Sanity check the scenario we just created. | 2819 // Sanity check the scenario we just created. |
2820 ASSERT_EQ(1u, renderSurfaceLayerList.size()); | 2820 ASSERT_EQ(1u, renderSurfaceLayerList.size()); |
2821 ASSERT_EQ(1u, root->renderSurface()->layerList().size()); | 2821 ASSERT_EQ(1u, root->renderSurface()->layerList().size()); |
2822 | 2822 |
2823 // Hit testing for points outside the layer. | 2823 // Hit testing for points outside the layer. |
2824 // These corners would have been inside the un-transformed layer, but they s
hould not hit the correctly transformed layer. | 2824 // These corners would have been inside the un-transformed layer, but they s
hould not hit the correctly transformed layer. |
2825 IntPoint testPoint(99, 99); | 2825 IntPoint testPoint(99, 99); |
2826 CCLayerImpl* resultLayer = CCLayerTreeHostCommon::findLayerThatIsHitByPoint(
testPoint, renderSurfaceLayerList); | 2826 CCLayerImpl* resultLayer = CCLayerTreeHostCommon::findLayerThatIsHitByPoint(
testPoint, renderSurfaceLayerList); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2863 translationByZ.translate3d(0, 0, -1); | 2863 translationByZ.translate3d(0, 0, -1); |
2864 | 2864 |
2865 FloatPoint anchor(0, 0); | 2865 FloatPoint anchor(0, 0); |
2866 FloatPoint position(0, 0); | 2866 FloatPoint position(0, 0); |
2867 IntSize bounds(100, 100); | 2867 IntSize bounds(100, 100); |
2868 setLayerPropertiesForTesting(root.get(), perspectiveProjectionAboutCenter *
translationByZ, identityMatrix, anchor, position, bounds, false); | 2868 setLayerPropertiesForTesting(root.get(), perspectiveProjectionAboutCenter *
translationByZ, identityMatrix, anchor, position, bounds, false); |
2869 root->setDrawsContent(true); | 2869 root->setDrawsContent(true); |
2870 | 2870 |
2871 Vector<CCLayerImpl*> renderSurfaceLayerList; | 2871 Vector<CCLayerImpl*> renderSurfaceLayerList; |
2872 int dummyMaxTextureSize = 512; | 2872 int dummyMaxTextureSize = 512; |
2873 CCLayerTreeHostCommon::calculateDrawTransforms(root.get(), root->bounds(), 1
, 0, dummyMaxTextureSize, renderSurfaceLayerList); | 2873 CCLayerTreeHostCommon::calculateDrawTransforms(root.get(), root->bounds(), 1
, 1, 0, dummyMaxTextureSize, renderSurfaceLayerList); |
2874 CCLayerTreeHostCommon::calculateVisibleRects(renderSurfaceLayerList); | 2874 CCLayerTreeHostCommon::calculateVisibleRects(renderSurfaceLayerList); |
2875 | 2875 |
2876 // Sanity check the scenario we just created. | 2876 // Sanity check the scenario we just created. |
2877 ASSERT_EQ(1u, renderSurfaceLayerList.size()); | 2877 ASSERT_EQ(1u, renderSurfaceLayerList.size()); |
2878 ASSERT_EQ(1u, root->renderSurface()->layerList().size()); | 2878 ASSERT_EQ(1u, root->renderSurface()->layerList().size()); |
2879 | 2879 |
2880 // Hit testing for points outside the layer. | 2880 // Hit testing for points outside the layer. |
2881 // These corners would have been inside the un-transformed layer, but they s
hould not hit the correctly transformed layer. | 2881 // These corners would have been inside the un-transformed layer, but they s
hould not hit the correctly transformed layer. |
2882 IntPoint testPoint(24, 24); | 2882 IntPoint testPoint(24, 24); |
2883 CCLayerImpl* resultLayer = CCLayerTreeHostCommon::findLayerThatIsHitByPoint(
testPoint, renderSurfaceLayerList); | 2883 CCLayerImpl* resultLayer = CCLayerTreeHostCommon::findLayerThatIsHitByPoint(
testPoint, renderSurfaceLayerList); |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2928 | 2928 |
2929 // override contentBounds | 2929 // override contentBounds |
2930 testLayer->setContentBounds(IntSize(100, 100)); | 2930 testLayer->setContentBounds(IntSize(100, 100)); |
2931 | 2931 |
2932 testLayer->setDrawsContent(true); | 2932 testLayer->setDrawsContent(true); |
2933 root->addChild(testLayer.release()); | 2933 root->addChild(testLayer.release()); |
2934 } | 2934 } |
2935 | 2935 |
2936 Vector<CCLayerImpl*> renderSurfaceLayerList; | 2936 Vector<CCLayerImpl*> renderSurfaceLayerList; |
2937 int dummyMaxTextureSize = 512; | 2937 int dummyMaxTextureSize = 512; |
2938 CCLayerTreeHostCommon::calculateDrawTransforms(root.get(), root->bounds(), 1
, 0, dummyMaxTextureSize, renderSurfaceLayerList); | 2938 CCLayerTreeHostCommon::calculateDrawTransforms(root.get(), root->bounds(), 1
, 1, 0, dummyMaxTextureSize, renderSurfaceLayerList); |
2939 CCLayerTreeHostCommon::calculateVisibleRects(renderSurfaceLayerList); | 2939 CCLayerTreeHostCommon::calculateVisibleRects(renderSurfaceLayerList); |
2940 | 2940 |
2941 // Sanity check the scenario we just created. | 2941 // Sanity check the scenario we just created. |
2942 // The visibleContentRect for testLayer is actually 100x100, even though its
layout size is 50x50, positioned at 25x25. | 2942 // The visibleContentRect for testLayer is actually 100x100, even though its
layout size is 50x50, positioned at 25x25. |
2943 CCLayerImpl* testLayer = root->children()[0]; | 2943 CCLayerImpl* testLayer = root->children()[0]; |
2944 EXPECT_RECT_EQ(IntRect(IntPoint::zero(), IntSize(100, 100)), testLayer->visi
bleContentRect()); | 2944 EXPECT_RECT_EQ(IntRect(IntPoint::zero(), IntSize(100, 100)), testLayer->visi
bleContentRect()); |
2945 ASSERT_EQ(1u, renderSurfaceLayerList.size()); | 2945 ASSERT_EQ(1u, renderSurfaceLayerList.size()); |
2946 ASSERT_EQ(1u, root->renderSurface()->layerList().size()); | 2946 ASSERT_EQ(1u, root->renderSurface()->layerList().size()); |
2947 | 2947 |
2948 // 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). | 2948 // 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). |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2993 position = FloatPoint(-50, -50); | 2993 position = FloatPoint(-50, -50); |
2994 bounds = IntSize(300, 300); | 2994 bounds = IntSize(300, 300); |
2995 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix
, anchor, position, bounds, false); | 2995 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix
, anchor, position, bounds, false); |
2996 child->setDrawsContent(true); | 2996 child->setDrawsContent(true); |
2997 clippingLayer->addChild(child.release()); | 2997 clippingLayer->addChild(child.release()); |
2998 root->addChild(clippingLayer.release()); | 2998 root->addChild(clippingLayer.release()); |
2999 } | 2999 } |
3000 | 3000 |
3001 Vector<CCLayerImpl*> renderSurfaceLayerList; | 3001 Vector<CCLayerImpl*> renderSurfaceLayerList; |
3002 int dummyMaxTextureSize = 512; | 3002 int dummyMaxTextureSize = 512; |
3003 CCLayerTreeHostCommon::calculateDrawTransforms(root.get(), root->bounds(), 1
, 0, dummyMaxTextureSize, renderSurfaceLayerList); | 3003 CCLayerTreeHostCommon::calculateDrawTransforms(root.get(), root->bounds(), 1
, 1, 0, dummyMaxTextureSize, renderSurfaceLayerList); |
3004 CCLayerTreeHostCommon::calculateVisibleRects(renderSurfaceLayerList); | 3004 CCLayerTreeHostCommon::calculateVisibleRects(renderSurfaceLayerList); |
3005 | 3005 |
3006 // Sanity check the scenario we just created. | 3006 // Sanity check the scenario we just created. |
3007 ASSERT_EQ(1u, renderSurfaceLayerList.size()); | 3007 ASSERT_EQ(1u, renderSurfaceLayerList.size()); |
3008 ASSERT_EQ(1u, root->renderSurface()->layerList().size()); | 3008 ASSERT_EQ(1u, root->renderSurface()->layerList().size()); |
3009 ASSERT_EQ(456, root->renderSurface()->layerList()[0]->id()); | 3009 ASSERT_EQ(456, root->renderSurface()->layerList()[0]->id()); |
3010 | 3010 |
3011 // Hit testing for a point outside the layer should return a null pointer. | 3011 // Hit testing for a point outside the layer should return a null pointer. |
3012 // Despite the child layer being very large, it should be clipped to the roo
t layer's bounds. | 3012 // Despite the child layer being very large, it should be clipped to the roo
t layer's bounds. |
3013 IntPoint testPoint(24, 24); | 3013 IntPoint testPoint(24, 24); |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3084 setLayerPropertiesForTesting(rotatedLeaf.get(), rotatedLeafTransform, id
entityMatrix, anchor, position, bounds, false); | 3084 setLayerPropertiesForTesting(rotatedLeaf.get(), rotatedLeafTransform, id
entityMatrix, anchor, position, bounds, false); |
3085 rotatedLeaf->setDrawsContent(true); | 3085 rotatedLeaf->setDrawsContent(true); |
3086 | 3086 |
3087 grandChild->addChild(rotatedLeaf.release()); | 3087 grandChild->addChild(rotatedLeaf.release()); |
3088 child->addChild(grandChild.release()); | 3088 child->addChild(grandChild.release()); |
3089 root->addChild(child.release()); | 3089 root->addChild(child.release()); |
3090 } | 3090 } |
3091 | 3091 |
3092 Vector<CCLayerImpl*> renderSurfaceLayerList; | 3092 Vector<CCLayerImpl*> renderSurfaceLayerList; |
3093 int dummyMaxTextureSize = 512; | 3093 int dummyMaxTextureSize = 512; |
3094 CCLayerTreeHostCommon::calculateDrawTransforms(root.get(), root->bounds(), 1
, 0, dummyMaxTextureSize, renderSurfaceLayerList); | 3094 CCLayerTreeHostCommon::calculateDrawTransforms(root.get(), root->bounds(), 1
, 1, 0, dummyMaxTextureSize, renderSurfaceLayerList); |
3095 CCLayerTreeHostCommon::calculateVisibleRects(renderSurfaceLayerList); | 3095 CCLayerTreeHostCommon::calculateVisibleRects(renderSurfaceLayerList); |
3096 | 3096 |
3097 // Sanity check the scenario we just created. | 3097 // Sanity check the scenario we just created. |
3098 // The grandChild is expected to create a renderSurface because it masksToBo
unds and is not axis aligned. | 3098 // The grandChild is expected to create a renderSurface because it masksToBo
unds and is not axis aligned. |
3099 ASSERT_EQ(2u, renderSurfaceLayerList.size()); | 3099 ASSERT_EQ(2u, renderSurfaceLayerList.size()); |
3100 ASSERT_EQ(1u, renderSurfaceLayerList[0]->renderSurface()->layerList().size()
); | 3100 ASSERT_EQ(1u, renderSurfaceLayerList[0]->renderSurface()->layerList().size()
); |
3101 ASSERT_EQ(789, renderSurfaceLayerList[0]->renderSurface()->layerList()[0]->i
d()); // grandChild's surface. | 3101 ASSERT_EQ(789, renderSurfaceLayerList[0]->renderSurface()->layerList()[0]->i
d()); // grandChild's surface. |
3102 ASSERT_EQ(1u, renderSurfaceLayerList[1]->renderSurface()->layerList().size()
); | 3102 ASSERT_EQ(1u, renderSurfaceLayerList[1]->renderSurface()->layerList().size()
); |
3103 ASSERT_EQ(2468, renderSurfaceLayerList[1]->renderSurface()->layerList()[0]->
id()); | 3103 ASSERT_EQ(2468, renderSurfaceLayerList[1]->renderSurface()->layerList()[0]->
id()); |
3104 | 3104 |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3167 position = FloatPoint(60, 60); // 70, 70 in screen space | 3167 position = FloatPoint(60, 60); // 70, 70 in screen space |
3168 bounds = IntSize(20, 20); | 3168 bounds = IntSize(20, 20); |
3169 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix
, anchor, position, bounds, false); | 3169 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix
, anchor, position, bounds, false); |
3170 child->setDrawsContent(true); | 3170 child->setDrawsContent(true); |
3171 intermediateLayer->addChild(child.release()); | 3171 intermediateLayer->addChild(child.release()); |
3172 root->addChild(intermediateLayer.release()); | 3172 root->addChild(intermediateLayer.release()); |
3173 } | 3173 } |
3174 | 3174 |
3175 Vector<CCLayerImpl*> renderSurfaceLayerList; | 3175 Vector<CCLayerImpl*> renderSurfaceLayerList; |
3176 int dummyMaxTextureSize = 512; | 3176 int dummyMaxTextureSize = 512; |
3177 CCLayerTreeHostCommon::calculateDrawTransforms(root.get(), root->bounds(), 1
, 0, dummyMaxTextureSize, renderSurfaceLayerList); | 3177 CCLayerTreeHostCommon::calculateDrawTransforms(root.get(), root->bounds(), 1
, 1, 0, dummyMaxTextureSize, renderSurfaceLayerList); |
3178 CCLayerTreeHostCommon::calculateVisibleRects(renderSurfaceLayerList); | 3178 CCLayerTreeHostCommon::calculateVisibleRects(renderSurfaceLayerList); |
3179 | 3179 |
3180 // Sanity check the scenario we just created. | 3180 // Sanity check the scenario we just created. |
3181 ASSERT_EQ(1u, renderSurfaceLayerList.size()); | 3181 ASSERT_EQ(1u, renderSurfaceLayerList.size()); |
3182 ASSERT_EQ(1u, root->renderSurface()->layerList().size()); | 3182 ASSERT_EQ(1u, root->renderSurface()->layerList().size()); |
3183 ASSERT_EQ(456, root->renderSurface()->layerList()[0]->id()); | 3183 ASSERT_EQ(456, root->renderSurface()->layerList()[0]->id()); |
3184 | 3184 |
3185 // Hit testing for a point outside the layer should return a null pointer. | 3185 // Hit testing for a point outside the layer should return a null pointer. |
3186 IntPoint testPoint(69, 69); | 3186 IntPoint testPoint(69, 69); |
3187 CCLayerImpl* resultLayer = CCLayerTreeHostCommon::findLayerThatIsHitByPoint(
testPoint, renderSurfaceLayerList); | 3187 CCLayerImpl* resultLayer = CCLayerTreeHostCommon::findLayerThatIsHitByPoint(
testPoint, renderSurfaceLayerList); |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3248 root->addChild(child1.release()); | 3248 root->addChild(child1.release()); |
3249 root->addChild(child2.release()); | 3249 root->addChild(child2.release()); |
3250 } | 3250 } |
3251 | 3251 |
3252 CCLayerImpl* child1 = root->children()[0]; | 3252 CCLayerImpl* child1 = root->children()[0]; |
3253 CCLayerImpl* child2 = root->children()[1]; | 3253 CCLayerImpl* child2 = root->children()[1]; |
3254 CCLayerImpl* grandChild1 = child1->children()[0]; | 3254 CCLayerImpl* grandChild1 = child1->children()[0]; |
3255 | 3255 |
3256 Vector<CCLayerImpl*> renderSurfaceLayerList; | 3256 Vector<CCLayerImpl*> renderSurfaceLayerList; |
3257 int dummyMaxTextureSize = 512; | 3257 int dummyMaxTextureSize = 512; |
3258 CCLayerTreeHostCommon::calculateDrawTransforms(root.get(), root->bounds(), 1
, 0, dummyMaxTextureSize, renderSurfaceLayerList); | 3258 CCLayerTreeHostCommon::calculateDrawTransforms(root.get(), root->bounds(), 1
, 1, 0, dummyMaxTextureSize, renderSurfaceLayerList); |
3259 CCLayerTreeHostCommon::calculateVisibleRects(renderSurfaceLayerList); | 3259 CCLayerTreeHostCommon::calculateVisibleRects(renderSurfaceLayerList); |
3260 | 3260 |
3261 // Sanity check the scenario we just created. | 3261 // Sanity check the scenario we just created. |
3262 ASSERT_TRUE(child1); | 3262 ASSERT_TRUE(child1); |
3263 ASSERT_TRUE(child2); | 3263 ASSERT_TRUE(child2); |
3264 ASSERT_TRUE(grandChild1); | 3264 ASSERT_TRUE(grandChild1); |
3265 ASSERT_EQ(1u, renderSurfaceLayerList.size()); | 3265 ASSERT_EQ(1u, renderSurfaceLayerList.size()); |
3266 ASSERT_EQ(4u, root->renderSurface()->layerList().size()); | 3266 ASSERT_EQ(4u, root->renderSurface()->layerList().size()); |
3267 ASSERT_EQ(1, root->renderSurface()->layerList()[0]->id()); // root layer | 3267 ASSERT_EQ(1, root->renderSurface()->layerList()[0]->id()); // root layer |
3268 ASSERT_EQ(2, root->renderSurface()->layerList()[1]->id()); // child1 | 3268 ASSERT_EQ(2, root->renderSurface()->layerList()[1]->id()); // child1 |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3357 root->addChild(child1.release()); | 3357 root->addChild(child1.release()); |
3358 root->addChild(child2.release()); | 3358 root->addChild(child2.release()); |
3359 } | 3359 } |
3360 | 3360 |
3361 CCLayerImpl* child1 = root->children()[0]; | 3361 CCLayerImpl* child1 = root->children()[0]; |
3362 CCLayerImpl* child2 = root->children()[1]; | 3362 CCLayerImpl* child2 = root->children()[1]; |
3363 CCLayerImpl* grandChild1 = child1->children()[0]; | 3363 CCLayerImpl* grandChild1 = child1->children()[0]; |
3364 | 3364 |
3365 Vector<CCLayerImpl*> renderSurfaceLayerList; | 3365 Vector<CCLayerImpl*> renderSurfaceLayerList; |
3366 int dummyMaxTextureSize = 512; | 3366 int dummyMaxTextureSize = 512; |
3367 CCLayerTreeHostCommon::calculateDrawTransforms(root.get(), root->bounds(), 1
, 0, dummyMaxTextureSize, renderSurfaceLayerList); | 3367 CCLayerTreeHostCommon::calculateDrawTransforms(root.get(), root->bounds(), 1
, 1, 0, dummyMaxTextureSize, renderSurfaceLayerList); |
3368 CCLayerTreeHostCommon::calculateVisibleRects(renderSurfaceLayerList); | 3368 CCLayerTreeHostCommon::calculateVisibleRects(renderSurfaceLayerList); |
3369 | 3369 |
3370 // Sanity check the scenario we just created. | 3370 // Sanity check the scenario we just created. |
3371 ASSERT_TRUE(child1); | 3371 ASSERT_TRUE(child1); |
3372 ASSERT_TRUE(child2); | 3372 ASSERT_TRUE(child2); |
3373 ASSERT_TRUE(grandChild1); | 3373 ASSERT_TRUE(grandChild1); |
3374 ASSERT_TRUE(child1->renderSurface()); | 3374 ASSERT_TRUE(child1->renderSurface()); |
3375 ASSERT_TRUE(child2->renderSurface()); | 3375 ASSERT_TRUE(child2->renderSurface()); |
3376 ASSERT_TRUE(grandChild1->renderSurface()); | 3376 ASSERT_TRUE(grandChild1->renderSurface()); |
3377 ASSERT_EQ(4u, renderSurfaceLayerList.size()); | 3377 ASSERT_EQ(4u, renderSurfaceLayerList.size()); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3414 ASSERT_TRUE(resultLayer); | 3414 ASSERT_TRUE(resultLayer); |
3415 EXPECT_EQ(3, resultLayer->id()); | 3415 EXPECT_EQ(3, resultLayer->id()); |
3416 | 3416 |
3417 // At (20, 51), child1 and grandChild1 overlap. grandChild1 is expected to b
e on top. | 3417 // At (20, 51), child1 and grandChild1 overlap. grandChild1 is expected to b
e on top. |
3418 testPoint = IntPoint(20, 51); | 3418 testPoint = IntPoint(20, 51); |
3419 resultLayer = CCLayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, re
nderSurfaceLayerList); | 3419 resultLayer = CCLayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, re
nderSurfaceLayerList); |
3420 ASSERT_TRUE(resultLayer); | 3420 ASSERT_TRUE(resultLayer); |
3421 EXPECT_EQ(4, resultLayer->id()); | 3421 EXPECT_EQ(4, resultLayer->id()); |
3422 } | 3422 } |
3423 | 3423 |
| 3424 class NoScaleContentLayerChromium : public ContentLayerChromium |
| 3425 { |
| 3426 public: |
| 3427 static PassRefPtr<NoScaleContentLayerChromium> create(ContentLayerChromiumCl
ient* client) { return adoptRef(new NoScaleContentLayerChromium(client)); } |
| 3428 virtual ~NoScaleContentLayerChromium() { } |
| 3429 |
| 3430 virtual bool needsContentsScale() const OVERRIDE { return false; } |
| 3431 |
| 3432 protected: |
| 3433 explicit NoScaleContentLayerChromium(ContentLayerChromiumClient* client) : C
ontentLayerChromium(client) { } |
| 3434 }; |
| 3435 |
| 3436 PassRefPtr<NoScaleContentLayerChromium> createNoScaleDrawableContentLayerChromiu
m(ContentLayerChromiumClient* delegate) |
| 3437 { |
| 3438 RefPtr<NoScaleContentLayerChromium> toReturn = NoScaleContentLayerChromium::
create(delegate); |
| 3439 toReturn->setIsDrawable(true); |
| 3440 return toReturn.release(); |
| 3441 } |
| 3442 |
3424 TEST(CCLayerTreeHostCommonTest, verifyLayerTransformsInHighDPI) | 3443 TEST(CCLayerTreeHostCommonTest, verifyLayerTransformsInHighDPI) |
3425 { | 3444 { |
3426 // Verify draw and screen space transforms of layers not in a surface. | 3445 // Verify draw and screen space transforms of layers not in a surface. |
3427 MockContentLayerChromiumClient delegate; | 3446 MockContentLayerChromiumClient delegate; |
3428 WebTransformationMatrix identityMatrix; | 3447 WebTransformationMatrix identityMatrix; |
3429 | 3448 |
3430 RefPtr<ContentLayerChromium> parent = createDrawableContentLayerChromium(&de
legate); | 3449 RefPtr<ContentLayerChromium> parent = createDrawableContentLayerChromium(&de
legate); |
3431 setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, F
loatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100), true); | 3450 setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, F
loatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100), true); |
3432 | 3451 |
3433 RefPtr<ContentLayerChromium> child = createDrawableContentLayerChromium(&del
egate); | 3452 RefPtr<ContentLayerChromium> child = createDrawableContentLayerChromium(&del
egate); |
3434 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, Fl
oatPoint(0, 0), FloatPoint(2, 2), IntSize(10, 10), true); | 3453 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, Fl
oatPoint(0, 0), FloatPoint(2, 2), IntSize(10, 10), true); |
3435 | 3454 |
3436 RefPtr<ContentLayerChromium> childNoScale = createDrawableContentLayerChromi
um(&delegate); | 3455 RefPtr<NoScaleContentLayerChromium> childNoScale = createNoScaleDrawableCont
entLayerChromium(&delegate); |
3437 setLayerPropertiesForTesting(childNoScale.get(), identityMatrix, identityMat
rix, FloatPoint(0, 0), FloatPoint(2, 2), IntSize(10, 10), true); | 3456 setLayerPropertiesForTesting(childNoScale.get(), identityMatrix, identityMat
rix, FloatPoint(0, 0), FloatPoint(2, 2), IntSize(10, 10), true); |
3438 | 3457 |
3439 parent->addChild(child); | 3458 parent->addChild(child); |
3440 parent->addChild(childNoScale); | 3459 parent->addChild(childNoScale); |
3441 | 3460 |
3442 Vector<RefPtr<LayerChromium> > renderSurfaceLayerList; | 3461 Vector<RefPtr<LayerChromium> > renderSurfaceLayerList; |
3443 int dummyMaxTextureSize = 512; | 3462 int dummyMaxTextureSize = 512; |
3444 | 3463 |
3445 const double deviceScaleFactor = 2.5; | 3464 const double deviceScaleFactor = 2.5; |
3446 parent->setContentsScale(deviceScaleFactor); | 3465 const double pageScaleFactor = 1; |
3447 child->setContentsScale(deviceScaleFactor); | |
3448 EXPECT_EQ(childNoScale->contentsScale(), 1); | |
3449 | 3466 |
3450 CCLayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(
), deviceScaleFactor, dummyMaxTextureSize, renderSurfaceLayerList); | 3467 CCLayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(
), deviceScaleFactor, pageScaleFactor, dummyMaxTextureSize, renderSurfaceLayerLi
st); |
| 3468 |
| 3469 EXPECT_EQ(deviceScaleFactor * pageScaleFactor, parent->contentsScale()); |
| 3470 EXPECT_EQ(deviceScaleFactor * pageScaleFactor, child->contentsScale()); |
| 3471 EXPECT_EQ(1, childNoScale->contentsScale()); |
3451 | 3472 |
3452 EXPECT_EQ(1u, renderSurfaceLayerList.size()); | 3473 EXPECT_EQ(1u, renderSurfaceLayerList.size()); |
3453 | 3474 |
3454 // Verify parent transforms | 3475 // Verify parent transforms |
3455 WebTransformationMatrix expectedParentTransform; | 3476 WebTransformationMatrix expectedParentTransform; |
3456 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedParentTransform, parent->screenSpace
Transform()); | 3477 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedParentTransform, parent->screenSpace
Transform()); |
3457 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedParentTransform, parent->drawTransfo
rm()); | 3478 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedParentTransform, parent->drawTransfo
rm()); |
3458 | 3479 |
3459 // Verify results of transformed parent rects | 3480 // Verify results of transformed parent rects |
3460 FloatRect parentContentBounds(FloatPoint(), FloatSize(parent->contentBounds(
))); | 3481 FloatRect parentContentBounds(FloatPoint(), FloatSize(parent->contentBounds(
))); |
(...skipping 26 matching lines...) Expand all Loading... |
3487 | 3508 |
3488 // Verify childNoScale transforms | 3509 // Verify childNoScale transforms |
3489 WebTransformationMatrix expectedChildNoScaleTransform = child->drawTransform
(); | 3510 WebTransformationMatrix expectedChildNoScaleTransform = child->drawTransform
(); |
3490 // All transforms operate on content rects. The child's content rect | 3511 // All transforms operate on content rects. The child's content rect |
3491 // incorporates device scale, but the childNoScale does not; add it here. | 3512 // incorporates device scale, but the childNoScale does not; add it here. |
3492 expectedChildNoScaleTransform.scale(deviceScaleFactor); | 3513 expectedChildNoScaleTransform.scale(deviceScaleFactor); |
3493 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildNoScaleTransform, childNoScale-
>drawTransform()); | 3514 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildNoScaleTransform, childNoScale-
>drawTransform()); |
3494 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildNoScaleTransform, childNoScale-
>screenSpaceTransform()); | 3515 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildNoScaleTransform, childNoScale-
>screenSpaceTransform()); |
3495 } | 3516 } |
3496 | 3517 |
| 3518 TEST(CCLayerTreeHostCommonTest, verifyContentsScale) |
| 3519 { |
| 3520 MockContentLayerChromiumClient delegate; |
| 3521 WebTransformationMatrix identityMatrix; |
| 3522 |
| 3523 WebTransformationMatrix parentScaleMatrix; |
| 3524 const double initialParentScale = 1.75; |
| 3525 parentScaleMatrix.scale(initialParentScale); |
| 3526 |
| 3527 WebTransformationMatrix childScaleMatrix; |
| 3528 const double initialChildScale = 1.25; |
| 3529 childScaleMatrix.scale(initialChildScale); |
| 3530 |
| 3531 RefPtr<ContentLayerChromium> parent = createDrawableContentLayerChromium(&de
legate); |
| 3532 setLayerPropertiesForTesting(parent.get(), parentScaleMatrix, identityMatrix
, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100), true); |
| 3533 |
| 3534 RefPtr<ContentLayerChromium> childScale = createDrawableContentLayerChromium
(&delegate); |
| 3535 setLayerPropertiesForTesting(childScale.get(), childScaleMatrix, identityMat
rix, FloatPoint(0, 0), FloatPoint(2, 2), IntSize(10, 10), true); |
| 3536 |
| 3537 RefPtr<NoScaleContentLayerChromium> childNoScale = createNoScaleDrawableCont
entLayerChromium(&delegate); |
| 3538 setLayerPropertiesForTesting(childNoScale.get(), childScaleMatrix, identityM
atrix, FloatPoint(0, 0), FloatPoint(12, 12), IntSize(10, 10), true); |
| 3539 |
| 3540 // FIXME: Remove this when pageScaleFactor is applied in the compositor. |
| 3541 // Page scale should not apply to the parent. |
| 3542 parent->setBoundsContainPageScale(true); |
| 3543 |
| 3544 parent->addChild(childScale); |
| 3545 parent->addChild(childNoScale); |
| 3546 |
| 3547 Vector<RefPtr<LayerChromium> > renderSurfaceLayerList; |
| 3548 int dummyMaxTextureSize = 512; |
| 3549 |
| 3550 double deviceScaleFactor = 2.5; |
| 3551 double pageScaleFactor = 1.5; |
| 3552 |
| 3553 // FIXME: Remove this when pageScaleFactor is applied in the compositor. |
| 3554 WebTransformationMatrix pageScaleMatrix; |
| 3555 pageScaleMatrix.scale(pageScaleFactor); |
| 3556 parent->setSublayerTransform(pageScaleMatrix); |
| 3557 |
| 3558 CCLayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(
), deviceScaleFactor, pageScaleFactor, dummyMaxTextureSize, renderSurfaceLayerLi
st); |
| 3559 |
| 3560 EXPECT_FLOAT_EQ(deviceScaleFactor * initialParentScale, parent->contentsScal
e()); |
| 3561 EXPECT_FLOAT_EQ(deviceScaleFactor * pageScaleFactor * initialParentScale * i
nitialChildScale, childScale->contentsScale()); |
| 3562 EXPECT_FLOAT_EQ(1, childNoScale->contentsScale()); |
| 3563 |
| 3564 // The parent is scaled up and shouldn't need to scale during draw. The chil
d that can scale its contents should |
| 3565 // also not need to scale during draw. The other should. |
| 3566 // There is some rounding error due to contentBounds being a rounded integer
. |
| 3567 EXPECT_NEAR(parent->drawTransform().m11(), 1, 0.01); |
| 3568 EXPECT_NEAR(parent->drawTransform().m22(), 1, 0.01); |
| 3569 EXPECT_NEAR(childScale->drawTransform().m11(), 1, 0.01); |
| 3570 EXPECT_NEAR(childScale->drawTransform().m22(), 1, 0.01); |
| 3571 EXPECT_FLOAT_EQ(deviceScaleFactor * pageScaleFactor * initialParentScale * i
nitialChildScale, childNoScale->drawTransform().m11()); |
| 3572 EXPECT_FLOAT_EQ(deviceScaleFactor * pageScaleFactor * initialParentScale * i
nitialChildScale, childNoScale->drawTransform().m22()); |
| 3573 |
| 3574 // If the transform changes, we expect the contentsScale to remain unchanged
. |
| 3575 childScale->setTransform(identityMatrix); |
| 3576 |
| 3577 renderSurfaceLayerList.clear(); |
| 3578 CCLayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(
), deviceScaleFactor, pageScaleFactor, dummyMaxTextureSize, renderSurfaceLayerLi
st); |
| 3579 |
| 3580 EXPECT_FLOAT_EQ(deviceScaleFactor * initialParentScale, parent->contentsScal
e()); |
| 3581 EXPECT_FLOAT_EQ(deviceScaleFactor * pageScaleFactor * initialParentScale * i
nitialChildScale, childScale->contentsScale()); |
| 3582 EXPECT_FLOAT_EQ(1, childNoScale->contentsScale()); |
| 3583 |
| 3584 // But if the deviceScaleFactor or pageScaleFactor changes, then it should b
e updated, but using the initial transform. |
| 3585 deviceScaleFactor = 2.25; |
| 3586 pageScaleFactor = 1.25; |
| 3587 |
| 3588 // FIXME: Remove this when pageScaleFactor is applied in the compositor. |
| 3589 pageScaleMatrix = identityMatrix; |
| 3590 pageScaleMatrix.scale(pageScaleFactor); |
| 3591 parent->setSublayerTransform(pageScaleMatrix); |
| 3592 |
| 3593 renderSurfaceLayerList.clear(); |
| 3594 CCLayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(
), deviceScaleFactor, pageScaleFactor, dummyMaxTextureSize, renderSurfaceLayerLi
st); |
| 3595 |
| 3596 EXPECT_FLOAT_EQ(deviceScaleFactor * initialParentScale, parent->contentsScal
e()); |
| 3597 EXPECT_FLOAT_EQ(deviceScaleFactor * pageScaleFactor * initialParentScale * i
nitialChildScale, childScale->contentsScale()); |
| 3598 EXPECT_FLOAT_EQ(1, childNoScale->contentsScale()); |
| 3599 } |
| 3600 |
| 3601 TEST(CCLayerTreeHostCommonTest, verifyContentsScaleForSurfaces) |
| 3602 { |
| 3603 MockContentLayerChromiumClient delegate; |
| 3604 WebTransformationMatrix identityMatrix; |
| 3605 |
| 3606 WebTransformationMatrix parentScaleMatrix; |
| 3607 const double initialParentScale = 2; |
| 3608 parentScaleMatrix.scale(initialParentScale); |
| 3609 |
| 3610 WebTransformationMatrix childScaleMatrix; |
| 3611 const double initialChildScale = 3; |
| 3612 childScaleMatrix.scale(initialChildScale); |
| 3613 |
| 3614 RefPtr<ContentLayerChromium> parent = createDrawableContentLayerChromium(&de
legate); |
| 3615 setLayerPropertiesForTesting(parent.get(), parentScaleMatrix, identityMatrix
, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100), true); |
| 3616 |
| 3617 RefPtr<ContentLayerChromium> surfaceScale = createDrawableContentLayerChromi
um(&delegate); |
| 3618 setLayerPropertiesForTesting(surfaceScale.get(), childScaleMatrix, identityM
atrix, FloatPoint(0, 0), FloatPoint(2, 2), IntSize(10, 10), true); |
| 3619 |
| 3620 RefPtr<ContentLayerChromium> surfaceScaleChildScale = createDrawableContentL
ayerChromium(&delegate); |
| 3621 setLayerPropertiesForTesting(surfaceScaleChildScale.get(), childScaleMatrix,
identityMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(10, 10), true); |
| 3622 |
| 3623 RefPtr<NoScaleContentLayerChromium> surfaceScaleChildNoScale = createNoScale
DrawableContentLayerChromium(&delegate); |
| 3624 setLayerPropertiesForTesting(surfaceScaleChildNoScale.get(), childScaleMatri
x, identityMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(10, 10), true); |
| 3625 |
| 3626 RefPtr<NoScaleContentLayerChromium> surfaceNoScale = createNoScaleDrawableCo
ntentLayerChromium(&delegate); |
| 3627 setLayerPropertiesForTesting(surfaceNoScale.get(), childScaleMatrix, identit
yMatrix, FloatPoint(0, 0), FloatPoint(12, 12), IntSize(10, 10), true); |
| 3628 |
| 3629 RefPtr<ContentLayerChromium> surfaceNoScaleChildScale = createDrawableConten
tLayerChromium(&delegate); |
| 3630 setLayerPropertiesForTesting(surfaceNoScaleChildScale.get(), childScaleMatri
x, identityMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(10, 10), true); |
| 3631 |
| 3632 RefPtr<NoScaleContentLayerChromium> surfaceNoScaleChildNoScale = createNoSca
leDrawableContentLayerChromium(&delegate); |
| 3633 setLayerPropertiesForTesting(surfaceNoScaleChildNoScale.get(), childScaleMat
rix, identityMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(10, 10), true); |
| 3634 |
| 3635 // FIXME: Remove this when pageScaleFactor is applied in the compositor. |
| 3636 // Page scale should not apply to the parent. |
| 3637 parent->setBoundsContainPageScale(true); |
| 3638 |
| 3639 parent->addChild(surfaceScale); |
| 3640 parent->addChild(surfaceNoScale); |
| 3641 |
| 3642 surfaceScale->setForceRenderSurface(true); |
| 3643 surfaceScale->addChild(surfaceScaleChildScale); |
| 3644 surfaceScale->addChild(surfaceScaleChildNoScale); |
| 3645 |
| 3646 surfaceNoScale->setForceRenderSurface(true); |
| 3647 surfaceNoScale->addChild(surfaceNoScaleChildScale); |
| 3648 surfaceNoScale->addChild(surfaceNoScaleChildNoScale); |
| 3649 |
| 3650 Vector<RefPtr<LayerChromium> > renderSurfaceLayerList; |
| 3651 int dummyMaxTextureSize = 512; |
| 3652 |
| 3653 double deviceScaleFactor = 5; |
| 3654 double pageScaleFactor = 7; |
| 3655 |
| 3656 // FIXME: Remove this when pageScaleFactor is applied in the compositor. |
| 3657 WebTransformationMatrix pageScaleMatrix; |
| 3658 pageScaleMatrix.scale(pageScaleFactor); |
| 3659 parent->setSublayerTransform(pageScaleMatrix); |
| 3660 |
| 3661 CCLayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(
), deviceScaleFactor, pageScaleFactor, dummyMaxTextureSize, renderSurfaceLayerLi
st); |
| 3662 |
| 3663 EXPECT_EQ(deviceScaleFactor * initialParentScale, parent->contentsScale()); |
| 3664 EXPECT_EQ(deviceScaleFactor * pageScaleFactor * initialParentScale * initial
ChildScale, surfaceScale->contentsScale()); |
| 3665 EXPECT_EQ(1, surfaceNoScale->contentsScale()); |
| 3666 // If the surface it draws into is scaling, then the contents scale should r
eflect both the layer's scale plus the surface's scale. |
| 3667 EXPECT_EQ(deviceScaleFactor * pageScaleFactor * initialParentScale * initial
ChildScale * initialChildScale, surfaceScaleChildScale->contentsScale()); |
| 3668 EXPECT_EQ(1, surfaceScaleChildNoScale->contentsScale()); |
| 3669 // If the surface it draws into won't scale, then the contents scale should
just reflect the size it will appear in its target surface. |
| 3670 EXPECT_EQ(initialChildScale, surfaceNoScaleChildScale->contentsScale()); |
| 3671 EXPECT_EQ(1, surfaceNoScaleChildNoScale->contentsScale()); |
| 3672 |
| 3673 // The parent is scaled up and shouldn't need to scale during draw. |
| 3674 EXPECT_FLOAT_EQ(1, parent->drawTransform().m11()); |
| 3675 EXPECT_FLOAT_EQ(1, parent->drawTransform().m22()); |
| 3676 |
| 3677 // The surfaceScale can apply contents scale so it's owned RenderSurface is
scaled also, and the layer shouldn't need to scale during draw. |
| 3678 EXPECT_FLOAT_EQ(1, surfaceScale->drawTransform().m11()); |
| 3679 EXPECT_FLOAT_EQ(1, surfaceScale->drawTransform().m22()); |
| 3680 |
| 3681 // The surfaceScale RenderSurface will be scaled by its owning layer's conte
ntsScale, so it shouldn't need to scale during draw. |
| 3682 EXPECT_FLOAT_EQ(1, surfaceScale->renderSurface()->drawTransform().m11()); |
| 3683 EXPECT_FLOAT_EQ(1, surfaceScale->renderSurface()->drawTransform().m22()); |
| 3684 |
| 3685 // The surfaceScaleChildScale can apply contents scale so it shouldn't need
to scale during draw. |
| 3686 EXPECT_FLOAT_EQ(1, surfaceScaleChildScale->drawTransform().m11()); |
| 3687 EXPECT_FLOAT_EQ(1, surfaceScaleChildScale->drawTransform().m22()); |
| 3688 |
| 3689 // The surfaceScaleChildNoScale can not apply contents scale, so it needs to
be scaled during draw. |
| 3690 // It will be scaled to draw at the scale of its target surface, along with
its own scale. |
| 3691 EXPECT_FLOAT_EQ(deviceScaleFactor * pageScaleFactor * initialParentScale * i
nitialChildScale * initialChildScale, surfaceScaleChildNoScale->drawTransform().
m11()); |
| 3692 EXPECT_FLOAT_EQ(deviceScaleFactor * pageScaleFactor * initialParentScale * i
nitialChildScale * initialChildScale, surfaceScaleChildNoScale->drawTransform().
m22()); |
| 3693 |
| 3694 // The surfaceNoScale can not apply contents scale so it's owned RenderSurfa
ce is not scaled. So the layer should not be scaled while drawing to its surface
. |
| 3695 EXPECT_FLOAT_EQ(1, surfaceNoScale->drawTransform().m11()); |
| 3696 EXPECT_FLOAT_EQ(1, surfaceNoScale->drawTransform().m22()); |
| 3697 |
| 3698 // The surfaceScale RenderSurface will not be scaled by its owning layer's c
ontentsScale, so it should be scaled during draw. |
| 3699 EXPECT_FLOAT_EQ(deviceScaleFactor * pageScaleFactor * initialParentScale * i
nitialChildScale, surfaceNoScale->renderSurface()->drawTransform().m11()); |
| 3700 EXPECT_FLOAT_EQ(deviceScaleFactor * pageScaleFactor * initialParentScale * i
nitialChildScale, surfaceNoScale->renderSurface()->drawTransform().m22()); |
| 3701 |
| 3702 // The surfaceScaleChildScale can apply contents scale so it shouldn't need
to scale during draw. |
| 3703 EXPECT_FLOAT_EQ(1, surfaceNoScaleChildScale->drawTransform().m11()); |
| 3704 EXPECT_FLOAT_EQ(1, surfaceNoScaleChildScale->drawTransform().m22()); |
| 3705 |
| 3706 // The surfaceScaleChildNoScale can not apply contents scale, so it needs to
be scaled during draw. |
| 3707 // Since its target surface is not scaled, it should only be scaled by its o
wn scale. |
| 3708 EXPECT_FLOAT_EQ(initialChildScale, surfaceNoScaleChildNoScale->drawTransform
().m11()); |
| 3709 EXPECT_FLOAT_EQ(initialChildScale, surfaceNoScaleChildNoScale->drawTransform
().m22()); |
| 3710 |
| 3711 } |
| 3712 |
3497 TEST(CCLayerTreeHostCommonTest, verifyRenderSurfaceTransformsInHighDPI) | 3713 TEST(CCLayerTreeHostCommonTest, verifyRenderSurfaceTransformsInHighDPI) |
3498 { | 3714 { |
3499 MockContentLayerChromiumClient delegate; | 3715 MockContentLayerChromiumClient delegate; |
3500 WebTransformationMatrix identityMatrix; | 3716 WebTransformationMatrix identityMatrix; |
3501 | 3717 |
3502 RefPtr<ContentLayerChromium> parent = createDrawableContentLayerChromium(&de
legate); | 3718 RefPtr<ContentLayerChromium> parent = createDrawableContentLayerChromium(&de
legate); |
3503 setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, F
loatPoint(0, 0), FloatPoint(0, 0), IntSize(30, 30), true); | 3719 setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, F
loatPoint(0, 0), FloatPoint(0, 0), IntSize(30, 30), true); |
3504 | 3720 |
3505 RefPtr<ContentLayerChromium> child = createDrawableContentLayerChromium(&del
egate); | 3721 RefPtr<ContentLayerChromium> child = createDrawableContentLayerChromium(&del
egate); |
3506 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, Fl
oatPoint(0, 0), FloatPoint(2, 2), IntSize(10, 10), true); | 3722 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, Fl
oatPoint(0, 0), FloatPoint(2, 2), IntSize(10, 10), true); |
(...skipping 14 matching lines...) Expand all Loading... |
3521 | 3737 |
3522 Vector<RefPtr<LayerChromium> > renderSurfaceLayerList; | 3738 Vector<RefPtr<LayerChromium> > renderSurfaceLayerList; |
3523 int dummyMaxTextureSize = 512; | 3739 int dummyMaxTextureSize = 512; |
3524 | 3740 |
3525 const double deviceScaleFactor = 1.5; | 3741 const double deviceScaleFactor = 1.5; |
3526 parent->setContentsScale(deviceScaleFactor); | 3742 parent->setContentsScale(deviceScaleFactor); |
3527 child->setContentsScale(deviceScaleFactor); | 3743 child->setContentsScale(deviceScaleFactor); |
3528 duplicateChildNonOwner->setContentsScale(deviceScaleFactor); | 3744 duplicateChildNonOwner->setContentsScale(deviceScaleFactor); |
3529 replica->setContentsScale(deviceScaleFactor); | 3745 replica->setContentsScale(deviceScaleFactor); |
3530 | 3746 |
3531 CCLayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(
), deviceScaleFactor, dummyMaxTextureSize, renderSurfaceLayerList); | 3747 CCLayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(
), deviceScaleFactor, 1, dummyMaxTextureSize, renderSurfaceLayerList); |
3532 | 3748 |
3533 // We should have two render surfaces. The root's render surface and child's | 3749 // We should have two render surfaces. The root's render surface and child's |
3534 // render surface (it needs one because it has a replica layer). | 3750 // render surface (it needs one because it has a replica layer). |
3535 EXPECT_EQ(2u, renderSurfaceLayerList.size()); | 3751 EXPECT_EQ(2u, renderSurfaceLayerList.size()); |
3536 | 3752 |
3537 WebTransformationMatrix expectedParentTransform; | 3753 WebTransformationMatrix expectedParentTransform; |
3538 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedParentTransform, parent->screenSpace
Transform()); | 3754 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedParentTransform, parent->screenSpace
Transform()); |
3539 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedParentTransform, parent->drawTransfo
rm()); | 3755 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedParentTransform, parent->drawTransfo
rm()); |
3540 | 3756 |
3541 WebTransformationMatrix expectedDrawTransform; | 3757 WebTransformationMatrix expectedDrawTransform; |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3592 int nonexistentId = -1; | 3808 int nonexistentId = -1; |
3593 EXPECT_EQ(root, CCLayerTreeHostCommon::findLayerInSubtree(root.get(), root->
id())); | 3809 EXPECT_EQ(root, CCLayerTreeHostCommon::findLayerInSubtree(root.get(), root->
id())); |
3594 EXPECT_EQ(child, CCLayerTreeHostCommon::findLayerInSubtree(root.get(), child
->id())); | 3810 EXPECT_EQ(child, CCLayerTreeHostCommon::findLayerInSubtree(root.get(), child
->id())); |
3595 EXPECT_EQ(grandChild, CCLayerTreeHostCommon::findLayerInSubtree(root.get(),
grandChild->id())); | 3811 EXPECT_EQ(grandChild, CCLayerTreeHostCommon::findLayerInSubtree(root.get(),
grandChild->id())); |
3596 EXPECT_EQ(maskLayer, CCLayerTreeHostCommon::findLayerInSubtree(root.get(), m
askLayer->id())); | 3812 EXPECT_EQ(maskLayer, CCLayerTreeHostCommon::findLayerInSubtree(root.get(), m
askLayer->id())); |
3597 EXPECT_EQ(replicaLayer, CCLayerTreeHostCommon::findLayerInSubtree(root.get()
, replicaLayer->id())); | 3813 EXPECT_EQ(replicaLayer, CCLayerTreeHostCommon::findLayerInSubtree(root.get()
, replicaLayer->id())); |
3598 EXPECT_EQ(0, CCLayerTreeHostCommon::findLayerInSubtree(root.get(), nonexiste
ntId)); | 3814 EXPECT_EQ(0, CCLayerTreeHostCommon::findLayerInSubtree(root.get(), nonexiste
ntId)); |
3599 } | 3815 } |
3600 | 3816 |
3601 } // namespace | 3817 } // namespace |
OLD | NEW |