[gegl] buffer: short-circuit nearest sampler with a 1x1 gegl_buffer_get



commit 4b9c3ad637b3fd53685a911ce30ef1aa6b92618c
Author: Øyvind Kolås <pippin gimp org>
Date:   Thu Jun 12 01:03:46 2014 +0200

    buffer: short-circuit nearest sampler with a 1x1 gegl_buffer_get
    
    The GeglSampler base-class is micro optimized for affine transformations at
    the moment, for now, this short-circuit of the nearest sampler implementation
    avoids a lot of redundant elbow-room caching.

 gegl/buffer/gegl-sampler-nearest.c |   14 +++++++++++++-
 1 files changed, 13 insertions(+), 1 deletions(-)
---
diff --git a/gegl/buffer/gegl-sampler-nearest.c b/gegl/buffer/gegl-sampler-nearest.c
index c34e41a..48da2d8 100644
--- a/gegl/buffer/gegl-sampler-nearest.c
+++ b/gegl/buffer/gegl-sampler-nearest.c
@@ -62,7 +62,7 @@ gegl_sampler_nearest_init (GeglSamplerNearest *self)
 }
 
 void
-gegl_sampler_nearest_get (      GeglSampler*    restrict  self,
+gegl_sampler_nearest_get (      GeglSampler*    restrict  sampler,
                           const gdouble                   absolute_x,
                           const gdouble                   absolute_y,
                                 GeglMatrix2              *scale,
@@ -77,10 +77,22 @@ gegl_sampler_nearest_get (      GeglSampler*    restrict  self,
    * located at (.5,.5) (instead of (0,0) as it would be if absolute
    * positions were center-based).
    */
+
+#if 1 /* There probably is faster ways to do this, */
+  GeglRectangle rect = {floorf(absolute_x), floorf(absolute_y), 1, 1};
+  gegl_buffer_get (sampler->buffer, &rect, 1.0,
+                   sampler->format, output, 0, repeat_mode);
+#else
+
+  /* this left in here; to make it easy to manually verify that the
+   * sampler framework behaves correctly.
+   */
+
   const gfloat* restrict in_bptr =
     gegl_sampler_get_ptr (self,
                           (gint) floor ((double) absolute_x),
                           (gint) floor ((double) absolute_y),
                           repeat_mode);
   babl_process (self->fish, in_bptr, output, 1);
+#endif
 }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]