OLD | NEW |
---|---|
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 BLIMP_CLIENT_ANDROID_BLIMP_VIEW_H_ | 5 #ifndef BLIMP_CLIENT_ANDROID_BLIMP_VIEW_H_ |
6 #define BLIMP_CLIENT_ANDROID_BLIMP_VIEW_H_ | 6 #define BLIMP_CLIENT_ANDROID_BLIMP_VIEW_H_ |
7 | 7 |
8 #include "base/android/jni_android.h" | 8 #include "base/android/jni_android.h" |
9 #include "base/macros.h" | 9 #include "base/macros.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
11 #include "ui/events/gesture_detection/filtered_gesture_provider.h" | |
11 | 12 |
12 namespace gfx { | 13 namespace gfx { |
13 class Size; | 14 class Size; |
14 } | 15 } |
15 | 16 |
16 namespace blimp { | 17 namespace blimp { |
17 | 18 |
18 class BlimpCompositorAndroid; | 19 class BlimpCompositorAndroid; |
19 | 20 |
20 // The native component of org.chromium.blimp.BlimpView. This builds and | 21 // The native component of org.chromium.blimp.BlimpView. This builds and |
21 // maintains a BlimpCompositorAndroid and handles notifying the compositor of | 22 // maintains a BlimpCompositorAndroid and handles notifying the compositor of |
22 // SurfaceView surface changes (size, creation, destruction, etc.). | 23 // SurfaceView surface changes (size, creation, destruction, etc.). |
23 class BlimpView { | 24 class BlimpView : public ui::GestureProviderClient { |
24 public: | 25 public: |
25 static bool RegisterJni(JNIEnv* env); | 26 static bool RegisterJni(JNIEnv* env); |
26 | 27 |
27 // |real_size| is the total display area including system decorations (see | 28 // |real_size| is the total display area including system decorations (see |
28 // android.view.Display.getRealSize()). |size| is the total display | 29 // android.view.Display.getRealSize()). |size| is the total display |
29 // area not including system decorations (see android.view.Display.getSize()). | 30 // area not including system decorations (see android.view.Display.getSize()). |
30 // |dp_to_px| is the scale factor that is required to convert dp (device | 31 // |dp_to_px| is the scale factor that is required to convert dp (device |
31 // pixels) to px. | 32 // pixels) to px. |
32 BlimpView(JNIEnv* env, | 33 BlimpView(JNIEnv* env, |
33 const base::android::JavaParamRef<jobject>& jobj, | 34 const base::android::JavaParamRef<jobject>& jobj, |
34 const gfx::Size& real_size, | 35 const gfx::Size& real_size, |
35 const gfx::Size& size, | 36 const gfx::Size& size, |
36 float dp_to_px); | 37 float dp_to_px); |
37 | 38 |
38 // Methods called from Java via JNI. | 39 // Methods called from Java via JNI. |
39 void Destroy(JNIEnv* env, jobject jobj); | 40 void Destroy(JNIEnv* env, jobject jobj); |
40 void SetNeedsComposite(JNIEnv* env, jobject jobj); | 41 void SetNeedsComposite(JNIEnv* env, jobject jobj); |
41 void OnSurfaceChanged(JNIEnv* env, | 42 void OnSurfaceChanged(JNIEnv* env, |
42 jobject jobj, | 43 jobject jobj, |
43 jint format, | 44 jint format, |
44 jint width, | 45 jint width, |
45 jint height, | 46 jint height, |
46 jobject jsurface); | 47 jobject jsurface); |
47 void OnSurfaceCreated(JNIEnv* env, jobject jobj); | 48 void OnSurfaceCreated(JNIEnv* env, jobject jobj); |
48 void OnSurfaceDestroyed(JNIEnv* env, jobject jobj); | 49 void OnSurfaceDestroyed(JNIEnv* env, jobject jobj); |
49 void SetVisibility(JNIEnv* env, jobject jobj, jboolean visible); | 50 void SetVisibility(JNIEnv* env, jobject jobj, jboolean visible); |
51 jboolean OnTouchEvent(JNIEnv* env, | |
52 jobject obj, | |
53 jobject motion_event, | |
54 jlong time_ms, | |
55 jint android_action, | |
56 jint pointer_count, | |
57 jint history_size, | |
58 jint action_index, | |
59 jfloat pos_x_0, | |
60 jfloat pos_y_0, | |
61 jfloat pos_x_1, | |
62 jfloat pos_y_1, | |
63 jint pointer_id_0, | |
64 jint pointer_id_1, | |
65 jfloat touch_major_0, | |
66 jfloat touch_major_1, | |
67 jfloat touch_minor_0, | |
68 jfloat touch_minor_1, | |
69 jfloat orientation_0, | |
70 jfloat orientation_1, | |
71 jfloat raw_pos_x, | |
72 jfloat raw_pos_y, | |
73 jint android_tool_type_0, | |
74 jint android_tool_type_1, | |
75 jint android_button_state, | |
76 jint android_meta_state); | |
77 | |
78 // ui::GestureProviderClient implementation. | |
79 void OnGestureEvent(const ui::GestureEventData& gesture) override; | |
50 | 80 |
51 private: | 81 private: |
52 virtual ~BlimpView(); | 82 virtual ~BlimpView(); |
53 | 83 |
54 // Reference to the Java object which owns this class. | 84 // Reference to the Java object which owns this class. |
55 base::android::ScopedJavaGlobalRef<jobject> java_obj_; | 85 base::android::ScopedJavaGlobalRef<jobject> java_obj_; |
56 | 86 |
87 float device_scale_factor_; | |
David Trainor- moved to gerrit
2015/11/02 16:55:30
const?
Khushal
2015/12/01 08:22:25
Done.
| |
88 | |
57 scoped_ptr<BlimpCompositorAndroid> compositor_; | 89 scoped_ptr<BlimpCompositorAndroid> compositor_; |
58 | 90 |
91 // Provides gesture synthesis given a stream of touch events (derived from | |
92 // Android MotionEvent's) and touch event acks. | |
93 ui::FilteredGestureProvider gesture_provider_; | |
94 | |
59 // The format of the current surface owned by |compositor_|. See | 95 // The format of the current surface owned by |compositor_|. See |
60 // android.graphics.PixelFormat.java. | 96 // android.graphics.PixelFormat.java. |
61 int current_surface_format_; | 97 int current_surface_format_; |
62 | 98 |
63 DISALLOW_COPY_AND_ASSIGN(BlimpView); | 99 DISALLOW_COPY_AND_ASSIGN(BlimpView); |
64 }; | 100 }; |
65 | 101 |
66 } // namespace blimp | 102 } // namespace blimp |
67 | 103 |
68 #endif // BLIMP_CLIENT_ANDROID_BLIMP_VIEW_H_ | 104 #endif // BLIMP_CLIENT_ANDROID_BLIMP_VIEW_H_ |
OLD | NEW |