From a7e23d2f1e27c241c2a72262d14d5dde9ea2e860 Mon Sep 17 00:00:00 2001 From: Vaxry Date: Fri, 10 May 2024 02:27:54 +0100 Subject: presentation-time: move to new impl --- src/protocols/PresentationTime.hpp | 73 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 src/protocols/PresentationTime.hpp (limited to 'src/protocols/PresentationTime.hpp') diff --git a/src/protocols/PresentationTime.hpp b/src/protocols/PresentationTime.hpp new file mode 100644 index 00000000..2df1c781 --- /dev/null +++ b/src/protocols/PresentationTime.hpp @@ -0,0 +1,73 @@ +#pragma once + +#include +#include +#include +#include "WaylandProtocol.hpp" +#include "presentation-time.hpp" + +class CMonitor; + +class CQueuedPresentationData { + public: + CQueuedPresentationData(wlr_surface* surf); + + void setPresentationType(bool zeroCopy); + void attachMonitor(CMonitor* pMonitor); + + void presented(); + void discarded(); + + private: + bool wasPresented = false; + bool zeroCopy = false; + CMonitor* pMonitor = nullptr; + wlr_surface* surface = nullptr; // READ-ONLY + + DYNLISTENER(destroySurface); + + friend class CPresentationFeedback; + friend class CPresentationProtocol; +}; + +class CPresentationFeedback { + public: + CPresentationFeedback(SP resource_, wlr_surface* surf); + + bool good(); + + void sendQueued(SP data, timespec* when, uint32_t untilRefreshNs, uint64_t seq, uint32_t reportedFlags); + + private: + SP resource; + wlr_surface* surface = nullptr; // READ-ONLY + bool done = false; + + 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); + + void onPresented(CMonitor* pMonitor, timespec* when, uint32_t untilRefreshNs, uint64_t seq, uint32_t reportedFlags); + void queueData(SP data); + + private: + void onManagerResourceDestroy(wl_resource* res); + void destroyResource(CPresentationFeedback* feedback); + void onGetFeedback(CWpPresentation* pMgr, wl_resource* surf, uint32_t id); + + // + std::vector> m_vManagers; + std::vector> m_vFeedbacks; + std::vector> m_vQueue; + + friend class CPresentationFeedback; +}; + +namespace PROTO { + inline UP presentation; +}; -- cgit v1.2.3