diff options
author | Tavian Barnes <tavianator@gmail.com> | 2009-07-04 21:53:55 +0000 |
---|---|---|
committer | Tavian Barnes <tavianator@gmail.com> | 2009-07-04 21:53:55 +0000 |
commit | 8085395acc28d8c77901615f8862ceeda5773b09 (patch) | |
tree | c8261638a486191a3c2cea1ed91590f8104878c7 /libdimension/dimension/canvas.h | |
parent | d3ad0b6a25146318d153ecd6c792e41a9a0a6025 (diff) | |
download | dimension-8085395acc28d8c77901615f8862ceeda5773b09.tar.xz |
New interface for optimizing canvas conversions by registering
dmnsn_set_pixel() callbacks.
Diffstat (limited to 'libdimension/dimension/canvas.h')
-rw-r--r-- | libdimension/dimension/canvas.h | 36 |
1 files changed, 24 insertions, 12 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 */ |