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/trees/layer_tree_host_impl.h" | 5 #include "cc/trees/layer_tree_host_impl.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <cmath> | 10 #include <cmath> |
(...skipping 6242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6253 SetScrollOffsetDelta(child_ptr, gfx::Vector2dF()); | 6253 SetScrollOffsetDelta(child_ptr, gfx::Vector2dF()); |
6254 gfx::Vector2d gesture_scroll_delta(10, 0); | 6254 gfx::Vector2d gesture_scroll_delta(10, 0); |
6255 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 6255 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
6256 host_impl_ | 6256 host_impl_ |
6257 ->ScrollBegin(BeginState(gfx::Point(1, 1)).get(), | 6257 ->ScrollBegin(BeginState(gfx::Point(1, 1)).get(), |
6258 InputHandler::TOUCHSCREEN) | 6258 InputHandler::TOUCHSCREEN) |
6259 .thread); | 6259 .thread); |
6260 host_impl_->ScrollBy(UpdateState(gfx::Point(), gesture_scroll_delta).get()); | 6260 host_impl_->ScrollBy(UpdateState(gfx::Point(), gesture_scroll_delta).get()); |
6261 host_impl_->ScrollEnd(EndState().get()); | 6261 host_impl_->ScrollEnd(EndState().get()); |
6262 | 6262 |
6263 // The child layer shouldn't have scrolled. | 6263 // The child layer should have scrolled down in its local coordinates an |
| 6264 // amount proportional to the angle between it and the input scroll delta. |
6264 gfx::Vector2d expected_scroll_delta( | 6265 gfx::Vector2d expected_scroll_delta( |
6265 0, -gesture_scroll_delta.x() * | 6266 0, -gesture_scroll_delta.x() * |
6266 std::sin(MathUtil::Deg2Rad(child_layer_angle))); | 6267 std::sin(MathUtil::Deg2Rad(child_layer_angle))); |
6267 std::unique_ptr<ScrollAndScaleSet> scroll_info = | 6268 std::unique_ptr<ScrollAndScaleSet> scroll_info = |
6268 host_impl_->ProcessScrollDeltas(); | 6269 host_impl_->ProcessScrollDeltas(); |
6269 EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(), child_scroll_id, | 6270 EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(), child_scroll_id, |
6270 expected_scroll_delta)); | 6271 expected_scroll_delta)); |
6271 | 6272 |
6272 // The root scroll layer shouldn't have scrolled. | 6273 // The root scroll layer shouldn't have scrolled. |
6273 ExpectNone(*scroll_info.get(), scroll_layer->element_id()); | 6274 ExpectNone(*scroll_info.get(), scroll_layer->element_id()); |
(...skipping 4666 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10940 scrolling_layer->CurrentScrollOffset()); | 10941 scrolling_layer->CurrentScrollOffset()); |
10941 EXPECT_EQ(nullptr, host_impl_->CurrentlyScrollingNode()); | 10942 EXPECT_EQ(nullptr, host_impl_->CurrentlyScrollingNode()); |
10942 host_impl_->DidFinishImplFrame(); | 10943 host_impl_->DidFinishImplFrame(); |
10943 } | 10944 } |
10944 | 10945 |
10945 TEST_F(LayerTreeHostImplTest, SecondScrollAnimatedBeginNotIgnored) { | 10946 TEST_F(LayerTreeHostImplTest, SecondScrollAnimatedBeginNotIgnored) { |
10946 const gfx::Size content_size(1000, 1000); | 10947 const gfx::Size content_size(1000, 1000); |
10947 const gfx::Size viewport_size(50, 100); | 10948 const gfx::Size viewport_size(50, 100); |
10948 CreateBasicVirtualViewportLayers(viewport_size, content_size); | 10949 CreateBasicVirtualViewportLayers(viewport_size, content_size); |
10949 | 10950 |
10950 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 10951 EXPECT_EQ( |
10951 host_impl_->ScrollAnimatedBegin(gfx::Point()).thread); | 10952 InputHandler::SCROLL_ON_IMPL_THREAD, |
| 10953 host_impl_->ScrollAnimatedBegin(BeginState(gfx::Point()).get()).thread); |
10952 | 10954 |
10953 // The second ScrollAnimatedBegin should not get ignored. | 10955 // The second ScrollAnimatedBegin should not get ignored. |
10954 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 10956 EXPECT_EQ( |
10955 host_impl_->ScrollAnimatedBegin(gfx::Point()).thread); | 10957 InputHandler::SCROLL_ON_IMPL_THREAD, |
| 10958 host_impl_->ScrollAnimatedBegin(BeginState(gfx::Point()).get()).thread); |
10956 } | 10959 } |
10957 | 10960 |
10958 // Verfify that a smooth scroll animation doesn't jump when UpdateTarget gets | 10961 // Verfify that a smooth scroll animation doesn't jump when UpdateTarget gets |
10959 // called before the animation is started. | 10962 // called before the animation is started. |
10960 TEST_F(LayerTreeHostImplTest, AnimatedScrollUpdateTargetBeforeStarting) { | 10963 TEST_F(LayerTreeHostImplTest, AnimatedScrollUpdateTargetBeforeStarting) { |
10961 const gfx::Size content_size(1000, 1000); | 10964 const gfx::Size content_size(1000, 1000); |
10962 const gfx::Size viewport_size(50, 100); | 10965 const gfx::Size viewport_size(50, 100); |
10963 CreateBasicVirtualViewportLayers(viewport_size, content_size); | 10966 CreateBasicVirtualViewportLayers(viewport_size, content_size); |
10964 | 10967 |
10965 DrawFrame(); | 10968 DrawFrame(); |
(...skipping 1709 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12675 // layer should be prioritized over the hidden layer. | 12678 // layer should be prioritized over the hidden layer. |
12676 hidden_layer->set_contributes_to_drawn_render_surface(false); | 12679 hidden_layer->set_contributes_to_drawn_render_surface(false); |
12677 hidden_layer->set_raster_even_if_not_drawn(true); | 12680 hidden_layer->set_raster_even_if_not_drawn(true); |
12678 queue = host_impl_->BuildRasterQueue(TreePriority::SMOOTHNESS_TAKES_PRIORITY, | 12681 queue = host_impl_->BuildRasterQueue(TreePriority::SMOOTHNESS_TAKES_PRIORITY, |
12679 RasterTilePriorityQueue::Type::ALL); | 12682 RasterTilePriorityQueue::Type::ALL); |
12680 EXPECT_EQ(queue->Top().tile()->layer_id(), 3); | 12683 EXPECT_EQ(queue->Top().tile()->layer_id(), 3); |
12681 } | 12684 } |
12682 | 12685 |
12683 } // namespace | 12686 } // namespace |
12684 } // namespace cc | 12687 } // namespace cc |
OLD | NEW |