diff options
| author | Daniel Eklöf <daniel@ekloef.se> | 2024-02-21 15:29:10 +0000 |
|---|---|---|
| committer | Daniel Eklöf <daniel@ekloef.se> | 2024-02-21 15:29:10 +0000 |
| commit | 67f97cbca1d9c1396537d0f04afb5a336ac46855 (patch) | |
| tree | aeb33443e200da5029a31759d02ddca7f07ee0e5 /shm.c | |
| parent | input: improved debug logging of key press/release (diff) | |
shm: use XRGB surfaces when we know we wont be using transparency
Diffstat (limited to 'shm.c')
| -rw-r--r-- | shm.c | 21 |
1 files changed, 13 insertions, 8 deletions
@@ -82,6 +82,7 @@ struct buffer_private { struct buffer_pool *pool; off_t offset; /* Offset into memfd where data begins */ size_t size; + bool with_alpha; bool scrollable; }; @@ -261,7 +262,7 @@ instantiate_offset(struct buffer_private *buf, off_t new_offset) wl_buf = wl_shm_pool_create_buffer( pool->wl_pool, new_offset, buf->public.width, buf->public.height, buf->public.stride, - WL_SHM_FORMAT_ARGB8888); + buf->with_alpha ? WL_SHM_FORMAT_ARGB8888 : WL_SHM_FORMAT_XRGB8888); if (wl_buf == NULL) { LOG_ERR("failed to create SHM buffer"); @@ -271,7 +272,8 @@ instantiate_offset(struct buffer_private *buf, off_t new_offset) /* One pixman image for each worker thread (do we really need multiple?) */ for (size_t i = 0; i < buf->public.pix_instances; i++) { pix[i] = pixman_image_create_bits_no_clear( - PIXMAN_a8r8g8b8, buf->public.width, buf->public.height, + buf->with_alpha ? PIXMAN_a8r8g8b8 : PIXMAN_x8r8g8b8, + buf->public.width, buf->public.height, (uint32_t *)mmapped, buf->public.stride); if (pix[i] == NULL) { LOG_ERR("failed to create pixman image"); @@ -304,7 +306,8 @@ err: static void NOINLINE get_new_buffers(struct buffer_chain *chain, size_t count, int widths[static count], int heights[static count], - struct buffer *bufs[static count], bool immediate_purge) + struct buffer *bufs[static count], bool with_alpha, + bool immediate_purge) { xassert(count == 1 || !chain->scrollable); /* @@ -322,7 +325,8 @@ get_new_buffers(struct buffer_chain *chain, size_t count, size_t total_size = 0; for (size_t i = 0; i < count; i++) { - stride[i] = stride_for_format_and_width(PIXMAN_a8r8g8b8, widths[i]); + stride[i] = stride_for_format_and_width( + with_alpha ? PIXMAN_a8r8g8b8 : PIXMAN_x8r8g8b8, widths[i]); sizes[i] = stride[i] * heights[i]; total_size += sizes[i]; } @@ -473,6 +477,7 @@ get_new_buffers(struct buffer_chain *chain, size_t count, .chain = chain, .ref_count = immediate_purge ? 0 : 1, .busy = true, + .with_alpha = with_alpha, .pool = pool, .offset = 0, .size = sizes[i], @@ -542,13 +547,13 @@ shm_did_not_use_buf(struct buffer *_buf) void shm_get_many(struct buffer_chain *chain, size_t count, int widths[static count], int heights[static count], - struct buffer *bufs[static count]) + struct buffer *bufs[static count], bool with_alpha) { - get_new_buffers(chain, count, widths, heights, bufs, true); + get_new_buffers(chain, count, widths, heights, bufs, with_alpha, true); } struct buffer * -shm_get_buffer(struct buffer_chain *chain, int width, int height) +shm_get_buffer(struct buffer_chain *chain, int width, int height, bool with_alpha) { LOG_DBG( "chain=%p: looking for a reusable %dx%d buffer " @@ -610,7 +615,7 @@ shm_get_buffer(struct buffer_chain *chain, int width, int height) } struct buffer *ret; - get_new_buffers(chain, 1, &width, &height, &ret, false); + get_new_buffers(chain, 1, &width, &height, &ret, with_alpha, false); return ret; } |
