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

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: Undo VrShellImpl changes, use native-side values. 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
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 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 UiInterface* GetUiInterface(); 89 UiInterface* GetUiInterface();
90 void OnDomContentsLoaded(); 90 void OnDomContentsLoaded();
91 91
92 // device::GvrDelegate implementation 92 // device::GvrDelegate implementation
93 void SetWebVRSecureOrigin(bool secure_origin) override; 93 void SetWebVRSecureOrigin(bool secure_origin) override;
94 void SubmitWebVRFrame() override; 94 void SubmitWebVRFrame() override;
95 void UpdateWebVRTextureBounds(const gvr::Rectf& left_bounds, 95 void UpdateWebVRTextureBounds(const gvr::Rectf& left_bounds,
96 const gvr::Rectf& right_bounds) override; 96 const gvr::Rectf& right_bounds) override;
97 gvr::GvrApi* gvr_api() override; 97 gvr::GvrApi* gvr_api() override;
98 void SetGvrPoseForWebVr(const gvr::Mat4f& pose, uint32_t pose_num) override; 98 void SetGvrPoseForWebVr(const gvr::Mat4f& pose, uint32_t pose_num) override;
99 void SetWebVRRenderSurfaceSize(int width, int height) override;
100 gvr::Sizei GetWebVRCompositorSurfaceSize() override;
99 101
100 void ContentSurfaceChanged( 102 void ContentSurfaceChanged(
101 JNIEnv* env, 103 JNIEnv* env,
102 const base::android::JavaParamRef<jobject>& object, 104 const base::android::JavaParamRef<jobject>& object,
103 jint width, 105 jint width,
104 jint height, 106 jint height,
105 const base::android::JavaParamRef<jobject>& surface); 107 const base::android::JavaParamRef<jobject>& surface);
106 void UiSurfaceChanged( 108 void UiSurfaceChanged(
107 JNIEnv* env, 109 JNIEnv* env,
108 const base::android::JavaParamRef<jobject>& object, 110 const base::android::JavaParamRef<jobject>& object,
109 jint width, 111 jint width,
110 jint height, 112 jint height,
111 const base::android::JavaParamRef<jobject>& surface); 113 const base::android::JavaParamRef<jobject>& surface);
112 114
113 // Called from non-render thread to queue a callback onto the render thread. 115 // Called from non-render thread to queue a callback onto the render thread.
114 // The render thread checks for callbacks and processes them between frames. 116 // The render thread checks for callbacks and processes them between frames.
115 void QueueTask(base::Callback<void()>& callback); 117 void QueueTask(base::Callback<void()>& callback);
116 118
117 // Perform a UI action triggered by the javascript API. 119 // Perform a UI action triggered by the javascript API.
118 void DoUiAction(const UiAction action); 120 void DoUiAction(const UiAction action);
119 121
120 private: 122 private:
121 ~VrShell() override; 123 ~VrShell() override;
122 void LoadUIContent(); 124 void LoadUIContent();
123 void DrawVrShell(const gvr::Mat4f& head_pose, gvr::Frame &frame); 125 void DrawVrShell(const gvr::Mat4f& head_pose, gvr::Frame &frame);
124 void DrawUiView(const gvr::Mat4f* head_pose, 126 void DrawUiView(const gvr::Mat4f* head_pose,
125 const std::vector<const ContentRectangle*>& elements); 127 const std::vector<const ContentRectangle*>& elements,
128 const gvr::Sizei& render_size, int viewport_offset);
126 void DrawElements(const gvr::Mat4f& render_matrix, 129 void DrawElements(const gvr::Mat4f& render_matrix,
127 const std::vector<const ContentRectangle*>& elements); 130 const std::vector<const ContentRectangle*>& elements);
128 void DrawCursor(const gvr::Mat4f& render_matrix); 131 void DrawCursor(const gvr::Mat4f& render_matrix);
129 void DrawWebVr(); 132 void DrawWebVr();
130 133
131 void UpdateController(const gvr::Vec3f& forward_vector); 134 void UpdateController(const gvr::Vec3f& forward_vector);
132 void SendEventsToTarget(VrInputManager* input_target, 135 void SendEventsToTarget(VrInputManager* input_target,
133 int pixel_x, 136 int pixel_x,
134 int pixel_y); 137 int pixel_y);
135 138
(...skipping 13 matching lines...) Expand all
149 152
150 std::unique_ptr<gvr::GvrApi> gvr_api_; 153 std::unique_ptr<gvr::GvrApi> gvr_api_;
151 std::unique_ptr<gvr::BufferViewportList> buffer_viewport_list_; 154 std::unique_ptr<gvr::BufferViewportList> buffer_viewport_list_;
152 std::unique_ptr<gvr::BufferViewport> buffer_viewport_; 155 std::unique_ptr<gvr::BufferViewport> buffer_viewport_;
153 std::unique_ptr<gvr::BufferViewport> headlocked_left_viewport_; 156 std::unique_ptr<gvr::BufferViewport> headlocked_left_viewport_;
154 std::unique_ptr<gvr::BufferViewport> headlocked_right_viewport_; 157 std::unique_ptr<gvr::BufferViewport> headlocked_right_viewport_;
155 std::unique_ptr<gvr::BufferViewport> webvr_left_viewport_; 158 std::unique_ptr<gvr::BufferViewport> webvr_left_viewport_;
156 std::unique_ptr<gvr::BufferViewport> webvr_right_viewport_; 159 std::unique_ptr<gvr::BufferViewport> webvr_right_viewport_;
157 std::unique_ptr<gvr::SwapChain> swap_chain_; 160 std::unique_ptr<gvr::SwapChain> swap_chain_;
158 161
159 gvr::Sizei render_size_; 162 gvr::Sizei render_size_primary_;
163 gvr::Sizei render_size_headlocked_;
160 164
161 std::queue<base::Callback<void()>> task_queue_; 165 std::queue<base::Callback<void()>> task_queue_;
162 base::Lock task_queue_lock_; 166 base::Lock task_queue_lock_;
163 base::Lock gvr_init_lock_; 167 base::Lock gvr_init_lock_;
164 168
165 std::unique_ptr<VrCompositor> content_compositor_; 169 std::unique_ptr<VrCompositor> content_compositor_;
166 content::WebContents* main_contents_; 170 content::WebContents* main_contents_;
167 std::unique_ptr<VrCompositor> ui_compositor_; 171 std::unique_ptr<VrCompositor> ui_compositor_;
168 content::WebContents* ui_contents_; 172 content::WebContents* ui_contents_;
169 std::unique_ptr<VrWebContentsObserver> vr_web_contents_observer_; 173 std::unique_ptr<VrWebContentsObserver> vr_web_contents_observer_;
170 174
171 VrShellDelegate* delegate_ = nullptr; 175 VrShellDelegate* delegate_ = nullptr;
172 std::unique_ptr<VrShellRenderer> vr_shell_renderer_; 176 std::unique_ptr<VrShellRenderer> vr_shell_renderer_;
173 base::android::ScopedJavaGlobalRef<jobject> j_vr_shell_; 177 base::android::ScopedJavaGlobalRef<jobject> j_vr_shell_;
174 178
175 bool touch_pending_ = false; 179 bool touch_pending_ = false;
176 gvr::Quatf controller_quat_; 180 gvr::Quatf controller_quat_;
177 181
178 gvr::Vec3f target_point_; 182 gvr::Vec3f target_point_;
179 const ContentRectangle* target_element_ = nullptr; 183 const ContentRectangle* target_element_ = nullptr;
180 VrInputManager* current_input_target_ = nullptr; 184 VrInputManager* current_input_target_ = nullptr;
181 int ui_tex_width_ = 0; 185 int ui_tex_width_ = 0;
182 int ui_tex_height_ = 0; 186 int ui_tex_height_ = 0;
183 int content_tex_width_ = 0; 187 int content_tex_width_ = 0;
184 int content_tex_height_ = 0; 188 int content_tex_height_ = 0;
185 189
186 bool webvr_mode_ = false; 190 bool webvr_mode_ = false;
191 bool webvr_needs_ui_ = false;
mthiesse 2016/11/16 21:30:41 Seems unused, remove?
187 192
188 // The pose ring buffer size must be a power of two to avoid glitches when 193 // The pose ring buffer size must be a power of two to avoid glitches when
189 // the pose index wraps around. It should be large enough to handle the 194 // the pose index wraps around. It should be large enough to handle the
190 // current backlog of poses which is 2-3 frames. 195 // current backlog of poses which is 2-3 frames.
191 static constexpr int kPoseRingBufferSize = 8; 196 static constexpr int kPoseRingBufferSize = 8;
192 std::vector<gvr::Mat4f> webvr_head_pose_; 197 std::vector<gvr::Mat4f> webvr_head_pose_;
198 jint webvr_texture_id_ = 0;
199 int webvr_width_ = 2048;
mthiesse 2016/11/16 21:30:41 magic numbers to constants somewhere? Also why the
200 int webvr_height_ = 1200;
193 201
194 std::unique_ptr<VrController> controller_; 202 std::unique_ptr<VrController> controller_;
195 scoped_refptr<VrInputManager> content_input_manager_; 203 scoped_refptr<VrInputManager> content_input_manager_;
196 scoped_refptr<VrInputManager> ui_input_manager_; 204 scoped_refptr<VrInputManager> ui_input_manager_;
197 205
198 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner_; 206 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner_;
199 207
200 base::WeakPtrFactory<VrShell> weak_ptr_factory_; 208 base::WeakPtrFactory<VrShell> weak_ptr_factory_;
201 209
202 DISALLOW_COPY_AND_ASSIGN(VrShell); 210 DISALLOW_COPY_AND_ASSIGN(VrShell);
203 }; 211 };
204 212
205 bool RegisterVrShell(JNIEnv* env); 213 bool RegisterVrShell(JNIEnv* env);
206 214
207 } // namespace vr_shell 215 } // namespace vr_shell
208 216
209 #endif // CHROME_BROWSER_ANDROID_VR_SHELL_VR_SHELL_H_ 217 #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') | chrome/browser/android/vr_shell/vr_shell.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698