| 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 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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); |
| 89 ret.setM33(1); | 89 ret.setM33(1); |
| 90 ret.setM34(0); | 90 ret.setM34(0); |
| 91 ret.setM43(0); | 91 ret.setM43(0); |
| 92 return ret; | 92 return ret; |
| 93 } | 93 } |
| 94 | 94 |
| 95 PassOwnPtr<CCLayerImpl> createTreeForFixedPositionTests() | 95 scoped_ptr<CCLayerImpl> createTreeForFixedPositionTests() |
| 96 { | 96 { |
| 97 OwnPtr<CCLayerImpl> root = CCLayerImpl::create(1); | 97 scoped_ptr<CCLayerImpl> root = CCLayerImpl::create(1); |
| 98 OwnPtr<CCLayerImpl> child = CCLayerImpl::create(2); | 98 scoped_ptr<CCLayerImpl> child = CCLayerImpl::create(2); |
| 99 OwnPtr<CCLayerImpl> grandChild = CCLayerImpl::create(3); | 99 scoped_ptr<CCLayerImpl> grandChild = CCLayerImpl::create(3); |
| 100 OwnPtr<CCLayerImpl> greatGrandChild = CCLayerImpl::create(4); | 100 scoped_ptr<CCLayerImpl> greatGrandChild = CCLayerImpl::create(4); |
| 101 | 101 |
| 102 WebTransformationMatrix IdentityMatrix; | 102 WebTransformationMatrix IdentityMatrix; |
| 103 FloatPoint anchor(0, 0); | 103 FloatPoint anchor(0, 0); |
| 104 FloatPoint position(0, 0); | 104 FloatPoint position(0, 0); |
| 105 IntSize bounds(100, 100); | 105 IntSize bounds(100, 100); |
| 106 setLayerPropertiesForTesting(root.get(), IdentityMatrix, IdentityMatrix, anc
hor, position, bounds, false); | 106 setLayerPropertiesForTesting(root.get(), IdentityMatrix, IdentityMatrix, anc
hor, position, bounds, false); |
| 107 setLayerPropertiesForTesting(child.get(), IdentityMatrix, IdentityMatrix, an
chor, position, bounds, false); | 107 setLayerPropertiesForTesting(child.get(), IdentityMatrix, IdentityMatrix, an
chor, position, bounds, false); |
| 108 setLayerPropertiesForTesting(grandChild.get(), IdentityMatrix, IdentityMatri
x, anchor, position, bounds, false); | 108 setLayerPropertiesForTesting(grandChild.get(), IdentityMatrix, IdentityMatri
x, anchor, position, bounds, false); |
| 109 setLayerPropertiesForTesting(greatGrandChild.get(), IdentityMatrix, Identity
Matrix, anchor, position, bounds, false); | 109 setLayerPropertiesForTesting(greatGrandChild.get(), IdentityMatrix, Identity
Matrix, anchor, position, bounds, false); |
| 110 | 110 |
| 111 grandChild->addChild(greatGrandChild.release()); | 111 grandChild->addChild(greatGrandChild.Pass()); |
| 112 child->addChild(grandChild.release()); | 112 child->addChild(grandChild.Pass()); |
| 113 root->addChild(child.release()); | 113 root->addChild(child.Pass()); |
| 114 | 114 |
| 115 return root.release(); | 115 return root.Pass(); |
| 116 } | 116 } |
| 117 | 117 |
| 118 class LayerChromiumWithForcedDrawsContent : public LayerChromium { | 118 class LayerChromiumWithForcedDrawsContent : public LayerChromium { |
| 119 public: | 119 public: |
| 120 LayerChromiumWithForcedDrawsContent() | 120 LayerChromiumWithForcedDrawsContent() |
| 121 : LayerChromium() | 121 : LayerChromium() |
| 122 { | 122 { |
| 123 } | 123 } |
| 124 | 124 |
| 125 virtual bool drawsContent() const OVERRIDE { return true; } | 125 virtual bool drawsContent() const OVERRIDE { return true; } |
| (...skipping 608 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 734 EXPECT_FALSE(renderSurface1->renderSurface()); | 734 EXPECT_FALSE(renderSurface1->renderSurface()); |
| 735 EXPECT_EQ(1U, renderSurfaceLayerList.size()); | 735 EXPECT_EQ(1U, renderSurfaceLayerList.size()); |
| 736 } | 736 } |
| 737 | 737 |
| 738 TEST(CCLayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerWit
hDirectContainer) | 738 TEST(CCLayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerWit
hDirectContainer) |
| 739 { | 739 { |
| 740 // This test checks for correct scroll compensation when the fixed-position
container | 740 // This test checks for correct scroll compensation when the fixed-position
container |
| 741 // is the direct parent of the fixed-position layer. | 741 // is the direct parent of the fixed-position layer. |
| 742 | 742 |
| 743 DebugScopedSetImplThread scopedImplThread; | 743 DebugScopedSetImplThread scopedImplThread; |
| 744 OwnPtr<CCLayerImpl> root = createTreeForFixedPositionTests(); | 744 scoped_ptr<CCLayerImpl> root = createTreeForFixedPositionTests(); |
| 745 CCLayerImpl* child = root->children()[0]; | 745 CCLayerImpl* child = root->children()[0]; |
| 746 CCLayerImpl* grandChild = child->children()[0]; | 746 CCLayerImpl* grandChild = child->children()[0]; |
| 747 | 747 |
| 748 child->setIsContainerForFixedPositionLayers(true); | 748 child->setIsContainerForFixedPositionLayers(true); |
| 749 grandChild->setFixedToContainerLayer(true); | 749 grandChild->setFixedToContainerLayer(true); |
| 750 | 750 |
| 751 // Case 1: scrollDelta of 0, 0 | 751 // Case 1: scrollDelta of 0, 0 |
| 752 child->setScrollDelta(IntSize(0, 0)); | 752 child->setScrollDelta(IntSize(0, 0)); |
| 753 executeCalculateDrawTransformsAndVisibility(root.get()); | 753 executeCalculateDrawTransformsAndVisibility(root.get()); |
| 754 | 754 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 775 // This test checks for correct scroll compensation when the fixed-position
container | 775 // This test checks for correct scroll compensation when the fixed-position
container |
| 776 // is the direct parent of the fixed-position layer, but that container is t
ransformed. | 776 // is the direct parent of the fixed-position layer, but that container is t
ransformed. |
| 777 // In this case, the fixed position element inherits the container's transfo
rm, | 777 // In this case, the fixed position element inherits the container's transfo
rm, |
| 778 // but the scrollDelta that has to be undone should not be affected by that
transform. | 778 // but the scrollDelta that has to be undone should not be affected by that
transform. |
| 779 // | 779 // |
| 780 // Transforms are in general non-commutative; using something like a non-uni
form scale | 780 // Transforms are in general non-commutative; using something like a non-uni
form scale |
| 781 // helps to verify that translations and non-uniform scales are applied in t
he correct | 781 // helps to verify that translations and non-uniform scales are applied in t
he correct |
| 782 // order. | 782 // order. |
| 783 | 783 |
| 784 DebugScopedSetImplThread scopedImplThread; | 784 DebugScopedSetImplThread scopedImplThread; |
| 785 OwnPtr<CCLayerImpl> root = createTreeForFixedPositionTests(); | 785 scoped_ptr<CCLayerImpl> root = createTreeForFixedPositionTests(); |
| 786 CCLayerImpl* child = root->children()[0]; | 786 CCLayerImpl* child = root->children()[0]; |
| 787 CCLayerImpl* grandChild = child->children()[0]; | 787 CCLayerImpl* grandChild = child->children()[0]; |
| 788 | 788 |
| 789 // This scale will cause child and grandChild to be effectively 200 x 800 wi
th respect to the renderTarget. | 789 // This scale will cause child and grandChild to be effectively 200 x 800 wi
th respect to the renderTarget. |
| 790 WebTransformationMatrix nonUniformScale; | 790 WebTransformationMatrix nonUniformScale; |
| 791 nonUniformScale.scaleNonUniform(2, 8); | 791 nonUniformScale.scaleNonUniform(2, 8); |
| 792 child->setTransform(nonUniformScale); | 792 child->setTransform(nonUniformScale); |
| 793 | 793 |
| 794 child->setIsContainerForFixedPositionLayers(true); | 794 child->setIsContainerForFixedPositionLayers(true); |
| 795 grandChild->setFixedToContainerLayer(true); | 795 grandChild->setFixedToContainerLayer(true); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 818 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->drawTransform
()); | 818 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->drawTransform
()); |
| 819 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->dra
wTransform()); | 819 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->dra
wTransform()); |
| 820 } | 820 } |
| 821 | 821 |
| 822 TEST(CCLayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerWit
hDistantContainer) | 822 TEST(CCLayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerWit
hDistantContainer) |
| 823 { | 823 { |
| 824 // This test checks for correct scroll compensation when the fixed-position
container | 824 // This test checks for correct scroll compensation when the fixed-position
container |
| 825 // is NOT the direct parent of the fixed-position layer. | 825 // is NOT the direct parent of the fixed-position layer. |
| 826 DebugScopedSetImplThread scopedImplThread; | 826 DebugScopedSetImplThread scopedImplThread; |
| 827 | 827 |
| 828 OwnPtr<CCLayerImpl> root = createTreeForFixedPositionTests(); | 828 scoped_ptr<CCLayerImpl> root = createTreeForFixedPositionTests(); |
| 829 CCLayerImpl* child = root->children()[0]; | 829 CCLayerImpl* child = root->children()[0]; |
| 830 CCLayerImpl* grandChild = child->children()[0]; | 830 CCLayerImpl* grandChild = child->children()[0]; |
| 831 CCLayerImpl* greatGrandChild = grandChild->children()[0]; | 831 CCLayerImpl* greatGrandChild = grandChild->children()[0]; |
| 832 | 832 |
| 833 child->setIsContainerForFixedPositionLayers(true); | 833 child->setIsContainerForFixedPositionLayers(true); |
| 834 grandChild->setPosition(FloatPoint(8, 6)); | 834 grandChild->setPosition(FloatPoint(8, 6)); |
| 835 greatGrandChild->setFixedToContainerLayer(true); | 835 greatGrandChild->setFixedToContainerLayer(true); |
| 836 | 836 |
| 837 // Case 1: scrollDelta of 0, 0 | 837 // Case 1: scrollDelta of 0, 0 |
| 838 child->setScrollDelta(IntSize(0, 0)); | 838 child->setScrollDelta(IntSize(0, 0)); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 862 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGreatGrandChildTransform, greatGrand
Child->drawTransform()); | 862 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGreatGrandChildTransform, greatGrand
Child->drawTransform()); |
| 863 } | 863 } |
| 864 | 864 |
| 865 TEST(CCLayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerWit
hDistantContainerAndTransforms) | 865 TEST(CCLayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerWit
hDistantContainerAndTransforms) |
| 866 { | 866 { |
| 867 // This test checks for correct scroll compensation when the fixed-position
container | 867 // This test checks for correct scroll compensation when the fixed-position
container |
| 868 // is NOT the direct parent of the fixed-position layer, and the hierarchy h
as various | 868 // is NOT the direct parent of the fixed-position layer, and the hierarchy h
as various |
| 869 // transforms that have to be processed in the correct order. | 869 // transforms that have to be processed in the correct order. |
| 870 DebugScopedSetImplThread scopedImplThread; | 870 DebugScopedSetImplThread scopedImplThread; |
| 871 | 871 |
| 872 OwnPtr<CCLayerImpl> root = createTreeForFixedPositionTests(); | 872 scoped_ptr<CCLayerImpl> root = createTreeForFixedPositionTests(); |
| 873 CCLayerImpl* child = root->children()[0]; | 873 CCLayerImpl* child = root->children()[0]; |
| 874 CCLayerImpl* grandChild = child->children()[0]; | 874 CCLayerImpl* grandChild = child->children()[0]; |
| 875 CCLayerImpl* greatGrandChild = grandChild->children()[0]; | 875 CCLayerImpl* greatGrandChild = grandChild->children()[0]; |
| 876 | 876 |
| 877 WebTransformationMatrix rotationAboutZ; | 877 WebTransformationMatrix rotationAboutZ; |
| 878 rotationAboutZ.rotate3d(0, 0, 90); | 878 rotationAboutZ.rotate3d(0, 0, 90); |
| 879 | 879 |
| 880 child->setIsContainerForFixedPositionLayers(true); | 880 child->setIsContainerForFixedPositionLayers(true); |
| 881 child->setTransform(rotationAboutZ); | 881 child->setTransform(rotationAboutZ); |
| 882 grandChild->setPosition(FloatPoint(8, 6)); | 882 grandChild->setPosition(FloatPoint(8, 6)); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 924 TEST(CCLayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerWit
hMultipleScrollDeltas) | 924 TEST(CCLayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerWit
hMultipleScrollDeltas) |
| 925 { | 925 { |
| 926 // This test checks for correct scroll compensation when the fixed-position
container | 926 // This test checks for correct scroll compensation when the fixed-position
container |
| 927 // has multiple ancestors that have nonzero scrollDelta before reaching the
space where the layer is fixed. | 927 // has multiple ancestors that have nonzero scrollDelta before reaching the
space where the layer is fixed. |
| 928 // In this test, each scrollDelta occurs in a different space because of eac
h layer's local transform. | 928 // In this test, each scrollDelta occurs in a different space because of eac
h layer's local transform. |
| 929 // This test checks for correct scroll compensation when the fixed-position
container | 929 // This test checks for correct scroll compensation when the fixed-position
container |
| 930 // is NOT the direct parent of the fixed-position layer, and the hierarchy h
as various | 930 // is NOT the direct parent of the fixed-position layer, and the hierarchy h
as various |
| 931 // transforms that have to be processed in the correct order. | 931 // transforms that have to be processed in the correct order. |
| 932 DebugScopedSetImplThread scopedImplThread; | 932 DebugScopedSetImplThread scopedImplThread; |
| 933 | 933 |
| 934 OwnPtr<CCLayerImpl> root = createTreeForFixedPositionTests(); | 934 scoped_ptr<CCLayerImpl> root = createTreeForFixedPositionTests(); |
| 935 CCLayerImpl* child = root->children()[0]; | 935 CCLayerImpl* child = root->children()[0]; |
| 936 CCLayerImpl* grandChild = child->children()[0]; | 936 CCLayerImpl* grandChild = child->children()[0]; |
| 937 CCLayerImpl* greatGrandChild = grandChild->children()[0]; | 937 CCLayerImpl* greatGrandChild = grandChild->children()[0]; |
| 938 | 938 |
| 939 WebTransformationMatrix rotationAboutZ; | 939 WebTransformationMatrix rotationAboutZ; |
| 940 rotationAboutZ.rotate3d(0, 0, 90); | 940 rotationAboutZ.rotate3d(0, 0, 90); |
| 941 | 941 |
| 942 child->setIsContainerForFixedPositionLayers(true); | 942 child->setIsContainerForFixedPositionLayers(true); |
| 943 child->setTransform(rotationAboutZ); | 943 child->setTransform(rotationAboutZ); |
| 944 grandChild->setPosition(FloatPoint(8, 6)); | 944 grandChild->setPosition(FloatPoint(8, 6)); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 986 } | 986 } |
| 987 | 987 |
| 988 TEST(CCLayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerWit
hIntermediateSurfaceAndTransforms) | 988 TEST(CCLayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerWit
hIntermediateSurfaceAndTransforms) |
| 989 { | 989 { |
| 990 // This test checks for correct scroll compensation when the fixed-position
container | 990 // This test checks for correct scroll compensation when the fixed-position
container |
| 991 // contributes to a different renderSurface than the fixed-position layer. I
n this | 991 // contributes to a different renderSurface than the fixed-position layer. I
n this |
| 992 // case, the surface drawTransforms also have to be accounted for when check
ing the | 992 // case, the surface drawTransforms also have to be accounted for when check
ing the |
| 993 // scrollDelta. | 993 // scrollDelta. |
| 994 DebugScopedSetImplThread scopedImplThread; | 994 DebugScopedSetImplThread scopedImplThread; |
| 995 | 995 |
| 996 OwnPtr<CCLayerImpl> root = createTreeForFixedPositionTests(); | 996 scoped_ptr<CCLayerImpl> root = createTreeForFixedPositionTests(); |
| 997 CCLayerImpl* child = root->children()[0]; | 997 CCLayerImpl* child = root->children()[0]; |
| 998 CCLayerImpl* grandChild = child->children()[0]; | 998 CCLayerImpl* grandChild = child->children()[0]; |
| 999 CCLayerImpl* greatGrandChild = grandChild->children()[0]; | 999 CCLayerImpl* greatGrandChild = grandChild->children()[0]; |
| 1000 | 1000 |
| 1001 child->setIsContainerForFixedPositionLayers(true); | 1001 child->setIsContainerForFixedPositionLayers(true); |
| 1002 grandChild->setPosition(FloatPoint(8, 6)); | 1002 grandChild->setPosition(FloatPoint(8, 6)); |
| 1003 grandChild->setForceRenderSurface(true); | 1003 grandChild->setForceRenderSurface(true); |
| 1004 greatGrandChild->setFixedToContainerLayer(true); | 1004 greatGrandChild->setFixedToContainerLayer(true); |
| 1005 greatGrandChild->setDrawsContent(true); | 1005 greatGrandChild->setDrawsContent(true); |
| 1006 | 1006 |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1059 } | 1059 } |
| 1060 | 1060 |
| 1061 TEST(CCLayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerWit
hMultipleIntermediateSurfaces) | 1061 TEST(CCLayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerWit
hMultipleIntermediateSurfaces) |
| 1062 { | 1062 { |
| 1063 // This test checks for correct scroll compensation when the fixed-position
container | 1063 // This test checks for correct scroll compensation when the fixed-position
container |
| 1064 // contributes to a different renderSurface than the fixed-position layer, w
ith | 1064 // contributes to a different renderSurface than the fixed-position layer, w
ith |
| 1065 // additional renderSurfaces in-between. This checks that the conversion to
ancestor | 1065 // additional renderSurfaces in-between. This checks that the conversion to
ancestor |
| 1066 // surfaces is accumulated properly in the final matrix transform. | 1066 // surfaces is accumulated properly in the final matrix transform. |
| 1067 DebugScopedSetImplThread scopedImplThread; | 1067 DebugScopedSetImplThread scopedImplThread; |
| 1068 | 1068 |
| 1069 OwnPtr<CCLayerImpl> root = createTreeForFixedPositionTests(); | 1069 scoped_ptr<CCLayerImpl> root = createTreeForFixedPositionTests(); |
| 1070 CCLayerImpl* child = root->children()[0]; | 1070 CCLayerImpl* child = root->children()[0]; |
| 1071 CCLayerImpl* grandChild = child->children()[0]; | 1071 CCLayerImpl* grandChild = child->children()[0]; |
| 1072 CCLayerImpl* greatGrandChild = grandChild->children()[0]; | 1072 CCLayerImpl* greatGrandChild = grandChild->children()[0]; |
| 1073 | 1073 |
| 1074 // Add one more layer to the test tree for this scenario. | 1074 // Add one more layer to the test tree for this scenario. |
| 1075 { | 1075 { |
| 1076 WebTransformationMatrix identity; | 1076 WebTransformationMatrix identity; |
| 1077 OwnPtr<CCLayerImpl> fixedPositionChild = CCLayerImpl::create(5); | 1077 scoped_ptr<CCLayerImpl> fixedPositionChild = CCLayerImpl::create(5); |
| 1078 setLayerPropertiesForTesting(fixedPositionChild.get(), identity, identit
y, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100), false); | 1078 setLayerPropertiesForTesting(fixedPositionChild.get(), identity, identit
y, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100), false); |
| 1079 greatGrandChild->addChild(fixedPositionChild.release()); | 1079 greatGrandChild->addChild(fixedPositionChild.Pass()); |
| 1080 } | 1080 } |
| 1081 CCLayerImpl* fixedPositionChild = greatGrandChild->children()[0]; | 1081 CCLayerImpl* fixedPositionChild = greatGrandChild->children()[0]; |
| 1082 | 1082 |
| 1083 // Actually set up the scenario here. | 1083 // Actually set up the scenario here. |
| 1084 child->setIsContainerForFixedPositionLayers(true); | 1084 child->setIsContainerForFixedPositionLayers(true); |
| 1085 grandChild->setPosition(FloatPoint(8, 6)); | 1085 grandChild->setPosition(FloatPoint(8, 6)); |
| 1086 grandChild->setForceRenderSurface(true); | 1086 grandChild->setForceRenderSurface(true); |
| 1087 greatGrandChild->setPosition(FloatPoint(40, 60)); | 1087 greatGrandChild->setPosition(FloatPoint(40, 60)); |
| 1088 greatGrandChild->setForceRenderSurface(true); | 1088 greatGrandChild->setForceRenderSurface(true); |
| 1089 fixedPositionChild->setFixedToContainerLayer(true); | 1089 fixedPositionChild->setFixedToContainerLayer(true); |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1170 } | 1170 } |
| 1171 | 1171 |
| 1172 TEST(CCLayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerWit
hContainerLayerThatHasSurface) | 1172 TEST(CCLayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerWit
hContainerLayerThatHasSurface) |
| 1173 { | 1173 { |
| 1174 // This test checks for correct scroll compensation when the fixed-position
container | 1174 // This test checks for correct scroll compensation when the fixed-position
container |
| 1175 // itself has a renderSurface. In this case, the container layer should be t
reated | 1175 // itself has a renderSurface. In this case, the container layer should be t
reated |
| 1176 // like a layer that contributes to a renderTarget, and that renderTarget | 1176 // like a layer that contributes to a renderTarget, and that renderTarget |
| 1177 // is completely irrelevant; it should not affect the scroll compensation. | 1177 // is completely irrelevant; it should not affect the scroll compensation. |
| 1178 DebugScopedSetImplThread scopedImplThread; | 1178 DebugScopedSetImplThread scopedImplThread; |
| 1179 | 1179 |
| 1180 OwnPtr<CCLayerImpl> root = createTreeForFixedPositionTests(); | 1180 scoped_ptr<CCLayerImpl> root = createTreeForFixedPositionTests(); |
| 1181 CCLayerImpl* child = root->children()[0]; | 1181 CCLayerImpl* child = root->children()[0]; |
| 1182 CCLayerImpl* grandChild = child->children()[0]; | 1182 CCLayerImpl* grandChild = child->children()[0]; |
| 1183 | 1183 |
| 1184 child->setIsContainerForFixedPositionLayers(true); | 1184 child->setIsContainerForFixedPositionLayers(true); |
| 1185 child->setForceRenderSurface(true); | 1185 child->setForceRenderSurface(true); |
| 1186 grandChild->setFixedToContainerLayer(true); | 1186 grandChild->setFixedToContainerLayer(true); |
| 1187 grandChild->setDrawsContent(true); | 1187 grandChild->setDrawsContent(true); |
| 1188 | 1188 |
| 1189 // Case 1: scrollDelta of 0, 0 | 1189 // Case 1: scrollDelta of 0, 0 |
| 1190 child->setScrollDelta(IntSize(0, 0)); | 1190 child->setScrollDelta(IntSize(0, 0)); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 1217 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->dra
wTransform()); | 1217 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->dra
wTransform()); |
| 1218 } | 1218 } |
| 1219 | 1219 |
| 1220 TEST(CCLayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerTha
tIsAlsoFixedPositionContainer) | 1220 TEST(CCLayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerTha
tIsAlsoFixedPositionContainer) |
| 1221 { | 1221 { |
| 1222 // This test checks the scenario where a fixed-position layer also happens t
o be a | 1222 // This test checks the scenario where a fixed-position layer also happens t
o be a |
| 1223 // container itself for a descendant fixed position layer. In particular, th
e layer | 1223 // container itself for a descendant fixed position layer. In particular, th
e layer |
| 1224 // should not accidentally be fixed to itself. | 1224 // should not accidentally be fixed to itself. |
| 1225 DebugScopedSetImplThread scopedImplThread; | 1225 DebugScopedSetImplThread scopedImplThread; |
| 1226 | 1226 |
| 1227 OwnPtr<CCLayerImpl> root = createTreeForFixedPositionTests(); | 1227 scoped_ptr<CCLayerImpl> root = createTreeForFixedPositionTests(); |
| 1228 CCLayerImpl* child = root->children()[0]; | 1228 CCLayerImpl* child = root->children()[0]; |
| 1229 CCLayerImpl* grandChild = child->children()[0]; | 1229 CCLayerImpl* grandChild = child->children()[0]; |
| 1230 | 1230 |
| 1231 child->setIsContainerForFixedPositionLayers(true); | 1231 child->setIsContainerForFixedPositionLayers(true); |
| 1232 grandChild->setFixedToContainerLayer(true); | 1232 grandChild->setFixedToContainerLayer(true); |
| 1233 | 1233 |
| 1234 // This should not confuse the grandChild. If correct, the grandChild would
still be considered fixed to its container (i.e. "child"). | 1234 // This should not confuse the grandChild. If correct, the grandChild would
still be considered fixed to its container (i.e. "child"). |
| 1235 grandChild->setIsContainerForFixedPositionLayers(true); | 1235 grandChild->setIsContainerForFixedPositionLayers(true); |
| 1236 | 1236 |
| 1237 // Case 1: scrollDelta of 0, 0 | 1237 // Case 1: scrollDelta of 0, 0 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 1254 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->dra
wTransform()); | 1254 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->dra
wTransform()); |
| 1255 } | 1255 } |
| 1256 | 1256 |
| 1257 TEST(CCLayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerTha
tHasNoContainer) | 1257 TEST(CCLayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerTha
tHasNoContainer) |
| 1258 { | 1258 { |
| 1259 // This test checks scroll compensation when a fixed-position layer does not
find any | 1259 // This test checks scroll compensation when a fixed-position layer does not
find any |
| 1260 // ancestor that is a "containerForFixedPositionLayers". In this situation,
the layer should | 1260 // ancestor that is a "containerForFixedPositionLayers". In this situation,
the layer should |
| 1261 // be fixed to the viewport -- not the rootLayer, which may have transforms
of its own. | 1261 // be fixed to the viewport -- not the rootLayer, which may have transforms
of its own. |
| 1262 DebugScopedSetImplThread scopedImplThread; | 1262 DebugScopedSetImplThread scopedImplThread; |
| 1263 | 1263 |
| 1264 OwnPtr<CCLayerImpl> root = createTreeForFixedPositionTests(); | 1264 scoped_ptr<CCLayerImpl> root = createTreeForFixedPositionTests(); |
| 1265 CCLayerImpl* child = root->children()[0]; | 1265 CCLayerImpl* child = root->children()[0]; |
| 1266 CCLayerImpl* grandChild = child->children()[0]; | 1266 CCLayerImpl* grandChild = child->children()[0]; |
| 1267 | 1267 |
| 1268 WebTransformationMatrix rotationByZ; | 1268 WebTransformationMatrix rotationByZ; |
| 1269 rotationByZ.rotate3d(0, 0, 90); | 1269 rotationByZ.rotate3d(0, 0, 90); |
| 1270 | 1270 |
| 1271 root->setTransform(rotationByZ); | 1271 root->setTransform(rotationByZ); |
| 1272 grandChild->setFixedToContainerLayer(true); | 1272 grandChild->setFixedToContainerLayer(true); |
| 1273 | 1273 |
| 1274 // Case 1: root scrollDelta of 0, 0 | 1274 // Case 1: root scrollDelta of 0, 0 |
| (...skipping 1372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2647 | 2647 |
| 2648 testPoint = IntPoint(10, 20); | 2648 testPoint = IntPoint(10, 20); |
| 2649 resultLayer = CCLayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, re
nderSurfaceLayerList); | 2649 resultLayer = CCLayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, re
nderSurfaceLayerList); |
| 2650 EXPECT_FALSE(resultLayer); | 2650 EXPECT_FALSE(resultLayer); |
| 2651 } | 2651 } |
| 2652 | 2652 |
| 2653 TEST(CCLayerTreeHostCommonTest, verifyHitTestingForSingleLayer) | 2653 TEST(CCLayerTreeHostCommonTest, verifyHitTestingForSingleLayer) |
| 2654 { | 2654 { |
| 2655 DebugScopedSetImplThread thisScopeIsOnImplThread; | 2655 DebugScopedSetImplThread thisScopeIsOnImplThread; |
| 2656 | 2656 |
| 2657 OwnPtr<CCLayerImpl> root = CCLayerImpl::create(12345); | 2657 scoped_ptr<CCLayerImpl> root = CCLayerImpl::create(12345); |
| 2658 | 2658 |
| 2659 WebTransformationMatrix identityMatrix; | 2659 WebTransformationMatrix identityMatrix; |
| 2660 FloatPoint anchor(0, 0); | 2660 FloatPoint anchor(0, 0); |
| 2661 FloatPoint position(0, 0); | 2661 FloatPoint position(0, 0); |
| 2662 IntSize bounds(100, 100); | 2662 IntSize bounds(100, 100); |
| 2663 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc
hor, position, bounds, false); | 2663 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc
hor, position, bounds, false); |
| 2664 root->setDrawsContent(true); | 2664 root->setDrawsContent(true); |
| 2665 | 2665 |
| 2666 std::vector<CCLayerImpl*> renderSurfaceLayerList; | 2666 std::vector<CCLayerImpl*> renderSurfaceLayerList; |
| 2667 int dummyMaxTextureSize = 512; | 2667 int dummyMaxTextureSize = 512; |
| (...skipping 22 matching lines...) Expand all Loading... |
| 2690 testPoint = IntPoint(99, 99); | 2690 testPoint = IntPoint(99, 99); |
| 2691 resultLayer = CCLayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, re
nderSurfaceLayerList); | 2691 resultLayer = CCLayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, re
nderSurfaceLayerList); |
| 2692 ASSERT_TRUE(resultLayer); | 2692 ASSERT_TRUE(resultLayer); |
| 2693 EXPECT_EQ(12345, resultLayer->id()); | 2693 EXPECT_EQ(12345, resultLayer->id()); |
| 2694 } | 2694 } |
| 2695 | 2695 |
| 2696 TEST(CCLayerTreeHostCommonTest, verifyHitTestingForUninvertibleTransform) | 2696 TEST(CCLayerTreeHostCommonTest, verifyHitTestingForUninvertibleTransform) |
| 2697 { | 2697 { |
| 2698 DebugScopedSetImplThread thisScopeIsOnImplThread; | 2698 DebugScopedSetImplThread thisScopeIsOnImplThread; |
| 2699 | 2699 |
| 2700 OwnPtr<CCLayerImpl> root = CCLayerImpl::create(12345); | 2700 scoped_ptr<CCLayerImpl> root = CCLayerImpl::create(12345); |
| 2701 | 2701 |
| 2702 WebTransformationMatrix uninvertibleTransform; | 2702 WebTransformationMatrix uninvertibleTransform; |
| 2703 uninvertibleTransform.setM11(0); | 2703 uninvertibleTransform.setM11(0); |
| 2704 uninvertibleTransform.setM22(0); | 2704 uninvertibleTransform.setM22(0); |
| 2705 uninvertibleTransform.setM33(0); | 2705 uninvertibleTransform.setM33(0); |
| 2706 uninvertibleTransform.setM44(0); | 2706 uninvertibleTransform.setM44(0); |
| 2707 ASSERT_FALSE(uninvertibleTransform.isInvertible()); | 2707 ASSERT_FALSE(uninvertibleTransform.isInvertible()); |
| 2708 | 2708 |
| 2709 WebTransformationMatrix identityMatrix; | 2709 WebTransformationMatrix identityMatrix; |
| 2710 FloatPoint anchor(0, 0); | 2710 FloatPoint anchor(0, 0); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2752 | 2752 |
| 2753 testPoint = IntPoint(-1, -1); | 2753 testPoint = IntPoint(-1, -1); |
| 2754 resultLayer = CCLayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, re
nderSurfaceLayerList); | 2754 resultLayer = CCLayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, re
nderSurfaceLayerList); |
| 2755 EXPECT_FALSE(resultLayer); | 2755 EXPECT_FALSE(resultLayer); |
| 2756 } | 2756 } |
| 2757 | 2757 |
| 2758 TEST(CCLayerTreeHostCommonTest, verifyHitTestingForSinglePositionedLayer) | 2758 TEST(CCLayerTreeHostCommonTest, verifyHitTestingForSinglePositionedLayer) |
| 2759 { | 2759 { |
| 2760 DebugScopedSetImplThread thisScopeIsOnImplThread; | 2760 DebugScopedSetImplThread thisScopeIsOnImplThread; |
| 2761 | 2761 |
| 2762 OwnPtr<CCLayerImpl> root = CCLayerImpl::create(12345); | 2762 scoped_ptr<CCLayerImpl> root = CCLayerImpl::create(12345); |
| 2763 | 2763 |
| 2764 WebTransformationMatrix identityMatrix; | 2764 WebTransformationMatrix identityMatrix; |
| 2765 FloatPoint anchor(0, 0); | 2765 FloatPoint anchor(0, 0); |
| 2766 FloatPoint position(50, 50); // this layer is positioned, and hit testing sh
ould correctly know where the layer is located. | 2766 FloatPoint position(50, 50); // this layer is positioned, and hit testing sh
ould correctly know where the layer is located. |
| 2767 IntSize bounds(100, 100); | 2767 IntSize bounds(100, 100); |
| 2768 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc
hor, position, bounds, false); | 2768 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc
hor, position, bounds, false); |
| 2769 root->setDrawsContent(true); | 2769 root->setDrawsContent(true); |
| 2770 | 2770 |
| 2771 std::vector<CCLayerImpl*> renderSurfaceLayerList; | 2771 std::vector<CCLayerImpl*> renderSurfaceLayerList; |
| 2772 int dummyMaxTextureSize = 512; | 2772 int dummyMaxTextureSize = 512; |
| (...skipping 23 matching lines...) Expand all Loading... |
| 2796 testPoint = IntPoint(99, 99); | 2796 testPoint = IntPoint(99, 99); |
| 2797 resultLayer = CCLayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, re
nderSurfaceLayerList); | 2797 resultLayer = CCLayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, re
nderSurfaceLayerList); |
| 2798 ASSERT_TRUE(resultLayer); | 2798 ASSERT_TRUE(resultLayer); |
| 2799 EXPECT_EQ(12345, resultLayer->id()); | 2799 EXPECT_EQ(12345, resultLayer->id()); |
| 2800 } | 2800 } |
| 2801 | 2801 |
| 2802 TEST(CCLayerTreeHostCommonTest, verifyHitTestingForSingleRotatedLayer) | 2802 TEST(CCLayerTreeHostCommonTest, verifyHitTestingForSingleRotatedLayer) |
| 2803 { | 2803 { |
| 2804 DebugScopedSetImplThread thisScopeIsOnImplThread; | 2804 DebugScopedSetImplThread thisScopeIsOnImplThread; |
| 2805 | 2805 |
| 2806 OwnPtr<CCLayerImpl> root = CCLayerImpl::create(12345); | 2806 scoped_ptr<CCLayerImpl> root = CCLayerImpl::create(12345); |
| 2807 | 2807 |
| 2808 WebTransformationMatrix identityMatrix; | 2808 WebTransformationMatrix identityMatrix; |
| 2809 WebTransformationMatrix rotation45DegreesAboutCenter; | 2809 WebTransformationMatrix rotation45DegreesAboutCenter; |
| 2810 rotation45DegreesAboutCenter.translate(50, 50); | 2810 rotation45DegreesAboutCenter.translate(50, 50); |
| 2811 rotation45DegreesAboutCenter.rotate3d(0, 0, 45); | 2811 rotation45DegreesAboutCenter.rotate3d(0, 0, 45); |
| 2812 rotation45DegreesAboutCenter.translate(-50, -50); | 2812 rotation45DegreesAboutCenter.translate(-50, -50); |
| 2813 FloatPoint anchor(0, 0); | 2813 FloatPoint anchor(0, 0); |
| 2814 FloatPoint position(0, 0); | 2814 FloatPoint position(0, 0); |
| 2815 IntSize bounds(100, 100); | 2815 IntSize bounds(100, 100); |
| 2816 setLayerPropertiesForTesting(root.get(), rotation45DegreesAboutCenter, ident
ityMatrix, anchor, position, bounds, false); | 2816 setLayerPropertiesForTesting(root.get(), rotation45DegreesAboutCenter, ident
ityMatrix, anchor, position, bounds, false); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2848 | 2848 |
| 2849 testPoint = IntPoint(-1, 50); | 2849 testPoint = IntPoint(-1, 50); |
| 2850 resultLayer = CCLayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, re
nderSurfaceLayerList); | 2850 resultLayer = CCLayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, re
nderSurfaceLayerList); |
| 2851 ASSERT_FALSE(resultLayer); | 2851 ASSERT_FALSE(resultLayer); |
| 2852 } | 2852 } |
| 2853 | 2853 |
| 2854 TEST(CCLayerTreeHostCommonTest, verifyHitTestingForSinglePerspectiveLayer) | 2854 TEST(CCLayerTreeHostCommonTest, verifyHitTestingForSinglePerspectiveLayer) |
| 2855 { | 2855 { |
| 2856 DebugScopedSetImplThread thisScopeIsOnImplThread; | 2856 DebugScopedSetImplThread thisScopeIsOnImplThread; |
| 2857 | 2857 |
| 2858 OwnPtr<CCLayerImpl> root = CCLayerImpl::create(12345); | 2858 scoped_ptr<CCLayerImpl> root = CCLayerImpl::create(12345); |
| 2859 | 2859 |
| 2860 WebTransformationMatrix identityMatrix; | 2860 WebTransformationMatrix identityMatrix; |
| 2861 | 2861 |
| 2862 // perspectiveProjectionAboutCenter * translationByZ is designed so that the
100 x 100 layer becomes 50 x 50, and remains centered at (50, 50). | 2862 // perspectiveProjectionAboutCenter * translationByZ is designed so that the
100 x 100 layer becomes 50 x 50, and remains centered at (50, 50). |
| 2863 WebTransformationMatrix perspectiveProjectionAboutCenter; | 2863 WebTransformationMatrix perspectiveProjectionAboutCenter; |
| 2864 perspectiveProjectionAboutCenter.translate(50, 50); | 2864 perspectiveProjectionAboutCenter.translate(50, 50); |
| 2865 perspectiveProjectionAboutCenter.applyPerspective(1); | 2865 perspectiveProjectionAboutCenter.applyPerspective(1); |
| 2866 perspectiveProjectionAboutCenter.translate(-50, -50); | 2866 perspectiveProjectionAboutCenter.translate(-50, -50); |
| 2867 WebTransformationMatrix translationByZ; | 2867 WebTransformationMatrix translationByZ; |
| 2868 translationByZ.translate3d(0, 0, -1); | 2868 translationByZ.translate3d(0, 0, -1); |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2911 // test makes sure that hit testing works correctly accounts for the content
s scale. | 2911 // test makes sure that hit testing works correctly accounts for the content
s scale. |
| 2912 // A contentsScale that is not 1 effectively forces a non-identity transform
between | 2912 // A contentsScale that is not 1 effectively forces a non-identity transform
between |
| 2913 // layer's content space and layer's origin space. The hit testing code must
take this into account. | 2913 // layer's content space and layer's origin space. The hit testing code must
take this into account. |
| 2914 // | 2914 // |
| 2915 // To test this, the layer is positioned at (25, 25), and is size (50, 50).
If | 2915 // To test this, the layer is positioned at (25, 25), and is size (50, 50).
If |
| 2916 // contentsScale is ignored, then hit testing will mis-interpret the visible
ContentRect | 2916 // contentsScale is ignored, then hit testing will mis-interpret the visible
ContentRect |
| 2917 // as being larger than the actual bounds of the layer. | 2917 // as being larger than the actual bounds of the layer. |
| 2918 // | 2918 // |
| 2919 DebugScopedSetImplThread thisScopeIsOnImplThread; | 2919 DebugScopedSetImplThread thisScopeIsOnImplThread; |
| 2920 | 2920 |
| 2921 OwnPtr<CCLayerImpl> root = CCLayerImpl::create(1); | 2921 scoped_ptr<CCLayerImpl> root = CCLayerImpl::create(1); |
| 2922 | 2922 |
| 2923 WebTransformationMatrix identityMatrix; | 2923 WebTransformationMatrix identityMatrix; |
| 2924 FloatPoint anchor(0, 0); | 2924 FloatPoint anchor(0, 0); |
| 2925 | 2925 |
| 2926 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc
hor, FloatPoint(0, 0), IntSize(100, 100), false); | 2926 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc
hor, FloatPoint(0, 0), IntSize(100, 100), false); |
| 2927 | 2927 |
| 2928 { | 2928 { |
| 2929 FloatPoint position(25, 25); | 2929 FloatPoint position(25, 25); |
| 2930 IntSize bounds(50, 50); | 2930 IntSize bounds(50, 50); |
| 2931 OwnPtr<CCLayerImpl> testLayer = CCLayerImpl::create(12345); | 2931 scoped_ptr<CCLayerImpl> testLayer = CCLayerImpl::create(12345); |
| 2932 setLayerPropertiesForTesting(testLayer.get(), identityMatrix, identityMa
trix, anchor, position, bounds, false); | 2932 setLayerPropertiesForTesting(testLayer.get(), identityMatrix, identityMa
trix, anchor, position, bounds, false); |
| 2933 | 2933 |
| 2934 // override contentBounds | 2934 // override contentBounds |
| 2935 testLayer->setContentBounds(IntSize(100, 100)); | 2935 testLayer->setContentBounds(IntSize(100, 100)); |
| 2936 | 2936 |
| 2937 testLayer->setDrawsContent(true); | 2937 testLayer->setDrawsContent(true); |
| 2938 root->addChild(testLayer.release()); | 2938 root->addChild(testLayer.Pass()); |
| 2939 } | 2939 } |
| 2940 | 2940 |
| 2941 std::vector<CCLayerImpl*> renderSurfaceLayerList; | 2941 std::vector<CCLayerImpl*> renderSurfaceLayerList; |
| 2942 int dummyMaxTextureSize = 512; | 2942 int dummyMaxTextureSize = 512; |
| 2943 CCLayerTreeHostCommon::calculateDrawTransforms(root.get(), root->bounds(), 1
, 0, dummyMaxTextureSize, renderSurfaceLayerList); | 2943 CCLayerTreeHostCommon::calculateDrawTransforms(root.get(), root->bounds(), 1
, 0, dummyMaxTextureSize, renderSurfaceLayerList); |
| 2944 CCLayerTreeHostCommon::calculateVisibleRects(renderSurfaceLayerList); | 2944 CCLayerTreeHostCommon::calculateVisibleRects(renderSurfaceLayerList); |
| 2945 | 2945 |
| 2946 // Sanity check the scenario we just created. | 2946 // Sanity check the scenario we just created. |
| 2947 // The visibleContentRect for testLayer is actually 100x100, even though its
layout size is 50x50, positioned at 25x25. | 2947 // The visibleContentRect for testLayer is actually 100x100, even though its
layout size is 50x50, positioned at 25x25. |
| 2948 CCLayerImpl* testLayer = root->children()[0]; | 2948 CCLayerImpl* testLayer = root->children()[0]; |
| (...skipping 28 matching lines...) Expand all Loading... |
| 2977 | 2977 |
| 2978 TEST(CCLayerTreeHostCommonTest, verifyHitTestingForSimpleClippedLayer) | 2978 TEST(CCLayerTreeHostCommonTest, verifyHitTestingForSimpleClippedLayer) |
| 2979 { | 2979 { |
| 2980 // Test that hit-testing will only work for the visible portion of a layer,
and not | 2980 // Test that hit-testing will only work for the visible portion of a layer,
and not |
| 2981 // the entire layer bounds. Here we just test the simple axis-aligned case. | 2981 // the entire layer bounds. Here we just test the simple axis-aligned case. |
| 2982 DebugScopedSetImplThread thisScopeIsOnImplThread; | 2982 DebugScopedSetImplThread thisScopeIsOnImplThread; |
| 2983 | 2983 |
| 2984 WebTransformationMatrix identityMatrix; | 2984 WebTransformationMatrix identityMatrix; |
| 2985 FloatPoint anchor(0, 0); | 2985 FloatPoint anchor(0, 0); |
| 2986 | 2986 |
| 2987 OwnPtr<CCLayerImpl> root = CCLayerImpl::create(1); | 2987 scoped_ptr<CCLayerImpl> root = CCLayerImpl::create(1); |
| 2988 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc
hor, FloatPoint(0, 0), IntSize(100, 100), false); | 2988 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc
hor, FloatPoint(0, 0), IntSize(100, 100), false); |
| 2989 | 2989 |
| 2990 { | 2990 { |
| 2991 OwnPtr<CCLayerImpl> clippingLayer = CCLayerImpl::create(123); | 2991 scoped_ptr<CCLayerImpl> clippingLayer = CCLayerImpl::create(123); |
| 2992 FloatPoint position(25, 25); // this layer is positioned, and hit testin
g should correctly know where the layer is located. | 2992 FloatPoint position(25, 25); // this layer is positioned, and hit testin
g should correctly know where the layer is located. |
| 2993 IntSize bounds(50, 50); | 2993 IntSize bounds(50, 50); |
| 2994 setLayerPropertiesForTesting(clippingLayer.get(), identityMatrix, identi
tyMatrix, anchor, position, bounds, false); | 2994 setLayerPropertiesForTesting(clippingLayer.get(), identityMatrix, identi
tyMatrix, anchor, position, bounds, false); |
| 2995 clippingLayer->setMasksToBounds(true); | 2995 clippingLayer->setMasksToBounds(true); |
| 2996 | 2996 |
| 2997 OwnPtr<CCLayerImpl> child = CCLayerImpl::create(456); | 2997 scoped_ptr<CCLayerImpl> child = CCLayerImpl::create(456); |
| 2998 position = FloatPoint(-50, -50); | 2998 position = FloatPoint(-50, -50); |
| 2999 bounds = IntSize(300, 300); | 2999 bounds = IntSize(300, 300); |
| 3000 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix
, anchor, position, bounds, false); | 3000 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix
, anchor, position, bounds, false); |
| 3001 child->setDrawsContent(true); | 3001 child->setDrawsContent(true); |
| 3002 clippingLayer->addChild(child.release()); | 3002 clippingLayer->addChild(child.Pass()); |
| 3003 root->addChild(clippingLayer.release()); | 3003 root->addChild(clippingLayer.Pass()); |
| 3004 } | 3004 } |
| 3005 | 3005 |
| 3006 std::vector<CCLayerImpl*> renderSurfaceLayerList; | 3006 std::vector<CCLayerImpl*> renderSurfaceLayerList; |
| 3007 int dummyMaxTextureSize = 512; | 3007 int dummyMaxTextureSize = 512; |
| 3008 CCLayerTreeHostCommon::calculateDrawTransforms(root.get(), root->bounds(), 1
, 0, dummyMaxTextureSize, renderSurfaceLayerList); | 3008 CCLayerTreeHostCommon::calculateDrawTransforms(root.get(), root->bounds(), 1
, 0, dummyMaxTextureSize, renderSurfaceLayerList); |
| 3009 CCLayerTreeHostCommon::calculateVisibleRects(renderSurfaceLayerList); | 3009 CCLayerTreeHostCommon::calculateVisibleRects(renderSurfaceLayerList); |
| 3010 | 3010 |
| 3011 // Sanity check the scenario we just created. | 3011 // Sanity check the scenario we just created. |
| 3012 ASSERT_EQ(1u, renderSurfaceLayerList.size()); | 3012 ASSERT_EQ(1u, renderSurfaceLayerList.size()); |
| 3013 ASSERT_EQ(1u, root->renderSurface()->layerList().size()); | 3013 ASSERT_EQ(1u, root->renderSurface()->layerList().size()); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 3043 // algorithm needs to recognize that multiple parent layers may clip the lay
er, and | 3043 // algorithm needs to recognize that multiple parent layers may clip the lay
er, and |
| 3044 // should not actually hit those clipped areas. | 3044 // should not actually hit those clipped areas. |
| 3045 // | 3045 // |
| 3046 // The child and grandChild layers are both initialized to clip the rotatedL
eaf. The | 3046 // The child and grandChild layers are both initialized to clip the rotatedL
eaf. The |
| 3047 // child layer is rotated about the top-left corner, so that the root + chil
d clips | 3047 // child layer is rotated about the top-left corner, so that the root + chil
d clips |
| 3048 // combined create a triangle. The rotatedLeaf will only be visible where it
overlaps | 3048 // combined create a triangle. The rotatedLeaf will only be visible where it
overlaps |
| 3049 // this triangle. | 3049 // this triangle. |
| 3050 // | 3050 // |
| 3051 DebugScopedSetImplThread thisScopeIsOnImplThread; | 3051 DebugScopedSetImplThread thisScopeIsOnImplThread; |
| 3052 | 3052 |
| 3053 OwnPtr<CCLayerImpl> root = CCLayerImpl::create(123); | 3053 scoped_ptr<CCLayerImpl> root = CCLayerImpl::create(123); |
| 3054 | 3054 |
| 3055 WebTransformationMatrix identityMatrix; | 3055 WebTransformationMatrix identityMatrix; |
| 3056 FloatPoint anchor(0, 0); | 3056 FloatPoint anchor(0, 0); |
| 3057 FloatPoint position(0, 0); | 3057 FloatPoint position(0, 0); |
| 3058 IntSize bounds(100, 100); | 3058 IntSize bounds(100, 100); |
| 3059 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc
hor, position, bounds, false); | 3059 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc
hor, position, bounds, false); |
| 3060 root->setMasksToBounds(true); | 3060 root->setMasksToBounds(true); |
| 3061 | 3061 |
| 3062 { | 3062 { |
| 3063 OwnPtr<CCLayerImpl> child = CCLayerImpl::create(456); | 3063 scoped_ptr<CCLayerImpl> child = CCLayerImpl::create(456); |
| 3064 OwnPtr<CCLayerImpl> grandChild = CCLayerImpl::create(789); | 3064 scoped_ptr<CCLayerImpl> grandChild = CCLayerImpl::create(789); |
| 3065 OwnPtr<CCLayerImpl> rotatedLeaf = CCLayerImpl::create(2468); | 3065 scoped_ptr<CCLayerImpl> rotatedLeaf = CCLayerImpl::create(2468); |
| 3066 | 3066 |
| 3067 position = FloatPoint(10, 10); | 3067 position = FloatPoint(10, 10); |
| 3068 bounds = IntSize(80, 80); | 3068 bounds = IntSize(80, 80); |
| 3069 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix
, anchor, position, bounds, false); | 3069 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix
, anchor, position, bounds, false); |
| 3070 child->setMasksToBounds(true); | 3070 child->setMasksToBounds(true); |
| 3071 | 3071 |
| 3072 WebTransformationMatrix rotation45DegreesAboutCorner; | 3072 WebTransformationMatrix rotation45DegreesAboutCorner; |
| 3073 rotation45DegreesAboutCorner.rotate3d(0, 0, 45); | 3073 rotation45DegreesAboutCorner.rotate3d(0, 0, 45); |
| 3074 | 3074 |
| 3075 position = FloatPoint(0, 0); // remember, positioned with respect to its
parent which is already at 10, 10 | 3075 position = FloatPoint(0, 0); // remember, positioned with respect to its
parent which is already at 10, 10 |
| 3076 bounds = IntSize(200, 200); // to ensure it covers at least sqrt(2) * 10
0. | 3076 bounds = IntSize(200, 200); // to ensure it covers at least sqrt(2) * 10
0. |
| 3077 setLayerPropertiesForTesting(grandChild.get(), rotation45DegreesAboutCor
ner, identityMatrix, anchor, position, bounds, false); | 3077 setLayerPropertiesForTesting(grandChild.get(), rotation45DegreesAboutCor
ner, identityMatrix, anchor, position, bounds, false); |
| 3078 grandChild->setMasksToBounds(true); | 3078 grandChild->setMasksToBounds(true); |
| 3079 | 3079 |
| 3080 // Rotates about the center of the layer | 3080 // Rotates about the center of the layer |
| 3081 WebTransformationMatrix rotatedLeafTransform; | 3081 WebTransformationMatrix rotatedLeafTransform; |
| 3082 rotatedLeafTransform.translate(-10, -10); // cancel out the grandParent'
s position | 3082 rotatedLeafTransform.translate(-10, -10); // cancel out the grandParent'
s position |
| 3083 rotatedLeafTransform.rotate3d(0, 0, -45); // cancel out the corner 45-de
gree rotation of the parent. | 3083 rotatedLeafTransform.rotate3d(0, 0, -45); // cancel out the corner 45-de
gree rotation of the parent. |
| 3084 rotatedLeafTransform.translate(50, 50); | 3084 rotatedLeafTransform.translate(50, 50); |
| 3085 rotatedLeafTransform.rotate3d(0, 0, 45); | 3085 rotatedLeafTransform.rotate3d(0, 0, 45); |
| 3086 rotatedLeafTransform.translate(-50, -50); | 3086 rotatedLeafTransform.translate(-50, -50); |
| 3087 position = FloatPoint(0, 0); | 3087 position = FloatPoint(0, 0); |
| 3088 bounds = IntSize(100, 100); | 3088 bounds = IntSize(100, 100); |
| 3089 setLayerPropertiesForTesting(rotatedLeaf.get(), rotatedLeafTransform, id
entityMatrix, anchor, position, bounds, false); | 3089 setLayerPropertiesForTesting(rotatedLeaf.get(), rotatedLeafTransform, id
entityMatrix, anchor, position, bounds, false); |
| 3090 rotatedLeaf->setDrawsContent(true); | 3090 rotatedLeaf->setDrawsContent(true); |
| 3091 | 3091 |
| 3092 grandChild->addChild(rotatedLeaf.release()); | 3092 grandChild->addChild(rotatedLeaf.Pass()); |
| 3093 child->addChild(grandChild.release()); | 3093 child->addChild(grandChild.Pass()); |
| 3094 root->addChild(child.release()); | 3094 root->addChild(child.Pass()); |
| 3095 } | 3095 } |
| 3096 | 3096 |
| 3097 std::vector<CCLayerImpl*> renderSurfaceLayerList; | 3097 std::vector<CCLayerImpl*> renderSurfaceLayerList; |
| 3098 int dummyMaxTextureSize = 512; | 3098 int dummyMaxTextureSize = 512; |
| 3099 CCLayerTreeHostCommon::calculateDrawTransforms(root.get(), root->bounds(), 1
, 0, dummyMaxTextureSize, renderSurfaceLayerList); | 3099 CCLayerTreeHostCommon::calculateDrawTransforms(root.get(), root->bounds(), 1
, 0, dummyMaxTextureSize, renderSurfaceLayerList); |
| 3100 CCLayerTreeHostCommon::calculateVisibleRects(renderSurfaceLayerList); | 3100 CCLayerTreeHostCommon::calculateVisibleRects(renderSurfaceLayerList); |
| 3101 | 3101 |
| 3102 // Sanity check the scenario we just created. | 3102 // Sanity check the scenario we just created. |
| 3103 // The grandChild is expected to create a renderSurface because it masksToBo
unds and is not axis aligned. | 3103 // The grandChild is expected to create a renderSurface because it masksToBo
unds and is not axis aligned. |
| 3104 ASSERT_EQ(2u, renderSurfaceLayerList.size()); | 3104 ASSERT_EQ(2u, renderSurfaceLayerList.size()); |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3147 | 3147 |
| 3148 TEST(CCLayerTreeHostCommonTest, verifyHitTestingForNonClippingIntermediateLayer) | 3148 TEST(CCLayerTreeHostCommonTest, verifyHitTestingForNonClippingIntermediateLayer) |
| 3149 { | 3149 { |
| 3150 // This test checks that hit testing code does not accidentally clip to laye
r | 3150 // This test checks that hit testing code does not accidentally clip to laye
r |
| 3151 // bounds for a layer that actually does not clip. | 3151 // bounds for a layer that actually does not clip. |
| 3152 DebugScopedSetImplThread thisScopeIsOnImplThread; | 3152 DebugScopedSetImplThread thisScopeIsOnImplThread; |
| 3153 | 3153 |
| 3154 WebTransformationMatrix identityMatrix; | 3154 WebTransformationMatrix identityMatrix; |
| 3155 FloatPoint anchor(0, 0); | 3155 FloatPoint anchor(0, 0); |
| 3156 | 3156 |
| 3157 OwnPtr<CCLayerImpl> root = CCLayerImpl::create(1); | 3157 scoped_ptr<CCLayerImpl> root = CCLayerImpl::create(1); |
| 3158 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc
hor, FloatPoint(0, 0), IntSize(100, 100), false); | 3158 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc
hor, FloatPoint(0, 0), IntSize(100, 100), false); |
| 3159 | 3159 |
| 3160 { | 3160 { |
| 3161 OwnPtr<CCLayerImpl> intermediateLayer = CCLayerImpl::create(123); | 3161 scoped_ptr<CCLayerImpl> intermediateLayer = CCLayerImpl::create(123); |
| 3162 FloatPoint position(10, 10); // this layer is positioned, and hit testin
g should correctly know where the layer is located. | 3162 FloatPoint position(10, 10); // this layer is positioned, and hit testin
g should correctly know where the layer is located. |
| 3163 IntSize bounds(50, 50); | 3163 IntSize bounds(50, 50); |
| 3164 setLayerPropertiesForTesting(intermediateLayer.get(), identityMatrix, id
entityMatrix, anchor, position, bounds, false); | 3164 setLayerPropertiesForTesting(intermediateLayer.get(), identityMatrix, id
entityMatrix, anchor, position, bounds, false); |
| 3165 // Sanity check the intermediate layer should not clip. | 3165 // Sanity check the intermediate layer should not clip. |
| 3166 ASSERT_FALSE(intermediateLayer->masksToBounds()); | 3166 ASSERT_FALSE(intermediateLayer->masksToBounds()); |
| 3167 ASSERT_FALSE(intermediateLayer->maskLayer()); | 3167 ASSERT_FALSE(intermediateLayer->maskLayer()); |
| 3168 | 3168 |
| 3169 // The child of the intermediateLayer is translated so that it does not
overlap intermediateLayer at all. | 3169 // The child of the intermediateLayer is translated so that it does not
overlap intermediateLayer at all. |
| 3170 // If child is incorrectly clipped, we would not be able to hit it succe
ssfully. | 3170 // If child is incorrectly clipped, we would not be able to hit it succe
ssfully. |
| 3171 OwnPtr<CCLayerImpl> child = CCLayerImpl::create(456); | 3171 scoped_ptr<CCLayerImpl> child = CCLayerImpl::create(456); |
| 3172 position = FloatPoint(60, 60); // 70, 70 in screen space | 3172 position = FloatPoint(60, 60); // 70, 70 in screen space |
| 3173 bounds = IntSize(20, 20); | 3173 bounds = IntSize(20, 20); |
| 3174 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix
, anchor, position, bounds, false); | 3174 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix
, anchor, position, bounds, false); |
| 3175 child->setDrawsContent(true); | 3175 child->setDrawsContent(true); |
| 3176 intermediateLayer->addChild(child.release()); | 3176 intermediateLayer->addChild(child.Pass()); |
| 3177 root->addChild(intermediateLayer.release()); | 3177 root->addChild(intermediateLayer.Pass()); |
| 3178 } | 3178 } |
| 3179 | 3179 |
| 3180 std::vector<CCLayerImpl*> renderSurfaceLayerList; | 3180 std::vector<CCLayerImpl*> renderSurfaceLayerList; |
| 3181 int dummyMaxTextureSize = 512; | 3181 int dummyMaxTextureSize = 512; |
| 3182 CCLayerTreeHostCommon::calculateDrawTransforms(root.get(), root->bounds(), 1
, 0, dummyMaxTextureSize, renderSurfaceLayerList); | 3182 CCLayerTreeHostCommon::calculateDrawTransforms(root.get(), root->bounds(), 1
, 0, dummyMaxTextureSize, renderSurfaceLayerList); |
| 3183 CCLayerTreeHostCommon::calculateVisibleRects(renderSurfaceLayerList); | 3183 CCLayerTreeHostCommon::calculateVisibleRects(renderSurfaceLayerList); |
| 3184 | 3184 |
| 3185 // Sanity check the scenario we just created. | 3185 // Sanity check the scenario we just created. |
| 3186 ASSERT_EQ(1u, renderSurfaceLayerList.size()); | 3186 ASSERT_EQ(1u, renderSurfaceLayerList.size()); |
| 3187 ASSERT_EQ(1u, root->renderSurface()->layerList().size()); | 3187 ASSERT_EQ(1u, root->renderSurface()->layerList().size()); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 3206 resultLayer = CCLayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, re
nderSurfaceLayerList); | 3206 resultLayer = CCLayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, re
nderSurfaceLayerList); |
| 3207 ASSERT_TRUE(resultLayer); | 3207 ASSERT_TRUE(resultLayer); |
| 3208 EXPECT_EQ(456, resultLayer->id()); | 3208 EXPECT_EQ(456, resultLayer->id()); |
| 3209 } | 3209 } |
| 3210 | 3210 |
| 3211 | 3211 |
| 3212 TEST(CCLayerTreeHostCommonTest, verifyHitTestingForMultipleLayers) | 3212 TEST(CCLayerTreeHostCommonTest, verifyHitTestingForMultipleLayers) |
| 3213 { | 3213 { |
| 3214 DebugScopedSetImplThread thisScopeIsOnImplThread; | 3214 DebugScopedSetImplThread thisScopeIsOnImplThread; |
| 3215 | 3215 |
| 3216 OwnPtr<CCLayerImpl> root = CCLayerImpl::create(1); | 3216 scoped_ptr<CCLayerImpl> root = CCLayerImpl::create(1); |
| 3217 | 3217 |
| 3218 WebTransformationMatrix identityMatrix; | 3218 WebTransformationMatrix identityMatrix; |
| 3219 FloatPoint anchor(0, 0); | 3219 FloatPoint anchor(0, 0); |
| 3220 FloatPoint position(0, 0); | 3220 FloatPoint position(0, 0); |
| 3221 IntSize bounds(100, 100); | 3221 IntSize bounds(100, 100); |
| 3222 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc
hor, position, bounds, false); | 3222 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc
hor, position, bounds, false); |
| 3223 root->setDrawsContent(true); | 3223 root->setDrawsContent(true); |
| 3224 | 3224 |
| 3225 { | 3225 { |
| 3226 // child 1 and child2 are initialized to overlap between x=50 and x=60. | 3226 // child 1 and child2 are initialized to overlap between x=50 and x=60. |
| 3227 // grandChild is set to overlap both child1 and child2 between y=50 and
y=60. | 3227 // grandChild is set to overlap both child1 and child2 between y=50 and
y=60. |
| 3228 // The expected stacking order is: | 3228 // The expected stacking order is: |
| 3229 // (front) child2, (second) grandChild, (third) child1, and (back) the
root layer behind all other layers. | 3229 // (front) child2, (second) grandChild, (third) child1, and (back) the
root layer behind all other layers. |
| 3230 | 3230 |
| 3231 OwnPtr<CCLayerImpl> child1 = CCLayerImpl::create(2); | 3231 scoped_ptr<CCLayerImpl> child1 = CCLayerImpl::create(2); |
| 3232 OwnPtr<CCLayerImpl> child2 = CCLayerImpl::create(3); | 3232 scoped_ptr<CCLayerImpl> child2 = CCLayerImpl::create(3); |
| 3233 OwnPtr<CCLayerImpl> grandChild1 = CCLayerImpl::create(4); | 3233 scoped_ptr<CCLayerImpl> grandChild1 = CCLayerImpl::create(4); |
| 3234 | 3234 |
| 3235 position = FloatPoint(10, 10); | 3235 position = FloatPoint(10, 10); |
| 3236 bounds = IntSize(50, 50); | 3236 bounds = IntSize(50, 50); |
| 3237 setLayerPropertiesForTesting(child1.get(), identityMatrix, identityMatri
x, anchor, position, bounds, false); | 3237 setLayerPropertiesForTesting(child1.get(), identityMatrix, identityMatri
x, anchor, position, bounds, false); |
| 3238 child1->setDrawsContent(true); | 3238 child1->setDrawsContent(true); |
| 3239 | 3239 |
| 3240 position = FloatPoint(50, 10); | 3240 position = FloatPoint(50, 10); |
| 3241 bounds = IntSize(50, 50); | 3241 bounds = IntSize(50, 50); |
| 3242 setLayerPropertiesForTesting(child2.get(), identityMatrix, identityMatri
x, anchor, position, bounds, false); | 3242 setLayerPropertiesForTesting(child2.get(), identityMatrix, identityMatri
x, anchor, position, bounds, false); |
| 3243 child2->setDrawsContent(true); | 3243 child2->setDrawsContent(true); |
| 3244 | 3244 |
| 3245 // Remember that grandChild is positioned with respect to its parent (i.
e. child1). | 3245 // Remember that grandChild is positioned with respect to its parent (i.
e. child1). |
| 3246 // In screen space, the intended position is (10, 50), with size 100 x 5
0. | 3246 // In screen space, the intended position is (10, 50), with size 100 x 5
0. |
| 3247 position = FloatPoint(0, 40); | 3247 position = FloatPoint(0, 40); |
| 3248 bounds = IntSize(100, 50); | 3248 bounds = IntSize(100, 50); |
| 3249 setLayerPropertiesForTesting(grandChild1.get(), identityMatrix, identity
Matrix, anchor, position, bounds, false); | 3249 setLayerPropertiesForTesting(grandChild1.get(), identityMatrix, identity
Matrix, anchor, position, bounds, false); |
| 3250 grandChild1->setDrawsContent(true); | 3250 grandChild1->setDrawsContent(true); |
| 3251 | 3251 |
| 3252 child1->addChild(grandChild1.release()); | 3252 child1->addChild(grandChild1.Pass()); |
| 3253 root->addChild(child1.release()); | 3253 root->addChild(child1.Pass()); |
| 3254 root->addChild(child2.release()); | 3254 root->addChild(child2.Pass()); |
| 3255 } | 3255 } |
| 3256 | 3256 |
| 3257 CCLayerImpl* child1 = root->children()[0]; | 3257 CCLayerImpl* child1 = root->children()[0]; |
| 3258 CCLayerImpl* child2 = root->children()[1]; | 3258 CCLayerImpl* child2 = root->children()[1]; |
| 3259 CCLayerImpl* grandChild1 = child1->children()[0]; | 3259 CCLayerImpl* grandChild1 = child1->children()[0]; |
| 3260 | 3260 |
| 3261 std::vector<CCLayerImpl*> renderSurfaceLayerList; | 3261 std::vector<CCLayerImpl*> renderSurfaceLayerList; |
| 3262 int dummyMaxTextureSize = 512; | 3262 int dummyMaxTextureSize = 512; |
| 3263 CCLayerTreeHostCommon::calculateDrawTransforms(root.get(), root->bounds(), 1
, 0, dummyMaxTextureSize, renderSurfaceLayerList); | 3263 CCLayerTreeHostCommon::calculateDrawTransforms(root.get(), root->bounds(), 1
, 0, dummyMaxTextureSize, renderSurfaceLayerList); |
| 3264 CCLayerTreeHostCommon::calculateVisibleRects(renderSurfaceLayerList); | 3264 CCLayerTreeHostCommon::calculateVisibleRects(renderSurfaceLayerList); |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3312 } | 3312 } |
| 3313 | 3313 |
| 3314 TEST(CCLayerTreeHostCommonTest, verifyHitTestingForMultipleLayerLists) | 3314 TEST(CCLayerTreeHostCommonTest, verifyHitTestingForMultipleLayerLists) |
| 3315 { | 3315 { |
| 3316 // | 3316 // |
| 3317 // The geometry is set up similarly to the previous case, but | 3317 // The geometry is set up similarly to the previous case, but |
| 3318 // all layers are forced to be renderSurfaces now. | 3318 // all layers are forced to be renderSurfaces now. |
| 3319 // | 3319 // |
| 3320 DebugScopedSetImplThread thisScopeIsOnImplThread; | 3320 DebugScopedSetImplThread thisScopeIsOnImplThread; |
| 3321 | 3321 |
| 3322 OwnPtr<CCLayerImpl> root = CCLayerImpl::create(1); | 3322 scoped_ptr<CCLayerImpl> root = CCLayerImpl::create(1); |
| 3323 | 3323 |
| 3324 WebTransformationMatrix identityMatrix; | 3324 WebTransformationMatrix identityMatrix; |
| 3325 FloatPoint anchor(0, 0); | 3325 FloatPoint anchor(0, 0); |
| 3326 FloatPoint position(0, 0); | 3326 FloatPoint position(0, 0); |
| 3327 IntSize bounds(100, 100); | 3327 IntSize bounds(100, 100); |
| 3328 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc
hor, position, bounds, false); | 3328 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc
hor, position, bounds, false); |
| 3329 root->setDrawsContent(true); | 3329 root->setDrawsContent(true); |
| 3330 | 3330 |
| 3331 { | 3331 { |
| 3332 // child 1 and child2 are initialized to overlap between x=50 and x=60. | 3332 // child 1 and child2 are initialized to overlap between x=50 and x=60. |
| 3333 // grandChild is set to overlap both child1 and child2 between y=50 and
y=60. | 3333 // grandChild is set to overlap both child1 and child2 between y=50 and
y=60. |
| 3334 // The expected stacking order is: | 3334 // The expected stacking order is: |
| 3335 // (front) child2, (second) grandChild, (third) child1, and (back) the
root layer behind all other layers. | 3335 // (front) child2, (second) grandChild, (third) child1, and (back) the
root layer behind all other layers. |
| 3336 | 3336 |
| 3337 OwnPtr<CCLayerImpl> child1 = CCLayerImpl::create(2); | 3337 scoped_ptr<CCLayerImpl> child1 = CCLayerImpl::create(2); |
| 3338 OwnPtr<CCLayerImpl> child2 = CCLayerImpl::create(3); | 3338 scoped_ptr<CCLayerImpl> child2 = CCLayerImpl::create(3); |
| 3339 OwnPtr<CCLayerImpl> grandChild1 = CCLayerImpl::create(4); | 3339 scoped_ptr<CCLayerImpl> grandChild1 = CCLayerImpl::create(4); |
| 3340 | 3340 |
| 3341 position = FloatPoint(10, 10); | 3341 position = FloatPoint(10, 10); |
| 3342 bounds = IntSize(50, 50); | 3342 bounds = IntSize(50, 50); |
| 3343 setLayerPropertiesForTesting(child1.get(), identityMatrix, identityMatri
x, anchor, position, bounds, false); | 3343 setLayerPropertiesForTesting(child1.get(), identityMatrix, identityMatri
x, anchor, position, bounds, false); |
| 3344 child1->setDrawsContent(true); | 3344 child1->setDrawsContent(true); |
| 3345 child1->setForceRenderSurface(true); | 3345 child1->setForceRenderSurface(true); |
| 3346 | 3346 |
| 3347 position = FloatPoint(50, 10); | 3347 position = FloatPoint(50, 10); |
| 3348 bounds = IntSize(50, 50); | 3348 bounds = IntSize(50, 50); |
| 3349 setLayerPropertiesForTesting(child2.get(), identityMatrix, identityMatri
x, anchor, position, bounds, false); | 3349 setLayerPropertiesForTesting(child2.get(), identityMatrix, identityMatri
x, anchor, position, bounds, false); |
| 3350 child2->setDrawsContent(true); | 3350 child2->setDrawsContent(true); |
| 3351 child2->setForceRenderSurface(true); | 3351 child2->setForceRenderSurface(true); |
| 3352 | 3352 |
| 3353 // Remember that grandChild is positioned with respect to its parent (i.
e. child1). | 3353 // Remember that grandChild is positioned with respect to its parent (i.
e. child1). |
| 3354 // In screen space, the intended position is (10, 50), with size 100 x 5
0. | 3354 // In screen space, the intended position is (10, 50), with size 100 x 5
0. |
| 3355 position = FloatPoint(0, 40); | 3355 position = FloatPoint(0, 40); |
| 3356 bounds = IntSize(100, 50); | 3356 bounds = IntSize(100, 50); |
| 3357 setLayerPropertiesForTesting(grandChild1.get(), identityMatrix, identity
Matrix, anchor, position, bounds, false); | 3357 setLayerPropertiesForTesting(grandChild1.get(), identityMatrix, identity
Matrix, anchor, position, bounds, false); |
| 3358 grandChild1->setDrawsContent(true); | 3358 grandChild1->setDrawsContent(true); |
| 3359 grandChild1->setForceRenderSurface(true); | 3359 grandChild1->setForceRenderSurface(true); |
| 3360 | 3360 |
| 3361 child1->addChild(grandChild1.release()); | 3361 child1->addChild(grandChild1.Pass()); |
| 3362 root->addChild(child1.release()); | 3362 root->addChild(child1.Pass()); |
| 3363 root->addChild(child2.release()); | 3363 root->addChild(child2.Pass()); |
| 3364 } | 3364 } |
| 3365 | 3365 |
| 3366 CCLayerImpl* child1 = root->children()[0]; | 3366 CCLayerImpl* child1 = root->children()[0]; |
| 3367 CCLayerImpl* child2 = root->children()[1]; | 3367 CCLayerImpl* child2 = root->children()[1]; |
| 3368 CCLayerImpl* grandChild1 = child1->children()[0]; | 3368 CCLayerImpl* grandChild1 = child1->children()[0]; |
| 3369 | 3369 |
| 3370 std::vector<CCLayerImpl*> renderSurfaceLayerList; | 3370 std::vector<CCLayerImpl*> renderSurfaceLayerList; |
| 3371 int dummyMaxTextureSize = 512; | 3371 int dummyMaxTextureSize = 512; |
| 3372 CCLayerTreeHostCommon::calculateDrawTransforms(root.get(), root->bounds(), 1
, 0, dummyMaxTextureSize, renderSurfaceLayerList); | 3372 CCLayerTreeHostCommon::calculateDrawTransforms(root.get(), root->bounds(), 1
, 0, dummyMaxTextureSize, renderSurfaceLayerList); |
| 3373 CCLayerTreeHostCommon::calculateVisibleRects(renderSurfaceLayerList); | 3373 CCLayerTreeHostCommon::calculateVisibleRects(renderSurfaceLayerList); |
| (...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3597 int nonexistentId = -1; | 3597 int nonexistentId = -1; |
| 3598 EXPECT_EQ(root, CCLayerTreeHostCommon::findLayerInSubtree(root.get(), root->
id())); | 3598 EXPECT_EQ(root, CCLayerTreeHostCommon::findLayerInSubtree(root.get(), root->
id())); |
| 3599 EXPECT_EQ(child, CCLayerTreeHostCommon::findLayerInSubtree(root.get(), child
->id())); | 3599 EXPECT_EQ(child, CCLayerTreeHostCommon::findLayerInSubtree(root.get(), child
->id())); |
| 3600 EXPECT_EQ(grandChild, CCLayerTreeHostCommon::findLayerInSubtree(root.get(),
grandChild->id())); | 3600 EXPECT_EQ(grandChild, CCLayerTreeHostCommon::findLayerInSubtree(root.get(),
grandChild->id())); |
| 3601 EXPECT_EQ(maskLayer, CCLayerTreeHostCommon::findLayerInSubtree(root.get(), m
askLayer->id())); | 3601 EXPECT_EQ(maskLayer, CCLayerTreeHostCommon::findLayerInSubtree(root.get(), m
askLayer->id())); |
| 3602 EXPECT_EQ(replicaLayer, CCLayerTreeHostCommon::findLayerInSubtree(root.get()
, replicaLayer->id())); | 3602 EXPECT_EQ(replicaLayer, CCLayerTreeHostCommon::findLayerInSubtree(root.get()
, replicaLayer->id())); |
| 3603 EXPECT_EQ(0, CCLayerTreeHostCommon::findLayerInSubtree(root.get(), nonexiste
ntId)); | 3603 EXPECT_EQ(0, CCLayerTreeHostCommon::findLayerInSubtree(root.get(), nonexiste
ntId)); |
| 3604 } | 3604 } |
| 3605 | 3605 |
| 3606 } // namespace | 3606 } // namespace |
| OLD | NEW |