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

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

Issue 800613009: Convert scroll offsets to use SyncedProperty. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix Android WebView tests Created 5 years, 10 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 | « cc/trees/layer_tree_host_unittest_animation.cc ('k') | cc/trees/layer_tree_impl.h » ('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/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 812 matching lines...) Expand 10 before | Expand all | Expand 10 after
823 823
824 switch (impl->active_tree()->source_frame_number()) { 824 switch (impl->active_tree()->source_frame_number()) {
825 case 0: 825 case 0:
826 if (!impl->pending_tree()) { 826 if (!impl->pending_tree()) {
827 impl->BlockNotifyReadyToActivateForTesting(true); 827 impl->BlockNotifyReadyToActivateForTesting(true);
828 EXPECT_VECTOR_EQ(scroll_layer->ScrollDelta(), gfx::Vector2d()); 828 EXPECT_VECTOR_EQ(scroll_layer->ScrollDelta(), gfx::Vector2d());
829 scroll_layer->ScrollBy(impl_thread_scroll1_); 829 scroll_layer->ScrollBy(impl_thread_scroll1_);
830 830
831 EXPECT_VECTOR_EQ(scroll_layer->scroll_offset(), initial_scroll_); 831 EXPECT_VECTOR_EQ(scroll_layer->scroll_offset(), initial_scroll_);
832 EXPECT_VECTOR_EQ(scroll_layer->ScrollDelta(), impl_thread_scroll1_); 832 EXPECT_VECTOR_EQ(scroll_layer->ScrollDelta(), impl_thread_scroll1_);
833 EXPECT_VECTOR_EQ(scroll_layer->sent_scroll_delta(), gfx::Vector2d());
834 PostSetNeedsCommitToMainThread(); 833 PostSetNeedsCommitToMainThread();
835 834
836 // CommitCompleteOnThread will trigger this function again 835 // CommitCompleteOnThread will trigger this function again
837 // and cause us to take the else clause. 836 // and cause us to take the else clause.
838 } else { 837 } else {
839 impl->BlockNotifyReadyToActivateForTesting(false); 838 impl->BlockNotifyReadyToActivateForTesting(false);
840 ASSERT_TRUE(pending_root); 839 ASSERT_TRUE(pending_root);
841 EXPECT_EQ(impl->pending_tree()->source_frame_number(), 1); 840 EXPECT_EQ(impl->pending_tree()->source_frame_number(), 1);
842 841
843 scroll_layer->ScrollBy(impl_thread_scroll2_); 842 scroll_layer->ScrollBy(impl_thread_scroll2_);
844 EXPECT_VECTOR_EQ(scroll_layer->scroll_offset(), initial_scroll_); 843 EXPECT_VECTOR_EQ(scroll_layer->scroll_offset(), initial_scroll_);
845 EXPECT_VECTOR_EQ(scroll_layer->ScrollDelta(), 844 EXPECT_VECTOR_EQ(scroll_layer->ScrollDelta(),
846 impl_thread_scroll1_ + impl_thread_scroll2_); 845 impl_thread_scroll1_ + impl_thread_scroll2_);
847 EXPECT_VECTOR_EQ(scroll_layer->sent_scroll_delta(),
848 impl_thread_scroll1_);
849 846
850 LayerImpl* pending_scroll_layer = pending_root->children()[0]; 847 LayerImpl* pending_scroll_layer = pending_root->children()[0];
851 EXPECT_VECTOR_EQ( 848 EXPECT_VECTOR_EQ(
852 pending_scroll_layer->scroll_offset(), 849 pending_scroll_layer->scroll_offset(),
853 gfx::ScrollOffsetWithDelta( 850 gfx::ScrollOffsetWithDelta(
854 initial_scroll_, main_thread_scroll_ + impl_thread_scroll1_)); 851 initial_scroll_, main_thread_scroll_ + impl_thread_scroll1_));
855 EXPECT_VECTOR_EQ(pending_scroll_layer->ScrollDelta(), 852 EXPECT_VECTOR_EQ(pending_scroll_layer->ScrollDelta(),
856 impl_thread_scroll2_); 853 impl_thread_scroll2_);
857 EXPECT_VECTOR_EQ(pending_scroll_layer->sent_scroll_delta(),
858 gfx::Vector2d());
859 } 854 }
860 break; 855 break;
861 case 1: 856 case 1:
862 EXPECT_FALSE(impl->pending_tree()); 857 EXPECT_FALSE(impl->pending_tree());
863 EXPECT_VECTOR_EQ( 858 EXPECT_VECTOR_EQ(
864 scroll_layer->scroll_offset(), 859 scroll_layer->scroll_offset(),
865 gfx::ScrollOffsetWithDelta( 860 gfx::ScrollOffsetWithDelta(
866 initial_scroll_, main_thread_scroll_ + impl_thread_scroll1_)); 861 initial_scroll_, main_thread_scroll_ + impl_thread_scroll1_));
867 EXPECT_VECTOR_EQ(scroll_layer->ScrollDelta(), impl_thread_scroll2_); 862 EXPECT_VECTOR_EQ(scroll_layer->ScrollDelta(), impl_thread_scroll2_);
868 EXPECT_VECTOR_EQ(scroll_layer->sent_scroll_delta(), gfx::Vector2d());
869 EndTest(); 863 EndTest();
870 break; 864 break;
871 } 865 }
872 } 866 }
873 867
874 void ApplyViewportDeltas(const gfx::Vector2d& scroll_delta, 868 void ApplyViewportDeltas(const gfx::Vector2d& scroll_delta,
875 float scale, 869 float scale,
876 float top_controls_delta) override { 870 float top_controls_delta) override {
877 num_scrolls_++; 871 num_scrolls_++;
878 } 872 }
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
956 LayerImpl* pending_root = impl->pending_tree()->root_layer(); 950 LayerImpl* pending_root = impl->pending_tree()->root_layer();
957 LayerImpl* pending_scroll_layer = pending_root->children()[0]; 951 LayerImpl* pending_scroll_layer = pending_root->children()[0];
958 952
959 ASSERT_TRUE(pending_root); 953 ASSERT_TRUE(pending_root);
960 ASSERT_TRUE(pending_scroll_layer); 954 ASSERT_TRUE(pending_scroll_layer);
961 switch (impl->pending_tree()->source_frame_number()) { 955 switch (impl->pending_tree()->source_frame_number()) {
962 case 0: 956 case 0:
963 EXPECT_VECTOR_EQ(pending_scroll_layer->scroll_offset(), 957 EXPECT_VECTOR_EQ(pending_scroll_layer->scroll_offset(),
964 initial_scroll_); 958 initial_scroll_);
965 EXPECT_VECTOR_EQ(pending_scroll_layer->ScrollDelta(), gfx::Vector2d()); 959 EXPECT_VECTOR_EQ(pending_scroll_layer->ScrollDelta(), gfx::Vector2d());
966 EXPECT_VECTOR_EQ(pending_scroll_layer->sent_scroll_delta(),
967 gfx::Vector2d());
968 EXPECT_FALSE(active_root); 960 EXPECT_FALSE(active_root);
969 break; 961 break;
970 case 1: 962 case 1:
971 // Even though the scroll happened during the commit, both layers 963 // Even though the scroll happened during the commit, both layers
972 // should have the appropriate scroll delta. 964 // should have the appropriate scroll delta.
973 EXPECT_VECTOR_EQ(pending_scroll_layer->scroll_offset(), 965 EXPECT_VECTOR_EQ(pending_scroll_layer->scroll_offset(),
974 initial_scroll_); 966 initial_scroll_);
975 EXPECT_VECTOR_EQ(pending_scroll_layer->ScrollDelta(), 967 EXPECT_VECTOR_EQ(pending_scroll_layer->ScrollDelta(),
976 impl_thread_scroll_); 968 impl_thread_scroll_);
977 EXPECT_VECTOR_EQ(pending_scroll_layer->sent_scroll_delta(),
978 gfx::Vector2d());
979 ASSERT_TRUE(active_root); 969 ASSERT_TRUE(active_root);
980 EXPECT_VECTOR_EQ(active_scroll_layer->scroll_offset(), initial_scroll_); 970 EXPECT_VECTOR_EQ(active_scroll_layer->scroll_offset(), initial_scroll_);
981 EXPECT_VECTOR_EQ(active_scroll_layer->ScrollDelta(), 971 EXPECT_VECTOR_EQ(active_scroll_layer->ScrollDelta(),
982 impl_thread_scroll_); 972 impl_thread_scroll_);
983 EXPECT_VECTOR_EQ(active_scroll_layer->sent_scroll_delta(),
984 gfx::Vector2d());
985 break; 973 break;
986 case 2: 974 case 2:
987 // On the next commit, this delta should have been sent and applied. 975 // On the next commit, this delta should have been sent and applied.
988 EXPECT_VECTOR_EQ(pending_scroll_layer->scroll_offset(), 976 EXPECT_VECTOR_EQ(pending_scroll_layer->scroll_offset(),
989 gfx::ScrollOffsetWithDelta(initial_scroll_, 977 gfx::ScrollOffsetWithDelta(initial_scroll_,
990 impl_thread_scroll_)); 978 impl_thread_scroll_));
991 EXPECT_VECTOR_EQ(pending_scroll_layer->ScrollDelta(), gfx::Vector2d()); 979 EXPECT_VECTOR_EQ(pending_scroll_layer->ScrollDelta(), gfx::Vector2d());
992 EXPECT_VECTOR_EQ(pending_scroll_layer->sent_scroll_delta(),
993 gfx::Vector2d());
994 break; 980 break;
995 } 981 }
996 } 982 }
997 983
998 void DrawLayersOnThread(LayerTreeHostImpl* impl) override { 984 void DrawLayersOnThread(LayerTreeHostImpl* impl) override {
999 ImplSidePaintingScrollTest::DrawLayersOnThread(impl); 985 ImplSidePaintingScrollTest::DrawLayersOnThread(impl);
1000 986
1001 LayerImpl* root = impl->active_tree()->root_layer(); 987 LayerImpl* root = impl->active_tree()->root_layer();
1002 LayerImpl* scroll_layer = root->children()[0]; 988 LayerImpl* scroll_layer = root->children()[0];
1003 989
1004 switch (impl->active_tree()->source_frame_number()) { 990 switch (impl->active_tree()->source_frame_number()) {
1005 case 0: 991 case 0:
1006 EXPECT_VECTOR_EQ(scroll_layer->scroll_offset(), initial_scroll_); 992 EXPECT_VECTOR_EQ(scroll_layer->scroll_offset(), initial_scroll_);
1007 EXPECT_VECTOR_EQ(scroll_layer->ScrollDelta(), gfx::Vector2d()); 993 EXPECT_VECTOR_EQ(scroll_layer->ScrollDelta(), gfx::Vector2d());
1008 EXPECT_VECTOR_EQ(scroll_layer->sent_scroll_delta(), gfx::Vector2d());
1009 EXPECT_EQ(1.f, impl->active_tree()->page_scale_delta()); 994 EXPECT_EQ(1.f, impl->active_tree()->page_scale_delta());
1010 EXPECT_EQ(1.f, impl->active_tree()->current_page_scale_factor()); 995 EXPECT_EQ(1.f, impl->active_tree()->current_page_scale_factor());
1011 PostSetNeedsCommitToMainThread(); 996 PostSetNeedsCommitToMainThread();
1012 break; 997 break;
1013 case 1: 998 case 1:
1014 EXPECT_VECTOR_EQ(scroll_layer->scroll_offset(), initial_scroll_); 999 EXPECT_VECTOR_EQ(scroll_layer->scroll_offset(), initial_scroll_);
1015 EXPECT_VECTOR_EQ(scroll_layer->ScrollDelta(), impl_thread_scroll_); 1000 EXPECT_VECTOR_EQ(scroll_layer->ScrollDelta(), impl_thread_scroll_);
1016 EXPECT_VECTOR_EQ(scroll_layer->sent_scroll_delta(), gfx::Vector2d());
1017 EXPECT_EQ(impl_scale_, impl->active_tree()->page_scale_delta()); 1001 EXPECT_EQ(impl_scale_, impl->active_tree()->page_scale_delta());
1018 EXPECT_EQ(impl_scale_, 1002 EXPECT_EQ(impl_scale_,
1019 impl->active_tree()->current_page_scale_factor()); 1003 impl->active_tree()->current_page_scale_factor());
1020 PostSetNeedsCommitToMainThread(); 1004 PostSetNeedsCommitToMainThread();
1021 break; 1005 break;
1022 case 2: 1006 case 2:
1023 EXPECT_EQ(1.f, impl->active_tree()->page_scale_delta()); 1007 EXPECT_EQ(1.f, impl->active_tree()->page_scale_delta());
1024 EXPECT_EQ(impl_scale_, 1008 EXPECT_EQ(impl_scale_,
1025 impl->active_tree()->current_page_scale_factor()); 1009 impl->active_tree()->current_page_scale_factor());
1026 EndTest(); 1010 EndTest();
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
1246 RunTest(true, false, true); 1230 RunTest(true, false, true);
1247 } 1231 }
1248 1232
1249 TEST_F(LayerTreeHostScrollTestLayerStructureChange, ScrollDestroyWholeTree) { 1233 TEST_F(LayerTreeHostScrollTestLayerStructureChange, ScrollDestroyWholeTree) {
1250 scroll_destroy_whole_tree_ = true; 1234 scroll_destroy_whole_tree_ = true;
1251 RunTest(true, false, true); 1235 RunTest(true, false, true);
1252 } 1236 }
1253 1237
1254 } // namespace 1238 } // namespace
1255 } // namespace cc 1239 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_host_unittest_animation.cc ('k') | cc/trees/layer_tree_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698