| Index: chrome/browser/android/vr_shell/vr_shell_gl.h
|
| diff --git a/chrome/browser/android/vr_shell/vr_shell_gl.h b/chrome/browser/android/vr_shell/vr_shell_gl.h
|
| index 45ded1a7faf71c38d20b6aca4832c0c236fe9f09..28849d831ed9a0a4e496e5e2b8be9c4bfd2b044a 100644
|
| --- a/chrome/browser/android/vr_shell/vr_shell_gl.h
|
| +++ b/chrome/browser/android/vr_shell/vr_shell_gl.h
|
| @@ -13,6 +13,8 @@
|
| #include "base/memory/weak_ptr.h"
|
| #include "base/single_thread_task_runner.h"
|
| #include "device/vr/android/gvr/gvr_delegate.h"
|
| +#include "device/vr/vr_service.mojom.h"
|
| +#include "mojo/public/cpp/bindings/binding.h"
|
| #include "third_party/gvr-android-sdk/src/libraries/headers/vr/gvr/capi/include/gvr.h"
|
| #include "third_party/gvr-android-sdk/src/libraries/headers/vr/gvr/capi/include/gvr_types.h"
|
| #include "ui/gfx/native_widget_types.h"
|
| @@ -38,12 +40,13 @@ class UiScene;
|
| class VrController;
|
| class VrInputManager;
|
| class VrShell;
|
| +class VrShellDelegate;
|
| class VrShellRenderer;
|
| struct ContentRectangle;
|
|
|
| // This class manages all GLThread owned objects and GL rendering for VrShell.
|
| // It is not threadsafe and must only be used on the GL thread.
|
| -class VrShellGl {
|
| +class VrShellGl : public device::mojom::VRVSyncProvider {
|
| public:
|
| enum class InputTarget {
|
| NONE = 0,
|
| @@ -55,17 +58,16 @@ class VrShellGl {
|
| const base::WeakPtr<VrShell>& weak_vr_shell,
|
| const base::WeakPtr<VrInputManager>& content_input_manager,
|
| const base::WeakPtr<VrInputManager>& ui_input_manager,
|
| + const base::WeakPtr<VrShellDelegate>& delegate_provider,
|
| scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner,
|
| gvr_context* gvr_api,
|
| bool initially_web_vr,
|
| bool reprojected_rendering);
|
| - ~VrShellGl();
|
| + ~VrShellGl() override;
|
|
|
| void Initialize();
|
| void InitializeGl(gfx::AcceleratedWidget window);
|
|
|
| - void DrawFrame();
|
| -
|
| void OnTriggerEvent();
|
| void OnPause();
|
| void OnResume();
|
| @@ -85,9 +87,14 @@ class VrShellGl {
|
|
|
| void UpdateScene(std::unique_ptr<base::ListValue> commands);
|
|
|
| + void UpdateVSyncInterval(long timebase_nanos, double interval_seconds);
|
| +
|
| + void OnRequest(device::mojom::VRVSyncProviderRequest request);
|
| +
|
| private:
|
| void GvrInit(gvr_context* gvr_api);
|
| void InitializeRenderer();
|
| + void DrawFrame();
|
| void DrawVrShell(const gvr::Mat4f& head_pose, gvr::Frame &frame);
|
| void DrawUiView(const gvr::Mat4f* head_pose,
|
| const std::vector<const ContentRectangle*>& elements,
|
| @@ -106,13 +113,17 @@ class VrShellGl {
|
|
|
| void OnUIFrameAvailable();
|
| void OnContentFrameAvailable();
|
| + bool GetPixelEncodedPoseIndexByte(int* pose_index);
|
|
|
| - void UpdateVSyncParameters(const base::TimeTicks timebase,
|
| - const base::TimeDelta interval);
|
| - void ScheduleNextDrawFrame();
|
| + void OnVSync();
|
| +
|
| + // VRVSyncProvider
|
| + void GetVSync(const GetVSyncCallback& callback) override;
|
|
|
| void ForceExitVr();
|
|
|
| + device::mojom::VRPosePtr GetPose();
|
| +
|
| // samplerExternalOES texture data for UI content image.
|
| int ui_texture_id_ = 0;
|
| // samplerExternalOES texture data for main content image.
|
| @@ -161,7 +172,6 @@ class VrShellGl {
|
| // current backlog of poses which is 2-3 frames.
|
| static constexpr int kPoseRingBufferSize = 8;
|
| std::vector<gvr::Mat4f> webvr_head_pose_;
|
| - std::vector<bool> webvr_head_pose_valid_;
|
| int webvr_texture_id_ = 0;
|
| bool web_vr_mode_;
|
| bool ready_to_draw_ = false;
|
| @@ -170,15 +180,25 @@ class VrShellGl {
|
| std::unique_ptr<VrController> controller_;
|
|
|
| scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
|
| - base::CancelableClosure draw_task_;
|
| + base::CancelableClosure vsync_task_;
|
| base::TimeTicks vsync_timebase_;
|
| base::TimeDelta vsync_interval_;
|
|
|
| + base::TimeDelta pending_time_;
|
| + bool pending_vsync_ = false;
|
| + GetVSyncCallback callback_;
|
| + bool received_frame_ = false;
|
| + mojo::Binding<device::mojom::VRVSyncProvider> binding_;
|
| +
|
| base::WeakPtr<VrShell> weak_vr_shell_;
|
| base::WeakPtr<VrInputManager> content_input_manager_;
|
| base::WeakPtr<VrInputManager> ui_input_manager_;
|
| + base::WeakPtr<VrShellDelegate> delegate_provider_;
|
| scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner_;
|
|
|
| + uint32_t pose_index_ = 1;
|
| + int last_pose_ = 0;
|
| +
|
| base::WeakPtrFactory<VrShellGl> weak_ptr_factory_;
|
|
|
| DISALLOW_COPY_AND_ASSIGN(VrShellGl);
|
|
|