Overte C++ Documentation
RefreshRateController.h
1 //
2 // RefreshRateController.h
3 // libraries/display-pluging/src/display-plugin
4 //
5 // Created by Dante Ruiz on 2019-04-15.
6 // Copyright 2019 High Fidelity, Inc.
7 //
8 // Distributed under the Apache License, Version 2.0.
9 // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
10 //
11 
12 #ifndef hifi_RefreshRateController_h
13 #define hifi_RefreshRateController_h
14 
15 #include <DependencyManager.h>
16 
17 #include <chrono>
18 #include <atomic>
19 
20 class QThread;
21 
22 class RefreshRateController {
23 public:
24  RefreshRateController() = default;
25  ~RefreshRateController() = default;
26 
27  void setRefreshRateLimitPeriod(int refreshRateLimit);
28  int getRefreshRateLimitPeriod() const;
29 
30  void clockStartTime() { _startTime = std::chrono::high_resolution_clock::now(); }
31  void clockEndTime() { _endTime = std::chrono::high_resolution_clock::now(); }
32  std::chrono::nanoseconds sleepThreadIfNeeded(QThread* thread, bool isHmd);
33 private:
34  std::chrono::time_point<std::chrono::high_resolution_clock> _startTime { std::chrono::high_resolution_clock::now() };
35  std::chrono::time_point<std::chrono::high_resolution_clock> _endTime { std::chrono::high_resolution_clock::now() };
36  std::atomic<int64_t> _refreshRateLimitPeriod { 50 };
37 
38 };
39 
40 #endif