[gegl/threaded-base-classes: 3/22] buffer: use tile-indice based mutexes for tile-writing
- From: Øyvind Kolås <ok src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gegl/threaded-base-classes: 3/22] buffer: use tile-indice based mutexes for tile-writing
- Date: Mon, 30 Jun 2014 02:15:09 +0000 (UTC)
commit c8319988d6e8679b060cb3ce1f2952708eda2ddc
Author: Massimo Valentini <mvalentini src gnome org>
Date: Thu Jun 26 18:48:54 2014 +0200
buffer: use tile-indice based mutexes for tile-writing
This changes both gegl_buffer_set and gegl_buffer_iterator.
gegl/buffer/gegl-buffer-access.c | 13 ++++++++++---
gegl/buffer/gegl-buffer-iterator.c | 3 +++
2 files changed, 13 insertions(+), 3 deletions(-)
---
diff --git a/gegl/buffer/gegl-buffer-access.c b/gegl/buffer/gegl-buffer-access.c
index c2cf098..9a88b49 100644
--- a/gegl/buffer/gegl-buffer-access.c
+++ b/gegl/buffer/gegl-buffer-access.c
@@ -303,6 +303,8 @@ gegl_buffer_flush (GeglBuffer *buffer)
GEGL_TILE_FLUSH, 0,0,0,NULL);
}
+static GMutex mutexes[256];
+
static inline void
gegl_buffer_iterate_write (GeglBuffer *buffer,
const GeglRectangle *roi,
@@ -375,6 +377,8 @@ gegl_buffer_iterate_write (GeglBuffer *buffer,
gint tiledx = buffer_x + bufx;
gint offsetx = gegl_tile_offset (tiledx, tile_width);
gint y = bufy;
+ gint index_x;
+ gint index_y;
gint lskip, rskip, pixels, row;
guchar *bp, *tile_base, *tp;
GeglTile *tile;
@@ -386,10 +390,13 @@ gegl_buffer_iterate_write (GeglBuffer *buffer,
else
pixels = tile_width - offsetx;
+ index_x = gegl_tile_indice (tiledx, tile_width);
+ index_y = gegl_tile_indice (tiledy, tile_height);
+
+ g_mutex_lock (&mutexes[ABS (index_x) % 256]);
tile = gegl_tile_source_get_tile ((GeglTileSource *) (buffer),
- gegl_tile_indice (tiledx, tile_width),
- gegl_tile_indice (tiledy, tile_height),
- level);
+ index_x, index_y, level);
+ g_mutex_unlock (&mutexes[ABS (index_x) % 256]);
lskip = (buffer_abyss_x) - (buffer_x + bufx);
/* gap between left side of tile, and abyss */
diff --git a/gegl/buffer/gegl-buffer-iterator.c b/gegl/buffer/gegl-buffer-iterator.c
index 456e805..9a90e5c 100644
--- a/gegl/buffer/gegl-buffer-iterator.c
+++ b/gegl/buffer/gegl-buffer-iterator.c
@@ -285,6 +285,7 @@ increment_rects (GeglBufferIterator *iter)
return TRUE;
}
+static GMutex mutexes[256];
static void
get_tile (GeglBufferIterator *iter,
int index)
@@ -313,8 +314,10 @@ get_tile (GeglBufferIterator *iter,
int tile_x = gegl_tile_indice (iter->roi[index].x + shift_x, tile_width);
int tile_y = gegl_tile_indice (iter->roi[index].y + shift_y, tile_height);
+ g_mutex_lock (&mutexes[ABS (tile_x) % 256]);
sub->current_tile = gegl_tile_source_get_tile ((GeglTileSource *)(buf),
tile_x, tile_y, 0);
+ g_mutex_unlock (&mutexes[ABS (tile_x) % 256]);
if (sub->flags & GEGL_BUFFER_WRITE)
gegl_tile_lock (sub->current_tile);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]