| 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 "chrome/browser/android/vr_shell/ui_interface.h" | 17 #include "chrome/browser/android/vr_shell/ui_interface.h" |
| 18 #include "chrome/browser/android/vr_shell/ui_unsupported_mode.h" | 18 #include "chrome/browser/android/vr_shell/ui_unsupported_mode.h" |
| 19 #include "chrome/browser/android/vr_shell/vr_controller_model.h" | 19 #include "chrome/browser/android/vr_shell/vr_controller_model.h" |
| 20 #include "chrome/browser/ui/toolbar/chrome_toolbar_model_delegate.h" |
| 20 #include "content/public/browser/web_contents_observer.h" | 21 #include "content/public/browser/web_contents_observer.h" |
| 21 #include "device/vr/android/gvr/cardboard_gamepad_data_provider.h" | 22 #include "device/vr/android/gvr/cardboard_gamepad_data_provider.h" |
| 22 #include "device/vr/android/gvr/gvr_delegate.h" | 23 #include "device/vr/android/gvr/gvr_delegate.h" |
| 23 #include "device/vr/android/gvr/gvr_gamepad_data_provider.h" | 24 #include "device/vr/android/gvr/gvr_gamepad_data_provider.h" |
| 24 #include "device/vr/vr_service.mojom.h" | 25 #include "device/vr/vr_service.mojom.h" |
| 25 #include "third_party/gvr-android-sdk/src/libraries/headers/vr/gvr/capi/include/
gvr_types.h" | 26 #include "third_party/gvr-android-sdk/src/libraries/headers/vr/gvr/capi/include/
gvr_types.h" |
| 26 | 27 |
| 27 namespace blink { | 28 namespace blink { |
| 28 class WebInputEvent; | 29 class WebInputEvent; |
| 29 } | 30 } |
| 30 | 31 |
| 31 namespace content { | 32 namespace content { |
| 32 class WebContents; | 33 class WebContents; |
| 33 } | 34 } |
| 34 | 35 |
| 35 namespace ui { | 36 namespace ui { |
| 36 class WindowAndroid; | 37 class WindowAndroid; |
| 37 } | 38 } |
| 38 | 39 |
| 39 namespace vr_shell { | 40 namespace vr_shell { |
| 40 | 41 |
| 41 class AndroidUiGestureTarget; | 42 class AndroidUiGestureTarget; |
| 43 class ToolbarHelper; |
| 42 class UiInterface; | 44 class UiInterface; |
| 43 class VrCompositor; | 45 class VrCompositor; |
| 44 class VrGLThread; | 46 class VrGLThread; |
| 45 class VrInputManager; | 47 class VrInputManager; |
| 46 class VrMetricsHelper; | 48 class VrMetricsHelper; |
| 47 class VrShellDelegate; | 49 class VrShellDelegate; |
| 48 class VrWebContentsObserver; | 50 class VrWebContentsObserver; |
| 49 | 51 |
| 50 enum UiAction { | 52 enum UiAction { |
| 51 HISTORY_BACK = 0, | 53 HISTORY_BACK = 0, |
| 52 HISTORY_FORWARD, | 54 HISTORY_FORWARD, |
| 53 RELOAD, | 55 RELOAD, |
| 54 SHOW_TAB, | 56 SHOW_TAB, |
| 55 OPEN_NEW_TAB, | 57 OPEN_NEW_TAB, |
| 56 EXIT_PRESENT, | 58 EXIT_PRESENT, |
| 57 }; | 59 }; |
| 58 | 60 |
| 59 class VrMetricsHelper; | 61 class VrMetricsHelper; |
| 60 | 62 |
| 61 // The native instance of the Java VrShell. This class is not threadsafe and | 63 // The native instance of the Java VrShell. This class is not threadsafe and |
| 62 // must only be used on the UI thread. | 64 // must only be used on the UI thread. |
| 63 class VrShell : public device::GvrDelegate, | 65 class VrShell : public device::GvrDelegate, |
| 64 device::GvrGamepadDataProvider, | 66 device::GvrGamepadDataProvider, |
| 65 device::CardboardGamepadDataProvider { | 67 device::CardboardGamepadDataProvider, |
| 68 public ChromeToolbarModelDelegate { |
| 66 public: | 69 public: |
| 67 VrShell(JNIEnv* env, | 70 VrShell(JNIEnv* env, |
| 68 jobject obj, | 71 jobject obj, |
| 69 ui::WindowAndroid* window, | 72 ui::WindowAndroid* window, |
| 70 bool for_web_vr, | 73 bool for_web_vr, |
| 71 bool web_vr_autopresented, | 74 bool web_vr_autopresented, |
| 72 bool in_cct, | 75 bool in_cct, |
| 73 VrShellDelegate* delegate, | 76 VrShellDelegate* delegate, |
| 74 gvr_context* gvr_api, | 77 gvr_context* gvr_api, |
| 75 bool reprojected_rendering); | 78 bool reprojected_rendering); |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 166 void SubmitControllerModel(std::unique_ptr<VrControllerModel> model); | 169 void SubmitControllerModel(std::unique_ptr<VrControllerModel> model); |
| 167 | 170 |
| 168 // device::GvrGamepadDataProvider implementation. | 171 // device::GvrGamepadDataProvider implementation. |
| 169 void UpdateGamepadData(device::GvrGamepadData) override; | 172 void UpdateGamepadData(device::GvrGamepadData) override; |
| 170 void RegisterGvrGamepadDataFetcher(device::GvrGamepadDataFetcher*) override; | 173 void RegisterGvrGamepadDataFetcher(device::GvrGamepadDataFetcher*) override; |
| 171 | 174 |
| 172 // device::CardboardGamepadDataProvider implementation. | 175 // device::CardboardGamepadDataProvider implementation. |
| 173 void RegisterCardboardGamepadDataFetcher( | 176 void RegisterCardboardGamepadDataFetcher( |
| 174 device::CardboardGamepadDataFetcher*) override; | 177 device::CardboardGamepadDataFetcher*) override; |
| 175 | 178 |
| 179 // ChromeToolbarModelDelegate implementation. |
| 180 content::WebContents* GetActiveWebContents() const override; |
| 181 |
| 176 private: | 182 private: |
| 177 ~VrShell() override; | 183 ~VrShell() override; |
| 178 void WaitForGlThread(); | 184 void WaitForGlThread(); |
| 179 void PostToGlThread(const tracked_objects::Location& from_here, | 185 void PostToGlThread(const tracked_objects::Location& from_here, |
| 180 const base::Closure& task); | 186 const base::Closure& task); |
| 181 void SetUiState(); | 187 void SetUiState(); |
| 182 | 188 |
| 183 // device::GvrDelegate implementation. | 189 // device::GvrDelegate implementation. |
| 184 void SetWebVRSecureOrigin(bool secure_origin) override; | 190 void SetWebVRSecureOrigin(bool secure_origin) override; |
| 185 void UpdateVSyncInterval(int64_t timebase_nanos, | 191 void UpdateVSyncInterval(int64_t timebase_nanos, |
| (...skipping 26 matching lines...) Expand all Loading... |
| 212 VrShellDelegate* delegate_provider_ = nullptr; | 218 VrShellDelegate* delegate_provider_ = nullptr; |
| 213 base::android::ScopedJavaGlobalRef<jobject> j_vr_shell_; | 219 base::android::ScopedJavaGlobalRef<jobject> j_vr_shell_; |
| 214 | 220 |
| 215 std::unique_ptr<VrInputManager> input_manager_; | 221 std::unique_ptr<VrInputManager> input_manager_; |
| 216 std::unique_ptr<AndroidUiGestureTarget> android_ui_gesture_target_; | 222 std::unique_ptr<AndroidUiGestureTarget> android_ui_gesture_target_; |
| 217 std::unique_ptr<VrMetricsHelper> metrics_helper_; | 223 std::unique_ptr<VrMetricsHelper> metrics_helper_; |
| 218 | 224 |
| 219 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner_; | 225 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner_; |
| 220 std::unique_ptr<VrGLThread> gl_thread_; | 226 std::unique_ptr<VrGLThread> gl_thread_; |
| 221 bool thread_started_ = false; | 227 bool thread_started_ = false; |
| 228 bool reprojected_rendering_; |
| 229 |
| 222 UiInterface* ui_; | 230 UiInterface* ui_; |
| 223 bool reprojected_rendering_; | 231 std::unique_ptr<ToolbarHelper> toolbar_; |
| 224 | 232 |
| 225 jobject content_surface_ = nullptr; | 233 jobject content_surface_ = nullptr; |
| 226 bool taken_surface_ = false; | 234 bool taken_surface_ = false; |
| 227 base::CancelableClosure poll_capturing_media_task_; | 235 base::CancelableClosure poll_capturing_media_task_; |
| 228 bool is_capturing_audio_ = false; | 236 bool is_capturing_audio_ = false; |
| 229 bool is_capturing_video_ = false; | 237 bool is_capturing_video_ = false; |
| 230 bool is_capturing_screen_ = false; | 238 bool is_capturing_screen_ = false; |
| 231 | 239 |
| 232 // Are we currently providing a gamepad factory to the gamepad manager? | 240 // Are we currently providing a gamepad factory to the gamepad manager? |
| 233 bool gvr_gamepad_source_active_ = false; | 241 bool gvr_gamepad_source_active_ = false; |
| 234 bool cardboard_gamepad_source_active_ = false; | 242 bool cardboard_gamepad_source_active_ = false; |
| 235 | 243 |
| 236 // Registered fetchers, must remain alive for UpdateGamepadData calls. | 244 // Registered fetchers, must remain alive for UpdateGamepadData calls. |
| 237 // That's ok since the fetcher is only destroyed from VrShell's destructor. | 245 // That's ok since the fetcher is only destroyed from VrShell's destructor. |
| 238 device::GvrGamepadDataFetcher* gvr_gamepad_data_fetcher_ = nullptr; | 246 device::GvrGamepadDataFetcher* gvr_gamepad_data_fetcher_ = nullptr; |
| 239 device::CardboardGamepadDataFetcher* cardboard_gamepad_data_fetcher_ = | 247 device::CardboardGamepadDataFetcher* cardboard_gamepad_data_fetcher_ = |
| 240 nullptr; | 248 nullptr; |
| 241 int64_t cardboard_gamepad_timer_ = 0; | 249 int64_t cardboard_gamepad_timer_ = 0; |
| 242 | 250 |
| 243 base::WeakPtrFactory<VrShell> weak_ptr_factory_; | 251 base::WeakPtrFactory<VrShell> weak_ptr_factory_; |
| 244 | 252 |
| 245 DISALLOW_COPY_AND_ASSIGN(VrShell); | 253 DISALLOW_COPY_AND_ASSIGN(VrShell); |
| 246 }; | 254 }; |
| 247 | 255 |
| 248 bool RegisterVrShell(JNIEnv* env); | 256 bool RegisterVrShell(JNIEnv* env); |
| 249 | 257 |
| 250 } // namespace vr_shell | 258 } // namespace vr_shell |
| 251 | 259 |
| 252 #endif // CHROME_BROWSER_ANDROID_VR_SHELL_VR_SHELL_H_ | 260 #endif // CHROME_BROWSER_ANDROID_VR_SHELL_VR_SHELL_H_ |
| OLD | NEW |