summaryrefslogtreecommitdiffstats
path: root/libdimension/dimension/canvas.h
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@gmail.com>2009-07-01 20:07:12 +0000
committerTavian Barnes <tavianator@gmail.com>2009-07-01 20:07:12 +0000
commit219fc9ac99e2c24acea011d7845a22d6b3700f75 (patch)
tree9532ecc162dd317fa47d841e2b77e3044e022976 /libdimension/dimension/canvas.h
parent74a94dd492f9bcabf442e3f0c89dbb7cf8463cf8 (diff)
downloaddimension-219fc9ac99e2c24acea011d7845a22d6b3700f75.tar.xz
Inline some functions: about a 5% performance boost.
Diffstat (limited to 'libdimension/dimension/canvas.h')
-rw-r--r--libdimension/dimension/canvas.h25
1 files changed, 19 insertions, 6 deletions
diff --git a/libdimension/dimension/canvas.h b/libdimension/dimension/canvas.h
index 269763b..4c94c33 100644
--- a/libdimension/dimension/canvas.h
+++ b/libdimension/dimension/canvas.h
@@ -41,11 +41,24 @@ dmnsn_canvas *dmnsn_new_canvas(unsigned int x, unsigned int y);
void dmnsn_delete_canvas(dmnsn_canvas *canvas);
/* Pixel accessors */
-dmnsn_color dmnsn_get_pixel(const dmnsn_canvas *canvas,
- unsigned int x, unsigned int y);
-void dmnsn_set_pixel(dmnsn_canvas *canvas,
- unsigned int x, unsigned int y, dmnsn_color color);
-dmnsn_color *dmnsn_pixel_at(dmnsn_canvas *canvas,
- unsigned int x, unsigned int y);
+
+DMNSN_INLINE dmnsn_color
+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;
+}
#endif /* DIMENSION_CANVAS_H */