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

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

Issue 2570553004: Clean up some VrShell threading issues and remove unnecessary WeakPtr types. (Closed)
Patch Set: Created 4 years 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_GL_H_ 5 #ifndef CHROME_BROWSER_ANDROID_VR_SHELL_VR_SHELL_GL_H_
6 #define CHROME_BROWSER_ANDROID_VR_SHELL_VR_SHELL_GL_H_ 6 #define CHROME_BROWSER_ANDROID_VR_SHELL_VR_SHELL_GL_H_
7 7
8 #include <memory> 8 #include <memory>
9 9
10 #include "base/cancelable_callback.h" 10 #include "base/cancelable_callback.h"
(...skipping 30 matching lines...) Expand all
41 // It is not threadsafe and must only be used on the GL thread. 41 // It is not threadsafe and must only be used on the GL thread.
42 class VrShellGl { 42 class VrShellGl {
43 public: 43 public:
44 enum class InputTarget { 44 enum class InputTarget {
45 NONE = 0, 45 NONE = 0,
46 CONTENT, 46 CONTENT,
47 UI 47 UI
48 }; 48 };
49 49
50 VrShellGl( 50 VrShellGl(
51 VrShell* vr_shell,
52 const base::WeakPtr<VrShell>& weak_vr_shell, 51 const base::WeakPtr<VrShell>& weak_vr_shell,
53 const base::WeakPtr<VrInputManager>& content_input_manager, 52 const base::WeakPtr<VrInputManager>& content_input_manager,
54 const base::WeakPtr<VrInputManager>& ui_input_manager, 53 const base::WeakPtr<VrInputManager>& ui_input_manager,
55 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner, 54 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner,
56 gvr_context* gvr_api); 55 gvr_context* gvr_api,
56 bool initially_web_vr);
57 ~VrShellGl(); 57 ~VrShellGl();
58 58
59 bool Initialize(); 59 bool Initialize();
60 60
61 void DrawFrame(); 61 void DrawFrame();
62 62
63 void OnTriggerEvent(); 63 void OnTriggerEvent();
64 void OnPause(); 64 void OnPause();
65 void OnResume(); 65 void OnResume();
66 66
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 int content_tex_css_height_ = 0; 157 int content_tex_css_height_ = 0;
158 gvr::Sizei content_tex_physical_size_ = {0, 0}; 158 gvr::Sizei content_tex_physical_size_ = {0, 0};
159 gvr::Sizei ui_tex_physical_size_ = {0, 0}; 159 gvr::Sizei ui_tex_physical_size_ = {0, 0};
160 160
161 // The pose ring buffer size must be a power of two to avoid glitches when 161 // The pose ring buffer size must be a power of two to avoid glitches when
162 // the pose index wraps around. It should be large enough to handle the 162 // the pose index wraps around. It should be large enough to handle the
163 // current backlog of poses which is 2-3 frames. 163 // current backlog of poses which is 2-3 frames.
164 static constexpr int kPoseRingBufferSize = 8; 164 static constexpr int kPoseRingBufferSize = 8;
165 std::vector<gvr::Mat4f> webvr_head_pose_; 165 std::vector<gvr::Mat4f> webvr_head_pose_;
166 std::vector<bool> webvr_head_pose_valid_; 166 std::vector<bool> webvr_head_pose_valid_;
167 jint webvr_texture_id_ = 0; 167 int webvr_texture_id_ = 0;
168 bool web_vr_mode_;
168 169
169 std::unique_ptr<VrController> controller_; 170 std::unique_ptr<VrController> controller_;
170 171
171 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; 172 scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
172 base::CancelableClosure draw_task_; 173 base::CancelableClosure draw_task_;
173 base::TimeTicks vsync_timebase_; 174 base::TimeTicks vsync_timebase_;
174 base::TimeDelta vsync_interval_; 175 base::TimeDelta vsync_interval_;
175 176
176 // TODO(mthiesse): Remove thread-unsafe VrShell usage.
177 VrShell* vr_shell_;
178 base::WeakPtr<VrShell> weak_vr_shell_; 177 base::WeakPtr<VrShell> weak_vr_shell_;
179 base::WeakPtr<VrInputManager> content_input_manager_; 178 base::WeakPtr<VrInputManager> content_input_manager_;
180 base::WeakPtr<VrInputManager> ui_input_manager_; 179 base::WeakPtr<VrInputManager> ui_input_manager_;
181 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner_; 180 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner_;
182 181
183 base::WeakPtrFactory<VrShellGl> weak_ptr_factory_; 182 base::WeakPtrFactory<VrShellGl> weak_ptr_factory_;
184 183
185 DISALLOW_COPY_AND_ASSIGN(VrShellGl); 184 DISALLOW_COPY_AND_ASSIGN(VrShellGl);
186 }; 185 };
187 186
188 } // namespace vr_shell 187 } // namespace vr_shell
189 188
190 #endif // CHROME_BROWSER_ANDROID_VR_SHELL_VR_SHELL_GL_H_ 189 #endif // CHROME_BROWSER_ANDROID_VR_SHELL_VR_SHELL_GL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698