summaryrefslogtreecommitdiffstats
path: root/libdimension/png.c
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@tavianator.com>2014-05-30 15:48:29 -0400
committerTavian Barnes <tavianator@tavianator.com>2014-05-30 15:48:29 -0400
commit45e219eac23ea4a8181f68300fed693d9ac361a0 (patch)
tree06b72b3ca9a97b1352537836a2a42af7033ae6b1 /libdimension/png.c
parentf61c7c75c3c7ff4a329315700d3efa1d77bafa6d (diff)
downloaddimension-45e219eac23ea4a8181f68300fed693d9ac361a0.tar.xz
canvas: Use pool.
Diffstat (limited to 'libdimension/png.c')
-rw-r--r--libdimension/png.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/libdimension/png.c b/libdimension/png.c
index c33ad91..8348e5f 100644
--- a/libdimension/png.c
+++ b/libdimension/png.c
@@ -49,6 +49,7 @@ typedef struct {
typedef struct {
dmnsn_future *future;
dmnsn_canvas **canvas;
+ dmnsn_pool *pool;
FILE *file;
} dmnsn_png_read_payload;
@@ -85,25 +86,26 @@ dmnsn_png_write_canvas_async(const dmnsn_canvas *canvas, FILE *file)
/* Read a canvas from the PNG file `file'. Return NULL on error. */
dmnsn_canvas *
-dmnsn_png_read_canvas(FILE *file)
+dmnsn_png_read_canvas(dmnsn_pool *pool, FILE *file)
{
dmnsn_canvas *canvas;
- dmnsn_future *future = dmnsn_png_read_canvas_async(&canvas, file);
+ dmnsn_future *future = dmnsn_png_read_canvas_async(&canvas, pool, file);
dmnsn_future_join(future);
return canvas;
}
/* Read a canvas from a png file in the background */
dmnsn_future *
-dmnsn_png_read_canvas_async(dmnsn_canvas **canvas, FILE *file)
+dmnsn_png_read_canvas_async(dmnsn_canvas **canvas, dmnsn_pool *pool, FILE *file)
{
dmnsn_future *future = dmnsn_new_future();
dmnsn_png_read_payload *payload = DMNSN_MALLOC(dmnsn_png_read_payload);
- payload->future = future;
- payload->canvas = canvas;
+ payload->future = future;
+ payload->canvas = canvas;
*payload->canvas = NULL;
- payload->file = file;
+ payload->pool = pool;
+ payload->file = file;
/* Create the worker thread */
dmnsn_new_thread(future, dmnsn_png_read_canvas_thread, payload);
@@ -339,7 +341,7 @@ dmnsn_png_read_canvas_thread(void *ptr)
png_read_image(png_ptr, row_pointers);
/* Allocate the canvas */
- *payload->canvas = dmnsn_new_canvas(width, height);
+ *payload->canvas = dmnsn_new_canvas(payload->pool, width, height);
/* Now we convert the image to our canvas format. This depends on the image
bit depth (which has been scaled up to at least 8 or 16), and the presence