OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2011 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 930 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
941 // The child's drawTransform should have been taken by its surface. | 941 // The child's drawTransform should have been taken by its surface. |
942 ASSERT_TRUE(child->renderSurface()); | 942 ASSERT_TRUE(child->renderSurface()); |
943 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildDrawTransform, child->renderSur
face()->drawTransform()); | 943 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildDrawTransform, child->renderSur
face()->drawTransform()); |
944 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildScreenSpaceTransform, child->re
nderSurface()->screenSpaceTransform()); | 944 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildScreenSpaceTransform, child->re
nderSurface()->screenSpaceTransform()); |
945 EXPECT_TRANSFORMATION_MATRIX_EQ(identityMatrix, child->drawTransform()); | 945 EXPECT_TRANSFORMATION_MATRIX_EQ(identityMatrix, child->drawTransform()); |
946 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildScreenSpaceTransform, child->sc
reenSpaceTransform()); | 946 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildScreenSpaceTransform, child->sc
reenSpaceTransform()); |
947 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildDrawTransform, grandChild-
>drawTransform()); | 947 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildDrawTransform, grandChild-
>drawTransform()); |
948 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildScreenSpaceTransform, gran
dChild->screenSpaceTransform()); | 948 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildScreenSpaceTransform, gran
dChild->screenSpaceTransform()); |
949 } | 949 } |
950 | 950 |
| 951 TEST(CCLayerTreeHostCommonTest, verifyTransformsForDegenerateIntermediateLayer) |
| 952 { |
| 953 // A layer that is empty in one axis, but not the other, was accidentally sk
ipping a necessary translation. |
| 954 // Without that translation, the coordinate space of the layer's drawTransfo
rm is incorrect. |
| 955 // |
| 956 // Normally this isn't a problem, because the layer wouldn't be drawn anyway
, but if that layer becomes a renderSurface, then |
| 957 // its drawTransform is implicitly inherited by the rest of the subtree, whi
ch then is positioned incorrectly as a result. |
| 958 |
| 959 RefPtr<LayerChromium> root = LayerChromium::create(); |
| 960 RefPtr<LayerChromium> child = LayerChromium::create(); |
| 961 RefPtr<LayerChromiumWithForcedDrawsContent> grandChild = adoptRef(new LayerC
hromiumWithForcedDrawsContent()); |
| 962 |
| 963 // The child height is zero, but has non-zero width that should be accounted
for while computing drawTransforms. |
| 964 const WebTransformationMatrix identityMatrix; |
| 965 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, Flo
atPoint::zero(), FloatPoint::zero(), IntSize(100, 100), false); |
| 966 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, Fl
oatPoint::zero(), FloatPoint::zero(), IntSize(10, 0), false); |
| 967 setLayerPropertiesForTesting(grandChild.get(), identityMatrix, identityMatri
x, FloatPoint::zero(), FloatPoint::zero(), IntSize(10, 10), false); |
| 968 |
| 969 root->addChild(child); |
| 970 child->addChild(grandChild); |
| 971 child->setForceRenderSurface(true); |
| 972 |
| 973 executeCalculateDrawTransformsAndVisibility(root.get()); |
| 974 |
| 975 ASSERT_TRUE(child->renderSurface()); |
| 976 EXPECT_TRANSFORMATION_MATRIX_EQ(identityMatrix, child->renderSurface()->draw
Transform()); // This is the real test, the rest are sanity checks. |
| 977 EXPECT_TRANSFORMATION_MATRIX_EQ(identityMatrix, child->drawTransform()); |
| 978 EXPECT_TRANSFORMATION_MATRIX_EQ(identityMatrix, grandChild->drawTransform())
; |
| 979 } |
| 980 |
951 TEST(CCLayerTreeHostCommonTest, verifyRenderSurfaceListForRenderSurfaceWithClipp
edLayer) | 981 TEST(CCLayerTreeHostCommonTest, verifyRenderSurfaceListForRenderSurfaceWithClipp
edLayer) |
952 { | 982 { |
953 RefPtr<LayerChromium> parent = LayerChromium::create(); | 983 RefPtr<LayerChromium> parent = LayerChromium::create(); |
954 RefPtr<LayerChromium> renderSurface1 = LayerChromium::create(); | 984 RefPtr<LayerChromium> renderSurface1 = LayerChromium::create(); |
955 RefPtr<LayerChromiumWithForcedDrawsContent> child = adoptRef(new LayerChromi
umWithForcedDrawsContent()); | 985 RefPtr<LayerChromiumWithForcedDrawsContent> child = adoptRef(new LayerChromi
umWithForcedDrawsContent()); |
956 | 986 |
957 const WebTransformationMatrix identityMatrix; | 987 const WebTransformationMatrix identityMatrix; |
958 setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, F
loatPoint::zero(), FloatPoint::zero(), IntSize(10, 10), false); | 988 setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, F
loatPoint::zero(), FloatPoint::zero(), IntSize(10, 10), false); |
959 setLayerPropertiesForTesting(renderSurface1.get(), identityMatrix, identityM
atrix, FloatPoint::zero(), FloatPoint::zero(), IntSize(10, 10), false); | 989 setLayerPropertiesForTesting(renderSurface1.get(), identityMatrix, identityM
atrix, FloatPoint::zero(), FloatPoint::zero(), IntSize(10, 10), false); |
960 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, Fl
oatPoint::zero(), FloatPoint(30, 30), IntSize(10, 10), false); | 990 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, Fl
oatPoint::zero(), FloatPoint(30, 30), IntSize(10, 10), false); |
(...skipping 2589 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3550 int nonexistentId = -1; | 3580 int nonexistentId = -1; |
3551 EXPECT_EQ(root, CCLayerTreeHostCommon::findLayerInSubtree(root.get(), root->
id())); | 3581 EXPECT_EQ(root, CCLayerTreeHostCommon::findLayerInSubtree(root.get(), root->
id())); |
3552 EXPECT_EQ(child, CCLayerTreeHostCommon::findLayerInSubtree(root.get(), child
->id())); | 3582 EXPECT_EQ(child, CCLayerTreeHostCommon::findLayerInSubtree(root.get(), child
->id())); |
3553 EXPECT_EQ(grandChild, CCLayerTreeHostCommon::findLayerInSubtree(root.get(),
grandChild->id())); | 3583 EXPECT_EQ(grandChild, CCLayerTreeHostCommon::findLayerInSubtree(root.get(),
grandChild->id())); |
3554 EXPECT_EQ(maskLayer, CCLayerTreeHostCommon::findLayerInSubtree(root.get(), m
askLayer->id())); | 3584 EXPECT_EQ(maskLayer, CCLayerTreeHostCommon::findLayerInSubtree(root.get(), m
askLayer->id())); |
3555 EXPECT_EQ(replicaLayer, CCLayerTreeHostCommon::findLayerInSubtree(root.get()
, replicaLayer->id())); | 3585 EXPECT_EQ(replicaLayer, CCLayerTreeHostCommon::findLayerInSubtree(root.get()
, replicaLayer->id())); |
3556 EXPECT_EQ(0, CCLayerTreeHostCommon::findLayerInSubtree(root.get(), nonexiste
ntId)); | 3586 EXPECT_EQ(0, CCLayerTreeHostCommon::findLayerInSubtree(root.get(), nonexiste
ntId)); |
3557 } | 3587 } |
3558 | 3588 |
3559 } // namespace | 3589 } // namespace |
OLD | NEW |