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

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

Issue 2612333002: Allow VRDisplay to specify which frame the layer bounds should be updated at. (Closed)
Patch Set: rebase + address comments Created 3 years, 10 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 #include <queue>
9 10
10 #include "base/cancelable_callback.h" 11 #include "base/cancelable_callback.h"
11 #include "base/macros.h" 12 #include "base/macros.h"
12 #include "base/memory/ref_counted.h" 13 #include "base/memory/ref_counted.h"
13 #include "base/memory/weak_ptr.h" 14 #include "base/memory/weak_ptr.h"
14 #include "base/single_thread_task_runner.h" 15 #include "base/single_thread_task_runner.h"
15 #include "device/vr/android/gvr/gvr_delegate.h" 16 #include "device/vr/android/gvr/gvr_delegate.h"
16 #include "device/vr/vr_service.mojom.h" 17 #include "device/vr/vr_service.mojom.h"
17 #include "mojo/public/cpp/bindings/binding.h" 18 #include "mojo/public/cpp/bindings/binding.h"
18 #include "third_party/gvr-android-sdk/src/libraries/headers/vr/gvr/capi/include/ gvr.h" 19 #include "third_party/gvr-android-sdk/src/libraries/headers/vr/gvr/capi/include/ gvr.h"
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 void OnPause(); 70 void OnPause();
70 void OnResume(); 71 void OnResume();
71 72
72 void SetWebVrMode(bool enabled); 73 void SetWebVrMode(bool enabled);
73 void ContentBoundsChanged(int width, int height); 74 void ContentBoundsChanged(int width, int height);
74 void ContentPhysicalBoundsChanged(int width, int height); 75 void ContentPhysicalBoundsChanged(int width, int height);
75 void UIBoundsChanged(int width, int height); 76 void UIBoundsChanged(int width, int height);
76 void UIPhysicalBoundsChanged(int width, int height); 77 void UIPhysicalBoundsChanged(int width, int height);
77 base::WeakPtr<VrShellGl> GetWeakPtr(); 78 base::WeakPtr<VrShellGl> GetWeakPtr();
78 79
79 void UpdateWebVRTextureBounds(const gvr::Rectf& left_bounds, 80 void UpdateWebVRTextureBounds(int16_t frame_index,
81 const gvr::Rectf& left_bounds,
80 const gvr::Rectf& right_bounds); 82 const gvr::Rectf& right_bounds);
81 gvr::GvrApi* gvr_api(); 83 gvr::GvrApi* gvr_api();
82 void SetGvrPoseForWebVr(const gvr::Mat4f& pose, uint32_t pose_num); 84 void SetGvrPoseForWebVr(const gvr::Mat4f& pose, uint32_t pose_num);
83 gvr::Sizei GetWebVRCompositorSurfaceSize(); 85 gvr::Sizei GetWebVRCompositorSurfaceSize();
84 86
85 void UpdateScene(std::unique_ptr<base::ListValue> commands); 87 void UpdateScene(std::unique_ptr<base::ListValue> commands);
86 88
87 void UpdateVSyncInterval(long timebase_nanos, double interval_seconds); 89 void UpdateVSyncInterval(long timebase_nanos, double interval_seconds);
88 90
89 void OnRequest(device::mojom::VRVSyncProviderRequest request); 91 void OnRequest(device::mojom::VRVSyncProviderRequest request);
(...skipping 14 matching lines...) Expand all
104 bool WebVrPoseByteIsValid(int pose_index_byte); 106 bool WebVrPoseByteIsValid(int pose_index_byte);
105 107
106 void UpdateController(const gvr::Vec3f& forward_vector); 108 void UpdateController(const gvr::Vec3f& forward_vector);
107 void SendEventsToTarget(InputTarget input_target, int pixel_x, 109 void SendEventsToTarget(InputTarget input_target, int pixel_x,
108 int pixel_y); 110 int pixel_y);
109 void SendGesture(InputTarget input_target, 111 void SendGesture(InputTarget input_target,
110 std::unique_ptr<blink::WebInputEvent> event); 112 std::unique_ptr<blink::WebInputEvent> event);
111 113
112 void OnUIFrameAvailable(); 114 void OnUIFrameAvailable();
113 void OnContentFrameAvailable(); 115 void OnContentFrameAvailable();
114 bool GetPixelEncodedPoseIndexByte(int* pose_index); 116 bool GetPixelEncodedFrameIndex(uint16_t* frame_index);
115 117
116 void OnVSync(); 118 void OnVSync();
117 119
118 // VRVSyncProvider 120 // VRVSyncProvider
119 void GetVSync(const GetVSyncCallback& callback) override; 121 void GetVSync(const GetVSyncCallback& callback) override;
120 122
121 void ForceExitVr(); 123 void ForceExitVr();
122 124
123 device::mojom::VRPosePtr GetPose(); 125 void SendVSync(base::TimeDelta time, const GetVSyncCallback& callback);
124 126
125 // samplerExternalOES texture data for UI content image. 127 // samplerExternalOES texture data for UI content image.
126 int ui_texture_id_ = 0; 128 int ui_texture_id_ = 0;
127 // samplerExternalOES texture data for main content image. 129 // samplerExternalOES texture data for main content image.
128 int content_texture_id_ = 0; 130 int content_texture_id_ = 0;
129 131
130 std::unique_ptr<UiScene> scene_; 132 std::unique_ptr<UiScene> scene_;
131 133
132 scoped_refptr<gl::GLSurface> surface_; 134 scoped_refptr<gl::GLSurface> surface_;
133 scoped_refptr<gl::GLContext> context_; 135 scoped_refptr<gl::GLContext> context_;
134 scoped_refptr<gl::SurfaceTexture> ui_surface_texture_; 136 scoped_refptr<gl::SurfaceTexture> ui_surface_texture_;
135 scoped_refptr<gl::SurfaceTexture> content_surface_texture_; 137 scoped_refptr<gl::SurfaceTexture> content_surface_texture_;
136 138
137 std::unique_ptr<gl::ScopedJavaSurface> ui_surface_; 139 std::unique_ptr<gl::ScopedJavaSurface> ui_surface_;
138 std::unique_ptr<gl::ScopedJavaSurface> content_surface_; 140 std::unique_ptr<gl::ScopedJavaSurface> content_surface_;
139 141
140 std::unique_ptr<gvr::GvrApi> gvr_api_; 142 std::unique_ptr<gvr::GvrApi> gvr_api_;
141 std::unique_ptr<gvr::BufferViewportList> buffer_viewport_list_; 143 std::unique_ptr<gvr::BufferViewportList> buffer_viewport_list_;
142 std::unique_ptr<gvr::BufferViewport> buffer_viewport_; 144 std::unique_ptr<gvr::BufferViewport> buffer_viewport_;
143 std::unique_ptr<gvr::BufferViewport> headlocked_left_viewport_; 145 std::unique_ptr<gvr::BufferViewport> headlocked_left_viewport_;
144 std::unique_ptr<gvr::BufferViewport> headlocked_right_viewport_; 146 std::unique_ptr<gvr::BufferViewport> headlocked_right_viewport_;
145 std::unique_ptr<gvr::BufferViewport> webvr_left_viewport_; 147 std::unique_ptr<gvr::BufferViewport> webvr_left_viewport_;
146 std::unique_ptr<gvr::BufferViewport> webvr_right_viewport_; 148 std::unique_ptr<gvr::BufferViewport> webvr_right_viewport_;
147 std::unique_ptr<gvr::SwapChain> swap_chain_; 149 std::unique_ptr<gvr::SwapChain> swap_chain_;
150 using BoundsPair = std::pair<gvr::Rectf, gvr::Rectf>;
151 std::queue<std::pair<uint8_t, BoundsPair>> pending_bounds_;
148 152
149 // Current sizes for the render buffers. 153 // Current sizes for the render buffers.
150 gvr::Sizei render_size_primary_; 154 gvr::Sizei render_size_primary_;
151 gvr::Sizei render_size_headlocked_; 155 gvr::Sizei render_size_headlocked_;
152 156
153 std::unique_ptr<VrShellRenderer> vr_shell_renderer_; 157 std::unique_ptr<VrShellRenderer> vr_shell_renderer_;
154 158
155 bool touch_pending_ = false; 159 bool touch_pending_ = false;
156 gvr::Quatf controller_quat_; 160 gvr::Quatf controller_quat_;
157 161
158 gvr::Vec3f target_point_; 162 gvr::Vec3f target_point_;
159 const ContentRectangle* target_element_ = nullptr; 163 const ContentRectangle* target_element_ = nullptr;
160 InputTarget current_input_target_ = InputTarget::NONE; 164 InputTarget current_input_target_ = InputTarget::NONE;
161 int ui_tex_css_width_ = 0; 165 int ui_tex_css_width_ = 0;
162 int ui_tex_css_height_ = 0; 166 int ui_tex_css_height_ = 0;
163 int content_tex_css_width_ = 0; 167 int content_tex_css_width_ = 0;
164 int content_tex_css_height_ = 0; 168 int content_tex_css_height_ = 0;
165 gvr::Sizei content_tex_physical_size_ = {0, 0}; 169 gvr::Sizei content_tex_physical_size_ = {0, 0};
166 gvr::Sizei ui_tex_physical_size_ = {0, 0}; 170 gvr::Sizei ui_tex_physical_size_ = {0, 0};
167 171
168 // The pose ring buffer size must be a power of two to avoid glitches when
169 // the pose index wraps around. It should be large enough to handle the
170 // current backlog of poses which is 2-3 frames.
171 static constexpr int kPoseRingBufferSize = 8;
172 std::vector<gvr::Mat4f> webvr_head_pose_; 172 std::vector<gvr::Mat4f> webvr_head_pose_;
173 int webvr_texture_id_ = 0; 173 int webvr_texture_id_ = 0;
174 bool web_vr_mode_; 174 bool web_vr_mode_;
175 bool ready_to_draw_ = false; 175 bool ready_to_draw_ = false;
176 bool surfaceless_rendering_; 176 bool surfaceless_rendering_;
177 177
178 std::unique_ptr<VrController> controller_; 178 std::unique_ptr<VrController> controller_;
179 179
180 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; 180 scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
181 base::CancelableClosure vsync_task_; 181 base::CancelableClosure vsync_task_;
182 base::TimeTicks vsync_timebase_; 182 base::TimeTicks vsync_timebase_;
183 base::TimeDelta vsync_interval_; 183 base::TimeDelta vsync_interval_;
184 184
185 base::TimeDelta pending_time_; 185 base::TimeDelta pending_time_;
186 bool pending_vsync_ = false; 186 bool pending_vsync_ = false;
187 GetVSyncCallback callback_; 187 GetVSyncCallback callback_;
188 bool received_frame_ = false; 188 bool received_frame_ = false;
189 mojo::Binding<device::mojom::VRVSyncProvider> binding_; 189 mojo::Binding<device::mojom::VRVSyncProvider> binding_;
190 190
191 base::WeakPtr<VrShell> weak_vr_shell_; 191 base::WeakPtr<VrShell> weak_vr_shell_;
192 base::WeakPtr<VrShellDelegate> delegate_provider_; 192 base::WeakPtr<VrShellDelegate> delegate_provider_;
193 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner_; 193 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner_;
194 194
195 uint32_t pose_index_ = 1; 195 uint8_t frame_index_ = 0;
196 int last_pose_ = 0; 196 // larger than frame_index_ so it can be initialized out-of-band.
197 uint16_t last_frame_index_ = -1;
197 198
198 base::WeakPtrFactory<VrShellGl> weak_ptr_factory_; 199 base::WeakPtrFactory<VrShellGl> weak_ptr_factory_;
199 200
200 DISALLOW_COPY_AND_ASSIGN(VrShellGl); 201 DISALLOW_COPY_AND_ASSIGN(VrShellGl);
201 }; 202 };
202 203
203 } // namespace vr_shell 204 } // namespace vr_shell
204 205
205 #endif // CHROME_BROWSER_ANDROID_VR_SHELL_VR_SHELL_GL_H_ 206 #endif // CHROME_BROWSER_ANDROID_VR_SHELL_VR_SHELL_GL_H_
OLDNEW
« no previous file with comments | « chrome/browser/android/vr_shell/vr_shell.cc ('k') | chrome/browser/android/vr_shell/vr_shell_gl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698