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

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

Issue 2658643003: Refactor GvrDelegate ownership into GvrDelegateProvider and fix more threading violations. (Closed)
Patch Set: Address comments 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 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 void SetContentCssSize(float width, float height, float dpr); 127 void SetContentCssSize(float width, float height, float dpr);
128 void SetUiCssSize(float width, float height, float dpr); 128 void SetUiCssSize(float width, float height, float dpr);
129 129
130 void ContentFrameWasResized(bool width_changed); 130 void ContentFrameWasResized(bool width_changed);
131 131
132 void ForceExitVr(); 132 void ForceExitVr();
133 133
134 void ProcessUIGesture(std::unique_ptr<blink::WebInputEvent> event); 134 void ProcessUIGesture(std::unique_ptr<blink::WebInputEvent> event);
135 void ProcessContentGesture(std::unique_ptr<blink::WebInputEvent> event); 135 void ProcessContentGesture(std::unique_ptr<blink::WebInputEvent> event);
136 136
137 // TODO(mthiesse): Find a better place for these functions to live.
137 static device::mojom::VRPosePtr VRPosePtrFromGvrPose(gvr::Mat4f head_mat); 138 static device::mojom::VRPosePtr VRPosePtrFromGvrPose(gvr::Mat4f head_mat);
139 static device::mojom::VRDisplayInfoPtr CreateVRDisplayInfo(
140 gvr::GvrApi* gvr_api,
141 gvr::Sizei compositor_size,
142 uint32_t device_id);
138 143
139 private: 144 private:
140 ~VrShell() override; 145 ~VrShell() override;
141 void PostToGlThreadWhenReady(const base::Closure& task); 146 void PostToGlThreadWhenReady(const base::Closure& task);
142 147
143 // content::WebContentsObserver implementation. 148 // content::WebContentsObserver implementation.
144 void RenderViewHostChanged(content::RenderViewHost* old_host, 149 void RenderViewHostChanged(content::RenderViewHost* old_host,
145 content::RenderViewHost* new_host) override; 150 content::RenderViewHost* new_host) override;
146 void MainFrameWasResized(bool width_changed) override; 151 void MainFrameWasResized(bool width_changed) override;
147 void WebContentsDestroyed() override; 152 void WebContentsDestroyed() override;
148 153
149 // device::GvrDelegate implementation 154 // device::GvrDelegate implementation
150 void SetWebVRSecureOrigin(bool secure_origin) override; 155 void SetWebVRSecureOrigin(bool secure_origin) override;
151 void SubmitWebVRFrame() override; 156 void SubmitWebVRFrame() override;
152 void UpdateWebVRTextureBounds(int16_t frame_index, 157 void UpdateWebVRTextureBounds(int16_t frame_index,
153 const gvr::Rectf& left_bounds, 158 const gvr::Rectf& left_bounds,
154 const gvr::Rectf& right_bounds) override; 159 const gvr::Rectf& right_bounds) override;
155 gvr::GvrApi* gvr_api() override;
156 void SetWebVRRenderSurfaceSize(int width, int height) override;
157 gvr::Sizei GetWebVRCompositorSurfaceSize() override;
158 void OnVRVsyncProviderRequest( 160 void OnVRVsyncProviderRequest(
159 device::mojom::VRVSyncProviderRequest request) override; 161 device::mojom::VRVSyncProviderRequest request) override;
160 void UpdateVSyncInterval(long timebase_nanos, 162 void UpdateVSyncInterval(long timebase_nanos,
161 double interval_seconds) override; 163 double interval_seconds) override;
164 bool SupportsPresentation() override;
165 void ResetPose() override;
166 void CreateVRDisplayInfo(
167 const base::Callback<void(device::mojom::VRDisplayInfoPtr)>& callback,
168 uint32_t device_id) override;
162 169
163 std::unique_ptr<UiInterface> html_interface_; 170 std::unique_ptr<UiInterface> html_interface_;
164 171
165 content::WebContents* main_contents_; 172 content::WebContents* main_contents_;
166 std::unique_ptr<VrCompositor> content_compositor_; 173 std::unique_ptr<VrCompositor> content_compositor_;
167 content::WebContents* ui_contents_; 174 content::WebContents* ui_contents_;
168 std::unique_ptr<VrCompositor> ui_compositor_; 175 std::unique_ptr<VrCompositor> ui_compositor_;
169 176
170 std::unique_ptr<VrWebContentsObserver> vr_web_contents_observer_; 177 std::unique_ptr<VrWebContentsObserver> vr_web_contents_observer_;
171 178
172 VrShellDelegate* delegate_provider_ = nullptr; 179 VrShellDelegate* delegate_provider_ = nullptr;
173 base::android::ScopedJavaGlobalRef<jobject> j_vr_shell_; 180 base::android::ScopedJavaGlobalRef<jobject> j_vr_shell_;
174 181
175 std::unique_ptr<VrInputManager> content_input_manager_; 182 std::unique_ptr<VrInputManager> content_input_manager_;
176 std::unique_ptr<VrInputManager> ui_input_manager_; 183 std::unique_ptr<VrInputManager> ui_input_manager_;
177 std::unique_ptr<VrMetricsHelper> metrics_helper_; 184 std::unique_ptr<VrMetricsHelper> metrics_helper_;
178 185
179 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner_; 186 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner_;
180 std::unique_ptr<VrGLThread> gl_thread_; 187 std::unique_ptr<VrGLThread> gl_thread_;
181 bool reprojected_rendering_; 188 bool reprojected_rendering_;
182 189
190 // TODO(mthiesse): Remove the need for this to be stored here.
191 // crbug.com/674594
192 gvr_context* gvr_api_;
193
183 base::WeakPtrFactory<VrShell> weak_ptr_factory_; 194 base::WeakPtrFactory<VrShell> weak_ptr_factory_;
184 195
185 DISALLOW_COPY_AND_ASSIGN(VrShell); 196 DISALLOW_COPY_AND_ASSIGN(VrShell);
186 }; 197 };
187 198
188 bool RegisterVrShell(JNIEnv* env); 199 bool RegisterVrShell(JNIEnv* env);
189 200
190 } // namespace vr_shell 201 } // namespace vr_shell
191 202
192 #endif // CHROME_BROWSER_ANDROID_VR_SHELL_VR_SHELL_H_ 203 #endif // CHROME_BROWSER_ANDROID_VR_SHELL_VR_SHELL_H_
OLDNEW
« no previous file with comments | « chrome/browser/android/vr_shell/vr_gl_thread.h ('k') | chrome/browser/android/vr_shell/vr_shell.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698