OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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.h" | 5 #include "cc/trees/layer_tree_host.h" |
6 | 6 |
7 #include "base/memory/weak_ptr.h" | 7 #include "base/memory/weak_ptr.h" |
8 #include "cc/layers/layer.h" | 8 #include "cc/layers/layer.h" |
9 #include "cc/layers/layer_impl.h" | 9 #include "cc/layers/layer_impl.h" |
10 #include "cc/layers/picture_layer.h" | 10 #include "cc/layers/picture_layer.h" |
(...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
422 | 422 |
423 // Check that a fractional scroll delta is correctly accumulated over | 423 // Check that a fractional scroll delta is correctly accumulated over |
424 // multiple commits. | 424 // multiple commits. |
425 switch (impl->active_tree()->source_frame_number()) { | 425 switch (impl->active_tree()->source_frame_number()) { |
426 case 0: | 426 case 0: |
427 EXPECT_VECTOR_EQ(scroll_layer->BaseScrollOffset(), gfx::Vector2d(0, 0)); | 427 EXPECT_VECTOR_EQ(scroll_layer->BaseScrollOffset(), gfx::Vector2d(0, 0)); |
428 EXPECT_VECTOR_EQ(scroll_layer->ScrollDelta(), gfx::Vector2d(0, 0)); | 428 EXPECT_VECTOR_EQ(scroll_layer->ScrollDelta(), gfx::Vector2d(0, 0)); |
429 PostSetNeedsCommitToMainThread(); | 429 PostSetNeedsCommitToMainThread(); |
430 break; | 430 break; |
431 case 1: | 431 case 1: |
432 EXPECT_VECTOR_EQ(scroll_layer->BaseScrollOffset(), scroll_amount_); | 432 EXPECT_VECTOR_EQ(scroll_layer->BaseScrollOffset(), |
433 EXPECT_VECTOR_EQ(scroll_layer->ScrollDelta(), gfx::Vector2dF()); | 433 gfx::ToFlooredVector2d(scroll_amount_)); |
| 434 EXPECT_VECTOR_EQ(scroll_layer->ScrollDelta(), |
| 435 gfx::Vector2dF(fmod(scroll_amount_.x(), 1.0f), 0.0f)); |
434 PostSetNeedsCommitToMainThread(); | 436 PostSetNeedsCommitToMainThread(); |
435 break; | 437 break; |
436 case 2: | 438 case 2: |
437 EXPECT_VECTOR_EQ(scroll_layer->BaseScrollOffset(), | 439 EXPECT_VECTOR_EQ( |
438 (scroll_amount_ + scroll_amount_)); | 440 scroll_layer->BaseScrollOffset(), |
439 EXPECT_VECTOR_EQ(scroll_layer->ScrollDelta(), gfx::Vector2dF()); | 441 gfx::ToFlooredVector2d(scroll_amount_ + scroll_amount_)); |
| 442 EXPECT_VECTOR_EQ( |
| 443 scroll_layer->ScrollDelta(), |
| 444 gfx::Vector2dF(fmod(2.0f * scroll_amount_.x(), 1.0f), 0.0f)); |
440 EndTest(); | 445 EndTest(); |
441 break; | 446 break; |
442 } | 447 } |
443 scroll_layer->ScrollBy(scroll_amount_); | 448 scroll_layer->ScrollBy(scroll_amount_); |
444 } | 449 } |
445 | 450 |
446 void AfterTest() override {} | 451 void AfterTest() override {} |
447 | 452 |
448 private: | 453 private: |
449 gfx::Vector2dF scroll_amount_; | 454 gfx::Vector2dF scroll_amount_; |
(...skipping 664 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1114 bool received_stop_flinging = false; | 1119 bool received_stop_flinging = false; |
1115 LayerTreeSettings settings; | 1120 LayerTreeSettings settings; |
1116 | 1121 |
1117 ThreadCheckingInputHandlerClient input_handler_client( | 1122 ThreadCheckingInputHandlerClient input_handler_client( |
1118 impl_thread.message_loop_proxy().get(), &received_stop_flinging); | 1123 impl_thread.message_loop_proxy().get(), &received_stop_flinging); |
1119 FakeLayerTreeHostClient client(FakeLayerTreeHostClient::DIRECT_3D); | 1124 FakeLayerTreeHostClient client(FakeLayerTreeHostClient::DIRECT_3D); |
1120 | 1125 |
1121 ASSERT_TRUE(impl_thread.message_loop_proxy().get()); | 1126 ASSERT_TRUE(impl_thread.message_loop_proxy().get()); |
1122 scoped_ptr<SharedBitmapManager> shared_bitmap_manager( | 1127 scoped_ptr<SharedBitmapManager> shared_bitmap_manager( |
1123 new TestSharedBitmapManager()); | 1128 new TestSharedBitmapManager()); |
1124 scoped_ptr<LayerTreeHost> layer_tree_host = | 1129 scoped_ptr<LayerTreeHost> layer_tree_host = LayerTreeHost::CreateThreaded( |
1125 LayerTreeHost::CreateThreaded(&client, | 1130 &client, shared_bitmap_manager.get(), NULL, NULL, settings, |
1126 shared_bitmap_manager.get(), | 1131 base::MessageLoopProxy::current(), impl_thread.message_loop_proxy(), |
1127 NULL, | 1132 nullptr); |
1128 settings, | |
1129 base::MessageLoopProxy::current(), | |
1130 impl_thread.message_loop_proxy(), | |
1131 nullptr); | |
1132 | 1133 |
1133 impl_thread.message_loop_proxy() | 1134 impl_thread.message_loop_proxy() |
1134 ->PostTask(FROM_HERE, | 1135 ->PostTask(FROM_HERE, |
1135 base::Bind(&BindInputHandlerOnCompositorThread, | 1136 base::Bind(&BindInputHandlerOnCompositorThread, |
1136 layer_tree_host->GetInputHandler(), | 1137 layer_tree_host->GetInputHandler(), |
1137 base::Unretained(&input_handler_client))); | 1138 base::Unretained(&input_handler_client))); |
1138 | 1139 |
1139 layer_tree_host->DidStopFlinging(); | 1140 layer_tree_host->DidStopFlinging(); |
1140 layer_tree_host = nullptr; | 1141 layer_tree_host = nullptr; |
1141 impl_thread.Stop(); | 1142 impl_thread.Stop(); |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1229 RunTest(true, false, true); | 1230 RunTest(true, false, true); |
1230 } | 1231 } |
1231 | 1232 |
1232 TEST_F(LayerTreeHostScrollTestLayerStructureChange, ScrollDestroyWholeTree) { | 1233 TEST_F(LayerTreeHostScrollTestLayerStructureChange, ScrollDestroyWholeTree) { |
1233 scroll_destroy_whole_tree_ = true; | 1234 scroll_destroy_whole_tree_ = true; |
1234 RunTest(true, false, true); | 1235 RunTest(true, false, true); |
1235 } | 1236 } |
1236 | 1237 |
1237 } // namespace | 1238 } // namespace |
1238 } // namespace cc | 1239 } // namespace cc |
OLD | NEW |