OLD | NEW |
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/layer_tree_host_impl.h" | 5 #include "cc/trees/layer_tree_host_impl.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <cmath> | 10 #include <cmath> |
(...skipping 842 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
853 // Now the fling should go ahead since we've started scrolling a layer | 853 // Now the fling should go ahead since we've started scrolling a layer |
854 status = host_impl_->FlingScrollBegin(); | 854 status = host_impl_->FlingScrollBegin(); |
855 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, status.thread); | 855 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, status.thread); |
856 EXPECT_EQ(MainThreadScrollingReason::kNotScrollingOnMain, | 856 EXPECT_EQ(MainThreadScrollingReason::kNotScrollingOnMain, |
857 status.main_thread_scrolling_reasons); | 857 status.main_thread_scrolling_reasons); |
858 } | 858 } |
859 | 859 |
860 TEST_F(LayerTreeHostImplTest, NoFlingWhenScrollingOnMain) { | 860 TEST_F(LayerTreeHostImplTest, NoFlingWhenScrollingOnMain) { |
861 SetupScrollAndContentsLayers(gfx::Size(100, 100)); | 861 SetupScrollAndContentsLayers(gfx::Size(100, 100)); |
862 host_impl_->SetViewportSize(gfx::Size(50, 50)); | 862 host_impl_->SetViewportSize(gfx::Size(50, 50)); |
863 DrawFrame(); | |
864 LayerImpl* root = host_impl_->active_tree()->root_layer(); | 863 LayerImpl* root = host_impl_->active_tree()->root_layer(); |
865 | 864 |
866 root->set_main_thread_scrolling_reasons( | 865 root->set_main_thread_scrolling_reasons( |
867 MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects); | 866 MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects); |
868 | 867 |
| 868 SetNeedsRebuildPropertyTrees(); |
| 869 DrawFrame(); |
| 870 |
869 // Start scrolling a layer | 871 // Start scrolling a layer |
870 InputHandler::ScrollStatus status = host_impl_->ScrollBegin( | 872 InputHandler::ScrollStatus status = host_impl_->ScrollBegin( |
871 BeginState(gfx::Point()).get(), InputHandler::GESTURE); | 873 BeginState(gfx::Point()).get(), InputHandler::GESTURE); |
872 EXPECT_EQ(InputHandler::SCROLL_ON_MAIN_THREAD, status.thread); | 874 EXPECT_EQ(InputHandler::SCROLL_ON_MAIN_THREAD, status.thread); |
873 EXPECT_EQ(MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects, | 875 EXPECT_EQ(MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects, |
874 status.main_thread_scrolling_reasons); | 876 status.main_thread_scrolling_reasons); |
875 | 877 |
876 // The fling should be ignored since there's no layer being scrolled impl-side | 878 // The fling should be ignored since there's no layer being scrolled impl-side |
877 status = host_impl_->FlingScrollBegin(); | 879 status = host_impl_->FlingScrollBegin(); |
878 EXPECT_EQ(InputHandler::SCROLL_IGNORED, status.thread); | 880 EXPECT_EQ(InputHandler::SCROLL_IGNORED, status.thread); |
879 EXPECT_EQ(MainThreadScrollingReason::kNoScrollingLayer, | 881 EXPECT_EQ(MainThreadScrollingReason::kNoScrollingLayer, |
880 status.main_thread_scrolling_reasons); | 882 status.main_thread_scrolling_reasons); |
881 } | 883 } |
882 | 884 |
883 TEST_F(LayerTreeHostImplTest, ShouldScrollOnMainThread) { | 885 TEST_F(LayerTreeHostImplTest, ShouldScrollOnMainThread) { |
884 SetupScrollAndContentsLayers(gfx::Size(100, 100)); | 886 SetupScrollAndContentsLayers(gfx::Size(100, 100)); |
885 host_impl_->SetViewportSize(gfx::Size(50, 50)); | 887 host_impl_->SetViewportSize(gfx::Size(50, 50)); |
886 DrawFrame(); | |
887 LayerImpl* root = host_impl_->active_tree()->root_layer(); | 888 LayerImpl* root = host_impl_->active_tree()->root_layer(); |
888 | 889 |
889 root->set_main_thread_scrolling_reasons( | 890 root->set_main_thread_scrolling_reasons( |
890 MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects); | 891 MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects); |
| 892 SetNeedsRebuildPropertyTrees(); |
| 893 DrawFrame(); |
891 | 894 |
892 InputHandler::ScrollStatus status = host_impl_->ScrollBegin( | 895 InputHandler::ScrollStatus status = host_impl_->ScrollBegin( |
893 BeginState(gfx::Point()).get(), InputHandler::WHEEL); | 896 BeginState(gfx::Point()).get(), InputHandler::WHEEL); |
894 EXPECT_EQ(InputHandler::SCROLL_ON_MAIN_THREAD, status.thread); | 897 EXPECT_EQ(InputHandler::SCROLL_ON_MAIN_THREAD, status.thread); |
895 EXPECT_EQ(MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects, | 898 EXPECT_EQ(MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects, |
896 status.main_thread_scrolling_reasons); | 899 status.main_thread_scrolling_reasons); |
897 | 900 |
898 status = host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), | 901 status = host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), |
899 InputHandler::GESTURE); | 902 InputHandler::GESTURE); |
900 EXPECT_EQ(InputHandler::SCROLL_ON_MAIN_THREAD, status.thread); | 903 EXPECT_EQ(InputHandler::SCROLL_ON_MAIN_THREAD, status.thread); |
901 EXPECT_EQ(MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects, | 904 EXPECT_EQ(MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects, |
902 status.main_thread_scrolling_reasons); | 905 status.main_thread_scrolling_reasons); |
903 } | 906 } |
904 | 907 |
905 TEST_F(LayerTreeHostImplTest, NonFastScrollableRegionBasic) { | 908 TEST_F(LayerTreeHostImplTest, NonFastScrollableRegionBasic) { |
906 SetupScrollAndContentsLayers(gfx::Size(200, 200)); | 909 SetupScrollAndContentsLayers(gfx::Size(200, 200)); |
907 host_impl_->SetViewportSize(gfx::Size(100, 100)); | 910 host_impl_->SetViewportSize(gfx::Size(100, 100)); |
908 | 911 |
909 LayerImpl* root = host_impl_->active_tree()->root_layer(); | 912 LayerImpl* root = host_impl_->active_tree()->root_layer(); |
910 root->SetNonFastScrollableRegion(gfx::Rect(0, 0, 50, 50)); | 913 root->SetNonFastScrollableRegion(gfx::Rect(0, 0, 50, 50)); |
911 | 914 |
| 915 SetNeedsRebuildPropertyTrees(); |
912 DrawFrame(); | 916 DrawFrame(); |
913 | 917 |
914 // All scroll types inside the non-fast scrollable region should fail. | 918 // All scroll types inside the non-fast scrollable region should fail. |
915 InputHandler::ScrollStatus status = host_impl_->ScrollBegin( | 919 InputHandler::ScrollStatus status = host_impl_->ScrollBegin( |
916 BeginState(gfx::Point(25, 25)).get(), InputHandler::WHEEL); | 920 BeginState(gfx::Point(25, 25)).get(), InputHandler::WHEEL); |
917 EXPECT_EQ(InputHandler::SCROLL_ON_MAIN_THREAD, status.thread); | 921 EXPECT_EQ(InputHandler::SCROLL_ON_MAIN_THREAD, status.thread); |
918 EXPECT_EQ(MainThreadScrollingReason::kNonFastScrollableRegion, | 922 EXPECT_EQ(MainThreadScrollingReason::kNonFastScrollableRegion, |
919 status.main_thread_scrolling_reasons); | 923 status.main_thread_scrolling_reasons); |
920 EXPECT_FALSE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(25, 25), | 924 EXPECT_FALSE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(25, 25), |
921 InputHandler::WHEEL)); | 925 InputHandler::WHEEL)); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
959 | 963 |
960 TEST_F(LayerTreeHostImplTest, NonFastScrollableRegionWithOffset) { | 964 TEST_F(LayerTreeHostImplTest, NonFastScrollableRegionWithOffset) { |
961 SetupScrollAndContentsLayers(gfx::Size(200, 200)); | 965 SetupScrollAndContentsLayers(gfx::Size(200, 200)); |
962 host_impl_->SetViewportSize(gfx::Size(100, 100)); | 966 host_impl_->SetViewportSize(gfx::Size(100, 100)); |
963 | 967 |
964 LayerImpl* root = host_impl_->active_tree()->root_layer(); | 968 LayerImpl* root = host_impl_->active_tree()->root_layer(); |
965 root->SetNonFastScrollableRegion(gfx::Rect(0, 0, 50, 50)); | 969 root->SetNonFastScrollableRegion(gfx::Rect(0, 0, 50, 50)); |
966 root->SetPosition(gfx::PointF(-25.f, 0.f)); | 970 root->SetPosition(gfx::PointF(-25.f, 0.f)); |
967 root->SetDrawsContent(true); | 971 root->SetDrawsContent(true); |
968 | 972 |
| 973 SetNeedsRebuildPropertyTrees(); |
969 DrawFrame(); | 974 DrawFrame(); |
970 | 975 |
971 // This point would fall into the non-fast scrollable region except that we've | 976 // This point would fall into the non-fast scrollable region except that we've |
972 // moved the layer down by 25 pixels. | 977 // moved the layer down by 25 pixels. |
973 InputHandler::ScrollStatus status = host_impl_->ScrollBegin( | 978 InputHandler::ScrollStatus status = host_impl_->ScrollBegin( |
974 BeginState(gfx::Point(40, 10)).get(), InputHandler::WHEEL); | 979 BeginState(gfx::Point(40, 10)).get(), InputHandler::WHEEL); |
975 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, status.thread); | 980 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, status.thread); |
976 EXPECT_EQ(MainThreadScrollingReason::kNotScrollingOnMain, | 981 EXPECT_EQ(MainThreadScrollingReason::kNotScrollingOnMain, |
977 status.main_thread_scrolling_reasons); | 982 status.main_thread_scrolling_reasons); |
978 | 983 |
(...skipping 9146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10125 // There should not be any jitter measured till we hit the fixed point hits | 10130 // There should not be any jitter measured till we hit the fixed point hits |
10126 // threshold. | 10131 // threshold. |
10127 float expected_jitter = | 10132 float expected_jitter = |
10128 (i == pending_tree->kFixedPointHitsThreshold) ? 500 : 0; | 10133 (i == pending_tree->kFixedPointHitsThreshold) ? 500 : 0; |
10129 EXPECT_EQ(jitter, expected_jitter); | 10134 EXPECT_EQ(jitter, expected_jitter); |
10130 } | 10135 } |
10131 } | 10136 } |
10132 | 10137 |
10133 } // namespace | 10138 } // namespace |
10134 } // namespace cc | 10139 } // namespace cc |
OLD | NEW |