summaryrefslogtreecommitdiffstats
path: root/libdimension/dimension
diff options
context:
space:
mode:
Diffstat (limited to 'libdimension/dimension')
-rw-r--r--libdimension/dimension/canvas.h36
-rw-r--r--libdimension/dimension/gl.h3
-rw-r--r--libdimension/dimension/png.h3
3 files changed, 29 insertions, 13 deletions
diff --git a/libdimension/dimension/canvas.h b/libdimension/dimension/canvas.h
index 4c94c33..a14333d 100644
--- a/libdimension/dimension/canvas.h
+++ b/libdimension/dimension/canvas.h
@@ -34,12 +34,34 @@ typedef struct {
* at (a,b) is accessible as pixels[b*x + a].
*/
dmnsn_color *pixels;
+
+ /* An array of dmnsn_canvas_optimizer's */
+ dmnsn_array *optimizers;
} dmnsn_canvas;
+typedef struct dmnsn_canvas_optimizer dmnsn_canvas_optimizer;
+
+/* Canvas optimizer callback types */
+typedef void dmnsn_canvas_optimizer_fn(dmnsn_canvas *canvas,
+ dmnsn_canvas_optimizer optimizer,
+ unsigned int x, unsigned int y);
+typedef void dmnsn_canvas_optimizer_free_fn(void *ptr);
+
+/* Canvas optimizer */
+struct dmnsn_canvas_optimizer {
+ dmnsn_canvas_optimizer_fn *optimizer_fn;
+ dmnsn_canvas_optimizer_free_fn *free_fn;
+ void *ptr;
+};
+
/* Allocate and free a canvas */
dmnsn_canvas *dmnsn_new_canvas(unsigned int x, unsigned int y);
void dmnsn_delete_canvas(dmnsn_canvas *canvas);
+/* Set a canvas optimizer */
+void dmnsn_optimize_canvas(dmnsn_canvas *canvas,
+ dmnsn_canvas_optimizer optimizer);
+
/* Pixel accessors */
DMNSN_INLINE dmnsn_color
@@ -48,17 +70,7 @@ dmnsn_get_pixel(const dmnsn_canvas *canvas, unsigned int x, unsigned int y)
return canvas->pixels[y*canvas->x + x];
}
-DMNSN_INLINE void
-dmnsn_set_pixel(dmnsn_canvas *canvas,
- unsigned int x, unsigned int y, dmnsn_color color)
-{
- canvas->pixels[y*canvas->x + x] = color;
-}
-
-DMNSN_INLINE dmnsn_color *
-dmnsn_pixel_at(dmnsn_canvas *canvas, unsigned int x, unsigned int y)
-{
- return canvas->pixels + y*canvas->x + x;
-}
+void dmnsn_set_pixel(dmnsn_canvas *canvas, unsigned int x, unsigned int y,
+ dmnsn_color color);
#endif /* DIMENSION_CANVAS_H */
diff --git a/libdimension/dimension/gl.h b/libdimension/dimension/gl.h
index f7de782..f81f662 100644
--- a/libdimension/dimension/gl.h
+++ b/libdimension/dimension/gl.h
@@ -26,7 +26,8 @@
#ifndef DIMENSION_GL_H
#define DIMENSION_GL_H
-#include <stdio.h>
+/* Optimize canvas for GL drawing */
+int dmnsn_gl_optimize_canvas(dmnsn_canvas *canvas);
/* Write canvas to GL framebuffer. Returns 0 on success, nonzero on failure. */
int dmnsn_gl_write_canvas(const dmnsn_canvas *canvas);
diff --git a/libdimension/dimension/png.h b/libdimension/dimension/png.h
index 858f79f..f1b1470 100644
--- a/libdimension/dimension/png.h
+++ b/libdimension/dimension/png.h
@@ -27,6 +27,9 @@
#include <stdio.h>
+/* Optimize canvas for PNG exporting */
+int dmnsn_png_optimize_canvas(dmnsn_canvas *canvas);
+
/* Write canvas to file in PNG format. Returns 0 on success, nonzero on
failure */
int dmnsn_png_write_canvas(const dmnsn_canvas *canvas, FILE *file);