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

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: rebase 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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 // It is not threadsafe and must only be used on the GL thread. 45 // It is not threadsafe and must only be used on the GL thread.
46 class VrShellGl { 46 class VrShellGl {
47 public: 47 public:
48 enum class InputTarget { 48 enum class InputTarget {
49 NONE = 0, 49 NONE = 0,
50 CONTENT, 50 CONTENT,
51 UI 51 UI
52 }; 52 };
53 53
54 VrShellGl( 54 VrShellGl(
55 VrShell* vr_shell,
56 const base::WeakPtr<VrShell>& weak_vr_shell, 55 const base::WeakPtr<VrShell>& weak_vr_shell,
57 const base::WeakPtr<VrInputManager>& content_input_manager, 56 const base::WeakPtr<VrInputManager>& content_input_manager,
58 const base::WeakPtr<VrInputManager>& ui_input_manager, 57 const base::WeakPtr<VrInputManager>& ui_input_manager,
59 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner, 58 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner,
60 gvr_context* gvr_api); 59 gvr_context* gvr_api,
60 bool initially_web_vr);
61 ~VrShellGl(); 61 ~VrShellGl();
62 62
63 bool Initialize(); 63 bool Initialize();
64 64
65 void DrawFrame(); 65 void DrawFrame();
66 66
67 void OnTriggerEvent(); 67 void OnTriggerEvent();
68 void OnPause(); 68 void OnPause();
69 void OnResume(); 69 void OnResume();
70 70
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 int content_tex_css_height_ = 0; 154 int content_tex_css_height_ = 0;
155 gvr::Sizei content_tex_physical_size_ = {0, 0}; 155 gvr::Sizei content_tex_physical_size_ = {0, 0};
156 gvr::Sizei ui_tex_physical_size_ = {0, 0}; 156 gvr::Sizei ui_tex_physical_size_ = {0, 0};
157 157
158 // The pose ring buffer size must be a power of two to avoid glitches when 158 // The pose ring buffer size must be a power of two to avoid glitches when
159 // the pose index wraps around. It should be large enough to handle the 159 // the pose index wraps around. It should be large enough to handle the
160 // current backlog of poses which is 2-3 frames. 160 // current backlog of poses which is 2-3 frames.
161 static constexpr int kPoseRingBufferSize = 8; 161 static constexpr int kPoseRingBufferSize = 8;
162 std::vector<gvr::Mat4f> webvr_head_pose_; 162 std::vector<gvr::Mat4f> webvr_head_pose_;
163 std::vector<bool> webvr_head_pose_valid_; 163 std::vector<bool> webvr_head_pose_valid_;
164 jint webvr_texture_id_ = 0; 164 int webvr_texture_id_ = 0;
165 bool web_vr_mode_;
165 166
166 std::unique_ptr<VrController> controller_; 167 std::unique_ptr<VrController> controller_;
167 168
168 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; 169 scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
169 base::CancelableClosure draw_task_; 170 base::CancelableClosure draw_task_;
170 base::TimeTicks vsync_timebase_; 171 base::TimeTicks vsync_timebase_;
171 base::TimeDelta vsync_interval_; 172 base::TimeDelta vsync_interval_;
172 173
173 // TODO(mthiesse): Remove thread-unsafe VrShell usage.
174 VrShell* vr_shell_;
175 base::WeakPtr<VrShell> weak_vr_shell_; 174 base::WeakPtr<VrShell> weak_vr_shell_;
176 base::WeakPtr<VrInputManager> content_input_manager_; 175 base::WeakPtr<VrInputManager> content_input_manager_;
177 base::WeakPtr<VrInputManager> ui_input_manager_; 176 base::WeakPtr<VrInputManager> ui_input_manager_;
178 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner_; 177 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner_;
179 178
180 base::WeakPtrFactory<VrShellGl> weak_ptr_factory_; 179 base::WeakPtrFactory<VrShellGl> weak_ptr_factory_;
181 180
182 DISALLOW_COPY_AND_ASSIGN(VrShellGl); 181 DISALLOW_COPY_AND_ASSIGN(VrShellGl);
183 }; 182 };
184 183
185 } // namespace vr_shell 184 } // namespace vr_shell
186 185
187 #endif // CHROME_BROWSER_ANDROID_VR_SHELL_VR_SHELL_GL_H_ 186 #endif // CHROME_BROWSER_ANDROID_VR_SHELL_VR_SHELL_GL_H_
OLDNEW
« no previous file with comments | « chrome/browser/android/vr_shell/vr_shell_delegate.cc ('k') | chrome/browser/android/vr_shell/vr_shell_gl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698