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 2792 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2803 host_impl_->active_tree()->BuildPropertyTreesForTesting(); | 2803 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
2804 host_impl_->active_tree()->DidBecomeActive(); | 2804 host_impl_->active_tree()->DidBecomeActive(); |
2805 DrawFrame(); | 2805 DrawFrame(); |
2806 } | 2806 } |
2807 | 2807 |
2808 void RunTest(LayerTreeSettings::ScrollbarAnimator animator) { | 2808 void RunTest(LayerTreeSettings::ScrollbarAnimator animator) { |
2809 LayerTreeSettings settings = DefaultSettings(); | 2809 LayerTreeSettings settings = DefaultSettings(); |
2810 settings.scrollbar_animator = animator; | 2810 settings.scrollbar_animator = animator; |
2811 settings.scrollbar_show_delay = base::TimeDelta::FromMilliseconds(20); | 2811 settings.scrollbar_show_delay = base::TimeDelta::FromMilliseconds(20); |
2812 settings.scrollbar_fade_out_delay = base::TimeDelta::FromMilliseconds(20); | 2812 settings.scrollbar_fade_out_delay = base::TimeDelta::FromMilliseconds(20); |
| 2813 settings.scrollbar_fade_out_resize_delay = |
| 2814 base::TimeDelta::FromMilliseconds(20); |
2813 settings.scrollbar_fade_out_duration = | 2815 settings.scrollbar_fade_out_duration = |
2814 base::TimeDelta::FromMilliseconds(20); | 2816 base::TimeDelta::FromMilliseconds(20); |
2815 | 2817 |
2816 // If no animator is set, scrollbar won't show and no animation is expected. | 2818 // If no animator is set, scrollbar won't show and no animation is expected. |
2817 bool expecting_animations = animator != LayerTreeSettings::NO_ANIMATOR; | 2819 bool expecting_animations = animator != LayerTreeSettings::NO_ANIMATOR; |
2818 | 2820 |
2819 SetupLayers(settings); | 2821 SetupLayers(settings); |
2820 | 2822 |
2821 base::TimeTicks fake_now = base::TimeTicks::Now(); | 2823 base::TimeTicks fake_now = base::TimeTicks::Now(); |
2822 | 2824 |
(...skipping 13 matching lines...) Expand all Loading... |
2836 | 2838 |
2837 // If no scroll happened during a scroll gesture, it should have no effect. | 2839 // If no scroll happened during a scroll gesture, it should have no effect. |
2838 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), | 2840 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), |
2839 InputHandler::WHEEL); | 2841 InputHandler::WHEEL); |
2840 host_impl_->ScrollEnd(EndState().get()); | 2842 host_impl_->ScrollEnd(EndState().get()); |
2841 EXPECT_FALSE(did_request_next_frame_); | 2843 EXPECT_FALSE(did_request_next_frame_); |
2842 EXPECT_FALSE(did_request_redraw_); | 2844 EXPECT_FALSE(did_request_redraw_); |
2843 EXPECT_EQ(base::TimeDelta(), requested_animation_delay_); | 2845 EXPECT_EQ(base::TimeDelta(), requested_animation_delay_); |
2844 EXPECT_TRUE(animation_task_.Equals(base::Closure())); | 2846 EXPECT_TRUE(animation_task_.Equals(base::Closure())); |
2845 | 2847 |
| 2848 // For Aura Overlay Scrollbar, if no scroll happened during a scroll |
| 2849 // gesture, shows scrollbars and schedules a delay fade out. |
| 2850 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), |
| 2851 InputHandler::WHEEL); |
| 2852 host_impl_->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2dF(0, 0)).get()); |
| 2853 host_impl_->ScrollEnd(EndState().get()); |
| 2854 EXPECT_FALSE(did_request_next_frame_); |
| 2855 EXPECT_FALSE(did_request_redraw_); |
| 2856 if (animator == LayerTreeSettings::AURA_OVERLAY) { |
| 2857 EXPECT_EQ(base::TimeDelta::FromMilliseconds(20), |
| 2858 requested_animation_delay_); |
| 2859 EXPECT_FALSE(animation_task_.Equals(base::Closure())); |
| 2860 requested_animation_delay_ = base::TimeDelta(); |
| 2861 animation_task_ = base::Closure(); |
| 2862 } else { |
| 2863 EXPECT_EQ(base::TimeDelta(), requested_animation_delay_); |
| 2864 EXPECT_TRUE(animation_task_.Equals(base::Closure())); |
| 2865 } |
| 2866 |
2846 // Before the scrollbar animation exists, we should not get redraws. | 2867 // Before the scrollbar animation exists, we should not get redraws. |
2847 BeginFrameArgs begin_frame_args = | 2868 BeginFrameArgs begin_frame_args = |
2848 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, 0, 2, fake_now); | 2869 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, 0, 2, fake_now); |
2849 host_impl_->WillBeginImplFrame(begin_frame_args); | 2870 host_impl_->WillBeginImplFrame(begin_frame_args); |
2850 host_impl_->Animate(); | 2871 host_impl_->Animate(); |
2851 EXPECT_FALSE(did_request_next_frame_); | 2872 EXPECT_FALSE(did_request_next_frame_); |
2852 did_request_next_frame_ = false; | 2873 did_request_next_frame_ = false; |
2853 EXPECT_FALSE(did_request_redraw_); | 2874 EXPECT_FALSE(did_request_redraw_); |
2854 did_request_redraw_ = false; | 2875 did_request_redraw_ = false; |
2855 EXPECT_EQ(base::TimeDelta(), requested_animation_delay_); | 2876 EXPECT_EQ(base::TimeDelta(), requested_animation_delay_); |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2943 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, 0, 5, fake_now); | 2964 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, 0, 5, fake_now); |
2944 host_impl_->WillBeginImplFrame(begin_frame_args); | 2965 host_impl_->WillBeginImplFrame(begin_frame_args); |
2945 host_impl_->Animate(); | 2966 host_impl_->Animate(); |
2946 EXPECT_FALSE(did_request_next_frame_); | 2967 EXPECT_FALSE(did_request_next_frame_); |
2947 did_request_next_frame_ = false; | 2968 did_request_next_frame_ = false; |
2948 EXPECT_FALSE(did_request_redraw_); | 2969 EXPECT_FALSE(did_request_redraw_); |
2949 did_request_redraw_ = false; | 2970 did_request_redraw_ = false; |
2950 host_impl_->DidFinishImplFrame(); | 2971 host_impl_->DidFinishImplFrame(); |
2951 } | 2972 } |
2952 | 2973 |
2953 // Scrollbar animation is not triggered unnecessarily. | 2974 // For Andrdoid, scrollbar animation is not triggered unnecessarily. |
| 2975 // For Aura Overlay Scrollbar, scrollbar appears even if scroll offset did |
| 2976 // not change. |
2954 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), | 2977 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), |
2955 InputHandler::WHEEL); | 2978 InputHandler::WHEEL); |
2956 host_impl_->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2dF(5, 0)).get()); | 2979 host_impl_->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2dF(5, 0)).get()); |
2957 EXPECT_FALSE(did_request_next_frame_); | 2980 EXPECT_FALSE(did_request_next_frame_); |
2958 EXPECT_TRUE(did_request_redraw_); | 2981 EXPECT_TRUE(did_request_redraw_); |
2959 did_request_redraw_ = false; | 2982 did_request_redraw_ = false; |
2960 EXPECT_EQ(base::TimeDelta(), requested_animation_delay_); | 2983 EXPECT_EQ(base::TimeDelta(), requested_animation_delay_); |
2961 EXPECT_TRUE(animation_task_.Equals(base::Closure())); | 2984 EXPECT_TRUE(animation_task_.Equals(base::Closure())); |
2962 | 2985 |
2963 host_impl_->ScrollEnd(EndState().get()); | 2986 host_impl_->ScrollEnd(EndState().get()); |
2964 EXPECT_FALSE(did_request_next_frame_); | 2987 EXPECT_FALSE(did_request_next_frame_); |
2965 EXPECT_FALSE(did_request_redraw_); | 2988 EXPECT_FALSE(did_request_redraw_); |
2966 EXPECT_EQ(base::TimeDelta(), requested_animation_delay_); | 2989 if (animator == LayerTreeSettings::AURA_OVERLAY) { |
2967 EXPECT_TRUE(animation_task_.Equals(base::Closure())); | 2990 EXPECT_EQ(base::TimeDelta::FromMilliseconds(20), |
| 2991 requested_animation_delay_); |
| 2992 EXPECT_FALSE(animation_task_.Equals(base::Closure())); |
| 2993 requested_animation_delay_ = base::TimeDelta(); |
| 2994 animation_task_ = base::Closure(); |
| 2995 } else { |
| 2996 EXPECT_EQ(base::TimeDelta(), requested_animation_delay_); |
| 2997 EXPECT_TRUE(animation_task_.Equals(base::Closure())); |
| 2998 } |
2968 | 2999 |
2969 // Changing page scale triggers scrollbar animation. | 3000 // Changing page scale triggers scrollbar animation. |
2970 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 1.f, 4.f); | 3001 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 1.f, 4.f); |
2971 host_impl_->active_tree()->SetPageScaleOnActiveTree(1.1f); | 3002 host_impl_->active_tree()->SetPageScaleOnActiveTree(1.1f); |
2972 EXPECT_FALSE(did_request_next_frame_); | 3003 EXPECT_FALSE(did_request_next_frame_); |
2973 EXPECT_FALSE(did_request_redraw_); | 3004 EXPECT_FALSE(did_request_redraw_); |
2974 if (expecting_animations) { | 3005 if (expecting_animations) { |
2975 EXPECT_EQ(base::TimeDelta::FromMilliseconds(20), | 3006 EXPECT_EQ(base::TimeDelta::FromMilliseconds(20), |
2976 requested_animation_delay_); | 3007 requested_animation_delay_); |
2977 EXPECT_FALSE(animation_task_.Equals(base::Closure())); | 3008 EXPECT_FALSE(animation_task_.Equals(base::Closure())); |
(...skipping 9016 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11994 else | 12025 else |
11995 EXPECT_FALSE(tile->HasRasterTask()); | 12026 EXPECT_FALSE(tile->HasRasterTask()); |
11996 } | 12027 } |
11997 Region expected_invalidation( | 12028 Region expected_invalidation( |
11998 raster_source->GetRectForImage(checkerable_image->uniqueID())); | 12029 raster_source->GetRectForImage(checkerable_image->uniqueID())); |
11999 EXPECT_EQ(expected_invalidation, *(root->GetPendingInvalidation())); | 12030 EXPECT_EQ(expected_invalidation, *(root->GetPendingInvalidation())); |
12000 } | 12031 } |
12001 | 12032 |
12002 } // namespace | 12033 } // namespace |
12003 } // namespace cc | 12034 } // namespace cc |
OLD | NEW |