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

Side by Side Diff: webkit/child/fling_animator_impl_android.h

Issue 172933004: [Android] Port Scroller.java to C++ and use for fling animations (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Cleanup Created 6 years, 10 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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 #ifndef WEBKIT_CHILD_FLING_ANIMATOR_IMPL_ANDROID_H_ 5 #ifndef WEBKIT_CHILD_FLING_ANIMATOR_IMPL_ANDROID_H_
6 #define WEBKIT_CHILD_FLING_ANIMATOR_IMPL_ANDROID_H_ 6 #define WEBKIT_CHILD_FLING_ANIMATOR_IMPL_ANDROID_H_
7 7
8 #include "base/android/scoped_java_ref.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "third_party/WebKit/public/platform/WebFloatPoint.h" 9 #include "third_party/WebKit/public/platform/WebFloatPoint.h"
10 #include "third_party/WebKit/public/platform/WebGestureCurve.h" 10 #include "third_party/WebKit/public/platform/WebGestureCurve.h"
11 #include "third_party/WebKit/public/platform/WebSize.h" 11 #include "third_party/WebKit/public/platform/WebSize.h"
12 #include "ui/gfx/point.h"
13 #include "ui/gfx/point_f.h" 12 #include "ui/gfx/point_f.h"
14 #include "webkit/child/webkit_child_export.h" 13 #include "webkit/child/webkit_child_export.h"
15 14
16 namespace blink { 15 namespace blink {
17 class WebGestureCurveTarget; 16 class WebGestureCurveTarget;
18 } 17 }
19 18
19 namespace gfx {
20 class Scroller;
21 }
22
20 namespace webkit_glue { 23 namespace webkit_glue {
21 24
22 class WEBKIT_CHILD_EXPORT FlingAnimatorImpl : public blink::WebGestureCurve { 25 class WEBKIT_CHILD_EXPORT FlingAnimatorImpl : public blink::WebGestureCurve {
23 public: 26 public:
24 FlingAnimatorImpl(); 27 FlingAnimatorImpl();
25 virtual ~FlingAnimatorImpl(); 28 virtual ~FlingAnimatorImpl();
26 29
27 static FlingAnimatorImpl* CreateAndroidGestureCurve( 30 static FlingAnimatorImpl* CreateAndroidGestureCurve(
28 const blink::WebFloatPoint& velocity, 31 const blink::WebFloatPoint& velocity,
29 const blink::WebSize&); 32 const blink::WebSize&);
30 33
31 virtual bool apply(double time, 34 virtual bool apply(double time, blink::WebGestureCurveTarget* target);
32 blink::WebGestureCurveTarget* target);
33
34 static bool RegisterJni(JNIEnv*);
35 35
36 private: 36 private:
37 void StartFling(const gfx::PointF& velocity); 37 void StartFling(const gfx::PointF& velocity);
38 // Returns true if the animation is not yet finished. 38 void CancelFling();
39 bool UpdatePosition();
40 gfx::Point GetCurrentPosition();
41 float GetCurrentVelocity();
42 virtual void CancelFling();
43 39
44 bool is_active_; 40 bool is_active_;
45 41
46 // Java OverScroller instance and methods. 42 scoped_ptr<gfx::Scroller> scroller_;
jamesr 2014/02/21 23:41:13 why heap allocate this object? it's always constru
jdduke (slow) 2014/02/22 00:06:57 No reason at all, done.
47 base::android::ScopedJavaGlobalRef<jobject> java_scroller_;
48 43
49 gfx::Point last_position_; 44 gfx::PointF last_position_;
50 gfx::PointF last_velocity_;
51 double last_time_;
52 45
53 DISALLOW_COPY_AND_ASSIGN(FlingAnimatorImpl); 46 DISALLOW_COPY_AND_ASSIGN(FlingAnimatorImpl);
54 }; 47 };
55 48
56 } // namespace webkit_glue 49 } // namespace webkit_glue
57 50
58 #endif // WEBKIT_CHILD_FLING_ANIMATOR_IMPL_ANDROID_H_ 51 #endif // WEBKIT_CHILD_FLING_ANIMATOR_IMPL_ANDROID_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698