OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 CHROME_BROWSER_ANDROID_VR_SHELL_VR_SHELL_H_ | 5 #ifndef CHROME_BROWSER_ANDROID_VR_SHELL_VR_SHELL_H_ |
6 #define CHROME_BROWSER_ANDROID_VR_SHELL_VR_SHELL_H_ | 6 #define CHROME_BROWSER_ANDROID_VR_SHELL_VR_SHELL_H_ |
7 | 7 |
8 #include <jni.h> | 8 #include <jni.h> |
9 | 9 |
10 #include <memory> | 10 #include <memory> |
11 | 11 |
12 #include "base/android/jni_weak_ref.h" | 12 #include "base/android/jni_weak_ref.h" |
13 #include "base/callback.h" | 13 #include "base/callback.h" |
14 #include "base/macros.h" | 14 #include "base/macros.h" |
15 #include "base/memory/weak_ptr.h" | 15 #include "base/memory/weak_ptr.h" |
16 #include "base/single_thread_task_runner.h" | 16 #include "base/single_thread_task_runner.h" |
17 #include "content/public/browser/web_contents_observer.h" | 17 #include "content/public/browser/web_contents_observer.h" |
18 #include "device/vr/android/gvr/gvr_delegate.h" | 18 #include "device/vr/android/gvr/gvr_delegate.h" |
19 #include "third_party/gvr-android-sdk/src/ndk/include/vr/gvr/capi/include/gvr.h" | 19 #include "third_party/gvr-android-sdk/src/ndk/include/vr/gvr/capi/include/gvr.h" |
20 #include "third_party/gvr-android-sdk/src/ndk/include/vr/gvr/capi/include/gvr_ty
pes.h" | 20 #include "third_party/gvr-android-sdk/src/ndk/include/vr/gvr/capi/include/gvr_ty
pes.h" |
21 | 21 |
22 namespace base { | 22 namespace base { |
| 23 class ListValue; |
23 class Thread; | 24 class Thread; |
24 } | 25 } |
25 | 26 |
26 namespace content { | 27 namespace content { |
27 class WebContents; | 28 class WebContents; |
28 } | 29 } |
29 | 30 |
30 namespace ui { | 31 namespace ui { |
31 class WindowAndroid; | 32 class WindowAndroid; |
32 } | 33 } |
33 | 34 |
34 namespace vr_shell { | 35 namespace vr_shell { |
35 | 36 |
36 class UiInterface; | 37 class UiInterface; |
37 class UiScene; | |
38 class VrCompositor; | 38 class VrCompositor; |
39 class VrInputManager; | 39 class VrInputManager; |
40 class VrMetricsHelper; | 40 class VrMetricsHelper; |
41 class VrShellDelegate; | 41 class VrShellDelegate; |
42 class VrWebContentsObserver; | 42 class VrWebContentsObserver; |
43 | 43 |
44 enum UiAction { | 44 enum UiAction { |
45 HISTORY_BACK = 0, | 45 HISTORY_BACK = 0, |
46 HISTORY_FORWARD, | 46 HISTORY_FORWARD, |
47 RELOAD, | 47 RELOAD, |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 | 80 |
81 void ContentWebContentsDestroyed(); | 81 void ContentWebContentsDestroyed(); |
82 // Called when our WebContents have been hidden. Usually a sign that something | 82 // Called when our WebContents have been hidden. Usually a sign that something |
83 // like another tab placed in front of it. | 83 // like another tab placed in front of it. |
84 void ContentWasHidden(); | 84 void ContentWasHidden(); |
85 | 85 |
86 // html/js UI hooks. | 86 // html/js UI hooks. |
87 static base::WeakPtr<VrShell> GetWeakPtr( | 87 static base::WeakPtr<VrShell> GetWeakPtr( |
88 const content::WebContents* web_contents); | 88 const content::WebContents* web_contents); |
89 | 89 |
90 // Returns a pointer to the scene owned by the GL thread. Do not dereference | |
91 // this pointer off of the GL thread. | |
92 UiScene* GetScene(); | |
93 // TODO(mthiesse): Clean up threading around UiInterface. | 90 // TODO(mthiesse): Clean up threading around UiInterface. |
94 UiInterface* GetUiInterface(); | 91 UiInterface* GetUiInterface(); |
95 void OnDomContentsLoaded(); | 92 void OnDomContentsLoaded(); |
96 | 93 |
97 // device::GvrDelegate implementation | 94 // device::GvrDelegate implementation |
98 // TODO(mthiesse): Clean up threading around GVR API. These functions are | 95 // TODO(mthiesse): Clean up threading around GVR API. These functions are |
99 // called on the UI thread, but use GL thread objects in a non-threadsafe way. | 96 // called on the UI thread, but use GL thread objects in a non-threadsafe way. |
100 void SetWebVRSecureOrigin(bool secure_origin) override; | 97 void SetWebVRSecureOrigin(bool secure_origin) override; |
101 void SubmitWebVRFrame() override; | 98 void SubmitWebVRFrame() override; |
102 void UpdateWebVRTextureBounds(const gvr::Rectf& left_bounds, | 99 void UpdateWebVRTextureBounds(const gvr::Rectf& left_bounds, |
103 const gvr::Rectf& right_bounds) override; | 100 const gvr::Rectf& right_bounds) override; |
104 gvr::GvrApi* gvr_api() override; | 101 gvr::GvrApi* gvr_api() override; |
105 void SetGvrPoseForWebVr(const gvr::Mat4f& pose, uint32_t pose_num) override; | 102 void SetGvrPoseForWebVr(const gvr::Mat4f& pose, uint32_t pose_num) override; |
106 void SetWebVRRenderSurfaceSize(int width, int height) override; | 103 void SetWebVRRenderSurfaceSize(int width, int height) override; |
107 gvr::Sizei GetWebVRCompositorSurfaceSize() override; | 104 gvr::Sizei GetWebVRCompositorSurfaceSize() override; |
108 | 105 |
109 void SurfacesChanged(jobject content_surface, jobject ui_surface); | 106 void SurfacesChanged(jobject content_surface, jobject ui_surface); |
110 void GvrDelegateReady(); | 107 void GvrDelegateReady(); |
111 | 108 |
112 void ContentBoundsChanged( | 109 void ContentBoundsChanged( |
113 JNIEnv* env, | 110 JNIEnv* env, |
114 const base::android::JavaParamRef<jobject>& object, | 111 const base::android::JavaParamRef<jobject>& object, |
115 jint width, jint height, jfloat dpr); | 112 jint width, jint height, jfloat dpr); |
116 | 113 |
117 void UIBoundsChanged( | 114 void UIBoundsChanged( |
118 JNIEnv* env, | 115 JNIEnv* env, |
119 const base::android::JavaParamRef<jobject>& object, | 116 const base::android::JavaParamRef<jobject>& object, |
120 jint width, jint height, jfloat dpr); | 117 jint width, jint height, jfloat dpr); |
121 | 118 |
122 // Called from non-render thread to queue a callback onto the render thread. | 119 void UpdateScene(const base::ListValue* args); |
123 // The render thread checks for callbacks and processes them between frames. | |
124 void QueueTask(base::Callback<void()>& callback); | |
125 | 120 |
126 // Perform a UI action triggered by the javascript API. | 121 // Perform a UI action triggered by the javascript API. |
127 void DoUiAction(const UiAction action); | 122 void DoUiAction(const UiAction action); |
128 | 123 |
129 void SetContentCssSize(float width, float height, float dpr); | 124 void SetContentCssSize(float width, float height, float dpr); |
130 void SetUiCssSize(float width, float height, float dpr); | 125 void SetUiCssSize(float width, float height, float dpr); |
131 | 126 |
132 void ContentFrameWasResized(bool width_changed); | 127 void ContentFrameWasResized(bool width_changed); |
133 | 128 |
134 void ForceExitVr(); | 129 void ForceExitVr(); |
(...skipping 30 matching lines...) Expand all Loading... |
165 base::WeakPtrFactory<VrShell> weak_ptr_factory_; | 160 base::WeakPtrFactory<VrShell> weak_ptr_factory_; |
166 | 161 |
167 DISALLOW_COPY_AND_ASSIGN(VrShell); | 162 DISALLOW_COPY_AND_ASSIGN(VrShell); |
168 }; | 163 }; |
169 | 164 |
170 bool RegisterVrShell(JNIEnv* env); | 165 bool RegisterVrShell(JNIEnv* env); |
171 | 166 |
172 } // namespace vr_shell | 167 } // namespace vr_shell |
173 | 168 |
174 #endif // CHROME_BROWSER_ANDROID_VR_SHELL_VR_SHELL_H_ | 169 #endif // CHROME_BROWSER_ANDROID_VR_SHELL_VR_SHELL_H_ |
OLD | NEW |