#pragma once

#include "wayland-client.h"

#include "SharedMemory.h"

#include <memory>

class WaylandBuffer
{
public:

    WaylandBuffer() = default;
    void initializeSharedBuffer(int size);

    uint8_t* getPoolData();
    wl_buffer* getWorkingBuffer();

    void setUpPool(int size, int width, int height, int stride);
    void setSharedMemory(wl_shm* shared_memory);

    void tearDownPool(int size);

private:
    wl_shm* mWlSharedMemory{nullptr};

    std::unique_ptr<SharedMemory> mSharedMemory;
    uint8_t* mPoolData{nullptr};
    wl_shm_pool* mPool{nullptr};

    wl_buffer* mWorkingBuffer{nullptr};
    wl_buffer_listener mBufferListener;
};
