diff options
| author | Vaxry <vaxry@vaxry.net> | 2024-09-30 00:57:51 +0100 |
|---|---|---|
| committer | Vaxry <vaxry@vaxry.net> | 2024-09-30 00:58:16 +0100 |
| commit | 488efab63654a643d76df4997cd932d6fddd8faf (patch) | |
| tree | 4e330456e26e6ba5e208424f292fc1d03e89f10b /src/protocols/SinglePixel.hpp | |
| parent | 6649255d54f45a7e2fedd9b4be85fe5d11229c04 (diff) | |
single-pixel-buffer: new protocol impl
fixes #6624
Diffstat (limited to 'src/protocols/SinglePixel.hpp')
| -rw-r--r-- | src/protocols/SinglePixel.hpp | 79 |
1 files changed, 79 insertions, 0 deletions
diff --git a/src/protocols/SinglePixel.hpp b/src/protocols/SinglePixel.hpp new file mode 100644 index 00000000..ab74825c --- /dev/null +++ b/src/protocols/SinglePixel.hpp @@ -0,0 +1,79 @@ +#pragma once + +#include <memory> +#include <vector> +#include <cstdint> +#include "WaylandProtocol.hpp" +#include "single-pixel-buffer-v1.hpp" +#include "types/Buffer.hpp" + +class CSinglePixelBuffer : public IHLBuffer { + public: + CSinglePixelBuffer(uint32_t id, wl_client* client, CColor col); + virtual ~CSinglePixelBuffer(); + + virtual Aquamarine::eBufferCapability caps(); + virtual Aquamarine::eBufferType type(); + virtual bool isSynchronous(); + virtual void update(const CRegion& damage); + virtual Aquamarine::SDMABUFAttrs dmabuf(); + virtual std::tuple<uint8_t*, uint32_t, size_t> beginDataPtr(uint32_t flags); + virtual void endDataPtr(); + // + bool good(); + bool success = false; + + private: + uint32_t color = 0x00000000; + + struct { + CHyprSignalListener resourceDestroy; + } listeners; +}; + +class CSinglePixelBufferResource { + public: + CSinglePixelBufferResource(uint32_t id, wl_client* client, CColor color); + ~CSinglePixelBufferResource(); + + bool good(); + + private: + SP<CSinglePixelBuffer> buffer; + + struct { + CHyprSignalListener bufferResourceDestroy; + } listeners; +}; + +class CSinglePixelBufferManagerResource { + public: + CSinglePixelBufferManagerResource(SP<CWpSinglePixelBufferManagerV1> resource_); + + bool good(); + + private: + SP<CWpSinglePixelBufferManagerV1> resource; +}; + +class CSinglePixelProtocol : public IWaylandProtocol { + public: + CSinglePixelProtocol(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); + + private: + void destroyResource(CSinglePixelBufferManagerResource* resource); + void destroyResource(CSinglePixelBufferResource* resource); + + // + std::vector<SP<CSinglePixelBufferManagerResource>> m_vManagers; + std::vector<SP<CSinglePixelBufferResource>> m_vBuffers; + + friend class CSinglePixelBufferManagerResource; + friend class CSinglePixelBufferResource; +}; + +namespace PROTO { + inline UP<CSinglePixelProtocol> singlePixel; +};
\ No newline at end of file |
