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 2796 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2807 // SetScrollLayerId will initialize the scrollbar which will cause it to | 2807 // SetScrollLayerId will initialize the scrollbar which will cause it to |
2808 // show and request a redraw. | 2808 // show and request a redraw. |
2809 did_request_redraw_ = false; | 2809 did_request_redraw_ = false; |
2810 } | 2810 } |
2811 | 2811 |
2812 void RunTest(LayerTreeSettings::ScrollbarAnimator animator) { | 2812 void RunTest(LayerTreeSettings::ScrollbarAnimator animator) { |
2813 LayerTreeSettings settings = DefaultSettings(); | 2813 LayerTreeSettings settings = DefaultSettings(); |
2814 settings.scrollbar_animator = animator; | 2814 settings.scrollbar_animator = animator; |
2815 settings.scrollbar_show_delay = base::TimeDelta::FromMilliseconds(20); | 2815 settings.scrollbar_show_delay = base::TimeDelta::FromMilliseconds(20); |
2816 settings.scrollbar_fade_out_delay = base::TimeDelta::FromMilliseconds(20); | 2816 settings.scrollbar_fade_out_delay = base::TimeDelta::FromMilliseconds(20); |
| 2817 settings.scrollbar_fade_out_resize_delay = |
| 2818 base::TimeDelta::FromMilliseconds(20); |
2817 settings.scrollbar_fade_out_duration = | 2819 settings.scrollbar_fade_out_duration = |
2818 base::TimeDelta::FromMilliseconds(20); | 2820 base::TimeDelta::FromMilliseconds(20); |
2819 | 2821 |
2820 // If no animator is set, scrollbar won't show and no animation is expected. | 2822 // If no animator is set, scrollbar won't show and no animation is expected. |
2821 bool expecting_animations = animator != LayerTreeSettings::NO_ANIMATOR; | 2823 bool expecting_animations = animator != LayerTreeSettings::NO_ANIMATOR; |
2822 | 2824 |
2823 SetupLayers(settings); | 2825 SetupLayers(settings); |
2824 | 2826 |
2825 base::TimeTicks fake_now = base::TimeTicks::Now(); | 2827 base::TimeTicks fake_now = base::TimeTicks::Now(); |
2826 | 2828 |
(...skipping 13 matching lines...) Expand all Loading... |
2840 | 2842 |
2841 // If no scroll happened during a scroll gesture, it should have no effect. | 2843 // If no scroll happened during a scroll gesture, it should have no effect. |
2842 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), | 2844 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), |
2843 InputHandler::WHEEL); | 2845 InputHandler::WHEEL); |
2844 host_impl_->ScrollEnd(EndState().get()); | 2846 host_impl_->ScrollEnd(EndState().get()); |
2845 EXPECT_FALSE(did_request_next_frame_); | 2847 EXPECT_FALSE(did_request_next_frame_); |
2846 EXPECT_FALSE(did_request_redraw_); | 2848 EXPECT_FALSE(did_request_redraw_); |
2847 EXPECT_EQ(base::TimeDelta(), requested_animation_delay_); | 2849 EXPECT_EQ(base::TimeDelta(), requested_animation_delay_); |
2848 EXPECT_TRUE(animation_task_.Equals(base::Closure())); | 2850 EXPECT_TRUE(animation_task_.Equals(base::Closure())); |
2849 | 2851 |
| 2852 // For Aura Overlay Scrollbar, if no scroll happened during a scroll |
| 2853 // gesture, shows scrollbars and schedules a delay fade out. |
| 2854 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), |
| 2855 InputHandler::WHEEL); |
| 2856 host_impl_->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2dF(0, 0)).get()); |
| 2857 host_impl_->ScrollEnd(EndState().get()); |
| 2858 EXPECT_FALSE(did_request_next_frame_); |
| 2859 EXPECT_FALSE(did_request_redraw_); |
| 2860 if (animator == LayerTreeSettings::AURA_OVERLAY) { |
| 2861 EXPECT_EQ(base::TimeDelta::FromMilliseconds(20), |
| 2862 requested_animation_delay_); |
| 2863 EXPECT_FALSE(animation_task_.Equals(base::Closure())); |
| 2864 requested_animation_delay_ = base::TimeDelta(); |
| 2865 animation_task_ = base::Closure(); |
| 2866 } else { |
| 2867 EXPECT_EQ(base::TimeDelta(), requested_animation_delay_); |
| 2868 EXPECT_TRUE(animation_task_.Equals(base::Closure())); |
| 2869 } |
| 2870 |
2850 // Before the scrollbar animation exists, we should not get redraws. | 2871 // Before the scrollbar animation exists, we should not get redraws. |
2851 BeginFrameArgs begin_frame_args = | 2872 BeginFrameArgs begin_frame_args = |
2852 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, 0, 2, fake_now); | 2873 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, 0, 2, fake_now); |
2853 host_impl_->WillBeginImplFrame(begin_frame_args); | 2874 host_impl_->WillBeginImplFrame(begin_frame_args); |
2854 host_impl_->Animate(); | 2875 host_impl_->Animate(); |
2855 EXPECT_FALSE(did_request_next_frame_); | 2876 EXPECT_FALSE(did_request_next_frame_); |
2856 did_request_next_frame_ = false; | 2877 did_request_next_frame_ = false; |
2857 EXPECT_FALSE(did_request_redraw_); | 2878 EXPECT_FALSE(did_request_redraw_); |
2858 did_request_redraw_ = false; | 2879 did_request_redraw_ = false; |
2859 EXPECT_EQ(base::TimeDelta(), requested_animation_delay_); | 2880 EXPECT_EQ(base::TimeDelta(), requested_animation_delay_); |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2947 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, 0, 5, fake_now); | 2968 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, 0, 5, fake_now); |
2948 host_impl_->WillBeginImplFrame(begin_frame_args); | 2969 host_impl_->WillBeginImplFrame(begin_frame_args); |
2949 host_impl_->Animate(); | 2970 host_impl_->Animate(); |
2950 EXPECT_FALSE(did_request_next_frame_); | 2971 EXPECT_FALSE(did_request_next_frame_); |
2951 did_request_next_frame_ = false; | 2972 did_request_next_frame_ = false; |
2952 EXPECT_FALSE(did_request_redraw_); | 2973 EXPECT_FALSE(did_request_redraw_); |
2953 did_request_redraw_ = false; | 2974 did_request_redraw_ = false; |
2954 host_impl_->DidFinishImplFrame(); | 2975 host_impl_->DidFinishImplFrame(); |
2955 } | 2976 } |
2956 | 2977 |
2957 // Scrollbar animation is not triggered unnecessarily. | 2978 // For Andrdoid, scrollbar animation is not triggered unnecessarily. |
| 2979 // For Aura Overlay Scrollbar, scrollbar appears even if scroll offset did |
| 2980 // not change. |
2958 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), | 2981 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), |
2959 InputHandler::WHEEL); | 2982 InputHandler::WHEEL); |
2960 host_impl_->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2dF(5, 0)).get()); | 2983 host_impl_->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2dF(5, 0)).get()); |
2961 EXPECT_FALSE(did_request_next_frame_); | 2984 EXPECT_FALSE(did_request_next_frame_); |
2962 EXPECT_TRUE(did_request_redraw_); | 2985 EXPECT_TRUE(did_request_redraw_); |
2963 did_request_redraw_ = false; | 2986 did_request_redraw_ = false; |
2964 EXPECT_EQ(base::TimeDelta(), requested_animation_delay_); | 2987 EXPECT_EQ(base::TimeDelta(), requested_animation_delay_); |
2965 EXPECT_TRUE(animation_task_.Equals(base::Closure())); | 2988 EXPECT_TRUE(animation_task_.Equals(base::Closure())); |
2966 | 2989 |
2967 host_impl_->ScrollEnd(EndState().get()); | 2990 host_impl_->ScrollEnd(EndState().get()); |
2968 EXPECT_FALSE(did_request_next_frame_); | 2991 EXPECT_FALSE(did_request_next_frame_); |
2969 EXPECT_FALSE(did_request_redraw_); | 2992 EXPECT_FALSE(did_request_redraw_); |
2970 EXPECT_EQ(base::TimeDelta(), requested_animation_delay_); | 2993 if (animator == LayerTreeSettings::AURA_OVERLAY) { |
2971 EXPECT_TRUE(animation_task_.Equals(base::Closure())); | 2994 EXPECT_EQ(base::TimeDelta::FromMilliseconds(20), |
| 2995 requested_animation_delay_); |
| 2996 EXPECT_FALSE(animation_task_.Equals(base::Closure())); |
| 2997 requested_animation_delay_ = base::TimeDelta(); |
| 2998 animation_task_ = base::Closure(); |
| 2999 } else { |
| 3000 EXPECT_EQ(base::TimeDelta(), requested_animation_delay_); |
| 3001 EXPECT_TRUE(animation_task_.Equals(base::Closure())); |
| 3002 } |
2972 | 3003 |
2973 // Changing page scale triggers scrollbar animation. | 3004 // Changing page scale triggers scrollbar animation. |
2974 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 1.f, 4.f); | 3005 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 1.f, 4.f); |
2975 host_impl_->active_tree()->SetPageScaleOnActiveTree(1.1f); | 3006 host_impl_->active_tree()->SetPageScaleOnActiveTree(1.1f); |
2976 EXPECT_FALSE(did_request_next_frame_); | 3007 EXPECT_FALSE(did_request_next_frame_); |
2977 EXPECT_FALSE(did_request_redraw_); | 3008 EXPECT_FALSE(did_request_redraw_); |
2978 if (expecting_animations) { | 3009 if (expecting_animations) { |
2979 EXPECT_EQ(base::TimeDelta::FromMilliseconds(20), | 3010 EXPECT_EQ(base::TimeDelta::FromMilliseconds(20), |
2980 requested_animation_delay_); | 3011 requested_animation_delay_); |
2981 EXPECT_FALSE(animation_task_.Equals(base::Closure())); | 3012 EXPECT_FALSE(animation_task_.Equals(base::Closure())); |
(...skipping 9082 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12064 else | 12095 else |
12065 EXPECT_FALSE(tile->HasRasterTask()); | 12096 EXPECT_FALSE(tile->HasRasterTask()); |
12066 } | 12097 } |
12067 Region expected_invalidation( | 12098 Region expected_invalidation( |
12068 raster_source->GetRectForImage(checkerable_image->uniqueID())); | 12099 raster_source->GetRectForImage(checkerable_image->uniqueID())); |
12069 EXPECT_EQ(expected_invalidation, *(root->GetPendingInvalidation())); | 12100 EXPECT_EQ(expected_invalidation, *(root->GetPendingInvalidation())); |
12070 } | 12101 } |
12071 | 12102 |
12072 } // namespace | 12103 } // namespace |
12073 } // namespace cc | 12104 } // namespace cc |
OLD | NEW |