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 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 // device::GvrDelegate implementation | 96 // device::GvrDelegate implementation |
97 void SetWebVRSecureOrigin(bool secure_origin) override; | 97 void SetWebVRSecureOrigin(bool secure_origin) override; |
98 void SubmitWebVRFrame() override; | 98 void SubmitWebVRFrame() override; |
99 void UpdateWebVRTextureBounds(const gvr::Rectf& left_bounds, | 99 void UpdateWebVRTextureBounds(const gvr::Rectf& left_bounds, |
100 const gvr::Rectf& right_bounds) override; | 100 const gvr::Rectf& right_bounds) override; |
101 gvr::GvrApi* gvr_api() override; | 101 gvr::GvrApi* gvr_api() override; |
102 void SetGvrPoseForWebVr(const gvr::Mat4f& pose, uint32_t pose_num) override; | 102 void SetGvrPoseForWebVr(const gvr::Mat4f& pose, uint32_t pose_num) override; |
103 void SetWebVRRenderSurfaceSize(int width, int height) override; | 103 void SetWebVRRenderSurfaceSize(int width, int height) override; |
104 gvr::Sizei GetWebVRCompositorSurfaceSize() override; | 104 gvr::Sizei GetWebVRCompositorSurfaceSize() override; |
105 | 105 |
106 void ContentSurfaceChanged( | 106 void SurfacesChanged( |
107 JNIEnv* env, | 107 JNIEnv* env, |
108 const base::android::JavaParamRef<jobject>& object, | 108 const base::android::JavaParamRef<jobject>& object, |
109 jint width, | 109 const base::android::JavaParamRef<jobject>& content_surface, |
110 jint height, | 110 const base::android::JavaParamRef<jobject>& ui_surface); |
111 const base::android::JavaParamRef<jobject>& surface); | 111 |
112 void UiSurfaceChanged( | 112 void ContentBoundsChanged( |
113 JNIEnv* env, | 113 JNIEnv* env, |
114 const base::android::JavaParamRef<jobject>& object, | 114 const base::android::JavaParamRef<jobject>& object, |
115 jint width, | 115 jint width, jint height, jfloat dpr); |
116 jint height, | 116 |
117 const base::android::JavaParamRef<jobject>& surface); | 117 void UIBoundsChanged( |
| 118 JNIEnv* env, |
| 119 const base::android::JavaParamRef<jobject>& object, |
| 120 jint width, jint height, jfloat dpr); |
118 | 121 |
119 // Called from non-render thread to queue a callback onto the render thread. | 122 // Called from non-render thread to queue a callback onto the render thread. |
120 // The render thread checks for callbacks and processes them between frames. | 123 // The render thread checks for callbacks and processes them between frames. |
121 void QueueTask(base::Callback<void()>& callback); | 124 void QueueTask(base::Callback<void()>& callback); |
122 | 125 |
123 // Perform a UI action triggered by the javascript API. | 126 // Perform a UI action triggered by the javascript API. |
124 void DoUiAction(const UiAction action); | 127 void DoUiAction(const UiAction action); |
125 | 128 |
| 129 void SetContentCssSize(float width, float height, float dpr); |
| 130 void SetUiCssSize(float width, float height, float dpr); |
| 131 |
126 private: | 132 private: |
127 ~VrShell() override; | 133 ~VrShell() override; |
128 void LoadUIContent(); | 134 void LoadUIContent(); |
129 void DrawVrShell(const gvr::Mat4f& head_pose, gvr::Frame &frame); | 135 void DrawVrShell(const gvr::Mat4f& head_pose, gvr::Frame &frame); |
130 void DrawUiView(const gvr::Mat4f* head_pose, | 136 void DrawUiView(const gvr::Mat4f* head_pose, |
131 const std::vector<const ContentRectangle*>& elements, | 137 const std::vector<const ContentRectangle*>& elements, |
132 const gvr::Sizei& render_size, int viewport_offset); | 138 const gvr::Sizei& render_size, int viewport_offset); |
133 void DrawElements(const gvr::Mat4f& render_matrix, | 139 void DrawElements(const gvr::Mat4f& render_matrix, |
134 const std::vector<const ContentRectangle*>& elements); | 140 const std::vector<const ContentRectangle*>& elements); |
135 void DrawCursor(const gvr::Mat4f& render_matrix); | 141 void DrawCursor(const gvr::Mat4f& render_matrix); |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
184 VrShellDelegate* delegate_ = nullptr; | 190 VrShellDelegate* delegate_ = nullptr; |
185 std::unique_ptr<VrShellRenderer> vr_shell_renderer_; | 191 std::unique_ptr<VrShellRenderer> vr_shell_renderer_; |
186 base::android::ScopedJavaGlobalRef<jobject> j_vr_shell_; | 192 base::android::ScopedJavaGlobalRef<jobject> j_vr_shell_; |
187 | 193 |
188 bool touch_pending_ = false; | 194 bool touch_pending_ = false; |
189 gvr::Quatf controller_quat_; | 195 gvr::Quatf controller_quat_; |
190 | 196 |
191 gvr::Vec3f target_point_; | 197 gvr::Vec3f target_point_; |
192 const ContentRectangle* target_element_ = nullptr; | 198 const ContentRectangle* target_element_ = nullptr; |
193 VrInputManager* current_input_target_ = nullptr; | 199 VrInputManager* current_input_target_ = nullptr; |
194 int ui_tex_width_ = 0; | 200 int ui_tex_css_width_ = 0; |
195 int ui_tex_height_ = 0; | 201 int ui_tex_css_height_ = 0; |
196 int content_tex_width_ = 0; | 202 int content_tex_css_width_ = 0; |
197 int content_tex_height_ = 0; | 203 int content_tex_css_height_ = 0; |
198 gvr::Sizei content_tex_pixels_for_webvr_ = {0, 0}; | 204 gvr::Sizei content_tex_physical_size_ = {0, 0}; |
199 | 205 |
200 // The pose ring buffer size must be a power of two to avoid glitches when | 206 // The pose ring buffer size must be a power of two to avoid glitches when |
201 // the pose index wraps around. It should be large enough to handle the | 207 // the pose index wraps around. It should be large enough to handle the |
202 // current backlog of poses which is 2-3 frames. | 208 // current backlog of poses which is 2-3 frames. |
203 static constexpr int kPoseRingBufferSize = 8; | 209 static constexpr int kPoseRingBufferSize = 8; |
204 std::vector<gvr::Mat4f> webvr_head_pose_; | 210 std::vector<gvr::Mat4f> webvr_head_pose_; |
205 jint webvr_texture_id_ = 0; | 211 jint webvr_texture_id_ = 0; |
206 | 212 |
207 std::unique_ptr<VrController> controller_; | 213 std::unique_ptr<VrController> controller_; |
208 scoped_refptr<VrInputManager> content_input_manager_; | 214 scoped_refptr<VrInputManager> content_input_manager_; |
209 scoped_refptr<VrInputManager> ui_input_manager_; | 215 scoped_refptr<VrInputManager> ui_input_manager_; |
210 scoped_refptr<VrMetricsHelper> metrics_helper_; | 216 scoped_refptr<VrMetricsHelper> metrics_helper_; |
211 | 217 |
212 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner_; | 218 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner_; |
213 | 219 |
214 base::WeakPtrFactory<VrShell> weak_ptr_factory_; | 220 base::WeakPtrFactory<VrShell> weak_ptr_factory_; |
215 | 221 |
216 DISALLOW_COPY_AND_ASSIGN(VrShell); | 222 DISALLOW_COPY_AND_ASSIGN(VrShell); |
217 }; | 223 }; |
218 | 224 |
219 bool RegisterVrShell(JNIEnv* env); | 225 bool RegisterVrShell(JNIEnv* env); |
220 | 226 |
221 } // namespace vr_shell | 227 } // namespace vr_shell |
222 | 228 |
223 #endif // CHROME_BROWSER_ANDROID_VR_SHELL_VR_SHELL_H_ | 229 #endif // CHROME_BROWSER_ANDROID_VR_SHELL_VR_SHELL_H_ |
OLD | NEW |