wayland/core: move to new impl (#6268)
* wayland/core/dmabuf: move to new impl it's the final countdown
This commit is contained in:
parent
c31d9ef417
commit
6967a31450
147 changed files with 5388 additions and 2226 deletions
111
src/protocols/core/Shm.hpp
Normal file
111
src/protocols/core/Shm.hpp
Normal file
|
|
@ -0,0 +1,111 @@
|
|||
#pragma once
|
||||
|
||||
/*
|
||||
Implementations for:
|
||||
- wl_shm
|
||||
- wl_shm_pool
|
||||
- wl_buffer with shm
|
||||
*/
|
||||
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
#include <cstdint>
|
||||
#include "../WaylandProtocol.hpp"
|
||||
#include "wayland.hpp"
|
||||
#include "../types/Buffer.hpp"
|
||||
#include "../../helpers/Vector2D.hpp"
|
||||
|
||||
class CWLSHMPoolResource;
|
||||
|
||||
class CSHMPool {
|
||||
public:
|
||||
CSHMPool(int fd, size_t size);
|
||||
~CSHMPool();
|
||||
|
||||
int fd = 0;
|
||||
size_t size = 0;
|
||||
void* data = nullptr;
|
||||
|
||||
void resize(size_t size);
|
||||
};
|
||||
|
||||
class CWLSHMBuffer : public IWLBuffer {
|
||||
public:
|
||||
CWLSHMBuffer(SP<CWLSHMPoolResource> pool, uint32_t id, int32_t offset, const Vector2D& size, int32_t stride, uint32_t fmt);
|
||||
virtual ~CWLSHMBuffer();
|
||||
|
||||
virtual eBufferCapability caps();
|
||||
virtual eBufferType type();
|
||||
virtual void update(const CRegion& damage);
|
||||
virtual SSHMAttrs shm();
|
||||
virtual std::tuple<uint8_t*, uint32_t, size_t> beginDataPtr(uint32_t flags);
|
||||
virtual void endDataPtr();
|
||||
|
||||
bool good();
|
||||
void updateTexture();
|
||||
|
||||
int32_t offset = 0, stride = 0;
|
||||
uint32_t fmt = 0;
|
||||
SP<CSHMPool> pool;
|
||||
|
||||
private:
|
||||
bool success = false;
|
||||
|
||||
struct {
|
||||
CHyprSignalListener bufferResourceDestroy;
|
||||
} listeners;
|
||||
};
|
||||
|
||||
class CWLSHMPoolResource {
|
||||
public:
|
||||
CWLSHMPoolResource(SP<CWlShmPool> resource_, int fd, size_t size);
|
||||
|
||||
bool good();
|
||||
|
||||
SP<CSHMPool> pool;
|
||||
|
||||
WP<CWLSHMPoolResource> self;
|
||||
|
||||
private:
|
||||
SP<CWlShmPool> resource;
|
||||
|
||||
friend class CWLSHMBuffer;
|
||||
};
|
||||
|
||||
class CWLSHMResource {
|
||||
public:
|
||||
CWLSHMResource(SP<CWlShm> resource_);
|
||||
|
||||
bool good();
|
||||
|
||||
private:
|
||||
SP<CWlShm> resource;
|
||||
};
|
||||
|
||||
class CWLSHMProtocol : public IWaylandProtocol {
|
||||
public:
|
||||
CWLSHMProtocol(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(CWLSHMResource* resource);
|
||||
void destroyResource(CWLSHMPoolResource* resource);
|
||||
void destroyResource(CWLSHMBuffer* resource);
|
||||
|
||||
//
|
||||
std::vector<SP<CWLSHMResource>> m_vManagers;
|
||||
std::vector<SP<CWLSHMPoolResource>> m_vPools;
|
||||
std::vector<SP<CWLSHMBuffer>> m_vBuffers;
|
||||
|
||||
//
|
||||
std::vector<uint32_t> shmFormats;
|
||||
|
||||
friend class CWLSHMResource;
|
||||
friend class CWLSHMPoolResource;
|
||||
friend class CWLSHMBuffer;
|
||||
};
|
||||
|
||||
namespace PROTO {
|
||||
inline UP<CWLSHMProtocol> shm;
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue