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 "third_party/gvr-android-sdk/src/libraries/headers/vr/gvr/capi/include/
gvr.h" | 20 #include "third_party/gvr-android-sdk/src/libraries/headers/vr/gvr/capi/include/
gvr.h" |
20 #include "third_party/gvr-android-sdk/src/libraries/headers/vr/gvr/capi/include/
gvr_types.h" | 21 #include "third_party/gvr-android-sdk/src/libraries/headers/vr/gvr/capi/include/
gvr_types.h" |
21 | 22 |
22 namespace base { | 23 namespace base { |
23 class ListValue; | 24 class ListValue; |
24 class Thread; | 25 class Thread; |
25 } | 26 } |
26 | 27 |
27 namespace content { | 28 namespace content { |
28 class WebContents; | 29 class WebContents; |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 void OnPause(JNIEnv* env, | 75 void OnPause(JNIEnv* env, |
75 const base::android::JavaParamRef<jobject>& obj); | 76 const base::android::JavaParamRef<jobject>& obj); |
76 void OnResume(JNIEnv* env, | 77 void OnResume(JNIEnv* env, |
77 const base::android::JavaParamRef<jobject>& obj); | 78 const base::android::JavaParamRef<jobject>& obj); |
78 void SetSurface(JNIEnv* env, | 79 void SetSurface(JNIEnv* env, |
79 const base::android::JavaParamRef<jobject>& obj, | 80 const base::android::JavaParamRef<jobject>& obj, |
80 const base::android::JavaParamRef<jobject>& surface); | 81 const base::android::JavaParamRef<jobject>& surface); |
81 void SetWebVrMode(JNIEnv* env, | 82 void SetWebVrMode(JNIEnv* env, |
82 const base::android::JavaParamRef<jobject>& obj, | 83 const base::android::JavaParamRef<jobject>& obj, |
83 bool enabled); | 84 bool enabled); |
| 85 void UpdateVSyncInterval(JNIEnv* env, |
| 86 const base::android::JavaParamRef<jobject>& obj, |
| 87 jlong timebase_nanos, jdouble interval_seconds); |
84 | 88 |
85 void ContentWebContentsDestroyed(); | 89 void ContentWebContentsDestroyed(); |
86 // Called when our WebContents have been hidden. Usually a sign that something | 90 // Called when our WebContents have been hidden. Usually a sign that something |
87 // like another tab placed in front of it. | 91 // like another tab placed in front of it. |
88 void ContentWasHidden(); | 92 void ContentWasHidden(); |
89 | 93 |
90 // html/js UI hooks. | 94 // html/js UI hooks. |
91 static base::WeakPtr<VrShell> GetWeakPtr( | 95 static base::WeakPtr<VrShell> GetWeakPtr( |
92 const content::WebContents* web_contents); | 96 const content::WebContents* web_contents); |
93 | 97 |
94 // TODO(mthiesse): Clean up threading around UiInterface. | 98 // TODO(mthiesse): Clean up threading around UiInterface. |
95 UiInterface* GetUiInterface(); | 99 UiInterface* GetUiInterface(); |
96 void OnDomContentsLoaded(); | 100 void OnDomContentsLoaded(); |
97 | 101 |
98 // device::GvrDelegate implementation | 102 // device::GvrDelegate implementation |
99 // TODO(mthiesse): Clean up threading around GVR API. These functions are | 103 // TODO(mthiesse): Clean up threading around GVR API. These functions are |
100 // called on the UI thread, but use GL thread objects in a non-threadsafe way. | 104 // called on the UI thread, but use GL thread objects in a non-threadsafe way. |
101 void SetWebVRSecureOrigin(bool secure_origin) override; | 105 void SetWebVRSecureOrigin(bool secure_origin) override; |
102 void SubmitWebVRFrame() override; | 106 void SubmitWebVRFrame() override; |
103 void UpdateWebVRTextureBounds(const gvr::Rectf& left_bounds, | 107 void UpdateWebVRTextureBounds(const gvr::Rectf& left_bounds, |
104 const gvr::Rectf& right_bounds) override; | 108 const gvr::Rectf& right_bounds) override; |
105 gvr::GvrApi* gvr_api() override; | 109 gvr::GvrApi* gvr_api() override; |
106 void SetGvrPoseForWebVr(const gvr::Mat4f& pose, uint32_t pose_num) override; | |
107 void SetWebVRRenderSurfaceSize(int width, int height) override; | 110 void SetWebVRRenderSurfaceSize(int width, int height) override; |
108 gvr::Sizei GetWebVRCompositorSurfaceSize() override; | 111 gvr::Sizei GetWebVRCompositorSurfaceSize() override; |
109 | 112 |
110 void SurfacesChanged(jobject content_surface, jobject ui_surface); | 113 void SurfacesChanged(jobject content_surface, jobject ui_surface); |
111 void GvrDelegateReady(); | 114 void GvrDelegateReady(); |
112 void AppButtonPressed(); | 115 void AppButtonPressed(); |
113 | 116 |
114 void ContentBoundsChanged( | 117 void ContentBoundsChanged( |
115 JNIEnv* env, | 118 JNIEnv* env, |
116 const base::android::JavaParamRef<jobject>& object, | 119 const base::android::JavaParamRef<jobject>& object, |
117 jint width, jint height, jfloat dpr); | 120 jint width, jint height, jfloat dpr); |
118 | 121 |
119 void UIBoundsChanged( | 122 void UIBoundsChanged( |
120 JNIEnv* env, | 123 JNIEnv* env, |
121 const base::android::JavaParamRef<jobject>& object, | 124 const base::android::JavaParamRef<jobject>& object, |
122 jint width, jint height, jfloat dpr); | 125 jint width, jint height, jfloat dpr); |
123 | 126 |
124 void UpdateScene(const base::ListValue* args); | 127 void UpdateScene(const base::ListValue* args); |
125 | 128 |
126 // Perform a UI action triggered by the javascript API. | 129 // Perform a UI action triggered by the javascript API. |
127 void DoUiAction(const UiAction action); | 130 void DoUiAction(const UiAction action); |
128 | 131 |
129 void SetContentCssSize(float width, float height, float dpr); | 132 void SetContentCssSize(float width, float height, float dpr); |
130 void SetUiCssSize(float width, float height, float dpr); | 133 void SetUiCssSize(float width, float height, float dpr); |
131 | 134 |
132 void ContentFrameWasResized(bool width_changed); | 135 void ContentFrameWasResized(bool width_changed); |
133 | 136 |
134 void ForceExitVr(); | 137 void ForceExitVr(); |
135 | 138 |
| 139 void OnVRVsyncProviderReady(); |
| 140 void OnVRVSyncProviderClientConnected( |
| 141 device::mojom::VRVSyncProviderClientPtr client); |
| 142 |
136 private: | 143 private: |
137 ~VrShell() override; | 144 ~VrShell() override; |
138 void SetShowingOverscrollGlow(bool showing_glow); | 145 void SetShowingOverscrollGlow(bool showing_glow); |
139 void PostToGlThreadWhenReady(const base::Closure& task); | 146 void PostToGlThreadWhenReady(const base::Closure& task); |
140 | 147 |
141 // content::WebContentsObserver implementation. All called on UI thread. | 148 // content::WebContentsObserver implementation. All called on UI thread. |
142 void RenderViewHostChanged(content::RenderViewHost* old_host, | 149 void RenderViewHostChanged(content::RenderViewHost* old_host, |
143 content::RenderViewHost* new_host) override; | 150 content::RenderViewHost* new_host) override; |
144 void MainFrameWasResized(bool width_changed) override; | 151 void MainFrameWasResized(bool width_changed) override; |
145 void WebContentsDestroyed() override; | 152 void WebContentsDestroyed() override; |
(...skipping 21 matching lines...) Expand all Loading... |
167 base::WeakPtrFactory<VrShell> weak_ptr_factory_; | 174 base::WeakPtrFactory<VrShell> weak_ptr_factory_; |
168 | 175 |
169 DISALLOW_COPY_AND_ASSIGN(VrShell); | 176 DISALLOW_COPY_AND_ASSIGN(VrShell); |
170 }; | 177 }; |
171 | 178 |
172 bool RegisterVrShell(JNIEnv* env); | 179 bool RegisterVrShell(JNIEnv* env); |
173 | 180 |
174 } // namespace vr_shell | 181 } // namespace vr_shell |
175 | 182 |
176 #endif // CHROME_BROWSER_ANDROID_VR_SHELL_VR_SHELL_H_ | 183 #endif // CHROME_BROWSER_ANDROID_VR_SHELL_VR_SHELL_H_ |
OLD | NEW |