[gegl] buffer: only use sampler mutex when swapping samplers
- From: Øyvind Kolås <ok src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gegl] buffer: only use sampler mutex when swapping samplers
- Date: Sat, 22 Jul 2017 00:44:58 +0000 (UTC)
commit 600d10a00ee0a5884f0239840c68aa4ad6aa4fef
Author: Øyvind Kolås <pippin gimp org>
Date: Sat Jul 22 01:17:25 2017 +0200
buffer: only use sampler mutex when swapping samplers
gegl/buffer/gegl-sampler.c | 39 ++++++++++++++++++---------------------
1 files changed, 18 insertions(+), 21 deletions(-)
---
diff --git a/gegl/buffer/gegl-sampler.c b/gegl/buffer/gegl-sampler.c
index aa47a9a..7f1deff 100644
--- a/gegl/buffer/gegl-sampler.c
+++ b/gegl/buffer/gegl-sampler.c
@@ -532,7 +532,6 @@ gegl_buffer_sample_at_level (GeglBuffer *buffer,
GeglSamplerType sampler_type,
GeglAbyssPolicy repeat_mode)
{
- GType desired_type;
/*
if (sampler_type == GEGL_SAMPLER_NEAREST && format == buffer->soft_format)
{
@@ -541,9 +540,6 @@ gegl_buffer_sample_at_level (GeglBuffer *buffer,
return;
}*/
- gboolean threaded = gegl_config_threads ()>1;
-
-
if (!format)
format = buffer->soft_format;
@@ -553,24 +549,24 @@ gegl_buffer_sample_at_level (GeglBuffer *buffer,
gegl_buffer_cl_cache_flush (buffer, &rect);
}
- if (threaded)
- g_mutex_lock (&gegl_buffer_sampler_mutex);
-
/* unset the cached sampler if it dosn't match the needs */
- if (buffer->sampler != NULL &&
- (buffer->sampler_type != sampler_type ||
- buffer->sampler_format != format
- ))
+ if (buffer->sampler == NULL ||
+ (buffer->sampler != NULL &&
+ (buffer->sampler_type != sampler_type || buffer->sampler_format != format)))
{
- g_object_unref (buffer->sampler);
- buffer->sampler = NULL;
- buffer->sampler_type = 0;
- }
+ gboolean threaded = gegl_config_threads () > 1;
+ GType desired_type = gegl_sampler_gtype_from_enum (sampler_type);
+
+ if (threaded)
+ g_mutex_lock (&gegl_buffer_sampler_mutex);
+
+ if (buffer->sampler)
+ {
+ g_object_unref (buffer->sampler);
+ buffer->sampler = NULL;
+ buffer->sampler_type = 0;
+ }
- /* look up appropriate sampler,. */
- if (buffer->sampler == NULL)
- {
- desired_type = gegl_sampler_gtype_from_enum (sampler_type);
buffer->sampler_type = sampler_type;
buffer->sampler = g_object_new (desired_type,
"buffer", buffer,
@@ -579,11 +575,12 @@ gegl_buffer_sample_at_level (GeglBuffer *buffer,
NULL);
buffer->sampler_format = format;
gegl_sampler_prepare (buffer->sampler);
+
+ if (threaded)
+ g_mutex_unlock (&gegl_buffer_sampler_mutex);
}
buffer->sampler->get(buffer->sampler, x, y, scale, dest, repeat_mode);
- if (threaded)
- g_mutex_unlock (&gegl_buffer_sampler_mutex);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]