aboutsummaryrefslogtreecommitdiff
path: root/render
diff options
context:
space:
mode:
authorSimon Ser <contact@emersion.fr>2021-04-26 19:48:35 +0200
committerSimon Ser <contact@emersion.fr>2021-04-27 20:36:03 +0200
commit24fde77c620f7fceb62da17163ab71ea3921d373 (patch)
treebf23557f3c1a2cb3183a8bb42114e44e3f467ca7 /render
parentccbce0f0a6cf1a058b668e19b37b0aa39d81c344 (diff)
buffer: add format param to get_data_ptr
Allow wlr_buffer_impl.get_data_ptr to return a format. This allows the Pixman renderer to not care about get_dmabuf/get_shm, and only care about get_data_ptr. This will also help with [1], because client wl_shm buffers can't implement get_shm. [1]: https://github.com/swaywm/wlroots/pull/2892 References: https://github.com/swaywm/wlroots/issues/2864
Diffstat (limited to 'render')
-rw-r--r--render/pixman/renderer.c18
-rw-r--r--render/shm_allocator.c3
2 files changed, 6 insertions, 15 deletions
diff --git a/render/pixman/renderer.c b/render/pixman/renderer.c
index 3aa32f15..e50b774f 100644
--- a/render/pixman/renderer.c
+++ b/render/pixman/renderer.c
@@ -83,26 +83,16 @@ static struct wlr_pixman_buffer *create_buffer(
buffer->buffer = wlr_buffer;
buffer->renderer = renderer;
- uint32_t drm_format;
- struct wlr_dmabuf_attributes dmabuf = {0};
- struct wlr_shm_attributes shm = {0};
- if (wlr_buffer_get_dmabuf(wlr_buffer, &dmabuf)) {
- drm_format = dmabuf.format;
- } else if (wlr_buffer_get_shm(wlr_buffer, &shm)) {
- drm_format = shm.format;
- } else {
- goto error_buffer;
- }
-
- uint32_t format = get_pixman_format_from_drm(drm_format);
-
void *data = NULL;
+ uint32_t drm_format;
size_t stride;
- if (!buffer_get_data_ptr(wlr_buffer, &data, &stride)) {
+ if (!buffer_get_data_ptr(wlr_buffer, &data, &drm_format, &stride)) {
wlr_log(WLR_ERROR, "Failed to get buffer data");
goto error_buffer;
}
+ uint32_t format = get_pixman_format_from_drm(drm_format);
+
buffer->image = pixman_image_create_bits(format, wlr_buffer->width,
wlr_buffer->height, data, stride);
if (!buffer->image) {
diff --git a/render/shm_allocator.c b/render/shm_allocator.c
index 3bfb62e5..8da7bea6 100644
--- a/render/shm_allocator.c
+++ b/render/shm_allocator.c
@@ -31,9 +31,10 @@ static bool buffer_get_shm(struct wlr_buffer *wlr_buffer,
}
static bool buffer_get_data_ptr(struct wlr_buffer *wlr_buffer, void **data,
- size_t *stride) {
+ uint32_t *format, size_t *stride) {
struct wlr_shm_buffer *buffer = shm_buffer_from_buffer(wlr_buffer);
*data = buffer->data;
+ *format = buffer->shm.format;
*stride = buffer->shm.stride;
return true;
}