diff options
| author | Vaxry <vaxry@vaxry.net> | 2024-05-10 02:27:54 +0100 |
|---|---|---|
| committer | Vaxry <vaxry@vaxry.net> | 2024-05-10 02:38:54 +0100 |
| commit | a7e23d2f1e27c241c2a72262d14d5dde9ea2e860 (patch) | |
| tree | 72e9a6b77208f14788cd1387eb147a9475bb3229 /src/protocols/PresentationTime.hpp | |
| parent | 1753059b07be52cf78fa2676c4c71d2edb560199 (diff) | |
presentation-time: move to new impl
Diffstat (limited to 'src/protocols/PresentationTime.hpp')
| -rw-r--r-- | src/protocols/PresentationTime.hpp | 73 |
1 files changed, 73 insertions, 0 deletions
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 <memory> +#include <vector> +#include <cstdint> +#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<CWpPresentationFeedback> resource_, wlr_surface* surf); + + bool good(); + + void sendQueued(SP<CQueuedPresentationData> data, timespec* when, uint32_t untilRefreshNs, uint64_t seq, uint32_t reportedFlags); + + private: + SP<CWpPresentationFeedback> 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<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; +}; |
