OLD | NEW |
1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "config.h" | 5 #include "config.h" |
6 | 6 |
7 #include "cc/layer_tree_host_impl.h" | 7 #include "cc/layer_tree_host_impl.h" |
8 | 8 |
| 9 #include <cmath> |
| 10 |
9 #include "base/bind.h" | 11 #include "base/bind.h" |
10 #include "base/command_line.h" | 12 #include "base/command_line.h" |
11 #include "base/hash_tables.h" | 13 #include "base/hash_tables.h" |
12 #include "cc/delegated_renderer_layer_impl.h" | 14 #include "cc/delegated_renderer_layer_impl.h" |
13 #include "cc/geometry.h" | 15 #include "cc/geometry.h" |
14 #include "cc/gl_renderer.h" | 16 #include "cc/gl_renderer.h" |
15 #include "cc/heads_up_display_layer_impl.h" | 17 #include "cc/heads_up_display_layer_impl.h" |
16 #include "cc/io_surface_layer_impl.h" | 18 #include "cc/io_surface_layer_impl.h" |
17 #include "cc/layer_impl.h" | 19 #include "cc/layer_impl.h" |
18 #include "cc/layer_tiling_data.h" | 20 #include "cc/layer_tiling_data.h" |
| 21 #include "cc/math_util.h" |
19 #include "cc/quad_sink.h" | 22 #include "cc/quad_sink.h" |
20 #include "cc/render_pass_draw_quad.h" | 23 #include "cc/render_pass_draw_quad.h" |
21 #include "cc/scrollbar_geometry_fixed_thumb.h" | 24 #include "cc/scrollbar_geometry_fixed_thumb.h" |
22 #include "cc/scrollbar_layer_impl.h" | 25 #include "cc/scrollbar_layer_impl.h" |
23 #include "cc/settings.h" | 26 #include "cc/settings.h" |
24 #include "cc/single_thread_proxy.h" | 27 #include "cc/single_thread_proxy.h" |
25 #include "cc/solid_color_draw_quad.h" | 28 #include "cc/solid_color_draw_quad.h" |
26 #include "cc/test/animation_test_common.h" | 29 #include "cc/test/animation_test_common.h" |
27 #include "cc/test/fake_web_compositor_output_surface.h" | 30 #include "cc/test/fake_web_compositor_output_surface.h" |
28 #include "cc/test/fake_web_graphics_context_3d.h" | 31 #include "cc/test/fake_web_graphics_context_3d.h" |
(...skipping 1413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1442 | 1445 |
1443 { | 1446 { |
1444 // Scroll down in screen coordinates with a gesture. | 1447 // Scroll down in screen coordinates with a gesture. |
1445 gfx::Vector2d gestureScrollDelta(0, 10); | 1448 gfx::Vector2d gestureScrollDelta(0, 10); |
1446 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(0, 0), InputHandlerClient::
Gesture), InputHandlerClient::ScrollStarted); | 1449 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(0, 0), InputHandlerClient::
Gesture), InputHandlerClient::ScrollStarted); |
1447 m_hostImpl->scrollBy(gfx::Point(), gestureScrollDelta); | 1450 m_hostImpl->scrollBy(gfx::Point(), gestureScrollDelta); |
1448 m_hostImpl->scrollEnd(); | 1451 m_hostImpl->scrollEnd(); |
1449 | 1452 |
1450 // The child layer should have scrolled down in its local coordinates an
amount proportional to | 1453 // The child layer should have scrolled down in its local coordinates an
amount proportional to |
1451 // the angle between it and the input scroll delta. | 1454 // the angle between it and the input scroll delta. |
1452 gfx::Vector2d expectedScrollDelta(0, gestureScrollDelta.y() * cosf(deg2r
ad(childLayerAngle))); | 1455 gfx::Vector2d expectedScrollDelta(0, gestureScrollDelta.y() * std::cos(M
athUtil::Deg2Rad(childLayerAngle))); |
1453 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDelt
as(); | 1456 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDelt
as(); |
1454 expectContains(*scrollInfo.get(), childLayerId, expectedScrollDelta); | 1457 expectContains(*scrollInfo.get(), childLayerId, expectedScrollDelta); |
1455 | 1458 |
1456 // The root layer should not have scrolled, because the input delta was
close to the layer's | 1459 // The root layer should not have scrolled, because the input delta was
close to the layer's |
1457 // axis of movement. | 1460 // axis of movement. |
1458 EXPECT_EQ(scrollInfo->scrolls.size(), 1u); | 1461 EXPECT_EQ(scrollInfo->scrolls.size(), 1u); |
1459 } | 1462 } |
1460 | 1463 |
1461 { | 1464 { |
1462 // Now reset and scroll the same amount horizontally. | 1465 // Now reset and scroll the same amount horizontally. |
1463 m_hostImpl->rootLayer()->children()[1]->setScrollDelta(gfx::Vector2dF())
; | 1466 m_hostImpl->rootLayer()->children()[1]->setScrollDelta(gfx::Vector2dF())
; |
1464 gfx::Vector2d gestureScrollDelta(10, 0); | 1467 gfx::Vector2d gestureScrollDelta(10, 0); |
1465 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(0, 0), InputHandlerClient::
Gesture), InputHandlerClient::ScrollStarted); | 1468 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(0, 0), InputHandlerClient::
Gesture), InputHandlerClient::ScrollStarted); |
1466 m_hostImpl->scrollBy(gfx::Point(), gestureScrollDelta); | 1469 m_hostImpl->scrollBy(gfx::Point(), gestureScrollDelta); |
1467 m_hostImpl->scrollEnd(); | 1470 m_hostImpl->scrollEnd(); |
1468 | 1471 |
1469 // The child layer should have scrolled down in its local coordinates an
amount proportional to | 1472 // The child layer should have scrolled down in its local coordinates an
amount proportional to |
1470 // the angle between it and the input scroll delta. | 1473 // the angle between it and the input scroll delta. |
1471 gfx::Vector2d expectedScrollDelta(0, -gestureScrollDelta.x() * sinf(deg2
rad(childLayerAngle))); | 1474 gfx::Vector2d expectedScrollDelta(0, -gestureScrollDelta.x() * std::sin(
MathUtil::Deg2Rad(childLayerAngle))); |
1472 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDelt
as(); | 1475 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDelt
as(); |
1473 expectContains(*scrollInfo.get(), childLayerId, expectedScrollDelta); | 1476 expectContains(*scrollInfo.get(), childLayerId, expectedScrollDelta); |
1474 | 1477 |
1475 // The root layer should have scrolled more, since the input scroll delt
a was mostly | 1478 // The root layer should have scrolled more, since the input scroll delt
a was mostly |
1476 // orthogonal to the child layer's vertical scroll axis. | 1479 // orthogonal to the child layer's vertical scroll axis. |
1477 gfx::Vector2d expectedRootScrollDelta(gestureScrollDelta.x() * pow(cosf(
deg2rad(childLayerAngle)), 2), 0); | 1480 gfx::Vector2d expectedRootScrollDelta(gestureScrollDelta.x() * std::pow(
std::cos(MathUtil::Deg2Rad(childLayerAngle)), 2), 0); |
1478 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), expecte
dRootScrollDelta); | 1481 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), expecte
dRootScrollDelta); |
1479 } | 1482 } |
1480 } | 1483 } |
1481 | 1484 |
1482 TEST_P(LayerTreeHostImplTest, scrollScaledLayer) | 1485 TEST_P(LayerTreeHostImplTest, scrollScaledLayer) |
1483 { | 1486 { |
1484 setupScrollAndContentsLayers(gfx::Size(100, 100)); | 1487 setupScrollAndContentsLayers(gfx::Size(100, 100)); |
1485 | 1488 |
1486 // Scale the layer to twice its normal size. | 1489 // Scale the layer to twice its normal size. |
1487 int scale = 2; | 1490 int scale = 2; |
(...skipping 2920 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4408 verifyRenderPassTestData(removeRenderPassesCases[testCaseIndex], testDat
a); | 4411 verifyRenderPassTestData(removeRenderPassesCases[testCaseIndex], testDat
a); |
4409 testCaseIndex++; | 4412 testCaseIndex++; |
4410 } | 4413 } |
4411 } | 4414 } |
4412 | 4415 |
4413 INSTANTIATE_TEST_CASE_P(LayerTreeHostImplTests, | 4416 INSTANTIATE_TEST_CASE_P(LayerTreeHostImplTests, |
4414 LayerTreeHostImplTest, | 4417 LayerTreeHostImplTest, |
4415 ::testing::Values(false, true)); | 4418 ::testing::Values(false, true)); |
4416 | 4419 |
4417 } // anonymous namespace | 4420 } // anonymous namespace |
OLD | NEW |