Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(680)

Side by Side Diff: chrome/browser/android/vr_shell/vr_shell.h

Issue 2508703002: WebVR: Use content CVC size for compositor rendering (Closed)
Patch Set: Rebase, use more appropriate crbug/655722 for TODOS Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | chrome/browser/android/vr_shell/vr_shell.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 UiInterface* GetUiInterface(); 92 UiInterface* GetUiInterface();
93 void OnDomContentsLoaded(); 93 void OnDomContentsLoaded();
94 94
95 // device::GvrDelegate implementation 95 // device::GvrDelegate implementation
96 void SetWebVRSecureOrigin(bool secure_origin) override; 96 void SetWebVRSecureOrigin(bool secure_origin) override;
97 void SubmitWebVRFrame() override; 97 void SubmitWebVRFrame() override;
98 void UpdateWebVRTextureBounds(const gvr::Rectf& left_bounds, 98 void UpdateWebVRTextureBounds(const gvr::Rectf& left_bounds,
99 const gvr::Rectf& right_bounds) override; 99 const gvr::Rectf& right_bounds) override;
100 gvr::GvrApi* gvr_api() override; 100 gvr::GvrApi* gvr_api() override;
101 void SetGvrPoseForWebVr(const gvr::Mat4f& pose, uint32_t pose_num) override; 101 void SetGvrPoseForWebVr(const gvr::Mat4f& pose, uint32_t pose_num) override;
102 void SetWebVRRenderSurfaceSize(int width, int height) override;
103 gvr::Sizei GetWebVRCompositorSurfaceSize() override;
102 104
103 void ContentSurfaceChanged( 105 void ContentSurfaceChanged(
104 JNIEnv* env, 106 JNIEnv* env,
105 const base::android::JavaParamRef<jobject>& object, 107 const base::android::JavaParamRef<jobject>& object,
106 jint width, 108 jint width,
107 jint height, 109 jint height,
108 const base::android::JavaParamRef<jobject>& surface); 110 const base::android::JavaParamRef<jobject>& surface);
109 void UiSurfaceChanged( 111 void UiSurfaceChanged(
110 JNIEnv* env, 112 JNIEnv* env,
111 const base::android::JavaParamRef<jobject>& object, 113 const base::android::JavaParamRef<jobject>& object,
112 jint width, 114 jint width,
113 jint height, 115 jint height,
114 const base::android::JavaParamRef<jobject>& surface); 116 const base::android::JavaParamRef<jobject>& surface);
115 117
116 // Called from non-render thread to queue a callback onto the render thread. 118 // Called from non-render thread to queue a callback onto the render thread.
117 // The render thread checks for callbacks and processes them between frames. 119 // The render thread checks for callbacks and processes them between frames.
118 void QueueTask(base::Callback<void()>& callback); 120 void QueueTask(base::Callback<void()>& callback);
119 121
120 // Perform a UI action triggered by the javascript API. 122 // Perform a UI action triggered by the javascript API.
121 void DoUiAction(const UiAction action); 123 void DoUiAction(const UiAction action);
122 124
123 private: 125 private:
124 ~VrShell() override; 126 ~VrShell() override;
125 void LoadUIContent(); 127 void LoadUIContent();
126 void DrawVrShell(const gvr::Mat4f& head_pose, gvr::Frame &frame); 128 void DrawVrShell(const gvr::Mat4f& head_pose, gvr::Frame &frame);
127 void DrawUiView(const gvr::Mat4f* head_pose, 129 void DrawUiView(const gvr::Mat4f* head_pose,
128 const std::vector<const ContentRectangle*>& elements); 130 const std::vector<const ContentRectangle*>& elements,
131 const gvr::Sizei& render_size, int viewport_offset);
129 void DrawElements(const gvr::Mat4f& render_matrix, 132 void DrawElements(const gvr::Mat4f& render_matrix,
130 const std::vector<const ContentRectangle*>& elements); 133 const std::vector<const ContentRectangle*>& elements);
131 void DrawCursor(const gvr::Mat4f& render_matrix); 134 void DrawCursor(const gvr::Mat4f& render_matrix);
132 void DrawWebVr(); 135 void DrawWebVr();
133 136
134 void UpdateController(const gvr::Vec3f& forward_vector); 137 void UpdateController(const gvr::Vec3f& forward_vector);
135 void SendEventsToTarget(VrInputManager* input_target, 138 void SendEventsToTarget(VrInputManager* input_target,
136 int pixel_x, 139 int pixel_x,
137 int pixel_y); 140 int pixel_y);
138 141
(...skipping 13 matching lines...) Expand all
152 155
153 std::unique_ptr<gvr::GvrApi> gvr_api_; 156 std::unique_ptr<gvr::GvrApi> gvr_api_;
154 std::unique_ptr<gvr::BufferViewportList> buffer_viewport_list_; 157 std::unique_ptr<gvr::BufferViewportList> buffer_viewport_list_;
155 std::unique_ptr<gvr::BufferViewport> buffer_viewport_; 158 std::unique_ptr<gvr::BufferViewport> buffer_viewport_;
156 std::unique_ptr<gvr::BufferViewport> headlocked_left_viewport_; 159 std::unique_ptr<gvr::BufferViewport> headlocked_left_viewport_;
157 std::unique_ptr<gvr::BufferViewport> headlocked_right_viewport_; 160 std::unique_ptr<gvr::BufferViewport> headlocked_right_viewport_;
158 std::unique_ptr<gvr::BufferViewport> webvr_left_viewport_; 161 std::unique_ptr<gvr::BufferViewport> webvr_left_viewport_;
159 std::unique_ptr<gvr::BufferViewport> webvr_right_viewport_; 162 std::unique_ptr<gvr::BufferViewport> webvr_right_viewport_;
160 std::unique_ptr<gvr::SwapChain> swap_chain_; 163 std::unique_ptr<gvr::SwapChain> swap_chain_;
161 164
162 gvr::Sizei render_size_; 165 // Current sizes for the render buffers.
166 gvr::Sizei render_size_primary_;
167 gvr::Sizei render_size_headlocked_;
168
169 // Intended size for the primary render buffer by UI mode.
170 gvr::Sizei render_size_primary_webvr_ = device::kFallbackRenderTargetSize;
171 gvr::Sizei render_size_primary_vrshell_;
163 172
164 std::queue<base::Callback<void()>> task_queue_; 173 std::queue<base::Callback<void()>> task_queue_;
165 base::Lock task_queue_lock_; 174 base::Lock task_queue_lock_;
166 base::Lock gvr_init_lock_; 175 base::Lock gvr_init_lock_;
167 176
168 std::unique_ptr<VrCompositor> content_compositor_; 177 std::unique_ptr<VrCompositor> content_compositor_;
169 content::WebContents* main_contents_; 178 content::WebContents* main_contents_;
170 std::unique_ptr<VrCompositor> ui_compositor_; 179 std::unique_ptr<VrCompositor> ui_compositor_;
171 content::WebContents* ui_contents_; 180 content::WebContents* ui_contents_;
172 std::unique_ptr<VrWebContentsObserver> vr_web_contents_observer_; 181 std::unique_ptr<VrWebContentsObserver> vr_web_contents_observer_;
173 182
174 VrShellDelegate* delegate_ = nullptr; 183 VrShellDelegate* delegate_ = nullptr;
175 std::unique_ptr<VrShellRenderer> vr_shell_renderer_; 184 std::unique_ptr<VrShellRenderer> vr_shell_renderer_;
176 base::android::ScopedJavaGlobalRef<jobject> j_vr_shell_; 185 base::android::ScopedJavaGlobalRef<jobject> j_vr_shell_;
177 186
178 bool touch_pending_ = false; 187 bool touch_pending_ = false;
179 gvr::Quatf controller_quat_; 188 gvr::Quatf controller_quat_;
180 189
181 gvr::Vec3f target_point_; 190 gvr::Vec3f target_point_;
182 const ContentRectangle* target_element_ = nullptr; 191 const ContentRectangle* target_element_ = nullptr;
183 VrInputManager* current_input_target_ = nullptr; 192 VrInputManager* current_input_target_ = nullptr;
184 int ui_tex_width_ = 0; 193 int ui_tex_width_ = 0;
185 int ui_tex_height_ = 0; 194 int ui_tex_height_ = 0;
186 int content_tex_width_ = 0; 195 int content_tex_width_ = 0;
187 int content_tex_height_ = 0; 196 int content_tex_height_ = 0;
197 gvr::Sizei content_tex_pixels_for_webvr_ = {0, 0};
188 198
189 bool webvr_mode_ = false; 199 bool webvr_mode_ = false;
190 200
191 // The pose ring buffer size must be a power of two to avoid glitches when 201 // The pose ring buffer size must be a power of two to avoid glitches when
192 // the pose index wraps around. It should be large enough to handle the 202 // the pose index wraps around. It should be large enough to handle the
193 // current backlog of poses which is 2-3 frames. 203 // current backlog of poses which is 2-3 frames.
194 static constexpr int kPoseRingBufferSize = 8; 204 static constexpr int kPoseRingBufferSize = 8;
195 std::vector<gvr::Mat4f> webvr_head_pose_; 205 std::vector<gvr::Mat4f> webvr_head_pose_;
206 jint webvr_texture_id_ = 0;
196 207
197 std::unique_ptr<VrController> controller_; 208 std::unique_ptr<VrController> controller_;
198 scoped_refptr<VrInputManager> content_input_manager_; 209 scoped_refptr<VrInputManager> content_input_manager_;
199 scoped_refptr<VrInputManager> ui_input_manager_; 210 scoped_refptr<VrInputManager> ui_input_manager_;
200 scoped_refptr<VrMetricsHelper> metrics_helper_; 211 scoped_refptr<VrMetricsHelper> metrics_helper_;
201 212
202 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner_; 213 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner_;
203 214
204 base::WeakPtrFactory<VrShell> weak_ptr_factory_; 215 base::WeakPtrFactory<VrShell> weak_ptr_factory_;
205 216
206 DISALLOW_COPY_AND_ASSIGN(VrShell); 217 DISALLOW_COPY_AND_ASSIGN(VrShell);
207 }; 218 };
208 219
209 bool RegisterVrShell(JNIEnv* env); 220 bool RegisterVrShell(JNIEnv* env);
210 221
211 } // namespace vr_shell 222 } // namespace vr_shell
212 223
213 #endif // CHROME_BROWSER_ANDROID_VR_SHELL_VR_SHELL_H_ 224 #endif // CHROME_BROWSER_ANDROID_VR_SHELL_VR_SHELL_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/android/vr_shell/vr_shell.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698