| 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 1409 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1438 | 1441 |
| 1439 { | 1442 { |
| 1440 // Scroll down in screen coordinates with a gesture. | 1443 // Scroll down in screen coordinates with a gesture. |
| 1441 gfx::Vector2d gestureScrollDelta(0, 10); | 1444 gfx::Vector2d gestureScrollDelta(0, 10); |
| 1442 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(0, 0), InputHandlerClient::
Gesture), InputHandlerClient::ScrollStarted); | 1445 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(0, 0), InputHandlerClient::
Gesture), InputHandlerClient::ScrollStarted); |
| 1443 m_hostImpl->scrollBy(gfx::Point(), gestureScrollDelta); | 1446 m_hostImpl->scrollBy(gfx::Point(), gestureScrollDelta); |
| 1444 m_hostImpl->scrollEnd(); | 1447 m_hostImpl->scrollEnd(); |
| 1445 | 1448 |
| 1446 // The child layer should have scrolled down in its local coordinates an
amount proportional to | 1449 // The child layer should have scrolled down in its local coordinates an
amount proportional to |
| 1447 // the angle between it and the input scroll delta. | 1450 // the angle between it and the input scroll delta. |
| 1448 gfx::Vector2d expectedScrollDelta(0, gestureScrollDelta.y() * cosf(deg2r
ad(childLayerAngle))); | 1451 gfx::Vector2d expectedScrollDelta(0, gestureScrollDelta.y() * std::cos(M
athUtil::Deg2Rad(childLayerAngle))); |
| 1449 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDelt
as(); | 1452 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDelt
as(); |
| 1450 expectContains(*scrollInfo.get(), childLayerId, expectedScrollDelta); | 1453 expectContains(*scrollInfo.get(), childLayerId, expectedScrollDelta); |
| 1451 | 1454 |
| 1452 // The root layer should not have scrolled, because the input delta was
close to the layer's | 1455 // The root layer should not have scrolled, because the input delta was
close to the layer's |
| 1453 // axis of movement. | 1456 // axis of movement. |
| 1454 EXPECT_EQ(scrollInfo->scrolls.size(), 1u); | 1457 EXPECT_EQ(scrollInfo->scrolls.size(), 1u); |
| 1455 } | 1458 } |
| 1456 | 1459 |
| 1457 { | 1460 { |
| 1458 // Now reset and scroll the same amount horizontally. | 1461 // Now reset and scroll the same amount horizontally. |
| 1459 m_hostImpl->rootLayer()->children()[1]->setScrollDelta(gfx::Vector2dF())
; | 1462 m_hostImpl->rootLayer()->children()[1]->setScrollDelta(gfx::Vector2dF())
; |
| 1460 gfx::Vector2d gestureScrollDelta(10, 0); | 1463 gfx::Vector2d gestureScrollDelta(10, 0); |
| 1461 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(0, 0), InputHandlerClient::
Gesture), InputHandlerClient::ScrollStarted); | 1464 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(0, 0), InputHandlerClient::
Gesture), InputHandlerClient::ScrollStarted); |
| 1462 m_hostImpl->scrollBy(gfx::Point(), gestureScrollDelta); | 1465 m_hostImpl->scrollBy(gfx::Point(), gestureScrollDelta); |
| 1463 m_hostImpl->scrollEnd(); | 1466 m_hostImpl->scrollEnd(); |
| 1464 | 1467 |
| 1465 // The child layer should have scrolled down in its local coordinates an
amount proportional to | 1468 // The child layer should have scrolled down in its local coordinates an
amount proportional to |
| 1466 // the angle between it and the input scroll delta. | 1469 // the angle between it and the input scroll delta. |
| 1467 gfx::Vector2d expectedScrollDelta(0, -gestureScrollDelta.x() * sinf(deg2
rad(childLayerAngle))); | 1470 gfx::Vector2d expectedScrollDelta(0, -gestureScrollDelta.x() * std::sin(
MathUtil::Deg2Rad(childLayerAngle))); |
| 1468 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDelt
as(); | 1471 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDelt
as(); |
| 1469 expectContains(*scrollInfo.get(), childLayerId, expectedScrollDelta); | 1472 expectContains(*scrollInfo.get(), childLayerId, expectedScrollDelta); |
| 1470 | 1473 |
| 1471 // The root layer should have scrolled more, since the input scroll delt
a was mostly | 1474 // The root layer should have scrolled more, since the input scroll delt
a was mostly |
| 1472 // orthogonal to the child layer's vertical scroll axis. | 1475 // orthogonal to the child layer's vertical scroll axis. |
| 1473 gfx::Vector2d expectedRootScrollDelta(gestureScrollDelta.x() * pow(cosf(
deg2rad(childLayerAngle)), 2), 0); | 1476 gfx::Vector2d expectedRootScrollDelta(gestureScrollDelta.x() * std::pow(
std::cos(MathUtil::Deg2Rad(childLayerAngle)), 2), 0); |
| 1474 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), expecte
dRootScrollDelta); | 1477 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), expecte
dRootScrollDelta); |
| 1475 } | 1478 } |
| 1476 } | 1479 } |
| 1477 | 1480 |
| 1478 TEST_P(LayerTreeHostImplTest, scrollScaledLayer) | 1481 TEST_P(LayerTreeHostImplTest, scrollScaledLayer) |
| 1479 { | 1482 { |
| 1480 setupScrollAndContentsLayers(gfx::Size(100, 100)); | 1483 setupScrollAndContentsLayers(gfx::Size(100, 100)); |
| 1481 | 1484 |
| 1482 // Scale the layer to twice its normal size. | 1485 // Scale the layer to twice its normal size. |
| 1483 int scale = 2; | 1486 int scale = 2; |
| (...skipping 2920 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4404 verifyRenderPassTestData(removeRenderPassesCases[testCaseIndex], testDat
a); | 4407 verifyRenderPassTestData(removeRenderPassesCases[testCaseIndex], testDat
a); |
| 4405 testCaseIndex++; | 4408 testCaseIndex++; |
| 4406 } | 4409 } |
| 4407 } | 4410 } |
| 4408 | 4411 |
| 4409 INSTANTIATE_TEST_CASE_P(LayerTreeHostImplTests, | 4412 INSTANTIATE_TEST_CASE_P(LayerTreeHostImplTests, |
| 4410 LayerTreeHostImplTest, | 4413 LayerTreeHostImplTest, |
| 4411 ::testing::Values(false, true)); | 4414 ::testing::Values(false, true)); |
| 4412 | 4415 |
| 4413 } // anonymous namespace | 4416 } // anonymous namespace |
| OLD | NEW |