Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(455)

Side by Side Diff: cc/trees/layer_tree_host_unittest_scroll.cc

Issue 2511473003: Round the scroll offset synced back to main instead of flooring. (Closed)
Patch Set: Wait for scroll animation to complete before checking main thread scrolling reasons. Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cc/trees/layer_tree_host_impl_unittest.cc ('k') | cc/trees/property_tree.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/location.h" 7 #include "base/location.h"
8 #include "base/memory/weak_ptr.h" 8 #include "base/memory/weak_ptr.h"
9 #include "base/single_thread_task_runner.h" 9 #include "base/single_thread_task_runner.h"
10 #include "base/threading/thread_task_runner_handle.h" 10 #include "base/threading/thread_task_runner_handle.h"
(...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after
455 case 0: 455 case 0:
456 EXPECT_VECTOR_EQ( 456 EXPECT_VECTOR_EQ(
457 gfx::Vector2d(0, 0), 457 gfx::Vector2d(0, 0),
458 ScrollTreeForLayer(scroll_layer) 458 ScrollTreeForLayer(scroll_layer)
459 ->GetScrollOffsetBaseForTesting(scroll_layer->id())); 459 ->GetScrollOffsetBaseForTesting(scroll_layer->id()));
460 EXPECT_VECTOR_EQ(gfx::Vector2d(0, 0), ScrollDelta(scroll_layer)); 460 EXPECT_VECTOR_EQ(gfx::Vector2d(0, 0), ScrollDelta(scroll_layer));
461 PostSetNeedsCommitToMainThread(); 461 PostSetNeedsCommitToMainThread();
462 break; 462 break;
463 case 1: 463 case 1:
464 EXPECT_VECTOR_EQ( 464 EXPECT_VECTOR_EQ(
465 gfx::ToFlooredVector2d(scroll_amount_), 465 gfx::ToRoundedVector2d(scroll_amount_),
466 ScrollTreeForLayer(scroll_layer) 466 ScrollTreeForLayer(scroll_layer)
467 ->GetScrollOffsetBaseForTesting(scroll_layer->id())); 467 ->GetScrollOffsetBaseForTesting(scroll_layer->id()));
468 EXPECT_VECTOR_EQ(gfx::Vector2dF(fmod(scroll_amount_.x(), 1.0f), 0.0f), 468 EXPECT_VECTOR_EQ(
469 ScrollDelta(scroll_layer)); 469 scroll_amount_ - gfx::ToRoundedVector2d(scroll_amount_),
470 ScrollDelta(scroll_layer));
470 PostSetNeedsCommitToMainThread(); 471 PostSetNeedsCommitToMainThread();
471 break; 472 break;
472 case 2: 473 case 2:
473 EXPECT_VECTOR_EQ( 474 EXPECT_VECTOR_EQ(
474 gfx::ToFlooredVector2d(scroll_amount_ + scroll_amount_), 475 gfx::ToRoundedVector2d(scroll_amount_ + scroll_amount_),
475 ScrollTreeForLayer(scroll_layer) 476 ScrollTreeForLayer(scroll_layer)
476 ->GetScrollOffsetBaseForTesting(scroll_layer->id())); 477 ->GetScrollOffsetBaseForTesting(scroll_layer->id()));
477 EXPECT_VECTOR_EQ( 478 EXPECT_VECTOR_EQ(
478 gfx::Vector2dF(fmod(2.0f * scroll_amount_.x(), 1.0f), 0.0f), 479 scroll_amount_ + scroll_amount_ -
480 gfx::ToRoundedVector2d(scroll_amount_ + scroll_amount_),
479 ScrollDelta(scroll_layer)); 481 ScrollDelta(scroll_layer));
480 EndTest(); 482 EndTest();
481 break; 483 break;
482 } 484 }
483 scroll_layer->ScrollBy(scroll_amount_); 485 scroll_layer->ScrollBy(scroll_amount_);
484 } 486 }
485 487
486 void AfterTest() override {} 488 void AfterTest() override {}
487 489
488 private: 490 private:
(...skipping 1748 matching lines...) Expand 10 before | Expand all | Expand 10 after
2237 2239
2238 const float initial_page_scale_ = 0.5f; 2240 const float initial_page_scale_ = 0.5f;
2239 const float page_scale_update_ = 0.2f; 2241 const float page_scale_update_ = 0.2f;
2240 }; 2242 };
2241 2243
2242 // The reflected deltas are supported in threaded mode only. 2244 // The reflected deltas are supported in threaded mode only.
2243 MULTI_THREAD_TEST_F(LayerTreeHostScrollTestAppliesReflectedDeltas); 2245 MULTI_THREAD_TEST_F(LayerTreeHostScrollTestAppliesReflectedDeltas);
2244 2246
2245 } // namespace 2247 } // namespace
2246 } // namespace cc 2248 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_host_impl_unittest.cc ('k') | cc/trees/property_tree.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698