[gegl] buffer: speed up NEAREST gegl_buffer_sample
- From: Øyvind Kolås <ok src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gegl] buffer: speed up NEAREST gegl_buffer_sample
- Date: Tue, 15 May 2018 09:46:19 +0000 (UTC)
commit c8eb73eb761ee3b7a393fbb785117db0c96f98f8
Author: Øyvind Kolås <pippin gimp org>
Date: Tue May 15 11:36:53 2018 +0200
buffer: speed up NEAREST gegl_buffer_sample
For the nearest neighbor case, use gegl_buffer_get with a 1x1 rectangle instead
of a temporary sampler.
gegl/buffer/gegl-sampler.c | 47 +++++++++++++++++++++++++++++++++----------
1 files changed, 36 insertions(+), 11 deletions(-)
---
diff --git a/gegl/buffer/gegl-sampler.c b/gegl/buffer/gegl-sampler.c
index a9a4246..b63dbec 100644
--- a/gegl/buffer/gegl-sampler.c
+++ b/gegl/buffer/gegl-sampler.c
@@ -414,19 +414,29 @@ gegl_sampler_gtype_from_enum (GeglSamplerType sampler_type)
}
}
-void
-gegl_buffer_sample_at_level (GeglBuffer *buffer,
- gdouble x,
- gdouble y,
- GeglMatrix2 *scale,
- gpointer dest,
- const Babl *format,
- gint level,
- GeglSamplerType sampler_type,
- GeglAbyssPolicy repeat_mode)
+static inline void
+_gegl_buffer_sample_at_level (GeglBuffer *buffer,
+ gdouble x,
+ gdouble y,
+ GeglMatrix2 *scale,
+ gpointer dest,
+ const Babl *format,
+ gint level,
+ GeglSamplerType sampler_type,
+ GeglAbyssPolicy repeat_mode)
{
GeglSampler *sampler;
+ if (sampler_type == GEGL_SAMPLER_NEAREST &&
+ level == 0)
+ {
+ GeglRectangle rect = {x, y, 1, 1};
+ gegl_buffer_get (buffer, &rect, 1.0,
+ format, dest, GEGL_AUTO_ROWSTRIDE,
+ repeat_mode);
+ return;
+ }
+
if (!format)
format = buffer->soft_format;
@@ -438,6 +448,21 @@ gegl_buffer_sample_at_level (GeglBuffer *buffer,
g_object_unref (sampler);
}
+void
+gegl_buffer_sample_at_level (GeglBuffer *buffer,
+ gdouble x,
+ gdouble y,
+ GeglMatrix2 *scale,
+ gpointer dest,
+ const Babl *format,
+ gint level,
+ GeglSamplerType sampler_type,
+ GeglAbyssPolicy repeat_mode)
+{
+ _gegl_buffer_sample_at_level (buffer, x, y, scale, dest,
+ format, level, sampler_type, repeat_mode);
+}
+
void
gegl_buffer_sample (GeglBuffer *buffer,
@@ -449,7 +474,7 @@ gegl_buffer_sample (GeglBuffer *buffer,
GeglSamplerType sampler_type,
GeglAbyssPolicy repeat_mode)
{
- gegl_buffer_sample_at_level (buffer, x, y, scale, dest, format, 0, sampler_type, repeat_mode);
+ _gegl_buffer_sample_at_level (buffer, x, y, scale, dest, format, 0, sampler_type, repeat_mode);
}
void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]