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

Side by Side Diff: device/vr/android/gvr/gvr_device.h

Issue 2584343002: WIP: working copy-no-compositor path
Patch Set: StatTracker destructor, delete old magic numbers, mojo export 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 DEVICE_VR_ANDROID_GVR_DEVICE_H 5 #ifndef DEVICE_VR_ANDROID_GVR_DEVICE_H
6 #define DEVICE_VR_ANDROID_GVR_DEVICE_H 6 #define DEVICE_VR_ANDROID_GVR_DEVICE_H
7 7
8 #include <list>
9
8 #include "base/macros.h" 10 #include "base/macros.h"
9 #include "device/vr/vr_device.h" 11 #include "device/vr/vr_device.h"
10 12
11 namespace gvr { 13 namespace gvr {
12 class GvrApi; 14 class GvrApi;
13 } // namespace gvr 15 } // namespace gvr
14 16
15 namespace device { 17 namespace device {
16 18
17 class GvrDeviceProvider; 19 class GvrDeviceProvider;
18 class GvrDelegate; 20 class GvrDelegate;
19 21
22 class StatTracker final {
23 public:
24 StatTracker(unsigned int capacity);
25 ~StatTracker();
26 bool hasPrediction();
27 double getPrediction();
28 void add(double value);
29 void clear();
30 private:
31 unsigned int m_capacity;
32 std::list<double> m_items;
33 };
34
20 class GvrDevice : public VRDevice { 35 class GvrDevice : public VRDevice {
21 public: 36 public:
22 GvrDevice(GvrDeviceProvider* provider, GvrDelegate* delegate); 37 GvrDevice(GvrDeviceProvider* provider, GvrDelegate* delegate);
23 ~GvrDevice() override; 38 ~GvrDevice() override;
24 39
25 // VRDevice 40 // VRDevice
26 mojom::VRDisplayInfoPtr GetVRDevice() override; 41 mojom::VRDisplayInfoPtr GetVRDevice() override;
27 mojom::VRPosePtr GetPose() override; 42 mojom::VRPosePtr GetPose() override;
28 void ResetPose() override; 43 void ResetPose() override;
29 44
30 void RequestPresent(const base::Callback<void(bool)>& callback) override; 45 void RequestPresent(const base::Callback<void(bool)>& callback) override;
31 void SetSecureOrigin(bool secure_origin) override; 46 void SetSecureOrigin(bool secure_origin) override;
32 void ExitPresent() override; 47 void ExitPresent() override;
33 48
34 void SubmitFrame(mojom::VRPosePtr pose) override; 49 void SubmitFrame(int32_t surface_handle,
50 mojom::VRPosePtr pose,
51 const mojom::VRDisplay::SubmitFrameCallback& callback) overri de;
52 void OnFrameSubmitted(int32_t surface_handle, uint32_t frame_index, double ela psed);
35 void UpdateLayerBounds(mojom::VRLayerBoundsPtr left_bounds, 53 void UpdateLayerBounds(mojom::VRLayerBoundsPtr left_bounds,
36 mojom::VRLayerBoundsPtr right_bounds) override; 54 mojom::VRLayerBoundsPtr right_bounds) override;
55 void GetSurfaceHandle(int32_t width, int32_t height, const mojom::VRDisplay::G etSurfaceHandleCallback& callback) override;
37 56
38 void SetDelegate(GvrDelegate* delegate); 57 void SetDelegate(GvrDelegate* delegate);
39 58
40 private: 59 private:
41 gvr::GvrApi* GetGvrApi(); 60 gvr::GvrApi* GetGvrApi();
42 61
43 GvrDelegate* delegate_; 62 GvrDelegate* delegate_;
44 GvrDeviceProvider* gvr_provider_; 63 GvrDeviceProvider* gvr_provider_;
45 bool secure_origin_ = false; 64 bool secure_origin_ = false;
65
66 // Map takes ownership of callbacks.
67 std::map<uint32_t, device::mojom::VRDisplay::SubmitFrameCallback> callback_map _;
68 StatTracker last_processing_ms_{5};
69 StatTracker last_render_ms_{5};
70
46 uint32_t pose_index_ = 1; 71 uint32_t pose_index_ = 1;
47 72
48 DISALLOW_COPY_AND_ASSIGN(GvrDevice); 73 DISALLOW_COPY_AND_ASSIGN(GvrDevice);
49 }; 74 };
50 75
51 } // namespace device 76 } // namespace device
52 77
53 #endif // DEVICE_VR_ANDROID_GVR_DEVICE_H 78 #endif // DEVICE_VR_ANDROID_GVR_DEVICE_H
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698