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

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

Issue 1979273002: cc: Use to_screen transform for scroll offset snapping (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Minor change in unit test Created 4 years, 7 months 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 | « no previous file | 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 479 matching lines...) Expand 10 before | Expand all | Expand 10 after
490 } 490 }
491 491
492 void AfterTest() override {} 492 void AfterTest() override {}
493 493
494 private: 494 private:
495 gfx::Vector2dF scroll_amount_; 495 gfx::Vector2dF scroll_amount_;
496 }; 496 };
497 497
498 MULTI_THREAD_TEST_F(LayerTreeHostScrollTestFractionalScroll); 498 MULTI_THREAD_TEST_F(LayerTreeHostScrollTestFractionalScroll);
499 499
500 class LayerTreeHostScrollTestScrollSnapping : public LayerTreeHostScrollTest {
501 public:
502 LayerTreeHostScrollTestScrollSnapping() : scroll_amount_(1.75, 0) {}
503
504 void SetupTree() override {
505 LayerTreeHostScrollTest::SetupTree();
506 layer_tree_host()
507 ->outer_viewport_scroll_layer()
508 ->scroll_clip_layer()
509 ->SetForceRenderSurfaceForTesting(true);
510 gfx::Transform translate;
511 translate.Translate(0.25f, 0.f);
512 layer_tree_host()
513 ->outer_viewport_scroll_layer()
514 ->scroll_clip_layer()
515 ->SetTransform(translate);
516 layer_tree_host()->SetPageScaleFactorAndLimits(1.f, 0.1f, 100.f);
517 }
518
519 void BeginTest() override { PostSetNeedsCommitToMainThread(); }
520
521 void DrawLayersOnThread(LayerTreeHostImpl* impl) override {
522 LayerImpl* scroll_layer = impl->OuterViewportScrollLayer();
523 gfx::Transform translate;
524
525 // Check that screen space transform of the scrollable layer is correctly
526 // snapped to integers.
527 switch (impl->active_tree()->source_frame_number()) {
528 case 0:
529 EXPECT_EQ(gfx::Transform(),
530 scroll_layer->draw_properties().screen_space_transform);
531 PostSetNeedsCommitToMainThread();
532 break;
533 case 1:
534 translate.Translate(-2, 0);
535 EXPECT_EQ(translate,
536 scroll_layer->draw_properties().screen_space_transform);
537 PostSetNeedsCommitToMainThread();
538 break;
539 case 2:
540 translate.Translate(-3, 0);
541 EXPECT_EQ(translate,
542 scroll_layer->draw_properties().screen_space_transform);
543 EndTest();
544 break;
545 }
546 scroll_layer->ScrollBy(scroll_amount_);
547 }
548
549 void AfterTest() override {}
550
551 private:
552 gfx::Vector2dF scroll_amount_;
553 };
554
555 MULTI_THREAD_TEST_F(LayerTreeHostScrollTestScrollSnapping);
556
500 class LayerTreeHostScrollTestCaseWithChild : public LayerTreeHostScrollTest { 557 class LayerTreeHostScrollTestCaseWithChild : public LayerTreeHostScrollTest {
501 public: 558 public:
502 LayerTreeHostScrollTestCaseWithChild() 559 LayerTreeHostScrollTestCaseWithChild()
503 : initial_offset_(10, 20), 560 : initial_offset_(10, 20),
504 javascript_scroll_(40, 5), 561 javascript_scroll_(40, 5),
505 scroll_amount_(2, -1), 562 scroll_amount_(2, -1),
506 num_scrolls_(0) {} 563 num_scrolls_(0) {}
507 564
508 void SetupTree() override { 565 void SetupTree() override {
509 layer_tree_host()->SetDeviceScaleFactor(device_scale_factor_); 566 layer_tree_host()->SetDeviceScaleFactor(device_scale_factor_);
(...skipping 941 matching lines...) Expand 10 before | Expand all | Expand 10 after
1451 RunTest(CompositorMode::THREADED, false); 1508 RunTest(CompositorMode::THREADED, false);
1452 } 1509 }
1453 1510
1454 TEST_F(LayerTreeHostScrollTestLayerStructureChange, ScrollDestroyWholeTree) { 1511 TEST_F(LayerTreeHostScrollTestLayerStructureChange, ScrollDestroyWholeTree) {
1455 scroll_destroy_whole_tree_ = true; 1512 scroll_destroy_whole_tree_ = true;
1456 RunTest(CompositorMode::THREADED, false); 1513 RunTest(CompositorMode::THREADED, false);
1457 } 1514 }
1458 1515
1459 } // namespace 1516 } // namespace
1460 } // namespace cc 1517 } // namespace cc
OLDNEW
« no previous file with comments | « no previous file | cc/trees/property_tree.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698