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

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

Issue 2428383006: Decouple VR Shell DPR and CSS size from Physical Displays. (Closed)
Patch Set: Address bshe comments + minor fix Created 4 years 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 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
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);
136 void DrawWebVr(); 142 void DrawWebVr();
137 143
138 void UpdateController(const gvr::Vec3f& forward_vector); 144 void UpdateController(const gvr::Vec3f& forward_vector);
139 void SendEventsToTarget(VrInputManager* input_target, 145 void SendEventsToTarget(VrInputManager* input_target,
140 int pixel_x, 146 int pixel_x,
141 int pixel_y); 147 int pixel_y);
142 148
143 void HandleQueuedTasks(); 149 void HandleQueuedTasks();
144 150
145 // content::WebContentsObserver implementation. 151 // content::WebContentsObserver implementation.
146 void RenderViewHostChanged(content::RenderViewHost* old_host, 152 void RenderViewHostChanged(content::RenderViewHost* old_host,
147 content::RenderViewHost* new_host) override; 153 content::RenderViewHost* new_host) override;
154 void MainFrameWasResized(bool width_changed) override;
148 155
149 // samplerExternalOES texture data for UI content image. 156 // samplerExternalOES texture data for UI content image.
150 jint ui_texture_id_ = 0; 157 jint ui_texture_id_ = 0;
151 // samplerExternalOES texture data for main content image. 158 // samplerExternalOES texture data for main content image.
152 jint content_texture_id_ = 0; 159 jint content_texture_id_ = 0;
153 160
154 std::unique_ptr<UiScene> scene_; 161 std::unique_ptr<UiScene> scene_;
155 std::unique_ptr<UiInterface> html_interface_; 162 std::unique_ptr<UiInterface> html_interface_;
156 163
157 std::unique_ptr<gvr::GvrApi> gvr_api_; 164 std::unique_ptr<gvr::GvrApi> gvr_api_;
(...skipping 26 matching lines...) Expand all
184 VrShellDelegate* delegate_ = nullptr; 191 VrShellDelegate* delegate_ = nullptr;
185 std::unique_ptr<VrShellRenderer> vr_shell_renderer_; 192 std::unique_ptr<VrShellRenderer> vr_shell_renderer_;
186 base::android::ScopedJavaGlobalRef<jobject> j_vr_shell_; 193 base::android::ScopedJavaGlobalRef<jobject> j_vr_shell_;
187 194
188 bool touch_pending_ = false; 195 bool touch_pending_ = false;
189 gvr::Quatf controller_quat_; 196 gvr::Quatf controller_quat_;
190 197
191 gvr::Vec3f target_point_; 198 gvr::Vec3f target_point_;
192 const ContentRectangle* target_element_ = nullptr; 199 const ContentRectangle* target_element_ = nullptr;
193 VrInputManager* current_input_target_ = nullptr; 200 VrInputManager* current_input_target_ = nullptr;
194 int ui_tex_width_ = 0; 201 int ui_tex_css_width_ = 0;
195 int ui_tex_height_ = 0; 202 int ui_tex_css_height_ = 0;
196 int content_tex_width_ = 0; 203 int content_tex_css_width_ = 0;
197 int content_tex_height_ = 0; 204 int content_tex_css_height_ = 0;
198 gvr::Sizei content_tex_pixels_for_webvr_ = {0, 0}; 205 gvr::Sizei content_tex_physical_size_ = {0, 0};
199 206
200 // The pose ring buffer size must be a power of two to avoid glitches when 207 // 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 208 // the pose index wraps around. It should be large enough to handle the
202 // current backlog of poses which is 2-3 frames. 209 // current backlog of poses which is 2-3 frames.
203 static constexpr int kPoseRingBufferSize = 8; 210 static constexpr int kPoseRingBufferSize = 8;
204 std::vector<gvr::Mat4f> webvr_head_pose_; 211 std::vector<gvr::Mat4f> webvr_head_pose_;
205 jint webvr_texture_id_ = 0; 212 jint webvr_texture_id_ = 0;
206 213
207 std::unique_ptr<VrController> controller_; 214 std::unique_ptr<VrController> controller_;
208 scoped_refptr<VrInputManager> content_input_manager_; 215 scoped_refptr<VrInputManager> content_input_manager_;
209 scoped_refptr<VrInputManager> ui_input_manager_; 216 scoped_refptr<VrInputManager> ui_input_manager_;
210 scoped_refptr<VrMetricsHelper> metrics_helper_; 217 scoped_refptr<VrMetricsHelper> metrics_helper_;
211 218
212 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner_; 219 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner_;
213 220
214 base::WeakPtrFactory<VrShell> weak_ptr_factory_; 221 base::WeakPtrFactory<VrShell> weak_ptr_factory_;
215 222
216 DISALLOW_COPY_AND_ASSIGN(VrShell); 223 DISALLOW_COPY_AND_ASSIGN(VrShell);
217 }; 224 };
218 225
219 bool RegisterVrShell(JNIEnv* env); 226 bool RegisterVrShell(JNIEnv* env);
220 227
221 } // namespace vr_shell 228 } // namespace vr_shell
222 229
223 #endif // CHROME_BROWSER_ANDROID_VR_SHELL_VR_SHELL_H_ 230 #endif // CHROME_BROWSER_ANDROID_VR_SHELL_VR_SHELL_H_
OLDNEW
« no previous file with comments | « chrome/browser/android/vr_shell/vr_compositor.cc ('k') | chrome/browser/android/vr_shell/vr_shell.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698