[gegl/threaded-base-classes] only disable 1x1 hot-tile code paths when multi threaded
- From: Øyvind Kolås <ok src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gegl/threaded-base-classes] only disable 1x1 hot-tile code paths when multi threaded
- Date: Fri, 27 Jun 2014 08:03:19 +0000 (UTC)
commit 3cd0891e0d08c89f3c8048a6bd437882369210ec
Author: Øyvind Kolås <pippin gimp org>
Date: Fri Jun 27 10:03:09 2014 +0200
only disable 1x1 hot-tile code paths when multi threaded
gegl/buffer/gegl-buffer-access.c | 5 +++--
gegl/buffer/gegl-sampler-nearest.c | 24 ++++++++++++++++--------
gegl/gegl-config.h | 2 ++
gegl/gegl-init.c | 7 +++++++
4 files changed, 28 insertions(+), 10 deletions(-)
---
diff --git a/gegl/buffer/gegl-buffer-access.c b/gegl/buffer/gegl-buffer-access.c
index a54cbe3..3f723ba 100644
--- a/gegl/buffer/gegl-buffer-access.c
+++ b/gegl/buffer/gegl-buffer-access.c
@@ -1330,10 +1330,11 @@ gegl_buffer_set (GeglBuffer *buffer,
if (format == NULL)
format = buffer->soft_format;
- /*if (rect && (rect->width == 1 && rect->height == 1))
+ if (rect && (rect->width == 1 && rect->height == 1) &&
+ gegl_config()->threads == 1)
_gegl_buffer_set_pixel (buffer, rect->x, rect->y, format, src,
GEGL_BUFFER_SET_FLAG_LOCK|GEGL_BUFFER_SET_FLAG_NOTIFY);
- else*/
+ else
_gegl_buffer_set_with_flags (buffer, rect, level, format, src, rowstride,
GEGL_BUFFER_SET_FLAG_LOCK|
GEGL_BUFFER_SET_FLAG_NOTIFY);
diff --git a/gegl/buffer/gegl-sampler-nearest.c b/gegl/buffer/gegl-sampler-nearest.c
index 21d3d87..4461a83 100644
--- a/gegl/buffer/gegl-sampler-nearest.c
+++ b/gegl/buffer/gegl-sampler-nearest.c
@@ -26,7 +26,7 @@
#include "gegl-buffer-private.h"
#include "gegl-tile-storage.h"
#include "gegl-tile-backend.h"
-
+#include "gegl-config.h"
#include "gegl-sampler-nearest.h"
enum
@@ -180,7 +180,7 @@ gegl_sampler_nearest_get_same_format ( GeglSampler* restrict sampler,
}
static void
-gegl_sampler_nearest_get ( GeglSampler* restrict sampler,
+gegl_sampler_nearest_get_threaded ( GeglSampler* restrict sampler,
const gdouble absolute_x,
const gdouble absolute_y,
GeglMatrix2 *scale,
@@ -191,10 +191,17 @@ gegl_sampler_nearest_get ( GeglSampler* restrict sampler,
(gint) floorf ((double) absolute_y),1,1};
gegl_buffer_get (sampler->buffer, &rect, 1.0, sampler->format, output, GEGL_AUTO_ROWSTRIDE, repeat_mode);
return;
+}
- /*
-
-#if 0
+static void
+gegl_sampler_nearest_get ( GeglSampler* restrict sampler,
+ const gdouble absolute_x,
+ const gdouble absolute_y,
+ GeglMatrix2 *scale,
+ void* restrict output,
+ GeglAbyssPolicy repeat_mode)
+{
+#if 1
gegl_sampler_get_pixel (sampler,
floorf(absolute_x), floorf(absolute_y),
output, repeat_mode);
@@ -206,8 +213,6 @@ gegl_sampler_nearest_get ( GeglSampler* restrict sampler,
repeat_mode);
babl_process (sampler->fish, in_bptr, output, 1);
#endif
-
- */
}
@@ -218,14 +223,17 @@ gegl_sampler_nearest_prepare (GeglSampler* restrict sampler)
return;
GEGL_SAMPLER_NEAREST (sampler)->buffer_bpp = babl_format_get_bytes_per_pixel (sampler->buffer->format);
+ if (gegl_config()->threads > 1)
+ sampler->get = gegl_sampler_nearest_get_threaded;
+
#if 0 // maybe re-enable; when certain result is correct
if (sampler->format == sampler->buffer->soft_format)
{
sampler->get = gegl_sampler_nearest_get_same_format;
}
else
+#endif
{
sampler->fish = babl_fish (sampler->buffer->soft_format, sampler->format);
}
-#endif
}
diff --git a/gegl/gegl-config.h b/gegl/gegl-config.h
index 607c883..f5330d0 100644
--- a/gegl/gegl-config.h
+++ b/gegl/gegl-config.h
@@ -52,6 +52,8 @@ struct _GeglConfigClass
GObjectClass parent_class;
};
+gint gegl_config_threads (void);
+
G_END_DECLS
#endif
diff --git a/gegl/gegl-init.c b/gegl/gegl-init.c
index 91baf04..ff8ac8e 100644
--- a/gegl/gegl-init.c
+++ b/gegl/gegl-init.c
@@ -399,6 +399,13 @@ GeglConfig *gegl_config (void)
return config;
}
+gint gegl_config_threads (void)
+{
+ if (!config)
+ config = gegl_config ();
+ return config->threads;
+}
+
static void swap_clean (void)
{
const gchar *swap_dir = gegl_swap_dir ();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]