| OLD | NEW |
| 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 #include <queue> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 | 36 |
| 37 namespace gpu { | 37 namespace gpu { |
| 38 struct MailboxHolder; | 38 struct MailboxHolder; |
| 39 } | 39 } |
| 40 | 40 |
| 41 namespace vr_shell { | 41 namespace vr_shell { |
| 42 | 42 |
| 43 class FPSMeter; | 43 class FPSMeter; |
| 44 class MailboxToSurfaceBridge; | 44 class MailboxToSurfaceBridge; |
| 45 class UiScene; | 45 class UiScene; |
| 46 class VrBrowserInterface; |
| 46 class VrController; | 47 class VrController; |
| 47 class VrShell; | 48 class VrShell; |
| 48 class VrShellRenderer; | 49 class VrShellRenderer; |
| 49 struct UiElement; | 50 struct UiElement; |
| 50 | 51 |
| 51 struct WebVrBounds { | 52 struct WebVrBounds { |
| 52 WebVrBounds(const gfx::RectF& left, | 53 WebVrBounds(const gfx::RectF& left, |
| 53 const gfx::RectF& right, | 54 const gfx::RectF& right, |
| 54 const gfx::Size& size) | 55 const gfx::Size& size) |
| 55 : left_bounds(left), right_bounds(right), source_size(size) {} | 56 : left_bounds(left), right_bounds(right), source_size(size) {} |
| 56 gfx::RectF left_bounds; | 57 gfx::RectF left_bounds; |
| 57 gfx::RectF right_bounds; | 58 gfx::RectF right_bounds; |
| 58 gfx::Size source_size; | 59 gfx::Size source_size; |
| 59 }; | 60 }; |
| 60 | 61 |
| 61 // This class manages all GLThread owned objects and GL rendering for VrShell. | 62 // This class manages all GLThread owned objects and GL rendering for VrShell. |
| 62 // It is not threadsafe and must only be used on the GL thread. | 63 // It is not threadsafe and must only be used on the GL thread. |
| 63 class VrShellGl : public device::mojom::VRVSyncProvider { | 64 class VrShellGl : public device::mojom::VRVSyncProvider { |
| 64 public: | 65 public: |
| 65 enum class InputTarget { | 66 enum class InputTarget { |
| 66 NONE = 0, | 67 NONE = 0, |
| 67 CONTENT, | 68 CONTENT, |
| 68 }; | 69 }; |
| 69 | 70 |
| 70 VrShellGl(const base::WeakPtr<VrShell>& weak_vr_shell, | 71 VrShellGl(VrBrowserInterface* browser, |
| 71 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner, | |
| 72 gvr_context* gvr_api, | 72 gvr_context* gvr_api, |
| 73 bool initially_web_vr, | 73 bool initially_web_vr, |
| 74 bool reprojected_rendering, | 74 bool reprojected_rendering, |
| 75 UiScene* scene); | 75 UiScene* scene); |
| 76 ~VrShellGl() override; | 76 ~VrShellGl() override; |
| 77 | 77 |
| 78 void Initialize(); | 78 void Initialize(); |
| 79 void InitializeGl(gfx::AcceleratedWidget window); | 79 void InitializeGl(gfx::AcceleratedWidget window); |
| 80 | 80 |
| 81 void OnTriggerEvent(); | 81 void OnTriggerEvent(); |
| 82 void OnPause(); | 82 void OnPause(); |
| 83 void OnResume(); | 83 void OnResume(); |
| 84 | 84 |
| 85 scoped_refptr<base::SingleThreadTaskRunner> GetTaskRunner() { |
| 86 return task_runner_; |
| 87 } |
| 88 |
| 85 void SetWebVrMode(bool enabled); | 89 void SetWebVrMode(bool enabled); |
| 86 void CreateOrResizeWebVRSurface(const gfx::Size& size); | 90 void CreateOrResizeWebVRSurface(const gfx::Size& size); |
| 87 void CreateContentSurface(); | 91 void CreateContentSurface(); |
| 88 void ContentBoundsChanged(int width, int height); | 92 void ContentBoundsChanged(int width, int height); |
| 89 void ContentPhysicalBoundsChanged(int width, int height); | 93 void ContentPhysicalBoundsChanged(int width, int height); |
| 90 void UIBoundsChanged(int width, int height); | 94 void UIBoundsChanged(int width, int height); |
| 91 void UIPhysicalBoundsChanged(int width, int height); | 95 void UIPhysicalBoundsChanged(int width, int height); |
| 92 base::WeakPtr<VrShellGl> GetWeakPtr(); | 96 base::WeakPtr<VrShellGl> GetWeakPtr(); |
| 93 | 97 |
| 94 void SetControllerModel(std::unique_ptr<VrControllerModel> model); | 98 void SetControllerModel(std::unique_ptr<VrControllerModel> model); |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 218 base::TimeTicks vsync_timebase_; | 222 base::TimeTicks vsync_timebase_; |
| 219 base::TimeDelta vsync_interval_; | 223 base::TimeDelta vsync_interval_; |
| 220 | 224 |
| 221 base::TimeDelta pending_time_; | 225 base::TimeDelta pending_time_; |
| 222 bool pending_vsync_ = false; | 226 bool pending_vsync_ = false; |
| 223 GetVSyncCallback callback_; | 227 GetVSyncCallback callback_; |
| 224 bool received_frame_ = false; | 228 bool received_frame_ = false; |
| 225 mojo::Binding<device::mojom::VRVSyncProvider> binding_; | 229 mojo::Binding<device::mojom::VRVSyncProvider> binding_; |
| 226 device::mojom::VRSubmitFrameClientPtr submit_client_; | 230 device::mojom::VRSubmitFrameClientPtr submit_client_; |
| 227 | 231 |
| 228 base::WeakPtr<VrShell> weak_vr_shell_; | 232 VrBrowserInterface* browser_; |
| 229 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner_; | |
| 230 | 233 |
| 231 UiScene* scene_ = nullptr; | 234 UiScene* scene_ = nullptr; |
| 232 | 235 |
| 233 uint8_t frame_index_ = 0; | 236 uint8_t frame_index_ = 0; |
| 234 // Larger than frame_index_ so it can be initialized out-of-band. | 237 // Larger than frame_index_ so it can be initialized out-of-band. |
| 235 uint16_t last_frame_index_ = -1; | 238 uint16_t last_frame_index_ = -1; |
| 236 | 239 |
| 237 // Attributes for gesture detection while holding app button. | 240 // Attributes for gesture detection while holding app button. |
| 238 gfx::Vector3dF controller_start_direction_; | 241 gfx::Vector3dF controller_start_direction_; |
| 239 | 242 |
| 240 std::unique_ptr<FPSMeter> fps_meter_; | 243 std::unique_ptr<FPSMeter> fps_meter_; |
| 241 | 244 |
| 242 gfx::Point3F pointer_start_; | 245 gfx::Point3F pointer_start_; |
| 243 | 246 |
| 244 base::WeakPtrFactory<VrShellGl> weak_ptr_factory_; | 247 base::WeakPtrFactory<VrShellGl> weak_ptr_factory_; |
| 245 | 248 |
| 246 DISALLOW_COPY_AND_ASSIGN(VrShellGl); | 249 DISALLOW_COPY_AND_ASSIGN(VrShellGl); |
| 247 }; | 250 }; |
| 248 | 251 |
| 249 } // namespace vr_shell | 252 } // namespace vr_shell |
| 250 | 253 |
| 251 #endif // CHROME_BROWSER_ANDROID_VR_SHELL_VR_SHELL_GL_H_ | 254 #endif // CHROME_BROWSER_ANDROID_VR_SHELL_VR_SHELL_GL_H_ |
| OLD | NEW |