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

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

Issue 2612333002: Allow VRDisplay to specify which frame the layer bounds should be updated at. (Closed)
Patch Set: Address comments 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_NON_PRESENTING_GVR_DELEGATE_H_ 5 #ifndef CHROME_BROWSER_ANDROID_VR_SHELL_NON_PRESENTING_GVR_DELEGATE_H_
6 #define CHROME_BROWSER_ANDROID_VR_SHELL_NON_PRESENTING_GVR_DELEGATE_H_ 6 #define CHROME_BROWSER_ANDROID_VR_SHELL_NON_PRESENTING_GVR_DELEGATE_H_
7 7
8 #include <jni.h> 8 #include <jni.h>
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 "device/vr/android/gvr/gvr_delegate.h" 12 #include "device/vr/android/gvr/gvr_delegate.h"
13 #include "device/vr/vr_service.mojom.h" 13 #include "device/vr/vr_service.mojom.h"
14 #include "mojo/public/cpp/bindings/binding.h" 14 #include "mojo/public/cpp/bindings/binding.h"
15 15
16 namespace vr_shell { 16 namespace vr_shell {
17 17
18 // A non presenting delegate for magic window mode. 18 // A non presenting delegate for magic window mode.
19 class NonPresentingGvrDelegate : public device::GvrDelegate, 19 class NonPresentingGvrDelegate : public device::GvrDelegate,
20 public device::mojom::VRVSyncProvider { 20 public device::mojom::VRVSyncProvider {
21 public: 21 public:
22 explicit NonPresentingGvrDelegate(long context); 22 explicit NonPresentingGvrDelegate(long context);
23 23
24 ~NonPresentingGvrDelegate(); 24 ~NonPresentingGvrDelegate();
25 25
26 // GvrDelegate implementation 26 // GvrDelegate implementation
27 void SetWebVRSecureOrigin(bool secure_origin) override {} 27 void SetWebVRSecureOrigin(bool secure_origin) override {}
28 void SubmitWebVRFrame() override {} 28 void SubmitWebVRFrame() override {}
29 void UpdateWebVRTextureBounds(const gvr::Rectf& left_bounds, 29 void UpdateWebVRTextureBounds(int16_t frame_index,
30 const gvr::Rectf& left_bounds,
30 const gvr::Rectf& right_bounds) override {} 31 const gvr::Rectf& right_bounds) override {}
31 void SetWebVRRenderSurfaceSize(int width, int height) override {} 32 void SetWebVRRenderSurfaceSize(int width, int height) override {}
32 gvr::Sizei GetWebVRCompositorSurfaceSize() override { 33 gvr::Sizei GetWebVRCompositorSurfaceSize() override {
33 return device::kInvalidRenderTargetSize; } 34 return device::kInvalidRenderTargetSize;
35 }
34 gvr::GvrApi* gvr_api() override { return gvr_api_.get(); } 36 gvr::GvrApi* gvr_api() override { return gvr_api_.get(); }
35 void OnVRVsyncProviderRequest( 37 void OnVRVsyncProviderRequest(
36 device::mojom::VRVSyncProviderRequest request) override; 38 device::mojom::VRVSyncProviderRequest request) override;
37 void UpdateVSyncInterval(long timebase_nanos, 39 void UpdateVSyncInterval(long timebase_nanos,
38 double interval_seconds) override; 40 double interval_seconds) override;
39 41
40 void Pause(); 42 void Pause();
41 void Resume(); 43 void Resume();
42 device::mojom::VRVSyncProviderRequest OnSwitchToPresentingDelegate(); 44 device::mojom::VRVSyncProviderRequest OnSwitchToPresentingDelegate();
43 45
44 private: 46 private:
45 void StopVSyncLoop(); 47 void StopVSyncLoop();
46 void StartVSyncLoop(); 48 void StartVSyncLoop();
47 void OnVSync(); 49 void OnVSync();
48 void GetVSync(const GetVSyncCallback& callback); 50 void SendVSync(base::TimeDelta time, const GetVSyncCallback& callback);
49 device::mojom::VRPosePtr GetPose(); 51
52 // VRVSyncProvider implementation
53 void GetVSync(const GetVSyncCallback& callback) override;
50 54
51 std::unique_ptr<gvr::GvrApi> gvr_api_; 55 std::unique_ptr<gvr::GvrApi> gvr_api_;
52 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; 56 scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
53 base::CancelableClosure vsync_task_; 57 base::CancelableClosure vsync_task_;
54 base::TimeTicks vsync_timebase_; 58 base::TimeTicks vsync_timebase_;
55 base::TimeDelta vsync_interval_; 59 base::TimeDelta vsync_interval_;
56 60
57 // Whether the vsync loop is paused, but not stopped. 61 // Whether the vsync loop is paused, but not stopped.
58 bool vsync_paused_ = false; 62 bool vsync_paused_ = false;
59 base::TimeDelta pending_time_; 63 base::TimeDelta pending_time_;
60 bool pending_vsync_ = false; 64 bool pending_vsync_ = false;
61 GetVSyncCallback callback_; 65 GetVSyncCallback callback_;
62 bool received_frame_ = false; 66 bool received_frame_ = false;
63 uint32_t pose_index_ = 1;
64 mojo::Binding<device::mojom::VRVSyncProvider> binding_; 67 mojo::Binding<device::mojom::VRVSyncProvider> binding_;
65 base::WeakPtrFactory<NonPresentingGvrDelegate> weak_ptr_factory_; 68 base::WeakPtrFactory<NonPresentingGvrDelegate> weak_ptr_factory_;
66 69
67 DISALLOW_COPY_AND_ASSIGN(NonPresentingGvrDelegate); 70 DISALLOW_COPY_AND_ASSIGN(NonPresentingGvrDelegate);
68 }; 71 };
69 72
70 } // namespace vr_shell 73 } // namespace vr_shell
71 74
72 #endif // CHROME_BROWSER_ANDROID_VR_SHELL_NON_PRESENTING_GVR_DELEGATE_H_ 75 #endif // CHROME_BROWSER_ANDROID_VR_SHELL_NON_PRESENTING_GVR_DELEGATE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698