summaryrefslogtreecommitdiffstats
path: root/libdimension/dimension/canvas.h
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@gmail.com>2009-04-08 22:26:16 +0000
committerTavian Barnes <tavianator@gmail.com>2009-04-08 22:26:16 +0000
commit968e1d8710004517639966bd4c6f83f37edccd21 (patch)
tree09f2bfebd6dd0da42e3f47ccd909c075969f46d2 /libdimension/dimension/canvas.h
parent97d9b60f0fff735bace4653f3b321592ba4ed1cc (diff)
downloaddimension-968e1d8710004517639966bd4c6f83f37edccd21.tar.xz
Add read-write mutexes to canvas pixels. New error infrastructure.
Diffstat (limited to 'libdimension/dimension/canvas.h')
-rw-r--r--libdimension/dimension/canvas.h18
1 files changed, 18 insertions, 0 deletions
diff --git a/libdimension/dimension/canvas.h b/libdimension/dimension/canvas.h
index 21d56e4..d40ed1d 100644
--- a/libdimension/dimension/canvas.h
+++ b/libdimension/dimension/canvas.h
@@ -25,6 +25,8 @@
#ifndef DIMENSION_CANVAS_H
#define DIMENSION_CANVAS_H
+#include <pthread.h>
+
typedef struct {
unsigned int x, y;
@@ -33,9 +35,25 @@ typedef struct {
* at (a,b) is accessible as pixels[b*x + a].
*/
dmnsn_color *pixels;
+
+ /* Read-write locks for each pixel */
+ pthread_rwlock_t *rwlocks;
} dmnsn_canvas;
dmnsn_canvas *dmnsn_new_canvas(unsigned int x, unsigned int y);
void dmnsn_delete_canvas(dmnsn_canvas *canvas);
+/* These handle the rwlocks correctly */
+dmnsn_color dmnsn_get_pixel(const dmnsn_canvas *canvas,
+ unsigned int x, unsigned int y);
+void dmnsn_set_pixel(dmnsn_canvas *canvas, dmnsn_color color,
+ unsigned int x, unsigned int y);
+
+/* Manual locking */
+void dmnsn_rdlock_pixel(const dmnsn_canvas *canvas,
+ unsigned int x, unsigned int y);
+void dmnsn_wrlock_pixel(dmnsn_canvas *canvas, unsigned int x, unsigned int y);
+void dmnsn_unlock_pixel(const dmnsn_canvas *canvas,
+ unsigned int x, unsigned int y);
+
#endif /* DIMENSION_CANVAS_H */