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 373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
384 scoped_ptr<LayerImpl> layer = | 384 scoped_ptr<LayerImpl> layer = |
385 LayerImpl::Create(host_impl_->active_tree(), id); | 385 LayerImpl::Create(host_impl_->active_tree(), id); |
386 layer->SetScrollClipLayer(clip_layer->id()); | 386 layer->SetScrollClipLayer(clip_layer->id()); |
387 layer->SetDrawsContent(true); | 387 layer->SetDrawsContent(true); |
388 layer->SetBounds(size); | 388 layer->SetBounds(size); |
389 clip_layer->SetBounds(gfx::Size(size.width() / 2, size.height() / 2)); | 389 clip_layer->SetBounds(gfx::Size(size.width() / 2, size.height() / 2)); |
390 return layer; | 390 return layer; |
391 } | 391 } |
392 | 392 |
393 scoped_ptr<ScrollState> BeginState(const gfx::Point& point) { | 393 scoped_ptr<ScrollState> BeginState(const gfx::Point& point) { |
394 return ScrollState::Create(gfx::Vector2dF(), point, gfx::Vector2dF(), true, | 394 ScrollStateData scroll_state_data; |
395 false, false); | 395 scroll_state_data.is_beginning = true; |
| 396 scroll_state_data.start_position_x = point.x(); |
| 397 scroll_state_data.start_position_y = point.y(); |
| 398 scoped_ptr<ScrollState> scroll_state(new ScrollState(scroll_state_data)); |
| 399 return scroll_state; |
396 } | 400 } |
397 | 401 |
398 scoped_ptr<ScrollState> UpdateState(const gfx::Point& point, | 402 scoped_ptr<ScrollState> UpdateState(const gfx::Point& point, |
399 const gfx::Vector2dF& delta) { | 403 const gfx::Vector2dF& delta) { |
400 return ScrollState::Create(delta, point, gfx::Vector2dF(), false, false, | 404 ScrollStateData scroll_state_data; |
401 false); | 405 scroll_state_data.delta_x = delta.x(); |
| 406 scroll_state_data.delta_y = delta.y(); |
| 407 scroll_state_data.start_position_x = point.x(); |
| 408 scroll_state_data.start_position_y = point.y(); |
| 409 scoped_ptr<ScrollState> scroll_state(new ScrollState(scroll_state_data)); |
| 410 return scroll_state; |
402 } | 411 } |
403 | 412 |
404 scoped_ptr<ScrollState> EndState() { | 413 scoped_ptr<ScrollState> EndState() { |
405 return ScrollState::Create(gfx::Vector2dF(), gfx::Point(), gfx::Vector2dF(), | 414 ScrollStateData scroll_state_data; |
406 false, false, true); | 415 scroll_state_data.is_ending = true; |
| 416 scoped_ptr<ScrollState> scroll_state(new ScrollState(scroll_state_data)); |
| 417 return scroll_state; |
407 } | 418 } |
408 | 419 |
409 void DrawFrame() { | 420 void DrawFrame() { |
410 LayerTreeHostImpl::FrameData frame; | 421 LayerTreeHostImpl::FrameData frame; |
411 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); | 422 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); |
412 host_impl_->DrawLayers(&frame); | 423 host_impl_->DrawLayers(&frame); |
413 host_impl_->DidDrawAllLayers(frame); | 424 host_impl_->DidDrawAllLayers(frame); |
414 } | 425 } |
415 | 426 |
416 void RebuildPropertyTrees() { | 427 void RebuildPropertyTrees() { |
(...skipping 8835 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9252 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 9263 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
9253 host_impl_->ScrollBegin(BeginState(gfx::Point(0, y)).get(), | 9264 host_impl_->ScrollBegin(BeginState(gfx::Point(0, y)).get(), |
9254 InputHandler::WHEEL) | 9265 InputHandler::WHEEL) |
9255 .thread); | 9266 .thread); |
9256 EXPECT_TRUE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(0, y), | 9267 EXPECT_TRUE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(0, y), |
9257 InputHandler::WHEEL)); | 9268 InputHandler::WHEEL)); |
9258 host_impl_->ScrollBy( | 9269 host_impl_->ScrollBy( |
9259 UpdateState(gfx::Point(0, y), gfx::Vector2d(0, 50)).get()); | 9270 UpdateState(gfx::Point(0, y), gfx::Vector2d(0, 50)).get()); |
9260 EXPECT_TRUE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(0, y + 50), | 9271 EXPECT_TRUE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(0, y + 50), |
9261 InputHandler::WHEEL)); | 9272 InputHandler::WHEEL)); |
9262 ScrollState scroll_state_end(0, 0, 0 /* start_position_x */, | 9273 scoped_ptr<ScrollState> scroll_state_end = EndState(); |
9263 y + 50 /* start_position_y */, 0, 0, false, | 9274 host_impl_->ScrollEnd(scroll_state_end.get()); |
9264 false, true); | |
9265 host_impl_->ScrollEnd(&scroll_state_end); | |
9266 EXPECT_FALSE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(), | 9275 EXPECT_FALSE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(), |
9267 InputHandler::WHEEL)); | 9276 InputHandler::WHEEL)); |
9268 | 9277 |
9269 // The instant scroll should have marked the smooth scroll animation as | 9278 // The instant scroll should have marked the smooth scroll animation as |
9270 // aborted. | 9279 // aborted. |
9271 EXPECT_FALSE( | 9280 EXPECT_FALSE( |
9272 host_impl_->animation_host()->HasActiveAnimation(scrolling_layer->id())); | 9281 host_impl_->animation_host()->HasActiveAnimation(scrolling_layer->id())); |
9273 | 9282 |
9274 EXPECT_VECTOR2DF_EQ(gfx::ScrollOffset(0, y + 50), | 9283 EXPECT_VECTOR2DF_EQ(gfx::ScrollOffset(0, y + 50), |
9275 scrolling_layer->CurrentScrollOffset()); | 9284 scrolling_layer->CurrentScrollOffset()); |
(...skipping 687 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9963 // There should not be any jitter measured till we hit the fixed point hits | 9972 // There should not be any jitter measured till we hit the fixed point hits |
9964 // threshold. | 9973 // threshold. |
9965 float expected_jitter = | 9974 float expected_jitter = |
9966 (i == pending_tree->kFixedPointHitsThreshold) ? 500 : 0; | 9975 (i == pending_tree->kFixedPointHitsThreshold) ? 500 : 0; |
9967 EXPECT_EQ(jitter, expected_jitter); | 9976 EXPECT_EQ(jitter, expected_jitter); |
9968 } | 9977 } |
9969 } | 9978 } |
9970 | 9979 |
9971 } // namespace | 9980 } // namespace |
9972 } // namespace cc | 9981 } // namespace cc |
OLD | NEW |