mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-02-05 04:06:08 -05:00
shm/render: there's no need to have one pixman image per thread
This commit is contained in:
parent
f45e5c6aef
commit
72d3cbca26
3 changed files with 10 additions and 29 deletions
4
render.c
4
render.c
|
|
@ -367,7 +367,7 @@ render_worker_thread(void *_ctx)
|
|||
switch (row_no) {
|
||||
default:
|
||||
assert(buf != NULL);
|
||||
render_row(term, buf->pix[my_id], grid_row_in_view(term->grid, row_no), row_no);
|
||||
render_row(term, buf->pix, grid_row_in_view(term->grid, row_no), row_no);
|
||||
break;
|
||||
|
||||
case -1:
|
||||
|
|
@ -405,7 +405,7 @@ grid_render(struct terminal *term)
|
|||
assert(term->height > 0);
|
||||
|
||||
struct buffer *buf = shm_get_buffer(term->wl.shm, term->width, term->height, 1 + term->render.workers.count);
|
||||
pixman_image_t *pix = buf->pix[0];
|
||||
pixman_image_t *pix = buf->pix;
|
||||
|
||||
bool all_clean = tll_length(term->grid->scroll_damage) == 0;
|
||||
|
||||
|
|
|
|||
31
shm.c
31
shm.c
|
|
@ -60,7 +60,7 @@ shm_get_buffer(struct wl_shm *shm, int width, int height, size_t copies)
|
|||
struct wl_shm_pool *pool = NULL;
|
||||
struct wl_buffer *buf = NULL;
|
||||
|
||||
pixman_image_t **pix = NULL;
|
||||
pixman_image_t *pix = NULL;
|
||||
|
||||
/* Backing memory for SHM */
|
||||
pool_fd = memfd_create("f00sel-wayland-shm-buffer-pool", MFD_CLOEXEC);
|
||||
|
|
@ -105,16 +105,8 @@ shm_get_buffer(struct wl_shm *shm, int width, int height, size_t copies)
|
|||
close(pool_fd); pool_fd = -1;
|
||||
|
||||
/* One pixman image for each worker thread (do we really need multiple?) */
|
||||
pix = calloc(copies, sizeof(pix[0]));
|
||||
for (size_t i = 0; i < copies; i++) {
|
||||
pix[i] = pixman_image_create_bits_no_clear(
|
||||
PIXMAN_a8r8g8b8, width, height, (uint32_t *)mmapped, stride);
|
||||
|
||||
if (pix[i] == NULL) {
|
||||
LOG_ERR("failed to create pixman image");
|
||||
goto err;
|
||||
}
|
||||
}
|
||||
pix = pixman_image_create_bits_no_clear(
|
||||
PIXMAN_a8r8g8b8, width, height, (uint32_t *)mmapped, stride);
|
||||
|
||||
/* Push to list of available buffers, but marked as 'busy' */
|
||||
tll_push_back(
|
||||
|
|
@ -127,7 +119,6 @@ shm_get_buffer(struct wl_shm *shm, int width, int height, size_t copies)
|
|||
.size = size,
|
||||
.mmapped = mmapped,
|
||||
.wl_buf = buf,
|
||||
.copies = copies,
|
||||
.pix = pix}
|
||||
)
|
||||
);
|
||||
|
|
@ -137,12 +128,8 @@ shm_get_buffer(struct wl_shm *shm, int width, int height, size_t copies)
|
|||
return ret;
|
||||
|
||||
err:
|
||||
if (pix != NULL) {
|
||||
for (size_t i = 0; i < copies; i++)
|
||||
if (pix[i] != NULL)
|
||||
pixman_image_unref(pix[i]);
|
||||
free(pix);
|
||||
}
|
||||
if (pix != NULL)
|
||||
pixman_image_unref(pix);
|
||||
if (buf != NULL)
|
||||
wl_buffer_destroy(buf);
|
||||
if (pool != NULL)
|
||||
|
|
@ -161,12 +148,8 @@ shm_fini(void)
|
|||
tll_foreach(buffers, it) {
|
||||
struct buffer *buf = &it->item;
|
||||
|
||||
if (buf->pix != NULL) {
|
||||
for (size_t i = 0; i < buf->copies; i++)
|
||||
if (buf->pix[i] != NULL)
|
||||
pixman_image_unref(buf->pix[i]);
|
||||
free(buf->pix);
|
||||
}
|
||||
if (buf->pix != NULL)
|
||||
pixman_image_unref(buf->pix);
|
||||
wl_buffer_destroy(buf->wl_buf);
|
||||
munmap(buf->mmapped, buf->size);
|
||||
|
||||
|
|
|
|||
4
shm.h
4
shm.h
|
|
@ -16,9 +16,7 @@ struct buffer {
|
|||
void *mmapped;
|
||||
|
||||
struct wl_buffer *wl_buf;
|
||||
|
||||
size_t copies;
|
||||
pixman_image_t **pix;
|
||||
pixman_image_t *pix;
|
||||
};
|
||||
|
||||
struct buffer *shm_get_buffer(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue