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_APP_ANDROID_BLIMP_VIEW_H_ | 5 #ifndef BLIMP_CLIENT_APP_ANDROID_BLIMP_VIEW_H_ |
6 #define BLIMP_CLIENT_APP_ANDROID_BLIMP_VIEW_H_ | 6 #define BLIMP_CLIENT_APP_ANDROID_BLIMP_VIEW_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 | 9 |
10 #include "base/android/jni_android.h" | 10 #include "base/android/jni_android.h" |
11 #include "base/macros.h" | 11 #include "base/macros.h" |
12 #include "blimp/client/app/android/blimp_compositor_manager_android.h" | 12 #include "blimp/client/app/android/blimp_compositor_manager_android.h" |
13 #include "ui/gfx/native_widget_types.h" | 13 #include "ui/gfx/native_widget_types.h" |
14 | 14 |
15 namespace gfx { | 15 namespace gfx { |
16 class Size; | 16 class Size; |
17 } | 17 } |
18 | 18 |
19 namespace blimp { | 19 namespace blimp { |
20 namespace client { | 20 namespace client { |
21 | 21 class BrowserCompositor; |
22 class RenderWidgetFeature; | 22 class RenderWidgetFeature; |
23 | 23 |
24 // The native component of org.chromium.blimp.BlimpView. This builds and | 24 // The native component of org.chromium.blimp.BlimpView. This builds and |
25 // maintains a BlimpCompositorAndroid and handles notifying the compositor of | 25 // maintains a BlimpCompositorAndroid and handles notifying the compositor of |
26 // SurfaceView surface changes (size, creation, destruction, etc.). | 26 // SurfaceView surface changes (size, creation, destruction, etc.). |
27 class BlimpView : public BlimpCompositorManagerClient { | 27 class BlimpView { |
28 public: | 28 public: |
29 static bool RegisterJni(JNIEnv* env); | 29 static bool RegisterJni(JNIEnv* env); |
30 | 30 |
31 // |real_size| is the total display area including system decorations (see | 31 // |real_size| is the total display area including system decorations (see |
32 // android.view.Display.getRealSize()). |size| is the total display | 32 // android.view.Display.getRealSize()). |size| is the total display |
33 // area not including system decorations (see android.view.Display.getSize()). | 33 // area not including system decorations (see android.view.Display.getSize()). |
34 // |dp_to_px| is the scale factor that is required to convert dp (device | 34 // |dp_to_px| is the scale factor that is required to convert dp (device |
35 // pixels) to px. | 35 // pixels) to px. |
36 BlimpView(JNIEnv* env, | 36 BlimpView(JNIEnv* env, |
37 const base::android::JavaParamRef<jobject>& jobj, | 37 const base::android::JavaParamRef<jobject>& jobj, |
38 const gfx::Size& real_size, | 38 const gfx::Size& real_size, |
39 const gfx::Size& size, | 39 const gfx::Size& size, |
40 float dp_to_px, | 40 float dp_to_px, |
41 RenderWidgetFeature* render_widget_feature); | 41 RenderWidgetFeature* render_widget_feature); |
42 | 42 |
43 // Methods called from Java via JNI. | 43 // Methods called from Java via JNI. |
44 void Destroy(JNIEnv* env, const base::android::JavaParamRef<jobject>& jobj); | 44 void Destroy(JNIEnv* env, const base::android::JavaParamRef<jobject>& jobj); |
45 void SetNeedsComposite(JNIEnv* env, | 45 void OnContentAreaSizeChanged( |
46 const base::android::JavaParamRef<jobject>& jobj); | 46 JNIEnv* env, |
| 47 const base::android::JavaParamRef<jobject>& jobj, |
| 48 jint width, |
| 49 jint height, |
| 50 jfloat dpToPx); |
47 void OnSurfaceChanged(JNIEnv* env, | 51 void OnSurfaceChanged(JNIEnv* env, |
48 const base::android::JavaParamRef<jobject>& jobj, | 52 const base::android::JavaParamRef<jobject>& jobj, |
49 jint format, | 53 jint format, |
50 jint width, | 54 jint width, |
51 jint height, | 55 jint height, |
52 const base::android::JavaParamRef<jobject>& jsurface); | 56 const base::android::JavaParamRef<jobject>& jsurface); |
53 void OnSurfaceCreated(JNIEnv* env, | 57 void OnSurfaceCreated(JNIEnv* env, |
54 const base::android::JavaParamRef<jobject>& jobj); | 58 const base::android::JavaParamRef<jobject>& jobj); |
55 void OnSurfaceDestroyed(JNIEnv* env, | 59 void OnSurfaceDestroyed(JNIEnv* env, |
56 const base::android::JavaParamRef<jobject>& jobj); | 60 const base::android::JavaParamRef<jobject>& jobj); |
57 void SetVisibility(JNIEnv* env, | |
58 const base::android::JavaParamRef<jobject>& jobj, | |
59 jboolean visible); | |
60 jboolean OnTouchEvent( | 61 jboolean OnTouchEvent( |
61 JNIEnv* env, | 62 JNIEnv* env, |
62 const base::android::JavaParamRef<jobject>& obj, | 63 const base::android::JavaParamRef<jobject>& obj, |
63 const base::android::JavaParamRef<jobject>& motion_event, | 64 const base::android::JavaParamRef<jobject>& motion_event, |
64 jlong time_ms, | 65 jlong time_ms, |
65 jint android_action, | 66 jint android_action, |
66 jint pointer_count, | 67 jint pointer_count, |
67 jint history_size, | 68 jint history_size, |
68 jint action_index, | 69 jint action_index, |
69 jfloat pos_x_0, | 70 jfloat pos_x_0, |
(...skipping 13 matching lines...) Expand all Loading... |
83 jfloat raw_pos_x, | 84 jfloat raw_pos_x, |
84 jfloat raw_pos_y, | 85 jfloat raw_pos_y, |
85 jint android_tool_type_0, | 86 jint android_tool_type_0, |
86 jint android_tool_type_1, | 87 jint android_tool_type_1, |
87 jint android_button_state, | 88 jint android_button_state, |
88 jint android_meta_state); | 89 jint android_meta_state); |
89 | 90 |
90 private: | 91 private: |
91 virtual ~BlimpView(); | 92 virtual ~BlimpView(); |
92 | 93 |
93 void ReleaseAcceleratedWidget(); | 94 void OnSwapBuffersCompleted(); |
94 | 95 |
95 // BlimpCompositorManagerClient implementation. | 96 void SetSurface(jobject surface); |
96 void OnSwapBuffersCompleted() override; | |
97 void DidCommitAndDrawFrame() override; | |
98 | 97 |
99 // Reference to the Java object which owns this class. | 98 // Reference to the Java object which owns this class. |
100 base::android::ScopedJavaGlobalRef<jobject> java_obj_; | 99 base::android::ScopedJavaGlobalRef<jobject> java_obj_; |
101 | 100 |
102 const float device_scale_factor_; | 101 const float device_scale_factor_; |
103 | 102 |
| 103 std::unique_ptr<BrowserCompositor> compositor_; |
| 104 |
104 std::unique_ptr<BlimpCompositorManagerAndroid> compositor_manager_; | 105 std::unique_ptr<BlimpCompositorManagerAndroid> compositor_manager_; |
105 | 106 |
106 // The format of the current surface owned by |compositor_|. See | 107 // The format of the current surface owned by |compositor_|. See |
107 // android.graphics.PixelFormat.java. | 108 // android.graphics.PixelFormat.java. |
108 int current_surface_format_; | 109 int current_surface_format_; |
109 | 110 |
110 gfx::AcceleratedWidget window_; | 111 gfx::AcceleratedWidget window_; |
111 | 112 |
| 113 base::WeakPtrFactory<BlimpView> weak_ptr_factory_; |
| 114 |
112 DISALLOW_COPY_AND_ASSIGN(BlimpView); | 115 DISALLOW_COPY_AND_ASSIGN(BlimpView); |
113 }; | 116 }; |
114 | 117 |
115 } // namespace client | 118 } // namespace client |
116 } // namespace blimp | 119 } // namespace blimp |
117 | 120 |
118 #endif // BLIMP_CLIENT_APP_ANDROID_BLIMP_VIEW_H_ | 121 #endif // BLIMP_CLIENT_APP_ANDROID_BLIMP_VIEW_H_ |
OLD | NEW |