[gegl] samplers: rename inverse_jacobian to scale
- From: Ãyvind KolÃs <ok src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gegl] samplers: rename inverse_jacobian to scale
- Date: Sun, 3 Jul 2011 17:03:15 +0000 (UTC)
commit 1726d5b36815b7a1727efd6696b468f988abc301
Author: Ãyvind KolÃs <pippin gimp org>
Date: Sun Jul 3 02:34:10 2011 +0100
samplers: rename inverse_jacobian to scale
gegl/buffer/gegl-buffer-access.c | 7 +++----
gegl/buffer/gegl-sampler.c | 25 +++++++++++++++----------
gegl/buffer/gegl-sampler.h | 10 ++++++----
gegl/gegl-plugin.h | 34 ++++++++++++++++++----------------
gegl/gegl-utils.h | 3 ---
operations/workshop/fractal-trace.c | 32 +++++++++++++++++---------------
6 files changed, 59 insertions(+), 52 deletions(-)
---
diff --git a/gegl/buffer/gegl-buffer-access.c b/gegl/buffer/gegl-buffer-access.c
index 3614a86..620737c 100644
--- a/gegl/buffer/gegl-buffer-access.c
+++ b/gegl/buffer/gegl-buffer-access.c
@@ -339,7 +339,6 @@ gegl_buffer_iterate (GeglBuffer *buffer,
gint buffer_abyss_y = buffer->abyss.y + buffer_shift_y;
gint abyss_x_total = buffer_abyss_x + buffer->abyss.width;
gint abyss_y_total = buffer_abyss_y + buffer->abyss.height;
- gint i;
gint factor = 1<<level;
/* roi specified, override buffers extent */
@@ -1069,7 +1068,7 @@ void
gegl_buffer_sample2 (GeglBuffer *buffer,
gdouble x,
gdouble y,
- GeglMatrix2 *inverse_jacobian,
+ GeglMatrix2 *scale,
gpointer dest,
const Babl *format,
GeglInterpolation interpolation)
@@ -1105,8 +1104,8 @@ gegl_buffer_sample2 (GeglBuffer *buffer,
buffer->sampler_format = format;
gegl_sampler_prepare (buffer->sampler);
}
- if (inverse_jacobian)
- gegl_sampler_set_inverse_jacobian (buffer->sampler, inverse_jacobian);
+ if (scale)
+ gegl_sampler_set_scale (buffer->sampler, scale);
gegl_sampler_get (buffer->sampler, x, y, dest);
}
diff --git a/gegl/buffer/gegl-sampler.c b/gegl/buffer/gegl-sampler.c
index 9d45e49..ce0c2ad 100644
--- a/gegl/buffer/gegl-sampler.c
+++ b/gegl/buffer/gegl-sampler.c
@@ -42,7 +42,7 @@ enum
PROP_BUFFER,
PROP_FORMAT,
PROP_CONTEXT_RECT,
- PROP_INVERSE_JACOBIAN,
+ PROP_SCALE,
PROP_LAST
};
@@ -103,10 +103,15 @@ gegl_sampler_class_init (GeglSamplerClass *klass)
g_object_class_install_property (
object_class,
- PROP_INVERSE_JACOBIAN,
- g_param_spec_pointer ("inverse_jacobian",
- "Inverse Jacobian",
- "Inverse Jacobian matrix, for certain samplers.",
+ PROP_SCALE,
+ g_param_spec_pointer ("scale",
+ "Scale",
+"An approximation of the extent of pixels sampled in source for a pixel. "
+"The property can be varied per sampled pixel, avoid setting it if it is "
+"constant for the entire buffer; if setting it for every pixel using the "
+"C function gegl_sampler_set_scale is more efficient. "
+"Mostly the scaling factors for sampling does not need to be set if the "
+"transformation is rotating or only scaling up.",
G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
}
@@ -500,7 +505,7 @@ get_property (GObject *object,
g_value_set_pointer (value, self->format);
break;
- case PROP_INVERSE_JACOBIAN:
+ case PROP_SCALE:
g_value_set_pointer (value, self->inverse_jacobian);
break;
@@ -527,7 +532,7 @@ set_property (GObject *object,
self->format = g_value_get_pointer (value);
break;
- case PROP_INVERSE_JACOBIAN:
+ case PROP_SCALE:
self->inverse_jacobian = g_value_get_pointer (value);
break;
@@ -591,8 +596,8 @@ gegl_sampler_type_from_interpolation (GeglInterpolation interpolation)
}
}
-void gegl_sampler_set_inverse_jacobian (GeglSampler *self,
- GeglMatrix2 *inverse_jacobian)
+void gegl_sampler_set_scale (GeglSampler *self,
+ GeglMatrix2 *scale)
{
- self->inverse_jacobian = inverse_jacobian;
+ self->inverse_jacobian = scale;
}
diff --git a/gegl/buffer/gegl-sampler.h b/gegl/buffer/gegl-sampler.h
index 0568e6a..65e2189 100644
--- a/gegl/buffer/gegl-sampler.h
+++ b/gegl/buffer/gegl-sampler.h
@@ -48,7 +48,10 @@ struct _GeglSampler
GeglRectangle context_rect[GEGL_SAMPLER_MIPMAP_LEVELS];
gpointer sampler_buffer[GEGL_SAMPLER_MIPMAP_LEVELS];
GeglRectangle sampler_rectangle[GEGL_SAMPLER_MIPMAP_LEVELS];
- GeglMatrix2 *inverse_jacobian;
+ GeglMatrix2 *inverse_jacobian; /* scale - which could be the inverse
+ inverse jacobian matrix or some other
+ approximation of the extent of the region
+ being sampled. */
gdouble x; /* mirrors the currently requested */
gdouble y; /* coordinates in the instance */
};
@@ -73,14 +76,13 @@ void gegl_sampler_prepare (GeglSampler *self);
void gegl_sampler_set_buffer (GeglSampler *self,
GeglBuffer *buffer);
+void gegl_sampler_set_scale (GeglSampler *self,
+ GeglMatrix2 *scale);
void gegl_sampler_get (GeglSampler *self,
gdouble x,
gdouble y,
void *output);
-void gegl_sampler_set_inverse_jacobian (GeglSampler *self,
- GeglMatrix2 *inverse_jacobian);
-
gfloat * gegl_sampler_get_from_buffer (GeglSampler *sampler,
gint x,
gint y);
diff --git a/gegl/gegl-plugin.h b/gegl/gegl-plugin.h
index 68881ff..3fec394 100644
--- a/gegl/gegl-plugin.h
+++ b/gegl/gegl-plugin.h
@@ -96,25 +96,27 @@ const gchar * gegl_extension_handler_get_saver (const gchar *extensi
* transform this is massive computational overhead that can
* be skipped by passing NULL to the sampler.
*
- * #define inverse_map(x,y,dx,dy) { dx=x; dy=y; }
+ * #define gegl_unmap(x,y,dx,dy) { dx=x; dy=y; }
*
- * gegl_compute_jacobian(matrix, x, y);
- * inverse_map(x,y,sample_x,sample_y);
+ * gegl_sampler_compute_scale (scale, x, y);
+ * gegl_unmap(x,y,sample_x,sample_y);
+ * gegl_buffer_sample (buffer, sample_x, sample_y, scale, dest, format,
+ * GEGL_INTERPOLATION_LOHALO);
*
- * #undef inverse_map // IMPORTANT undefine map macro
+ * #undef gegl_unmap // IMPORTANT undefine map macro
*/
-#define gegl_compute_inverse_jacobian(matrix, x, y) \
- { \
- float ax, ay, bx, by; \
- inverse_map(x + 0.5, y, ax, ay); \
- inverse_map(x - 0.5, y, bx, by); \
- matrix.coeff[0][0] = ax - bx; \
- matrix.coeff[1][0] = ay - by; \
- inverse_map(x, y + 0.5, ax, ay); \
- inverse_map(x, y - 0.5, bx, by); \
- matrix.coeff[0][1] = ax - bx; \
- matrix.coeff[1][1] = ay - by; \
- }
+#define gegl_sampler_compute_scale (matrix, x, y) \
+{ \
+ float ax, ay, bx, by; \
+ gegl_inverse_map(x + 0.5, y, ax, ay); \
+ gegl_inverse_map(x - 0.5, y, bx, by); \
+ matrix.coeff[0][0] = ax - bx; \
+ matrix.coeff[1][0] = ay - by; \
+ gegl_inverse_map(x, y + 0.5, ax, ay); \
+ gegl_inverse_map(x, y - 0.5, bx, by); \
+ matrix.coeff[0][1] = ax - bx; \
+ matrix.coeff[1][1] = ay - by; \
+}
#include <glib-object.h>
#include <babl/babl.h>
diff --git a/gegl/gegl-utils.h b/gegl/gegl-utils.h
index 3a56b99..f22db42 100644
--- a/gegl/gegl-utils.h
+++ b/gegl/gegl-utils.h
@@ -22,9 +22,6 @@
G_BEGIN_DECLS
-
-
-
/***
* GeglRectangle:
*
diff --git a/operations/workshop/fractal-trace.c b/operations/workshop/fractal-trace.c
index 22436f3..e5f3958 100644
--- a/operations/workshop/fractal-trace.c
+++ b/operations/workshop/fractal-trace.c
@@ -116,11 +116,13 @@ fractaltrace (GeglBuffer *input,
BackgroundType background_type,
Babl *format)
{
- GeglMatrix2 inverse_jacobian;
- gint x, i, offset;
- gdouble scale_x, scale_y;
- gdouble bailout2;
- gfloat dest[4];
+ GeglMatrix2 scale; /* a matrix indicating scaling factors around the
+ current center pixel.
+ */
+ gint x, i, offset;
+ gdouble scale_x, scale_y;
+ gdouble bailout2;
+ gfloat dest[4];
scale_x = (o->X2 - o->X1) / picture->width;
scale_y = (o->Y2 - o->Y1) / picture->height;
@@ -138,7 +140,7 @@ fractaltrace (GeglBuffer *input,
switch (fractal_type)
{
case FRACTAL_TYPE_JULIA:
-#define inverse_map(u,v,ud,vd) {\
+#define gegl_inverse_map(u,v,ud,vd) {\
gdouble rx, ry;\
cx = o->X1 + ((u) - picture->x) * scale_x; \
cy = o->Y1 + ((v) - picture->y) * scale_y; \
@@ -146,13 +148,13 @@ fractaltrace (GeglBuffer *input,
ud = (rx - o->X1) / scale_x + picture->x;\
vd = (ry - o->Y1) / scale_y + picture->y;\
}
- gegl_compute_inverse_jacobian (inverse_jacobian, x, y);
- inverse_map(x,y,px,py);
-#undef inverse_map
+ gegl_sampler_compute_scale (scale, x, y);
+ gegl_inverse_map(x,y,px,py);
+#undef gegl_inverse_map
break;
case FRACTAL_TYPE_MANDELBROT:
-#define inverse_map(u,v,ud,vd) {\
+#define gegl_inverse_map(u,v,ud,vd) {\
gdouble rx, ry;\
cx = o->X1 + ((u) - picture->x) * scale_x; \
cy = o->Y1 + ((v) - picture->y) * scale_y; \
@@ -160,9 +162,9 @@ fractaltrace (GeglBuffer *input,
ud = (rx - o->X1) / scale_x + picture->x;\
vd = (ry - o->Y1) / scale_y + picture->y;\
}
- gegl_compute_inverse_jacobian (inverse_jacobian, x, y);
- inverse_map(x,y,px,py);
-#undef inverse_map
+ gegl_compute_inverse_jacobian (scale, x, y);
+ gegl_inverse_map(x,y,px,py);
+#undef gegl_inverse_map
break;
default:
@@ -171,7 +173,7 @@ fractaltrace (GeglBuffer *input,
if (0 <= px && px < picture->width && 0 <= py && py < picture->height)
{
- gegl_buffer_sample2 (input, px, py, &inverse_jacobian, dest, format,
+ gegl_buffer_sample2 (input, px, py, &scale, dest, format,
GEGL_INTERPOLATION_LOHALO);
}
else
@@ -204,7 +206,7 @@ fractaltrace (GeglBuffer *input,
py = picture->height - 1.0;
}
- gegl_buffer_sample2 (input, px, py, &inverse_jacobian, dest, format,
+ gegl_buffer_sample2 (input, px, py, &scale, dest, format,
GEGL_INTERPOLATION_LOHALO);
break;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]