| OLD | NEW |
| 1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "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/heads_up_display_layer_impl.h" | 9 #include "cc/heads_up_display_layer_impl.h" |
| 10 #include "cc/layer.h" | 10 #include "cc/layer.h" |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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, canUseLCDText, dummyRen
derSurfaceLayerList, false); | 75 LayerTreeHostCommon::calculateDrawProperties(rootLayer, deviceViewportSize,
deviceScaleFactor, pageScaleFactor, dummyMaxTextureSize, canUseLCDText, dummyRen
derSurfaceLayerList, false); |
| 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->activeTree(), 1); | 80 scoped_ptr<LayerImpl> root = LayerImpl::Create(hostImpl->active_tree(), 1); |
| 81 scoped_ptr<LayerImpl> child = LayerImpl::Create(hostImpl->activeTree(), 2); | 81 scoped_ptr<LayerImpl> child = LayerImpl::Create(hostImpl->active_tree(), 2); |
| 82 scoped_ptr<LayerImpl> grandChild = LayerImpl::Create(hostImpl->activeTree(),
3); | 82 scoped_ptr<LayerImpl> grandChild = LayerImpl::Create(hostImpl->active_tree()
, 3); |
| 83 scoped_ptr<LayerImpl> greatGrandChild = LayerImpl::Create(hostImpl->activeTr
ee(), 4); | 83 scoped_ptr<LayerImpl> greatGrandChild = LayerImpl::Create(hostImpl->active_t
ree(), 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 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 263 const gfx::Vector2d kScrollOffset(50, 100); | 263 const gfx::Vector2d kScrollOffset(50, 100); |
| 264 const gfx::Vector2dF kScrollDelta(2.34f, 5.67f); | 264 const gfx::Vector2dF kScrollDelta(2.34f, 5.67f); |
| 265 const gfx::PointF kScrollLayerPosition(-kScrollOffset.x(), -kScrollOffset.y(
)); | 265 const gfx::PointF kScrollLayerPosition(-kScrollOffset.x(), -kScrollOffset.y(
)); |
| 266 const float kPageScale = 0.888f; | 266 const float kPageScale = 0.888f; |
| 267 const float kDeviceScale = 1.666f; | 267 const float kDeviceScale = 1.666f; |
| 268 | 268 |
| 269 FakeImplProxy proxy; | 269 FakeImplProxy proxy; |
| 270 FakeLayerTreeHostImpl hostImpl(&proxy); | 270 FakeLayerTreeHostImpl hostImpl(&proxy); |
| 271 | 271 |
| 272 gfx::Transform identityMatrix; | 272 gfx::Transform identityMatrix; |
| 273 scoped_ptr<LayerImpl> sublayerScopedPtr(LayerImpl::Create(hostImpl.activeTre
e(), 1)); | 273 scoped_ptr<LayerImpl> sublayerScopedPtr(LayerImpl::Create(hostImpl.active_tr
ee(), 1)); |
| 274 LayerImpl* sublayer = sublayerScopedPtr.get(); | 274 LayerImpl* sublayer = sublayerScopedPtr.get(); |
| 275 sublayer->SetContentsScale(kPageScale * kDeviceScale, kPageScale * kDeviceSc
ale); | 275 sublayer->SetContentsScale(kPageScale * kDeviceScale, kPageScale * kDeviceSc
ale); |
| 276 setLayerPropertiesForTesting(sublayer, identityMatrix, identityMatrix, gfx::
Point(0, 0), gfx::PointF(0, 0), gfx::Size(500, 500), false); | 276 setLayerPropertiesForTesting(sublayer, identityMatrix, identityMatrix, gfx::
Point(0, 0), gfx::PointF(0, 0), gfx::Size(500, 500), false); |
| 277 | 277 |
| 278 scoped_ptr<LayerImpl> scrollLayerScopedPtr(LayerImpl::Create(hostImpl.active
Tree(), 2)); | 278 scoped_ptr<LayerImpl> scrollLayerScopedPtr(LayerImpl::Create(hostImpl.active
_tree(), 2)); |
| 279 LayerImpl* scrollLayer = scrollLayerScopedPtr.get(); | 279 LayerImpl* scrollLayer = scrollLayerScopedPtr.get(); |
| 280 setLayerPropertiesForTesting(scrollLayer, identityMatrix, identityMatrix, gf
x::PointF(0, 0), kScrollLayerPosition, gfx::Size(10, 20), false); | 280 setLayerPropertiesForTesting(scrollLayer, identityMatrix, identityMatrix, gf
x::PointF(0, 0), kScrollLayerPosition, gfx::Size(10, 20), false); |
| 281 scrollLayer->SetScrollable(true); | 281 scrollLayer->SetScrollable(true); |
| 282 scrollLayer->SetScrollOffset(kScrollOffset); | 282 scrollLayer->SetScrollOffset(kScrollOffset); |
| 283 scrollLayer->SetScrollDelta(kScrollDelta); | 283 scrollLayer->SetScrollDelta(kScrollDelta); |
| 284 gfx::Transform implTransform; | 284 gfx::Transform implTransform; |
| 285 implTransform.Scale(kPageScale, kPageScale); | 285 implTransform.Scale(kPageScale, kPageScale); |
| 286 scrollLayer->SetImplTransform(implTransform); | 286 scrollLayer->SetImplTransform(implTransform); |
| 287 scrollLayer->AddChild(sublayerScopedPtr.Pass()); | 287 scrollLayer->AddChild(sublayerScopedPtr.Pass()); |
| 288 | 288 |
| 289 scoped_ptr<LayerImpl> root(LayerImpl::Create(hostImpl.activeTree(), 3)); | 289 scoped_ptr<LayerImpl> root(LayerImpl::Create(hostImpl.active_tree(), 3)); |
| 290 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, gfx
::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(3, 4), false); | 290 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, gfx
::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(3, 4), false); |
| 291 root->AddChild(scrollLayerScopedPtr.Pass()); | 291 root->AddChild(scrollLayerScopedPtr.Pass()); |
| 292 | 292 |
| 293 executeCalculateDrawProperties(root.get(), kDeviceScale, kPageScale); | 293 executeCalculateDrawProperties(root.get(), kDeviceScale, kPageScale); |
| 294 gfx::Transform expectedTransform = identityMatrix; | 294 gfx::Transform expectedTransform = identityMatrix; |
| 295 gfx::PointF subLayerScreenPosition = kScrollLayerPosition - kScrollDelta; | 295 gfx::PointF subLayerScreenPosition = kScrollLayerPosition - kScrollDelta; |
| 296 subLayerScreenPosition.Scale(kPageScale * kDeviceScale); | 296 subLayerScreenPosition.Scale(kPageScale * kDeviceScale); |
| 297 expectedTransform.Translate(MathUtil::Round(subLayerScreenPosition.x()), Mat
hUtil::Round(subLayerScreenPosition.y())); | 297 expectedTransform.Translate(MathUtil::Round(subLayerScreenPosition.x()), Mat
hUtil::Round(subLayerScreenPosition.y())); |
| 298 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedTransform, sublayer->draw_transform(
)); | 298 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedTransform, sublayer->draw_transform(
)); |
| 299 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedTransform, sublayer->screen_space_tr
ansform()); | 299 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedTransform, sublayer->screen_space_tr
ansform()); |
| (...skipping 996 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1296 FakeImplProxy proxy; | 1296 FakeImplProxy proxy; |
| 1297 FakeLayerTreeHostImpl hostImpl(&proxy); | 1297 FakeLayerTreeHostImpl hostImpl(&proxy); |
| 1298 scoped_ptr<LayerImpl> root = createTreeForFixedPositionTests(&hostImpl); | 1298 scoped_ptr<LayerImpl> root = createTreeForFixedPositionTests(&hostImpl); |
| 1299 LayerImpl* child = root->children()[0]; | 1299 LayerImpl* child = root->children()[0]; |
| 1300 LayerImpl* grandChild = child->children()[0]; | 1300 LayerImpl* grandChild = child->children()[0]; |
| 1301 LayerImpl* greatGrandChild = grandChild->children()[0]; | 1301 LayerImpl* greatGrandChild = grandChild->children()[0]; |
| 1302 | 1302 |
| 1303 // Add one more layer to the test tree for this scenario. | 1303 // Add one more layer to the test tree for this scenario. |
| 1304 { | 1304 { |
| 1305 gfx::Transform identity; | 1305 gfx::Transform identity; |
| 1306 scoped_ptr<LayerImpl> fixedPositionChild = LayerImpl::Create(hostImpl.ac
tiveTree(), 5); | 1306 scoped_ptr<LayerImpl> fixedPositionChild = LayerImpl::Create(hostImpl.ac
tive_tree(), 5); |
| 1307 setLayerPropertiesForTesting(fixedPositionChild.get(), identity, identit
y, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); | 1307 setLayerPropertiesForTesting(fixedPositionChild.get(), identity, identit
y, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); |
| 1308 greatGrandChild->AddChild(fixedPositionChild.Pass()); | 1308 greatGrandChild->AddChild(fixedPositionChild.Pass()); |
| 1309 } | 1309 } |
| 1310 LayerImpl* fixedPositionChild = greatGrandChild->children()[0]; | 1310 LayerImpl* fixedPositionChild = greatGrandChild->children()[0]; |
| 1311 | 1311 |
| 1312 // Actually set up the scenario here. | 1312 // Actually set up the scenario here. |
| 1313 child->SetIsContainerForFixedPositionLayers(true); | 1313 child->SetIsContainerForFixedPositionLayers(true); |
| 1314 grandChild->SetPosition(gfx::PointF(8, 6)); | 1314 grandChild->SetPosition(gfx::PointF(8, 6)); |
| 1315 grandChild->SetForceRenderSurface(true); | 1315 grandChild->SetForceRenderSurface(true); |
| 1316 greatGrandChild->SetPosition(gfx::PointF(40, 60)); | 1316 greatGrandChild->SetPosition(gfx::PointF(40, 60)); |
| (...skipping 1654 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2971 | 2971 |
| 2972 testPoint = gfx::Point(10, 20); | 2972 testPoint = gfx::Point(10, 20); |
| 2973 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); | 2973 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); |
| 2974 EXPECT_FALSE(resultLayer); | 2974 EXPECT_FALSE(resultLayer); |
| 2975 } | 2975 } |
| 2976 | 2976 |
| 2977 TEST(LayerTreeHostCommonTest, verifyHitTestingForSingleLayer) | 2977 TEST(LayerTreeHostCommonTest, verifyHitTestingForSingleLayer) |
| 2978 { | 2978 { |
| 2979 FakeImplProxy proxy; | 2979 FakeImplProxy proxy; |
| 2980 FakeLayerTreeHostImpl hostImpl(&proxy); | 2980 FakeLayerTreeHostImpl hostImpl(&proxy); |
| 2981 scoped_ptr<LayerImpl> root = LayerImpl::Create(hostImpl.activeTree(), 12345)
; | 2981 scoped_ptr<LayerImpl> root = LayerImpl::Create(hostImpl.active_tree(), 12345
); |
| 2982 | 2982 |
| 2983 gfx::Transform identityMatrix; | 2983 gfx::Transform identityMatrix; |
| 2984 gfx::PointF anchor(0, 0); | 2984 gfx::PointF anchor(0, 0); |
| 2985 gfx::PointF position(0, 0); | 2985 gfx::PointF position(0, 0); |
| 2986 gfx::Size bounds(100, 100); | 2986 gfx::Size bounds(100, 100); |
| 2987 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc
hor, position, bounds, false); | 2987 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc
hor, position, bounds, false); |
| 2988 root->SetDrawsContent(true); | 2988 root->SetDrawsContent(true); |
| 2989 | 2989 |
| 2990 std::vector<LayerImpl*> renderSurfaceLayerList; | 2990 std::vector<LayerImpl*> renderSurfaceLayerList; |
| 2991 int dummyMaxTextureSize = 512; | 2991 int dummyMaxTextureSize = 512; |
| (...skipping 21 matching lines...) Expand all Loading... |
| 3013 testPoint = gfx::Point(99, 99); | 3013 testPoint = gfx::Point(99, 99); |
| 3014 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); | 3014 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); |
| 3015 ASSERT_TRUE(resultLayer); | 3015 ASSERT_TRUE(resultLayer); |
| 3016 EXPECT_EQ(12345, resultLayer->id()); | 3016 EXPECT_EQ(12345, resultLayer->id()); |
| 3017 } | 3017 } |
| 3018 | 3018 |
| 3019 TEST(LayerTreeHostCommonTest, verifyHitTestingForSingleLayerAndHud) | 3019 TEST(LayerTreeHostCommonTest, verifyHitTestingForSingleLayerAndHud) |
| 3020 { | 3020 { |
| 3021 FakeImplProxy proxy; | 3021 FakeImplProxy proxy; |
| 3022 FakeLayerTreeHostImpl hostImpl(&proxy); | 3022 FakeLayerTreeHostImpl hostImpl(&proxy); |
| 3023 scoped_ptr<LayerImpl> root = LayerImpl::Create(hostImpl.activeTree(), 12345)
; | 3023 scoped_ptr<LayerImpl> root = LayerImpl::Create(hostImpl.active_tree(), 12345
); |
| 3024 scoped_ptr<HeadsUpDisplayLayerImpl> hud = HeadsUpDisplayLayerImpl::Create(ho
stImpl.activeTree(), 11111); | 3024 scoped_ptr<HeadsUpDisplayLayerImpl> hud = HeadsUpDisplayLayerImpl::Create(ho
stImpl.active_tree(), 11111); |
| 3025 | 3025 |
| 3026 gfx::Transform identityMatrix; | 3026 gfx::Transform identityMatrix; |
| 3027 gfx::PointF anchor(0.f, 0.f); | 3027 gfx::PointF anchor(0.f, 0.f); |
| 3028 gfx::PointF position(0.f, 0.f); | 3028 gfx::PointF position(0.f, 0.f); |
| 3029 gfx::Size bounds(100, 100); | 3029 gfx::Size bounds(100, 100); |
| 3030 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc
hor, position, bounds, false); | 3030 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc
hor, position, bounds, false); |
| 3031 root->SetDrawsContent(true); | 3031 root->SetDrawsContent(true); |
| 3032 | 3032 |
| 3033 // Create hud and add it as a child of root. | 3033 // Create hud and add it as a child of root. |
| 3034 gfx::Size hudBounds(200, 200); | 3034 gfx::Size hudBounds(200, 200); |
| 3035 setLayerPropertiesForTesting(hud.get(), identityMatrix, identityMatrix, anch
or, position, hudBounds, false); | 3035 setLayerPropertiesForTesting(hud.get(), identityMatrix, identityMatrix, anch
or, position, hudBounds, false); |
| 3036 hud->SetDrawsContent(true); | 3036 hud->SetDrawsContent(true); |
| 3037 | 3037 |
| 3038 hostImpl.activeTree()->set_hud_layer(hud.get()); | 3038 hostImpl.active_tree()->set_hud_layer(hud.get()); |
| 3039 root->AddChild(hud.PassAs<LayerImpl>()); | 3039 root->AddChild(hud.PassAs<LayerImpl>()); |
| 3040 | 3040 |
| 3041 std::vector<LayerImpl*> renderSurfaceLayerList; | 3041 std::vector<LayerImpl*> renderSurfaceLayerList; |
| 3042 int dummyMaxTextureSize = 512; | 3042 int dummyMaxTextureSize = 512; |
| 3043 LayerTreeHostCommon::calculateDrawProperties(root.get(), hudBounds, 1, 1, du
mmyMaxTextureSize, false, renderSurfaceLayerList, false); | 3043 LayerTreeHostCommon::calculateDrawProperties(root.get(), hudBounds, 1, 1, du
mmyMaxTextureSize, false, renderSurfaceLayerList, false); |
| 3044 | 3044 |
| 3045 // Sanity check the scenario we just created. | 3045 // Sanity check the scenario we just created. |
| 3046 ASSERT_EQ(1u, renderSurfaceLayerList.size()); | 3046 ASSERT_EQ(1u, renderSurfaceLayerList.size()); |
| 3047 ASSERT_EQ(2u, root->render_surface()->layer_list().size()); | 3047 ASSERT_EQ(2u, root->render_surface()->layer_list().size()); |
| 3048 | 3048 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 3064 testPoint = gfx::Point(99, 99); | 3064 testPoint = gfx::Point(99, 99); |
| 3065 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); | 3065 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); |
| 3066 ASSERT_TRUE(resultLayer); | 3066 ASSERT_TRUE(resultLayer); |
| 3067 EXPECT_EQ(12345, resultLayer->id()); | 3067 EXPECT_EQ(12345, resultLayer->id()); |
| 3068 } | 3068 } |
| 3069 | 3069 |
| 3070 TEST(LayerTreeHostCommonTest, verifyHitTestingForUninvertibleTransform) | 3070 TEST(LayerTreeHostCommonTest, verifyHitTestingForUninvertibleTransform) |
| 3071 { | 3071 { |
| 3072 FakeImplProxy proxy; | 3072 FakeImplProxy proxy; |
| 3073 FakeLayerTreeHostImpl hostImpl(&proxy); | 3073 FakeLayerTreeHostImpl hostImpl(&proxy); |
| 3074 scoped_ptr<LayerImpl> root = LayerImpl::Create(hostImpl.activeTree(), 12345)
; | 3074 scoped_ptr<LayerImpl> root = LayerImpl::Create(hostImpl.active_tree(), 12345
); |
| 3075 | 3075 |
| 3076 gfx::Transform uninvertibleTransform; | 3076 gfx::Transform uninvertibleTransform; |
| 3077 uninvertibleTransform.matrix().setDouble(0, 0, 0); | 3077 uninvertibleTransform.matrix().setDouble(0, 0, 0); |
| 3078 uninvertibleTransform.matrix().setDouble(1, 1, 0); | 3078 uninvertibleTransform.matrix().setDouble(1, 1, 0); |
| 3079 uninvertibleTransform.matrix().setDouble(2, 2, 0); | 3079 uninvertibleTransform.matrix().setDouble(2, 2, 0); |
| 3080 uninvertibleTransform.matrix().setDouble(3, 3, 0); | 3080 uninvertibleTransform.matrix().setDouble(3, 3, 0); |
| 3081 ASSERT_FALSE(uninvertibleTransform.IsInvertible()); | 3081 ASSERT_FALSE(uninvertibleTransform.IsInvertible()); |
| 3082 | 3082 |
| 3083 gfx::Transform identityMatrix; | 3083 gfx::Transform identityMatrix; |
| 3084 gfx::PointF anchor(0, 0); | 3084 gfx::PointF anchor(0, 0); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3125 | 3125 |
| 3126 testPoint = gfx::Point(-1, -1); | 3126 testPoint = gfx::Point(-1, -1); |
| 3127 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); | 3127 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); |
| 3128 EXPECT_FALSE(resultLayer); | 3128 EXPECT_FALSE(resultLayer); |
| 3129 } | 3129 } |
| 3130 | 3130 |
| 3131 TEST(LayerTreeHostCommonTest, verifyHitTestingForSinglePositionedLayer) | 3131 TEST(LayerTreeHostCommonTest, verifyHitTestingForSinglePositionedLayer) |
| 3132 { | 3132 { |
| 3133 FakeImplProxy proxy; | 3133 FakeImplProxy proxy; |
| 3134 FakeLayerTreeHostImpl hostImpl(&proxy); | 3134 FakeLayerTreeHostImpl hostImpl(&proxy); |
| 3135 scoped_ptr<LayerImpl> root = LayerImpl::Create(hostImpl.activeTree(), 12345)
; | 3135 scoped_ptr<LayerImpl> root = LayerImpl::Create(hostImpl.active_tree(), 12345
); |
| 3136 | 3136 |
| 3137 gfx::Transform identityMatrix; | 3137 gfx::Transform identityMatrix; |
| 3138 gfx::PointF anchor(0, 0); | 3138 gfx::PointF anchor(0, 0); |
| 3139 gfx::PointF position(50, 50); // this layer is positioned, and hit testing s
hould correctly know where the layer is located. | 3139 gfx::PointF position(50, 50); // this layer is positioned, and hit testing s
hould correctly know where the layer is located. |
| 3140 gfx::Size bounds(100, 100); | 3140 gfx::Size bounds(100, 100); |
| 3141 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc
hor, position, bounds, false); | 3141 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc
hor, position, bounds, false); |
| 3142 root->SetDrawsContent(true); | 3142 root->SetDrawsContent(true); |
| 3143 | 3143 |
| 3144 std::vector<LayerImpl*> renderSurfaceLayerList; | 3144 std::vector<LayerImpl*> renderSurfaceLayerList; |
| 3145 int dummyMaxTextureSize = 512; | 3145 int dummyMaxTextureSize = 512; |
| (...skipping 22 matching lines...) Expand all Loading... |
| 3168 testPoint = gfx::Point(99, 99); | 3168 testPoint = gfx::Point(99, 99); |
| 3169 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); | 3169 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); |
| 3170 ASSERT_TRUE(resultLayer); | 3170 ASSERT_TRUE(resultLayer); |
| 3171 EXPECT_EQ(12345, resultLayer->id()); | 3171 EXPECT_EQ(12345, resultLayer->id()); |
| 3172 } | 3172 } |
| 3173 | 3173 |
| 3174 TEST(LayerTreeHostCommonTest, verifyHitTestingForSingleRotatedLayer) | 3174 TEST(LayerTreeHostCommonTest, verifyHitTestingForSingleRotatedLayer) |
| 3175 { | 3175 { |
| 3176 FakeImplProxy proxy; | 3176 FakeImplProxy proxy; |
| 3177 FakeLayerTreeHostImpl hostImpl(&proxy); | 3177 FakeLayerTreeHostImpl hostImpl(&proxy); |
| 3178 scoped_ptr<LayerImpl> root = LayerImpl::Create(hostImpl.activeTree(), 12345)
; | 3178 scoped_ptr<LayerImpl> root = LayerImpl::Create(hostImpl.active_tree(), 12345
); |
| 3179 | 3179 |
| 3180 gfx::Transform identityMatrix; | 3180 gfx::Transform identityMatrix; |
| 3181 gfx::Transform rotation45DegreesAboutCenter; | 3181 gfx::Transform rotation45DegreesAboutCenter; |
| 3182 rotation45DegreesAboutCenter.Translate(50, 50); | 3182 rotation45DegreesAboutCenter.Translate(50, 50); |
| 3183 rotation45DegreesAboutCenter.RotateAboutZAxis(45); | 3183 rotation45DegreesAboutCenter.RotateAboutZAxis(45); |
| 3184 rotation45DegreesAboutCenter.Translate(-50, -50); | 3184 rotation45DegreesAboutCenter.Translate(-50, -50); |
| 3185 gfx::PointF anchor(0, 0); | 3185 gfx::PointF anchor(0, 0); |
| 3186 gfx::PointF position(0, 0); | 3186 gfx::PointF position(0, 0); |
| 3187 gfx::Size bounds(100, 100); | 3187 gfx::Size bounds(100, 100); |
| 3188 setLayerPropertiesForTesting(root.get(), rotation45DegreesAboutCenter, ident
ityMatrix, anchor, position, bounds, false); | 3188 setLayerPropertiesForTesting(root.get(), rotation45DegreesAboutCenter, ident
ityMatrix, anchor, position, bounds, false); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 3219 | 3219 |
| 3220 testPoint = gfx::Point(-1, 50); | 3220 testPoint = gfx::Point(-1, 50); |
| 3221 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); | 3221 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); |
| 3222 ASSERT_FALSE(resultLayer); | 3222 ASSERT_FALSE(resultLayer); |
| 3223 } | 3223 } |
| 3224 | 3224 |
| 3225 TEST(LayerTreeHostCommonTest, verifyHitTestingForSinglePerspectiveLayer) | 3225 TEST(LayerTreeHostCommonTest, verifyHitTestingForSinglePerspectiveLayer) |
| 3226 { | 3226 { |
| 3227 FakeImplProxy proxy; | 3227 FakeImplProxy proxy; |
| 3228 FakeLayerTreeHostImpl hostImpl(&proxy); | 3228 FakeLayerTreeHostImpl hostImpl(&proxy); |
| 3229 scoped_ptr<LayerImpl> root = LayerImpl::Create(hostImpl.activeTree(), 12345)
; | 3229 scoped_ptr<LayerImpl> root = LayerImpl::Create(hostImpl.active_tree(), 12345
); |
| 3230 | 3230 |
| 3231 gfx::Transform identityMatrix; | 3231 gfx::Transform identityMatrix; |
| 3232 | 3232 |
| 3233 // perspectiveProjectionAboutCenter * translationByZ is designed so that the
100 x 100 layer becomes 50 x 50, and remains centered at (50, 50). | 3233 // perspectiveProjectionAboutCenter * translationByZ is designed so that the
100 x 100 layer becomes 50 x 50, and remains centered at (50, 50). |
| 3234 gfx::Transform perspectiveProjectionAboutCenter; | 3234 gfx::Transform perspectiveProjectionAboutCenter; |
| 3235 perspectiveProjectionAboutCenter.Translate(50, 50); | 3235 perspectiveProjectionAboutCenter.Translate(50, 50); |
| 3236 perspectiveProjectionAboutCenter.ApplyPerspectiveDepth(1); | 3236 perspectiveProjectionAboutCenter.ApplyPerspectiveDepth(1); |
| 3237 perspectiveProjectionAboutCenter.Translate(-50, -50); | 3237 perspectiveProjectionAboutCenter.Translate(-50, -50); |
| 3238 gfx::Transform translationByZ; | 3238 gfx::Transform translationByZ; |
| 3239 translationByZ.Translate3d(0, 0, -1); | 3239 translationByZ.Translate3d(0, 0, -1); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3281 // test makes sure that hit testing works correctly accounts for the content
s scale. | 3281 // test makes sure that hit testing works correctly accounts for the content
s scale. |
| 3282 // A contentsScale that is not 1 effectively forces a non-identity transform
between | 3282 // A contentsScale that is not 1 effectively forces a non-identity transform
between |
| 3283 // layer's content space and layer's origin space. The hit testing code must
take this into account. | 3283 // layer's content space and layer's origin space. The hit testing code must
take this into account. |
| 3284 // | 3284 // |
| 3285 // To test this, the layer is positioned at (25, 25), and is size (50, 50).
If | 3285 // To test this, the layer is positioned at (25, 25), and is size (50, 50).
If |
| 3286 // contentsScale is ignored, then hit testing will mis-interpret the visible
ContentRect | 3286 // contentsScale is ignored, then hit testing will mis-interpret the visible
ContentRect |
| 3287 // as being larger than the actual bounds of the layer. | 3287 // as being larger than the actual bounds of the layer. |
| 3288 // | 3288 // |
| 3289 FakeImplProxy proxy; | 3289 FakeImplProxy proxy; |
| 3290 FakeLayerTreeHostImpl hostImpl(&proxy); | 3290 FakeLayerTreeHostImpl hostImpl(&proxy); |
| 3291 scoped_ptr<LayerImpl> root = LayerImpl::Create(hostImpl.activeTree(), 1); | 3291 scoped_ptr<LayerImpl> root = LayerImpl::Create(hostImpl.active_tree(), 1); |
| 3292 | 3292 |
| 3293 gfx::Transform identityMatrix; | 3293 gfx::Transform identityMatrix; |
| 3294 gfx::PointF anchor(0, 0); | 3294 gfx::PointF anchor(0, 0); |
| 3295 | 3295 |
| 3296 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc
hor, gfx::PointF(0, 0), gfx::Size(100, 100), false); | 3296 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc
hor, gfx::PointF(0, 0), gfx::Size(100, 100), false); |
| 3297 | 3297 |
| 3298 { | 3298 { |
| 3299 gfx::PointF position(25, 25); | 3299 gfx::PointF position(25, 25); |
| 3300 gfx::Size bounds(50, 50); | 3300 gfx::Size bounds(50, 50); |
| 3301 scoped_ptr<LayerImpl> testLayer = LayerImpl::Create(hostImpl.activeTree(
), 12345); | 3301 scoped_ptr<LayerImpl> testLayer = LayerImpl::Create(hostImpl.active_tree
(), 12345); |
| 3302 setLayerPropertiesForTesting(testLayer.get(), identityMatrix, identityMa
trix, anchor, position, bounds, false); | 3302 setLayerPropertiesForTesting(testLayer.get(), identityMatrix, identityMa
trix, anchor, position, bounds, false); |
| 3303 | 3303 |
| 3304 // override contentBounds and contentsScale | 3304 // override contentBounds and contentsScale |
| 3305 testLayer->SetContentBounds(gfx::Size(100, 100)); | 3305 testLayer->SetContentBounds(gfx::Size(100, 100)); |
| 3306 testLayer->SetContentsScale(2, 2); | 3306 testLayer->SetContentsScale(2, 2); |
| 3307 | 3307 |
| 3308 testLayer->SetDrawsContent(true); | 3308 testLayer->SetDrawsContent(true); |
| 3309 root->AddChild(testLayer.Pass()); | 3309 root->AddChild(testLayer.Pass()); |
| 3310 } | 3310 } |
| 3311 | 3311 |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3347 | 3347 |
| 3348 TEST(LayerTreeHostCommonTest, verifyHitTestingForSimpleClippedLayer) | 3348 TEST(LayerTreeHostCommonTest, verifyHitTestingForSimpleClippedLayer) |
| 3349 { | 3349 { |
| 3350 // Test that hit-testing will only work for the visible portion of a layer,
and not | 3350 // Test that hit-testing will only work for the visible portion of a layer,
and not |
| 3351 // the entire layer bounds. Here we just test the simple axis-aligned case. | 3351 // the entire layer bounds. Here we just test the simple axis-aligned case. |
| 3352 gfx::Transform identityMatrix; | 3352 gfx::Transform identityMatrix; |
| 3353 gfx::PointF anchor(0, 0); | 3353 gfx::PointF anchor(0, 0); |
| 3354 | 3354 |
| 3355 FakeImplProxy proxy; | 3355 FakeImplProxy proxy; |
| 3356 FakeLayerTreeHostImpl hostImpl(&proxy); | 3356 FakeLayerTreeHostImpl hostImpl(&proxy); |
| 3357 scoped_ptr<LayerImpl> root = LayerImpl::Create(hostImpl.activeTree(), 1); | 3357 scoped_ptr<LayerImpl> root = LayerImpl::Create(hostImpl.active_tree(), 1); |
| 3358 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc
hor, gfx::PointF(0, 0), gfx::Size(100, 100), false); | 3358 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc
hor, gfx::PointF(0, 0), gfx::Size(100, 100), false); |
| 3359 | 3359 |
| 3360 { | 3360 { |
| 3361 scoped_ptr<LayerImpl> clippingLayer = LayerImpl::Create(hostImpl.activeT
ree(), 123); | 3361 scoped_ptr<LayerImpl> clippingLayer = LayerImpl::Create(hostImpl.active_
tree(), 123); |
| 3362 gfx::PointF position(25, 25); // this layer is positioned, and hit testi
ng should correctly know where the layer is located. | 3362 gfx::PointF position(25, 25); // this layer is positioned, and hit testi
ng should correctly know where the layer is located. |
| 3363 gfx::Size bounds(50, 50); | 3363 gfx::Size bounds(50, 50); |
| 3364 setLayerPropertiesForTesting(clippingLayer.get(), identityMatrix, identi
tyMatrix, anchor, position, bounds, false); | 3364 setLayerPropertiesForTesting(clippingLayer.get(), identityMatrix, identi
tyMatrix, anchor, position, bounds, false); |
| 3365 clippingLayer->SetMasksToBounds(true); | 3365 clippingLayer->SetMasksToBounds(true); |
| 3366 | 3366 |
| 3367 scoped_ptr<LayerImpl> child = LayerImpl::Create(hostImpl.activeTree(), 4
56); | 3367 scoped_ptr<LayerImpl> child = LayerImpl::Create(hostImpl.active_tree(),
456); |
| 3368 position = gfx::PointF(-50, -50); | 3368 position = gfx::PointF(-50, -50); |
| 3369 bounds = gfx::Size(300, 300); | 3369 bounds = gfx::Size(300, 300); |
| 3370 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix
, anchor, position, bounds, false); | 3370 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix
, anchor, position, bounds, false); |
| 3371 child->SetDrawsContent(true); | 3371 child->SetDrawsContent(true); |
| 3372 clippingLayer->AddChild(child.Pass()); | 3372 clippingLayer->AddChild(child.Pass()); |
| 3373 root->AddChild(clippingLayer.Pass()); | 3373 root->AddChild(clippingLayer.Pass()); |
| 3374 } | 3374 } |
| 3375 | 3375 |
| 3376 std::vector<LayerImpl*> renderSurfaceLayerList; | 3376 std::vector<LayerImpl*> renderSurfaceLayerList; |
| 3377 int dummyMaxTextureSize = 512; | 3377 int dummyMaxTextureSize = 512; |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3412 // algorithm needs to recognize that multiple parent layers may clip the lay
er, and | 3412 // algorithm needs to recognize that multiple parent layers may clip the lay
er, and |
| 3413 // should not actually hit those clipped areas. | 3413 // should not actually hit those clipped areas. |
| 3414 // | 3414 // |
| 3415 // The child and grandChild layers are both initialized to clip the rotatedL
eaf. The | 3415 // The child and grandChild layers are both initialized to clip the rotatedL
eaf. The |
| 3416 // child layer is rotated about the top-left corner, so that the root + chil
d clips | 3416 // child layer is rotated about the top-left corner, so that the root + chil
d clips |
| 3417 // combined create a triangle. The rotatedLeaf will only be visible where it
overlaps | 3417 // combined create a triangle. The rotatedLeaf will only be visible where it
overlaps |
| 3418 // this triangle. | 3418 // this triangle. |
| 3419 // | 3419 // |
| 3420 FakeImplProxy proxy; | 3420 FakeImplProxy proxy; |
| 3421 FakeLayerTreeHostImpl hostImpl(&proxy); | 3421 FakeLayerTreeHostImpl hostImpl(&proxy); |
| 3422 scoped_ptr<LayerImpl> root = LayerImpl::Create(hostImpl.activeTree(), 123); | 3422 scoped_ptr<LayerImpl> root = LayerImpl::Create(hostImpl.active_tree(), 123); |
| 3423 | 3423 |
| 3424 gfx::Transform identityMatrix; | 3424 gfx::Transform identityMatrix; |
| 3425 gfx::PointF anchor(0, 0); | 3425 gfx::PointF anchor(0, 0); |
| 3426 gfx::PointF position(0, 0); | 3426 gfx::PointF position(0, 0); |
| 3427 gfx::Size bounds(100, 100); | 3427 gfx::Size bounds(100, 100); |
| 3428 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc
hor, position, bounds, false); | 3428 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc
hor, position, bounds, false); |
| 3429 root->SetMasksToBounds(true); | 3429 root->SetMasksToBounds(true); |
| 3430 | 3430 |
| 3431 { | 3431 { |
| 3432 scoped_ptr<LayerImpl> child = LayerImpl::Create(hostImpl.activeTree(), 4
56); | 3432 scoped_ptr<LayerImpl> child = LayerImpl::Create(hostImpl.active_tree(),
456); |
| 3433 scoped_ptr<LayerImpl> grandChild = LayerImpl::Create(hostImpl.activeTree
(), 789); | 3433 scoped_ptr<LayerImpl> grandChild = LayerImpl::Create(hostImpl.active_tre
e(), 789); |
| 3434 scoped_ptr<LayerImpl> rotatedLeaf = LayerImpl::Create(hostImpl.activeTre
e(), 2468); | 3434 scoped_ptr<LayerImpl> rotatedLeaf = LayerImpl::Create(hostImpl.active_tr
ee(), 2468); |
| 3435 | 3435 |
| 3436 position = gfx::PointF(10, 10); | 3436 position = gfx::PointF(10, 10); |
| 3437 bounds = gfx::Size(80, 80); | 3437 bounds = gfx::Size(80, 80); |
| 3438 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix
, anchor, position, bounds, false); | 3438 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix
, anchor, position, bounds, false); |
| 3439 child->SetMasksToBounds(true); | 3439 child->SetMasksToBounds(true); |
| 3440 | 3440 |
| 3441 gfx::Transform rotation45DegreesAboutCorner; | 3441 gfx::Transform rotation45DegreesAboutCorner; |
| 3442 rotation45DegreesAboutCorner.RotateAboutZAxis(45); | 3442 rotation45DegreesAboutCorner.RotateAboutZAxis(45); |
| 3443 | 3443 |
| 3444 position = gfx::PointF(0, 0); // remember, positioned with respect to it
s parent which is already at 10, 10 | 3444 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 Loading... |
| 3515 | 3515 |
| 3516 TEST(LayerTreeHostCommonTest, verifyHitTestingForNonClippingIntermediateLayer) | 3516 TEST(LayerTreeHostCommonTest, verifyHitTestingForNonClippingIntermediateLayer) |
| 3517 { | 3517 { |
| 3518 // This test checks that hit testing code does not accidentally clip to laye
r | 3518 // This test checks that hit testing code does not accidentally clip to laye
r |
| 3519 // bounds for a layer that actually does not clip. | 3519 // bounds for a layer that actually does not clip. |
| 3520 gfx::Transform identityMatrix; | 3520 gfx::Transform identityMatrix; |
| 3521 gfx::PointF anchor(0, 0); | 3521 gfx::PointF anchor(0, 0); |
| 3522 | 3522 |
| 3523 FakeImplProxy proxy; | 3523 FakeImplProxy proxy; |
| 3524 FakeLayerTreeHostImpl hostImpl(&proxy); | 3524 FakeLayerTreeHostImpl hostImpl(&proxy); |
| 3525 scoped_ptr<LayerImpl> root = LayerImpl::Create(hostImpl.activeTree(), 1); | 3525 scoped_ptr<LayerImpl> root = LayerImpl::Create(hostImpl.active_tree(), 1); |
| 3526 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc
hor, gfx::PointF(0, 0), gfx::Size(100, 100), false); | 3526 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc
hor, gfx::PointF(0, 0), gfx::Size(100, 100), false); |
| 3527 | 3527 |
| 3528 { | 3528 { |
| 3529 scoped_ptr<LayerImpl> intermediateLayer = LayerImpl::Create(hostImpl.act
iveTree(), 123); | 3529 scoped_ptr<LayerImpl> intermediateLayer = LayerImpl::Create(hostImpl.act
ive_tree(), 123); |
| 3530 gfx::PointF position(10, 10); // this layer is positioned, and hit testi
ng should correctly know where the layer is located. | 3530 gfx::PointF position(10, 10); // this layer is positioned, and hit testi
ng should correctly know where the layer is located. |
| 3531 gfx::Size bounds(50, 50); | 3531 gfx::Size bounds(50, 50); |
| 3532 setLayerPropertiesForTesting(intermediateLayer.get(), identityMatrix, id
entityMatrix, anchor, position, bounds, false); | 3532 setLayerPropertiesForTesting(intermediateLayer.get(), identityMatrix, id
entityMatrix, anchor, position, bounds, false); |
| 3533 // Sanity check the intermediate layer should not clip. | 3533 // Sanity check the intermediate layer should not clip. |
| 3534 ASSERT_FALSE(intermediateLayer->masks_to_bounds()); | 3534 ASSERT_FALSE(intermediateLayer->masks_to_bounds()); |
| 3535 ASSERT_FALSE(intermediateLayer->mask_layer()); | 3535 ASSERT_FALSE(intermediateLayer->mask_layer()); |
| 3536 | 3536 |
| 3537 // The child of the intermediateLayer is translated so that it does not
overlap intermediateLayer at all. | 3537 // The child of the intermediateLayer is translated so that it does not
overlap intermediateLayer at all. |
| 3538 // If child is incorrectly clipped, we would not be able to hit it succe
ssfully. | 3538 // If child is incorrectly clipped, we would not be able to hit it succe
ssfully. |
| 3539 scoped_ptr<LayerImpl> child = LayerImpl::Create(hostImpl.activeTree(), 4
56); | 3539 scoped_ptr<LayerImpl> child = LayerImpl::Create(hostImpl.active_tree(),
456); |
| 3540 position = gfx::PointF(60, 60); // 70, 70 in screen space | 3540 position = gfx::PointF(60, 60); // 70, 70 in screen space |
| 3541 bounds = gfx::Size(20, 20); | 3541 bounds = gfx::Size(20, 20); |
| 3542 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix
, anchor, position, bounds, false); | 3542 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix
, anchor, position, bounds, false); |
| 3543 child->SetDrawsContent(true); | 3543 child->SetDrawsContent(true); |
| 3544 intermediateLayer->AddChild(child.Pass()); | 3544 intermediateLayer->AddChild(child.Pass()); |
| 3545 root->AddChild(intermediateLayer.Pass()); | 3545 root->AddChild(intermediateLayer.Pass()); |
| 3546 } | 3546 } |
| 3547 | 3547 |
| 3548 std::vector<LayerImpl*> renderSurfaceLayerList; | 3548 std::vector<LayerImpl*> renderSurfaceLayerList; |
| 3549 int dummyMaxTextureSize = 512; | 3549 int dummyMaxTextureSize = 512; |
| (...skipping 23 matching lines...) Expand all Loading... |
| 3573 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); | 3573 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); |
| 3574 ASSERT_TRUE(resultLayer); | 3574 ASSERT_TRUE(resultLayer); |
| 3575 EXPECT_EQ(456, resultLayer->id()); | 3575 EXPECT_EQ(456, resultLayer->id()); |
| 3576 } | 3576 } |
| 3577 | 3577 |
| 3578 | 3578 |
| 3579 TEST(LayerTreeHostCommonTest, verifyHitTestingForMultipleLayers) | 3579 TEST(LayerTreeHostCommonTest, verifyHitTestingForMultipleLayers) |
| 3580 { | 3580 { |
| 3581 FakeImplProxy proxy; | 3581 FakeImplProxy proxy; |
| 3582 FakeLayerTreeHostImpl hostImpl(&proxy); | 3582 FakeLayerTreeHostImpl hostImpl(&proxy); |
| 3583 scoped_ptr<LayerImpl> root = LayerImpl::Create(hostImpl.activeTree(), 1); | 3583 scoped_ptr<LayerImpl> root = LayerImpl::Create(hostImpl.active_tree(), 1); |
| 3584 | 3584 |
| 3585 gfx::Transform identityMatrix; | 3585 gfx::Transform identityMatrix; |
| 3586 gfx::PointF anchor(0, 0); | 3586 gfx::PointF anchor(0, 0); |
| 3587 gfx::PointF position(0, 0); | 3587 gfx::PointF position(0, 0); |
| 3588 gfx::Size bounds(100, 100); | 3588 gfx::Size bounds(100, 100); |
| 3589 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc
hor, position, bounds, false); | 3589 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc
hor, position, bounds, false); |
| 3590 root->SetDrawsContent(true); | 3590 root->SetDrawsContent(true); |
| 3591 | 3591 |
| 3592 { | 3592 { |
| 3593 // child 1 and child2 are initialized to overlap between x=50 and x=60. | 3593 // child 1 and child2 are initialized to overlap between x=50 and x=60. |
| 3594 // grandChild is set to overlap both child1 and child2 between y=50 and
y=60. | 3594 // grandChild is set to overlap both child1 and child2 between y=50 and
y=60. |
| 3595 // The expected stacking order is: | 3595 // The expected stacking order is: |
| 3596 // (front) child2, (second) grandChild, (third) child1, and (back) the
root layer behind all other layers. | 3596 // (front) child2, (second) grandChild, (third) child1, and (back) the
root layer behind all other layers. |
| 3597 | 3597 |
| 3598 scoped_ptr<LayerImpl> child1 = LayerImpl::Create(hostImpl.activeTree(),
2); | 3598 scoped_ptr<LayerImpl> child1 = LayerImpl::Create(hostImpl.active_tree(),
2); |
| 3599 scoped_ptr<LayerImpl> child2 = LayerImpl::Create(hostImpl.activeTree(),
3); | 3599 scoped_ptr<LayerImpl> child2 = LayerImpl::Create(hostImpl.active_tree(),
3); |
| 3600 scoped_ptr<LayerImpl> grandChild1 = LayerImpl::Create(hostImpl.activeTre
e(), 4); | 3600 scoped_ptr<LayerImpl> grandChild1 = LayerImpl::Create(hostImpl.active_tr
ee(), 4); |
| 3601 | 3601 |
| 3602 position = gfx::PointF(10, 10); | 3602 position = gfx::PointF(10, 10); |
| 3603 bounds = gfx::Size(50, 50); | 3603 bounds = gfx::Size(50, 50); |
| 3604 setLayerPropertiesForTesting(child1.get(), identityMatrix, identityMatri
x, anchor, position, bounds, false); | 3604 setLayerPropertiesForTesting(child1.get(), identityMatrix, identityMatri
x, anchor, position, bounds, false); |
| 3605 child1->SetDrawsContent(true); | 3605 child1->SetDrawsContent(true); |
| 3606 | 3606 |
| 3607 position = gfx::PointF(50, 10); | 3607 position = gfx::PointF(50, 10); |
| 3608 bounds = gfx::Size(50, 50); | 3608 bounds = gfx::Size(50, 50); |
| 3609 setLayerPropertiesForTesting(child2.get(), identityMatrix, identityMatri
x, anchor, position, bounds, false); | 3609 setLayerPropertiesForTesting(child2.get(), identityMatrix, identityMatri
x, anchor, position, bounds, false); |
| 3610 child2->SetDrawsContent(true); | 3610 child2->SetDrawsContent(true); |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3678 } | 3678 } |
| 3679 | 3679 |
| 3680 TEST(LayerTreeHostCommonTest, verifyHitTestingForMultipleLayerLists) | 3680 TEST(LayerTreeHostCommonTest, verifyHitTestingForMultipleLayerLists) |
| 3681 { | 3681 { |
| 3682 // | 3682 // |
| 3683 // The geometry is set up similarly to the previous case, but | 3683 // The geometry is set up similarly to the previous case, but |
| 3684 // all layers are forced to be renderSurfaces now. | 3684 // all layers are forced to be renderSurfaces now. |
| 3685 // | 3685 // |
| 3686 FakeImplProxy proxy; | 3686 FakeImplProxy proxy; |
| 3687 FakeLayerTreeHostImpl hostImpl(&proxy); | 3687 FakeLayerTreeHostImpl hostImpl(&proxy); |
| 3688 scoped_ptr<LayerImpl> root = LayerImpl::Create(hostImpl.activeTree(), 1); | 3688 scoped_ptr<LayerImpl> root = LayerImpl::Create(hostImpl.active_tree(), 1); |
| 3689 | 3689 |
| 3690 gfx::Transform identityMatrix; | 3690 gfx::Transform identityMatrix; |
| 3691 gfx::PointF anchor(0, 0); | 3691 gfx::PointF anchor(0, 0); |
| 3692 gfx::PointF position(0, 0); | 3692 gfx::PointF position(0, 0); |
| 3693 gfx::Size bounds(100, 100); | 3693 gfx::Size bounds(100, 100); |
| 3694 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc
hor, position, bounds, false); | 3694 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc
hor, position, bounds, false); |
| 3695 root->SetDrawsContent(true); | 3695 root->SetDrawsContent(true); |
| 3696 | 3696 |
| 3697 { | 3697 { |
| 3698 // child 1 and child2 are initialized to overlap between x=50 and x=60. | 3698 // child 1 and child2 are initialized to overlap between x=50 and x=60. |
| 3699 // grandChild is set to overlap both child1 and child2 between y=50 and
y=60. | 3699 // grandChild is set to overlap both child1 and child2 between y=50 and
y=60. |
| 3700 // The expected stacking order is: | 3700 // The expected stacking order is: |
| 3701 // (front) child2, (second) grandChild, (third) child1, and (back) the
root layer behind all other layers. | 3701 // (front) child2, (second) grandChild, (third) child1, and (back) the
root layer behind all other layers. |
| 3702 | 3702 |
| 3703 scoped_ptr<LayerImpl> child1 = LayerImpl::Create(hostImpl.activeTree(),
2); | 3703 scoped_ptr<LayerImpl> child1 = LayerImpl::Create(hostImpl.active_tree(),
2); |
| 3704 scoped_ptr<LayerImpl> child2 = LayerImpl::Create(hostImpl.activeTree(),
3); | 3704 scoped_ptr<LayerImpl> child2 = LayerImpl::Create(hostImpl.active_tree(),
3); |
| 3705 scoped_ptr<LayerImpl> grandChild1 = LayerImpl::Create(hostImpl.activeTre
e(), 4); | 3705 scoped_ptr<LayerImpl> grandChild1 = LayerImpl::Create(hostImpl.active_tr
ee(), 4); |
| 3706 | 3706 |
| 3707 position = gfx::PointF(10, 10); | 3707 position = gfx::PointF(10, 10); |
| 3708 bounds = gfx::Size(50, 50); | 3708 bounds = gfx::Size(50, 50); |
| 3709 setLayerPropertiesForTesting(child1.get(), identityMatrix, identityMatri
x, anchor, position, bounds, false); | 3709 setLayerPropertiesForTesting(child1.get(), identityMatrix, identityMatri
x, anchor, position, bounds, false); |
| 3710 child1->SetDrawsContent(true); | 3710 child1->SetDrawsContent(true); |
| 3711 child1->SetForceRenderSurface(true); | 3711 child1->SetForceRenderSurface(true); |
| 3712 | 3712 |
| 3713 position = gfx::PointF(50, 10); | 3713 position = gfx::PointF(50, 10); |
| 3714 bounds = gfx::Size(50, 50); | 3714 bounds = gfx::Size(50, 50); |
| 3715 setLayerPropertiesForTesting(child2.get(), identityMatrix, identityMatri
x, anchor, position, bounds, false); | 3715 setLayerPropertiesForTesting(child2.get(), identityMatrix, identityMatri
x, anchor, position, bounds, false); |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3802 | 3802 |
| 3803 testPoint = gfx::Point(10, 20); | 3803 testPoint = gfx::Point(10, 20); |
| 3804 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPointInTouchHandlerRe
gion(testPoint, renderSurfaceLayerList); | 3804 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPointInTouchHandlerRe
gion(testPoint, renderSurfaceLayerList); |
| 3805 EXPECT_FALSE(resultLayer); | 3805 EXPECT_FALSE(resultLayer); |
| 3806 } | 3806 } |
| 3807 | 3807 |
| 3808 TEST(LayerTreeHostCommonTest, verifyHitCheckingTouchHandlerRegionsForSingleLayer
) | 3808 TEST(LayerTreeHostCommonTest, verifyHitCheckingTouchHandlerRegionsForSingleLayer
) |
| 3809 { | 3809 { |
| 3810 FakeImplProxy proxy; | 3810 FakeImplProxy proxy; |
| 3811 FakeLayerTreeHostImpl hostImpl(&proxy); | 3811 FakeLayerTreeHostImpl hostImpl(&proxy); |
| 3812 scoped_ptr<LayerImpl> root = LayerImpl::Create(hostImpl.activeTree(), 12345)
; | 3812 scoped_ptr<LayerImpl> root = LayerImpl::Create(hostImpl.active_tree(), 12345
); |
| 3813 | 3813 |
| 3814 gfx::Transform identityMatrix; | 3814 gfx::Transform identityMatrix; |
| 3815 Region touchHandlerRegion(gfx::Rect(10, 10, 50, 50)); | 3815 Region touchHandlerRegion(gfx::Rect(10, 10, 50, 50)); |
| 3816 gfx::PointF anchor(0, 0); | 3816 gfx::PointF anchor(0, 0); |
| 3817 gfx::PointF position(0, 0); | 3817 gfx::PointF position(0, 0); |
| 3818 gfx::Size bounds(100, 100); | 3818 gfx::Size bounds(100, 100); |
| 3819 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc
hor, position, bounds, false); | 3819 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc
hor, position, bounds, false); |
| 3820 root->SetDrawsContent(true); | 3820 root->SetDrawsContent(true); |
| 3821 | 3821 |
| 3822 std::vector<LayerImpl*> renderSurfaceLayerList; | 3822 std::vector<LayerImpl*> renderSurfaceLayerList; |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3860 testPoint = gfx::Point(59, 59); | 3860 testPoint = gfx::Point(59, 59); |
| 3861 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPointInTouchHandlerRe
gion(testPoint, renderSurfaceLayerList); | 3861 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPointInTouchHandlerRe
gion(testPoint, renderSurfaceLayerList); |
| 3862 ASSERT_TRUE(resultLayer); | 3862 ASSERT_TRUE(resultLayer); |
| 3863 EXPECT_EQ(12345, resultLayer->id()); | 3863 EXPECT_EQ(12345, resultLayer->id()); |
| 3864 } | 3864 } |
| 3865 | 3865 |
| 3866 TEST(LayerTreeHostCommonTest, verifyHitCheckingTouchHandlerRegionsForUninvertibl
eTransform) | 3866 TEST(LayerTreeHostCommonTest, verifyHitCheckingTouchHandlerRegionsForUninvertibl
eTransform) |
| 3867 { | 3867 { |
| 3868 FakeImplProxy proxy; | 3868 FakeImplProxy proxy; |
| 3869 FakeLayerTreeHostImpl hostImpl(&proxy); | 3869 FakeLayerTreeHostImpl hostImpl(&proxy); |
| 3870 scoped_ptr<LayerImpl> root = LayerImpl::Create(hostImpl.activeTree(), 12345)
; | 3870 scoped_ptr<LayerImpl> root = LayerImpl::Create(hostImpl.active_tree(), 12345
); |
| 3871 | 3871 |
| 3872 gfx::Transform uninvertibleTransform; | 3872 gfx::Transform uninvertibleTransform; |
| 3873 uninvertibleTransform.matrix().setDouble(0, 0, 0); | 3873 uninvertibleTransform.matrix().setDouble(0, 0, 0); |
| 3874 uninvertibleTransform.matrix().setDouble(1, 1, 0); | 3874 uninvertibleTransform.matrix().setDouble(1, 1, 0); |
| 3875 uninvertibleTransform.matrix().setDouble(2, 2, 0); | 3875 uninvertibleTransform.matrix().setDouble(2, 2, 0); |
| 3876 uninvertibleTransform.matrix().setDouble(3, 3, 0); | 3876 uninvertibleTransform.matrix().setDouble(3, 3, 0); |
| 3877 ASSERT_FALSE(uninvertibleTransform.IsInvertible()); | 3877 ASSERT_FALSE(uninvertibleTransform.IsInvertible()); |
| 3878 | 3878 |
| 3879 gfx::Transform identityMatrix; | 3879 gfx::Transform identityMatrix; |
| 3880 Region touchHandlerRegion(gfx::Rect(10, 10, 50, 50)); | 3880 Region touchHandlerRegion(gfx::Rect(10, 10, 50, 50)); |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3923 | 3923 |
| 3924 testPoint = gfx::Point(-1, -1); | 3924 testPoint = gfx::Point(-1, -1); |
| 3925 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPointInTouchHandlerRe
gion(testPoint, renderSurfaceLayerList); | 3925 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPointInTouchHandlerRe
gion(testPoint, renderSurfaceLayerList); |
| 3926 EXPECT_FALSE(resultLayer); | 3926 EXPECT_FALSE(resultLayer); |
| 3927 } | 3927 } |
| 3928 | 3928 |
| 3929 TEST(LayerTreeHostCommonTest, verifyHitCheckingTouchHandlerRegionsForSinglePosit
ionedLayer) | 3929 TEST(LayerTreeHostCommonTest, verifyHitCheckingTouchHandlerRegionsForSinglePosit
ionedLayer) |
| 3930 { | 3930 { |
| 3931 FakeImplProxy proxy; | 3931 FakeImplProxy proxy; |
| 3932 FakeLayerTreeHostImpl hostImpl(&proxy); | 3932 FakeLayerTreeHostImpl hostImpl(&proxy); |
| 3933 scoped_ptr<LayerImpl> root = LayerImpl::Create(hostImpl.activeTree(), 12345)
; | 3933 scoped_ptr<LayerImpl> root = LayerImpl::Create(hostImpl.active_tree(), 12345
); |
| 3934 | 3934 |
| 3935 gfx::Transform identityMatrix; | 3935 gfx::Transform identityMatrix; |
| 3936 Region touchHandlerRegion(gfx::Rect(10, 10, 50, 50)); | 3936 Region touchHandlerRegion(gfx::Rect(10, 10, 50, 50)); |
| 3937 gfx::PointF anchor(0, 0); | 3937 gfx::PointF anchor(0, 0); |
| 3938 gfx::PointF position(50, 50); // this layer is positioned, and hit testing s
hould correctly know where the layer is located. | 3938 gfx::PointF position(50, 50); // this layer is positioned, and hit testing s
hould correctly know where the layer is located. |
| 3939 gfx::Size bounds(100, 100); | 3939 gfx::Size bounds(100, 100); |
| 3940 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc
hor, position, bounds, false); | 3940 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc
hor, position, bounds, false); |
| 3941 root->SetDrawsContent(true); | 3941 root->SetDrawsContent(true); |
| 3942 root->SetTouchEventHandlerRegion(touchHandlerRegion); | 3942 root->SetTouchEventHandlerRegion(touchHandlerRegion); |
| 3943 | 3943 |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3983 // test makes sure that hit testing works correctly accounts for the content
s scale. | 3983 // test makes sure that hit testing works correctly accounts for the content
s scale. |
| 3984 // A contentsScale that is not 1 effectively forces a non-identity transform
between | 3984 // A contentsScale that is not 1 effectively forces a non-identity transform
between |
| 3985 // layer's content space and layer's origin space. The hit testing code must
take this into account. | 3985 // layer's content space and layer's origin space. The hit testing code must
take this into account. |
| 3986 // | 3986 // |
| 3987 // To test this, the layer is positioned at (25, 25), and is size (50, 50).
If | 3987 // To test this, the layer is positioned at (25, 25), and is size (50, 50).
If |
| 3988 // contentsScale is ignored, then hit checking will mis-interpret the visibl
eContentRect | 3988 // contentsScale is ignored, then hit checking will mis-interpret the visibl
eContentRect |
| 3989 // as being larger than the actual bounds of the layer. | 3989 // as being larger than the actual bounds of the layer. |
| 3990 // | 3990 // |
| 3991 FakeImplProxy proxy; | 3991 FakeImplProxy proxy; |
| 3992 FakeLayerTreeHostImpl hostImpl(&proxy); | 3992 FakeLayerTreeHostImpl hostImpl(&proxy); |
| 3993 scoped_ptr<LayerImpl> root = LayerImpl::Create(hostImpl.activeTree(), 1); | 3993 scoped_ptr<LayerImpl> root = LayerImpl::Create(hostImpl.active_tree(), 1); |
| 3994 | 3994 |
| 3995 gfx::Transform identityMatrix; | 3995 gfx::Transform identityMatrix; |
| 3996 gfx::PointF anchor(0, 0); | 3996 gfx::PointF anchor(0, 0); |
| 3997 | 3997 |
| 3998 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc
hor, gfx::PointF(0, 0), gfx::Size(100, 100), false); | 3998 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc
hor, gfx::PointF(0, 0), gfx::Size(100, 100), false); |
| 3999 | 3999 |
| 4000 { | 4000 { |
| 4001 Region touchHandlerRegion(gfx::Rect(10, 10, 30, 30)); | 4001 Region touchHandlerRegion(gfx::Rect(10, 10, 30, 30)); |
| 4002 gfx::PointF position(25, 25); | 4002 gfx::PointF position(25, 25); |
| 4003 gfx::Size bounds(50, 50); | 4003 gfx::Size bounds(50, 50); |
| 4004 scoped_ptr<LayerImpl> testLayer = LayerImpl::Create(hostImpl.activeTree(
), 12345); | 4004 scoped_ptr<LayerImpl> testLayer = LayerImpl::Create(hostImpl.active_tree
(), 12345); |
| 4005 setLayerPropertiesForTesting(testLayer.get(), identityMatrix, identityMa
trix, anchor, position, bounds, false); | 4005 setLayerPropertiesForTesting(testLayer.get(), identityMatrix, identityMa
trix, anchor, position, bounds, false); |
| 4006 | 4006 |
| 4007 // override contentBounds and contentsScale | 4007 // override contentBounds and contentsScale |
| 4008 testLayer->SetContentBounds(gfx::Size(100, 100)); | 4008 testLayer->SetContentBounds(gfx::Size(100, 100)); |
| 4009 testLayer->SetContentsScale(2, 2); | 4009 testLayer->SetContentsScale(2, 2); |
| 4010 | 4010 |
| 4011 testLayer->SetDrawsContent(true); | 4011 testLayer->SetDrawsContent(true); |
| 4012 testLayer->SetTouchEventHandlerRegion(touchHandlerRegion); | 4012 testLayer->SetTouchEventHandlerRegion(touchHandlerRegion); |
| 4013 root->AddChild(testLayer.Pass()); | 4013 root->AddChild(testLayer.Pass()); |
| 4014 } | 4014 } |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4057 ASSERT_TRUE(resultLayer); | 4057 ASSERT_TRUE(resultLayer); |
| 4058 EXPECT_EQ(12345, resultLayer->id()); | 4058 EXPECT_EQ(12345, resultLayer->id()); |
| 4059 } | 4059 } |
| 4060 | 4060 |
| 4061 TEST(LayerTreeHostCommonTest, verifyHitCheckingTouchHandlerRegionsForSingleLayer
WithDeviceScale) | 4061 TEST(LayerTreeHostCommonTest, verifyHitCheckingTouchHandlerRegionsForSingleLayer
WithDeviceScale) |
| 4062 { | 4062 { |
| 4063 // The layer's deviceScalefactor and pageScaleFactor should scale the conten
tRect and we should | 4063 // The layer's deviceScalefactor and pageScaleFactor should scale the conten
tRect and we should |
| 4064 // be able to hit the touch handler region by scaling the points accordingly
. | 4064 // be able to hit the touch handler region by scaling the points accordingly
. |
| 4065 FakeImplProxy proxy; | 4065 FakeImplProxy proxy; |
| 4066 FakeLayerTreeHostImpl hostImpl(&proxy); | 4066 FakeLayerTreeHostImpl hostImpl(&proxy); |
| 4067 scoped_ptr<LayerImpl> root = LayerImpl::Create(hostImpl.activeTree(), 1); | 4067 scoped_ptr<LayerImpl> root = LayerImpl::Create(hostImpl.active_tree(), 1); |
| 4068 | 4068 |
| 4069 gfx::Transform identityMatrix; | 4069 gfx::Transform identityMatrix; |
| 4070 gfx::PointF anchor(0, 0); | 4070 gfx::PointF anchor(0, 0); |
| 4071 // Set the bounds of the root layer big enough to fit the child when scaled. | 4071 // Set the bounds of the root layer big enough to fit the child when scaled. |
| 4072 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc
hor, gfx::PointF(0, 0), gfx::Size(100, 100), false); | 4072 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc
hor, gfx::PointF(0, 0), gfx::Size(100, 100), false); |
| 4073 | 4073 |
| 4074 { | 4074 { |
| 4075 Region touchHandlerRegion(gfx::Rect(10, 10, 30, 30)); | 4075 Region touchHandlerRegion(gfx::Rect(10, 10, 30, 30)); |
| 4076 gfx::PointF position(25, 25); | 4076 gfx::PointF position(25, 25); |
| 4077 gfx::Size bounds(50, 50); | 4077 gfx::Size bounds(50, 50); |
| 4078 scoped_ptr<LayerImpl> testLayer = LayerImpl::Create(hostImpl.activeTree(
), 12345); | 4078 scoped_ptr<LayerImpl> testLayer = LayerImpl::Create(hostImpl.active_tree
(), 12345); |
| 4079 setLayerPropertiesForTesting(testLayer.get(), identityMatrix, identityMa
trix, anchor, position, bounds, false); | 4079 setLayerPropertiesForTesting(testLayer.get(), identityMatrix, identityMa
trix, anchor, position, bounds, false); |
| 4080 | 4080 |
| 4081 testLayer->SetDrawsContent(true); | 4081 testLayer->SetDrawsContent(true); |
| 4082 testLayer->SetTouchEventHandlerRegion(touchHandlerRegion); | 4082 testLayer->SetTouchEventHandlerRegion(touchHandlerRegion); |
| 4083 root->AddChild(testLayer.Pass()); | 4083 root->AddChild(testLayer.Pass()); |
| 4084 } | 4084 } |
| 4085 | 4085 |
| 4086 std::vector<LayerImpl*> renderSurfaceLayerList; | 4086 std::vector<LayerImpl*> renderSurfaceLayerList; |
| 4087 int dummyMaxTextureSize = 512; | 4087 int dummyMaxTextureSize = 512; |
| 4088 float deviceScaleFactor = 3.0f; | 4088 float deviceScaleFactor = 3.0f; |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4145 | 4145 |
| 4146 TEST(LayerTreeHostCommonTest, verifyHitCheckingTouchHandlerRegionsForSimpleClipp
edLayer) | 4146 TEST(LayerTreeHostCommonTest, verifyHitCheckingTouchHandlerRegionsForSimpleClipp
edLayer) |
| 4147 { | 4147 { |
| 4148 // Test that hit-checking will only work for the visible portion of a layer,
and not | 4148 // Test that hit-checking will only work for the visible portion of a layer,
and not |
| 4149 // the entire layer bounds. Here we just test the simple axis-aligned case. | 4149 // the entire layer bounds. Here we just test the simple axis-aligned case. |
| 4150 gfx::Transform identityMatrix; | 4150 gfx::Transform identityMatrix; |
| 4151 gfx::PointF anchor(0, 0); | 4151 gfx::PointF anchor(0, 0); |
| 4152 | 4152 |
| 4153 FakeImplProxy proxy; | 4153 FakeImplProxy proxy; |
| 4154 FakeLayerTreeHostImpl hostImpl(&proxy); | 4154 FakeLayerTreeHostImpl hostImpl(&proxy); |
| 4155 scoped_ptr<LayerImpl> root = LayerImpl::Create(hostImpl.activeTree(), 1); | 4155 scoped_ptr<LayerImpl> root = LayerImpl::Create(hostImpl.active_tree(), 1); |
| 4156 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc
hor, gfx::PointF(0, 0), gfx::Size(100, 100), false); | 4156 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc
hor, gfx::PointF(0, 0), gfx::Size(100, 100), false); |
| 4157 | 4157 |
| 4158 { | 4158 { |
| 4159 scoped_ptr<LayerImpl> clippingLayer = LayerImpl::Create(hostImpl.activeT
ree(), 123); | 4159 scoped_ptr<LayerImpl> clippingLayer = LayerImpl::Create(hostImpl.active_
tree(), 123); |
| 4160 gfx::PointF position(25, 25); // this layer is positioned, and hit testi
ng should correctly know where the layer is located. | 4160 gfx::PointF position(25, 25); // this layer is positioned, and hit testi
ng should correctly know where the layer is located. |
| 4161 gfx::Size bounds(50, 50); | 4161 gfx::Size bounds(50, 50); |
| 4162 setLayerPropertiesForTesting(clippingLayer.get(), identityMatrix, identi
tyMatrix, anchor, position, bounds, false); | 4162 setLayerPropertiesForTesting(clippingLayer.get(), identityMatrix, identi
tyMatrix, anchor, position, bounds, false); |
| 4163 clippingLayer->SetMasksToBounds(true); | 4163 clippingLayer->SetMasksToBounds(true); |
| 4164 | 4164 |
| 4165 scoped_ptr<LayerImpl> child = LayerImpl::Create(hostImpl.activeTree(), 4
56); | 4165 scoped_ptr<LayerImpl> child = LayerImpl::Create(hostImpl.active_tree(),
456); |
| 4166 Region touchHandlerRegion(gfx::Rect(10, 10, 50, 50)); | 4166 Region touchHandlerRegion(gfx::Rect(10, 10, 50, 50)); |
| 4167 position = gfx::PointF(-50, -50); | 4167 position = gfx::PointF(-50, -50); |
| 4168 bounds = gfx::Size(300, 300); | 4168 bounds = gfx::Size(300, 300); |
| 4169 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix
, anchor, position, bounds, false); | 4169 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix
, anchor, position, bounds, false); |
| 4170 child->SetDrawsContent(true); | 4170 child->SetDrawsContent(true); |
| 4171 child->SetTouchEventHandlerRegion(touchHandlerRegion); | 4171 child->SetTouchEventHandlerRegion(touchHandlerRegion); |
| 4172 clippingLayer->AddChild(child.Pass()); | 4172 clippingLayer->AddChild(child.Pass()); |
| 4173 root->AddChild(clippingLayer.Pass()); | 4173 root->AddChild(clippingLayer.Pass()); |
| 4174 } | 4174 } |
| 4175 | 4175 |
| (...skipping 966 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5142 EXPECT_EQ(m_canUseLCDText, m_grandChild->can_use_lcd_text()); | 5142 EXPECT_EQ(m_canUseLCDText, m_grandChild->can_use_lcd_text()); |
| 5143 } | 5143 } |
| 5144 | 5144 |
| 5145 INSTANTIATE_TEST_CASE_P(LayerTreeHostCommonTest, | 5145 INSTANTIATE_TEST_CASE_P(LayerTreeHostCommonTest, |
| 5146 LCDTextTest, | 5146 LCDTextTest, |
| 5147 testing::Combine(testing::Bool(), | 5147 testing::Combine(testing::Bool(), |
| 5148 testing::Bool())); | 5148 testing::Bool())); |
| 5149 | 5149 |
| 5150 } // namespace | 5150 } // namespace |
| 5151 } // namespace cc | 5151 } // namespace cc |
| OLD | NEW |