summaryrefslogtreecommitdiffstats
path: root/libdimension/dimension/canvas.h
diff options
context:
space:
mode:
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 */