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 /shm.c | |
| 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
Diffstat (limited to 'shm.c')
| -rw-r--r-- | shm.c | 31 |
1 files changed, 7 insertions, 24 deletions
@@ -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); |
