// somebar - dwl bar // See LICENSE file for copyright and license details. #include #include #include "shm_buffer.hpp" #include "common.hpp" constexpr int n = 2; ShmBuffer::ShmBuffer(int w, int h, wl_shm_format format) : width(w) , height(h) , stride(w*4) { auto oneSize = stride*h; _totalSize = oneSize * n; auto fd = memfd_create("wl_shm", MFD_CLOEXEC); ftruncate(fd, _totalSize); auto pool = wl_shm_create_pool(shm, fd, _totalSize); auto ptr = reinterpret_cast(mmap(nullptr, _totalSize, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0)); close(fd); for (auto i=0; i