| 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(); | |
| 118 // Converts a pixel rectangle to (0..1) float texture coordinates. | |
| 119 // Callers need to ensure that the texture width/height is | |
| 120 // initialized by checking IsUiTextureReady() first. | |
| 121 Rectf MakeUiGlCopyRect(Recti pixel_rect); | |
| 122 void DrawVrShell(const gvr::Mat4f& head_pose); | 117 void DrawVrShell(const gvr::Mat4f& head_pose); |
| 123 void DrawEye(gvr::Eye eye, | 118 void DrawEye(gvr::Eye eye, |
| 124 const gvr::Mat4f& head_pose, | 119 const gvr::Mat4f& head_pose, |
| 125 const gvr::BufferViewport& params); | 120 const gvr::BufferViewport& params); |
| 126 void DrawUI(const gvr::Mat4f& world_matrix, | 121 void DrawUI(const gvr::Mat4f& world_matrix, |
| 127 const gvr::Mat4f& fov_matrix); | 122 const gvr::Mat4f& fov_matrix); |
| 128 void DrawCursor(const gvr::Mat4f& render_matrix); | 123 void DrawCursor(const gvr::Mat4f& render_matrix); |
| 129 void DrawWebVr(); | 124 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 | 125 |
| 135 void UpdateController(const gvr::Vec3f& forward_vector); | 126 void UpdateController(const gvr::Vec3f& forward_vector); |
| 136 | 127 |
| 137 void HandleQueuedTasks(); | 128 void HandleQueuedTasks(); |
| 138 | 129 |
| 139 // samplerExternalOES texture data for UI content image. | 130 // samplerExternalOES texture data for UI content image. |
| 140 jint ui_texture_id_ = 0; | 131 jint ui_texture_id_ = 0; |
| 141 // samplerExternalOES texture data for main content image. | 132 // samplerExternalOES texture data for main content image. |
| 142 jint content_texture_id_ = 0; | 133 jint content_texture_id_ = 0; |
| 143 | 134 |
| (...skipping 25 matching lines...) Expand all Loading... |
| 169 bool touch_pending_ = false; | 160 bool touch_pending_ = false; |
| 170 gvr::Quatf controller_quat_; | 161 gvr::Quatf controller_quat_; |
| 171 | 162 |
| 172 gvr::Vec3f target_point_; | 163 gvr::Vec3f target_point_; |
| 173 const ContentRectangle* target_element_ = nullptr; | 164 const ContentRectangle* target_element_ = nullptr; |
| 174 VrInputManager* current_input_target_ = nullptr; | 165 VrInputManager* current_input_target_ = nullptr; |
| 175 int ui_tex_width_ = 0; | 166 int ui_tex_width_ = 0; |
| 176 int ui_tex_height_ = 0; | 167 int ui_tex_height_ = 0; |
| 177 | 168 |
| 178 bool webvr_mode_ = false; | 169 bool webvr_mode_ = false; |
| 179 bool webvr_secure_origin_ = false; | 170 |
| 180 int64_t webvr_warning_end_nanos_ = 0; | |
| 181 // The pose ring buffer size must be a power of two to avoid glitches when | 171 // The pose ring buffer size must be a power of two to avoid glitches when |
| 182 // the pose index wraps around. It should be large enough to handle the | 172 // the pose index wraps around. It should be large enough to handle the |
| 183 // current backlog of poses which is 2-3 frames. | 173 // current backlog of poses which is 2-3 frames. |
| 184 static constexpr int kPoseRingBufferSize = 8; | 174 static constexpr int kPoseRingBufferSize = 8; |
| 185 std::vector<gvr::Mat4f> webvr_head_pose_; | 175 std::vector<gvr::Mat4f> webvr_head_pose_; |
| 186 | 176 |
| 187 std::unique_ptr<VrController> controller_; | 177 std::unique_ptr<VrController> controller_; |
| 188 scoped_refptr<VrInputManager> content_input_manager_; | 178 scoped_refptr<VrInputManager> content_input_manager_; |
| 189 scoped_refptr<VrInputManager> ui_input_manager_; | 179 scoped_refptr<VrInputManager> ui_input_manager_; |
| 190 | 180 |
| 191 base::WeakPtrFactory<VrShell> weak_ptr_factory_; | 181 base::WeakPtrFactory<VrShell> weak_ptr_factory_; |
| 192 | 182 |
| 193 DISALLOW_COPY_AND_ASSIGN(VrShell); | 183 DISALLOW_COPY_AND_ASSIGN(VrShell); |
| 194 }; | 184 }; |
| 195 | 185 |
| 196 bool RegisterVrShell(JNIEnv* env); | 186 bool RegisterVrShell(JNIEnv* env); |
| 197 | 187 |
| 198 } // namespace vr_shell | 188 } // namespace vr_shell |
| 199 | 189 |
| 200 #endif // CHROME_BROWSER_ANDROID_VR_SHELL_VR_SHELL_H_ | 190 #endif // CHROME_BROWSER_ANDROID_VR_SHELL_VR_SHELL_H_ |
| OLD | NEW |