diff options
| author | tslil <tslil@posteo.de> | 2026-04-04 17:44:21 +0100 |
|---|---|---|
| committer | tslil <tslil@posteo.de> | 2026-04-04 17:47:21 +0100 |
| commit | 5413fb67d5454666cd4606ac51e8f8d1ae31aa6e (patch) | |
| tree | effd7869b631e1e1a455b65eea1a1f12263b4bba /somebar/src/shm_buffer.hpp | |
| parent | 0c860a57966d4c0f4ef817b9c7f378de4623a236 (diff) | |
cleanup
Diffstat (limited to 'somebar/src/shm_buffer.hpp')
| -rw-r--r-- | somebar/src/shm_buffer.hpp | 45 |
1 files changed, 0 insertions, 45 deletions
diff --git a/somebar/src/shm_buffer.hpp b/somebar/src/shm_buffer.hpp deleted file mode 100644 index f6927dd..0000000 --- a/somebar/src/shm_buffer.hpp +++ /dev/null @@ -1,45 +0,0 @@ -// somebar - dwl bar -// See LICENSE file for copyright and license details. - -#pragma once -#include <array> -#include <sys/mman.h> -#include <wayland-client.h> -#include "common.hpp" - -class MemoryMapping { - void* _ptr {nullptr}; - size_t _size {0}; -public: - MemoryMapping() { } - explicit MemoryMapping(void* ptr, size_t size) : _ptr(ptr), _size(size) { } - MemoryMapping(const MemoryMapping&) = delete; - MemoryMapping(MemoryMapping&& other) { swap(other); } - MemoryMapping& operator=(const MemoryMapping& other) = delete; - MemoryMapping& operator=(MemoryMapping&& other) { swap(other); return *this; } - ~MemoryMapping() { if (_ptr) munmap(_ptr, _size); } - void swap(MemoryMapping &other) { - using std::swap; - swap(_ptr, other._ptr); - swap(_size, other._size); - } -}; - -// double buffered shm -// format is must be 32-bit -class ShmBuffer { - struct Buf { - uint8_t* data {nullptr}; - wl_unique_ptr<wl_buffer> buffer; - }; - std::array<Buf, 2> _buffers; - int _current {0}; - MemoryMapping _mapping; -public: - const uint32_t width, height, stride; - - explicit ShmBuffer(int width, int height, wl_shm_format format); - uint8_t* data(); - wl_buffer* buffer(); - void flip(); -}; |
