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

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

Issue 2624633002: Remove Sync GetPose VRService call, implement VRVSyncProvider (Closed)
Patch Set: Created 3 years, 11 months 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_GL_H_ 5 #ifndef CHROME_BROWSER_ANDROID_VR_SHELL_VR_SHELL_GL_H_
6 #define CHROME_BROWSER_ANDROID_VR_SHELL_VR_SHELL_GL_H_ 6 #define CHROME_BROWSER_ANDROID_VR_SHELL_VR_SHELL_GL_H_
7 7
8 #include <memory> 8 #include <memory>
9 9
10 #include "base/cancelable_callback.h" 10 #include "base/cancelable_callback.h"
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "base/memory/ref_counted.h" 12 #include "base/memory/ref_counted.h"
13 #include "base/memory/weak_ptr.h" 13 #include "base/memory/weak_ptr.h"
14 #include "base/single_thread_task_runner.h" 14 #include "base/single_thread_task_runner.h"
15 #include "device/vr/android/gvr/gvr_delegate.h" 15 #include "device/vr/android/gvr/gvr_delegate.h"
16 #include "device/vr/vr_service.mojom.h"
16 #include "third_party/gvr-android-sdk/src/libraries/headers/vr/gvr/capi/include/ gvr.h" 17 #include "third_party/gvr-android-sdk/src/libraries/headers/vr/gvr/capi/include/ gvr.h"
17 #include "third_party/gvr-android-sdk/src/libraries/headers/vr/gvr/capi/include/ gvr_types.h" 18 #include "third_party/gvr-android-sdk/src/libraries/headers/vr/gvr/capi/include/ gvr_types.h"
18 #include "ui/gfx/native_widget_types.h" 19 #include "ui/gfx/native_widget_types.h"
19 20
20 namespace base { 21 namespace base {
21 class ListValue; 22 class ListValue;
22 } 23 }
23 24
24 namespace blink { 25 namespace blink {
25 class WebInputEvent; 26 class WebInputEvent;
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 const base::WeakPtr<VrInputManager>& ui_input_manager, 58 const base::WeakPtr<VrInputManager>& ui_input_manager,
58 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner, 59 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner,
59 gvr_context* gvr_api, 60 gvr_context* gvr_api,
60 bool initially_web_vr, 61 bool initially_web_vr,
61 bool reprojected_rendering); 62 bool reprojected_rendering);
62 ~VrShellGl(); 63 ~VrShellGl();
63 64
64 void Initialize(); 65 void Initialize();
65 void InitializeGl(gfx::AcceleratedWidget window); 66 void InitializeGl(gfx::AcceleratedWidget window);
66 67
67 void DrawFrame();
68
69 void OnTriggerEvent(); 68 void OnTriggerEvent();
70 void OnPause(); 69 void OnPause();
71 void OnResume(); 70 void OnResume();
72 71
73 void SetWebVrMode(bool enabled); 72 void SetWebVrMode(bool enabled);
74 void ContentBoundsChanged(int width, int height); 73 void ContentBoundsChanged(int width, int height);
75 void ContentPhysicalBoundsChanged(int width, int height); 74 void ContentPhysicalBoundsChanged(int width, int height);
76 void UIBoundsChanged(int width, int height); 75 void UIBoundsChanged(int width, int height);
77 void UIPhysicalBoundsChanged(int width, int height); 76 void UIPhysicalBoundsChanged(int width, int height);
78 base::WeakPtr<VrShellGl> GetWeakPtr(); 77 base::WeakPtr<VrShellGl> GetWeakPtr();
79 78
80 void UpdateWebVRTextureBounds(const gvr::Rectf& left_bounds, 79 void UpdateWebVRTextureBounds(const gvr::Rectf& left_bounds,
81 const gvr::Rectf& right_bounds); 80 const gvr::Rectf& right_bounds);
82 gvr::GvrApi* gvr_api(); 81 gvr::GvrApi* gvr_api();
83 void SetGvrPoseForWebVr(const gvr::Mat4f& pose, uint32_t pose_num); 82 void SetGvrPoseForWebVr(const gvr::Mat4f& pose, uint32_t pose_num);
84 gvr::Sizei GetWebVRCompositorSurfaceSize(); 83 gvr::Sizei GetWebVRCompositorSurfaceSize();
85 84
86 void UpdateScene(std::unique_ptr<base::ListValue> commands); 85 void UpdateScene(std::unique_ptr<base::ListValue> commands);
87 86
87 void OnVRVSyncProviderClientConnected(
88 device::mojom::VRVSyncProviderClientPtr client_info);
89 void UpdateVSyncInterval(long timebase_nanos, double interval_seconds);
90
88 private: 91 private:
89 void GvrInit(gvr_context* gvr_api); 92 void GvrInit(gvr_context* gvr_api);
90 void InitializeRenderer(); 93 void InitializeRenderer();
94 void DrawFrame();
91 void DrawVrShell(const gvr::Mat4f& head_pose, gvr::Frame &frame); 95 void DrawVrShell(const gvr::Mat4f& head_pose, gvr::Frame &frame);
92 void DrawUiView(const gvr::Mat4f* head_pose, 96 void DrawUiView(const gvr::Mat4f* head_pose,
93 const std::vector<const ContentRectangle*>& elements, 97 const std::vector<const ContentRectangle*>& elements,
94 const gvr::Sizei& render_size, int viewport_offset); 98 const gvr::Sizei& render_size, int viewport_offset);
95 void DrawElements(const gvr::Mat4f& render_matrix, 99 void DrawElements(const gvr::Mat4f& render_matrix,
96 const std::vector<const ContentRectangle*>& elements); 100 const std::vector<const ContentRectangle*>& elements);
97 void DrawCursor(const gvr::Mat4f& render_matrix); 101 void DrawCursor(const gvr::Mat4f& render_matrix);
98 void DrawWebVr(); 102 void DrawWebVr();
99 bool WebVrPoseByteIsValid(int pose_index_byte); 103 bool WebVrPoseByteIsValid(int pose_index_byte);
100 104
101 void UpdateController(const gvr::Vec3f& forward_vector); 105 void UpdateController(const gvr::Vec3f& forward_vector);
102 void SendEventsToTarget(InputTarget input_target, int pixel_x, 106 void SendEventsToTarget(InputTarget input_target, int pixel_x,
103 int pixel_y); 107 int pixel_y);
104 void SendGesture(InputTarget input_target, 108 void SendGesture(InputTarget input_target,
105 std::unique_ptr<blink::WebInputEvent> event); 109 std::unique_ptr<blink::WebInputEvent> event);
106 110
107 void OnUIFrameAvailable(); 111 void OnUIFrameAvailable();
108 void OnContentFrameAvailable(); 112 void OnContentFrameAvailable();
109 113
110 void UpdateVSyncParameters(const base::TimeTicks timebase,
111 const base::TimeDelta interval);
112 void ScheduleNextDrawFrame(); 114 void ScheduleNextDrawFrame();
113 115
114 void ForceExitVr(); 116 void ForceExitVr();
115 117
118 void OnVSyncAck();
119
120 device::mojom::VRPosePtr GetPose();
121
116 // samplerExternalOES texture data for UI content image. 122 // samplerExternalOES texture data for UI content image.
117 int ui_texture_id_ = 0; 123 int ui_texture_id_ = 0;
118 // samplerExternalOES texture data for main content image. 124 // samplerExternalOES texture data for main content image.
119 int content_texture_id_ = 0; 125 int content_texture_id_ = 0;
120 126
121 std::unique_ptr<UiScene> scene_; 127 std::unique_ptr<UiScene> scene_;
122 128
123 scoped_refptr<gl::GLSurface> surface_; 129 scoped_refptr<gl::GLSurface> surface_;
124 scoped_refptr<gl::GLContext> context_; 130 scoped_refptr<gl::GLContext> context_;
125 scoped_refptr<gl::SurfaceTexture> ui_surface_texture_; 131 scoped_refptr<gl::SurfaceTexture> ui_surface_texture_;
(...skipping 28 matching lines...) Expand all
154 int content_tex_css_width_ = 0; 160 int content_tex_css_width_ = 0;
155 int content_tex_css_height_ = 0; 161 int content_tex_css_height_ = 0;
156 gvr::Sizei content_tex_physical_size_ = {0, 0}; 162 gvr::Sizei content_tex_physical_size_ = {0, 0};
157 gvr::Sizei ui_tex_physical_size_ = {0, 0}; 163 gvr::Sizei ui_tex_physical_size_ = {0, 0};
158 164
159 // The pose ring buffer size must be a power of two to avoid glitches when 165 // The pose ring buffer size must be a power of two to avoid glitches when
160 // the pose index wraps around. It should be large enough to handle the 166 // the pose index wraps around. It should be large enough to handle the
161 // current backlog of poses which is 2-3 frames. 167 // current backlog of poses which is 2-3 frames.
162 static constexpr int kPoseRingBufferSize = 8; 168 static constexpr int kPoseRingBufferSize = 8;
163 std::vector<gvr::Mat4f> webvr_head_pose_; 169 std::vector<gvr::Mat4f> webvr_head_pose_;
164 std::vector<bool> webvr_head_pose_valid_;
165 int webvr_texture_id_ = 0; 170 int webvr_texture_id_ = 0;
166 bool web_vr_mode_; 171 bool web_vr_mode_;
167 bool ready_to_draw_ = false; 172 bool ready_to_draw_ = false;
168 bool surfaceless_rendering_; 173 bool surfaceless_rendering_;
169 174
170 std::unique_ptr<VrController> controller_; 175 std::unique_ptr<VrController> controller_;
171 176
172 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; 177 scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
173 base::CancelableClosure draw_task_; 178 base::CancelableClosure draw_task_;
174 base::TimeTicks vsync_timebase_; 179 base::TimeTicks vsync_timebase_;
175 base::TimeDelta vsync_interval_; 180 base::TimeDelta vsync_interval_;
176 181
182 bool pending_vsync_ = false;
183 double pending_time_;
184 bool pending_ack_ = false;
185 bool triggered_vsync_from_ack_ = false;
186
177 base::WeakPtr<VrShell> weak_vr_shell_; 187 base::WeakPtr<VrShell> weak_vr_shell_;
178 base::WeakPtr<VrInputManager> content_input_manager_; 188 base::WeakPtr<VrInputManager> content_input_manager_;
179 base::WeakPtr<VrInputManager> ui_input_manager_; 189 base::WeakPtr<VrInputManager> ui_input_manager_;
180 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner_; 190 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner_;
181 191
192 device::mojom::VRVSyncProviderClientPtr client_;
193 uint32_t pose_index_ = 1;
194
182 base::WeakPtrFactory<VrShellGl> weak_ptr_factory_; 195 base::WeakPtrFactory<VrShellGl> weak_ptr_factory_;
183 196
184 DISALLOW_COPY_AND_ASSIGN(VrShellGl); 197 DISALLOW_COPY_AND_ASSIGN(VrShellGl);
185 }; 198 };
186 199
187 } // namespace vr_shell 200 } // namespace vr_shell
188 201
189 #endif // CHROME_BROWSER_ANDROID_VR_SHELL_VR_SHELL_GL_H_ 202 #endif // CHROME_BROWSER_ANDROID_VR_SHELL_VR_SHELL_GL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698