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