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

Side by Side Diff: cc/layer_tree_host_common_unittest.cc

Issue 11519018: [cc] Make LayerImpls point at LayerTreeImpl instead of LTHI (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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
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"
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 int dummyMaxTextureSize = 512; 70 int dummyMaxTextureSize = 512;
71 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);
72 72
73 // 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.
74 DCHECK(!rootLayer->bounds().IsEmpty()); 74 DCHECK(!rootLayer->bounds().IsEmpty());
75 LayerTreeHostCommon::calculateDrawProperties(rootLayer, deviceViewportSize, deviceScaleFactor, pageScaleFactor, dummyMaxTextureSize, dummyRenderSurfaceLayer List); 75 LayerTreeHostCommon::calculateDrawProperties(rootLayer, deviceViewportSize, deviceScaleFactor, pageScaleFactor, dummyMaxTextureSize, dummyRenderSurfaceLayer List);
76 } 76 }
77 77
78 scoped_ptr<LayerImpl> createTreeForFixedPositionTests(LayerTreeHostImpl* hostImp l) 78 scoped_ptr<LayerImpl> createTreeForFixedPositionTests(LayerTreeHostImpl* hostImp l)
79 { 79 {
80 scoped_ptr<LayerImpl> root = LayerImpl::create(hostImpl, 1); 80 scoped_ptr<LayerImpl> root = LayerImpl::create(hostImpl->activeTree(), 1);
81 scoped_ptr<LayerImpl> child = LayerImpl::create(hostImpl, 2); 81 scoped_ptr<LayerImpl> child = LayerImpl::create(hostImpl->activeTree(), 2);
82 scoped_ptr<LayerImpl> grandChild = LayerImpl::create(hostImpl, 3); 82 scoped_ptr<LayerImpl> grandChild = LayerImpl::create(hostImpl->activeTree(), 3);
83 scoped_ptr<LayerImpl> greatGrandChild = LayerImpl::create(hostImpl, 4); 83 scoped_ptr<LayerImpl> greatGrandChild = LayerImpl::create(hostImpl->activeTr ee(), 4);
84 84
85 gfx::Transform IdentityMatrix; 85 gfx::Transform IdentityMatrix;
86 gfx::PointF anchor(0, 0); 86 gfx::PointF anchor(0, 0);
87 gfx::PointF position(0, 0); 87 gfx::PointF position(0, 0);
88 gfx::Size bounds(100, 100); 88 gfx::Size bounds(100, 100);
89 setLayerPropertiesForTesting(root.get(), IdentityMatrix, IdentityMatrix, anc hor, position, bounds, false); 89 setLayerPropertiesForTesting(root.get(), IdentityMatrix, IdentityMatrix, anc hor, position, bounds, false);
90 setLayerPropertiesForTesting(child.get(), IdentityMatrix, IdentityMatrix, an chor, position, bounds, false); 90 setLayerPropertiesForTesting(child.get(), IdentityMatrix, IdentityMatrix, an chor, position, bounds, false);
91 setLayerPropertiesForTesting(grandChild.get(), IdentityMatrix, IdentityMatri x, anchor, position, bounds, false); 91 setLayerPropertiesForTesting(grandChild.get(), IdentityMatrix, IdentityMatri x, anchor, position, bounds, false);
92 setLayerPropertiesForTesting(greatGrandChild.get(), IdentityMatrix, Identity Matrix, anchor, position, bounds, false); 92 setLayerPropertiesForTesting(greatGrandChild.get(), IdentityMatrix, Identity Matrix, anchor, position, bounds, false);
93 93
(...skipping 1011 matching lines...) Expand 10 before | Expand all | Expand 10 after
1105 FakeImplProxy proxy; 1105 FakeImplProxy proxy;
1106 FakeLayerTreeHostImpl hostImpl(&proxy); 1106 FakeLayerTreeHostImpl hostImpl(&proxy);
1107 scoped_ptr<LayerImpl> root = createTreeForFixedPositionTests(&hostImpl); 1107 scoped_ptr<LayerImpl> root = createTreeForFixedPositionTests(&hostImpl);
1108 LayerImpl* child = root->children()[0]; 1108 LayerImpl* child = root->children()[0];
1109 LayerImpl* grandChild = child->children()[0]; 1109 LayerImpl* grandChild = child->children()[0];
1110 LayerImpl* greatGrandChild = grandChild->children()[0]; 1110 LayerImpl* greatGrandChild = grandChild->children()[0];
1111 1111
1112 // Add one more layer to the test tree for this scenario. 1112 // Add one more layer to the test tree for this scenario.
1113 { 1113 {
1114 gfx::Transform identity; 1114 gfx::Transform identity;
1115 scoped_ptr<LayerImpl> fixedPositionChild = LayerImpl::create(&hostImpl, 5); 1115 scoped_ptr<LayerImpl> fixedPositionChild = LayerImpl::create(hostImpl.ac tiveTree(), 5);
1116 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);
1117 greatGrandChild->addChild(fixedPositionChild.Pass()); 1117 greatGrandChild->addChild(fixedPositionChild.Pass());
1118 } 1118 }
1119 LayerImpl* fixedPositionChild = greatGrandChild->children()[0]; 1119 LayerImpl* fixedPositionChild = greatGrandChild->children()[0];
1120 1120
1121 // Actually set up the scenario here. 1121 // Actually set up the scenario here.
1122 child->setIsContainerForFixedPositionLayers(true); 1122 child->setIsContainerForFixedPositionLayers(true);
1123 grandChild->setPosition(gfx::PointF(8, 6)); 1123 grandChild->setPosition(gfx::PointF(8, 6));
1124 grandChild->setForceRenderSurface(true); 1124 grandChild->setForceRenderSurface(true);
1125 greatGrandChild->setPosition(gfx::PointF(40, 60)); 1125 greatGrandChild->setPosition(gfx::PointF(40, 60));
(...skipping 1660 matching lines...) Expand 10 before | Expand all | Expand 10 after
2786 2786
2787 testPoint = gfx::Point(10, 20); 2787 testPoint = gfx::Point(10, 20);
2788 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend erSurfaceLayerList); 2788 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend erSurfaceLayerList);
2789 EXPECT_FALSE(resultLayer); 2789 EXPECT_FALSE(resultLayer);
2790 } 2790 }
2791 2791
2792 TEST(LayerTreeHostCommonTest, verifyHitTestingForSingleLayer) 2792 TEST(LayerTreeHostCommonTest, verifyHitTestingForSingleLayer)
2793 { 2793 {
2794 FakeImplProxy proxy; 2794 FakeImplProxy proxy;
2795 FakeLayerTreeHostImpl hostImpl(&proxy); 2795 FakeLayerTreeHostImpl hostImpl(&proxy);
2796 scoped_ptr<LayerImpl> root = LayerImpl::create(&hostImpl, 12345); 2796 scoped_ptr<LayerImpl> root = LayerImpl::create(hostImpl.activeTree(), 12345) ;
2797 2797
2798 gfx::Transform identityMatrix; 2798 gfx::Transform identityMatrix;
2799 gfx::PointF anchor(0, 0); 2799 gfx::PointF anchor(0, 0);
2800 gfx::PointF position(0, 0); 2800 gfx::PointF position(0, 0);
2801 gfx::Size bounds(100, 100); 2801 gfx::Size bounds(100, 100);
2802 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc hor, position, bounds, false); 2802 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc hor, position, bounds, false);
2803 root->setDrawsContent(true); 2803 root->setDrawsContent(true);
2804 2804
2805 std::vector<LayerImpl*> renderSurfaceLayerList; 2805 std::vector<LayerImpl*> renderSurfaceLayerList;
2806 int dummyMaxTextureSize = 512; 2806 int dummyMaxTextureSize = 512;
(...skipping 21 matching lines...) Expand all
2828 testPoint = gfx::Point(99, 99); 2828 testPoint = gfx::Point(99, 99);
2829 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend erSurfaceLayerList); 2829 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend erSurfaceLayerList);
2830 ASSERT_TRUE(resultLayer); 2830 ASSERT_TRUE(resultLayer);
2831 EXPECT_EQ(12345, resultLayer->id()); 2831 EXPECT_EQ(12345, resultLayer->id());
2832 } 2832 }
2833 2833
2834 TEST(LayerTreeHostCommonTest, verifyHitTestingForUninvertibleTransform) 2834 TEST(LayerTreeHostCommonTest, verifyHitTestingForUninvertibleTransform)
2835 { 2835 {
2836 FakeImplProxy proxy; 2836 FakeImplProxy proxy;
2837 FakeLayerTreeHostImpl hostImpl(&proxy); 2837 FakeLayerTreeHostImpl hostImpl(&proxy);
2838 scoped_ptr<LayerImpl> root = LayerImpl::create(&hostImpl, 12345); 2838 scoped_ptr<LayerImpl> root = LayerImpl::create(hostImpl.activeTree(), 12345) ;
2839 2839
2840 gfx::Transform uninvertibleTransform; 2840 gfx::Transform uninvertibleTransform;
2841 uninvertibleTransform.matrix().setDouble(0, 0, 0); 2841 uninvertibleTransform.matrix().setDouble(0, 0, 0);
2842 uninvertibleTransform.matrix().setDouble(1, 1, 0); 2842 uninvertibleTransform.matrix().setDouble(1, 1, 0);
2843 uninvertibleTransform.matrix().setDouble(2, 2, 0); 2843 uninvertibleTransform.matrix().setDouble(2, 2, 0);
2844 uninvertibleTransform.matrix().setDouble(3, 3, 0); 2844 uninvertibleTransform.matrix().setDouble(3, 3, 0);
2845 ASSERT_FALSE(uninvertibleTransform.IsInvertible()); 2845 ASSERT_FALSE(uninvertibleTransform.IsInvertible());
2846 2846
2847 gfx::Transform identityMatrix; 2847 gfx::Transform identityMatrix;
2848 gfx::PointF anchor(0, 0); 2848 gfx::PointF anchor(0, 0);
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
2889 2889
2890 testPoint = gfx::Point(-1, -1); 2890 testPoint = gfx::Point(-1, -1);
2891 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend erSurfaceLayerList); 2891 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend erSurfaceLayerList);
2892 EXPECT_FALSE(resultLayer); 2892 EXPECT_FALSE(resultLayer);
2893 } 2893 }
2894 2894
2895 TEST(LayerTreeHostCommonTest, verifyHitTestingForSinglePositionedLayer) 2895 TEST(LayerTreeHostCommonTest, verifyHitTestingForSinglePositionedLayer)
2896 { 2896 {
2897 FakeImplProxy proxy; 2897 FakeImplProxy proxy;
2898 FakeLayerTreeHostImpl hostImpl(&proxy); 2898 FakeLayerTreeHostImpl hostImpl(&proxy);
2899 scoped_ptr<LayerImpl> root = LayerImpl::create(&hostImpl, 12345); 2899 scoped_ptr<LayerImpl> root = LayerImpl::create(hostImpl.activeTree(), 12345) ;
2900 2900
2901 gfx::Transform identityMatrix; 2901 gfx::Transform identityMatrix;
2902 gfx::PointF anchor(0, 0); 2902 gfx::PointF anchor(0, 0);
2903 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.
2904 gfx::Size bounds(100, 100); 2904 gfx::Size bounds(100, 100);
2905 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc hor, position, bounds, false); 2905 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc hor, position, bounds, false);
2906 root->setDrawsContent(true); 2906 root->setDrawsContent(true);
2907 2907
2908 std::vector<LayerImpl*> renderSurfaceLayerList; 2908 std::vector<LayerImpl*> renderSurfaceLayerList;
2909 int dummyMaxTextureSize = 512; 2909 int dummyMaxTextureSize = 512;
(...skipping 22 matching lines...) Expand all
2932 testPoint = gfx::Point(99, 99); 2932 testPoint = gfx::Point(99, 99);
2933 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend erSurfaceLayerList); 2933 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend erSurfaceLayerList);
2934 ASSERT_TRUE(resultLayer); 2934 ASSERT_TRUE(resultLayer);
2935 EXPECT_EQ(12345, resultLayer->id()); 2935 EXPECT_EQ(12345, resultLayer->id());
2936 } 2936 }
2937 2937
2938 TEST(LayerTreeHostCommonTest, verifyHitTestingForSingleRotatedLayer) 2938 TEST(LayerTreeHostCommonTest, verifyHitTestingForSingleRotatedLayer)
2939 { 2939 {
2940 FakeImplProxy proxy; 2940 FakeImplProxy proxy;
2941 FakeLayerTreeHostImpl hostImpl(&proxy); 2941 FakeLayerTreeHostImpl hostImpl(&proxy);
2942 scoped_ptr<LayerImpl> root = LayerImpl::create(&hostImpl, 12345); 2942 scoped_ptr<LayerImpl> root = LayerImpl::create(hostImpl.activeTree(), 12345) ;
2943 2943
2944 gfx::Transform identityMatrix; 2944 gfx::Transform identityMatrix;
2945 gfx::Transform rotation45DegreesAboutCenter; 2945 gfx::Transform rotation45DegreesAboutCenter;
2946 rotation45DegreesAboutCenter.Translate(50, 50); 2946 rotation45DegreesAboutCenter.Translate(50, 50);
2947 MathUtil::rotateEulerAngles(&rotation45DegreesAboutCenter, 0, 0, 45); 2947 MathUtil::rotateEulerAngles(&rotation45DegreesAboutCenter, 0, 0, 45);
2948 rotation45DegreesAboutCenter.Translate(-50, -50); 2948 rotation45DegreesAboutCenter.Translate(-50, -50);
2949 gfx::PointF anchor(0, 0); 2949 gfx::PointF anchor(0, 0);
2950 gfx::PointF position(0, 0); 2950 gfx::PointF position(0, 0);
2951 gfx::Size bounds(100, 100); 2951 gfx::Size bounds(100, 100);
2952 setLayerPropertiesForTesting(root.get(), rotation45DegreesAboutCenter, ident ityMatrix, anchor, position, bounds, false); 2952 setLayerPropertiesForTesting(root.get(), rotation45DegreesAboutCenter, ident ityMatrix, anchor, position, bounds, false);
(...skipping 30 matching lines...) Expand all
2983 2983
2984 testPoint = gfx::Point(-1, 50); 2984 testPoint = gfx::Point(-1, 50);
2985 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend erSurfaceLayerList); 2985 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend erSurfaceLayerList);
2986 ASSERT_FALSE(resultLayer); 2986 ASSERT_FALSE(resultLayer);
2987 } 2987 }
2988 2988
2989 TEST(LayerTreeHostCommonTest, verifyHitTestingForSinglePerspectiveLayer) 2989 TEST(LayerTreeHostCommonTest, verifyHitTestingForSinglePerspectiveLayer)
2990 { 2990 {
2991 FakeImplProxy proxy; 2991 FakeImplProxy proxy;
2992 FakeLayerTreeHostImpl hostImpl(&proxy); 2992 FakeLayerTreeHostImpl hostImpl(&proxy);
2993 scoped_ptr<LayerImpl> root = LayerImpl::create(&hostImpl, 12345); 2993 scoped_ptr<LayerImpl> root = LayerImpl::create(hostImpl.activeTree(), 12345) ;
2994 2994
2995 gfx::Transform identityMatrix; 2995 gfx::Transform identityMatrix;
2996 2996
2997 // 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).
2998 gfx::Transform perspectiveProjectionAboutCenter; 2998 gfx::Transform perspectiveProjectionAboutCenter;
2999 perspectiveProjectionAboutCenter.Translate(50, 50); 2999 perspectiveProjectionAboutCenter.Translate(50, 50);
3000 perspectiveProjectionAboutCenter.ApplyPerspectiveDepth(1); 3000 perspectiveProjectionAboutCenter.ApplyPerspectiveDepth(1);
3001 perspectiveProjectionAboutCenter.Translate(-50, -50); 3001 perspectiveProjectionAboutCenter.Translate(-50, -50);
3002 gfx::Transform translationByZ; 3002 gfx::Transform translationByZ;
3003 translationByZ.Translate3d(0, 0, -1); 3003 translationByZ.Translate3d(0, 0, -1);
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
3045 // 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.
3046 // 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
3047 // 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.
3048 // 3048 //
3049 // 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
3050 // 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
3051 // as being larger than the actual bounds of the layer. 3051 // as being larger than the actual bounds of the layer.
3052 // 3052 //
3053 FakeImplProxy proxy; 3053 FakeImplProxy proxy;
3054 FakeLayerTreeHostImpl hostImpl(&proxy); 3054 FakeLayerTreeHostImpl hostImpl(&proxy);
3055 scoped_ptr<LayerImpl> root = LayerImpl::create(&hostImpl, 1); 3055 scoped_ptr<LayerImpl> root = LayerImpl::create(hostImpl.activeTree(), 1);
3056 3056
3057 gfx::Transform identityMatrix; 3057 gfx::Transform identityMatrix;
3058 gfx::PointF anchor(0, 0); 3058 gfx::PointF anchor(0, 0);
3059 3059
3060 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);
3061 3061
3062 { 3062 {
3063 gfx::PointF position(25, 25); 3063 gfx::PointF position(25, 25);
3064 gfx::Size bounds(50, 50); 3064 gfx::Size bounds(50, 50);
3065 scoped_ptr<LayerImpl> testLayer = LayerImpl::create(&hostImpl, 12345); 3065 scoped_ptr<LayerImpl> testLayer = LayerImpl::create(hostImpl.activeTree( ), 12345);
3066 setLayerPropertiesForTesting(testLayer.get(), identityMatrix, identityMa trix, anchor, position, bounds, false); 3066 setLayerPropertiesForTesting(testLayer.get(), identityMatrix, identityMa trix, anchor, position, bounds, false);
3067 3067
3068 // override contentBounds and contentsScale 3068 // override contentBounds and contentsScale
3069 testLayer->setContentBounds(gfx::Size(100, 100)); 3069 testLayer->setContentBounds(gfx::Size(100, 100));
3070 testLayer->setContentsScale(2, 2); 3070 testLayer->setContentsScale(2, 2);
3071 3071
3072 testLayer->setDrawsContent(true); 3072 testLayer->setDrawsContent(true);
3073 root->addChild(testLayer.Pass()); 3073 root->addChild(testLayer.Pass());
3074 } 3074 }
3075 3075
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
3111 3111
3112 TEST(LayerTreeHostCommonTest, verifyHitTestingForSimpleClippedLayer) 3112 TEST(LayerTreeHostCommonTest, verifyHitTestingForSimpleClippedLayer)
3113 { 3113 {
3114 // 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
3115 // 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.
3116 gfx::Transform identityMatrix; 3116 gfx::Transform identityMatrix;
3117 gfx::PointF anchor(0, 0); 3117 gfx::PointF anchor(0, 0);
3118 3118
3119 FakeImplProxy proxy; 3119 FakeImplProxy proxy;
3120 FakeLayerTreeHostImpl hostImpl(&proxy); 3120 FakeLayerTreeHostImpl hostImpl(&proxy);
3121 scoped_ptr<LayerImpl> root = LayerImpl::create(&hostImpl, 1); 3121 scoped_ptr<LayerImpl> root = LayerImpl::create(hostImpl.activeTree(), 1);
3122 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);
3123 3123
3124 { 3124 {
3125 scoped_ptr<LayerImpl> clippingLayer = LayerImpl::create(&hostImpl, 123); 3125 scoped_ptr<LayerImpl> clippingLayer = LayerImpl::create(hostImpl.activeT ree(), 123);
3126 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.
3127 gfx::Size bounds(50, 50); 3127 gfx::Size bounds(50, 50);
3128 setLayerPropertiesForTesting(clippingLayer.get(), identityMatrix, identi tyMatrix, anchor, position, bounds, false); 3128 setLayerPropertiesForTesting(clippingLayer.get(), identityMatrix, identi tyMatrix, anchor, position, bounds, false);
3129 clippingLayer->setMasksToBounds(true); 3129 clippingLayer->setMasksToBounds(true);
3130 3130
3131 scoped_ptr<LayerImpl> child = LayerImpl::create(&hostImpl, 456); 3131 scoped_ptr<LayerImpl> child = LayerImpl::create(hostImpl.activeTree(), 4 56);
3132 position = gfx::PointF(-50, -50); 3132 position = gfx::PointF(-50, -50);
3133 bounds = gfx::Size(300, 300); 3133 bounds = gfx::Size(300, 300);
3134 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix , anchor, position, bounds, false); 3134 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix , anchor, position, bounds, false);
3135 child->setDrawsContent(true); 3135 child->setDrawsContent(true);
3136 clippingLayer->addChild(child.Pass()); 3136 clippingLayer->addChild(child.Pass());
3137 root->addChild(clippingLayer.Pass()); 3137 root->addChild(clippingLayer.Pass());
3138 } 3138 }
3139 3139
3140 std::vector<LayerImpl*> renderSurfaceLayerList; 3140 std::vector<LayerImpl*> renderSurfaceLayerList;
3141 int dummyMaxTextureSize = 512; 3141 int dummyMaxTextureSize = 512;
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
3176 // 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
3177 // should not actually hit those clipped areas. 3177 // should not actually hit those clipped areas.
3178 // 3178 //
3179 // 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
3180 // 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
3181 // 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
3182 // this triangle. 3182 // this triangle.
3183 // 3183 //
3184 FakeImplProxy proxy; 3184 FakeImplProxy proxy;
3185 FakeLayerTreeHostImpl hostImpl(&proxy); 3185 FakeLayerTreeHostImpl hostImpl(&proxy);
3186 scoped_ptr<LayerImpl> root = LayerImpl::create(&hostImpl, 123); 3186 scoped_ptr<LayerImpl> root = LayerImpl::create(hostImpl.activeTree(), 123);
3187 3187
3188 gfx::Transform identityMatrix; 3188 gfx::Transform identityMatrix;
3189 gfx::PointF anchor(0, 0); 3189 gfx::PointF anchor(0, 0);
3190 gfx::PointF position(0, 0); 3190 gfx::PointF position(0, 0);
3191 gfx::Size bounds(100, 100); 3191 gfx::Size bounds(100, 100);
3192 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc hor, position, bounds, false); 3192 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc hor, position, bounds, false);
3193 root->setMasksToBounds(true); 3193 root->setMasksToBounds(true);
3194 3194
3195 { 3195 {
3196 scoped_ptr<LayerImpl> child = LayerImpl::create(&hostImpl, 456); 3196 scoped_ptr<LayerImpl> child = LayerImpl::create(hostImpl.activeTree(), 4 56);
3197 scoped_ptr<LayerImpl> grandChild = LayerImpl::create(&hostImpl, 789); 3197 scoped_ptr<LayerImpl> grandChild = LayerImpl::create(hostImpl.activeTree (), 789);
3198 scoped_ptr<LayerImpl> rotatedLeaf = LayerImpl::create(&hostImpl, 2468); 3198 scoped_ptr<LayerImpl> rotatedLeaf = LayerImpl::create(hostImpl.activeTre e(), 2468);
3199 3199
3200 position = gfx::PointF(10, 10); 3200 position = gfx::PointF(10, 10);
3201 bounds = gfx::Size(80, 80); 3201 bounds = gfx::Size(80, 80);
3202 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix , anchor, position, bounds, false); 3202 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix , anchor, position, bounds, false);
3203 child->setMasksToBounds(true); 3203 child->setMasksToBounds(true);
3204 3204
3205 gfx::Transform rotation45DegreesAboutCorner; 3205 gfx::Transform rotation45DegreesAboutCorner;
3206 MathUtil::rotateEulerAngles(&rotation45DegreesAboutCorner, 0, 0, 45); 3206 MathUtil::rotateEulerAngles(&rotation45DegreesAboutCorner, 0, 0, 45);
3207 3207
3208 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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
3279 3279
3280 TEST(LayerTreeHostCommonTest, verifyHitTestingForNonClippingIntermediateLayer) 3280 TEST(LayerTreeHostCommonTest, verifyHitTestingForNonClippingIntermediateLayer)
3281 { 3281 {
3282 // 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
3283 // bounds for a layer that actually does not clip. 3283 // bounds for a layer that actually does not clip.
3284 gfx::Transform identityMatrix; 3284 gfx::Transform identityMatrix;
3285 gfx::PointF anchor(0, 0); 3285 gfx::PointF anchor(0, 0);
3286 3286
3287 FakeImplProxy proxy; 3287 FakeImplProxy proxy;
3288 FakeLayerTreeHostImpl hostImpl(&proxy); 3288 FakeLayerTreeHostImpl hostImpl(&proxy);
3289 scoped_ptr<LayerImpl> root = LayerImpl::create(&hostImpl, 1); 3289 scoped_ptr<LayerImpl> root = LayerImpl::create(hostImpl.activeTree(), 1);
3290 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);
3291 3291
3292 { 3292 {
3293 scoped_ptr<LayerImpl> intermediateLayer = LayerImpl::create(&hostImpl, 1 23); 3293 scoped_ptr<LayerImpl> intermediateLayer = LayerImpl::create(hostImpl.act iveTree(), 123);
3294 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.
3295 gfx::Size bounds(50, 50); 3295 gfx::Size bounds(50, 50);
3296 setLayerPropertiesForTesting(intermediateLayer.get(), identityMatrix, id entityMatrix, anchor, position, bounds, false); 3296 setLayerPropertiesForTesting(intermediateLayer.get(), identityMatrix, id entityMatrix, anchor, position, bounds, false);
3297 // Sanity check the intermediate layer should not clip. 3297 // Sanity check the intermediate layer should not clip.
3298 ASSERT_FALSE(intermediateLayer->masksToBounds()); 3298 ASSERT_FALSE(intermediateLayer->masksToBounds());
3299 ASSERT_FALSE(intermediateLayer->maskLayer()); 3299 ASSERT_FALSE(intermediateLayer->maskLayer());
3300 3300
3301 // 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.
3302 // 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.
3303 scoped_ptr<LayerImpl> child = LayerImpl::create(&hostImpl, 456); 3303 scoped_ptr<LayerImpl> child = LayerImpl::create(hostImpl.activeTree(), 4 56);
3304 position = gfx::PointF(60, 60); // 70, 70 in screen space 3304 position = gfx::PointF(60, 60); // 70, 70 in screen space
3305 bounds = gfx::Size(20, 20); 3305 bounds = gfx::Size(20, 20);
3306 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix , anchor, position, bounds, false); 3306 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix , anchor, position, bounds, false);
3307 child->setDrawsContent(true); 3307 child->setDrawsContent(true);
3308 intermediateLayer->addChild(child.Pass()); 3308 intermediateLayer->addChild(child.Pass());
3309 root->addChild(intermediateLayer.Pass()); 3309 root->addChild(intermediateLayer.Pass());
3310 } 3310 }
3311 3311
3312 std::vector<LayerImpl*> renderSurfaceLayerList; 3312 std::vector<LayerImpl*> renderSurfaceLayerList;
3313 int dummyMaxTextureSize = 512; 3313 int dummyMaxTextureSize = 512;
(...skipping 23 matching lines...) Expand all
3337 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend erSurfaceLayerList); 3337 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend erSurfaceLayerList);
3338 ASSERT_TRUE(resultLayer); 3338 ASSERT_TRUE(resultLayer);
3339 EXPECT_EQ(456, resultLayer->id()); 3339 EXPECT_EQ(456, resultLayer->id());
3340 } 3340 }
3341 3341
3342 3342
3343 TEST(LayerTreeHostCommonTest, verifyHitTestingForMultipleLayers) 3343 TEST(LayerTreeHostCommonTest, verifyHitTestingForMultipleLayers)
3344 { 3344 {
3345 FakeImplProxy proxy; 3345 FakeImplProxy proxy;
3346 FakeLayerTreeHostImpl hostImpl(&proxy); 3346 FakeLayerTreeHostImpl hostImpl(&proxy);
3347 scoped_ptr<LayerImpl> root = LayerImpl::create(&hostImpl, 1); 3347 scoped_ptr<LayerImpl> root = LayerImpl::create(hostImpl.activeTree(), 1);
3348 3348
3349 gfx::Transform identityMatrix; 3349 gfx::Transform identityMatrix;
3350 gfx::PointF anchor(0, 0); 3350 gfx::PointF anchor(0, 0);
3351 gfx::PointF position(0, 0); 3351 gfx::PointF position(0, 0);
3352 gfx::Size bounds(100, 100); 3352 gfx::Size bounds(100, 100);
3353 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc hor, position, bounds, false); 3353 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc hor, position, bounds, false);
3354 root->setDrawsContent(true); 3354 root->setDrawsContent(true);
3355 3355
3356 { 3356 {
3357 // 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.
3358 // 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.
3359 // The expected stacking order is: 3359 // The expected stacking order is:
3360 // (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.
3361 3361
3362 scoped_ptr<LayerImpl> child1 = LayerImpl::create(&hostImpl, 2); 3362 scoped_ptr<LayerImpl> child1 = LayerImpl::create(hostImpl.activeTree(), 2);
3363 scoped_ptr<LayerImpl> child2 = LayerImpl::create(&hostImpl, 3); 3363 scoped_ptr<LayerImpl> child2 = LayerImpl::create(hostImpl.activeTree(), 3);
3364 scoped_ptr<LayerImpl> grandChild1 = LayerImpl::create(&hostImpl, 4); 3364 scoped_ptr<LayerImpl> grandChild1 = LayerImpl::create(hostImpl.activeTre e(), 4);
3365 3365
3366 position = gfx::PointF(10, 10); 3366 position = gfx::PointF(10, 10);
3367 bounds = gfx::Size(50, 50); 3367 bounds = gfx::Size(50, 50);
3368 setLayerPropertiesForTesting(child1.get(), identityMatrix, identityMatri x, anchor, position, bounds, false); 3368 setLayerPropertiesForTesting(child1.get(), identityMatrix, identityMatri x, anchor, position, bounds, false);
3369 child1->setDrawsContent(true); 3369 child1->setDrawsContent(true);
3370 3370
3371 position = gfx::PointF(50, 10); 3371 position = gfx::PointF(50, 10);
3372 bounds = gfx::Size(50, 50); 3372 bounds = gfx::Size(50, 50);
3373 setLayerPropertiesForTesting(child2.get(), identityMatrix, identityMatri x, anchor, position, bounds, false); 3373 setLayerPropertiesForTesting(child2.get(), identityMatrix, identityMatri x, anchor, position, bounds, false);
3374 child2->setDrawsContent(true); 3374 child2->setDrawsContent(true);
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
3442 } 3442 }
3443 3443
3444 TEST(LayerTreeHostCommonTest, verifyHitTestingForMultipleLayerLists) 3444 TEST(LayerTreeHostCommonTest, verifyHitTestingForMultipleLayerLists)
3445 { 3445 {
3446 // 3446 //
3447 // The geometry is set up similarly to the previous case, but 3447 // The geometry is set up similarly to the previous case, but
3448 // all layers are forced to be renderSurfaces now. 3448 // all layers are forced to be renderSurfaces now.
3449 // 3449 //
3450 FakeImplProxy proxy; 3450 FakeImplProxy proxy;
3451 FakeLayerTreeHostImpl hostImpl(&proxy); 3451 FakeLayerTreeHostImpl hostImpl(&proxy);
3452 scoped_ptr<LayerImpl> root = LayerImpl::create(&hostImpl, 1); 3452 scoped_ptr<LayerImpl> root = LayerImpl::create(hostImpl.activeTree(), 1);
3453 3453
3454 gfx::Transform identityMatrix; 3454 gfx::Transform identityMatrix;
3455 gfx::PointF anchor(0, 0); 3455 gfx::PointF anchor(0, 0);
3456 gfx::PointF position(0, 0); 3456 gfx::PointF position(0, 0);
3457 gfx::Size bounds(100, 100); 3457 gfx::Size bounds(100, 100);
3458 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc hor, position, bounds, false); 3458 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc hor, position, bounds, false);
3459 root->setDrawsContent(true); 3459 root->setDrawsContent(true);
3460 3460
3461 { 3461 {
3462 // 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.
3463 // 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.
3464 // The expected stacking order is: 3464 // The expected stacking order is:
3465 // (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.
3466 3466
3467 scoped_ptr<LayerImpl> child1 = LayerImpl::create(&hostImpl, 2); 3467 scoped_ptr<LayerImpl> child1 = LayerImpl::create(hostImpl.activeTree(), 2);
3468 scoped_ptr<LayerImpl> child2 = LayerImpl::create(&hostImpl, 3); 3468 scoped_ptr<LayerImpl> child2 = LayerImpl::create(hostImpl.activeTree(), 3);
3469 scoped_ptr<LayerImpl> grandChild1 = LayerImpl::create(&hostImpl, 4); 3469 scoped_ptr<LayerImpl> grandChild1 = LayerImpl::create(hostImpl.activeTre e(), 4);
3470 3470
3471 position = gfx::PointF(10, 10); 3471 position = gfx::PointF(10, 10);
3472 bounds = gfx::Size(50, 50); 3472 bounds = gfx::Size(50, 50);
3473 setLayerPropertiesForTesting(child1.get(), identityMatrix, identityMatri x, anchor, position, bounds, false); 3473 setLayerPropertiesForTesting(child1.get(), identityMatrix, identityMatri x, anchor, position, bounds, false);
3474 child1->setDrawsContent(true); 3474 child1->setDrawsContent(true);
3475 child1->setForceRenderSurface(true); 3475 child1->setForceRenderSurface(true);
3476 3476
3477 position = gfx::PointF(50, 10); 3477 position = gfx::PointF(50, 10);
3478 bounds = gfx::Size(50, 50); 3478 bounds = gfx::Size(50, 50);
3479 setLayerPropertiesForTesting(child2.get(), identityMatrix, identityMatri x, anchor, position, bounds, false); 3479 setLayerPropertiesForTesting(child2.get(), identityMatrix, identityMatri x, anchor, position, bounds, false);
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
3566 3566
3567 testPoint = gfx::Point(10, 20); 3567 testPoint = gfx::Point(10, 20);
3568 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPointInTouchHandlerRe gion(testPoint, renderSurfaceLayerList); 3568 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPointInTouchHandlerRe gion(testPoint, renderSurfaceLayerList);
3569 EXPECT_FALSE(resultLayer); 3569 EXPECT_FALSE(resultLayer);
3570 } 3570 }
3571 3571
3572 TEST(LayerTreeHostCommonTest, verifyHitCheckingTouchHandlerRegionsForSingleLayer ) 3572 TEST(LayerTreeHostCommonTest, verifyHitCheckingTouchHandlerRegionsForSingleLayer )
3573 { 3573 {
3574 FakeImplProxy proxy; 3574 FakeImplProxy proxy;
3575 FakeLayerTreeHostImpl hostImpl(&proxy); 3575 FakeLayerTreeHostImpl hostImpl(&proxy);
3576 scoped_ptr<LayerImpl> root = LayerImpl::create(&hostImpl, 12345); 3576 scoped_ptr<LayerImpl> root = LayerImpl::create(hostImpl.activeTree(), 12345) ;
3577 3577
3578 gfx::Transform identityMatrix; 3578 gfx::Transform identityMatrix;
3579 Region touchHandlerRegion(gfx::Rect(10, 10, 50, 50)); 3579 Region touchHandlerRegion(gfx::Rect(10, 10, 50, 50));
3580 gfx::PointF anchor(0, 0); 3580 gfx::PointF anchor(0, 0);
3581 gfx::PointF position(0, 0); 3581 gfx::PointF position(0, 0);
3582 gfx::Size bounds(100, 100); 3582 gfx::Size bounds(100, 100);
3583 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc hor, position, bounds, false); 3583 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc hor, position, bounds, false);
3584 root->setDrawsContent(true); 3584 root->setDrawsContent(true);
3585 3585
3586 std::vector<LayerImpl*> renderSurfaceLayerList; 3586 std::vector<LayerImpl*> renderSurfaceLayerList;
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
3624 testPoint = gfx::Point(59, 59); 3624 testPoint = gfx::Point(59, 59);
3625 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPointInTouchHandlerRe gion(testPoint, renderSurfaceLayerList); 3625 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPointInTouchHandlerRe gion(testPoint, renderSurfaceLayerList);
3626 ASSERT_TRUE(resultLayer); 3626 ASSERT_TRUE(resultLayer);
3627 EXPECT_EQ(12345, resultLayer->id()); 3627 EXPECT_EQ(12345, resultLayer->id());
3628 } 3628 }
3629 3629
3630 TEST(LayerTreeHostCommonTest, verifyHitCheckingTouchHandlerRegionsForUninvertibl eTransform) 3630 TEST(LayerTreeHostCommonTest, verifyHitCheckingTouchHandlerRegionsForUninvertibl eTransform)
3631 { 3631 {
3632 FakeImplProxy proxy; 3632 FakeImplProxy proxy;
3633 FakeLayerTreeHostImpl hostImpl(&proxy); 3633 FakeLayerTreeHostImpl hostImpl(&proxy);
3634 scoped_ptr<LayerImpl> root = LayerImpl::create(&hostImpl, 12345); 3634 scoped_ptr<LayerImpl> root = LayerImpl::create(hostImpl.activeTree(), 12345) ;
3635 3635
3636 gfx::Transform uninvertibleTransform; 3636 gfx::Transform uninvertibleTransform;
3637 uninvertibleTransform.matrix().setDouble(0, 0, 0); 3637 uninvertibleTransform.matrix().setDouble(0, 0, 0);
3638 uninvertibleTransform.matrix().setDouble(1, 1, 0); 3638 uninvertibleTransform.matrix().setDouble(1, 1, 0);
3639 uninvertibleTransform.matrix().setDouble(2, 2, 0); 3639 uninvertibleTransform.matrix().setDouble(2, 2, 0);
3640 uninvertibleTransform.matrix().setDouble(3, 3, 0); 3640 uninvertibleTransform.matrix().setDouble(3, 3, 0);
3641 ASSERT_FALSE(uninvertibleTransform.IsInvertible()); 3641 ASSERT_FALSE(uninvertibleTransform.IsInvertible());
3642 3642
3643 gfx::Transform identityMatrix; 3643 gfx::Transform identityMatrix;
3644 Region touchHandlerRegion(gfx::Rect(10, 10, 50, 50)); 3644 Region touchHandlerRegion(gfx::Rect(10, 10, 50, 50));
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
3687 3687
3688 testPoint = gfx::Point(-1, -1); 3688 testPoint = gfx::Point(-1, -1);
3689 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPointInTouchHandlerRe gion(testPoint, renderSurfaceLayerList); 3689 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPointInTouchHandlerRe gion(testPoint, renderSurfaceLayerList);
3690 EXPECT_FALSE(resultLayer); 3690 EXPECT_FALSE(resultLayer);
3691 } 3691 }
3692 3692
3693 TEST(LayerTreeHostCommonTest, verifyHitCheckingTouchHandlerRegionsForSinglePosit ionedLayer) 3693 TEST(LayerTreeHostCommonTest, verifyHitCheckingTouchHandlerRegionsForSinglePosit ionedLayer)
3694 { 3694 {
3695 FakeImplProxy proxy; 3695 FakeImplProxy proxy;
3696 FakeLayerTreeHostImpl hostImpl(&proxy); 3696 FakeLayerTreeHostImpl hostImpl(&proxy);
3697 scoped_ptr<LayerImpl> root = LayerImpl::create(&hostImpl, 12345); 3697 scoped_ptr<LayerImpl> root = LayerImpl::create(hostImpl.activeTree(), 12345) ;
3698 3698
3699 gfx::Transform identityMatrix; 3699 gfx::Transform identityMatrix;
3700 Region touchHandlerRegion(gfx::Rect(10, 10, 50, 50)); 3700 Region touchHandlerRegion(gfx::Rect(10, 10, 50, 50));
3701 gfx::PointF anchor(0, 0); 3701 gfx::PointF anchor(0, 0);
3702 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.
3703 gfx::Size bounds(100, 100); 3703 gfx::Size bounds(100, 100);
3704 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc hor, position, bounds, false); 3704 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc hor, position, bounds, false);
3705 root->setDrawsContent(true); 3705 root->setDrawsContent(true);
3706 root->setTouchEventHandlerRegion(touchHandlerRegion); 3706 root->setTouchEventHandlerRegion(touchHandlerRegion);
3707 3707
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
3747 // 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.
3748 // 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
3749 // 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.
3750 // 3750 //
3751 // 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
3752 // 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
3753 // as being larger than the actual bounds of the layer. 3753 // as being larger than the actual bounds of the layer.
3754 // 3754 //
3755 FakeImplProxy proxy; 3755 FakeImplProxy proxy;
3756 FakeLayerTreeHostImpl hostImpl(&proxy); 3756 FakeLayerTreeHostImpl hostImpl(&proxy);
3757 scoped_ptr<LayerImpl> root = LayerImpl::create(&hostImpl, 1); 3757 scoped_ptr<LayerImpl> root = LayerImpl::create(hostImpl.activeTree(), 1);
3758 3758
3759 gfx::Transform identityMatrix; 3759 gfx::Transform identityMatrix;
3760 gfx::PointF anchor(0, 0); 3760 gfx::PointF anchor(0, 0);
3761 3761
3762 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);
3763 3763
3764 { 3764 {
3765 Region touchHandlerRegion(gfx::Rect(10, 10, 30, 30)); 3765 Region touchHandlerRegion(gfx::Rect(10, 10, 30, 30));
3766 gfx::PointF position(25, 25); 3766 gfx::PointF position(25, 25);
3767 gfx::Size bounds(50, 50); 3767 gfx::Size bounds(50, 50);
3768 scoped_ptr<LayerImpl> testLayer = LayerImpl::create(&hostImpl, 12345); 3768 scoped_ptr<LayerImpl> testLayer = LayerImpl::create(hostImpl.activeTree( ), 12345);
3769 setLayerPropertiesForTesting(testLayer.get(), identityMatrix, identityMa trix, anchor, position, bounds, false); 3769 setLayerPropertiesForTesting(testLayer.get(), identityMatrix, identityMa trix, anchor, position, bounds, false);
3770 3770
3771 // override contentBounds and contentsScale 3771 // override contentBounds and contentsScale
3772 testLayer->setContentBounds(gfx::Size(100, 100)); 3772 testLayer->setContentBounds(gfx::Size(100, 100));
3773 testLayer->setContentsScale(2, 2); 3773 testLayer->setContentsScale(2, 2);
3774 3774
3775 testLayer->setDrawsContent(true); 3775 testLayer->setDrawsContent(true);
3776 testLayer->setTouchEventHandlerRegion(touchHandlerRegion); 3776 testLayer->setTouchEventHandlerRegion(touchHandlerRegion);
3777 root->addChild(testLayer.Pass()); 3777 root->addChild(testLayer.Pass());
3778 } 3778 }
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
3821 ASSERT_TRUE(resultLayer); 3821 ASSERT_TRUE(resultLayer);
3822 EXPECT_EQ(12345, resultLayer->id()); 3822 EXPECT_EQ(12345, resultLayer->id());
3823 } 3823 }
3824 3824
3825 TEST(LayerTreeHostCommonTest, verifyHitCheckingTouchHandlerRegionsForSingleLayer WithDeviceScale) 3825 TEST(LayerTreeHostCommonTest, verifyHitCheckingTouchHandlerRegionsForSingleLayer WithDeviceScale)
3826 { 3826 {
3827 // 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
3828 // 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 .
3829 FakeImplProxy proxy; 3829 FakeImplProxy proxy;
3830 FakeLayerTreeHostImpl hostImpl(&proxy); 3830 FakeLayerTreeHostImpl hostImpl(&proxy);
3831 scoped_ptr<LayerImpl> root = LayerImpl::create(&hostImpl, 1); 3831 scoped_ptr<LayerImpl> root = LayerImpl::create(hostImpl.activeTree(), 1);
3832 3832
3833 gfx::Transform identityMatrix; 3833 gfx::Transform identityMatrix;
3834 gfx::PointF anchor(0, 0); 3834 gfx::PointF anchor(0, 0);
3835 // 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.
3836 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);
3837 3837
3838 { 3838 {
3839 Region touchHandlerRegion(gfx::Rect(10, 10, 30, 30)); 3839 Region touchHandlerRegion(gfx::Rect(10, 10, 30, 30));
3840 gfx::PointF position(25, 25); 3840 gfx::PointF position(25, 25);
3841 gfx::Size bounds(50, 50); 3841 gfx::Size bounds(50, 50);
3842 scoped_ptr<LayerImpl> testLayer = LayerImpl::create(&hostImpl, 12345); 3842 scoped_ptr<LayerImpl> testLayer = LayerImpl::create(hostImpl.activeTree( ), 12345);
3843 setLayerPropertiesForTesting(testLayer.get(), identityMatrix, identityMa trix, anchor, position, bounds, false); 3843 setLayerPropertiesForTesting(testLayer.get(), identityMatrix, identityMa trix, anchor, position, bounds, false);
3844 3844
3845 testLayer->setDrawsContent(true); 3845 testLayer->setDrawsContent(true);
3846 testLayer->setTouchEventHandlerRegion(touchHandlerRegion); 3846 testLayer->setTouchEventHandlerRegion(touchHandlerRegion);
3847 root->addChild(testLayer.Pass()); 3847 root->addChild(testLayer.Pass());
3848 } 3848 }
3849 3849
3850 std::vector<LayerImpl*> renderSurfaceLayerList; 3850 std::vector<LayerImpl*> renderSurfaceLayerList;
3851 int dummyMaxTextureSize = 512; 3851 int dummyMaxTextureSize = 512;
3852 float deviceScaleFactor = 3.0f; 3852 float deviceScaleFactor = 3.0f;
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
3909 3909
3910 TEST(LayerTreeHostCommonTest, verifyHitCheckingTouchHandlerRegionsForSimpleClipp edLayer) 3910 TEST(LayerTreeHostCommonTest, verifyHitCheckingTouchHandlerRegionsForSimpleClipp edLayer)
3911 { 3911 {
3912 // 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
3913 // 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.
3914 gfx::Transform identityMatrix; 3914 gfx::Transform identityMatrix;
3915 gfx::PointF anchor(0, 0); 3915 gfx::PointF anchor(0, 0);
3916 3916
3917 FakeImplProxy proxy; 3917 FakeImplProxy proxy;
3918 FakeLayerTreeHostImpl hostImpl(&proxy); 3918 FakeLayerTreeHostImpl hostImpl(&proxy);
3919 scoped_ptr<LayerImpl> root = LayerImpl::create(&hostImpl, 1); 3919 scoped_ptr<LayerImpl> root = LayerImpl::create(hostImpl.activeTree(), 1);
3920 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);
3921 3921
3922 { 3922 {
3923 scoped_ptr<LayerImpl> clippingLayer = LayerImpl::create(&hostImpl, 123); 3923 scoped_ptr<LayerImpl> clippingLayer = LayerImpl::create(hostImpl.activeT ree(), 123);
3924 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.
3925 gfx::Size bounds(50, 50); 3925 gfx::Size bounds(50, 50);
3926 setLayerPropertiesForTesting(clippingLayer.get(), identityMatrix, identi tyMatrix, anchor, position, bounds, false); 3926 setLayerPropertiesForTesting(clippingLayer.get(), identityMatrix, identi tyMatrix, anchor, position, bounds, false);
3927 clippingLayer->setMasksToBounds(true); 3927 clippingLayer->setMasksToBounds(true);
3928 3928
3929 scoped_ptr<LayerImpl> child = LayerImpl::create(&hostImpl, 456); 3929 scoped_ptr<LayerImpl> child = LayerImpl::create(hostImpl.activeTree(), 4 56);
3930 Region touchHandlerRegion(gfx::Rect(10, 10, 50, 50)); 3930 Region touchHandlerRegion(gfx::Rect(10, 10, 50, 50));
3931 position = gfx::PointF(-50, -50); 3931 position = gfx::PointF(-50, -50);
3932 bounds = gfx::Size(300, 300); 3932 bounds = gfx::Size(300, 300);
3933 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix , anchor, position, bounds, false); 3933 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix , anchor, position, bounds, false);
3934 child->setDrawsContent(true); 3934 child->setDrawsContent(true);
3935 child->setTouchEventHandlerRegion(touchHandlerRegion); 3935 child->setTouchEventHandlerRegion(touchHandlerRegion);
3936 clippingLayer->addChild(child.Pass()); 3936 clippingLayer->addChild(child.Pass());
3937 root->addChild(clippingLayer.Pass()); 3937 root->addChild(clippingLayer.Pass());
3938 } 3938 }
3939 3939
(...skipping 749 matching lines...) Expand 10 before | Expand all | Expand 10 after
4689 child->addChild(grandChild); 4689 child->addChild(grandChild);
4690 child->setOpacity(0.5f); 4690 child->setOpacity(0.5f);
4691 4691
4692 executeCalculateDrawProperties(root.get()); 4692 executeCalculateDrawProperties(root.get());
4693 4693
4694 EXPECT_FALSE(child->renderSurface()); 4694 EXPECT_FALSE(child->renderSurface());
4695 } 4695 }
4696 4696
4697 } // namespace 4697 } // namespace
4698 } // namespace cc 4698 } // namespace cc
OLDNEW
« cc/layer.h ('K') | « cc/layer_tree_host.cc ('k') | cc/layer_tree_host_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698