Disable StorageInfoProviderTest.* on Valgrind bots.
[chromium-blink-merge.git] / cc / scrollbar_animation_controller_linear_fade.cc
blob201f6d4f49e7d5e7cdece6bd0cdd42930a24ecea
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
3 // found in the LICENSE file.
5 #include "cc/scrollbar_animation_controller_linear_fade.h"
7 #include "cc/scrollbar_layer_impl.h"
9 namespace cc {
11 scoped_ptr<ScrollbarAnimationControllerLinearFade> ScrollbarAnimationControllerLinearFade::create(LayerImpl* scrollLayer, double fadeoutDelay, double fadeoutLength)
13 return make_scoped_ptr(new ScrollbarAnimationControllerLinearFade(scrollLayer, fadeoutDelay, fadeoutLength));
16 ScrollbarAnimationControllerLinearFade::ScrollbarAnimationControllerLinearFade(LayerImpl* scrollLayer, double fadeoutDelay, double fadeoutLength)
17 : ScrollbarAnimationController(scrollLayer)
18 , m_lastAwakenTime(-100000000) // arbitrary invalid timestamp
19 , m_pinchGestureInEffect(false)
20 , m_fadeoutDelay(fadeoutDelay)
21 , m_fadeoutLength(fadeoutLength)
25 ScrollbarAnimationControllerLinearFade::~ScrollbarAnimationControllerLinearFade()
29 bool ScrollbarAnimationControllerLinearFade::animate(double monotonicTime)
31 float opacity = opacityAtTime(monotonicTime);
32 if (horizontalScrollbarLayer())
33 horizontalScrollbarLayer()->setOpacity(opacity);
34 if (verticalScrollbarLayer())
35 verticalScrollbarLayer()->setOpacity(opacity);
36 return opacity;
39 void ScrollbarAnimationControllerLinearFade::didPinchGestureUpdateAtTime(double)
41 m_pinchGestureInEffect = true;
44 void ScrollbarAnimationControllerLinearFade::didPinchGestureEndAtTime(double monotonicTime)
46 m_pinchGestureInEffect = false;
47 m_lastAwakenTime = monotonicTime;
50 void ScrollbarAnimationControllerLinearFade::updateScrollOffsetAtTime(LayerImpl* scrollLayer, double monotonicTime)
52 gfx::Vector2dF previousPos = currentOffset();
53 ScrollbarAnimationController::updateScrollOffsetAtTime(scrollLayer, monotonicTime);
55 if (previousPos == currentOffset())
56 return;
58 m_lastAwakenTime = monotonicTime;
61 float ScrollbarAnimationControllerLinearFade::opacityAtTime(double monotonicTime)
63 if (m_pinchGestureInEffect)
64 return 1;
66 double delta = monotonicTime - m_lastAwakenTime;
68 if (delta <= m_fadeoutDelay)
69 return 1;
70 if (delta < m_fadeoutDelay + m_fadeoutLength)
71 return (m_fadeoutDelay + m_fadeoutLength - delta) / m_fadeoutLength;
72 return 0;
75 } // namespace cc