Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(354)

Side by Side Diff: cc/layer_tree_host_common_unittest.cc

Issue 11472021: cc: Pass LayerTreeHostImpl to LayerImpl constructor (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 8 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « cc/layer_sorter_unittest.cc ('k') | cc/layer_tree_host_impl_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "cc/layer_tree_host_common.h" 5 #include "cc/layer_tree_host_common.h"
6 6
7 #include "cc/content_layer.h" 7 #include "cc/content_layer.h"
8 #include "cc/content_layer_client.h" 8 #include "cc/content_layer_client.h"
9 #include "cc/layer.h" 9 #include "cc/layer.h"
10 #include "cc/layer_animation_controller.h" 10 #include "cc/layer_animation_controller.h"
11 #include "cc/layer_impl.h" 11 #include "cc/layer_impl.h"
12 #include "cc/math_util.h" 12 #include "cc/math_util.h"
13 #include "cc/proxy.h" 13 #include "cc/proxy.h"
14 #include "cc/single_thread_proxy.h" 14 #include "cc/single_thread_proxy.h"
15 #include "cc/test/animation_test_common.h" 15 #include "cc/test/animation_test_common.h"
16 #include "cc/test/fake_impl_proxy.h"
17 #include "cc/test/fake_layer_tree_host_impl.h"
16 #include "cc/test/geometry_test_utils.h" 18 #include "cc/test/geometry_test_utils.h"
17 #include "cc/thread.h" 19 #include "cc/thread.h"
18 #include "testing/gmock/include/gmock/gmock.h" 20 #include "testing/gmock/include/gmock/gmock.h"
19 #include "testing/gtest/include/gtest/gtest.h" 21 #include "testing/gtest/include/gtest/gtest.h"
20 #include "ui/gfx/quad_f.h" 22 #include "ui/gfx/quad_f.h"
21 #include "ui/gfx/size_conversions.h" 23 #include "ui/gfx/size_conversions.h"
22 #include "ui/gfx/transform.h" 24 #include "ui/gfx/transform.h"
23 25
24 using namespace WebKitTests; 26 using namespace WebKitTests;
25 27
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 gfx::Transform identityMatrix; 68 gfx::Transform identityMatrix;
67 std::vector<LayerImpl*> dummyRenderSurfaceLayerList; 69 std::vector<LayerImpl*> dummyRenderSurfaceLayerList;
68 int dummyMaxTextureSize = 512; 70 int dummyMaxTextureSize = 512;
69 gfx::Size deviceViewportSize = gfx::Size(rootLayer->bounds().width() * devic eScaleFactor, rootLayer->bounds().height() * deviceScaleFactor); 71 gfx::Size deviceViewportSize = gfx::Size(rootLayer->bounds().width() * devic eScaleFactor, rootLayer->bounds().height() * deviceScaleFactor);
70 72
71 // We are probably not testing what is intended if the rootLayer bounds are empty. 73 // We are probably not testing what is intended if the rootLayer bounds are empty.
72 DCHECK(!rootLayer->bounds().IsEmpty()); 74 DCHECK(!rootLayer->bounds().IsEmpty());
73 LayerTreeHostCommon::calculateDrawProperties(rootLayer, deviceViewportSize, deviceScaleFactor, pageScaleFactor, dummyMaxTextureSize, dummyRenderSurfaceLayer List); 75 LayerTreeHostCommon::calculateDrawProperties(rootLayer, deviceViewportSize, deviceScaleFactor, pageScaleFactor, dummyMaxTextureSize, dummyRenderSurfaceLayer List);
74 } 76 }
75 77
76 scoped_ptr<LayerImpl> createTreeForFixedPositionTests() 78 scoped_ptr<LayerImpl> createTreeForFixedPositionTests(LayerTreeHostImpl* hostImp l)
77 { 79 {
78 scoped_ptr<LayerImpl> root = LayerImpl::create(1); 80 scoped_ptr<LayerImpl> root = LayerImpl::create(hostImpl, 1);
79 scoped_ptr<LayerImpl> child = LayerImpl::create(2); 81 scoped_ptr<LayerImpl> child = LayerImpl::create(hostImpl, 2);
80 scoped_ptr<LayerImpl> grandChild = LayerImpl::create(3); 82 scoped_ptr<LayerImpl> grandChild = LayerImpl::create(hostImpl, 3);
81 scoped_ptr<LayerImpl> greatGrandChild = LayerImpl::create(4); 83 scoped_ptr<LayerImpl> greatGrandChild = LayerImpl::create(hostImpl, 4);
82 84
83 gfx::Transform IdentityMatrix; 85 gfx::Transform IdentityMatrix;
84 gfx::PointF anchor(0, 0); 86 gfx::PointF anchor(0, 0);
85 gfx::PointF position(0, 0); 87 gfx::PointF position(0, 0);
86 gfx::Size bounds(100, 100); 88 gfx::Size bounds(100, 100);
87 setLayerPropertiesForTesting(root.get(), IdentityMatrix, IdentityMatrix, anc hor, position, bounds, false); 89 setLayerPropertiesForTesting(root.get(), IdentityMatrix, IdentityMatrix, anc hor, position, bounds, false);
88 setLayerPropertiesForTesting(child.get(), IdentityMatrix, IdentityMatrix, an chor, position, bounds, false); 90 setLayerPropertiesForTesting(child.get(), IdentityMatrix, IdentityMatrix, an chor, position, bounds, false);
89 setLayerPropertiesForTesting(grandChild.get(), IdentityMatrix, IdentityMatri x, anchor, position, bounds, false); 91 setLayerPropertiesForTesting(grandChild.get(), IdentityMatrix, IdentityMatri x, anchor, position, bounds, false);
90 setLayerPropertiesForTesting(greatGrandChild.get(), IdentityMatrix, Identity Matrix, anchor, position, bounds, false); 92 setLayerPropertiesForTesting(greatGrandChild.get(), IdentityMatrix, Identity Matrix, anchor, position, bounds, false);
91 93
(...skipping 676 matching lines...) Expand 10 before | Expand all | Expand 10 after
768 LayerTreeHostCommon::calculateDrawProperties(parent.get(), parent->bounds(), 1, 1, dummyMaxTextureSize, renderSurfaceLayerList); 770 LayerTreeHostCommon::calculateDrawProperties(parent.get(), parent->bounds(), 1, 1, dummyMaxTextureSize, renderSurfaceLayerList);
769 EXPECT_TRUE(parent->renderSurface()); 771 EXPECT_TRUE(parent->renderSurface());
770 EXPECT_FALSE(renderSurface1->renderSurface()); 772 EXPECT_FALSE(renderSurface1->renderSurface());
771 EXPECT_EQ(1U, renderSurfaceLayerList.size()); 773 EXPECT_EQ(1U, renderSurfaceLayerList.size());
772 } 774 }
773 775
774 TEST(LayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerWithD irectContainer) 776 TEST(LayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerWithD irectContainer)
775 { 777 {
776 // This test checks for correct scroll compensation when the fixed-position container 778 // This test checks for correct scroll compensation when the fixed-position container
777 // is the direct parent of the fixed-position layer. 779 // is the direct parent of the fixed-position layer.
778 scoped_ptr<LayerImpl> root = createTreeForFixedPositionTests(); 780 FakeImplProxy proxy;
781 FakeLayerTreeHostImpl hostImpl(&proxy);
782 scoped_ptr<LayerImpl> root = createTreeForFixedPositionTests(&hostImpl);
779 LayerImpl* child = root->children()[0]; 783 LayerImpl* child = root->children()[0];
780 LayerImpl* grandChild = child->children()[0]; 784 LayerImpl* grandChild = child->children()[0];
781 785
782 child->setIsContainerForFixedPositionLayers(true); 786 child->setIsContainerForFixedPositionLayers(true);
783 grandChild->setFixedToContainerLayer(true); 787 grandChild->setFixedToContainerLayer(true);
784 788
785 // Case 1: scrollDelta of 0, 0 789 // Case 1: scrollDelta of 0, 0
786 child->setScrollDelta(gfx::Vector2d(0, 0)); 790 child->setScrollDelta(gfx::Vector2d(0, 0));
787 executeCalculateDrawProperties(root.get()); 791 executeCalculateDrawProperties(root.get());
788 792
(...skipping 18 matching lines...) Expand all
807 TEST(LayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerWithT ransformedDirectContainer) 811 TEST(LayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerWithT ransformedDirectContainer)
808 { 812 {
809 // This test checks for correct scroll compensation when the fixed-position container 813 // This test checks for correct scroll compensation when the fixed-position container
810 // is the direct parent of the fixed-position layer, but that container is t ransformed. 814 // is the direct parent of the fixed-position layer, but that container is t ransformed.
811 // In this case, the fixed position element inherits the container's transfo rm, 815 // In this case, the fixed position element inherits the container's transfo rm,
812 // but the scrollDelta that has to be undone should not be affected by that transform. 816 // but the scrollDelta that has to be undone should not be affected by that transform.
813 // 817 //
814 // gfx::Transforms are in general non-commutative; using something like a no n-uniform scale 818 // gfx::Transforms are in general non-commutative; using something like a no n-uniform scale
815 // helps to verify that translations and non-uniform scales are applied in t he correct 819 // helps to verify that translations and non-uniform scales are applied in t he correct
816 // order. 820 // order.
817 scoped_ptr<LayerImpl> root = createTreeForFixedPositionTests(); 821 FakeImplProxy proxy;
822 FakeLayerTreeHostImpl hostImpl(&proxy);
823 scoped_ptr<LayerImpl> root = createTreeForFixedPositionTests(&hostImpl);
818 LayerImpl* child = root->children()[0]; 824 LayerImpl* child = root->children()[0];
819 LayerImpl* grandChild = child->children()[0]; 825 LayerImpl* grandChild = child->children()[0];
820 826
821 // This scale will cause child and grandChild to be effectively 200 x 800 wi th respect to the renderTarget. 827 // This scale will cause child and grandChild to be effectively 200 x 800 wi th respect to the renderTarget.
822 gfx::Transform nonUniformScale; 828 gfx::Transform nonUniformScale;
823 nonUniformScale.Scale(2, 8); 829 nonUniformScale.Scale(2, 8);
824 child->setTransform(nonUniformScale); 830 child->setTransform(nonUniformScale);
825 831
826 child->setIsContainerForFixedPositionLayers(true); 832 child->setIsContainerForFixedPositionLayers(true);
827 grandChild->setFixedToContainerLayer(true); 833 grandChild->setFixedToContainerLayer(true);
(...skipping 20 matching lines...) Expand all
848 expectedChildTransform.PreconcatTransform(nonUniformScale); 854 expectedChildTransform.PreconcatTransform(nonUniformScale);
849 855
850 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->drawTransform ()); 856 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->drawTransform ());
851 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->dra wTransform()); 857 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->dra wTransform());
852 } 858 }
853 859
854 TEST(LayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerWithD istantContainer) 860 TEST(LayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerWithD istantContainer)
855 { 861 {
856 // This test checks for correct scroll compensation when the fixed-position container 862 // This test checks for correct scroll compensation when the fixed-position container
857 // is NOT the direct parent of the fixed-position layer. 863 // is NOT the direct parent of the fixed-position layer.
858 scoped_ptr<LayerImpl> root = createTreeForFixedPositionTests(); 864 FakeImplProxy proxy;
865 FakeLayerTreeHostImpl hostImpl(&proxy);
866 scoped_ptr<LayerImpl> root = createTreeForFixedPositionTests(&hostImpl);
859 LayerImpl* child = root->children()[0]; 867 LayerImpl* child = root->children()[0];
860 LayerImpl* grandChild = child->children()[0]; 868 LayerImpl* grandChild = child->children()[0];
861 LayerImpl* greatGrandChild = grandChild->children()[0]; 869 LayerImpl* greatGrandChild = grandChild->children()[0];
862 870
863 child->setIsContainerForFixedPositionLayers(true); 871 child->setIsContainerForFixedPositionLayers(true);
864 grandChild->setPosition(gfx::PointF(8, 6)); 872 grandChild->setPosition(gfx::PointF(8, 6));
865 greatGrandChild->setFixedToContainerLayer(true); 873 greatGrandChild->setFixedToContainerLayer(true);
866 874
867 // Case 1: scrollDelta of 0, 0 875 // Case 1: scrollDelta of 0, 0
868 child->setScrollDelta(gfx::Vector2d(0, 0)); 876 child->setScrollDelta(gfx::Vector2d(0, 0));
(...skipping 21 matching lines...) Expand all
890 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->drawTransform ()); 898 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->drawTransform ());
891 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->dra wTransform()); 899 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->dra wTransform());
892 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGreatGrandChildTransform, greatGrand Child->drawTransform()); 900 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGreatGrandChildTransform, greatGrand Child->drawTransform());
893 } 901 }
894 902
895 TEST(LayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerWithD istantContainerAndTransforms) 903 TEST(LayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerWithD istantContainerAndTransforms)
896 { 904 {
897 // This test checks for correct scroll compensation when the fixed-position container 905 // This test checks for correct scroll compensation when the fixed-position container
898 // is NOT the direct parent of the fixed-position layer, and the hierarchy h as various 906 // is NOT the direct parent of the fixed-position layer, and the hierarchy h as various
899 // transforms that have to be processed in the correct order. 907 // transforms that have to be processed in the correct order.
900 scoped_ptr<LayerImpl> root = createTreeForFixedPositionTests(); 908 FakeImplProxy proxy;
909 FakeLayerTreeHostImpl hostImpl(&proxy);
910 scoped_ptr<LayerImpl> root = createTreeForFixedPositionTests(&hostImpl);
901 LayerImpl* child = root->children()[0]; 911 LayerImpl* child = root->children()[0];
902 LayerImpl* grandChild = child->children()[0]; 912 LayerImpl* grandChild = child->children()[0];
903 LayerImpl* greatGrandChild = grandChild->children()[0]; 913 LayerImpl* greatGrandChild = grandChild->children()[0];
904 914
905 gfx::Transform rotationAboutZ; 915 gfx::Transform rotationAboutZ;
906 MathUtil::rotateEulerAngles(&rotationAboutZ, 0, 0, 90); 916 MathUtil::rotateEulerAngles(&rotationAboutZ, 0, 0, 90);
907 917
908 child->setIsContainerForFixedPositionLayers(true); 918 child->setIsContainerForFixedPositionLayers(true);
909 child->setTransform(rotationAboutZ); 919 child->setTransform(rotationAboutZ);
910 grandChild->setPosition(gfx::PointF(8, 6)); 920 grandChild->setPosition(gfx::PointF(8, 6));
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
950 } 960 }
951 961
952 TEST(LayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerWithM ultipleScrollDeltas) 962 TEST(LayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerWithM ultipleScrollDeltas)
953 { 963 {
954 // This test checks for correct scroll compensation when the fixed-position container 964 // This test checks for correct scroll compensation when the fixed-position container
955 // has multiple ancestors that have nonzero scrollDelta before reaching the space where the layer is fixed. 965 // has multiple ancestors that have nonzero scrollDelta before reaching the space where the layer is fixed.
956 // In this test, each scrollDelta occurs in a different space because of eac h layer's local transform. 966 // In this test, each scrollDelta occurs in a different space because of eac h layer's local transform.
957 // This test checks for correct scroll compensation when the fixed-position container 967 // This test checks for correct scroll compensation when the fixed-position container
958 // is NOT the direct parent of the fixed-position layer, and the hierarchy h as various 968 // is NOT the direct parent of the fixed-position layer, and the hierarchy h as various
959 // transforms that have to be processed in the correct order. 969 // transforms that have to be processed in the correct order.
960 scoped_ptr<LayerImpl> root = createTreeForFixedPositionTests(); 970 FakeImplProxy proxy;
971 FakeLayerTreeHostImpl hostImpl(&proxy);
972 scoped_ptr<LayerImpl> root = createTreeForFixedPositionTests(&hostImpl);
961 LayerImpl* child = root->children()[0]; 973 LayerImpl* child = root->children()[0];
962 LayerImpl* grandChild = child->children()[0]; 974 LayerImpl* grandChild = child->children()[0];
963 LayerImpl* greatGrandChild = grandChild->children()[0]; 975 LayerImpl* greatGrandChild = grandChild->children()[0];
964 976
965 gfx::Transform rotationAboutZ; 977 gfx::Transform rotationAboutZ;
966 MathUtil::rotateEulerAngles(&rotationAboutZ, 0, 0, 90); 978 MathUtil::rotateEulerAngles(&rotationAboutZ, 0, 0, 90);
967 979
968 child->setIsContainerForFixedPositionLayers(true); 980 child->setIsContainerForFixedPositionLayers(true);
969 child->setTransform(rotationAboutZ); 981 child->setTransform(rotationAboutZ);
970 grandChild->setPosition(gfx::PointF(8, 6)); 982 grandChild->setPosition(gfx::PointF(8, 6));
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
1010 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->dra wTransform()); 1022 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->dra wTransform());
1011 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGreatGrandChildTransform, greatGrand Child->drawTransform()); 1023 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGreatGrandChildTransform, greatGrand Child->drawTransform());
1012 } 1024 }
1013 1025
1014 TEST(LayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerWithI ntermediateSurfaceAndTransforms) 1026 TEST(LayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerWithI ntermediateSurfaceAndTransforms)
1015 { 1027 {
1016 // This test checks for correct scroll compensation when the fixed-position container 1028 // This test checks for correct scroll compensation when the fixed-position container
1017 // contributes to a different renderSurface than the fixed-position layer. I n this 1029 // contributes to a different renderSurface than the fixed-position layer. I n this
1018 // case, the surface drawTransforms also have to be accounted for when check ing the 1030 // case, the surface drawTransforms also have to be accounted for when check ing the
1019 // scrollDelta. 1031 // scrollDelta.
1020 scoped_ptr<LayerImpl> root = createTreeForFixedPositionTests(); 1032 FakeImplProxy proxy;
1033 FakeLayerTreeHostImpl hostImpl(&proxy);
1034 scoped_ptr<LayerImpl> root = createTreeForFixedPositionTests(&hostImpl);
1021 LayerImpl* child = root->children()[0]; 1035 LayerImpl* child = root->children()[0];
1022 LayerImpl* grandChild = child->children()[0]; 1036 LayerImpl* grandChild = child->children()[0];
1023 LayerImpl* greatGrandChild = grandChild->children()[0]; 1037 LayerImpl* greatGrandChild = grandChild->children()[0];
1024 1038
1025 child->setIsContainerForFixedPositionLayers(true); 1039 child->setIsContainerForFixedPositionLayers(true);
1026 grandChild->setPosition(gfx::PointF(8, 6)); 1040 grandChild->setPosition(gfx::PointF(8, 6));
1027 grandChild->setForceRenderSurface(true); 1041 grandChild->setForceRenderSurface(true);
1028 greatGrandChild->setFixedToContainerLayer(true); 1042 greatGrandChild->setFixedToContainerLayer(true);
1029 greatGrandChild->setDrawsContent(true); 1043 greatGrandChild->setDrawsContent(true);
1030 1044
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
1081 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->dra wTransform()); 1095 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->dra wTransform());
1082 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGreatGrandChildTransform, greatGrand Child->drawTransform()); 1096 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGreatGrandChildTransform, greatGrand Child->drawTransform());
1083 } 1097 }
1084 1098
1085 TEST(LayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerWithM ultipleIntermediateSurfaces) 1099 TEST(LayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerWithM ultipleIntermediateSurfaces)
1086 { 1100 {
1087 // This test checks for correct scroll compensation when the fixed-position container 1101 // This test checks for correct scroll compensation when the fixed-position container
1088 // contributes to a different renderSurface than the fixed-position layer, w ith 1102 // contributes to a different renderSurface than the fixed-position layer, w ith
1089 // additional renderSurfaces in-between. This checks that the conversion to ancestor 1103 // additional renderSurfaces in-between. This checks that the conversion to ancestor
1090 // surfaces is accumulated properly in the final matrix transform. 1104 // surfaces is accumulated properly in the final matrix transform.
1091 scoped_ptr<LayerImpl> root = createTreeForFixedPositionTests(); 1105 FakeImplProxy proxy;
1106 FakeLayerTreeHostImpl hostImpl(&proxy);
1107 scoped_ptr<LayerImpl> root = createTreeForFixedPositionTests(&hostImpl);
1092 LayerImpl* child = root->children()[0]; 1108 LayerImpl* child = root->children()[0];
1093 LayerImpl* grandChild = child->children()[0]; 1109 LayerImpl* grandChild = child->children()[0];
1094 LayerImpl* greatGrandChild = grandChild->children()[0]; 1110 LayerImpl* greatGrandChild = grandChild->children()[0];
1095 1111
1096 // Add one more layer to the test tree for this scenario. 1112 // Add one more layer to the test tree for this scenario.
1097 { 1113 {
1098 gfx::Transform identity; 1114 gfx::Transform identity;
1099 scoped_ptr<LayerImpl> fixedPositionChild = LayerImpl::create(5); 1115 scoped_ptr<LayerImpl> fixedPositionChild = LayerImpl::create(&hostImpl, 5);
1100 setLayerPropertiesForTesting(fixedPositionChild.get(), identity, identit y, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); 1116 setLayerPropertiesForTesting(fixedPositionChild.get(), identity, identit y, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false);
1101 greatGrandChild->addChild(fixedPositionChild.Pass()); 1117 greatGrandChild->addChild(fixedPositionChild.Pass());
1102 } 1118 }
1103 LayerImpl* fixedPositionChild = greatGrandChild->children()[0]; 1119 LayerImpl* fixedPositionChild = greatGrandChild->children()[0];
1104 1120
1105 // Actually set up the scenario here. 1121 // Actually set up the scenario here.
1106 child->setIsContainerForFixedPositionLayers(true); 1122 child->setIsContainerForFixedPositionLayers(true);
1107 grandChild->setPosition(gfx::PointF(8, 6)); 1123 grandChild->setPosition(gfx::PointF(8, 6));
1108 grandChild->setForceRenderSurface(true); 1124 grandChild->setForceRenderSurface(true);
1109 greatGrandChild->setPosition(gfx::PointF(40, 60)); 1125 greatGrandChild->setPosition(gfx::PointF(40, 60));
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
1190 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGreatGrandChildTransform, greatGrand Child->drawTransform()); 1206 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGreatGrandChildTransform, greatGrand Child->drawTransform());
1191 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedFixedPositionChildTransform, fixedPo sitionChild->drawTransform()); 1207 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedFixedPositionChildTransform, fixedPo sitionChild->drawTransform());
1192 } 1208 }
1193 1209
1194 TEST(LayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerWithC ontainerLayerThatHasSurface) 1210 TEST(LayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerWithC ontainerLayerThatHasSurface)
1195 { 1211 {
1196 // This test checks for correct scroll compensation when the fixed-position container 1212 // This test checks for correct scroll compensation when the fixed-position container
1197 // itself has a renderSurface. In this case, the container layer should be t reated 1213 // itself has a renderSurface. In this case, the container layer should be t reated
1198 // like a layer that contributes to a renderTarget, and that renderTarget 1214 // like a layer that contributes to a renderTarget, and that renderTarget
1199 // is completely irrelevant; it should not affect the scroll compensation. 1215 // is completely irrelevant; it should not affect the scroll compensation.
1200 scoped_ptr<LayerImpl> root = createTreeForFixedPositionTests(); 1216 FakeImplProxy proxy;
1217 FakeLayerTreeHostImpl hostImpl(&proxy);
1218 scoped_ptr<LayerImpl> root = createTreeForFixedPositionTests(&hostImpl);
1201 LayerImpl* child = root->children()[0]; 1219 LayerImpl* child = root->children()[0];
1202 LayerImpl* grandChild = child->children()[0]; 1220 LayerImpl* grandChild = child->children()[0];
1203 1221
1204 child->setIsContainerForFixedPositionLayers(true); 1222 child->setIsContainerForFixedPositionLayers(true);
1205 child->setForceRenderSurface(true); 1223 child->setForceRenderSurface(true);
1206 grandChild->setFixedToContainerLayer(true); 1224 grandChild->setFixedToContainerLayer(true);
1207 grandChild->setDrawsContent(true); 1225 grandChild->setDrawsContent(true);
1208 1226
1209 // Case 1: scrollDelta of 0, 0 1227 // Case 1: scrollDelta of 0, 0
1210 child->setScrollDelta(gfx::Vector2d(0, 0)); 1228 child->setScrollDelta(gfx::Vector2d(0, 0));
(...skipping 24 matching lines...) Expand all
1235 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedSurfaceDrawTransform, child->renderS urface()->drawTransform()); 1253 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedSurfaceDrawTransform, child->renderS urface()->drawTransform());
1236 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->drawTransform ()); 1254 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->drawTransform ());
1237 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->dra wTransform()); 1255 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->dra wTransform());
1238 } 1256 }
1239 1257
1240 TEST(LayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerThatI sAlsoFixedPositionContainer) 1258 TEST(LayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerThatI sAlsoFixedPositionContainer)
1241 { 1259 {
1242 // This test checks the scenario where a fixed-position layer also happens t o be a 1260 // This test checks the scenario where a fixed-position layer also happens t o be a
1243 // container itself for a descendant fixed position layer. In particular, th e layer 1261 // container itself for a descendant fixed position layer. In particular, th e layer
1244 // should not accidentally be fixed to itself. 1262 // should not accidentally be fixed to itself.
1245 scoped_ptr<LayerImpl> root = createTreeForFixedPositionTests(); 1263 FakeImplProxy proxy;
1264 FakeLayerTreeHostImpl hostImpl(&proxy);
1265 scoped_ptr<LayerImpl> root = createTreeForFixedPositionTests(&hostImpl);
1246 LayerImpl* child = root->children()[0]; 1266 LayerImpl* child = root->children()[0];
1247 LayerImpl* grandChild = child->children()[0]; 1267 LayerImpl* grandChild = child->children()[0];
1248 1268
1249 child->setIsContainerForFixedPositionLayers(true); 1269 child->setIsContainerForFixedPositionLayers(true);
1250 grandChild->setFixedToContainerLayer(true); 1270 grandChild->setFixedToContainerLayer(true);
1251 1271
1252 // This should not confuse the grandChild. If correct, the grandChild would still be considered fixed to its container (i.e. "child"). 1272 // This should not confuse the grandChild. If correct, the grandChild would still be considered fixed to its container (i.e. "child").
1253 grandChild->setIsContainerForFixedPositionLayers(true); 1273 grandChild->setIsContainerForFixedPositionLayers(true);
1254 1274
1255 // Case 1: scrollDelta of 0, 0 1275 // Case 1: scrollDelta of 0, 0
(...skipping 14 matching lines...) Expand all
1270 expectedChildTransform.Translate(-10, -10); 1290 expectedChildTransform.Translate(-10, -10);
1271 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->drawTransform ()); 1291 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->drawTransform ());
1272 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->dra wTransform()); 1292 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->dra wTransform());
1273 } 1293 }
1274 1294
1275 TEST(LayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerThatH asNoContainer) 1295 TEST(LayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerThatH asNoContainer)
1276 { 1296 {
1277 // This test checks scroll compensation when a fixed-position layer does not find any 1297 // This test checks scroll compensation when a fixed-position layer does not find any
1278 // ancestor that is a "containerForFixedPositionLayers". In this situation, the layer should 1298 // ancestor that is a "containerForFixedPositionLayers". In this situation, the layer should
1279 // be fixed to the viewport -- not the rootLayer, which may have transforms of its own. 1299 // be fixed to the viewport -- not the rootLayer, which may have transforms of its own.
1280 scoped_ptr<LayerImpl> root = createTreeForFixedPositionTests(); 1300 FakeImplProxy proxy;
1301 FakeLayerTreeHostImpl hostImpl(&proxy);
1302 scoped_ptr<LayerImpl> root = createTreeForFixedPositionTests(&hostImpl);
1281 LayerImpl* child = root->children()[0]; 1303 LayerImpl* child = root->children()[0];
1282 LayerImpl* grandChild = child->children()[0]; 1304 LayerImpl* grandChild = child->children()[0];
1283 1305
1284 gfx::Transform rotationByZ; 1306 gfx::Transform rotationByZ;
1285 MathUtil::rotateEulerAngles(&rotationByZ, 0, 0, 90); 1307 MathUtil::rotateEulerAngles(&rotationByZ, 0, 0, 90);
1286 1308
1287 root->setTransform(rotationByZ); 1309 root->setTransform(rotationByZ);
1288 grandChild->setFixedToContainerLayer(true); 1310 grandChild->setFixedToContainerLayer(true);
1289 1311
1290 // Case 1: root scrollDelta of 0, 0 1312 // Case 1: root scrollDelta of 0, 0
(...skipping 1471 matching lines...) Expand 10 before | Expand all | Expand 10 after
2762 LayerImpl* resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(test Point, renderSurfaceLayerList); 2784 LayerImpl* resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(test Point, renderSurfaceLayerList);
2763 EXPECT_FALSE(resultLayer); 2785 EXPECT_FALSE(resultLayer);
2764 2786
2765 testPoint = gfx::Point(10, 20); 2787 testPoint = gfx::Point(10, 20);
2766 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend erSurfaceLayerList); 2788 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend erSurfaceLayerList);
2767 EXPECT_FALSE(resultLayer); 2789 EXPECT_FALSE(resultLayer);
2768 } 2790 }
2769 2791
2770 TEST(LayerTreeHostCommonTest, verifyHitTestingForSingleLayer) 2792 TEST(LayerTreeHostCommonTest, verifyHitTestingForSingleLayer)
2771 { 2793 {
2772 scoped_ptr<LayerImpl> root = LayerImpl::create(12345); 2794 FakeImplProxy proxy;
2795 FakeLayerTreeHostImpl hostImpl(&proxy);
2796 scoped_ptr<LayerImpl> root = LayerImpl::create(&hostImpl, 12345);
2773 2797
2774 gfx::Transform identityMatrix; 2798 gfx::Transform identityMatrix;
2775 gfx::PointF anchor(0, 0); 2799 gfx::PointF anchor(0, 0);
2776 gfx::PointF position(0, 0); 2800 gfx::PointF position(0, 0);
2777 gfx::Size bounds(100, 100); 2801 gfx::Size bounds(100, 100);
2778 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc hor, position, bounds, false); 2802 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc hor, position, bounds, false);
2779 root->setDrawsContent(true); 2803 root->setDrawsContent(true);
2780 2804
2781 std::vector<LayerImpl*> renderSurfaceLayerList; 2805 std::vector<LayerImpl*> renderSurfaceLayerList;
2782 int dummyMaxTextureSize = 512; 2806 int dummyMaxTextureSize = 512;
(...skipping 19 matching lines...) Expand all
2802 EXPECT_EQ(12345, resultLayer->id()); 2826 EXPECT_EQ(12345, resultLayer->id());
2803 2827
2804 testPoint = gfx::Point(99, 99); 2828 testPoint = gfx::Point(99, 99);
2805 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend erSurfaceLayerList); 2829 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend erSurfaceLayerList);
2806 ASSERT_TRUE(resultLayer); 2830 ASSERT_TRUE(resultLayer);
2807 EXPECT_EQ(12345, resultLayer->id()); 2831 EXPECT_EQ(12345, resultLayer->id());
2808 } 2832 }
2809 2833
2810 TEST(LayerTreeHostCommonTest, verifyHitTestingForUninvertibleTransform) 2834 TEST(LayerTreeHostCommonTest, verifyHitTestingForUninvertibleTransform)
2811 { 2835 {
2812 scoped_ptr<LayerImpl> root = LayerImpl::create(12345); 2836 FakeImplProxy proxy;
2837 FakeLayerTreeHostImpl hostImpl(&proxy);
2838 scoped_ptr<LayerImpl> root = LayerImpl::create(&hostImpl, 12345);
2813 2839
2814 gfx::Transform uninvertibleTransform; 2840 gfx::Transform uninvertibleTransform;
2815 uninvertibleTransform.matrix().setDouble(0, 0, 0); 2841 uninvertibleTransform.matrix().setDouble(0, 0, 0);
2816 uninvertibleTransform.matrix().setDouble(1, 1, 0); 2842 uninvertibleTransform.matrix().setDouble(1, 1, 0);
2817 uninvertibleTransform.matrix().setDouble(2, 2, 0); 2843 uninvertibleTransform.matrix().setDouble(2, 2, 0);
2818 uninvertibleTransform.matrix().setDouble(3, 3, 0); 2844 uninvertibleTransform.matrix().setDouble(3, 3, 0);
2819 ASSERT_FALSE(uninvertibleTransform.IsInvertible()); 2845 ASSERT_FALSE(uninvertibleTransform.IsInvertible());
2820 2846
2821 gfx::Transform identityMatrix; 2847 gfx::Transform identityMatrix;
2822 gfx::PointF anchor(0, 0); 2848 gfx::PointF anchor(0, 0);
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
2861 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend erSurfaceLayerList); 2887 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend erSurfaceLayerList);
2862 EXPECT_FALSE(resultLayer); 2888 EXPECT_FALSE(resultLayer);
2863 2889
2864 testPoint = gfx::Point(-1, -1); 2890 testPoint = gfx::Point(-1, -1);
2865 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend erSurfaceLayerList); 2891 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend erSurfaceLayerList);
2866 EXPECT_FALSE(resultLayer); 2892 EXPECT_FALSE(resultLayer);
2867 } 2893 }
2868 2894
2869 TEST(LayerTreeHostCommonTest, verifyHitTestingForSinglePositionedLayer) 2895 TEST(LayerTreeHostCommonTest, verifyHitTestingForSinglePositionedLayer)
2870 { 2896 {
2871 scoped_ptr<LayerImpl> root = LayerImpl::create(12345); 2897 FakeImplProxy proxy;
2898 FakeLayerTreeHostImpl hostImpl(&proxy);
2899 scoped_ptr<LayerImpl> root = LayerImpl::create(&hostImpl, 12345);
2872 2900
2873 gfx::Transform identityMatrix; 2901 gfx::Transform identityMatrix;
2874 gfx::PointF anchor(0, 0); 2902 gfx::PointF anchor(0, 0);
2875 gfx::PointF position(50, 50); // this layer is positioned, and hit testing s hould correctly know where the layer is located. 2903 gfx::PointF position(50, 50); // this layer is positioned, and hit testing s hould correctly know where the layer is located.
2876 gfx::Size bounds(100, 100); 2904 gfx::Size bounds(100, 100);
2877 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc hor, position, bounds, false); 2905 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc hor, position, bounds, false);
2878 root->setDrawsContent(true); 2906 root->setDrawsContent(true);
2879 2907
2880 std::vector<LayerImpl*> renderSurfaceLayerList; 2908 std::vector<LayerImpl*> renderSurfaceLayerList;
2881 int dummyMaxTextureSize = 512; 2909 int dummyMaxTextureSize = 512;
(...skipping 20 matching lines...) Expand all
2902 EXPECT_EQ(12345, resultLayer->id()); 2930 EXPECT_EQ(12345, resultLayer->id());
2903 2931
2904 testPoint = gfx::Point(99, 99); 2932 testPoint = gfx::Point(99, 99);
2905 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend erSurfaceLayerList); 2933 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend erSurfaceLayerList);
2906 ASSERT_TRUE(resultLayer); 2934 ASSERT_TRUE(resultLayer);
2907 EXPECT_EQ(12345, resultLayer->id()); 2935 EXPECT_EQ(12345, resultLayer->id());
2908 } 2936 }
2909 2937
2910 TEST(LayerTreeHostCommonTest, verifyHitTestingForSingleRotatedLayer) 2938 TEST(LayerTreeHostCommonTest, verifyHitTestingForSingleRotatedLayer)
2911 { 2939 {
2912 scoped_ptr<LayerImpl> root = LayerImpl::create(12345); 2940 FakeImplProxy proxy;
2941 FakeLayerTreeHostImpl hostImpl(&proxy);
2942 scoped_ptr<LayerImpl> root = LayerImpl::create(&hostImpl, 12345);
2913 2943
2914 gfx::Transform identityMatrix; 2944 gfx::Transform identityMatrix;
2915 gfx::Transform rotation45DegreesAboutCenter; 2945 gfx::Transform rotation45DegreesAboutCenter;
2916 rotation45DegreesAboutCenter.Translate(50, 50); 2946 rotation45DegreesAboutCenter.Translate(50, 50);
2917 MathUtil::rotateEulerAngles(&rotation45DegreesAboutCenter, 0, 0, 45); 2947 MathUtil::rotateEulerAngles(&rotation45DegreesAboutCenter, 0, 0, 45);
2918 rotation45DegreesAboutCenter.Translate(-50, -50); 2948 rotation45DegreesAboutCenter.Translate(-50, -50);
2919 gfx::PointF anchor(0, 0); 2949 gfx::PointF anchor(0, 0);
2920 gfx::PointF position(0, 0); 2950 gfx::PointF position(0, 0);
2921 gfx::Size bounds(100, 100); 2951 gfx::Size bounds(100, 100);
2922 setLayerPropertiesForTesting(root.get(), rotation45DegreesAboutCenter, ident ityMatrix, anchor, position, bounds, false); 2952 setLayerPropertiesForTesting(root.get(), rotation45DegreesAboutCenter, ident ityMatrix, anchor, position, bounds, false);
(...skipping 28 matching lines...) Expand all
2951 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend erSurfaceLayerList); 2981 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend erSurfaceLayerList);
2952 ASSERT_FALSE(resultLayer); 2982 ASSERT_FALSE(resultLayer);
2953 2983
2954 testPoint = gfx::Point(-1, 50); 2984 testPoint = gfx::Point(-1, 50);
2955 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend erSurfaceLayerList); 2985 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend erSurfaceLayerList);
2956 ASSERT_FALSE(resultLayer); 2986 ASSERT_FALSE(resultLayer);
2957 } 2987 }
2958 2988
2959 TEST(LayerTreeHostCommonTest, verifyHitTestingForSinglePerspectiveLayer) 2989 TEST(LayerTreeHostCommonTest, verifyHitTestingForSinglePerspectiveLayer)
2960 { 2990 {
2961 scoped_ptr<LayerImpl> root = LayerImpl::create(12345); 2991 FakeImplProxy proxy;
2992 FakeLayerTreeHostImpl hostImpl(&proxy);
2993 scoped_ptr<LayerImpl> root = LayerImpl::create(&hostImpl, 12345);
2962 2994
2963 gfx::Transform identityMatrix; 2995 gfx::Transform identityMatrix;
2964 2996
2965 // perspectiveProjectionAboutCenter * translationByZ is designed so that the 100 x 100 layer becomes 50 x 50, and remains centered at (50, 50). 2997 // perspectiveProjectionAboutCenter * translationByZ is designed so that the 100 x 100 layer becomes 50 x 50, and remains centered at (50, 50).
2966 gfx::Transform perspectiveProjectionAboutCenter; 2998 gfx::Transform perspectiveProjectionAboutCenter;
2967 perspectiveProjectionAboutCenter.Translate(50, 50); 2999 perspectiveProjectionAboutCenter.Translate(50, 50);
2968 perspectiveProjectionAboutCenter.ApplyPerspectiveDepth(1); 3000 perspectiveProjectionAboutCenter.ApplyPerspectiveDepth(1);
2969 perspectiveProjectionAboutCenter.Translate(-50, -50); 3001 perspectiveProjectionAboutCenter.Translate(-50, -50);
2970 gfx::Transform translationByZ; 3002 gfx::Transform translationByZ;
2971 translationByZ.Translate3d(0, 0, -1); 3003 translationByZ.Translate3d(0, 0, -1);
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
3011 // A layer's visibleContentRect is actually in the layer's content space. Th e 3043 // A layer's visibleContentRect is actually in the layer's content space. Th e
3012 // screenSpaceTransform converts from the layer's origin space to screen spa ce. This 3044 // screenSpaceTransform converts from the layer's origin space to screen spa ce. This
3013 // test makes sure that hit testing works correctly accounts for the content s scale. 3045 // test makes sure that hit testing works correctly accounts for the content s scale.
3014 // A contentsScale that is not 1 effectively forces a non-identity transform between 3046 // A contentsScale that is not 1 effectively forces a non-identity transform between
3015 // layer's content space and layer's origin space. The hit testing code must take this into account. 3047 // layer's content space and layer's origin space. The hit testing code must take this into account.
3016 // 3048 //
3017 // To test this, the layer is positioned at (25, 25), and is size (50, 50). If 3049 // To test this, the layer is positioned at (25, 25), and is size (50, 50). If
3018 // contentsScale is ignored, then hit testing will mis-interpret the visible ContentRect 3050 // contentsScale is ignored, then hit testing will mis-interpret the visible ContentRect
3019 // as being larger than the actual bounds of the layer. 3051 // as being larger than the actual bounds of the layer.
3020 // 3052 //
3021 scoped_ptr<LayerImpl> root = LayerImpl::create(1); 3053 FakeImplProxy proxy;
3054 FakeLayerTreeHostImpl hostImpl(&proxy);
3055 scoped_ptr<LayerImpl> root = LayerImpl::create(&hostImpl, 1);
3022 3056
3023 gfx::Transform identityMatrix; 3057 gfx::Transform identityMatrix;
3024 gfx::PointF anchor(0, 0); 3058 gfx::PointF anchor(0, 0);
3025 3059
3026 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc hor, gfx::PointF(0, 0), gfx::Size(100, 100), false); 3060 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc hor, gfx::PointF(0, 0), gfx::Size(100, 100), false);
3027 3061
3028 { 3062 {
3029 gfx::PointF position(25, 25); 3063 gfx::PointF position(25, 25);
3030 gfx::Size bounds(50, 50); 3064 gfx::Size bounds(50, 50);
3031 scoped_ptr<LayerImpl> testLayer = LayerImpl::create(12345); 3065 scoped_ptr<LayerImpl> testLayer = LayerImpl::create(&hostImpl, 12345);
3032 setLayerPropertiesForTesting(testLayer.get(), identityMatrix, identityMa trix, anchor, position, bounds, false); 3066 setLayerPropertiesForTesting(testLayer.get(), identityMatrix, identityMa trix, anchor, position, bounds, false);
3033 3067
3034 // override contentBounds and contentsScale 3068 // override contentBounds and contentsScale
3035 testLayer->setContentBounds(gfx::Size(100, 100)); 3069 testLayer->setContentBounds(gfx::Size(100, 100));
3036 testLayer->setContentsScale(2, 2); 3070 testLayer->setContentsScale(2, 2);
3037 3071
3038 testLayer->setDrawsContent(true); 3072 testLayer->setDrawsContent(true);
3039 root->addChild(testLayer.Pass()); 3073 root->addChild(testLayer.Pass());
3040 } 3074 }
3041 3075
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
3075 EXPECT_EQ(12345, resultLayer->id()); 3109 EXPECT_EQ(12345, resultLayer->id());
3076 } 3110 }
3077 3111
3078 TEST(LayerTreeHostCommonTest, verifyHitTestingForSimpleClippedLayer) 3112 TEST(LayerTreeHostCommonTest, verifyHitTestingForSimpleClippedLayer)
3079 { 3113 {
3080 // Test that hit-testing will only work for the visible portion of a layer, and not 3114 // Test that hit-testing will only work for the visible portion of a layer, and not
3081 // the entire layer bounds. Here we just test the simple axis-aligned case. 3115 // the entire layer bounds. Here we just test the simple axis-aligned case.
3082 gfx::Transform identityMatrix; 3116 gfx::Transform identityMatrix;
3083 gfx::PointF anchor(0, 0); 3117 gfx::PointF anchor(0, 0);
3084 3118
3085 scoped_ptr<LayerImpl> root = LayerImpl::create(1); 3119 FakeImplProxy proxy;
3120 FakeLayerTreeHostImpl hostImpl(&proxy);
3121 scoped_ptr<LayerImpl> root = LayerImpl::create(&hostImpl, 1);
3086 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc hor, gfx::PointF(0, 0), gfx::Size(100, 100), false); 3122 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc hor, gfx::PointF(0, 0), gfx::Size(100, 100), false);
3087 3123
3088 { 3124 {
3089 scoped_ptr<LayerImpl> clippingLayer = LayerImpl::create(123); 3125 scoped_ptr<LayerImpl> clippingLayer = LayerImpl::create(&hostImpl, 123);
3090 gfx::PointF position(25, 25); // this layer is positioned, and hit testi ng should correctly know where the layer is located. 3126 gfx::PointF position(25, 25); // this layer is positioned, and hit testi ng should correctly know where the layer is located.
3091 gfx::Size bounds(50, 50); 3127 gfx::Size bounds(50, 50);
3092 setLayerPropertiesForTesting(clippingLayer.get(), identityMatrix, identi tyMatrix, anchor, position, bounds, false); 3128 setLayerPropertiesForTesting(clippingLayer.get(), identityMatrix, identi tyMatrix, anchor, position, bounds, false);
3093 clippingLayer->setMasksToBounds(true); 3129 clippingLayer->setMasksToBounds(true);
3094 3130
3095 scoped_ptr<LayerImpl> child = LayerImpl::create(456); 3131 scoped_ptr<LayerImpl> child = LayerImpl::create(&hostImpl, 456);
3096 position = gfx::PointF(-50, -50); 3132 position = gfx::PointF(-50, -50);
3097 bounds = gfx::Size(300, 300); 3133 bounds = gfx::Size(300, 300);
3098 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix , anchor, position, bounds, false); 3134 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix , anchor, position, bounds, false);
3099 child->setDrawsContent(true); 3135 child->setDrawsContent(true);
3100 clippingLayer->addChild(child.Pass()); 3136 clippingLayer->addChild(child.Pass());
3101 root->addChild(clippingLayer.Pass()); 3137 root->addChild(clippingLayer.Pass());
3102 } 3138 }
3103 3139
3104 std::vector<LayerImpl*> renderSurfaceLayerList; 3140 std::vector<LayerImpl*> renderSurfaceLayerList;
3105 int dummyMaxTextureSize = 512; 3141 int dummyMaxTextureSize = 512;
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
3138 // This test checks whether hit testing correctly avoids hit testing with mu ltiple 3174 // This test checks whether hit testing correctly avoids hit testing with mu ltiple
3139 // ancestors that clip in non axis-aligned ways. To pass this test, the hit testing 3175 // ancestors that clip in non axis-aligned ways. To pass this test, the hit testing
3140 // algorithm needs to recognize that multiple parent layers may clip the lay er, and 3176 // algorithm needs to recognize that multiple parent layers may clip the lay er, and
3141 // should not actually hit those clipped areas. 3177 // should not actually hit those clipped areas.
3142 // 3178 //
3143 // The child and grandChild layers are both initialized to clip the rotatedL eaf. The 3179 // The child and grandChild layers are both initialized to clip the rotatedL eaf. The
3144 // child layer is rotated about the top-left corner, so that the root + chil d clips 3180 // child layer is rotated about the top-left corner, so that the root + chil d clips
3145 // combined create a triangle. The rotatedLeaf will only be visible where it overlaps 3181 // combined create a triangle. The rotatedLeaf will only be visible where it overlaps
3146 // this triangle. 3182 // this triangle.
3147 // 3183 //
3148 scoped_ptr<LayerImpl> root = LayerImpl::create(123); 3184 FakeImplProxy proxy;
3185 FakeLayerTreeHostImpl hostImpl(&proxy);
3186 scoped_ptr<LayerImpl> root = LayerImpl::create(&hostImpl, 123);
3149 3187
3150 gfx::Transform identityMatrix; 3188 gfx::Transform identityMatrix;
3151 gfx::PointF anchor(0, 0); 3189 gfx::PointF anchor(0, 0);
3152 gfx::PointF position(0, 0); 3190 gfx::PointF position(0, 0);
3153 gfx::Size bounds(100, 100); 3191 gfx::Size bounds(100, 100);
3154 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc hor, position, bounds, false); 3192 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc hor, position, bounds, false);
3155 root->setMasksToBounds(true); 3193 root->setMasksToBounds(true);
3156 3194
3157 { 3195 {
3158 scoped_ptr<LayerImpl> child = LayerImpl::create(456); 3196 scoped_ptr<LayerImpl> child = LayerImpl::create(&hostImpl, 456);
3159 scoped_ptr<LayerImpl> grandChild = LayerImpl::create(789); 3197 scoped_ptr<LayerImpl> grandChild = LayerImpl::create(&hostImpl, 789);
3160 scoped_ptr<LayerImpl> rotatedLeaf = LayerImpl::create(2468); 3198 scoped_ptr<LayerImpl> rotatedLeaf = LayerImpl::create(&hostImpl, 2468);
3161 3199
3162 position = gfx::PointF(10, 10); 3200 position = gfx::PointF(10, 10);
3163 bounds = gfx::Size(80, 80); 3201 bounds = gfx::Size(80, 80);
3164 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix , anchor, position, bounds, false); 3202 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix , anchor, position, bounds, false);
3165 child->setMasksToBounds(true); 3203 child->setMasksToBounds(true);
3166 3204
3167 gfx::Transform rotation45DegreesAboutCorner; 3205 gfx::Transform rotation45DegreesAboutCorner;
3168 MathUtil::rotateEulerAngles(&rotation45DegreesAboutCorner, 0, 0, 45); 3206 MathUtil::rotateEulerAngles(&rotation45DegreesAboutCorner, 0, 0, 45);
3169 3207
3170 position = gfx::PointF(0, 0); // remember, positioned with respect to it s parent which is already at 10, 10 3208 position = gfx::PointF(0, 0); // remember, positioned with respect to it s parent which is already at 10, 10
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
3239 EXPECT_EQ(2468, resultLayer->id()); 3277 EXPECT_EQ(2468, resultLayer->id());
3240 } 3278 }
3241 3279
3242 TEST(LayerTreeHostCommonTest, verifyHitTestingForNonClippingIntermediateLayer) 3280 TEST(LayerTreeHostCommonTest, verifyHitTestingForNonClippingIntermediateLayer)
3243 { 3281 {
3244 // This test checks that hit testing code does not accidentally clip to laye r 3282 // This test checks that hit testing code does not accidentally clip to laye r
3245 // bounds for a layer that actually does not clip. 3283 // bounds for a layer that actually does not clip.
3246 gfx::Transform identityMatrix; 3284 gfx::Transform identityMatrix;
3247 gfx::PointF anchor(0, 0); 3285 gfx::PointF anchor(0, 0);
3248 3286
3249 scoped_ptr<LayerImpl> root = LayerImpl::create(1); 3287 FakeImplProxy proxy;
3288 FakeLayerTreeHostImpl hostImpl(&proxy);
3289 scoped_ptr<LayerImpl> root = LayerImpl::create(&hostImpl, 1);
3250 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc hor, gfx::PointF(0, 0), gfx::Size(100, 100), false); 3290 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc hor, gfx::PointF(0, 0), gfx::Size(100, 100), false);
3251 3291
3252 { 3292 {
3253 scoped_ptr<LayerImpl> intermediateLayer = LayerImpl::create(123); 3293 scoped_ptr<LayerImpl> intermediateLayer = LayerImpl::create(&hostImpl, 1 23);
3254 gfx::PointF position(10, 10); // this layer is positioned, and hit testi ng should correctly know where the layer is located. 3294 gfx::PointF position(10, 10); // this layer is positioned, and hit testi ng should correctly know where the layer is located.
3255 gfx::Size bounds(50, 50); 3295 gfx::Size bounds(50, 50);
3256 setLayerPropertiesForTesting(intermediateLayer.get(), identityMatrix, id entityMatrix, anchor, position, bounds, false); 3296 setLayerPropertiesForTesting(intermediateLayer.get(), identityMatrix, id entityMatrix, anchor, position, bounds, false);
3257 // Sanity check the intermediate layer should not clip. 3297 // Sanity check the intermediate layer should not clip.
3258 ASSERT_FALSE(intermediateLayer->masksToBounds()); 3298 ASSERT_FALSE(intermediateLayer->masksToBounds());
3259 ASSERT_FALSE(intermediateLayer->maskLayer()); 3299 ASSERT_FALSE(intermediateLayer->maskLayer());
3260 3300
3261 // The child of the intermediateLayer is translated so that it does not overlap intermediateLayer at all. 3301 // The child of the intermediateLayer is translated so that it does not overlap intermediateLayer at all.
3262 // If child is incorrectly clipped, we would not be able to hit it succe ssfully. 3302 // If child is incorrectly clipped, we would not be able to hit it succe ssfully.
3263 scoped_ptr<LayerImpl> child = LayerImpl::create(456); 3303 scoped_ptr<LayerImpl> child = LayerImpl::create(&hostImpl, 456);
3264 position = gfx::PointF(60, 60); // 70, 70 in screen space 3304 position = gfx::PointF(60, 60); // 70, 70 in screen space
3265 bounds = gfx::Size(20, 20); 3305 bounds = gfx::Size(20, 20);
3266 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix , anchor, position, bounds, false); 3306 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix , anchor, position, bounds, false);
3267 child->setDrawsContent(true); 3307 child->setDrawsContent(true);
3268 intermediateLayer->addChild(child.Pass()); 3308 intermediateLayer->addChild(child.Pass());
3269 root->addChild(intermediateLayer.Pass()); 3309 root->addChild(intermediateLayer.Pass());
3270 } 3310 }
3271 3311
3272 std::vector<LayerImpl*> renderSurfaceLayerList; 3312 std::vector<LayerImpl*> renderSurfaceLayerList;
3273 int dummyMaxTextureSize = 512; 3313 int dummyMaxTextureSize = 512;
(...skipping 21 matching lines...) Expand all
3295 3335
3296 testPoint = gfx::Point(89, 89); 3336 testPoint = gfx::Point(89, 89);
3297 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend erSurfaceLayerList); 3337 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend erSurfaceLayerList);
3298 ASSERT_TRUE(resultLayer); 3338 ASSERT_TRUE(resultLayer);
3299 EXPECT_EQ(456, resultLayer->id()); 3339 EXPECT_EQ(456, resultLayer->id());
3300 } 3340 }
3301 3341
3302 3342
3303 TEST(LayerTreeHostCommonTest, verifyHitTestingForMultipleLayers) 3343 TEST(LayerTreeHostCommonTest, verifyHitTestingForMultipleLayers)
3304 { 3344 {
3305 scoped_ptr<LayerImpl> root = LayerImpl::create(1); 3345 FakeImplProxy proxy;
3346 FakeLayerTreeHostImpl hostImpl(&proxy);
3347 scoped_ptr<LayerImpl> root = LayerImpl::create(&hostImpl, 1);
3306 3348
3307 gfx::Transform identityMatrix; 3349 gfx::Transform identityMatrix;
3308 gfx::PointF anchor(0, 0); 3350 gfx::PointF anchor(0, 0);
3309 gfx::PointF position(0, 0); 3351 gfx::PointF position(0, 0);
3310 gfx::Size bounds(100, 100); 3352 gfx::Size bounds(100, 100);
3311 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc hor, position, bounds, false); 3353 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc hor, position, bounds, false);
3312 root->setDrawsContent(true); 3354 root->setDrawsContent(true);
3313 3355
3314 { 3356 {
3315 // child 1 and child2 are initialized to overlap between x=50 and x=60. 3357 // child 1 and child2 are initialized to overlap between x=50 and x=60.
3316 // grandChild is set to overlap both child1 and child2 between y=50 and y=60. 3358 // grandChild is set to overlap both child1 and child2 between y=50 and y=60.
3317 // The expected stacking order is: 3359 // The expected stacking order is:
3318 // (front) child2, (second) grandChild, (third) child1, and (back) the root layer behind all other layers. 3360 // (front) child2, (second) grandChild, (third) child1, and (back) the root layer behind all other layers.
3319 3361
3320 scoped_ptr<LayerImpl> child1 = LayerImpl::create(2); 3362 scoped_ptr<LayerImpl> child1 = LayerImpl::create(&hostImpl, 2);
3321 scoped_ptr<LayerImpl> child2 = LayerImpl::create(3); 3363 scoped_ptr<LayerImpl> child2 = LayerImpl::create(&hostImpl, 3);
3322 scoped_ptr<LayerImpl> grandChild1 = LayerImpl::create(4); 3364 scoped_ptr<LayerImpl> grandChild1 = LayerImpl::create(&hostImpl, 4);
3323 3365
3324 position = gfx::PointF(10, 10); 3366 position = gfx::PointF(10, 10);
3325 bounds = gfx::Size(50, 50); 3367 bounds = gfx::Size(50, 50);
3326 setLayerPropertiesForTesting(child1.get(), identityMatrix, identityMatri x, anchor, position, bounds, false); 3368 setLayerPropertiesForTesting(child1.get(), identityMatrix, identityMatri x, anchor, position, bounds, false);
3327 child1->setDrawsContent(true); 3369 child1->setDrawsContent(true);
3328 3370
3329 position = gfx::PointF(50, 10); 3371 position = gfx::PointF(50, 10);
3330 bounds = gfx::Size(50, 50); 3372 bounds = gfx::Size(50, 50);
3331 setLayerPropertiesForTesting(child2.get(), identityMatrix, identityMatri x, anchor, position, bounds, false); 3373 setLayerPropertiesForTesting(child2.get(), identityMatrix, identityMatri x, anchor, position, bounds, false);
3332 child2->setDrawsContent(true); 3374 child2->setDrawsContent(true);
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
3398 ASSERT_TRUE(resultLayer); 3440 ASSERT_TRUE(resultLayer);
3399 EXPECT_EQ(4, resultLayer->id()); 3441 EXPECT_EQ(4, resultLayer->id());
3400 } 3442 }
3401 3443
3402 TEST(LayerTreeHostCommonTest, verifyHitTestingForMultipleLayerLists) 3444 TEST(LayerTreeHostCommonTest, verifyHitTestingForMultipleLayerLists)
3403 { 3445 {
3404 // 3446 //
3405 // The geometry is set up similarly to the previous case, but 3447 // The geometry is set up similarly to the previous case, but
3406 // all layers are forced to be renderSurfaces now. 3448 // all layers are forced to be renderSurfaces now.
3407 // 3449 //
3408 scoped_ptr<LayerImpl> root = LayerImpl::create(1); 3450 FakeImplProxy proxy;
3451 FakeLayerTreeHostImpl hostImpl(&proxy);
3452 scoped_ptr<LayerImpl> root = LayerImpl::create(&hostImpl, 1);
3409 3453
3410 gfx::Transform identityMatrix; 3454 gfx::Transform identityMatrix;
3411 gfx::PointF anchor(0, 0); 3455 gfx::PointF anchor(0, 0);
3412 gfx::PointF position(0, 0); 3456 gfx::PointF position(0, 0);
3413 gfx::Size bounds(100, 100); 3457 gfx::Size bounds(100, 100);
3414 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc hor, position, bounds, false); 3458 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc hor, position, bounds, false);
3415 root->setDrawsContent(true); 3459 root->setDrawsContent(true);
3416 3460
3417 { 3461 {
3418 // child 1 and child2 are initialized to overlap between x=50 and x=60. 3462 // child 1 and child2 are initialized to overlap between x=50 and x=60.
3419 // grandChild is set to overlap both child1 and child2 between y=50 and y=60. 3463 // grandChild is set to overlap both child1 and child2 between y=50 and y=60.
3420 // The expected stacking order is: 3464 // The expected stacking order is:
3421 // (front) child2, (second) grandChild, (third) child1, and (back) the root layer behind all other layers. 3465 // (front) child2, (second) grandChild, (third) child1, and (back) the root layer behind all other layers.
3422 3466
3423 scoped_ptr<LayerImpl> child1 = LayerImpl::create(2); 3467 scoped_ptr<LayerImpl> child1 = LayerImpl::create(&hostImpl, 2);
3424 scoped_ptr<LayerImpl> child2 = LayerImpl::create(3); 3468 scoped_ptr<LayerImpl> child2 = LayerImpl::create(&hostImpl, 3);
3425 scoped_ptr<LayerImpl> grandChild1 = LayerImpl::create(4); 3469 scoped_ptr<LayerImpl> grandChild1 = LayerImpl::create(&hostImpl, 4);
3426 3470
3427 position = gfx::PointF(10, 10); 3471 position = gfx::PointF(10, 10);
3428 bounds = gfx::Size(50, 50); 3472 bounds = gfx::Size(50, 50);
3429 setLayerPropertiesForTesting(child1.get(), identityMatrix, identityMatri x, anchor, position, bounds, false); 3473 setLayerPropertiesForTesting(child1.get(), identityMatrix, identityMatri x, anchor, position, bounds, false);
3430 child1->setDrawsContent(true); 3474 child1->setDrawsContent(true);
3431 child1->setForceRenderSurface(true); 3475 child1->setForceRenderSurface(true);
3432 3476
3433 position = gfx::PointF(50, 10); 3477 position = gfx::PointF(50, 10);
3434 bounds = gfx::Size(50, 50); 3478 bounds = gfx::Size(50, 50);
3435 setLayerPropertiesForTesting(child2.get(), identityMatrix, identityMatri x, anchor, position, bounds, false); 3479 setLayerPropertiesForTesting(child2.get(), identityMatrix, identityMatri x, anchor, position, bounds, false);
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
3520 LayerImpl* resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPointInTou chHandlerRegion(testPoint, renderSurfaceLayerList); 3564 LayerImpl* resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPointInTou chHandlerRegion(testPoint, renderSurfaceLayerList);
3521 EXPECT_FALSE(resultLayer); 3565 EXPECT_FALSE(resultLayer);
3522 3566
3523 testPoint = gfx::Point(10, 20); 3567 testPoint = gfx::Point(10, 20);
3524 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPointInTouchHandlerRe gion(testPoint, renderSurfaceLayerList); 3568 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPointInTouchHandlerRe gion(testPoint, renderSurfaceLayerList);
3525 EXPECT_FALSE(resultLayer); 3569 EXPECT_FALSE(resultLayer);
3526 } 3570 }
3527 3571
3528 TEST(LayerTreeHostCommonTest, verifyHitCheckingTouchHandlerRegionsForSingleLayer ) 3572 TEST(LayerTreeHostCommonTest, verifyHitCheckingTouchHandlerRegionsForSingleLayer )
3529 { 3573 {
3530 scoped_ptr<LayerImpl> root = LayerImpl::create(12345); 3574 FakeImplProxy proxy;
3575 FakeLayerTreeHostImpl hostImpl(&proxy);
3576 scoped_ptr<LayerImpl> root = LayerImpl::create(&hostImpl, 12345);
3531 3577
3532 gfx::Transform identityMatrix; 3578 gfx::Transform identityMatrix;
3533 Region touchHandlerRegion(gfx::Rect(10, 10, 50, 50)); 3579 Region touchHandlerRegion(gfx::Rect(10, 10, 50, 50));
3534 gfx::PointF anchor(0, 0); 3580 gfx::PointF anchor(0, 0);
3535 gfx::PointF position(0, 0); 3581 gfx::PointF position(0, 0);
3536 gfx::Size bounds(100, 100); 3582 gfx::Size bounds(100, 100);
3537 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc hor, position, bounds, false); 3583 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc hor, position, bounds, false);
3538 root->setDrawsContent(true); 3584 root->setDrawsContent(true);
3539 3585
3540 std::vector<LayerImpl*> renderSurfaceLayerList; 3586 std::vector<LayerImpl*> renderSurfaceLayerList;
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
3576 EXPECT_EQ(12345, resultLayer->id()); 3622 EXPECT_EQ(12345, resultLayer->id());
3577 3623
3578 testPoint = gfx::Point(59, 59); 3624 testPoint = gfx::Point(59, 59);
3579 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPointInTouchHandlerRe gion(testPoint, renderSurfaceLayerList); 3625 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPointInTouchHandlerRe gion(testPoint, renderSurfaceLayerList);
3580 ASSERT_TRUE(resultLayer); 3626 ASSERT_TRUE(resultLayer);
3581 EXPECT_EQ(12345, resultLayer->id()); 3627 EXPECT_EQ(12345, resultLayer->id());
3582 } 3628 }
3583 3629
3584 TEST(LayerTreeHostCommonTest, verifyHitCheckingTouchHandlerRegionsForUninvertibl eTransform) 3630 TEST(LayerTreeHostCommonTest, verifyHitCheckingTouchHandlerRegionsForUninvertibl eTransform)
3585 { 3631 {
3586 scoped_ptr<LayerImpl> root = LayerImpl::create(12345); 3632 FakeImplProxy proxy;
3633 FakeLayerTreeHostImpl hostImpl(&proxy);
3634 scoped_ptr<LayerImpl> root = LayerImpl::create(&hostImpl, 12345);
3587 3635
3588 gfx::Transform uninvertibleTransform; 3636 gfx::Transform uninvertibleTransform;
3589 uninvertibleTransform.matrix().setDouble(0, 0, 0); 3637 uninvertibleTransform.matrix().setDouble(0, 0, 0);
3590 uninvertibleTransform.matrix().setDouble(1, 1, 0); 3638 uninvertibleTransform.matrix().setDouble(1, 1, 0);
3591 uninvertibleTransform.matrix().setDouble(2, 2, 0); 3639 uninvertibleTransform.matrix().setDouble(2, 2, 0);
3592 uninvertibleTransform.matrix().setDouble(3, 3, 0); 3640 uninvertibleTransform.matrix().setDouble(3, 3, 0);
3593 ASSERT_FALSE(uninvertibleTransform.IsInvertible()); 3641 ASSERT_FALSE(uninvertibleTransform.IsInvertible());
3594 3642
3595 gfx::Transform identityMatrix; 3643 gfx::Transform identityMatrix;
3596 Region touchHandlerRegion(gfx::Rect(10, 10, 50, 50)); 3644 Region touchHandlerRegion(gfx::Rect(10, 10, 50, 50));
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
3637 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPointInTouchHandlerRe gion(testPoint, renderSurfaceLayerList); 3685 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPointInTouchHandlerRe gion(testPoint, renderSurfaceLayerList);
3638 EXPECT_FALSE(resultLayer); 3686 EXPECT_FALSE(resultLayer);
3639 3687
3640 testPoint = gfx::Point(-1, -1); 3688 testPoint = gfx::Point(-1, -1);
3641 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPointInTouchHandlerRe gion(testPoint, renderSurfaceLayerList); 3689 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPointInTouchHandlerRe gion(testPoint, renderSurfaceLayerList);
3642 EXPECT_FALSE(resultLayer); 3690 EXPECT_FALSE(resultLayer);
3643 } 3691 }
3644 3692
3645 TEST(LayerTreeHostCommonTest, verifyHitCheckingTouchHandlerRegionsForSinglePosit ionedLayer) 3693 TEST(LayerTreeHostCommonTest, verifyHitCheckingTouchHandlerRegionsForSinglePosit ionedLayer)
3646 { 3694 {
3647 scoped_ptr<LayerImpl> root = LayerImpl::create(12345); 3695 FakeImplProxy proxy;
3696 FakeLayerTreeHostImpl hostImpl(&proxy);
3697 scoped_ptr<LayerImpl> root = LayerImpl::create(&hostImpl, 12345);
3648 3698
3649 gfx::Transform identityMatrix; 3699 gfx::Transform identityMatrix;
3650 Region touchHandlerRegion(gfx::Rect(10, 10, 50, 50)); 3700 Region touchHandlerRegion(gfx::Rect(10, 10, 50, 50));
3651 gfx::PointF anchor(0, 0); 3701 gfx::PointF anchor(0, 0);
3652 gfx::PointF position(50, 50); // this layer is positioned, and hit testing s hould correctly know where the layer is located. 3702 gfx::PointF position(50, 50); // this layer is positioned, and hit testing s hould correctly know where the layer is located.
3653 gfx::Size bounds(100, 100); 3703 gfx::Size bounds(100, 100);
3654 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc hor, position, bounds, false); 3704 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc hor, position, bounds, false);
3655 root->setDrawsContent(true); 3705 root->setDrawsContent(true);
3656 root->setTouchEventHandlerRegion(touchHandlerRegion); 3706 root->setTouchEventHandlerRegion(touchHandlerRegion);
3657 3707
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
3695 // A layer's visibleContentRect is actually in the layer's content space. Th e 3745 // A layer's visibleContentRect is actually in the layer's content space. Th e
3696 // screenSpaceTransform converts from the layer's origin space to screen spa ce. This 3746 // screenSpaceTransform converts from the layer's origin space to screen spa ce. This
3697 // test makes sure that hit testing works correctly accounts for the content s scale. 3747 // test makes sure that hit testing works correctly accounts for the content s scale.
3698 // A contentsScale that is not 1 effectively forces a non-identity transform between 3748 // A contentsScale that is not 1 effectively forces a non-identity transform between
3699 // layer's content space and layer's origin space. The hit testing code must take this into account. 3749 // layer's content space and layer's origin space. The hit testing code must take this into account.
3700 // 3750 //
3701 // To test this, the layer is positioned at (25, 25), and is size (50, 50). If 3751 // To test this, the layer is positioned at (25, 25), and is size (50, 50). If
3702 // contentsScale is ignored, then hit checking will mis-interpret the visibl eContentRect 3752 // contentsScale is ignored, then hit checking will mis-interpret the visibl eContentRect
3703 // as being larger than the actual bounds of the layer. 3753 // as being larger than the actual bounds of the layer.
3704 // 3754 //
3705 scoped_ptr<LayerImpl> root = LayerImpl::create(1); 3755 FakeImplProxy proxy;
3756 FakeLayerTreeHostImpl hostImpl(&proxy);
3757 scoped_ptr<LayerImpl> root = LayerImpl::create(&hostImpl, 1);
3706 3758
3707 gfx::Transform identityMatrix; 3759 gfx::Transform identityMatrix;
3708 gfx::PointF anchor(0, 0); 3760 gfx::PointF anchor(0, 0);
3709 3761
3710 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc hor, gfx::PointF(0, 0), gfx::Size(100, 100), false); 3762 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc hor, gfx::PointF(0, 0), gfx::Size(100, 100), false);
3711 3763
3712 { 3764 {
3713 Region touchHandlerRegion(gfx::Rect(10, 10, 30, 30)); 3765 Region touchHandlerRegion(gfx::Rect(10, 10, 30, 30));
3714 gfx::PointF position(25, 25); 3766 gfx::PointF position(25, 25);
3715 gfx::Size bounds(50, 50); 3767 gfx::Size bounds(50, 50);
3716 scoped_ptr<LayerImpl> testLayer = LayerImpl::create(12345); 3768 scoped_ptr<LayerImpl> testLayer = LayerImpl::create(&hostImpl, 12345);
3717 setLayerPropertiesForTesting(testLayer.get(), identityMatrix, identityMa trix, anchor, position, bounds, false); 3769 setLayerPropertiesForTesting(testLayer.get(), identityMatrix, identityMa trix, anchor, position, bounds, false);
3718 3770
3719 // override contentBounds and contentsScale 3771 // override contentBounds and contentsScale
3720 testLayer->setContentBounds(gfx::Size(100, 100)); 3772 testLayer->setContentBounds(gfx::Size(100, 100));
3721 testLayer->setContentsScale(2, 2); 3773 testLayer->setContentsScale(2, 2);
3722 3774
3723 testLayer->setDrawsContent(true); 3775 testLayer->setDrawsContent(true);
3724 testLayer->setTouchEventHandlerRegion(touchHandlerRegion); 3776 testLayer->setTouchEventHandlerRegion(touchHandlerRegion);
3725 root->addChild(testLayer.Pass()); 3777 root->addChild(testLayer.Pass());
3726 } 3778 }
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
3767 testPoint = gfx::Point(64, 64); 3819 testPoint = gfx::Point(64, 64);
3768 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPointInTouchHandlerRe gion(testPoint, renderSurfaceLayerList); 3820 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPointInTouchHandlerRe gion(testPoint, renderSurfaceLayerList);
3769 ASSERT_TRUE(resultLayer); 3821 ASSERT_TRUE(resultLayer);
3770 EXPECT_EQ(12345, resultLayer->id()); 3822 EXPECT_EQ(12345, resultLayer->id());
3771 } 3823 }
3772 3824
3773 TEST(LayerTreeHostCommonTest, verifyHitCheckingTouchHandlerRegionsForSingleLayer WithDeviceScale) 3825 TEST(LayerTreeHostCommonTest, verifyHitCheckingTouchHandlerRegionsForSingleLayer WithDeviceScale)
3774 { 3826 {
3775 // The layer's deviceScalefactor and pageScaleFactor should scale the conten tRect and we should 3827 // The layer's deviceScalefactor and pageScaleFactor should scale the conten tRect and we should
3776 // be able to hit the touch handler region by scaling the points accordingly . 3828 // be able to hit the touch handler region by scaling the points accordingly .
3777 scoped_ptr<LayerImpl> root = LayerImpl::create(1); 3829 FakeImplProxy proxy;
3830 FakeLayerTreeHostImpl hostImpl(&proxy);
3831 scoped_ptr<LayerImpl> root = LayerImpl::create(&hostImpl, 1);
3778 3832
3779 gfx::Transform identityMatrix; 3833 gfx::Transform identityMatrix;
3780 gfx::PointF anchor(0, 0); 3834 gfx::PointF anchor(0, 0);
3781 // Set the bounds of the root layer big enough to fit the child when scaled. 3835 // Set the bounds of the root layer big enough to fit the child when scaled.
3782 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc hor, gfx::PointF(0, 0), gfx::Size(100, 100), false); 3836 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc hor, gfx::PointF(0, 0), gfx::Size(100, 100), false);
3783 3837
3784 { 3838 {
3785 Region touchHandlerRegion(gfx::Rect(10, 10, 30, 30)); 3839 Region touchHandlerRegion(gfx::Rect(10, 10, 30, 30));
3786 gfx::PointF position(25, 25); 3840 gfx::PointF position(25, 25);
3787 gfx::Size bounds(50, 50); 3841 gfx::Size bounds(50, 50);
3788 scoped_ptr<LayerImpl> testLayer = LayerImpl::create(12345); 3842 scoped_ptr<LayerImpl> testLayer = LayerImpl::create(&hostImpl, 12345);
3789 setLayerPropertiesForTesting(testLayer.get(), identityMatrix, identityMa trix, anchor, position, bounds, false); 3843 setLayerPropertiesForTesting(testLayer.get(), identityMatrix, identityMa trix, anchor, position, bounds, false);
3790 3844
3791 testLayer->setDrawsContent(true); 3845 testLayer->setDrawsContent(true);
3792 testLayer->setTouchEventHandlerRegion(touchHandlerRegion); 3846 testLayer->setTouchEventHandlerRegion(touchHandlerRegion);
3793 root->addChild(testLayer.Pass()); 3847 root->addChild(testLayer.Pass());
3794 } 3848 }
3795 3849
3796 std::vector<LayerImpl*> renderSurfaceLayerList; 3850 std::vector<LayerImpl*> renderSurfaceLayerList;
3797 int dummyMaxTextureSize = 512; 3851 int dummyMaxTextureSize = 512;
3798 float deviceScaleFactor = 3.0f; 3852 float deviceScaleFactor = 3.0f;
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
3853 EXPECT_EQ(12345, resultLayer->id()); 3907 EXPECT_EQ(12345, resultLayer->id());
3854 } 3908 }
3855 3909
3856 TEST(LayerTreeHostCommonTest, verifyHitCheckingTouchHandlerRegionsForSimpleClipp edLayer) 3910 TEST(LayerTreeHostCommonTest, verifyHitCheckingTouchHandlerRegionsForSimpleClipp edLayer)
3857 { 3911 {
3858 // Test that hit-checking will only work for the visible portion of a layer, and not 3912 // Test that hit-checking will only work for the visible portion of a layer, and not
3859 // the entire layer bounds. Here we just test the simple axis-aligned case. 3913 // the entire layer bounds. Here we just test the simple axis-aligned case.
3860 gfx::Transform identityMatrix; 3914 gfx::Transform identityMatrix;
3861 gfx::PointF anchor(0, 0); 3915 gfx::PointF anchor(0, 0);
3862 3916
3863 scoped_ptr<LayerImpl> root = LayerImpl::create(1); 3917 FakeImplProxy proxy;
3918 FakeLayerTreeHostImpl hostImpl(&proxy);
3919 scoped_ptr<LayerImpl> root = LayerImpl::create(&hostImpl, 1);
3864 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc hor, gfx::PointF(0, 0), gfx::Size(100, 100), false); 3920 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc hor, gfx::PointF(0, 0), gfx::Size(100, 100), false);
3865 3921
3866 { 3922 {
3867 scoped_ptr<LayerImpl> clippingLayer = LayerImpl::create(123); 3923 scoped_ptr<LayerImpl> clippingLayer = LayerImpl::create(&hostImpl, 123);
3868 gfx::PointF position(25, 25); // this layer is positioned, and hit testi ng should correctly know where the layer is located. 3924 gfx::PointF position(25, 25); // this layer is positioned, and hit testi ng should correctly know where the layer is located.
3869 gfx::Size bounds(50, 50); 3925 gfx::Size bounds(50, 50);
3870 setLayerPropertiesForTesting(clippingLayer.get(), identityMatrix, identi tyMatrix, anchor, position, bounds, false); 3926 setLayerPropertiesForTesting(clippingLayer.get(), identityMatrix, identi tyMatrix, anchor, position, bounds, false);
3871 clippingLayer->setMasksToBounds(true); 3927 clippingLayer->setMasksToBounds(true);
3872 3928
3873 scoped_ptr<LayerImpl> child = LayerImpl::create(456); 3929 scoped_ptr<LayerImpl> child = LayerImpl::create(&hostImpl, 456);
3874 Region touchHandlerRegion(gfx::Rect(10, 10, 50, 50)); 3930 Region touchHandlerRegion(gfx::Rect(10, 10, 50, 50));
3875 position = gfx::PointF(-50, -50); 3931 position = gfx::PointF(-50, -50);
3876 bounds = gfx::Size(300, 300); 3932 bounds = gfx::Size(300, 300);
3877 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix , anchor, position, bounds, false); 3933 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix , anchor, position, bounds, false);
3878 child->setDrawsContent(true); 3934 child->setDrawsContent(true);
3879 child->setTouchEventHandlerRegion(touchHandlerRegion); 3935 child->setTouchEventHandlerRegion(touchHandlerRegion);
3880 clippingLayer->addChild(child.Pass()); 3936 clippingLayer->addChild(child.Pass());
3881 root->addChild(clippingLayer.Pass()); 3937 root->addChild(clippingLayer.Pass());
3882 } 3938 }
3883 3939
(...skipping 749 matching lines...) Expand 10 before | Expand all | Expand 10 after
4633 child->addChild(grandChild); 4689 child->addChild(grandChild);
4634 child->setOpacity(0.5f); 4690 child->setOpacity(0.5f);
4635 4691
4636 executeCalculateDrawProperties(root.get()); 4692 executeCalculateDrawProperties(root.get());
4637 4693
4638 EXPECT_FALSE(child->renderSurface()); 4694 EXPECT_FALSE(child->renderSurface());
4639 } 4695 }
4640 4696
4641 } // namespace 4697 } // namespace
4642 } // namespace cc 4698 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layer_sorter_unittest.cc ('k') | cc/layer_tree_host_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698