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

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: rebase 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(const base::TimeDelta& time, GetVSyncCallback callback);
dcheng 2017/01/18 23:58:07 Nit: pass by value. It's also convention to pass c
mthiesse 2017/01/19 01:19:08 Done. The reason I wasn't passing by const ref is
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 bool paused_ = false; 61 bool paused_ = false;
58 base::TimeDelta pending_time_; 62 base::TimeDelta pending_time_;
59 bool pending_vsync_ = false; 63 bool pending_vsync_ = false;
60 GetVSyncCallback callback_; 64 GetVSyncCallback callback_;
61 bool received_frame_ = false; 65 bool received_frame_ = false;
62 uint32_t pose_index_ = 1;
63 mojo::Binding<device::mojom::VRVSyncProvider> binding_; 66 mojo::Binding<device::mojom::VRVSyncProvider> binding_;
64 base::WeakPtrFactory<NonPresentingGvrDelegate> weak_ptr_factory_; 67 base::WeakPtrFactory<NonPresentingGvrDelegate> weak_ptr_factory_;
65 68
66 DISALLOW_COPY_AND_ASSIGN(NonPresentingGvrDelegate); 69 DISALLOW_COPY_AND_ASSIGN(NonPresentingGvrDelegate);
67 }; 70 };
68 71
69 } // namespace vr_shell 72 } // namespace vr_shell
70 73
71 #endif // CHROME_BROWSER_ANDROID_VR_SHELL_NON_PRESENTING_GVR_DELEGATE_H_ 74 #endif // CHROME_BROWSER_ANDROID_VR_SHELL_NON_PRESENTING_GVR_DELEGATE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698