[gegl] GeglSampler: cache a bablfish in the sampler
- From: Øyvind Kolås <ok src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gegl] GeglSampler: cache a bablfish in the sampler
- Date: Sat, 30 Jan 2010 14:09:09 +0000 (UTC)
commit bd41776cb51ba9531a8676e9d95b7a2d8723210f
Author: �yvind Kolås <pippin gimp org>
Date: Sat Jan 30 13:57:46 2010 +0000
GeglSampler: cache a bablfish in the sampler
The fish will be valid after a call to gegl_sampler_prepare, before
calling prepare the expected output format should be set on the sampler.
gegl/buffer/gegl-sampler-cubic.c | 4 +---
gegl/buffer/gegl-sampler-lanczos.c | 3 +--
gegl/buffer/gegl-sampler-linear.c | 21 +++++++++------------
gegl/buffer/gegl-sampler.c | 15 +++++++++------
gegl/buffer/gegl-sampler.h | 1 +
5 files changed, 21 insertions(+), 23 deletions(-)
---
diff --git a/gegl/buffer/gegl-sampler-cubic.c b/gegl/buffer/gegl-sampler-cubic.c
index e68e9c2..599aaed 100644
--- a/gegl/buffer/gegl-sampler-cubic.c
+++ b/gegl/buffer/gegl-sampler-cubic.c
@@ -184,9 +184,7 @@ gegl_sampler_cubic_get (GeglSampler *self,
}
}
- babl_process (babl_fish (self->interpolate_format, self->format),
- newval, output, 1);
-
+ babl_process (self->fish, newval, output, 1);
}
static void
diff --git a/gegl/buffer/gegl-sampler-lanczos.c b/gegl/buffer/gegl-sampler-lanczos.c
index 0688d13..afd4050 100644
--- a/gegl/buffer/gegl-sampler-lanczos.c
+++ b/gegl/buffer/gegl-sampler-lanczos.c
@@ -199,8 +199,7 @@ gegl_sampler_lanczos_get (GeglSampler *self,
newval[3] += y_kernel[j] * x_kernel[i] * sampler_bptr[3];
}
- babl_process (babl_fish (self->interpolate_format, self->format),
- newval, output, 1);
+ babl_process (self->fish, newval, output, 1);
}
static void
diff --git a/gegl/buffer/gegl-sampler-linear.c b/gegl/buffer/gegl-sampler-linear.c
index 0aaa69d..5f80a47 100644
--- a/gegl/buffer/gegl-sampler-linear.c
+++ b/gegl/buffer/gegl-sampler-linear.c
@@ -74,10 +74,10 @@ enum
PROP_LAST
};
-static void gegl_sampler_linear_get ( GeglSampler* restrict self,
- const gdouble x,
- const gdouble y,
- void* restrict output);
+static void gegl_sampler_linear_get (GeglSampler* restrict self,
+ const gdouble x,
+ const gdouble y,
+ void* restrict output);
static void set_property (GObject* gobject,
guint property_id,
@@ -114,10 +114,10 @@ gegl_sampler_linear_init (GeglSamplerLinear *self)
}
static void
-gegl_sampler_linear_get ( GeglSampler* restrict self,
- const gdouble absolute_x,
- const gdouble absolute_y,
- void* restrict output)
+gegl_sampler_linear_get (GeglSampler* restrict self,
+ const gdouble absolute_x,
+ const gdouble absolute_y,
+ void* restrict output)
{
const gint pixels_per_buffer_row = 64;
const gint channels = 4;
@@ -229,10 +229,7 @@ gegl_sampler_linear_get ( GeglSampler* restrict self,
+
w_times_z * top_left_3;
- babl_process (babl_fish (self->interpolate_format, self->format),
- newval,
- output,
- 1);
+ babl_process (self->fish, newval, output, 1);
}
}
diff --git a/gegl/buffer/gegl-sampler.c b/gegl/buffer/gegl-sampler.c
index 2721106..5778384 100644
--- a/gegl/buffer/gegl-sampler.c
+++ b/gegl/buffer/gegl-sampler.c
@@ -154,6 +154,9 @@ gegl_sampler_prepare (GeglSampler *self)
if (klass->prepare)
klass->prepare (self);
+
+ self->fish = babl_fish (self->interpolate_format, self->format);
+
/*
* This makes the cache rect invalid, in case the data in the buffer
* has changed:
@@ -214,9 +217,9 @@ dispose (GObject *gobject)
* rowstride of 64px * 16bpp:
*/
gfloat *
-gegl_sampler_get_ptr ( GeglSampler *const sampler,
- const gint x,
- const gint y)
+gegl_sampler_get_ptr (GeglSampler *const sampler,
+ const gint x,
+ const gint y)
{
guchar *buffer_ptr;
gint dx;
@@ -305,9 +308,9 @@ gegl_sampler_get_ptr ( GeglSampler *const sampler,
}
gfloat *
-gegl_sampler_get_from_buffer ( GeglSampler *const sampler,
- const gint x,
- const gint y)
+gegl_sampler_get_from_buffer (GeglSampler *const sampler,
+ const gint x,
+ const gint y)
{
guchar *buffer_ptr;
gint dx;
diff --git a/gegl/buffer/gegl-sampler.h b/gegl/buffer/gegl-sampler.h
index d5e9494..9600c7e 100644
--- a/gegl/buffer/gegl-sampler.h
+++ b/gegl/buffer/gegl-sampler.h
@@ -43,6 +43,7 @@ struct _GeglSampler
GeglBuffer *buffer;
Babl *format;
Babl *interpolate_format;
+ Babl *fish;
GeglRectangle context_rect;
void *sampler_buffer;
GeglRectangle sampler_rectangle;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]