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

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

Issue 2720183003: Track the currently scrolling ScrollNode instead of the scrolling layer (Closed)
Patch Set: Rebase Created 3 years, 9 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
« cc/trees/layer_tree_impl.cc ('K') | « cc/trees/layer_tree_impl.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/tree_synchronizer.h" 5 #include "cc/trees/tree_synchronizer.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <set> 10 #include <set>
11 #include <vector> 11 #include <vector>
12 12
13 #include "base/format_macros.h" 13 #include "base/format_macros.h"
14 #include "base/memory/ptr_util.h" 14 #include "base/memory/ptr_util.h"
15 #include "base/strings/stringprintf.h" 15 #include "base/strings/stringprintf.h"
16 #include "base/threading/thread_task_runner_handle.h" 16 #include "base/threading/thread_task_runner_handle.h"
17 #include "cc/animation/animation_host.h" 17 #include "cc/animation/animation_host.h"
18 #include "cc/layers/layer.h" 18 #include "cc/layers/layer.h"
19 #include "cc/layers/layer_impl.h" 19 #include "cc/layers/layer_impl.h"
20 #include "cc/test/animation_test_common.h" 20 #include "cc/test/animation_test_common.h"
21 #include "cc/test/fake_impl_task_runner_provider.h" 21 #include "cc/test/fake_impl_task_runner_provider.h"
22 #include "cc/test/fake_layer_tree_host.h" 22 #include "cc/test/fake_layer_tree_host.h"
23 #include "cc/test/fake_rendering_stats_instrumentation.h" 23 #include "cc/test/fake_rendering_stats_instrumentation.h"
24 #include "cc/test/stub_layer_tree_host_single_thread_client.h" 24 #include "cc/test/stub_layer_tree_host_single_thread_client.h"
25 #include "cc/test/test_task_graph_runner.h" 25 #include "cc/test/test_task_graph_runner.h"
26 #include "cc/trees/effect_node.h" 26 #include "cc/trees/effect_node.h"
27 #include "cc/trees/layer_tree_host_common.h" 27 #include "cc/trees/layer_tree_host_common.h"
28 #include "cc/trees/scroll_node.h"
28 #include "cc/trees/single_thread_proxy.h" 29 #include "cc/trees/single_thread_proxy.h"
29 #include "cc/trees/task_runner_provider.h" 30 #include "cc/trees/task_runner_provider.h"
30 #include "testing/gtest/include/gtest/gtest.h" 31 #include "testing/gtest/include/gtest/gtest.h"
31 32
32 namespace cc { 33 namespace cc {
33 namespace { 34 namespace {
34 35
35 bool AreScrollOffsetsEqual(const SyncedScrollOffset* a, 36 bool AreScrollOffsetsEqual(const SyncedScrollOffset* a,
36 const SyncedScrollOffset* b) { 37 const SyncedScrollOffset* b) {
37 return a->ActiveBase() == b->ActiveBase() && 38 return a->ActiveBase() == b->ActiveBase() &&
(...skipping 459 matching lines...) Expand 10 before | Expand all | Expand 10 after
497 scroll_layer->SetScrollClipLayerId(scroll_clip_layer->id()); 498 scroll_layer->SetScrollClipLayerId(scroll_clip_layer->id());
498 host_->SetRootLayer(layer_tree_root); 499 host_->SetRootLayer(layer_tree_root);
499 host_->BuildPropertyTreesForTesting(); 500 host_->BuildPropertyTreesForTesting();
500 host_->CommitAndCreatePendingTree(); 501 host_->CommitAndCreatePendingTree();
501 host_impl->ActivateSyncTree(); 502 host_impl->ActivateSyncTree();
502 503
503 ExpectTreesAreIdentical(layer_tree_root.get(), 504 ExpectTreesAreIdentical(layer_tree_root.get(),
504 host_impl->active_tree()->root_layer_for_testing(), 505 host_impl->active_tree()->root_layer_for_testing(),
505 host_impl->active_tree()); 506 host_impl->active_tree());
506 507
507 host_impl->active_tree()->SetCurrentlyScrollingLayer(
508 host_impl->active_tree()->LayerById(scroll_layer->id()));
509 transient_scroll_layer->SetScrollClipLayerId(Layer::INVALID_ID); 508 transient_scroll_layer->SetScrollClipLayerId(Layer::INVALID_ID);
510 host_->BuildPropertyTreesForTesting(); 509 host_->BuildPropertyTreesForTesting();
511 510
511 ScrollTree& scroll_tree =
512 host_impl->active_tree()->property_trees()->scroll_tree;
513 host_impl->active_tree()->SetCurrentlyScrollingNode(
514 scroll_tree.Node(scroll_layer->scroll_tree_index()));
515
512 host_impl->CreatePendingTree(); 516 host_impl->CreatePendingTree();
513 host_->CommitAndCreatePendingTree(); 517 host_->CommitAndCreatePendingTree();
514 host_impl->ActivateSyncTree(); 518 host_impl->ActivateSyncTree();
515 519
516 EXPECT_EQ(scroll_layer->id(), 520 EXPECT_EQ(scroll_layer->scroll_tree_index(),
517 host_impl->active_tree()->CurrentlyScrollingLayer()->id()); 521 host_impl->active_tree()->CurrentlyScrollingNode()->id);
518 } 522 }
519 523
520 TEST_F(TreeSynchronizerTest, SynchronizeScrollTreeScrollOffsetMap) { 524 TEST_F(TreeSynchronizerTest, SynchronizeScrollTreeScrollOffsetMap) {
521 host_->InitializeSingleThreaded(&single_thread_client_, 525 host_->InitializeSingleThreaded(&single_thread_client_,
522 base::ThreadTaskRunnerHandle::Get()); 526 base::ThreadTaskRunnerHandle::Get());
523 LayerTreeSettings settings; 527 LayerTreeSettings settings;
524 FakeLayerTreeHostImplClient client; 528 FakeLayerTreeHostImplClient client;
525 FakeImplTaskRunnerProvider task_runner_provider; 529 FakeImplTaskRunnerProvider task_runner_provider;
526 FakeRenderingStatsInstrumentation stats_instrumentation; 530 FakeRenderingStatsInstrumentation stats_instrumentation;
527 TestTaskGraphRunner task_graph_runner; 531 TestTaskGraphRunner task_graph_runner;
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
590 std::unique_ptr<ScrollAndScaleSet> scroll_info(new ScrollAndScaleSet()); 594 std::unique_ptr<ScrollAndScaleSet> scroll_info(new ScrollAndScaleSet());
591 scroll_tree.CollectScrollDeltas(scroll_info.get(), Layer::INVALID_ID); 595 scroll_tree.CollectScrollDeltas(scroll_info.get(), Layer::INVALID_ID);
592 host_->proxy()->SetNeedsCommit(); 596 host_->proxy()->SetNeedsCommit();
593 host_->ApplyScrollAndScale(scroll_info.get()); 597 host_->ApplyScrollAndScale(scroll_info.get());
594 EXPECT_EQ(gfx::ScrollOffset(20, 30), scroll_layer->scroll_offset()); 598 EXPECT_EQ(gfx::ScrollOffset(20, 30), scroll_layer->scroll_offset());
595 scroll_layer->SetScrollOffset(gfx::ScrollOffset(100, 100)); 599 scroll_layer->SetScrollOffset(gfx::ScrollOffset(100, 100));
596 600
597 // More update to ScrollOffset active delta: gfx::ScrollOffset(20, 20) 601 // More update to ScrollOffset active delta: gfx::ScrollOffset(20, 20)
598 scroll_tree.SetScrollOffset(scroll_layer_impl->id(), 602 scroll_tree.SetScrollOffset(scroll_layer_impl->id(),
599 gfx::ScrollOffset(40, 50)); 603 gfx::ScrollOffset(40, 50));
600 host_impl->active_tree()->SetCurrentlyScrollingLayer(scroll_layer_impl);
601 604
602 // Make one layer unscrollable so that scroll tree topology changes 605 // Make one layer unscrollable so that scroll tree topology changes
603 transient_scroll_layer->SetScrollClipLayerId(Layer::INVALID_ID); 606 transient_scroll_layer->SetScrollClipLayerId(Layer::INVALID_ID);
604 host_->BuildPropertyTreesForTesting(); 607 host_->BuildPropertyTreesForTesting();
608 host_impl->active_tree()->SetCurrentlyScrollingNode(
pdr. 2017/02/28 19:20:22 Reviewer note: This has to be after property trees
609 scroll_tree.Node(scroll_layer->scroll_tree_index()));
605 610
606 host_impl->CreatePendingTree(); 611 host_impl->CreatePendingTree();
607 host_->CommitAndCreatePendingTree(); 612 host_->CommitAndCreatePendingTree();
608 host_impl->ActivateSyncTree(); 613 host_impl->ActivateSyncTree();
609 614
610 EXPECT_EQ(scroll_layer->id(), 615 EXPECT_EQ(scroll_layer->scroll_tree_index(),
611 host_impl->active_tree()->CurrentlyScrollingLayer()->id()); 616 host_impl->active_tree()->CurrentlyScrollingNode()->id);
612 scroll_layer_offset->SetCurrent(gfx::ScrollOffset(20, 30)); 617 scroll_layer_offset->SetCurrent(gfx::ScrollOffset(20, 30));
613 scroll_layer_offset->PullDeltaForMainThread(); 618 scroll_layer_offset->PullDeltaForMainThread();
614 scroll_layer_offset->SetCurrent(gfx::ScrollOffset(40, 50)); 619 scroll_layer_offset->SetCurrent(gfx::ScrollOffset(40, 50));
615 scroll_layer_offset->PushFromMainThread(gfx::ScrollOffset(100, 100)); 620 scroll_layer_offset->PushFromMainThread(gfx::ScrollOffset(100, 100));
616 scroll_layer_offset->PushPendingToActive(); 621 scroll_layer_offset->PushPendingToActive();
617 EXPECT_TRUE(AreScrollOffsetsEqual( 622 EXPECT_TRUE(AreScrollOffsetsEqual(
618 scroll_layer_offset.get(), 623 scroll_layer_offset.get(),
619 host_impl->active_tree() 624 host_impl->active_tree()
620 ->property_trees() 625 ->property_trees()
621 ->scroll_tree.GetSyncedScrollOffset(scroll_layer->id()))); 626 ->scroll_tree.GetSyncedScrollOffset(scroll_layer->id())));
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
665 host_->CommitAndCreatePendingTree(); 670 host_->CommitAndCreatePendingTree();
666 host_impl->ActivateSyncTree(); 671 host_impl->ActivateSyncTree();
667 EXPECT_EQ( 672 EXPECT_EQ(
668 CombinedAnimationScale(0.f, 0.f), 673 CombinedAnimationScale(0.f, 0.f),
669 host_impl->active_tree()->property_trees()->GetAnimationScales( 674 host_impl->active_tree()->property_trees()->GetAnimationScales(
670 transform_layer->transform_tree_index(), host_impl->active_tree())); 675 transform_layer->transform_tree_index(), host_impl->active_tree()));
671 } 676 }
672 677
673 } // namespace 678 } // namespace
674 } // namespace cc 679 } // namespace cc
OLDNEW
« cc/trees/layer_tree_impl.cc ('K') | « cc/trees/layer_tree_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698