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 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 ret.setM13(0); | 83 ret.setM13(0); |
84 ret.setM23(0); | 84 ret.setM23(0); |
85 ret.setM31(0); | 85 ret.setM31(0); |
86 ret.setM32(0); | 86 ret.setM32(0); |
87 ret.setM33(1); | 87 ret.setM33(1); |
88 ret.setM34(0); | 88 ret.setM34(0); |
89 ret.setM43(0); | 89 ret.setM43(0); |
90 return ret; | 90 return ret; |
91 } | 91 } |
92 | 92 |
93 PassOwnPtr<CCLayerImpl> createTreeForFixedPositionTests() | 93 scoped_ptr<CCLayerImpl> createTreeForFixedPositionTests() |
94 { | 94 { |
95 OwnPtr<CCLayerImpl> root = CCLayerImpl::create(1); | 95 scoped_ptr<CCLayerImpl> root = CCLayerImpl::create(1); |
96 OwnPtr<CCLayerImpl> child = CCLayerImpl::create(2); | 96 scoped_ptr<CCLayerImpl> child = CCLayerImpl::create(2); |
97 OwnPtr<CCLayerImpl> grandChild = CCLayerImpl::create(3); | 97 scoped_ptr<CCLayerImpl> grandChild = CCLayerImpl::create(3); |
98 OwnPtr<CCLayerImpl> greatGrandChild = CCLayerImpl::create(4); | 98 scoped_ptr<CCLayerImpl> greatGrandChild = CCLayerImpl::create(4); |
99 | 99 |
100 WebTransformationMatrix IdentityMatrix; | 100 WebTransformationMatrix IdentityMatrix; |
101 FloatPoint anchor(0, 0); | 101 FloatPoint anchor(0, 0); |
102 FloatPoint position(0, 0); | 102 FloatPoint position(0, 0); |
103 IntSize bounds(100, 100); | 103 IntSize bounds(100, 100); |
104 setLayerPropertiesForTesting(root.get(), IdentityMatrix, IdentityMatrix, anc
hor, position, bounds, false); | 104 setLayerPropertiesForTesting(root.get(), IdentityMatrix, IdentityMatrix, anc
hor, position, bounds, false); |
105 setLayerPropertiesForTesting(child.get(), IdentityMatrix, IdentityMatrix, an
chor, position, bounds, false); | 105 setLayerPropertiesForTesting(child.get(), IdentityMatrix, IdentityMatrix, an
chor, position, bounds, false); |
106 setLayerPropertiesForTesting(grandChild.get(), IdentityMatrix, IdentityMatri
x, anchor, position, bounds, false); | 106 setLayerPropertiesForTesting(grandChild.get(), IdentityMatrix, IdentityMatri
x, anchor, position, bounds, false); |
107 setLayerPropertiesForTesting(greatGrandChild.get(), IdentityMatrix, Identity
Matrix, anchor, position, bounds, false); | 107 setLayerPropertiesForTesting(greatGrandChild.get(), IdentityMatrix, Identity
Matrix, anchor, position, bounds, false); |
108 | 108 |
109 grandChild->addChild(greatGrandChild.release()); | 109 grandChild->addChild(greatGrandChild.Pass()); |
110 child->addChild(grandChild.release()); | 110 child->addChild(grandChild.Pass()); |
111 root->addChild(child.release()); | 111 root->addChild(child.Pass()); |
112 | 112 |
113 return root.release(); | 113 return root.Pass(); |
114 } | 114 } |
115 | 115 |
116 class LayerChromiumWithForcedDrawsContent : public LayerChromium { | 116 class LayerChromiumWithForcedDrawsContent : public LayerChromium { |
117 public: | 117 public: |
118 LayerChromiumWithForcedDrawsContent() | 118 LayerChromiumWithForcedDrawsContent() |
119 : LayerChromium() | 119 : LayerChromium() |
120 { | 120 { |
121 } | 121 } |
122 | 122 |
123 virtual bool drawsContent() const OVERRIDE { return true; } | 123 virtual bool drawsContent() const OVERRIDE { return true; } |
(...skipping 606 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
730 EXPECT_FALSE(renderSurface1->renderSurface()); | 730 EXPECT_FALSE(renderSurface1->renderSurface()); |
731 EXPECT_EQ(1U, renderSurfaceLayerList.size()); | 731 EXPECT_EQ(1U, renderSurfaceLayerList.size()); |
732 } | 732 } |
733 | 733 |
734 TEST(CCLayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerWit
hDirectContainer) | 734 TEST(CCLayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerWit
hDirectContainer) |
735 { | 735 { |
736 // This test checks for correct scroll compensation when the fixed-position
container | 736 // This test checks for correct scroll compensation when the fixed-position
container |
737 // is the direct parent of the fixed-position layer. | 737 // is the direct parent of the fixed-position layer. |
738 | 738 |
739 DebugScopedSetImplThread scopedImplThread; | 739 DebugScopedSetImplThread scopedImplThread; |
740 OwnPtr<CCLayerImpl> root = createTreeForFixedPositionTests(); | 740 scoped_ptr<CCLayerImpl> root = createTreeForFixedPositionTests(); |
741 CCLayerImpl* child = root->children()[0]; | 741 CCLayerImpl* child = root->children()[0]; |
742 CCLayerImpl* grandChild = child->children()[0]; | 742 CCLayerImpl* grandChild = child->children()[0]; |
743 | 743 |
744 child->setIsContainerForFixedPositionLayers(true); | 744 child->setIsContainerForFixedPositionLayers(true); |
745 grandChild->setFixedToContainerLayer(true); | 745 grandChild->setFixedToContainerLayer(true); |
746 | 746 |
747 // Case 1: scrollDelta of 0, 0 | 747 // Case 1: scrollDelta of 0, 0 |
748 child->setScrollDelta(IntSize(0, 0)); | 748 child->setScrollDelta(IntSize(0, 0)); |
749 executeCalculateDrawTransformsAndVisibility(root.get()); | 749 executeCalculateDrawTransformsAndVisibility(root.get()); |
750 | 750 |
(...skipping 20 matching lines...) Expand all Loading... |
771 // This test checks for correct scroll compensation when the fixed-position
container | 771 // This test checks for correct scroll compensation when the fixed-position
container |
772 // is the direct parent of the fixed-position layer, but that container is t
ransformed. | 772 // is the direct parent of the fixed-position layer, but that container is t
ransformed. |
773 // In this case, the fixed position element inherits the container's transfo
rm, | 773 // In this case, the fixed position element inherits the container's transfo
rm, |
774 // but the scrollDelta that has to be undone should not be affected by that
transform. | 774 // but the scrollDelta that has to be undone should not be affected by that
transform. |
775 // | 775 // |
776 // Transforms are in general non-commutative; using something like a non-uni
form scale | 776 // Transforms are in general non-commutative; using something like a non-uni
form scale |
777 // helps to verify that translations and non-uniform scales are applied in t
he correct | 777 // helps to verify that translations and non-uniform scales are applied in t
he correct |
778 // order. | 778 // order. |
779 | 779 |
780 DebugScopedSetImplThread scopedImplThread; | 780 DebugScopedSetImplThread scopedImplThread; |
781 OwnPtr<CCLayerImpl> root = createTreeForFixedPositionTests(); | 781 scoped_ptr<CCLayerImpl> root = createTreeForFixedPositionTests(); |
782 CCLayerImpl* child = root->children()[0]; | 782 CCLayerImpl* child = root->children()[0]; |
783 CCLayerImpl* grandChild = child->children()[0]; | 783 CCLayerImpl* grandChild = child->children()[0]; |
784 | 784 |
785 // This scale will cause child and grandChild to be effectively 200 x 800 wi
th respect to the renderTarget. | 785 // This scale will cause child and grandChild to be effectively 200 x 800 wi
th respect to the renderTarget. |
786 WebTransformationMatrix nonUniformScale; | 786 WebTransformationMatrix nonUniformScale; |
787 nonUniformScale.scaleNonUniform(2, 8); | 787 nonUniformScale.scaleNonUniform(2, 8); |
788 child->setTransform(nonUniformScale); | 788 child->setTransform(nonUniformScale); |
789 | 789 |
790 child->setIsContainerForFixedPositionLayers(true); | 790 child->setIsContainerForFixedPositionLayers(true); |
791 grandChild->setFixedToContainerLayer(true); | 791 grandChild->setFixedToContainerLayer(true); |
(...skipping 22 matching lines...) Expand all Loading... |
814 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->drawTransform
()); | 814 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->drawTransform
()); |
815 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->dra
wTransform()); | 815 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->dra
wTransform()); |
816 } | 816 } |
817 | 817 |
818 TEST(CCLayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerWit
hDistantContainer) | 818 TEST(CCLayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerWit
hDistantContainer) |
819 { | 819 { |
820 // This test checks for correct scroll compensation when the fixed-position
container | 820 // This test checks for correct scroll compensation when the fixed-position
container |
821 // is NOT the direct parent of the fixed-position layer. | 821 // is NOT the direct parent of the fixed-position layer. |
822 DebugScopedSetImplThread scopedImplThread; | 822 DebugScopedSetImplThread scopedImplThread; |
823 | 823 |
824 OwnPtr<CCLayerImpl> root = createTreeForFixedPositionTests(); | 824 scoped_ptr<CCLayerImpl> root = createTreeForFixedPositionTests(); |
825 CCLayerImpl* child = root->children()[0]; | 825 CCLayerImpl* child = root->children()[0]; |
826 CCLayerImpl* grandChild = child->children()[0]; | 826 CCLayerImpl* grandChild = child->children()[0]; |
827 CCLayerImpl* greatGrandChild = grandChild->children()[0]; | 827 CCLayerImpl* greatGrandChild = grandChild->children()[0]; |
828 | 828 |
829 child->setIsContainerForFixedPositionLayers(true); | 829 child->setIsContainerForFixedPositionLayers(true); |
830 grandChild->setPosition(FloatPoint(8, 6)); | 830 grandChild->setPosition(FloatPoint(8, 6)); |
831 greatGrandChild->setFixedToContainerLayer(true); | 831 greatGrandChild->setFixedToContainerLayer(true); |
832 | 832 |
833 // Case 1: scrollDelta of 0, 0 | 833 // Case 1: scrollDelta of 0, 0 |
834 child->setScrollDelta(IntSize(0, 0)); | 834 child->setScrollDelta(IntSize(0, 0)); |
(...skipping 23 matching lines...) Expand all Loading... |
858 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGreatGrandChildTransform, greatGrand
Child->drawTransform()); | 858 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGreatGrandChildTransform, greatGrand
Child->drawTransform()); |
859 } | 859 } |
860 | 860 |
861 TEST(CCLayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerWit
hDistantContainerAndTransforms) | 861 TEST(CCLayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerWit
hDistantContainerAndTransforms) |
862 { | 862 { |
863 // This test checks for correct scroll compensation when the fixed-position
container | 863 // This test checks for correct scroll compensation when the fixed-position
container |
864 // is NOT the direct parent of the fixed-position layer, and the hierarchy h
as various | 864 // is NOT the direct parent of the fixed-position layer, and the hierarchy h
as various |
865 // transforms that have to be processed in the correct order. | 865 // transforms that have to be processed in the correct order. |
866 DebugScopedSetImplThread scopedImplThread; | 866 DebugScopedSetImplThread scopedImplThread; |
867 | 867 |
868 OwnPtr<CCLayerImpl> root = createTreeForFixedPositionTests(); | 868 scoped_ptr<CCLayerImpl> root = createTreeForFixedPositionTests(); |
869 CCLayerImpl* child = root->children()[0]; | 869 CCLayerImpl* child = root->children()[0]; |
870 CCLayerImpl* grandChild = child->children()[0]; | 870 CCLayerImpl* grandChild = child->children()[0]; |
871 CCLayerImpl* greatGrandChild = grandChild->children()[0]; | 871 CCLayerImpl* greatGrandChild = grandChild->children()[0]; |
872 | 872 |
873 WebTransformationMatrix rotationAboutZ; | 873 WebTransformationMatrix rotationAboutZ; |
874 rotationAboutZ.rotate3d(0, 0, 90); | 874 rotationAboutZ.rotate3d(0, 0, 90); |
875 | 875 |
876 child->setIsContainerForFixedPositionLayers(true); | 876 child->setIsContainerForFixedPositionLayers(true); |
877 child->setTransform(rotationAboutZ); | 877 child->setTransform(rotationAboutZ); |
878 grandChild->setPosition(FloatPoint(8, 6)); | 878 grandChild->setPosition(FloatPoint(8, 6)); |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
920 TEST(CCLayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerWit
hMultipleScrollDeltas) | 920 TEST(CCLayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerWit
hMultipleScrollDeltas) |
921 { | 921 { |
922 // This test checks for correct scroll compensation when the fixed-position
container | 922 // This test checks for correct scroll compensation when the fixed-position
container |
923 // has multiple ancestors that have nonzero scrollDelta before reaching the
space where the layer is fixed. | 923 // has multiple ancestors that have nonzero scrollDelta before reaching the
space where the layer is fixed. |
924 // In this test, each scrollDelta occurs in a different space because of eac
h layer's local transform. | 924 // In this test, each scrollDelta occurs in a different space because of eac
h layer's local transform. |
925 // This test checks for correct scroll compensation when the fixed-position
container | 925 // This test checks for correct scroll compensation when the fixed-position
container |
926 // is NOT the direct parent of the fixed-position layer, and the hierarchy h
as various | 926 // is NOT the direct parent of the fixed-position layer, and the hierarchy h
as various |
927 // transforms that have to be processed in the correct order. | 927 // transforms that have to be processed in the correct order. |
928 DebugScopedSetImplThread scopedImplThread; | 928 DebugScopedSetImplThread scopedImplThread; |
929 | 929 |
930 OwnPtr<CCLayerImpl> root = createTreeForFixedPositionTests(); | 930 scoped_ptr<CCLayerImpl> root = createTreeForFixedPositionTests(); |
931 CCLayerImpl* child = root->children()[0]; | 931 CCLayerImpl* child = root->children()[0]; |
932 CCLayerImpl* grandChild = child->children()[0]; | 932 CCLayerImpl* grandChild = child->children()[0]; |
933 CCLayerImpl* greatGrandChild = grandChild->children()[0]; | 933 CCLayerImpl* greatGrandChild = grandChild->children()[0]; |
934 | 934 |
935 WebTransformationMatrix rotationAboutZ; | 935 WebTransformationMatrix rotationAboutZ; |
936 rotationAboutZ.rotate3d(0, 0, 90); | 936 rotationAboutZ.rotate3d(0, 0, 90); |
937 | 937 |
938 child->setIsContainerForFixedPositionLayers(true); | 938 child->setIsContainerForFixedPositionLayers(true); |
939 child->setTransform(rotationAboutZ); | 939 child->setTransform(rotationAboutZ); |
940 grandChild->setPosition(FloatPoint(8, 6)); | 940 grandChild->setPosition(FloatPoint(8, 6)); |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
982 } | 982 } |
983 | 983 |
984 TEST(CCLayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerWit
hIntermediateSurfaceAndTransforms) | 984 TEST(CCLayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerWit
hIntermediateSurfaceAndTransforms) |
985 { | 985 { |
986 // This test checks for correct scroll compensation when the fixed-position
container | 986 // This test checks for correct scroll compensation when the fixed-position
container |
987 // contributes to a different renderSurface than the fixed-position layer. I
n this | 987 // contributes to a different renderSurface than the fixed-position layer. I
n this |
988 // case, the surface drawTransforms also have to be accounted for when check
ing the | 988 // case, the surface drawTransforms also have to be accounted for when check
ing the |
989 // scrollDelta. | 989 // scrollDelta. |
990 DebugScopedSetImplThread scopedImplThread; | 990 DebugScopedSetImplThread scopedImplThread; |
991 | 991 |
992 OwnPtr<CCLayerImpl> root = createTreeForFixedPositionTests(); | 992 scoped_ptr<CCLayerImpl> root = createTreeForFixedPositionTests(); |
993 CCLayerImpl* child = root->children()[0]; | 993 CCLayerImpl* child = root->children()[0]; |
994 CCLayerImpl* grandChild = child->children()[0]; | 994 CCLayerImpl* grandChild = child->children()[0]; |
995 CCLayerImpl* greatGrandChild = grandChild->children()[0]; | 995 CCLayerImpl* greatGrandChild = grandChild->children()[0]; |
996 | 996 |
997 child->setIsContainerForFixedPositionLayers(true); | 997 child->setIsContainerForFixedPositionLayers(true); |
998 grandChild->setPosition(FloatPoint(8, 6)); | 998 grandChild->setPosition(FloatPoint(8, 6)); |
999 grandChild->setForceRenderSurface(true); | 999 grandChild->setForceRenderSurface(true); |
1000 greatGrandChild->setFixedToContainerLayer(true); | 1000 greatGrandChild->setFixedToContainerLayer(true); |
1001 greatGrandChild->setDrawsContent(true); | 1001 greatGrandChild->setDrawsContent(true); |
1002 | 1002 |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1055 } | 1055 } |
1056 | 1056 |
1057 TEST(CCLayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerWit
hMultipleIntermediateSurfaces) | 1057 TEST(CCLayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerWit
hMultipleIntermediateSurfaces) |
1058 { | 1058 { |
1059 // This test checks for correct scroll compensation when the fixed-position
container | 1059 // This test checks for correct scroll compensation when the fixed-position
container |
1060 // contributes to a different renderSurface than the fixed-position layer, w
ith | 1060 // contributes to a different renderSurface than the fixed-position layer, w
ith |
1061 // additional renderSurfaces in-between. This checks that the conversion to
ancestor | 1061 // additional renderSurfaces in-between. This checks that the conversion to
ancestor |
1062 // surfaces is accumulated properly in the final matrix transform. | 1062 // surfaces is accumulated properly in the final matrix transform. |
1063 DebugScopedSetImplThread scopedImplThread; | 1063 DebugScopedSetImplThread scopedImplThread; |
1064 | 1064 |
1065 OwnPtr<CCLayerImpl> root = createTreeForFixedPositionTests(); | 1065 scoped_ptr<CCLayerImpl> root = createTreeForFixedPositionTests(); |
1066 CCLayerImpl* child = root->children()[0]; | 1066 CCLayerImpl* child = root->children()[0]; |
1067 CCLayerImpl* grandChild = child->children()[0]; | 1067 CCLayerImpl* grandChild = child->children()[0]; |
1068 CCLayerImpl* greatGrandChild = grandChild->children()[0]; | 1068 CCLayerImpl* greatGrandChild = grandChild->children()[0]; |
1069 | 1069 |
1070 // Add one more layer to the test tree for this scenario. | 1070 // Add one more layer to the test tree for this scenario. |
1071 { | 1071 { |
1072 WebTransformationMatrix identity; | 1072 WebTransformationMatrix identity; |
1073 OwnPtr<CCLayerImpl> fixedPositionChild = CCLayerImpl::create(5); | 1073 scoped_ptr<CCLayerImpl> fixedPositionChild = CCLayerImpl::create(5); |
1074 setLayerPropertiesForTesting(fixedPositionChild.get(), identity, identit
y, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100), false); | 1074 setLayerPropertiesForTesting(fixedPositionChild.get(), identity, identit
y, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100), false); |
1075 greatGrandChild->addChild(fixedPositionChild.release()); | 1075 greatGrandChild->addChild(fixedPositionChild.Pass()); |
1076 } | 1076 } |
1077 CCLayerImpl* fixedPositionChild = greatGrandChild->children()[0]; | 1077 CCLayerImpl* fixedPositionChild = greatGrandChild->children()[0]; |
1078 | 1078 |
1079 // Actually set up the scenario here. | 1079 // Actually set up the scenario here. |
1080 child->setIsContainerForFixedPositionLayers(true); | 1080 child->setIsContainerForFixedPositionLayers(true); |
1081 grandChild->setPosition(FloatPoint(8, 6)); | 1081 grandChild->setPosition(FloatPoint(8, 6)); |
1082 grandChild->setForceRenderSurface(true); | 1082 grandChild->setForceRenderSurface(true); |
1083 greatGrandChild->setPosition(FloatPoint(40, 60)); | 1083 greatGrandChild->setPosition(FloatPoint(40, 60)); |
1084 greatGrandChild->setForceRenderSurface(true); | 1084 greatGrandChild->setForceRenderSurface(true); |
1085 fixedPositionChild->setFixedToContainerLayer(true); | 1085 fixedPositionChild->setFixedToContainerLayer(true); |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1166 } | 1166 } |
1167 | 1167 |
1168 TEST(CCLayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerWit
hContainerLayerThatHasSurface) | 1168 TEST(CCLayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerWit
hContainerLayerThatHasSurface) |
1169 { | 1169 { |
1170 // This test checks for correct scroll compensation when the fixed-position
container | 1170 // This test checks for correct scroll compensation when the fixed-position
container |
1171 // itself has a renderSurface. In this case, the container layer should be t
reated | 1171 // itself has a renderSurface. In this case, the container layer should be t
reated |
1172 // like a layer that contributes to a renderTarget, and that renderTarget | 1172 // like a layer that contributes to a renderTarget, and that renderTarget |
1173 // is completely irrelevant; it should not affect the scroll compensation. | 1173 // is completely irrelevant; it should not affect the scroll compensation. |
1174 DebugScopedSetImplThread scopedImplThread; | 1174 DebugScopedSetImplThread scopedImplThread; |
1175 | 1175 |
1176 OwnPtr<CCLayerImpl> root = createTreeForFixedPositionTests(); | 1176 scoped_ptr<CCLayerImpl> root = createTreeForFixedPositionTests(); |
1177 CCLayerImpl* child = root->children()[0]; | 1177 CCLayerImpl* child = root->children()[0]; |
1178 CCLayerImpl* grandChild = child->children()[0]; | 1178 CCLayerImpl* grandChild = child->children()[0]; |
1179 | 1179 |
1180 child->setIsContainerForFixedPositionLayers(true); | 1180 child->setIsContainerForFixedPositionLayers(true); |
1181 child->setForceRenderSurface(true); | 1181 child->setForceRenderSurface(true); |
1182 grandChild->setFixedToContainerLayer(true); | 1182 grandChild->setFixedToContainerLayer(true); |
1183 grandChild->setDrawsContent(true); | 1183 grandChild->setDrawsContent(true); |
1184 | 1184 |
1185 // Case 1: scrollDelta of 0, 0 | 1185 // Case 1: scrollDelta of 0, 0 |
1186 child->setScrollDelta(IntSize(0, 0)); | 1186 child->setScrollDelta(IntSize(0, 0)); |
(...skipping 26 matching lines...) Expand all Loading... |
1213 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->dra
wTransform()); | 1213 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->dra
wTransform()); |
1214 } | 1214 } |
1215 | 1215 |
1216 TEST(CCLayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerTha
tIsAlsoFixedPositionContainer) | 1216 TEST(CCLayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerTha
tIsAlsoFixedPositionContainer) |
1217 { | 1217 { |
1218 // This test checks the scenario where a fixed-position layer also happens t
o be a | 1218 // This test checks the scenario where a fixed-position layer also happens t
o be a |
1219 // container itself for a descendant fixed position layer. In particular, th
e layer | 1219 // container itself for a descendant fixed position layer. In particular, th
e layer |
1220 // should not accidentally be fixed to itself. | 1220 // should not accidentally be fixed to itself. |
1221 DebugScopedSetImplThread scopedImplThread; | 1221 DebugScopedSetImplThread scopedImplThread; |
1222 | 1222 |
1223 OwnPtr<CCLayerImpl> root = createTreeForFixedPositionTests(); | 1223 scoped_ptr<CCLayerImpl> root = createTreeForFixedPositionTests(); |
1224 CCLayerImpl* child = root->children()[0]; | 1224 CCLayerImpl* child = root->children()[0]; |
1225 CCLayerImpl* grandChild = child->children()[0]; | 1225 CCLayerImpl* grandChild = child->children()[0]; |
1226 | 1226 |
1227 child->setIsContainerForFixedPositionLayers(true); | 1227 child->setIsContainerForFixedPositionLayers(true); |
1228 grandChild->setFixedToContainerLayer(true); | 1228 grandChild->setFixedToContainerLayer(true); |
1229 | 1229 |
1230 // This should not confuse the grandChild. If correct, the grandChild would
still be considered fixed to its container (i.e. "child"). | 1230 // This should not confuse the grandChild. If correct, the grandChild would
still be considered fixed to its container (i.e. "child"). |
1231 grandChild->setIsContainerForFixedPositionLayers(true); | 1231 grandChild->setIsContainerForFixedPositionLayers(true); |
1232 | 1232 |
1233 // Case 1: scrollDelta of 0, 0 | 1233 // Case 1: scrollDelta of 0, 0 |
(...skipping 16 matching lines...) Expand all Loading... |
1250 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->dra
wTransform()); | 1250 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->dra
wTransform()); |
1251 } | 1251 } |
1252 | 1252 |
1253 TEST(CCLayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerTha
tHasNoContainer) | 1253 TEST(CCLayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerTha
tHasNoContainer) |
1254 { | 1254 { |
1255 // This test checks scroll compensation when a fixed-position layer does not
find any | 1255 // This test checks scroll compensation when a fixed-position layer does not
find any |
1256 // ancestor that is a "containerForFixedPositionLayers". In this situation,
the layer should | 1256 // ancestor that is a "containerForFixedPositionLayers". In this situation,
the layer should |
1257 // be fixed to the viewport -- not the rootLayer, which may have transforms
of its own. | 1257 // be fixed to the viewport -- not the rootLayer, which may have transforms
of its own. |
1258 DebugScopedSetImplThread scopedImplThread; | 1258 DebugScopedSetImplThread scopedImplThread; |
1259 | 1259 |
1260 OwnPtr<CCLayerImpl> root = createTreeForFixedPositionTests(); | 1260 scoped_ptr<CCLayerImpl> root = createTreeForFixedPositionTests(); |
1261 CCLayerImpl* child = root->children()[0]; | 1261 CCLayerImpl* child = root->children()[0]; |
1262 CCLayerImpl* grandChild = child->children()[0]; | 1262 CCLayerImpl* grandChild = child->children()[0]; |
1263 | 1263 |
1264 WebTransformationMatrix rotationByZ; | 1264 WebTransformationMatrix rotationByZ; |
1265 rotationByZ.rotate3d(0, 0, 90); | 1265 rotationByZ.rotate3d(0, 0, 90); |
1266 | 1266 |
1267 root->setTransform(rotationByZ); | 1267 root->setTransform(rotationByZ); |
1268 grandChild->setFixedToContainerLayer(true); | 1268 grandChild->setFixedToContainerLayer(true); |
1269 | 1269 |
1270 // Case 1: root scrollDelta of 0, 0 | 1270 // Case 1: root scrollDelta of 0, 0 |
(...skipping 1367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2638 | 2638 |
2639 testPoint = IntPoint(10, 20); | 2639 testPoint = IntPoint(10, 20); |
2640 resultLayer = CCLayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, re
nderSurfaceLayerList); | 2640 resultLayer = CCLayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, re
nderSurfaceLayerList); |
2641 EXPECT_FALSE(resultLayer); | 2641 EXPECT_FALSE(resultLayer); |
2642 } | 2642 } |
2643 | 2643 |
2644 TEST(CCLayerTreeHostCommonTest, verifyHitTestingForSingleLayer) | 2644 TEST(CCLayerTreeHostCommonTest, verifyHitTestingForSingleLayer) |
2645 { | 2645 { |
2646 DebugScopedSetImplThread thisScopeIsOnImplThread; | 2646 DebugScopedSetImplThread thisScopeIsOnImplThread; |
2647 | 2647 |
2648 OwnPtr<CCLayerImpl> root = CCLayerImpl::create(12345); | 2648 scoped_ptr<CCLayerImpl> root = CCLayerImpl::create(12345); |
2649 | 2649 |
2650 WebTransformationMatrix identityMatrix; | 2650 WebTransformationMatrix identityMatrix; |
2651 FloatPoint anchor(0, 0); | 2651 FloatPoint anchor(0, 0); |
2652 FloatPoint position(0, 0); | 2652 FloatPoint position(0, 0); |
2653 IntSize bounds(100, 100); | 2653 IntSize bounds(100, 100); |
2654 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc
hor, position, bounds, false); | 2654 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc
hor, position, bounds, false); |
2655 root->setDrawsContent(true); | 2655 root->setDrawsContent(true); |
2656 | 2656 |
2657 std::vector<CCLayerImpl*> renderSurfaceLayerList; | 2657 std::vector<CCLayerImpl*> renderSurfaceLayerList; |
2658 int dummyMaxTextureSize = 512; | 2658 int dummyMaxTextureSize = 512; |
(...skipping 21 matching lines...) Expand all Loading... |
2680 testPoint = IntPoint(99, 99); | 2680 testPoint = IntPoint(99, 99); |
2681 resultLayer = CCLayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, re
nderSurfaceLayerList); | 2681 resultLayer = CCLayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, re
nderSurfaceLayerList); |
2682 ASSERT_TRUE(resultLayer); | 2682 ASSERT_TRUE(resultLayer); |
2683 EXPECT_EQ(12345, resultLayer->id()); | 2683 EXPECT_EQ(12345, resultLayer->id()); |
2684 } | 2684 } |
2685 | 2685 |
2686 TEST(CCLayerTreeHostCommonTest, verifyHitTestingForUninvertibleTransform) | 2686 TEST(CCLayerTreeHostCommonTest, verifyHitTestingForUninvertibleTransform) |
2687 { | 2687 { |
2688 DebugScopedSetImplThread thisScopeIsOnImplThread; | 2688 DebugScopedSetImplThread thisScopeIsOnImplThread; |
2689 | 2689 |
2690 OwnPtr<CCLayerImpl> root = CCLayerImpl::create(12345); | 2690 scoped_ptr<CCLayerImpl> root = CCLayerImpl::create(12345); |
2691 | 2691 |
2692 WebTransformationMatrix uninvertibleTransform; | 2692 WebTransformationMatrix uninvertibleTransform; |
2693 uninvertibleTransform.setM11(0); | 2693 uninvertibleTransform.setM11(0); |
2694 uninvertibleTransform.setM22(0); | 2694 uninvertibleTransform.setM22(0); |
2695 uninvertibleTransform.setM33(0); | 2695 uninvertibleTransform.setM33(0); |
2696 uninvertibleTransform.setM44(0); | 2696 uninvertibleTransform.setM44(0); |
2697 ASSERT_FALSE(uninvertibleTransform.isInvertible()); | 2697 ASSERT_FALSE(uninvertibleTransform.isInvertible()); |
2698 | 2698 |
2699 WebTransformationMatrix identityMatrix; | 2699 WebTransformationMatrix identityMatrix; |
2700 FloatPoint anchor(0, 0); | 2700 FloatPoint anchor(0, 0); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2741 | 2741 |
2742 testPoint = IntPoint(-1, -1); | 2742 testPoint = IntPoint(-1, -1); |
2743 resultLayer = CCLayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, re
nderSurfaceLayerList); | 2743 resultLayer = CCLayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, re
nderSurfaceLayerList); |
2744 EXPECT_FALSE(resultLayer); | 2744 EXPECT_FALSE(resultLayer); |
2745 } | 2745 } |
2746 | 2746 |
2747 TEST(CCLayerTreeHostCommonTest, verifyHitTestingForSinglePositionedLayer) | 2747 TEST(CCLayerTreeHostCommonTest, verifyHitTestingForSinglePositionedLayer) |
2748 { | 2748 { |
2749 DebugScopedSetImplThread thisScopeIsOnImplThread; | 2749 DebugScopedSetImplThread thisScopeIsOnImplThread; |
2750 | 2750 |
2751 OwnPtr<CCLayerImpl> root = CCLayerImpl::create(12345); | 2751 scoped_ptr<CCLayerImpl> root = CCLayerImpl::create(12345); |
2752 | 2752 |
2753 WebTransformationMatrix identityMatrix; | 2753 WebTransformationMatrix identityMatrix; |
2754 FloatPoint anchor(0, 0); | 2754 FloatPoint anchor(0, 0); |
2755 FloatPoint position(50, 50); // this layer is positioned, and hit testing sh
ould correctly know where the layer is located. | 2755 FloatPoint position(50, 50); // this layer is positioned, and hit testing sh
ould correctly know where the layer is located. |
2756 IntSize bounds(100, 100); | 2756 IntSize bounds(100, 100); |
2757 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc
hor, position, bounds, false); | 2757 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc
hor, position, bounds, false); |
2758 root->setDrawsContent(true); | 2758 root->setDrawsContent(true); |
2759 | 2759 |
2760 std::vector<CCLayerImpl*> renderSurfaceLayerList; | 2760 std::vector<CCLayerImpl*> renderSurfaceLayerList; |
2761 int dummyMaxTextureSize = 512; | 2761 int dummyMaxTextureSize = 512; |
(...skipping 22 matching lines...) Expand all Loading... |
2784 testPoint = IntPoint(99, 99); | 2784 testPoint = IntPoint(99, 99); |
2785 resultLayer = CCLayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, re
nderSurfaceLayerList); | 2785 resultLayer = CCLayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, re
nderSurfaceLayerList); |
2786 ASSERT_TRUE(resultLayer); | 2786 ASSERT_TRUE(resultLayer); |
2787 EXPECT_EQ(12345, resultLayer->id()); | 2787 EXPECT_EQ(12345, resultLayer->id()); |
2788 } | 2788 } |
2789 | 2789 |
2790 TEST(CCLayerTreeHostCommonTest, verifyHitTestingForSingleRotatedLayer) | 2790 TEST(CCLayerTreeHostCommonTest, verifyHitTestingForSingleRotatedLayer) |
2791 { | 2791 { |
2792 DebugScopedSetImplThread thisScopeIsOnImplThread; | 2792 DebugScopedSetImplThread thisScopeIsOnImplThread; |
2793 | 2793 |
2794 OwnPtr<CCLayerImpl> root = CCLayerImpl::create(12345); | 2794 scoped_ptr<CCLayerImpl> root = CCLayerImpl::create(12345); |
2795 | 2795 |
2796 WebTransformationMatrix identityMatrix; | 2796 WebTransformationMatrix identityMatrix; |
2797 WebTransformationMatrix rotation45DegreesAboutCenter; | 2797 WebTransformationMatrix rotation45DegreesAboutCenter; |
2798 rotation45DegreesAboutCenter.translate(50, 50); | 2798 rotation45DegreesAboutCenter.translate(50, 50); |
2799 rotation45DegreesAboutCenter.rotate3d(0, 0, 45); | 2799 rotation45DegreesAboutCenter.rotate3d(0, 0, 45); |
2800 rotation45DegreesAboutCenter.translate(-50, -50); | 2800 rotation45DegreesAboutCenter.translate(-50, -50); |
2801 FloatPoint anchor(0, 0); | 2801 FloatPoint anchor(0, 0); |
2802 FloatPoint position(0, 0); | 2802 FloatPoint position(0, 0); |
2803 IntSize bounds(100, 100); | 2803 IntSize bounds(100, 100); |
2804 setLayerPropertiesForTesting(root.get(), rotation45DegreesAboutCenter, ident
ityMatrix, anchor, position, bounds, false); | 2804 setLayerPropertiesForTesting(root.get(), rotation45DegreesAboutCenter, ident
ityMatrix, anchor, position, bounds, false); |
(...skipping 30 matching lines...) Expand all Loading... |
2835 | 2835 |
2836 testPoint = IntPoint(-1, 50); | 2836 testPoint = IntPoint(-1, 50); |
2837 resultLayer = CCLayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, re
nderSurfaceLayerList); | 2837 resultLayer = CCLayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, re
nderSurfaceLayerList); |
2838 ASSERT_FALSE(resultLayer); | 2838 ASSERT_FALSE(resultLayer); |
2839 } | 2839 } |
2840 | 2840 |
2841 TEST(CCLayerTreeHostCommonTest, verifyHitTestingForSinglePerspectiveLayer) | 2841 TEST(CCLayerTreeHostCommonTest, verifyHitTestingForSinglePerspectiveLayer) |
2842 { | 2842 { |
2843 DebugScopedSetImplThread thisScopeIsOnImplThread; | 2843 DebugScopedSetImplThread thisScopeIsOnImplThread; |
2844 | 2844 |
2845 OwnPtr<CCLayerImpl> root = CCLayerImpl::create(12345); | 2845 scoped_ptr<CCLayerImpl> root = CCLayerImpl::create(12345); |
2846 | 2846 |
2847 WebTransformationMatrix identityMatrix; | 2847 WebTransformationMatrix identityMatrix; |
2848 | 2848 |
2849 // perspectiveProjectionAboutCenter * translationByZ is designed so that the
100 x 100 layer becomes 50 x 50, and remains centered at (50, 50). | 2849 // perspectiveProjectionAboutCenter * translationByZ is designed so that the
100 x 100 layer becomes 50 x 50, and remains centered at (50, 50). |
2850 WebTransformationMatrix perspectiveProjectionAboutCenter; | 2850 WebTransformationMatrix perspectiveProjectionAboutCenter; |
2851 perspectiveProjectionAboutCenter.translate(50, 50); | 2851 perspectiveProjectionAboutCenter.translate(50, 50); |
2852 perspectiveProjectionAboutCenter.applyPerspective(1); | 2852 perspectiveProjectionAboutCenter.applyPerspective(1); |
2853 perspectiveProjectionAboutCenter.translate(-50, -50); | 2853 perspectiveProjectionAboutCenter.translate(-50, -50); |
2854 WebTransformationMatrix translationByZ; | 2854 WebTransformationMatrix translationByZ; |
2855 translationByZ.translate3d(0, 0, -1); | 2855 translationByZ.translate3d(0, 0, -1); |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2897 // test makes sure that hit testing works correctly accounts for the content
s scale. | 2897 // test makes sure that hit testing works correctly accounts for the content
s scale. |
2898 // A contentsScale that is not 1 effectively forces a non-identity transform
between | 2898 // A contentsScale that is not 1 effectively forces a non-identity transform
between |
2899 // layer's content space and layer's origin space. The hit testing code must
take this into account. | 2899 // layer's content space and layer's origin space. The hit testing code must
take this into account. |
2900 // | 2900 // |
2901 // To test this, the layer is positioned at (25, 25), and is size (50, 50).
If | 2901 // To test this, the layer is positioned at (25, 25), and is size (50, 50).
If |
2902 // contentsScale is ignored, then hit testing will mis-interpret the visible
ContentRect | 2902 // contentsScale is ignored, then hit testing will mis-interpret the visible
ContentRect |
2903 // as being larger than the actual bounds of the layer. | 2903 // as being larger than the actual bounds of the layer. |
2904 // | 2904 // |
2905 DebugScopedSetImplThread thisScopeIsOnImplThread; | 2905 DebugScopedSetImplThread thisScopeIsOnImplThread; |
2906 | 2906 |
2907 OwnPtr<CCLayerImpl> root = CCLayerImpl::create(1); | 2907 scoped_ptr<CCLayerImpl> root = CCLayerImpl::create(1); |
2908 | 2908 |
2909 WebTransformationMatrix identityMatrix; | 2909 WebTransformationMatrix identityMatrix; |
2910 FloatPoint anchor(0, 0); | 2910 FloatPoint anchor(0, 0); |
2911 | 2911 |
2912 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc
hor, FloatPoint(0, 0), IntSize(100, 100), false); | 2912 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc
hor, FloatPoint(0, 0), IntSize(100, 100), false); |
2913 | 2913 |
2914 { | 2914 { |
2915 FloatPoint position(25, 25); | 2915 FloatPoint position(25, 25); |
2916 IntSize bounds(50, 50); | 2916 IntSize bounds(50, 50); |
2917 OwnPtr<CCLayerImpl> testLayer = CCLayerImpl::create(12345); | 2917 scoped_ptr<CCLayerImpl> testLayer = CCLayerImpl::create(12345); |
2918 setLayerPropertiesForTesting(testLayer.get(), identityMatrix, identityMa
trix, anchor, position, bounds, false); | 2918 setLayerPropertiesForTesting(testLayer.get(), identityMatrix, identityMa
trix, anchor, position, bounds, false); |
2919 | 2919 |
2920 // override contentBounds | 2920 // override contentBounds |
2921 testLayer->setContentBounds(IntSize(100, 100)); | 2921 testLayer->setContentBounds(IntSize(100, 100)); |
2922 | 2922 |
2923 testLayer->setDrawsContent(true); | 2923 testLayer->setDrawsContent(true); |
2924 root->addChild(testLayer.release()); | 2924 root->addChild(testLayer.Pass()); |
2925 } | 2925 } |
2926 | 2926 |
2927 std::vector<CCLayerImpl*> renderSurfaceLayerList; | 2927 std::vector<CCLayerImpl*> renderSurfaceLayerList; |
2928 int dummyMaxTextureSize = 512; | 2928 int dummyMaxTextureSize = 512; |
2929 CCLayerTreeHostCommon::calculateDrawTransforms(root.get(), root->bounds(), 1
, 0, dummyMaxTextureSize, renderSurfaceLayerList); | 2929 CCLayerTreeHostCommon::calculateDrawTransforms(root.get(), root->bounds(), 1
, 0, dummyMaxTextureSize, renderSurfaceLayerList); |
2930 | 2930 |
2931 // Sanity check the scenario we just created. | 2931 // Sanity check the scenario we just created. |
2932 // The visibleContentRect for testLayer is actually 100x100, even though its
layout size is 50x50, positioned at 25x25. | 2932 // The visibleContentRect for testLayer is actually 100x100, even though its
layout size is 50x50, positioned at 25x25. |
2933 CCLayerImpl* testLayer = root->children()[0]; | 2933 CCLayerImpl* testLayer = root->children()[0]; |
2934 EXPECT_RECT_EQ(IntRect(IntPoint::zero(), IntSize(100, 100)), testLayer->visi
bleContentRect()); | 2934 EXPECT_RECT_EQ(IntRect(IntPoint::zero(), IntSize(100, 100)), testLayer->visi
bleContentRect()); |
(...skipping 27 matching lines...) Expand all Loading... |
2962 | 2962 |
2963 TEST(CCLayerTreeHostCommonTest, verifyHitTestingForSimpleClippedLayer) | 2963 TEST(CCLayerTreeHostCommonTest, verifyHitTestingForSimpleClippedLayer) |
2964 { | 2964 { |
2965 // Test that hit-testing will only work for the visible portion of a layer,
and not | 2965 // Test that hit-testing will only work for the visible portion of a layer,
and not |
2966 // the entire layer bounds. Here we just test the simple axis-aligned case. | 2966 // the entire layer bounds. Here we just test the simple axis-aligned case. |
2967 DebugScopedSetImplThread thisScopeIsOnImplThread; | 2967 DebugScopedSetImplThread thisScopeIsOnImplThread; |
2968 | 2968 |
2969 WebTransformationMatrix identityMatrix; | 2969 WebTransformationMatrix identityMatrix; |
2970 FloatPoint anchor(0, 0); | 2970 FloatPoint anchor(0, 0); |
2971 | 2971 |
2972 OwnPtr<CCLayerImpl> root = CCLayerImpl::create(1); | 2972 scoped_ptr<CCLayerImpl> root = CCLayerImpl::create(1); |
2973 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc
hor, FloatPoint(0, 0), IntSize(100, 100), false); | 2973 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc
hor, FloatPoint(0, 0), IntSize(100, 100), false); |
2974 | 2974 |
2975 { | 2975 { |
2976 OwnPtr<CCLayerImpl> clippingLayer = CCLayerImpl::create(123); | 2976 scoped_ptr<CCLayerImpl> clippingLayer = CCLayerImpl::create(123); |
2977 FloatPoint position(25, 25); // this layer is positioned, and hit testin
g should correctly know where the layer is located. | 2977 FloatPoint position(25, 25); // this layer is positioned, and hit testin
g should correctly know where the layer is located. |
2978 IntSize bounds(50, 50); | 2978 IntSize bounds(50, 50); |
2979 setLayerPropertiesForTesting(clippingLayer.get(), identityMatrix, identi
tyMatrix, anchor, position, bounds, false); | 2979 setLayerPropertiesForTesting(clippingLayer.get(), identityMatrix, identi
tyMatrix, anchor, position, bounds, false); |
2980 clippingLayer->setMasksToBounds(true); | 2980 clippingLayer->setMasksToBounds(true); |
2981 | 2981 |
2982 OwnPtr<CCLayerImpl> child = CCLayerImpl::create(456); | 2982 scoped_ptr<CCLayerImpl> child = CCLayerImpl::create(456); |
2983 position = FloatPoint(-50, -50); | 2983 position = FloatPoint(-50, -50); |
2984 bounds = IntSize(300, 300); | 2984 bounds = IntSize(300, 300); |
2985 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix
, anchor, position, bounds, false); | 2985 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix
, anchor, position, bounds, false); |
2986 child->setDrawsContent(true); | 2986 child->setDrawsContent(true); |
2987 clippingLayer->addChild(child.release()); | 2987 clippingLayer->addChild(child.Pass()); |
2988 root->addChild(clippingLayer.release()); | 2988 root->addChild(clippingLayer.Pass()); |
2989 } | 2989 } |
2990 | 2990 |
2991 std::vector<CCLayerImpl*> renderSurfaceLayerList; | 2991 std::vector<CCLayerImpl*> renderSurfaceLayerList; |
2992 int dummyMaxTextureSize = 512; | 2992 int dummyMaxTextureSize = 512; |
2993 CCLayerTreeHostCommon::calculateDrawTransforms(root.get(), root->bounds(), 1
, 0, dummyMaxTextureSize, renderSurfaceLayerList); | 2993 CCLayerTreeHostCommon::calculateDrawTransforms(root.get(), root->bounds(), 1
, 0, dummyMaxTextureSize, renderSurfaceLayerList); |
2994 | 2994 |
2995 // Sanity check the scenario we just created. | 2995 // Sanity check the scenario we just created. |
2996 ASSERT_EQ(1u, renderSurfaceLayerList.size()); | 2996 ASSERT_EQ(1u, renderSurfaceLayerList.size()); |
2997 ASSERT_EQ(1u, root->renderSurface()->layerList().size()); | 2997 ASSERT_EQ(1u, root->renderSurface()->layerList().size()); |
2998 ASSERT_EQ(456, root->renderSurface()->layerList()[0]->id()); | 2998 ASSERT_EQ(456, root->renderSurface()->layerList()[0]->id()); |
(...skipping 28 matching lines...) Expand all Loading... |
3027 // algorithm needs to recognize that multiple parent layers may clip the lay
er, and | 3027 // algorithm needs to recognize that multiple parent layers may clip the lay
er, and |
3028 // should not actually hit those clipped areas. | 3028 // should not actually hit those clipped areas. |
3029 // | 3029 // |
3030 // The child and grandChild layers are both initialized to clip the rotatedL
eaf. The | 3030 // The child and grandChild layers are both initialized to clip the rotatedL
eaf. The |
3031 // child layer is rotated about the top-left corner, so that the root + chil
d clips | 3031 // child layer is rotated about the top-left corner, so that the root + chil
d clips |
3032 // combined create a triangle. The rotatedLeaf will only be visible where it
overlaps | 3032 // combined create a triangle. The rotatedLeaf will only be visible where it
overlaps |
3033 // this triangle. | 3033 // this triangle. |
3034 // | 3034 // |
3035 DebugScopedSetImplThread thisScopeIsOnImplThread; | 3035 DebugScopedSetImplThread thisScopeIsOnImplThread; |
3036 | 3036 |
3037 OwnPtr<CCLayerImpl> root = CCLayerImpl::create(123); | 3037 scoped_ptr<CCLayerImpl> root = CCLayerImpl::create(123); |
3038 | 3038 |
3039 WebTransformationMatrix identityMatrix; | 3039 WebTransformationMatrix identityMatrix; |
3040 FloatPoint anchor(0, 0); | 3040 FloatPoint anchor(0, 0); |
3041 FloatPoint position(0, 0); | 3041 FloatPoint position(0, 0); |
3042 IntSize bounds(100, 100); | 3042 IntSize bounds(100, 100); |
3043 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc
hor, position, bounds, false); | 3043 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc
hor, position, bounds, false); |
3044 root->setMasksToBounds(true); | 3044 root->setMasksToBounds(true); |
3045 | 3045 |
3046 { | 3046 { |
3047 OwnPtr<CCLayerImpl> child = CCLayerImpl::create(456); | 3047 scoped_ptr<CCLayerImpl> child = CCLayerImpl::create(456); |
3048 OwnPtr<CCLayerImpl> grandChild = CCLayerImpl::create(789); | 3048 scoped_ptr<CCLayerImpl> grandChild = CCLayerImpl::create(789); |
3049 OwnPtr<CCLayerImpl> rotatedLeaf = CCLayerImpl::create(2468); | 3049 scoped_ptr<CCLayerImpl> rotatedLeaf = CCLayerImpl::create(2468); |
3050 | 3050 |
3051 position = FloatPoint(10, 10); | 3051 position = FloatPoint(10, 10); |
3052 bounds = IntSize(80, 80); | 3052 bounds = IntSize(80, 80); |
3053 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix
, anchor, position, bounds, false); | 3053 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix
, anchor, position, bounds, false); |
3054 child->setMasksToBounds(true); | 3054 child->setMasksToBounds(true); |
3055 | 3055 |
3056 WebTransformationMatrix rotation45DegreesAboutCorner; | 3056 WebTransformationMatrix rotation45DegreesAboutCorner; |
3057 rotation45DegreesAboutCorner.rotate3d(0, 0, 45); | 3057 rotation45DegreesAboutCorner.rotate3d(0, 0, 45); |
3058 | 3058 |
3059 position = FloatPoint(0, 0); // remember, positioned with respect to its
parent which is already at 10, 10 | 3059 position = FloatPoint(0, 0); // remember, positioned with respect to its
parent which is already at 10, 10 |
3060 bounds = IntSize(200, 200); // to ensure it covers at least sqrt(2) * 10
0. | 3060 bounds = IntSize(200, 200); // to ensure it covers at least sqrt(2) * 10
0. |
3061 setLayerPropertiesForTesting(grandChild.get(), rotation45DegreesAboutCor
ner, identityMatrix, anchor, position, bounds, false); | 3061 setLayerPropertiesForTesting(grandChild.get(), rotation45DegreesAboutCor
ner, identityMatrix, anchor, position, bounds, false); |
3062 grandChild->setMasksToBounds(true); | 3062 grandChild->setMasksToBounds(true); |
3063 | 3063 |
3064 // Rotates about the center of the layer | 3064 // Rotates about the center of the layer |
3065 WebTransformationMatrix rotatedLeafTransform; | 3065 WebTransformationMatrix rotatedLeafTransform; |
3066 rotatedLeafTransform.translate(-10, -10); // cancel out the grandParent'
s position | 3066 rotatedLeafTransform.translate(-10, -10); // cancel out the grandParent'
s position |
3067 rotatedLeafTransform.rotate3d(0, 0, -45); // cancel out the corner 45-de
gree rotation of the parent. | 3067 rotatedLeafTransform.rotate3d(0, 0, -45); // cancel out the corner 45-de
gree rotation of the parent. |
3068 rotatedLeafTransform.translate(50, 50); | 3068 rotatedLeafTransform.translate(50, 50); |
3069 rotatedLeafTransform.rotate3d(0, 0, 45); | 3069 rotatedLeafTransform.rotate3d(0, 0, 45); |
3070 rotatedLeafTransform.translate(-50, -50); | 3070 rotatedLeafTransform.translate(-50, -50); |
3071 position = FloatPoint(0, 0); | 3071 position = FloatPoint(0, 0); |
3072 bounds = IntSize(100, 100); | 3072 bounds = IntSize(100, 100); |
3073 setLayerPropertiesForTesting(rotatedLeaf.get(), rotatedLeafTransform, id
entityMatrix, anchor, position, bounds, false); | 3073 setLayerPropertiesForTesting(rotatedLeaf.get(), rotatedLeafTransform, id
entityMatrix, anchor, position, bounds, false); |
3074 rotatedLeaf->setDrawsContent(true); | 3074 rotatedLeaf->setDrawsContent(true); |
3075 | 3075 |
3076 grandChild->addChild(rotatedLeaf.release()); | 3076 grandChild->addChild(rotatedLeaf.Pass()); |
3077 child->addChild(grandChild.release()); | 3077 child->addChild(grandChild.Pass()); |
3078 root->addChild(child.release()); | 3078 root->addChild(child.Pass()); |
3079 } | 3079 } |
3080 | 3080 |
3081 std::vector<CCLayerImpl*> renderSurfaceLayerList; | 3081 std::vector<CCLayerImpl*> renderSurfaceLayerList; |
3082 int dummyMaxTextureSize = 512; | 3082 int dummyMaxTextureSize = 512; |
3083 CCLayerTreeHostCommon::calculateDrawTransforms(root.get(), root->bounds(), 1
, 0, dummyMaxTextureSize, renderSurfaceLayerList); | 3083 CCLayerTreeHostCommon::calculateDrawTransforms(root.get(), root->bounds(), 1
, 0, dummyMaxTextureSize, renderSurfaceLayerList); |
3084 | 3084 |
3085 // Sanity check the scenario we just created. | 3085 // Sanity check the scenario we just created. |
3086 // The grandChild is expected to create a renderSurface because it masksToBo
unds and is not axis aligned. | 3086 // The grandChild is expected to create a renderSurface because it masksToBo
unds and is not axis aligned. |
3087 ASSERT_EQ(2u, renderSurfaceLayerList.size()); | 3087 ASSERT_EQ(2u, renderSurfaceLayerList.size()); |
3088 ASSERT_EQ(1u, renderSurfaceLayerList[0]->renderSurface()->layerList().size()
); | 3088 ASSERT_EQ(1u, renderSurfaceLayerList[0]->renderSurface()->layerList().size()
); |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3130 | 3130 |
3131 TEST(CCLayerTreeHostCommonTest, verifyHitTestingForNonClippingIntermediateLayer) | 3131 TEST(CCLayerTreeHostCommonTest, verifyHitTestingForNonClippingIntermediateLayer) |
3132 { | 3132 { |
3133 // This test checks that hit testing code does not accidentally clip to laye
r | 3133 // This test checks that hit testing code does not accidentally clip to laye
r |
3134 // bounds for a layer that actually does not clip. | 3134 // bounds for a layer that actually does not clip. |
3135 DebugScopedSetImplThread thisScopeIsOnImplThread; | 3135 DebugScopedSetImplThread thisScopeIsOnImplThread; |
3136 | 3136 |
3137 WebTransformationMatrix identityMatrix; | 3137 WebTransformationMatrix identityMatrix; |
3138 FloatPoint anchor(0, 0); | 3138 FloatPoint anchor(0, 0); |
3139 | 3139 |
3140 OwnPtr<CCLayerImpl> root = CCLayerImpl::create(1); | 3140 scoped_ptr<CCLayerImpl> root = CCLayerImpl::create(1); |
3141 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc
hor, FloatPoint(0, 0), IntSize(100, 100), false); | 3141 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc
hor, FloatPoint(0, 0), IntSize(100, 100), false); |
3142 | 3142 |
3143 { | 3143 { |
3144 OwnPtr<CCLayerImpl> intermediateLayer = CCLayerImpl::create(123); | 3144 scoped_ptr<CCLayerImpl> intermediateLayer = CCLayerImpl::create(123); |
3145 FloatPoint position(10, 10); // this layer is positioned, and hit testin
g should correctly know where the layer is located. | 3145 FloatPoint position(10, 10); // this layer is positioned, and hit testin
g should correctly know where the layer is located. |
3146 IntSize bounds(50, 50); | 3146 IntSize bounds(50, 50); |
3147 setLayerPropertiesForTesting(intermediateLayer.get(), identityMatrix, id
entityMatrix, anchor, position, bounds, false); | 3147 setLayerPropertiesForTesting(intermediateLayer.get(), identityMatrix, id
entityMatrix, anchor, position, bounds, false); |
3148 // Sanity check the intermediate layer should not clip. | 3148 // Sanity check the intermediate layer should not clip. |
3149 ASSERT_FALSE(intermediateLayer->masksToBounds()); | 3149 ASSERT_FALSE(intermediateLayer->masksToBounds()); |
3150 ASSERT_FALSE(intermediateLayer->maskLayer()); | 3150 ASSERT_FALSE(intermediateLayer->maskLayer()); |
3151 | 3151 |
3152 // The child of the intermediateLayer is translated so that it does not
overlap intermediateLayer at all. | 3152 // The child of the intermediateLayer is translated so that it does not
overlap intermediateLayer at all. |
3153 // If child is incorrectly clipped, we would not be able to hit it succe
ssfully. | 3153 // If child is incorrectly clipped, we would not be able to hit it succe
ssfully. |
3154 OwnPtr<CCLayerImpl> child = CCLayerImpl::create(456); | 3154 scoped_ptr<CCLayerImpl> child = CCLayerImpl::create(456); |
3155 position = FloatPoint(60, 60); // 70, 70 in screen space | 3155 position = FloatPoint(60, 60); // 70, 70 in screen space |
3156 bounds = IntSize(20, 20); | 3156 bounds = IntSize(20, 20); |
3157 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix
, anchor, position, bounds, false); | 3157 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix
, anchor, position, bounds, false); |
3158 child->setDrawsContent(true); | 3158 child->setDrawsContent(true); |
3159 intermediateLayer->addChild(child.release()); | 3159 intermediateLayer->addChild(child.Pass()); |
3160 root->addChild(intermediateLayer.release()); | 3160 root->addChild(intermediateLayer.Pass()); |
3161 } | 3161 } |
3162 | 3162 |
3163 std::vector<CCLayerImpl*> renderSurfaceLayerList; | 3163 std::vector<CCLayerImpl*> renderSurfaceLayerList; |
3164 int dummyMaxTextureSize = 512; | 3164 int dummyMaxTextureSize = 512; |
3165 CCLayerTreeHostCommon::calculateDrawTransforms(root.get(), root->bounds(), 1
, 0, dummyMaxTextureSize, renderSurfaceLayerList); | 3165 CCLayerTreeHostCommon::calculateDrawTransforms(root.get(), root->bounds(), 1
, 0, dummyMaxTextureSize, renderSurfaceLayerList); |
3166 | 3166 |
3167 // Sanity check the scenario we just created. | 3167 // Sanity check the scenario we just created. |
3168 ASSERT_EQ(1u, renderSurfaceLayerList.size()); | 3168 ASSERT_EQ(1u, renderSurfaceLayerList.size()); |
3169 ASSERT_EQ(1u, root->renderSurface()->layerList().size()); | 3169 ASSERT_EQ(1u, root->renderSurface()->layerList().size()); |
3170 ASSERT_EQ(456, root->renderSurface()->layerList()[0]->id()); | 3170 ASSERT_EQ(456, root->renderSurface()->layerList()[0]->id()); |
(...skipping 17 matching lines...) Expand all Loading... |
3188 resultLayer = CCLayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, re
nderSurfaceLayerList); | 3188 resultLayer = CCLayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, re
nderSurfaceLayerList); |
3189 ASSERT_TRUE(resultLayer); | 3189 ASSERT_TRUE(resultLayer); |
3190 EXPECT_EQ(456, resultLayer->id()); | 3190 EXPECT_EQ(456, resultLayer->id()); |
3191 } | 3191 } |
3192 | 3192 |
3193 | 3193 |
3194 TEST(CCLayerTreeHostCommonTest, verifyHitTestingForMultipleLayers) | 3194 TEST(CCLayerTreeHostCommonTest, verifyHitTestingForMultipleLayers) |
3195 { | 3195 { |
3196 DebugScopedSetImplThread thisScopeIsOnImplThread; | 3196 DebugScopedSetImplThread thisScopeIsOnImplThread; |
3197 | 3197 |
3198 OwnPtr<CCLayerImpl> root = CCLayerImpl::create(1); | 3198 scoped_ptr<CCLayerImpl> root = CCLayerImpl::create(1); |
3199 | 3199 |
3200 WebTransformationMatrix identityMatrix; | 3200 WebTransformationMatrix identityMatrix; |
3201 FloatPoint anchor(0, 0); | 3201 FloatPoint anchor(0, 0); |
3202 FloatPoint position(0, 0); | 3202 FloatPoint position(0, 0); |
3203 IntSize bounds(100, 100); | 3203 IntSize bounds(100, 100); |
3204 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc
hor, position, bounds, false); | 3204 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc
hor, position, bounds, false); |
3205 root->setDrawsContent(true); | 3205 root->setDrawsContent(true); |
3206 | 3206 |
3207 { | 3207 { |
3208 // child 1 and child2 are initialized to overlap between x=50 and x=60. | 3208 // child 1 and child2 are initialized to overlap between x=50 and x=60. |
3209 // grandChild is set to overlap both child1 and child2 between y=50 and
y=60. | 3209 // grandChild is set to overlap both child1 and child2 between y=50 and
y=60. |
3210 // The expected stacking order is: | 3210 // The expected stacking order is: |
3211 // (front) child2, (second) grandChild, (third) child1, and (back) the
root layer behind all other layers. | 3211 // (front) child2, (second) grandChild, (third) child1, and (back) the
root layer behind all other layers. |
3212 | 3212 |
3213 OwnPtr<CCLayerImpl> child1 = CCLayerImpl::create(2); | 3213 scoped_ptr<CCLayerImpl> child1 = CCLayerImpl::create(2); |
3214 OwnPtr<CCLayerImpl> child2 = CCLayerImpl::create(3); | 3214 scoped_ptr<CCLayerImpl> child2 = CCLayerImpl::create(3); |
3215 OwnPtr<CCLayerImpl> grandChild1 = CCLayerImpl::create(4); | 3215 scoped_ptr<CCLayerImpl> grandChild1 = CCLayerImpl::create(4); |
3216 | 3216 |
3217 position = FloatPoint(10, 10); | 3217 position = FloatPoint(10, 10); |
3218 bounds = IntSize(50, 50); | 3218 bounds = IntSize(50, 50); |
3219 setLayerPropertiesForTesting(child1.get(), identityMatrix, identityMatri
x, anchor, position, bounds, false); | 3219 setLayerPropertiesForTesting(child1.get(), identityMatrix, identityMatri
x, anchor, position, bounds, false); |
3220 child1->setDrawsContent(true); | 3220 child1->setDrawsContent(true); |
3221 | 3221 |
3222 position = FloatPoint(50, 10); | 3222 position = FloatPoint(50, 10); |
3223 bounds = IntSize(50, 50); | 3223 bounds = IntSize(50, 50); |
3224 setLayerPropertiesForTesting(child2.get(), identityMatrix, identityMatri
x, anchor, position, bounds, false); | 3224 setLayerPropertiesForTesting(child2.get(), identityMatrix, identityMatri
x, anchor, position, bounds, false); |
3225 child2->setDrawsContent(true); | 3225 child2->setDrawsContent(true); |
3226 | 3226 |
3227 // Remember that grandChild is positioned with respect to its parent (i.
e. child1). | 3227 // Remember that grandChild is positioned with respect to its parent (i.
e. child1). |
3228 // In screen space, the intended position is (10, 50), with size 100 x 5
0. | 3228 // In screen space, the intended position is (10, 50), with size 100 x 5
0. |
3229 position = FloatPoint(0, 40); | 3229 position = FloatPoint(0, 40); |
3230 bounds = IntSize(100, 50); | 3230 bounds = IntSize(100, 50); |
3231 setLayerPropertiesForTesting(grandChild1.get(), identityMatrix, identity
Matrix, anchor, position, bounds, false); | 3231 setLayerPropertiesForTesting(grandChild1.get(), identityMatrix, identity
Matrix, anchor, position, bounds, false); |
3232 grandChild1->setDrawsContent(true); | 3232 grandChild1->setDrawsContent(true); |
3233 | 3233 |
3234 child1->addChild(grandChild1.release()); | 3234 child1->addChild(grandChild1.Pass()); |
3235 root->addChild(child1.release()); | 3235 root->addChild(child1.Pass()); |
3236 root->addChild(child2.release()); | 3236 root->addChild(child2.Pass()); |
3237 } | 3237 } |
3238 | 3238 |
3239 CCLayerImpl* child1 = root->children()[0]; | 3239 CCLayerImpl* child1 = root->children()[0]; |
3240 CCLayerImpl* child2 = root->children()[1]; | 3240 CCLayerImpl* child2 = root->children()[1]; |
3241 CCLayerImpl* grandChild1 = child1->children()[0]; | 3241 CCLayerImpl* grandChild1 = child1->children()[0]; |
3242 | 3242 |
3243 std::vector<CCLayerImpl*> renderSurfaceLayerList; | 3243 std::vector<CCLayerImpl*> renderSurfaceLayerList; |
3244 int dummyMaxTextureSize = 512; | 3244 int dummyMaxTextureSize = 512; |
3245 CCLayerTreeHostCommon::calculateDrawTransforms(root.get(), root->bounds(), 1
, 0, dummyMaxTextureSize, renderSurfaceLayerList); | 3245 CCLayerTreeHostCommon::calculateDrawTransforms(root.get(), root->bounds(), 1
, 0, dummyMaxTextureSize, renderSurfaceLayerList); |
3246 | 3246 |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3293 } | 3293 } |
3294 | 3294 |
3295 TEST(CCLayerTreeHostCommonTest, verifyHitTestingForMultipleLayerLists) | 3295 TEST(CCLayerTreeHostCommonTest, verifyHitTestingForMultipleLayerLists) |
3296 { | 3296 { |
3297 // | 3297 // |
3298 // The geometry is set up similarly to the previous case, but | 3298 // The geometry is set up similarly to the previous case, but |
3299 // all layers are forced to be renderSurfaces now. | 3299 // all layers are forced to be renderSurfaces now. |
3300 // | 3300 // |
3301 DebugScopedSetImplThread thisScopeIsOnImplThread; | 3301 DebugScopedSetImplThread thisScopeIsOnImplThread; |
3302 | 3302 |
3303 OwnPtr<CCLayerImpl> root = CCLayerImpl::create(1); | 3303 scoped_ptr<CCLayerImpl> root = CCLayerImpl::create(1); |
3304 | 3304 |
3305 WebTransformationMatrix identityMatrix; | 3305 WebTransformationMatrix identityMatrix; |
3306 FloatPoint anchor(0, 0); | 3306 FloatPoint anchor(0, 0); |
3307 FloatPoint position(0, 0); | 3307 FloatPoint position(0, 0); |
3308 IntSize bounds(100, 100); | 3308 IntSize bounds(100, 100); |
3309 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc
hor, position, bounds, false); | 3309 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc
hor, position, bounds, false); |
3310 root->setDrawsContent(true); | 3310 root->setDrawsContent(true); |
3311 | 3311 |
3312 { | 3312 { |
3313 // child 1 and child2 are initialized to overlap between x=50 and x=60. | 3313 // child 1 and child2 are initialized to overlap between x=50 and x=60. |
3314 // grandChild is set to overlap both child1 and child2 between y=50 and
y=60. | 3314 // grandChild is set to overlap both child1 and child2 between y=50 and
y=60. |
3315 // The expected stacking order is: | 3315 // The expected stacking order is: |
3316 // (front) child2, (second) grandChild, (third) child1, and (back) the
root layer behind all other layers. | 3316 // (front) child2, (second) grandChild, (third) child1, and (back) the
root layer behind all other layers. |
3317 | 3317 |
3318 OwnPtr<CCLayerImpl> child1 = CCLayerImpl::create(2); | 3318 scoped_ptr<CCLayerImpl> child1 = CCLayerImpl::create(2); |
3319 OwnPtr<CCLayerImpl> child2 = CCLayerImpl::create(3); | 3319 scoped_ptr<CCLayerImpl> child2 = CCLayerImpl::create(3); |
3320 OwnPtr<CCLayerImpl> grandChild1 = CCLayerImpl::create(4); | 3320 scoped_ptr<CCLayerImpl> grandChild1 = CCLayerImpl::create(4); |
3321 | 3321 |
3322 position = FloatPoint(10, 10); | 3322 position = FloatPoint(10, 10); |
3323 bounds = IntSize(50, 50); | 3323 bounds = IntSize(50, 50); |
3324 setLayerPropertiesForTesting(child1.get(), identityMatrix, identityMatri
x, anchor, position, bounds, false); | 3324 setLayerPropertiesForTesting(child1.get(), identityMatrix, identityMatri
x, anchor, position, bounds, false); |
3325 child1->setDrawsContent(true); | 3325 child1->setDrawsContent(true); |
3326 child1->setForceRenderSurface(true); | 3326 child1->setForceRenderSurface(true); |
3327 | 3327 |
3328 position = FloatPoint(50, 10); | 3328 position = FloatPoint(50, 10); |
3329 bounds = IntSize(50, 50); | 3329 bounds = IntSize(50, 50); |
3330 setLayerPropertiesForTesting(child2.get(), identityMatrix, identityMatri
x, anchor, position, bounds, false); | 3330 setLayerPropertiesForTesting(child2.get(), identityMatrix, identityMatri
x, anchor, position, bounds, false); |
3331 child2->setDrawsContent(true); | 3331 child2->setDrawsContent(true); |
3332 child2->setForceRenderSurface(true); | 3332 child2->setForceRenderSurface(true); |
3333 | 3333 |
3334 // Remember that grandChild is positioned with respect to its parent (i.
e. child1). | 3334 // Remember that grandChild is positioned with respect to its parent (i.
e. child1). |
3335 // In screen space, the intended position is (10, 50), with size 100 x 5
0. | 3335 // In screen space, the intended position is (10, 50), with size 100 x 5
0. |
3336 position = FloatPoint(0, 40); | 3336 position = FloatPoint(0, 40); |
3337 bounds = IntSize(100, 50); | 3337 bounds = IntSize(100, 50); |
3338 setLayerPropertiesForTesting(grandChild1.get(), identityMatrix, identity
Matrix, anchor, position, bounds, false); | 3338 setLayerPropertiesForTesting(grandChild1.get(), identityMatrix, identity
Matrix, anchor, position, bounds, false); |
3339 grandChild1->setDrawsContent(true); | 3339 grandChild1->setDrawsContent(true); |
3340 grandChild1->setForceRenderSurface(true); | 3340 grandChild1->setForceRenderSurface(true); |
3341 | 3341 |
3342 child1->addChild(grandChild1.release()); | 3342 child1->addChild(grandChild1.Pass()); |
3343 root->addChild(child1.release()); | 3343 root->addChild(child1.Pass()); |
3344 root->addChild(child2.release()); | 3344 root->addChild(child2.Pass()); |
3345 } | 3345 } |
3346 | 3346 |
3347 CCLayerImpl* child1 = root->children()[0]; | 3347 CCLayerImpl* child1 = root->children()[0]; |
3348 CCLayerImpl* child2 = root->children()[1]; | 3348 CCLayerImpl* child2 = root->children()[1]; |
3349 CCLayerImpl* grandChild1 = child1->children()[0]; | 3349 CCLayerImpl* grandChild1 = child1->children()[0]; |
3350 | 3350 |
3351 std::vector<CCLayerImpl*> renderSurfaceLayerList; | 3351 std::vector<CCLayerImpl*> renderSurfaceLayerList; |
3352 int dummyMaxTextureSize = 512; | 3352 int dummyMaxTextureSize = 512; |
3353 CCLayerTreeHostCommon::calculateDrawTransforms(root.get(), root->bounds(), 1
, 0, dummyMaxTextureSize, renderSurfaceLayerList); | 3353 CCLayerTreeHostCommon::calculateDrawTransforms(root.get(), root->bounds(), 1
, 0, dummyMaxTextureSize, renderSurfaceLayerList); |
3354 | 3354 |
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3577 int nonexistentId = -1; | 3577 int nonexistentId = -1; |
3578 EXPECT_EQ(root, CCLayerTreeHostCommon::findLayerInSubtree(root.get(), root->
id())); | 3578 EXPECT_EQ(root, CCLayerTreeHostCommon::findLayerInSubtree(root.get(), root->
id())); |
3579 EXPECT_EQ(child, CCLayerTreeHostCommon::findLayerInSubtree(root.get(), child
->id())); | 3579 EXPECT_EQ(child, CCLayerTreeHostCommon::findLayerInSubtree(root.get(), child
->id())); |
3580 EXPECT_EQ(grandChild, CCLayerTreeHostCommon::findLayerInSubtree(root.get(),
grandChild->id())); | 3580 EXPECT_EQ(grandChild, CCLayerTreeHostCommon::findLayerInSubtree(root.get(),
grandChild->id())); |
3581 EXPECT_EQ(maskLayer, CCLayerTreeHostCommon::findLayerInSubtree(root.get(), m
askLayer->id())); | 3581 EXPECT_EQ(maskLayer, CCLayerTreeHostCommon::findLayerInSubtree(root.get(), m
askLayer->id())); |
3582 EXPECT_EQ(replicaLayer, CCLayerTreeHostCommon::findLayerInSubtree(root.get()
, replicaLayer->id())); | 3582 EXPECT_EQ(replicaLayer, CCLayerTreeHostCommon::findLayerInSubtree(root.get()
, replicaLayer->id())); |
3583 EXPECT_EQ(0, CCLayerTreeHostCommon::findLayerInSubtree(root.get(), nonexiste
ntId)); | 3583 EXPECT_EQ(0, CCLayerTreeHostCommon::findLayerInSubtree(root.get(), nonexiste
ntId)); |
3584 } | 3584 } |
3585 | 3585 |
3586 } // namespace | 3586 } // namespace |
OLD | NEW |