Hyprland/src/helpers/MonitorFrameScheduler.hpp
vaxerski 78c9e2080c framescheduler: fix edge case crashes
rare UAFs because renderMonitor can call onDisconnect (ugh, that should be changed...)

fixes #11073
2025-08-16 16:52:40 +02:00

40 lines
1.1 KiB
C++

#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;
WP<CMonitorFrameScheduler> m_self;
friend class CMonitor;
};