[gegl] sampler: add a macro that inlines trampline of gegl_sampler_get
- From: Ãyvind KolÃs <ok src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gegl] sampler: add a macro that inlines trampline of gegl_sampler_get
- Date: Sun, 3 Jul 2011 17:55:32 +0000 (UTC)
commit 78ceb5769bd7e501be38ecb0225efe03acf4dfe0
Author: Ãyvind KolÃs <pippin gimp org>
Date: Sun Jul 3 18:48:05 2011 +0100
sampler: add a macro that inlines trampline of gegl_sampler_get
Added a macro that implements an inlineable variant of gegl_sampler_get
gegl_sampler_get still exists as a function bindable by bindings.
gegl/buffer/gegl-buffer-private.h | 1 -
gegl/buffer/gegl-buffer.h | 3 +++
gegl/buffer/gegl-sampler.c | 6 ++++++
gegl/buffer/gegl-sampler.h | 20 ++++++++++----------
gegl/gegl-c.c | 1 +
gegl/gegl-plugin.h | 14 ++++++++++++++
operations/affine/affine.c | 20 +++++++++++---------
7 files changed, 45 insertions(+), 20 deletions(-)
---
diff --git a/gegl/buffer/gegl-buffer-private.h b/gegl/buffer/gegl-buffer-private.h
index 23d721e..2966c2b 100644
--- a/gegl/buffer/gegl-buffer-private.h
+++ b/gegl/buffer/gegl-buffer-private.h
@@ -22,7 +22,6 @@
#include "gegl-buffer-types.h"
#include "gegl-buffer.h"
-#include "gegl-sampler.h"
#include "gegl-tile-handler.h"
#include "gegl-buffer-iterator.h"
diff --git a/gegl/buffer/gegl-buffer.h b/gegl/buffer/gegl-buffer.h
index 9b3bb84..9010c30 100644
--- a/gegl/buffer/gegl-buffer.h
+++ b/gegl/buffer/gegl-buffer.h
@@ -397,6 +397,9 @@ void gegl_sampler_get (GeglSampler *sampler,
GeglMatrix2 *scale,
void *output);
+const GeglRectangle*
+gegl_sampler_get_context_rect (GeglSampler *sampler);
+
/**
* gegl_buffer_linear_new:
* @extent: dimensions of buffer.
diff --git a/gegl/buffer/gegl-sampler.c b/gegl/buffer/gegl-sampler.c
index 6fe3f6e..47ce92e 100644
--- a/gegl/buffer/gegl-sampler.c
+++ b/gegl/buffer/gegl-sampler.c
@@ -590,3 +590,9 @@ gegl_buffer_sampler_new (GeglBuffer *buffer,
gegl_sampler_prepare (sampler);
return sampler;
}
+
+const GeglRectangle*
+gegl_sampler_get_context_rect (GeglSampler *sampler)
+{
+ return &(sampler->context_rect);
+}
diff --git a/gegl/buffer/gegl-sampler.h b/gegl/buffer/gegl-sampler.h
index 1fd2a67..1e5b5f7 100644
--- a/gegl/buffer/gegl-sampler.h
+++ b/gegl/buffer/gegl-sampler.h
@@ -37,7 +37,16 @@ typedef struct _GeglSamplerClass GeglSamplerClass;
struct _GeglSampler
{
- GObject parent_instance;
+ GObject parent_instance;
+ void (* get) (GeglSampler *self,
+ gdouble x,
+ gdouble y,
+ GeglMatrix2 *scale,
+ void *output);
+ /* we cache the getter in the instance, (being able to return the
+ function pointer itself and cache it outside the calling loop
+ would be even quicker.
+ */
/*< private >*/
GeglBuffer *buffer;
@@ -50,15 +59,6 @@ struct _GeglSampler
gdouble x; /* mirrors the currently requested */
gdouble y; /* coordinates in the instance */
- /* we cache the getter in the instance, (being able to return the
- function pointer itself and cache it outside the calling loop
- would be even quicker.
- */
- void (* get) (GeglSampler *self,
- gdouble x,
- gdouble y,
- GeglMatrix2 *scale,
- void *output);
};
struct _GeglSamplerClass
diff --git a/gegl/gegl-c.c b/gegl/gegl-c.c
index 3d94ca6..c383e50 100644
--- a/gegl/gegl-c.c
+++ b/gegl/gegl-c.c
@@ -19,6 +19,7 @@
#include "config.h"
#include <gegl.h>
#include <gegl-plugin.h>
+#undef gegl_sampler_get
#include <glib/gprintf.h>
#include <gobject/gvaluecollector.h>
#include <stdarg.h>
diff --git a/gegl/gegl-plugin.h b/gegl/gegl-plugin.h
index 92938f9..cad2b73 100644
--- a/gegl/gegl-plugin.h
+++ b/gegl/gegl-plugin.h
@@ -118,6 +118,20 @@ const gchar * gegl_extension_handler_get_saver (const gchar *extensi
matrix.coeff[1][1] = ay - by; \
}
+typedef struct
+{
+ GObject parent_instance;
+ void (* get) (GeglSampler *self,
+ gdouble x,
+ gdouble y,
+ GeglMatrix2 *scale,
+ void *output);
+} SamplerMock;
+
+
+#define gegl_sampler_get(sampler,x,y,scale,dest) \
+ ((SamplerMock*)(sampler))->get((sampler),(x),(y),(scale),(dest))
+
#include <glib-object.h>
#include <babl/babl.h>
#include <operation/gegl-operation.h>
diff --git a/operations/affine/affine.c b/operations/affine/affine.c
index 7516e6d..b70fe12 100644
--- a/operations/affine/affine.c
+++ b/operations/affine/affine.c
@@ -447,7 +447,7 @@ gegl_affine_get_bounding_box (GeglOperation *op)
sampler = gegl_buffer_sampler_new (NULL, babl_format("RaGaBaA float"),
gegl_sampler_type_from_string (affine->filter));
- context_rect = sampler->context_rect[0];
+ context_rect = *gegl_sampler_get_context_rect (sampler);
g_object_unref (sampler);
if (gegl_operation_source_get_bounding_box (op, "input"))
@@ -534,7 +534,7 @@ gegl_affine_get_required_for_output (GeglOperation *op,
requested_rect = *region;
sampler = gegl_buffer_sampler_new (NULL, babl_format("RaGaBaA float"),
gegl_sampler_type_from_string (affine->filter));
- context_rect = sampler->context_rect[0];
+ context_rect = *gegl_sampler_get_context_rect (sampler);
g_object_unref (sampler);
gegl_affine_create_composite_matrix (affine, &inverse);
@@ -586,7 +586,7 @@ gegl_affine_get_invalidated_by_change (GeglOperation *op,
sampler = gegl_buffer_sampler_new (NULL, babl_format("RaGaBaA float"),
gegl_sampler_type_from_string (affine->filter));
- context_rect = sampler->context_rect[0];
+ context_rect = *gegl_sampler_get_context_rect (sampler);
g_object_unref (sampler);
gegl_affine_create_matrix (affine, &matrix);
@@ -875,6 +875,7 @@ gegl_affine_process (GeglOperation *operation,
{
GeglRectangle src_rect;
GeglSampler *sampler;
+ GeglRectangle context_rect;
input = gegl_operation_context_get_source (context, "input");
if (!input)
@@ -890,9 +891,10 @@ gegl_affine_process (GeglOperation *operation,
sampler = gegl_buffer_sampler_new (input, babl_format("RaGaBaA float"),
gegl_sampler_type_from_string (affine->filter));
+ context_rect = *gegl_sampler_get_context_rect (sampler);
- src_rect.width -= sampler->context_rect[0].width;
- src_rect.height -= sampler->context_rect[0].height;
+ src_rect.width -= context_rect.width;
+ src_rect.height -= context_rect.height;
gegl_affine_fast_reflect_x (output, input, result, &src_rect);
@@ -903,6 +905,7 @@ gegl_affine_process (GeglOperation *operation,
{
GeglRectangle src_rect;
GeglSampler *sampler;
+ GeglRectangle context_rect;
input = gegl_operation_context_get_source (context, "input");
if (!input)
@@ -918,9 +921,10 @@ gegl_affine_process (GeglOperation *operation,
sampler = gegl_buffer_sampler_new (input, babl_format("RaGaBaA float"),
gegl_sampler_type_from_string (affine->filter));
+ context_rect = *gegl_sampler_get_context_rect (sampler);
- src_rect.width -= sampler->context_rect[0].width;
- src_rect.height -= sampler->context_rect[0].height;
+ src_rect.width -= context_rect.width;
+ src_rect.height -= context_rect.height;
gegl_affine_fast_reflect_y (output, input, result, &src_rect);
@@ -938,8 +942,6 @@ gegl_affine_process (GeglOperation *operation,
sampler = gegl_buffer_sampler_new (input, babl_format("RaGaBaA float"),
gegl_sampler_type_from_string (affine->filter));
affine_generic (output, input, &matrix, sampler);
- g_object_unref(sampler->buffer);
- sampler->buffer = NULL;
g_object_unref (sampler);
if (input != NULL)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]