| 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> |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 SET_CONTENT_PAUSED, | 58 SET_CONTENT_PAUSED, |
| 59 }; | 59 }; |
| 60 | 60 |
| 61 class VrMetricsHelper; | 61 class VrMetricsHelper; |
| 62 | 62 |
| 63 // 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 |
| 64 // must only be used on the UI thread. | 64 // must only be used on the UI thread. |
| 65 class VrShell : public device::GvrDelegate, content::WebContentsObserver { | 65 class VrShell : public device::GvrDelegate, content::WebContentsObserver { |
| 66 public: | 66 public: |
| 67 VrShell(JNIEnv* env, jobject obj, | 67 VrShell(JNIEnv* env, jobject obj, |
| 68 content::WebContents* main_contents, | |
| 69 ui::WindowAndroid* content_window, | 68 ui::WindowAndroid* content_window, |
| 70 content::WebContents* ui_contents, | 69 content::WebContents* ui_contents, |
| 71 ui::WindowAndroid* ui_window, | 70 ui::WindowAndroid* ui_window, |
| 72 bool for_web_vr, | 71 bool for_web_vr, |
| 73 VrShellDelegate* delegate, | 72 VrShellDelegate* delegate, |
| 74 gvr_context* gvr_api, | 73 gvr_context* gvr_api, |
| 75 bool reprojected_rendering); | 74 bool reprojected_rendering); |
| 76 void SwapContents(JNIEnv* env, | 75 void SwapContents(JNIEnv* env, |
| 77 const base::android::JavaParamRef<jobject>& obj, | 76 const base::android::JavaParamRef<jobject>& obj, |
| 78 const base::android::JavaParamRef<jobject>& web_contents); | 77 const base::android::JavaParamRef<jobject>& web_contents); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 96 double progress); | 95 double progress); |
| 97 void OnTabListCreated(JNIEnv* env, | 96 void OnTabListCreated(JNIEnv* env, |
| 98 const base::android::JavaParamRef<jobject>& obj, | 97 const base::android::JavaParamRef<jobject>& obj, |
| 99 jobjectArray tabs, jobjectArray incognito_tabs); | 98 jobjectArray tabs, jobjectArray incognito_tabs); |
| 100 void OnTabUpdated(JNIEnv* env, | 99 void OnTabUpdated(JNIEnv* env, |
| 101 const base::android::JavaParamRef<jobject>& obj, | 100 const base::android::JavaParamRef<jobject>& obj, |
| 102 jboolean incognito, jint id, jstring jtitle); | 101 jboolean incognito, jint id, jstring jtitle); |
| 103 void OnTabRemoved(JNIEnv* env, | 102 void OnTabRemoved(JNIEnv* env, |
| 104 const base::android::JavaParamRef<jobject>& obj, | 103 const base::android::JavaParamRef<jobject>& obj, |
| 105 jboolean incognito, jint id); | 104 jboolean incognito, jint id); |
| 105 base::android::ScopedJavaGlobalRef<jobject> TakeContentSurface( |
| 106 JNIEnv* env, |
| 107 const base::android::JavaParamRef<jobject>& obj); |
| 108 void RestoreContentSurface(JNIEnv* env, |
| 109 const base::android::JavaParamRef<jobject>& obj); |
| 106 | 110 |
| 107 void ContentWebContentsDestroyed(); | 111 void ContentWebContentsDestroyed(); |
| 108 // Called when our WebContents have been hidden. Usually a sign that something | 112 // Called when our WebContents have been hidden. Usually a sign that something |
| 109 // like another tab placed in front of it. | 113 // like another tab placed in front of it. |
| 110 void ContentWasHidden(); | 114 void ContentWasHidden(); |
| 111 void ContentWasShown(); | 115 void ContentWasShown(); |
| 112 | 116 |
| 113 // html/js UI hooks. | 117 // html/js UI hooks. |
| 114 static base::WeakPtr<VrShell> GetWeakPtr( | 118 static base::WeakPtr<VrShell> GetWeakPtr( |
| 115 const content::WebContents* web_contents); | 119 const content::WebContents* web_contents); |
| 116 | 120 |
| 117 UiInterface* GetUiInterface(); | 121 UiInterface* GetUiInterface(); |
| 118 void OnDomContentsLoaded(); | 122 void OnDomContentsLoaded(); |
| 119 | 123 |
| 120 void SurfacesChanged(jobject content_surface, jobject ui_surface); | 124 void UiSurfaceChanged(jobject surface); |
| 125 void ContentSurfaceChanged(jobject surface); |
| 121 void GvrDelegateReady(); | 126 void GvrDelegateReady(); |
| 122 void AppButtonPressed(); | 127 void AppButtonPressed(); |
| 123 | 128 |
| 124 void ContentPhysicalBoundsChanged( | 129 void ContentPhysicalBoundsChanged( |
| 125 JNIEnv* env, | 130 JNIEnv* env, |
| 126 const base::android::JavaParamRef<jobject>& object, | 131 const base::android::JavaParamRef<jobject>& object, |
| 127 jint width, jint height, jfloat dpr); | 132 jint width, jint height, jfloat dpr); |
| 128 | 133 |
| 129 void UIPhysicalBoundsChanged( | 134 void UIPhysicalBoundsChanged( |
| 130 JNIEnv* env, | 135 JNIEnv* env, |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 180 void CreateVRDisplayInfo( | 185 void CreateVRDisplayInfo( |
| 181 const base::Callback<void(device::mojom::VRDisplayInfoPtr)>& callback, | 186 const base::Callback<void(device::mojom::VRDisplayInfoPtr)>& callback, |
| 182 uint32_t device_id) override; | 187 uint32_t device_id) override; |
| 183 | 188 |
| 184 void ProcessTabArray(JNIEnv* env, jobjectArray tabs, bool incognito); | 189 void ProcessTabArray(JNIEnv* env, jobjectArray tabs, bool incognito); |
| 185 | 190 |
| 186 std::unique_ptr<UiInterface> html_interface_; | 191 std::unique_ptr<UiInterface> html_interface_; |
| 187 bool content_paused_ = false; | 192 bool content_paused_ = false; |
| 188 bool webvr_mode_ = false; | 193 bool webvr_mode_ = false; |
| 189 | 194 |
| 190 content::WebContents* main_contents_; | 195 content::WebContents* main_contents_ = nullptr; |
| 196 ui::WindowAndroid* content_window_; |
| 191 std::unique_ptr<VrCompositor> content_compositor_; | 197 std::unique_ptr<VrCompositor> content_compositor_; |
| 192 content::WebContents* ui_contents_; | 198 content::WebContents* ui_contents_; |
| 193 std::unique_ptr<VrCompositor> ui_compositor_; | 199 std::unique_ptr<VrCompositor> ui_compositor_; |
| 194 | 200 |
| 195 std::unique_ptr<VrWebContentsObserver> vr_web_contents_observer_; | 201 std::unique_ptr<VrWebContentsObserver> vr_web_contents_observer_; |
| 196 | 202 |
| 197 VrShellDelegate* delegate_provider_ = nullptr; | 203 VrShellDelegate* delegate_provider_ = nullptr; |
| 198 base::android::ScopedJavaGlobalRef<jobject> j_vr_shell_; | 204 base::android::ScopedJavaGlobalRef<jobject> j_vr_shell_; |
| 199 | 205 |
| 200 std::unique_ptr<VrInputManager> content_input_manager_; | 206 std::unique_ptr<VrInputManager> content_input_manager_; |
| 201 std::unique_ptr<VrInputManager> ui_input_manager_; | 207 std::unique_ptr<VrInputManager> ui_input_manager_; |
| 202 std::unique_ptr<VrMetricsHelper> metrics_helper_; | 208 std::unique_ptr<VrMetricsHelper> metrics_helper_; |
| 203 | 209 |
| 204 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner_; | 210 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner_; |
| 205 std::unique_ptr<VrGLThread> gl_thread_; | 211 std::unique_ptr<VrGLThread> gl_thread_; |
| 206 bool reprojected_rendering_; | 212 bool reprojected_rendering_; |
| 207 | 213 |
| 214 jobject content_surface_ = nullptr; |
| 215 |
| 208 // TODO(mthiesse): Remove the need for this to be stored here. | 216 // TODO(mthiesse): Remove the need for this to be stored here. |
| 209 // crbug.com/674594 | 217 // crbug.com/674594 |
| 210 gvr_context* gvr_api_; | 218 gvr_context* gvr_api_; |
| 211 | 219 |
| 212 base::WeakPtrFactory<VrShell> weak_ptr_factory_; | 220 base::WeakPtrFactory<VrShell> weak_ptr_factory_; |
| 213 | 221 |
| 214 DISALLOW_COPY_AND_ASSIGN(VrShell); | 222 DISALLOW_COPY_AND_ASSIGN(VrShell); |
| 215 }; | 223 }; |
| 216 | 224 |
| 217 bool RegisterVrShell(JNIEnv* env); | 225 bool RegisterVrShell(JNIEnv* env); |
| 218 | 226 |
| 219 } // namespace vr_shell | 227 } // namespace vr_shell |
| 220 | 228 |
| 221 #endif // CHROME_BROWSER_ANDROID_VR_SHELL_VR_SHELL_H_ | 229 #endif // CHROME_BROWSER_ANDROID_VR_SHELL_VR_SHELL_H_ |
| OLD | NEW |