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 "device/vr/vr_service.mojom.h" | 19 #include "device/vr/vr_service.mojom.h" |
| 20 #include "ui/android/context_provider_factory.h" |
| 21 #include "gpu/ipc/client/gpu_channel_host.h" |
20 #include "third_party/gvr-android-sdk/src/libraries/headers/vr/gvr/capi/include/
gvr.h" | 22 #include "third_party/gvr-android-sdk/src/libraries/headers/vr/gvr/capi/include/
gvr.h" |
21 #include "third_party/gvr-android-sdk/src/libraries/headers/vr/gvr/capi/include/
gvr_types.h" | 23 #include "third_party/gvr-android-sdk/src/libraries/headers/vr/gvr/capi/include/
gvr_types.h" |
22 | 24 |
23 namespace base { | 25 namespace base { |
24 class ListValue; | 26 class ListValue; |
25 } | 27 } |
26 | 28 |
27 namespace blink { | 29 namespace blink { |
28 class WebInputEvent; | 30 class WebInputEvent; |
29 } | 31 } |
30 | 32 |
31 namespace content { | 33 namespace content { |
32 class WebContents; | 34 class WebContents; |
33 } | 35 } |
34 | 36 |
| 37 namespace gpu { |
| 38 namespace gles2 { |
| 39 class GLES2Interface; |
| 40 } |
| 41 } |
| 42 |
35 namespace ui { | 43 namespace ui { |
| 44 class ContextProviderCommandBuffer; |
36 class WindowAndroid; | 45 class WindowAndroid; |
37 } | 46 } |
38 | 47 |
39 namespace vr_shell { | 48 namespace vr_shell { |
40 | 49 |
41 class AndroidUiGestureTarget; | 50 class AndroidUiGestureTarget; |
42 class UiInterface; | 51 class UiInterface; |
43 class VrCompositor; | 52 class VrCompositor; |
44 class VrGLThread; | 53 class VrGLThread; |
45 class VrInputManager; | 54 class VrInputManager; |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 | 132 |
124 // html/js UI hooks. | 133 // html/js UI hooks. |
125 static base::WeakPtr<VrShell> GetWeakPtr( | 134 static base::WeakPtr<VrShell> GetWeakPtr( |
126 const content::WebContents* web_contents); | 135 const content::WebContents* web_contents); |
127 | 136 |
128 UiInterface* GetUiInterface(); | 137 UiInterface* GetUiInterface(); |
129 void OnDomContentsLoaded(); | 138 void OnDomContentsLoaded(); |
130 | 139 |
131 void UiSurfaceChanged(jobject surface); | 140 void UiSurfaceChanged(jobject surface); |
132 void ContentSurfaceChanged(jobject surface); | 141 void ContentSurfaceChanged(jobject surface); |
| 142 void WebVRSurfaceChanged(int surface_handle); |
| 143 void WebVRFrameCompleted(int frame_index); |
133 void GvrDelegateReady(); | 144 void GvrDelegateReady(); |
134 void AppButtonPressed(); | 145 void AppButtonPressed(); |
135 | 146 |
136 void ContentPhysicalBoundsChanged( | 147 void ContentPhysicalBoundsChanged( |
137 JNIEnv* env, | 148 JNIEnv* env, |
138 const base::android::JavaParamRef<jobject>& object, | 149 const base::android::JavaParamRef<jobject>& object, |
139 jint width, | 150 jint width, |
140 jint height, | 151 jint height, |
141 jfloat dpr); | 152 jfloat dpr); |
142 | 153 |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
177 void SetUiState(); | 188 void SetUiState(); |
178 | 189 |
179 // content::WebContentsObserver implementation. | 190 // content::WebContentsObserver implementation. |
180 void RenderViewHostChanged(content::RenderViewHost* old_host, | 191 void RenderViewHostChanged(content::RenderViewHost* old_host, |
181 content::RenderViewHost* new_host) override; | 192 content::RenderViewHost* new_host) override; |
182 void MainFrameWasResized(bool width_changed) override; | 193 void MainFrameWasResized(bool width_changed) override; |
183 void WebContentsDestroyed() override; | 194 void WebContentsDestroyed() override; |
184 | 195 |
185 // device::GvrDelegate implementation | 196 // device::GvrDelegate implementation |
186 void SetWebVRSecureOrigin(bool secure_origin) override; | 197 void SetWebVRSecureOrigin(bool secure_origin) override; |
187 void SubmitWebVRFrame() override; | 198 void SubmitWebVRFrame(int frame_index, const gpu::Mailbox& mailbox) override; |
188 void UpdateWebVRTextureBounds(int16_t frame_index, | 199 void UpdateWebVRTextureBounds(int16_t frame_index, |
189 const gvr::Rectf& left_bounds, | 200 const gvr::Rectf& left_bounds, |
190 const gvr::Rectf& right_bounds) override; | 201 const gvr::Rectf& right_bounds) override; |
191 void OnVRVsyncProviderRequest( | 202 void OnVRVsyncProviderRequest( |
192 device::mojom::VRVSyncProviderRequest request) override; | 203 device::mojom::VRVSyncProviderRequest request) override; |
193 void UpdateVSyncInterval(int64_t timebase_nanos, | 204 void UpdateVSyncInterval(int64_t timebase_nanos, |
194 double interval_seconds) override; | 205 double interval_seconds) override; |
195 bool SupportsPresentation() override; | 206 bool SupportsPresentation() override; |
196 void ResetPose() override; | 207 void ResetPose() override; |
197 void CreateVRDisplayInfo( | 208 void CreateVRDisplayInfo( |
198 const base::Callback<void(device::mojom::VRDisplayInfoPtr)>& callback, | 209 const base::Callback<void(device::mojom::VRDisplayInfoPtr)>& callback, |
199 uint32_t device_id) override; | 210 uint32_t device_id) override; |
200 | 211 |
201 void ProcessTabArray(JNIEnv* env, jobjectArray tabs, bool incognito); | 212 void ProcessTabArray(JNIEnv* env, jobjectArray tabs, bool incognito); |
202 | 213 |
| 214 void OnWebVrGpuChannelEstablished( |
| 215 scoped_refptr<gpu::GpuChannelHost> gpu_channel_host, |
| 216 ui::ContextProviderFactory::GpuChannelHostResult result); |
| 217 |
203 bool vr_shell_enabled_; | 218 bool vr_shell_enabled_; |
204 | 219 |
205 std::unique_ptr<UiInterface> html_interface_; | 220 std::unique_ptr<UiInterface> html_interface_; |
206 bool content_paused_ = false; | 221 bool content_paused_ = false; |
207 bool webvr_mode_ = false; | 222 bool webvr_mode_ = false; |
| 223 int webvr_surface_handle_; |
| 224 int webvr_frames_in_surface_queue_ = 0; |
| 225 |
| 226 scoped_refptr<ui::ContextProviderCommandBuffer> |
| 227 webvr_context_provider_command_buffer_; |
| 228 gpu::gles2::GLES2Interface* webvr_surface_gl_ = nullptr; |
208 | 229 |
209 content::WebContents* main_contents_ = nullptr; | 230 content::WebContents* main_contents_ = nullptr; |
210 base::android::ScopedJavaGlobalRef<jobject> j_motion_event_synthesizer_; | 231 base::android::ScopedJavaGlobalRef<jobject> j_motion_event_synthesizer_; |
211 ui::WindowAndroid* content_window_; | 232 ui::WindowAndroid* content_window_; |
212 std::unique_ptr<VrCompositor> content_compositor_; | 233 std::unique_ptr<VrCompositor> content_compositor_; |
213 content::WebContents* ui_contents_; | 234 content::WebContents* ui_contents_; |
214 std::unique_ptr<VrCompositor> ui_compositor_; | 235 std::unique_ptr<VrCompositor> ui_compositor_; |
215 | 236 |
216 std::unique_ptr<VrWebContentsObserver> vr_web_contents_observer_; | 237 std::unique_ptr<VrWebContentsObserver> vr_web_contents_observer_; |
217 | 238 |
(...skipping 18 matching lines...) Expand all Loading... |
236 base::WeakPtrFactory<VrShell> weak_ptr_factory_; | 257 base::WeakPtrFactory<VrShell> weak_ptr_factory_; |
237 | 258 |
238 DISALLOW_COPY_AND_ASSIGN(VrShell); | 259 DISALLOW_COPY_AND_ASSIGN(VrShell); |
239 }; | 260 }; |
240 | 261 |
241 bool RegisterVrShell(JNIEnv* env); | 262 bool RegisterVrShell(JNIEnv* env); |
242 | 263 |
243 } // namespace vr_shell | 264 } // namespace vr_shell |
244 | 265 |
245 #endif // CHROME_BROWSER_ANDROID_VR_SHELL_VR_SHELL_H_ | 266 #endif // CHROME_BROWSER_ANDROID_VR_SHELL_VR_SHELL_H_ |
OLD | NEW |