| 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/layer.h" | 10 #include "cc/layer.h" |
| 10 #include "cc/layer_animation_controller.h" | 11 #include "cc/layer_animation_controller.h" |
| 11 #include "cc/layer_impl.h" | 12 #include "cc/layer_impl.h" |
| 13 #include "cc/layer_tree_impl.h" |
| 12 #include "cc/math_util.h" | 14 #include "cc/math_util.h" |
| 13 #include "cc/proxy.h" | 15 #include "cc/proxy.h" |
| 14 #include "cc/single_thread_proxy.h" | 16 #include "cc/single_thread_proxy.h" |
| 15 #include "cc/test/animation_test_common.h" | 17 #include "cc/test/animation_test_common.h" |
| 16 #include "cc/test/fake_impl_proxy.h" | 18 #include "cc/test/fake_impl_proxy.h" |
| 17 #include "cc/test/fake_layer_tree_host_impl.h" | 19 #include "cc/test/fake_layer_tree_host_impl.h" |
| 18 #include "cc/test/geometry_test_utils.h" | 20 #include "cc/test/geometry_test_utils.h" |
| 19 #include "cc/thread.h" | 21 #include "cc/thread.h" |
| 20 #include "testing/gmock/include/gmock/gmock.h" | 22 #include "testing/gmock/include/gmock/gmock.h" |
| 21 #include "testing/gtest/include/gtest/gtest.h" | 23 #include "testing/gtest/include/gtest/gtest.h" |
| (...skipping 2933 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2955 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); | 2957 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); |
| 2956 ASSERT_TRUE(resultLayer); | 2958 ASSERT_TRUE(resultLayer); |
| 2957 EXPECT_EQ(12345, resultLayer->id()); | 2959 EXPECT_EQ(12345, resultLayer->id()); |
| 2958 | 2960 |
| 2959 testPoint = gfx::Point(99, 99); | 2961 testPoint = gfx::Point(99, 99); |
| 2960 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); | 2962 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); |
| 2961 ASSERT_TRUE(resultLayer); | 2963 ASSERT_TRUE(resultLayer); |
| 2962 EXPECT_EQ(12345, resultLayer->id()); | 2964 EXPECT_EQ(12345, resultLayer->id()); |
| 2963 } | 2965 } |
| 2964 | 2966 |
| 2967 TEST(LayerTreeHostCommonTest, verifyHitTestingForSingleLayerAndHud) |
| 2968 { |
| 2969 FakeImplProxy proxy; |
| 2970 FakeLayerTreeHostImpl hostImpl(&proxy); |
| 2971 scoped_ptr<LayerImpl> root = LayerImpl::create(hostImpl.activeTree(), 12345)
; |
| 2972 scoped_ptr<HeadsUpDisplayLayerImpl> hud = HeadsUpDisplayLayerImpl::create(ho
stImpl.activeTree(), 11111); |
| 2973 |
| 2974 gfx::Transform identityMatrix; |
| 2975 gfx::PointF anchor(0.f, 0.f); |
| 2976 gfx::PointF position(0.f, 0.f); |
| 2977 gfx::Size bounds(100, 100); |
| 2978 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc
hor, position, bounds, false); |
| 2979 root->setDrawsContent(true); |
| 2980 |
| 2981 // Create hud and add it as a child of root. |
| 2982 gfx::Size hudBounds(200, 200); |
| 2983 setLayerPropertiesForTesting(hud.get(), identityMatrix, identityMatrix, anch
or, position, hudBounds, false); |
| 2984 hud->setDrawsContent(true); |
| 2985 |
| 2986 hostImpl.activeTree()->set_hud_layer(hud.get()); |
| 2987 root->addChild(hud.PassAs<LayerImpl>()); |
| 2988 |
| 2989 std::vector<LayerImpl*> renderSurfaceLayerList; |
| 2990 int dummyMaxTextureSize = 512; |
| 2991 LayerTreeHostCommon::calculateDrawProperties(root.get(), hudBounds, 1, 1, du
mmyMaxTextureSize, false, renderSurfaceLayerList, false); |
| 2992 |
| 2993 // Sanity check the scenario we just created. |
| 2994 ASSERT_EQ(1u, renderSurfaceLayerList.size()); |
| 2995 ASSERT_EQ(2u, root->renderSurface()->layerList().size()); |
| 2996 |
| 2997 // Hit testing for a point inside HUD, but outside root should return null |
| 2998 gfx::Point testPoint(101, 101); |
| 2999 LayerImpl* resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(test
Point, renderSurfaceLayerList); |
| 3000 EXPECT_FALSE(resultLayer); |
| 3001 |
| 3002 testPoint = gfx::Point(-1, -1); |
| 3003 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); |
| 3004 EXPECT_FALSE(resultLayer); |
| 3005 |
| 3006 // Hit testing for a point inside should return the root layer, never the HU
D layer. |
| 3007 testPoint = gfx::Point(1, 1); |
| 3008 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); |
| 3009 ASSERT_TRUE(resultLayer); |
| 3010 EXPECT_EQ(12345, resultLayer->id()); |
| 3011 |
| 3012 testPoint = gfx::Point(99, 99); |
| 3013 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); |
| 3014 ASSERT_TRUE(resultLayer); |
| 3015 EXPECT_EQ(12345, resultLayer->id()); |
| 3016 } |
| 3017 |
| 2965 TEST(LayerTreeHostCommonTest, verifyHitTestingForUninvertibleTransform) | 3018 TEST(LayerTreeHostCommonTest, verifyHitTestingForUninvertibleTransform) |
| 2966 { | 3019 { |
| 2967 FakeImplProxy proxy; | 3020 FakeImplProxy proxy; |
| 2968 FakeLayerTreeHostImpl hostImpl(&proxy); | 3021 FakeLayerTreeHostImpl hostImpl(&proxy); |
| 2969 scoped_ptr<LayerImpl> root = LayerImpl::create(hostImpl.activeTree(), 12345)
; | 3022 scoped_ptr<LayerImpl> root = LayerImpl::create(hostImpl.activeTree(), 12345)
; |
| 2970 | 3023 |
| 2971 gfx::Transform uninvertibleTransform; | 3024 gfx::Transform uninvertibleTransform; |
| 2972 uninvertibleTransform.matrix().setDouble(0, 0, 0); | 3025 uninvertibleTransform.matrix().setDouble(0, 0, 0); |
| 2973 uninvertibleTransform.matrix().setDouble(1, 1, 0); | 3026 uninvertibleTransform.matrix().setDouble(1, 1, 0); |
| 2974 uninvertibleTransform.matrix().setDouble(2, 2, 0); | 3027 uninvertibleTransform.matrix().setDouble(2, 2, 0); |
| (...skipping 2062 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5037 EXPECT_EQ(m_canUseLCDText, m_grandChild->canUseLCDText()); | 5090 EXPECT_EQ(m_canUseLCDText, m_grandChild->canUseLCDText()); |
| 5038 } | 5091 } |
| 5039 | 5092 |
| 5040 INSTANTIATE_TEST_CASE_P(LayerTreeHostCommonTest, | 5093 INSTANTIATE_TEST_CASE_P(LayerTreeHostCommonTest, |
| 5041 LCDTextTest, | 5094 LCDTextTest, |
| 5042 testing::Combine(testing::Bool(), | 5095 testing::Combine(testing::Bool(), |
| 5043 testing::Bool())); | 5096 testing::Bool())); |
| 5044 | 5097 |
| 5045 } // namespace | 5098 } // namespace |
| 5046 } // namespace cc | 5099 } // namespace cc |
| OLD | NEW |