#pragma once #include #include #include #include "WaylandProtocol.hpp" #include "wayland.hpp" #include "linux-dmabuf-v1.hpp" #include "../helpers/signal/Signal.hpp" #include "../helpers/Format.hpp" #include "../helpers/Monitor.hpp" #include class CDMABuffer; class CWLSurfaceResource; class CLinuxDMABuffer { public: CLinuxDMABuffer(uint32_t id, wl_client* client, Aquamarine::SDMABUFAttrs attrs); ~CLinuxDMABuffer(); bool good(); private: SP buffer; struct { CHyprSignalListener bufferResourceDestroy; } listeners; friend class CLinuxDMABBUFParamsResource; }; #pragma pack(push, 1) struct SDMABUFFormatTableEntry { uint32_t fmt = 0; char pad[4]; uint64_t modifier = 0; }; #pragma pack(pop) struct SDMABUFTranche { dev_t device = 0; uint32_t flags = 0; std::vector formats; std::vector indicies; }; class CDMABUFFormatTable { public: CDMABUFFormatTable(SDMABUFTranche rendererTranche, std::vector, SDMABUFTranche>> tranches); ~CDMABUFFormatTable(); int tableFD = -1; size_t tableSize = 0; SDMABUFTranche rendererTranche; std::vector, SDMABUFTranche>> monitorTranches; }; class CLinuxDMABBUFParamsResource { public: CLinuxDMABBUFParamsResource(SP resource_); ~CLinuxDMABBUFParamsResource(); bool good(); void create(uint32_t id); // 0 means not immed SP attrs; WP createdBuffer; bool used = false; private: SP resource; bool verify(); bool commence(); }; class CLinuxDMABUFFeedbackResource { public: CLinuxDMABUFFeedbackResource(SP resource_, SP surface_); ~CLinuxDMABUFFeedbackResource(); bool good(); void sendDefaultFeedback(); void sendTranche(SDMABUFTranche& tranche); SP surface; // optional, for surface feedbacks private: SP resource; bool lastFeedbackWasScanout = false; friend class CLinuxDMABufV1Protocol; }; class CLinuxDMABUFResource { public: CLinuxDMABUFResource(SP resource_); bool good(); void sendMods(); private: SP resource; }; class CLinuxDMABufV1Protocol : public IWaylandProtocol { public: CLinuxDMABufV1Protocol(const wl_interface* iface, const int& ver, const std::string& name); ~CLinuxDMABufV1Protocol(); virtual void bindManager(wl_client* client, void* data, uint32_t ver, uint32_t id); void updateScanoutTranche(SP surface, SP pMonitor); private: void destroyResource(CLinuxDMABUFResource* resource); void destroyResource(CLinuxDMABUFFeedbackResource* resource); void destroyResource(CLinuxDMABBUFParamsResource* resource); void destroyResource(CLinuxDMABuffer* resource); void resetFormatTable(); // std::vector> m_vManagers; std::vector> m_vFeedbacks; std::vector> m_vParams; std::vector> m_vBuffers; UP formatTable; dev_t mainDevice; int mainDeviceFD = -1; friend class CLinuxDMABUFResource; friend class CLinuxDMABUFFeedbackResource; friend class CLinuxDMABBUFParamsResource; friend class CLinuxDMABuffer; }; namespace PROTO { inline UP linuxDma; };