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