summaryrefslogtreecommitdiffstats
path: root/libdimension/dimension
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@tavianator.com>2014-06-19 16:58:14 -0400
committerTavian Barnes <tavianator@tavianator.com>2014-06-19 16:58:40 -0400
commite39f2e09698556e7895b084b7addb88d3e7ea58d (patch)
treea5f9f989203d0750328a220ffb4ea9f24f82fae1 /libdimension/dimension
parent4a28a6ac23f92f5d1ce13e369b27be22815aec6c (diff)
downloaddimension-e39f2e09698556e7895b084b7addb88d3e7ea58d.tar.xz
canvas: Kill optimizers' ->ptr field.
Diffstat (limited to 'libdimension/dimension')
-rw-r--r--libdimension/dimension/canvas.h25
-rw-r--r--libdimension/dimension/gl.h3
-rw-r--r--libdimension/dimension/png.h3
3 files changed, 19 insertions, 12 deletions
diff --git a/libdimension/dimension/canvas.h b/libdimension/dimension/canvas.h
index d03a37e..e325364 100644
--- a/libdimension/dimension/canvas.h
+++ b/libdimension/dimension/canvas.h
@@ -41,23 +41,22 @@ typedef struct dmnsn_canvas {
dmnsn_tcolor *pixels;
} dmnsn_canvas;
+/* Forward-declare dmnsn_canvas_optimizer. */
+typedef struct dmnsn_canvas_optimizer dmnsn_canvas_optimizer;
+
/**
* Canvas optimizer callback type.
+ * @param[in] optimizer The canvas optimizer.
* @param[in] canvas The canvas that was just updated.
- * @param[in] ptr The canvas optimizer's data pointer.
- * @param[in] x The x-coordinate that was just updated.
- * @param[in] y The y-coordinate that was just updated.
+ * @param[in] x The x-coordinate that was just updated.
+ * @param[in] y The y-coordinate that was just updated.
*/
-typedef void dmnsn_canvas_optimizer_fn(const dmnsn_canvas *canvas, void *ptr,
- size_t x, size_t y);
+typedef void dmnsn_canvas_optimizer_fn(dmnsn_canvas_optimizer *optimizer, const dmnsn_canvas *canvas, size_t x, size_t y);
/** Canvas optimizer. */
-typedef struct dmnsn_canvas_optimizer {
+struct dmnsn_canvas_optimizer {
dmnsn_canvas_optimizer_fn *optimizer_fn; /**< Optimizer callback. */
- dmnsn_free_fn *free_fn; /**< Destructor callback. */
-
- void *ptr; /**< Generic pointer. */
-} dmnsn_canvas_optimizer;
+};
/**
* Allocate a new canvas.
@@ -69,6 +68,12 @@ typedef struct dmnsn_canvas_optimizer {
dmnsn_canvas *dmnsn_new_canvas(dmnsn_pool *pool, size_t width, size_t height);
/**
+ * Initialize a dmnsn_canvas_optimizer field
+ * @param[in] optimizer The optimizer to initialize.
+ */
+void dmnsn_init_canvas_optimizer(dmnsn_canvas_optimizer *optimizer);
+
+/**
* Set a canvas optimizer
* @param[in,out] canvas The canvas to optimize.
* @param[in] optimizer The optimizer to use.
diff --git a/libdimension/dimension/gl.h b/libdimension/dimension/gl.h
index 8e64ba6..284a248 100644
--- a/libdimension/dimension/gl.h
+++ b/libdimension/dimension/gl.h
@@ -25,10 +25,11 @@
/**
* Optimize a canvas for GL drawing
+ * @param[in] pool The memory pool to allocate from.
* @param[in,out] canvas The canvas to optimize.
* @return Whether the canvas was successfully optimized.
*/
-int dmnsn_gl_optimize_canvas(dmnsn_canvas *canvas);
+int dmnsn_gl_optimize_canvas(dmnsn_pool *pool, dmnsn_canvas *canvas);
/**
* Write canvas to GL framebuffer.
diff --git a/libdimension/dimension/png.h b/libdimension/dimension/png.h
index c45a9bf..f4d2c1e 100644
--- a/libdimension/dimension/png.h
+++ b/libdimension/dimension/png.h
@@ -27,10 +27,11 @@
/**
* Optimize a canvas for PNG exporting
+ * @param[in] pool The memory pool to allocate from.
* @param[in,out] canvas The canvas to optimize.
* @return Whether the canvas was successfully optimized.
*/
-int dmnsn_png_optimize_canvas(dmnsn_canvas *canvas);
+int dmnsn_png_optimize_canvas(dmnsn_pool *pool, dmnsn_canvas *canvas);
/**
* Write a canvas to a file in PNG format.