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

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: cleanup Created 3 years, 11 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 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 // Perform a UI action triggered by the javascript API. 117 // Perform a UI action triggered by the javascript API.
118 void DoUiAction(const UiAction action); 118 void DoUiAction(const UiAction action);
119 119
120 void SetContentCssSize(float width, float height, float dpr); 120 void SetContentCssSize(float width, float height, float dpr);
121 void SetUiCssSize(float width, float height, float dpr); 121 void SetUiCssSize(float width, float height, float dpr);
122 122
123 void ContentFrameWasResized(bool width_changed); 123 void ContentFrameWasResized(bool width_changed);
124 124
125 void ForceExitVr(); 125 void ForceExitVr();
126 126
127 // TODO(mthiesse): Find a better place for these functions to live.
127 static device::mojom::VRPosePtr VRPosePtrFromGvrPose(gvr::Mat4f head_mat); 128 static device::mojom::VRPosePtr VRPosePtrFromGvrPose(gvr::Mat4f head_mat);
129 static device::mojom::VRDisplayInfoPtr CreateVRDisplayInfo(
130 gvr::GvrApi* gvr_api,
131 gvr::Sizei compositor_size,
132 uint32_t device_id);
128 133
129 private: 134 private:
130 ~VrShell() override; 135 ~VrShell() override;
131 void SetIsInVR(bool is_in_vr); 136 void SetIsInVR(bool is_in_vr);
132 void PostToGlThreadWhenReady(const base::Closure& task); 137 void PostToGlThreadWhenReady(const base::Closure& task);
133 138
134 // content::WebContentsObserver implementation. 139 // content::WebContentsObserver implementation.
135 void RenderViewHostChanged(content::RenderViewHost* old_host, 140 void RenderViewHostChanged(content::RenderViewHost* old_host,
136 content::RenderViewHost* new_host) override; 141 content::RenderViewHost* new_host) override;
137 void MainFrameWasResized(bool width_changed) override; 142 void MainFrameWasResized(bool width_changed) override;
138 void WebContentsDestroyed() override; 143 void WebContentsDestroyed() override;
139 144
140 // device::GvrDelegate implementation 145 // device::GvrDelegate implementation
141 void SetWebVRSecureOrigin(bool secure_origin) override; 146 void SetWebVRSecureOrigin(bool secure_origin) override;
142 void SubmitWebVRFrame() override; 147 void SubmitWebVRFrame() override;
143 void UpdateWebVRTextureBounds(int16_t frame_index, 148 void UpdateWebVRTextureBounds(int16_t frame_index,
144 const gvr::Rectf& left_bounds, 149 const gvr::Rectf& left_bounds,
145 const gvr::Rectf& right_bounds) override; 150 const gvr::Rectf& right_bounds) override;
146 gvr::GvrApi* gvr_api() override;
147 void SetWebVRRenderSurfaceSize(int width, int height) override;
148 gvr::Sizei GetWebVRCompositorSurfaceSize() override;
149 void OnVRVsyncProviderRequest( 151 void OnVRVsyncProviderRequest(
150 device::mojom::VRVSyncProviderRequest request) override; 152 device::mojom::VRVSyncProviderRequest request) override;
151 void UpdateVSyncInterval(long timebase_nanos, 153 void UpdateVSyncInterval(long timebase_nanos,
152 double interval_seconds) override; 154 double interval_seconds) override;
155 bool SupportsPresentation() override;
156 void ResetPose() override;
157 void CreateVRDisplayInfo(
158 const base::Callback<void(device::mojom::VRDisplayInfoPtr)>& callback,
159 uint32_t device_id) override;
153 160
154 std::unique_ptr<UiInterface> html_interface_; 161 std::unique_ptr<UiInterface> html_interface_;
155 162
156 content::WebContents* main_contents_; 163 content::WebContents* main_contents_;
157 std::unique_ptr<VrCompositor> content_compositor_; 164 std::unique_ptr<VrCompositor> content_compositor_;
158 content::WebContents* ui_contents_; 165 content::WebContents* ui_contents_;
159 std::unique_ptr<VrCompositor> ui_compositor_; 166 std::unique_ptr<VrCompositor> ui_compositor_;
160 167
161 std::unique_ptr<VrWebContentsObserver> vr_web_contents_observer_; 168 std::unique_ptr<VrWebContentsObserver> vr_web_contents_observer_;
162 169
163 VrShellDelegate* delegate_provider_ = nullptr; 170 VrShellDelegate* delegate_provider_ = nullptr;
164 base::android::ScopedJavaGlobalRef<jobject> j_vr_shell_; 171 base::android::ScopedJavaGlobalRef<jobject> j_vr_shell_;
165 172
166 std::unique_ptr<VrInputManager> content_input_manager_; 173 std::unique_ptr<VrInputManager> content_input_manager_;
167 std::unique_ptr<VrInputManager> ui_input_manager_; 174 std::unique_ptr<VrInputManager> ui_input_manager_;
168 std::unique_ptr<VrMetricsHelper> metrics_helper_; 175 std::unique_ptr<VrMetricsHelper> metrics_helper_;
169 176
170 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner_; 177 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner_;
171 std::unique_ptr<VrGLThread> gl_thread_; 178 std::unique_ptr<VrGLThread> gl_thread_;
172 bool reprojected_rendering_; 179 bool reprojected_rendering_;
173 180
181 // TODO(mthiesse): Remove the need for this to stored here. crbug.com/674594
cjgrant 2017/01/25 21:45:31 s/to/to be/
mthiesse 2017/01/30 19:47:26 Done.
182 gvr_context* gvr_api_;
cjgrant 2017/01/25 21:45:31 Could we convince the GVR team to typedef this to
mthiesse 2017/01/30 19:47:26 Be my guest ;)
183
174 base::WeakPtrFactory<VrShell> weak_ptr_factory_; 184 base::WeakPtrFactory<VrShell> weak_ptr_factory_;
175 185
176 DISALLOW_COPY_AND_ASSIGN(VrShell); 186 DISALLOW_COPY_AND_ASSIGN(VrShell);
177 }; 187 };
178 188
179 bool RegisterVrShell(JNIEnv* env); 189 bool RegisterVrShell(JNIEnv* env);
180 190
181 } // namespace vr_shell 191 } // namespace vr_shell
182 192
183 #endif // CHROME_BROWSER_ANDROID_VR_SHELL_VR_SHELL_H_ 193 #endif // CHROME_BROWSER_ANDROID_VR_SHELL_VR_SHELL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698