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_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 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 // Called from non-render thread to queue a callback onto the render thread. | 107 // Called from non-render thread to queue a callback onto the render thread. |
108 // The render thread checks for callbacks and processes them between frames. | 108 // The render thread checks for callbacks and processes them between frames. |
109 void QueueTask(base::Callback<void()>& callback); | 109 void QueueTask(base::Callback<void()>& callback); |
110 | 110 |
111 // Perform a UI action triggered by the javascript API. | 111 // Perform a UI action triggered by the javascript API. |
112 void DoUiAction(const UiAction action); | 112 void DoUiAction(const UiAction action); |
113 | 113 |
114 private: | 114 private: |
115 virtual ~VrShell(); | 115 virtual ~VrShell(); |
116 void LoadUIContent(); | 116 void LoadUIContent(); |
117 bool IsUiTextureReady(); | 117 void DrawVrShell(const gvr::Mat4f& head_pose, gvr::Frame &frame); |
118 // Converts a pixel rectangle to (0..1) float texture coordinates. | 118 void DrawUiView(const gvr::Mat4f* head_pose, |
119 // Callers need to ensure that the texture width/height is | 119 const std::vector<const ContentRectangle*>& elements); |
120 // initialized by checking IsUiTextureReady() first. | 120 void DrawElements(const gvr::Mat4f& render_matrix, |
121 Rectf MakeUiGlCopyRect(Recti pixel_rect); | 121 const std::vector<const ContentRectangle*>& elements); |
122 void DrawVrShell(const gvr::Mat4f& head_pose); | |
123 void DrawEye(gvr::Eye eye, | |
124 const gvr::Mat4f& head_pose, | |
125 const gvr::BufferViewport& params); | |
126 void DrawUI(const gvr::Mat4f& world_matrix, | |
127 const gvr::Mat4f& fov_matrix); | |
128 void DrawCursor(const gvr::Mat4f& render_matrix); | 122 void DrawCursor(const gvr::Mat4f& render_matrix); |
129 void DrawWebVr(); | 123 void DrawWebVr(); |
130 void DrawWebVrOverlay(int64_t present_time_nanos); | |
131 void DrawWebVrEye(const gvr::Mat4f& view_matrix, | |
132 const gvr::BufferViewport& params, | |
133 int64_t present_time_nanos); | |
134 | 124 |
135 void UpdateController(const gvr::Vec3f& forward_vector); | 125 void UpdateController(const gvr::Vec3f& forward_vector); |
136 | 126 |
137 void HandleQueuedTasks(); | 127 void HandleQueuedTasks(); |
138 | 128 |
139 // samplerExternalOES texture data for UI content image. | 129 // samplerExternalOES texture data for UI content image. |
140 jint ui_texture_id_ = 0; | 130 jint ui_texture_id_ = 0; |
141 // samplerExternalOES texture data for main content image. | 131 // samplerExternalOES texture data for main content image. |
142 jint content_texture_id_ = 0; | 132 jint content_texture_id_ = 0; |
143 | 133 |
(...skipping 28 matching lines...) Expand all Loading... |
172 gvr::Quatf controller_quat_; | 162 gvr::Quatf controller_quat_; |
173 | 163 |
174 gvr::Vec3f target_point_; | 164 gvr::Vec3f target_point_; |
175 const ContentRectangle* target_element_ = nullptr; | 165 const ContentRectangle* target_element_ = nullptr; |
176 VrInputManager* current_input_target_ = nullptr; | 166 VrInputManager* current_input_target_ = nullptr; |
177 int ui_tex_width_ = 0; | 167 int ui_tex_width_ = 0; |
178 int ui_tex_height_ = 0; | 168 int ui_tex_height_ = 0; |
179 bool dom_contents_loaded_ = false; | 169 bool dom_contents_loaded_ = false; |
180 | 170 |
181 bool webvr_mode_ = false; | 171 bool webvr_mode_ = false; |
182 bool webvr_secure_origin_ = false; | 172 |
183 int64_t webvr_warning_end_nanos_ = 0; | |
184 // The pose ring buffer size must be a power of two to avoid glitches when | 173 // The pose ring buffer size must be a power of two to avoid glitches when |
185 // the pose index wraps around. It should be large enough to handle the | 174 // the pose index wraps around. It should be large enough to handle the |
186 // current backlog of poses which is 2-3 frames. | 175 // current backlog of poses which is 2-3 frames. |
187 static constexpr int kPoseRingBufferSize = 8; | 176 static constexpr int kPoseRingBufferSize = 8; |
188 std::vector<gvr::Mat4f> webvr_head_pose_; | 177 std::vector<gvr::Mat4f> webvr_head_pose_; |
189 | 178 |
190 std::unique_ptr<VrController> controller_; | 179 std::unique_ptr<VrController> controller_; |
191 scoped_refptr<VrInputManager> content_input_manager_; | 180 scoped_refptr<VrInputManager> content_input_manager_; |
192 scoped_refptr<VrInputManager> ui_input_manager_; | 181 scoped_refptr<VrInputManager> ui_input_manager_; |
193 | 182 |
194 base::WeakPtrFactory<VrShell> weak_ptr_factory_; | 183 base::WeakPtrFactory<VrShell> weak_ptr_factory_; |
195 | 184 |
196 DISALLOW_COPY_AND_ASSIGN(VrShell); | 185 DISALLOW_COPY_AND_ASSIGN(VrShell); |
197 }; | 186 }; |
198 | 187 |
199 bool RegisterVrShell(JNIEnv* env); | 188 bool RegisterVrShell(JNIEnv* env); |
200 | 189 |
201 } // namespace vr_shell | 190 } // namespace vr_shell |
202 | 191 |
203 #endif // CHROME_BROWSER_ANDROID_VR_SHELL_VR_SHELL_H_ | 192 #endif // CHROME_BROWSER_ANDROID_VR_SHELL_VR_SHELL_H_ |
OLD | NEW |