diff --git a/render.c b/render.c index cefff04b..e2ed46b1 100644 --- a/render.c +++ b/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; diff --git a/shm.c b/shm.c index 0ae46f90..ebff8a1a 100644 --- a/shm.c +++ b/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); diff --git a/shm.h b/shm.h index 7006ab3a..68013888 100644 --- a/shm.h +++ b/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(