Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(580)

Side by Side Diff: chrome/browser/android/vr_shell/vr_shell.h

Issue 2683953007: Support rendering Android Native Pages in VR Shell. (Closed)
Patch Set: rebase Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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
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 20 matching lines...) Expand all
151 static device::mojom::VRPosePtr VRPosePtrFromGvrPose(gvr::Mat4f head_mat); 156 static device::mojom::VRPosePtr VRPosePtrFromGvrPose(gvr::Mat4f head_mat);
152 static device::mojom::VRDisplayInfoPtr CreateVRDisplayInfo( 157 static device::mojom::VRDisplayInfoPtr CreateVRDisplayInfo(
153 gvr::GvrApi* gvr_api, 158 gvr::GvrApi* gvr_api,
154 gvr::Sizei compositor_size, 159 gvr::Sizei compositor_size,
155 uint32_t device_id); 160 uint32_t device_id);
156 161
157 private: 162 private:
158 ~VrShell() override; 163 ~VrShell() override;
159 void PostToGlThreadWhenReady(const base::Closure& task); 164 void PostToGlThreadWhenReady(const base::Closure& task);
160 void SetContentPaused(bool paused); 165 void SetContentPaused(bool paused);
166 void SetUiState();
161 167
162 // content::WebContentsObserver implementation. 168 // content::WebContentsObserver implementation.
163 void RenderViewHostChanged(content::RenderViewHost* old_host, 169 void RenderViewHostChanged(content::RenderViewHost* old_host,
164 content::RenderViewHost* new_host) override; 170 content::RenderViewHost* new_host) override;
165 void MainFrameWasResized(bool width_changed) override; 171 void MainFrameWasResized(bool width_changed) override;
166 void WebContentsDestroyed() override; 172 void WebContentsDestroyed() override;
167 173
168 // device::GvrDelegate implementation 174 // device::GvrDelegate implementation
169 void SetWebVRSecureOrigin(bool secure_origin) override; 175 void SetWebVRSecureOrigin(bool secure_origin) override;
170 void SubmitWebVRFrame() override; 176 void SubmitWebVRFrame() override;
(...skipping 11 matching lines...) Expand all
182 uint32_t device_id) override; 188 uint32_t device_id) override;
183 189
184 void ProcessTabArray(JNIEnv* env, jobjectArray tabs, bool incognito); 190 void ProcessTabArray(JNIEnv* env, jobjectArray tabs, bool incognito);
185 191
186 bool vr_shell_enabled_; 192 bool vr_shell_enabled_;
187 193
188 std::unique_ptr<UiInterface> html_interface_; 194 std::unique_ptr<UiInterface> html_interface_;
189 bool content_paused_ = false; 195 bool content_paused_ = false;
190 bool webvr_mode_ = false; 196 bool webvr_mode_ = false;
191 197
192 content::WebContents* main_contents_; 198 content::WebContents* main_contents_ = nullptr;
199 ui::WindowAndroid* content_window_;
193 std::unique_ptr<VrCompositor> content_compositor_; 200 std::unique_ptr<VrCompositor> content_compositor_;
194 content::WebContents* ui_contents_; 201 content::WebContents* ui_contents_;
195 std::unique_ptr<VrCompositor> ui_compositor_; 202 std::unique_ptr<VrCompositor> ui_compositor_;
196 203
197 std::unique_ptr<VrWebContentsObserver> vr_web_contents_observer_; 204 std::unique_ptr<VrWebContentsObserver> vr_web_contents_observer_;
198 205
199 VrShellDelegate* delegate_provider_ = nullptr; 206 VrShellDelegate* delegate_provider_ = nullptr;
200 base::android::ScopedJavaGlobalRef<jobject> j_vr_shell_; 207 base::android::ScopedJavaGlobalRef<jobject> j_vr_shell_;
201 208
202 std::unique_ptr<VrInputManager> content_input_manager_; 209 std::unique_ptr<VrInputManager> content_input_manager_;
203 std::unique_ptr<VrInputManager> ui_input_manager_; 210 std::unique_ptr<VrInputManager> ui_input_manager_;
204 std::unique_ptr<VrMetricsHelper> metrics_helper_; 211 std::unique_ptr<VrMetricsHelper> metrics_helper_;
205 212
206 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner_; 213 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner_;
207 std::unique_ptr<VrGLThread> gl_thread_; 214 std::unique_ptr<VrGLThread> gl_thread_;
208 bool reprojected_rendering_; 215 bool reprojected_rendering_;
209 216
217 jobject content_surface_ = nullptr;
218
210 // TODO(mthiesse): Remove the need for this to be stored here. 219 // TODO(mthiesse): Remove the need for this to be stored here.
211 // crbug.com/674594 220 // crbug.com/674594
212 gvr_context* gvr_api_; 221 gvr_context* gvr_api_;
213 222
214 base::WeakPtrFactory<VrShell> weak_ptr_factory_; 223 base::WeakPtrFactory<VrShell> weak_ptr_factory_;
215 224
216 DISALLOW_COPY_AND_ASSIGN(VrShell); 225 DISALLOW_COPY_AND_ASSIGN(VrShell);
217 }; 226 };
218 227
219 bool RegisterVrShell(JNIEnv* env); 228 bool RegisterVrShell(JNIEnv* env);
220 229
221 } // namespace vr_shell 230 } // namespace vr_shell
222 231
223 #endif // CHROME_BROWSER_ANDROID_VR_SHELL_VR_SHELL_H_ 232 #endif // CHROME_BROWSER_ANDROID_VR_SHELL_VR_SHELL_H_
OLDNEW
« no previous file with comments | « chrome/browser/android/vr_shell/vr_compositor.cc ('k') | chrome/browser/android/vr_shell/vr_shell.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698