| 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 4662 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10936 scrolling_layer->CurrentScrollOffset()); | 10937 scrolling_layer->CurrentScrollOffset()); |
| 10937 EXPECT_EQ(nullptr, host_impl_->CurrentlyScrollingNode()); | 10938 EXPECT_EQ(nullptr, host_impl_->CurrentlyScrollingNode()); |
| 10938 host_impl_->DidFinishImplFrame(); | 10939 host_impl_->DidFinishImplFrame(); |
| 10939 } | 10940 } |
| 10940 | 10941 |
| 10941 TEST_F(LayerTreeHostImplTest, SecondScrollAnimatedBeginNotIgnored) { | 10942 TEST_F(LayerTreeHostImplTest, SecondScrollAnimatedBeginNotIgnored) { |
| 10942 const gfx::Size content_size(1000, 1000); | 10943 const gfx::Size content_size(1000, 1000); |
| 10943 const gfx::Size viewport_size(50, 100); | 10944 const gfx::Size viewport_size(50, 100); |
| 10944 CreateBasicVirtualViewportLayers(viewport_size, content_size); | 10945 CreateBasicVirtualViewportLayers(viewport_size, content_size); |
| 10945 | 10946 |
| 10946 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 10947 EXPECT_EQ( |
| 10947 host_impl_->ScrollAnimatedBegin(gfx::Point()).thread); | 10948 InputHandler::SCROLL_ON_IMPL_THREAD, |
| 10949 host_impl_->ScrollAnimatedBegin(BeginState(gfx::Point()).get()).thread); |
| 10948 | 10950 |
| 10949 // The second ScrollAnimatedBegin should not get ignored. | 10951 // The second ScrollAnimatedBegin should not get ignored. |
| 10950 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 10952 EXPECT_EQ( |
| 10951 host_impl_->ScrollAnimatedBegin(gfx::Point()).thread); | 10953 InputHandler::SCROLL_ON_IMPL_THREAD, |
| 10954 host_impl_->ScrollAnimatedBegin(BeginState(gfx::Point()).get()).thread); |
| 10952 } | 10955 } |
| 10953 | 10956 |
| 10954 // Verfify that a smooth scroll animation doesn't jump when UpdateTarget gets | 10957 // Verfify that a smooth scroll animation doesn't jump when UpdateTarget gets |
| 10955 // called before the animation is started. | 10958 // called before the animation is started. |
| 10956 TEST_F(LayerTreeHostImplTest, AnimatedScrollUpdateTargetBeforeStarting) { | 10959 TEST_F(LayerTreeHostImplTest, AnimatedScrollUpdateTargetBeforeStarting) { |
| 10957 const gfx::Size content_size(1000, 1000); | 10960 const gfx::Size content_size(1000, 1000); |
| 10958 const gfx::Size viewport_size(50, 100); | 10961 const gfx::Size viewport_size(50, 100); |
| 10959 CreateBasicVirtualViewportLayers(viewport_size, content_size); | 10962 CreateBasicVirtualViewportLayers(viewport_size, content_size); |
| 10960 | 10963 |
| 10961 DrawFrame(); | 10964 DrawFrame(); |
| (...skipping 1700 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12662 // layer should be prioritized over the hidden layer. | 12665 // layer should be prioritized over the hidden layer. |
| 12663 hidden_layer->set_contributes_to_drawn_render_surface(false); | 12666 hidden_layer->set_contributes_to_drawn_render_surface(false); |
| 12664 hidden_layer->set_raster_even_if_not_drawn(true); | 12667 hidden_layer->set_raster_even_if_not_drawn(true); |
| 12665 queue = host_impl_->BuildRasterQueue(TreePriority::SMOOTHNESS_TAKES_PRIORITY, | 12668 queue = host_impl_->BuildRasterQueue(TreePriority::SMOOTHNESS_TAKES_PRIORITY, |
| 12666 RasterTilePriorityQueue::Type::ALL); | 12669 RasterTilePriorityQueue::Type::ALL); |
| 12667 EXPECT_EQ(queue->Top().tile()->layer_id(), 3); | 12670 EXPECT_EQ(queue->Top().tile()->layer_id(), 3); |
| 12668 } | 12671 } |
| 12669 | 12672 |
| 12670 } // namespace | 12673 } // namespace |
| 12671 } // namespace cc | 12674 } // namespace cc |
| OLD | NEW |