OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CHROME_BROWSER_ANDROID_VR_SHELL_NON_PRESENTING_GVR_DELEGATE_H_ |
| 6 #define CHROME_BROWSER_ANDROID_VR_SHELL_NON_PRESENTING_GVR_DELEGATE_H_ |
| 7 |
| 8 #include <jni.h> |
| 9 |
| 10 #include "base/cancelable_callback.h" |
| 11 #include "base/macros.h" |
| 12 #include "device/vr/android/gvr/gvr_delegate.h" |
| 13 #include "device/vr/vr_service.mojom.h" |
| 14 #include "mojo/public/cpp/bindings/binding.h" |
| 15 |
| 16 namespace vr_shell { |
| 17 |
| 18 // A non presenting delegate for magic window mode. |
| 19 class NonPresentingGvrDelegate : public device::GvrDelegate, |
| 20 public device::mojom::VRVSyncProvider { |
| 21 public: |
| 22 explicit NonPresentingGvrDelegate(long context); |
| 23 |
| 24 ~NonPresentingGvrDelegate(); |
| 25 |
| 26 // GvrDelegate implementation |
| 27 void SetWebVRSecureOrigin(bool secure_origin) override {} |
| 28 void SubmitWebVRFrame() override {} |
| 29 void UpdateWebVRTextureBounds(const gvr::Rectf& left_bounds, |
| 30 const gvr::Rectf& right_bounds) override {} |
| 31 void SetWebVRRenderSurfaceSize(int width, int height) override {} |
| 32 gvr::Sizei GetWebVRCompositorSurfaceSize() override { |
| 33 return device::kInvalidRenderTargetSize; } |
| 34 gvr::GvrApi* gvr_api() override { return gvr_api_.get(); } |
| 35 void OnVRVsyncProviderRequest( |
| 36 device::mojom::VRVSyncProviderRequest request) override; |
| 37 |
| 38 void Pause(); |
| 39 |
| 40 void Resume(); |
| 41 |
| 42 void StopVSyncLoop(); |
| 43 |
| 44 void StartVSyncLoop(); |
| 45 |
| 46 void OnVSync(); |
| 47 |
| 48 void GetVSync(const GetVSyncCallback& callback); |
| 49 |
| 50 void UpdateVSyncInterval(long timebase_nanos, |
| 51 double interval_seconds) override; |
| 52 |
| 53 device::mojom::VRPosePtr GetPose(); |
| 54 |
| 55 private: |
| 56 std::unique_ptr<gvr::GvrApi> gvr_api_; |
| 57 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; |
| 58 base::CancelableClosure vsync_task_; |
| 59 base::TimeTicks vsync_timebase_; |
| 60 base::TimeDelta vsync_interval_; |
| 61 |
| 62 bool paused_ = false; |
| 63 double pending_time_ = 0; |
| 64 bool pending_vsync_ = false; |
| 65 GetVSyncCallback callback_; |
| 66 bool received_frame_ = false; |
| 67 uint32_t pose_index_ = 1; |
| 68 mojo::Binding<device::mojom::VRVSyncProvider> binding_; |
| 69 base::WeakPtrFactory<NonPresentingGvrDelegate> weak_ptr_factory_; |
| 70 |
| 71 DISALLOW_COPY_AND_ASSIGN(NonPresentingGvrDelegate); |
| 72 }; |
| 73 |
| 74 } // namespace vr_shell |
| 75 |
| 76 #endif // CHROME_BROWSER_ANDROID_VR_SHELL_NON_PRESENTING_GVR_DELEGATE_H_ |
OLD | NEW |