gegl r2143 - in trunk: . gegl/buffer
- From: ok svn gnome org
- To: svn-commits-list gnome org
- Subject: gegl r2143 - in trunk: . gegl/buffer
- Date: Sun, 2 Mar 2008 17:12:27 +0000 (GMT)
Author: ok
Date: Sun Mar 2 17:12:27 2008
New Revision: 2143
URL: http://svn.gnome.org/viewvc/gegl?rev=2143&view=rev
Log:
* gegl/buffer/gegl-buffer.c: (gegl_buffer_set), (gegl_buffer_get),
(gegl_buffer_sample): Added a big buffer lock that is a recursive
static mutex for the multi processor case, this isn't neccesarily
a final solution but it should be a better catch all for paralell
experiments using GeglBuffers than the simplistic tile based locks.
This is a stopgap measure until either the buffer code, or the tile
backend code resides in a separate thread.
Modified:
trunk/ChangeLog
trunk/gegl/buffer/gegl-buffer.c
Modified: trunk/gegl/buffer/gegl-buffer.c
==============================================================================
--- trunk/gegl/buffer/gegl-buffer.c (original)
+++ trunk/gegl/buffer/gegl-buffer.c Sun Mar 2 17:12:27 2008
@@ -45,6 +45,10 @@
G_DEFINE_TYPE (GeglBuffer, gegl_buffer, GEGL_TYPE_TILE_TRAITS)
+#if ENABLE_MP
+GStaticRecMutex mutex = G_STATIC_REC_MUTEX_INIT;
+#endif
+
static GObjectClass * parent_class = NULL;
enum
@@ -1227,6 +1231,9 @@
GeglBuffer *sub_buf;
g_return_if_fail (GEGL_IS_BUFFER (buffer));
+#if ENABLE_MP
+ g_static_rec_mutex_lock (&mutex);
+#endif
if (format == NULL)
format = buffer->format;
@@ -1237,6 +1244,9 @@
if (rect && rect->width == 1 && rect->height == 1) /* fast path */
{
pset (buffer, rect->x, rect->y, format, src);
+#if ENABLE_MP
+ g_static_rec_mutex_unlock (&mutex);
+#endif
return;
}
/* FIXME: if rect->width == TILE_WIDTH and rect->height == TILE_HEIGHT and
@@ -1246,11 +1256,17 @@
if (rect == NULL)
{
gegl_buffer_iterate (buffer, src, rowstride, TRUE, format, 0);
+#if ENABLE_MP
+ g_static_rec_mutex_unlock (&mutex);
+#endif
return;
}
sub_buf = gegl_buffer_create_sub_buffer (buffer, rect);
gegl_buffer_iterate (sub_buf, src, rowstride, TRUE, format, 0);
g_object_unref (sub_buf);
+#if ENABLE_MP
+ g_static_rec_mutex_unlock (&mutex);
+#endif
}
/*
@@ -1583,6 +1599,9 @@
gint rowstride)
{
g_return_if_fail (GEGL_IS_BUFFER (buffer));
+#if ENABLE_MP
+ g_static_rec_mutex_lock (&mutex);
+#endif
if (format == NULL)
format = buffer->format;
@@ -1593,20 +1612,34 @@
rect->height == 1) /* fast path */
{
pget (buffer, rect->x, rect->y, format, dest_buf);
+#if ENABLE_MP
+ g_static_rec_mutex_unlock (&mutex);
+#endif
return;
}
if (!rect && scale == 1.0)
{
gegl_buffer_iterate (buffer, dest_buf, rowstride, FALSE, format, 0);
+#if ENABLE_MP
+ g_static_rec_mutex_unlock (&mutex);
+#endif
return;
}
if (rect->width == 0 ||
rect->height == 0)
- return;
+ {
+#if ENABLE_MP
+ g_static_rec_mutex_unlock (&mutex);
+#endif
+ return;
+ }
if (GEGL_FLOAT_EQUAL (scale, 1.0))
{
gegl_buffer_get_scaled (buffer, rect, dest_buf, rowstride, format, 0);
+#if ENABLE_MP
+ g_static_rec_mutex_unlock (&mutex);
+#endif
return;
}
else
@@ -1683,6 +1716,9 @@
}
g_free (sample_buf);
}
+#if ENABLE_MP
+ g_static_rec_mutex_unlock (&mutex);
+#endif
}
const GeglRectangle *
@@ -1710,6 +1746,10 @@
return;
#endif
+#if ENABLE_MP
+ g_static_rec_mutex_lock (&mutex);
+#endif
+
/* look up appropriate sampler,. */
if (buffer->sampler == NULL)
{
@@ -1737,6 +1777,10 @@
}
gegl_sampler_get (buffer->sampler, x, y, dest);
+#if ENABLE_MP
+ g_static_rec_mutex_unlock (&mutex);
+#endif
+
/* if none found, create a singleton sampler for this buffer,
* a function to clean up the samplers set for a buffer should
* also be provided */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]