update drwl
This commit is contained in:
parent
4fb17188e8
commit
ca47635f2e
3 changed files with 138 additions and 78 deletions
55
poolbuf.h
55
poolbuf.h
|
@ -1,6 +1,26 @@
|
|||
/*
|
||||
* poolbuf - https://codeberg.org/sewn/drwl
|
||||
* See LICENSE file for copyright and license details.
|
||||
*
|
||||
* Copyright (c) 2023-2024 sewn <sewn@disroot.org>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
@ -56,9 +76,28 @@ create_shm(void)
|
|||
}
|
||||
#endif
|
||||
|
||||
/* Caller must call poolbuf_destroy after finalizing usage */
|
||||
static void
|
||||
poolbuf_destroy(PoolBuf *buf)
|
||||
{
|
||||
wl_buffer_destroy(buf->wl_buf);
|
||||
munmap(buf->data, buf->size);
|
||||
free(buf);
|
||||
}
|
||||
|
||||
static void
|
||||
poolbuf_buffer_release(void *data, struct wl_buffer *wl_buffer)
|
||||
{
|
||||
PoolBuf *buf = data;
|
||||
poolbuf_destroy(buf);
|
||||
}
|
||||
|
||||
static struct wl_buffer_listener poolbuf_buffer_listener = {
|
||||
.release = poolbuf_buffer_release,
|
||||
};
|
||||
|
||||
/* Caller must call poolbuf_destroy after finalizing usage if norelease is passed */
|
||||
static PoolBuf *
|
||||
poolbuf_create(struct wl_shm *shm, int32_t width, int32_t height)
|
||||
poolbuf_create(struct wl_shm *shm, int32_t width, int32_t height, int norelease)
|
||||
{
|
||||
int fd;
|
||||
void *data;
|
||||
|
@ -100,13 +139,7 @@ poolbuf_create(struct wl_shm *shm, int32_t width, int32_t height)
|
|||
buf->stride = stride;
|
||||
buf->size = size;
|
||||
buf->data = data;
|
||||
if (!norelease)
|
||||
wl_buffer_add_listener(wl_buf, &poolbuf_buffer_listener, buf);
|
||||
return buf;
|
||||
}
|
||||
|
||||
static void
|
||||
poolbuf_destroy(PoolBuf *buf)
|
||||
{
|
||||
wl_buffer_destroy(buf->wl_buf);
|
||||
munmap(buf->data, buf->size);
|
||||
free(buf);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue