OLD | NEW |
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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 CONTENT, | 50 CONTENT, |
51 UI | 51 UI |
52 }; | 52 }; |
53 | 53 |
54 VrShellGl( | 54 VrShellGl( |
55 const base::WeakPtr<VrShell>& weak_vr_shell, | 55 const base::WeakPtr<VrShell>& weak_vr_shell, |
56 const base::WeakPtr<VrInputManager>& content_input_manager, | 56 const base::WeakPtr<VrInputManager>& content_input_manager, |
57 const base::WeakPtr<VrInputManager>& ui_input_manager, | 57 const base::WeakPtr<VrInputManager>& ui_input_manager, |
58 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner, | 58 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner, |
59 gvr_context* gvr_api, | 59 gvr_context* gvr_api, |
60 bool initially_web_vr); | 60 bool initially_web_vr, |
| 61 bool reprojected_rendering); |
61 ~VrShellGl(); | 62 ~VrShellGl(); |
62 | 63 |
63 bool Initialize(); | 64 void Initialize(); |
| 65 void InitializeGl(gfx::AcceleratedWidget window); |
64 | 66 |
65 void DrawFrame(); | 67 void DrawFrame(); |
66 | 68 |
67 void OnTriggerEvent(); | 69 void OnTriggerEvent(); |
68 void OnPause(); | 70 void OnPause(); |
69 void OnResume(); | 71 void OnResume(); |
70 | 72 |
71 void SetWebVrMode(bool enabled); | 73 void SetWebVrMode(bool enabled); |
72 void ContentBoundsChanged(int width, int height); | 74 void ContentBoundsChanged(int width, int height); |
73 void ContentPhysicalBoundsChanged(int width, int height); | 75 void ContentPhysicalBoundsChanged(int width, int height); |
74 void UIBoundsChanged(int width, int height); | 76 void UIBoundsChanged(int width, int height); |
75 void UIPhysicalBoundsChanged(int width, int height); | 77 void UIPhysicalBoundsChanged(int width, int height); |
76 base::WeakPtr<VrShellGl> GetWeakPtr(); | 78 base::WeakPtr<VrShellGl> GetWeakPtr(); |
77 | 79 |
78 void UpdateWebVRTextureBounds(const gvr::Rectf& left_bounds, | 80 void UpdateWebVRTextureBounds(const gvr::Rectf& left_bounds, |
79 const gvr::Rectf& right_bounds); | 81 const gvr::Rectf& right_bounds); |
80 gvr::GvrApi* gvr_api(); | 82 gvr::GvrApi* gvr_api(); |
81 void SetGvrPoseForWebVr(const gvr::Mat4f& pose, uint32_t pose_num); | 83 void SetGvrPoseForWebVr(const gvr::Mat4f& pose, uint32_t pose_num); |
82 gvr::Sizei GetWebVRCompositorSurfaceSize(); | 84 gvr::Sizei GetWebVRCompositorSurfaceSize(); |
83 | 85 |
84 void UpdateScene(std::unique_ptr<base::ListValue> commands); | 86 void UpdateScene(std::unique_ptr<base::ListValue> commands); |
85 | 87 |
86 private: | 88 private: |
87 bool InitializeGl(); | |
88 void GvrInit(gvr_context* gvr_api); | 89 void GvrInit(gvr_context* gvr_api); |
89 void InitializeRenderer(); | 90 void InitializeRenderer(); |
90 void DrawVrShell(const gvr::Mat4f& head_pose, gvr::Frame &frame); | 91 void DrawVrShell(const gvr::Mat4f& head_pose, gvr::Frame &frame); |
91 void DrawUiView(const gvr::Mat4f* head_pose, | 92 void DrawUiView(const gvr::Mat4f* head_pose, |
92 const std::vector<const ContentRectangle*>& elements, | 93 const std::vector<const ContentRectangle*>& elements, |
93 const gvr::Sizei& render_size, int viewport_offset); | 94 const gvr::Sizei& render_size, int viewport_offset); |
94 void DrawElements(const gvr::Mat4f& render_matrix, | 95 void DrawElements(const gvr::Mat4f& render_matrix, |
95 const std::vector<const ContentRectangle*>& elements); | 96 const std::vector<const ContentRectangle*>& elements); |
96 void DrawCursor(const gvr::Mat4f& render_matrix); | 97 void DrawCursor(const gvr::Mat4f& render_matrix); |
97 void DrawWebVr(); | 98 void DrawWebVr(); |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 gvr::Sizei ui_tex_physical_size_ = {0, 0}; | 157 gvr::Sizei ui_tex_physical_size_ = {0, 0}; |
157 | 158 |
158 // The pose ring buffer size must be a power of two to avoid glitches when | 159 // 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 | 160 // the pose index wraps around. It should be large enough to handle the |
160 // current backlog of poses which is 2-3 frames. | 161 // current backlog of poses which is 2-3 frames. |
161 static constexpr int kPoseRingBufferSize = 8; | 162 static constexpr int kPoseRingBufferSize = 8; |
162 std::vector<gvr::Mat4f> webvr_head_pose_; | 163 std::vector<gvr::Mat4f> webvr_head_pose_; |
163 std::vector<bool> webvr_head_pose_valid_; | 164 std::vector<bool> webvr_head_pose_valid_; |
164 int webvr_texture_id_ = 0; | 165 int webvr_texture_id_ = 0; |
165 bool web_vr_mode_; | 166 bool web_vr_mode_; |
| 167 bool ready_to_draw_ = false; |
| 168 bool surfaceless_rendering_; |
166 | 169 |
167 std::unique_ptr<VrController> controller_; | 170 std::unique_ptr<VrController> controller_; |
168 | 171 |
169 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; | 172 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; |
170 base::CancelableClosure draw_task_; | 173 base::CancelableClosure draw_task_; |
171 base::TimeTicks vsync_timebase_; | 174 base::TimeTicks vsync_timebase_; |
172 base::TimeDelta vsync_interval_; | 175 base::TimeDelta vsync_interval_; |
173 | 176 |
174 base::WeakPtr<VrShell> weak_vr_shell_; | 177 base::WeakPtr<VrShell> weak_vr_shell_; |
175 base::WeakPtr<VrInputManager> content_input_manager_; | 178 base::WeakPtr<VrInputManager> content_input_manager_; |
176 base::WeakPtr<VrInputManager> ui_input_manager_; | 179 base::WeakPtr<VrInputManager> ui_input_manager_; |
177 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner_; | 180 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner_; |
178 | 181 |
179 base::WeakPtrFactory<VrShellGl> weak_ptr_factory_; | 182 base::WeakPtrFactory<VrShellGl> weak_ptr_factory_; |
180 | 183 |
181 DISALLOW_COPY_AND_ASSIGN(VrShellGl); | 184 DISALLOW_COPY_AND_ASSIGN(VrShellGl); |
182 }; | 185 }; |
183 | 186 |
184 } // namespace vr_shell | 187 } // namespace vr_shell |
185 | 188 |
186 #endif // CHROME_BROWSER_ANDROID_VR_SHELL_VR_SHELL_GL_H_ | 189 #endif // CHROME_BROWSER_ANDROID_VR_SHELL_VR_SHELL_GL_H_ |
OLD | NEW |