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_CONTENTS_DISPLAY_H_ | |
6 #define BLIMP_CLIENT_APP_ANDROID_BLIMP_CONTENTS_DISPLAY_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 BlimpContents; | |
22 class CompositorDependencies; | |
23 class BlimpEnvironment; | |
24 class BrowserCompositor; | |
25 | |
26 namespace app { | |
27 | |
28 // The native component of org.chromium.blimp.BlimpContentsDisplay. This builds | |
29 // and maintains a BlimpCompositorAndroid and handles notifying the compositor | |
30 // of SurfaceView surface changes (size, creation, destruction, etc.). | |
31 class BlimpContentsDisplay { | |
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 BlimpContentsDisplay(JNIEnv* env, | |
41 const base::android::JavaParamRef<jobject>& jobj, | |
42 const gfx::Size& real_size, | |
43 const gfx::Size& size, | |
44 BlimpEnvironment* blimp_environment, | |
45 BlimpContents* blimp_contents); | |
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 | |
66 private: | |
67 virtual ~BlimpContentsDisplay(); | |
68 | |
69 void OnSwapBuffersCompleted(); | |
70 | |
71 void SetSurface(jobject surface); | |
72 | |
73 // Reference to the Java object which owns this class. | |
74 base::android::ScopedJavaGlobalRef<jobject> java_obj_; | |
75 | |
76 std::unique_ptr<CompositorDependencies> compositor_dependencies_; | |
77 std::unique_ptr<BrowserCompositor> compositor_; | |
78 | |
79 BlimpContents* blimp_contents_; | |
80 | |
81 // The format of the current surface owned by |compositor_|. See | |
82 // android.graphics.PixelFormat.java. | |
83 int current_surface_format_; | |
84 | |
85 gfx::AcceleratedWidget window_; | |
86 | |
87 base::WeakPtrFactory<BlimpContentsDisplay> weak_ptr_factory_; | |
88 | |
89 DISALLOW_COPY_AND_ASSIGN(BlimpContentsDisplay); | |
90 }; | |
91 | |
92 } // namespace app | |
93 } // namespace client | |
94 } // namespace blimp | |
95 | |
96 #endif // BLIMP_CLIENT_APP_ANDROID_BLIMP_CONTENTS_DISPLAY_H_ | |
OLD | NEW |