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

Side by Side Diff: cc/scrollbar_animation_controller_linear_fade.cc

Issue 12408028: cc: Delay start of scrollbar animation setNeedsRedraw. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase to 187970 and update test Created 7 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
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/scrollbar_animation_controller_linear_fade.h" 5 #include "cc/scrollbar_animation_controller_linear_fade.h"
6 6
7 #include "base/time.h" 7 #include "base/time.h"
8 #include "cc/layer_impl.h" 8 #include "cc/layer_impl.h"
9 9
10 namespace cc { 10 namespace cc {
(...skipping 10 matching lines...) Expand all
21 , m_fadeoutDelay(fadeoutDelay) 21 , m_fadeoutDelay(fadeoutDelay)
22 , m_fadeoutLength(fadeoutLength) 22 , m_fadeoutLength(fadeoutLength)
23 , m_currentTimeForTesting(0) 23 , m_currentTimeForTesting(0)
24 { 24 {
25 } 25 }
26 26
27 ScrollbarAnimationControllerLinearFade::~ScrollbarAnimationControllerLinearFade( ) 27 ScrollbarAnimationControllerLinearFade::~ScrollbarAnimationControllerLinearFade( )
28 { 28 {
29 } 29 }
30 30
31 double ScrollbarAnimationControllerLinearFade::secondsBeforeStart(base::TimeTick s now) const
32 {
33 if (m_lastAwakenTime.is_null())
34 return -1;
35
36 double delta = (now - m_lastAwakenTime).InSecondsF();
37 return std::max(0.0, m_fadeoutDelay - delta);
38 }
39
31 bool ScrollbarAnimationControllerLinearFade::animate(base::TimeTicks now) 40 bool ScrollbarAnimationControllerLinearFade::animate(base::TimeTicks now)
32 { 41 {
33 float opacity = opacityAtTime(now); 42 float opacity = opacityAtTime(now);
34 m_scrollLayer->SetScrollbarOpacity(opacity); 43 m_scrollLayer->SetScrollbarOpacity(opacity);
35 return opacity; 44 if (!opacity)
45 m_lastAwakenTime = base::TimeTicks();
46 return secondsBeforeStart(now) == 0;
36 } 47 }
37 48
38 void ScrollbarAnimationControllerLinearFade::didPinchGestureUpdate(base::TimeTic ks now) 49 void ScrollbarAnimationControllerLinearFade::didPinchGestureUpdate(base::TimeTic ks now)
39 { 50 {
40 m_pinchGestureInEffect = true;
41 }
42
43 void ScrollbarAnimationControllerLinearFade::didPinchGestureEnd(base::TimeTicks now)
44 {
45 m_pinchGestureInEffect = false;
46 m_lastAwakenTime = now; 51 m_lastAwakenTime = now;
52 m_scrollLayer->SetScrollbarOpacity(1);
47 } 53 }
48 54
49 void ScrollbarAnimationControllerLinearFade::didUpdateScrollOffset(base::TimeTic ks now) 55 void ScrollbarAnimationControllerLinearFade::didUpdateScrollOffset(base::TimeTic ks now)
50 { 56 {
51 m_lastAwakenTime = now; 57 m_lastAwakenTime = now;
58 m_scrollLayer->SetScrollbarOpacity(1);
52 } 59 }
53 60
54 float ScrollbarAnimationControllerLinearFade::opacityAtTime(base::TimeTicks now) 61 float ScrollbarAnimationControllerLinearFade::opacityAtTime(base::TimeTicks now)
55 { 62 {
56 if (m_pinchGestureInEffect)
57 return 1;
58
59 if (m_lastAwakenTime.is_null()) 63 if (m_lastAwakenTime.is_null())
60 return 0; 64 return 0;
61 65
62 double delta = (now - m_lastAwakenTime).InSecondsF(); 66 double delta = (now - m_lastAwakenTime).InSecondsF();
63 67
64 if (delta <= m_fadeoutDelay) 68 if (delta <= m_fadeoutDelay)
65 return 1; 69 return 1;
66 if (delta < m_fadeoutDelay + m_fadeoutLength) 70 if (delta < m_fadeoutDelay + m_fadeoutLength)
67 return (m_fadeoutDelay + m_fadeoutLength - delta) / m_fadeoutLength; 71 return (m_fadeoutDelay + m_fadeoutLength - delta) / m_fadeoutLength;
68 return 0; 72 return 0;
69 } 73 }
70 74
71 } // namespace cc 75 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698