diff options
| author | Daniel Eklöf <daniel@ekloef.se> | 2019-08-16 20:54:05 +0000 |
|---|---|---|
| committer | Daniel Eklöf <daniel@ekloef.se> | 2019-08-16 20:54:05 +0000 |
| commit | 72d3cbca268334fd5b7431c56121c570f6e0e90f (patch) | |
| tree | 266fc7199ac5a9d9782f1367a806e4b17fa30b3b | |
| parent | Remove all references to cairo; we now use pixman only (diff) | |
shm/render: there's no need to have one pixman image per thread
| -rw-r--r-- | render.c | 4 | ||||
| -rw-r--r-- | shm.c | 31 | ||||
| -rw-r--r-- | shm.h | 4 |
3 files changed, 10 insertions, 29 deletions
@@ -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; @@ -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); @@ -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( |
