summaryrefslogtreecommitdiff
path: root/src/helpers/MonitorFrameScheduler.hpp
blob: e6eab9c911d3fa6a5369cd5458802f42ac108930 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#pragma once

#include "Monitor.hpp"

#include <chrono>

class CEGLSync;

class CMonitorFrameScheduler {
  public:
    using hrc = std::chrono::high_resolution_clock;

    CMonitorFrameScheduler(PHLMONITOR m);

    CMonitorFrameScheduler(const CMonitorFrameScheduler&)            = delete;
    CMonitorFrameScheduler(CMonitorFrameScheduler&&)                 = delete;
    CMonitorFrameScheduler& operator=(const CMonitorFrameScheduler&) = delete;
    CMonitorFrameScheduler& operator=(CMonitorFrameScheduler&&)      = delete;

    void                    onSyncFired();
    void                    onPresented();
    void                    onFrame();

  private:
    bool            canRender();
    void            onFinishRender();
    bool            newSchedulingEnabled();

    bool            m_renderAtFrame = true;
    bool            m_pendingThird  = false;
    hrc::time_point m_lastRenderBegun;

    PHLMONITORREF   m_monitor;

    UP<CEGLSync>    m_sync;
};