Hyprland/src/protocols/PresentationTime.hpp

77 lines
2.1 KiB
C++
Raw Normal View History

2024-05-10 03:27:54 +02:00
#pragma once
#include <memory>
#include <vector>
#include <cstdint>
#include "WaylandProtocol.hpp"
#include "presentation-time.hpp"
class CMonitor;
class CWLSurfaceResource;
2024-05-10 03:27:54 +02:00
class CQueuedPresentationData {
public:
CQueuedPresentationData(SP<CWLSurfaceResource> surf);
2024-05-10 03:27:54 +02:00
void setPresentationType(bool zeroCopy);
2024-08-30 15:50:25 +02:00
void attachMonitor(SP<CMonitor> pMonitor);
2024-05-10 03:27:54 +02:00
void presented();
void discarded();
2024-08-30 15:50:25 +02:00
bool done = false;
2024-05-10 03:27:54 +02:00
private:
bool wasPresented = false;
bool zeroCopy = false;
2024-08-30 15:50:25 +02:00
WP<CMonitor> pMonitor;
WP<CWLSurfaceResource> surface;
2024-05-10 03:27:54 +02:00
DYNLISTENER(destroySurface);
friend class CPresentationFeedback;
friend class CPresentationProtocol;
};
class CPresentationFeedback {
public:
CPresentationFeedback(SP<CWpPresentationFeedback> resource_, SP<CWLSurfaceResource> surf);
2024-05-10 03:27:54 +02:00
bool good();
void sendQueued(SP<CQueuedPresentationData> data, timespec* when, uint32_t untilRefreshNs, uint64_t seq, uint32_t reportedFlags);
private:
SP<CWpPresentationFeedback> resource;
WP<CWLSurfaceResource> surface;
bool done = false;
2024-05-10 03:27:54 +02:00
friend class CPresentationProtocol;
};
class CPresentationProtocol : public IWaylandProtocol {
public:
CPresentationProtocol(const wl_interface* iface, const int& ver, const std::string& name);
virtual void bindManager(wl_client* client, void* data, uint32_t ver, uint32_t id);
2024-08-30 15:50:25 +02:00
void onPresented(SP<CMonitor> pMonitor, timespec* when, uint32_t untilRefreshNs, uint64_t seq, uint32_t reportedFlags);
2024-05-10 03:27:54 +02:00
void queueData(SP<CQueuedPresentationData> data);
private:
void onManagerResourceDestroy(wl_resource* res);
void destroyResource(CPresentationFeedback* feedback);
void onGetFeedback(CWpPresentation* pMgr, wl_resource* surf, uint32_t id);
//
std::vector<UP<CWpPresentation>> m_vManagers;
std::vector<SP<CPresentationFeedback>> m_vFeedbacks;
std::vector<SP<CQueuedPresentationData>> m_vQueue;
friend class CPresentationFeedback;
};
namespace PROTO {
inline UP<CPresentationProtocol> presentation;
};