clang/win: Try to fix 64-bit build more after https://codereview.chromium.org/1261953003.
[chromium-blink-merge.git] / cc / animation / scrollbar_animation_controller.h
blob795c7c1766c0794660bbc4076907a5662d37da8f
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 #ifndef CC_ANIMATION_SCROLLBAR_ANIMATION_CONTROLLER_H_
6 #define CC_ANIMATION_SCROLLBAR_ANIMATION_CONTROLLER_H_
8 #include "base/cancelable_callback.h"
9 #include "base/memory/weak_ptr.h"
10 #include "base/time/time.h"
11 #include "cc/base/cc_export.h"
12 #include "cc/layers/layer_impl.h"
13 #include "ui/gfx/geometry/vector2d_f.h"
15 namespace cc {
17 class ScrollbarAnimationController;
19 class CC_EXPORT ScrollbarAnimationControllerClient {
20 public:
21 virtual void StartAnimatingScrollbarAnimationController(
22 ScrollbarAnimationController* controller) = 0;
23 virtual void StopAnimatingScrollbarAnimationController(
24 ScrollbarAnimationController* controller) = 0;
25 virtual void PostDelayedScrollbarAnimationTask(const base::Closure& task,
26 base::TimeDelta delay) = 0;
27 virtual void SetNeedsRedrawForScrollbarAnimation() = 0;
29 protected:
30 virtual ~ScrollbarAnimationControllerClient() {}
33 // This abstract class represents the compositor-side analogy of
34 // ScrollbarAnimator. Individual platforms should subclass it to provide
35 // specialized implementation.
36 class CC_EXPORT ScrollbarAnimationController {
37 public:
38 virtual ~ScrollbarAnimationController();
40 void Animate(base::TimeTicks now);
42 virtual void DidScrollBegin();
43 virtual void DidScrollUpdate(bool on_resize);
44 virtual void DidScrollEnd();
45 virtual void DidMouseMoveOffScrollbar() {}
46 virtual void DidMouseMoveNear(float distance) {}
48 protected:
49 ScrollbarAnimationController(LayerImpl* scroll_layer,
50 ScrollbarAnimationControllerClient* client,
51 base::TimeDelta delay_before_starting,
52 base::TimeDelta resize_delay_before_starting,
53 base::TimeDelta duration);
55 virtual void RunAnimationFrame(float progress) = 0;
57 void StartAnimation();
58 void StopAnimation();
60 LayerImpl* scroll_layer_;
61 ScrollbarAnimationControllerClient* client_;
63 private:
64 // Returns how far through the animation we are as a progress value from
65 // 0 to 1.
66 float AnimationProgressAtTime(base::TimeTicks now);
68 void PostDelayedAnimationTask(bool on_resize);
70 base::TimeTicks last_awaken_time_;
71 base::TimeDelta delay_before_starting_;
72 base::TimeDelta resize_delay_before_starting_;
73 base::TimeDelta duration_;
75 bool is_animating_;
77 bool currently_scrolling_;
78 bool scroll_gesture_has_scrolled_;
79 base::CancelableClosure delayed_scrollbar_fade_;
81 base::WeakPtrFactory<ScrollbarAnimationController> weak_factory_;
84 } // namespace cc
86 #endif // CC_ANIMATION_SCROLLBAR_ANIMATION_CONTROLLER_H_