| 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 #include <memory> | 9 #include <memory> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 jint height, | 87 jint height, |
| 88 const base::android::JavaParamRef<jobject>& surface); | 88 const base::android::JavaParamRef<jobject>& surface); |
| 89 | 89 |
| 90 // Called from non-render thread to queue a callback onto the render thread. | 90 // Called from non-render thread to queue a callback onto the render thread. |
| 91 // The render thread checks for callbacks and processes them between frames. | 91 // The render thread checks for callbacks and processes them between frames. |
| 92 void QueueTask(base::Callback<void()>& callback); | 92 void QueueTask(base::Callback<void()>& callback); |
| 93 | 93 |
| 94 private: | 94 private: |
| 95 virtual ~VrShell(); | 95 virtual ~VrShell(); |
| 96 void LoadUIContent(); | 96 void LoadUIContent(); |
| 97 bool IsUiTextureReady(); |
| 98 // Converts a pixel rectangle to (0..1) float texture coordinates. |
| 99 // Callers need to ensure that the texture width/height is |
| 100 // initialized by checking IsUiTextureReady() first. |
| 101 Rectf MakeUiGlCopyRect(Recti pixel_rect); |
| 97 void DrawVrShell(const gvr::Mat4f& head_pose); | 102 void DrawVrShell(const gvr::Mat4f& head_pose); |
| 98 void DrawEye(const gvr::Mat4f& view_matrix, | 103 void DrawEye(const gvr::Mat4f& view_matrix, |
| 99 const gvr::BufferViewport& params); | 104 const gvr::BufferViewport& params); |
| 100 void DrawContentRect(); | |
| 101 void DrawWebVr(); | |
| 102 void DrawUI(const gvr::Mat4f& render_matrix); | 105 void DrawUI(const gvr::Mat4f& render_matrix); |
| 103 void DrawCursor(const gvr::Mat4f& render_matrix); | 106 void DrawCursor(const gvr::Mat4f& render_matrix); |
| 107 void DrawWebVr(); |
| 108 void DrawWebVrOverlay(int64_t present_time_nanos); |
| 109 void DrawWebVrEye(const gvr::Mat4f& view_matrix, |
| 110 const gvr::BufferViewport& params, |
| 111 int64_t present_time_nanos); |
| 104 | 112 |
| 105 void UpdateController(const gvr::Vec3f& forward_vector); | 113 void UpdateController(const gvr::Vec3f& forward_vector); |
| 106 | 114 |
| 107 void HandleQueuedTasks(); | 115 void HandleQueuedTasks(); |
| 108 | 116 |
| 109 // samplerExternalOES texture data for UI content image. | 117 // samplerExternalOES texture data for UI content image. |
| 110 jint ui_texture_id_ = 0; | 118 jint ui_texture_id_ = 0; |
| 111 // samplerExternalOES texture data for main content image. | 119 // samplerExternalOES texture data for main content image. |
| 112 jint content_texture_id_ = 0; | 120 jint content_texture_id_ = 0; |
| 113 | 121 |
| 114 float desktop_screen_tilt_; | 122 float desktop_screen_tilt_; |
| 115 float desktop_height_; | 123 float desktop_height_; |
| 116 | 124 |
| 117 ContentRectangle* desktop_plane_; | 125 ContentRectangle* desktop_plane_; |
| 118 | 126 |
| 119 UiScene scene_; | 127 UiScene scene_; |
| 120 | 128 |
| 121 std::unique_ptr<gvr::GvrApi> gvr_api_; | 129 std::unique_ptr<gvr::GvrApi> gvr_api_; |
| 122 std::unique_ptr<gvr::BufferViewportList> buffer_viewport_list_; | 130 std::unique_ptr<gvr::BufferViewportList> buffer_viewport_list_; |
| 123 std::unique_ptr<gvr::BufferViewport> buffer_viewport_; | 131 std::unique_ptr<gvr::BufferViewport> buffer_viewport_; |
| 124 std::unique_ptr<gvr::SwapChain> swap_chain_; | 132 std::unique_ptr<gvr::SwapChain> swap_chain_; |
| 125 | 133 |
| 126 gvr::Sizei render_size_; | 134 gvr::Sizei render_size_; |
| 127 float cursor_distance_; | |
| 128 | 135 |
| 129 std::queue<base::Callback<void()>> task_queue_; | 136 std::queue<base::Callback<void()>> task_queue_; |
| 130 base::Lock task_queue_lock_; | 137 base::Lock task_queue_lock_; |
| 131 | 138 |
| 132 std::unique_ptr<VrCompositor> content_compositor_; | 139 std::unique_ptr<VrCompositor> content_compositor_; |
| 133 content::ContentViewCore* content_cvc_; | 140 content::ContentViewCore* content_cvc_; |
| 134 std::unique_ptr<VrCompositor> ui_compositor_; | 141 std::unique_ptr<VrCompositor> ui_compositor_; |
| 135 content::ContentViewCore* ui_cvc_; | 142 content::ContentViewCore* ui_cvc_; |
| 136 | 143 |
| 137 VrShellDelegate* delegate_; | 144 VrShellDelegate* delegate_; |
| 138 std::unique_ptr<VrShellRenderer> vr_shell_renderer_; | 145 std::unique_ptr<VrShellRenderer> vr_shell_renderer_; |
| 139 base::android::ScopedJavaGlobalRef<jobject> j_vr_shell_; | 146 base::android::ScopedJavaGlobalRef<jobject> j_vr_shell_; |
| 140 | 147 |
| 141 gvr::Quatf controller_quat_; | 148 gvr::Quatf controller_quat_; |
| 142 bool controller_active_ = false; | 149 bool controller_active_ = false; |
| 143 | 150 |
| 144 gvr::Vec3f target_point_; | 151 gvr::Vec3f target_point_; |
| 145 const ContentRectangle* target_element_ = nullptr; | 152 const ContentRectangle* target_element_ = nullptr; |
| 146 int ui_tex_width_ = 0; | 153 int ui_tex_width_ = 0; |
| 147 int ui_tex_height_ = 0; | 154 int ui_tex_height_ = 0; |
| 148 | 155 |
| 149 bool webvr_mode_ = false; | 156 bool webvr_mode_ = false; |
| 150 bool webvr_secure_origin_ = false; | 157 bool webvr_secure_origin_ = false; |
| 158 int64_t webvr_warning_end_nanos_ = 0; |
| 151 | 159 |
| 152 base::WeakPtrFactory<VrShell> weak_ptr_factory_; | 160 base::WeakPtrFactory<VrShell> weak_ptr_factory_; |
| 153 | 161 |
| 154 DISALLOW_COPY_AND_ASSIGN(VrShell); | 162 DISALLOW_COPY_AND_ASSIGN(VrShell); |
| 155 }; | 163 }; |
| 156 | 164 |
| 157 bool RegisterVrShell(JNIEnv* env); | 165 bool RegisterVrShell(JNIEnv* env); |
| 158 | 166 |
| 159 } // namespace vr_shell | 167 } // namespace vr_shell |
| 160 | 168 |
| 161 #endif // CHROME_BROWSER_ANDROID_VR_SHELL_VR_SHELL_H_ | 169 #endif // CHROME_BROWSER_ANDROID_VR_SHELL_VR_SHELL_H_ |
| OLD | NEW |