[gegl] Rename the exported seamless cloning api (Begin with GeglSc, not just Sc)
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gegl] Rename the exported seamless cloning api (Begin with GeglSc, not just Sc)
- Date: Tue, 14 May 2013 22:19:48 +0000 (UTC)
commit 27d155f98960b2bcc00d4b90fa5fd0ed3e0c61c0
Author: Barak Itkin <lightningismyname gmail com>
Date: Sat Dec 8 15:21:54 2012 +0200
Rename the exported seamless cloning api (Begin with GeglSc, not just Sc)
operations/common/seamless-clone/sc-common.h | 32 +-
.../common/seamless-clone/sc-context-private.h | 26 +-
operations/common/seamless-clone/sc-context.c | 340 ++++++++++----------
operations/common/seamless-clone/sc-context.h | 48 ++--
operations/common/seamless-clone/sc-outline.c | 142 ++++----
operations/common/seamless-clone/sc-outline.h | 110 ++++----
operations/common/seamless-clone/sc-sample.c | 92 +++---
operations/common/seamless-clone/sc-sample.h | 26 +-
operations/common/seamless-clone/seamless-clone.c | 34 +-
9 files changed, 426 insertions(+), 424 deletions(-)
---
diff --git a/operations/common/seamless-clone/sc-common.h b/operations/common/seamless-clone/sc-common.h
index 12f9b86..f2ae371 100644
--- a/operations/common/seamless-clone/sc-common.h
+++ b/operations/common/seamless-clone/sc-common.h
@@ -29,39 +29,39 @@
* ALPHA CHANNEL IS ALWAYS LAST. DO NOT CHANGE THIS WITHOUT UPDATING
* THE REST OF THE CODE!
*/
-#define SC_COLOR_BABL_NAME "R'G'B'A float"
+#define GEGL_SC_COLOR_BABL_NAME "R'G'B'A float"
/**
* The type used for individual color channels. Note that this should
* never be used directly - you must get a pointer to this type using
* the allocation macros below!
*/
-typedef gfloat ScColor;
+typedef gfloat GeglScColor;
/**
* The amount of channels per color
*/
-#define SC_COLORA_CHANNEL_COUNT 4
-#define SC_COLOR_CHANNEL_COUNT ((SC_COLORA_CHANNEL_COUNT) - 1)
+#define GEGL_SC_COLORA_CHANNEL_COUNT 4
+#define GEGL_SC_COLOR_CHANNEL_COUNT ((GEGL_SC_COLORA_CHANNEL_COUNT) - 1)
-#define sc_color_new() (g_new (ScColor, SC_COLORA_CHANNEL_COUNT))
-#define sc_color_free(mem) (g_free (mem))
+#define gegl_sc_color_new() (g_new (GeglScColor, GEGL_SC_COLORA_CHANNEL_COUNT))
+#define gegl_sc_color_free(mem) (g_free (mem))
/**
* The index of the alpha channel in the color
*/
-#define SC_COLOR_ALPHA_INDEX SC_COLOR_CHANNEL_COUNT
+#define GEGL_SC_COLOR_ALPHA_INDEX GEGL_SC_COLOR_CHANNEL_COUNT
/**
* Apply a macro once for each non-alpha color channel, with the
* channel index as an input
*/
-#define sc_color_process() \
-G_STMT_START \
- { \
- sc_color_expr(0); \
- sc_color_expr(1); \
- sc_color_expr(2); \
- } \
+#define gegl_sc_color_process() \
+G_STMT_START \
+ { \
+ gegl_sc_color_expr(0); \
+ gegl_sc_color_expr(1); \
+ gegl_sc_color_expr(2); \
+ } \
G_STMT_END
typedef struct {
@@ -75,9 +75,9 @@ typedef struct {
gint yoff;
gboolean render_bg;
-} ScRenderInfo;
+} GeglScRenderInfo;
-#define sc_point_in_rectangle(px, py, rect) \
+#define gegl_sc_point_in_rectangle(px, py, rect) \
( ((px) >= (rect)->x) \
&& ((py) >= (rect)->y) \
&& ((px) < (rect)->x + (rect)->width) \
diff --git a/operations/common/seamless-clone/sc-context-private.h
b/operations/common/seamless-clone/sc-context-private.h
index 7aeaa0c..b89cf4b 100644
--- a/operations/common/seamless-clone/sc-context-private.h
+++ b/operations/common/seamless-clone/sc-context-private.h
@@ -29,25 +29,25 @@
typedef struct
{
- GHashTable *pt2col;
- gboolean is_valid;
-} ScRenderCache;
+ GHashTable *pt2col;
+ gboolean is_valid;
+} GeglScRenderCache;
-struct _ScContext
+struct _GeglScContext
{
- ScOutline *outline;
- GeglRectangle mesh_bounds;
- P2trMesh *mesh;
+ GeglScOutline *outline;
+ GeglRectangle mesh_bounds;
+ P2trMesh *mesh;
- ScMeshSampling *sampling;
+ GeglScMeshSampling *sampling;
- gboolean cache_uvt;
- GeglBuffer *uvt;
+ gboolean cache_uvt;
+ GeglBuffer *uvt;
- ScRenderCache *render_cache;
+ GeglScRenderCache *render_cache;
};
-#define SC_BABL_UVT_TYPE (babl_type_new ("uvt", "bits", sizeof (P2trUVT) * 8, NULL))
-#define SC_BABL_UVT_FORMAT (babl_format_n (SC_BABL_UVT_TYPE, 1))
+#define GEGL_SC_BABL_UVT_TYPE (babl_type_new ("uvt", "bits", sizeof (P2trUVT) * 8, NULL))
+#define GEGL_SC_BABL_UVT_FORMAT (babl_format_n (GEGL_SC_BABL_UVT_TYPE, 1))
#endif
diff --git a/operations/common/seamless-clone/sc-context.c b/operations/common/seamless-clone/sc-context.c
index 83ed022..0ddd30a 100644
--- a/operations/common/seamless-clone/sc-context.c
+++ b/operations/common/seamless-clone/sc-context.c
@@ -27,57 +27,57 @@
#include "sc-common.h"
#include "sc-sample.h"
-static ScOutline* sc_context_create_outline (GeglBuffer *input,
- const GeglRectangle *roi,
- gdouble threshold,
- ScCreationError *error);
+static GeglScOutline* gegl_sc_context_create_outline (GeglBuffer *input,
+ const GeglRectangle *roi,
+ gdouble threshold,
+ GeglScCreationError *error);
-static P2trMesh* sc_make_fine_mesh (ScOutline *outline,
- GeglRectangle *mesh_bounds,
- int max_refine_steps);
+static P2trMesh* gegl_sc_make_fine_mesh (GeglScOutline *outline,
+ GeglRectangle *mesh_bounds,
+ int max_refine_steps);
-static void sc_context_update_from_outline (ScContext *self,
- ScOutline *outline);
+static void gegl_sc_context_update_from_outline (GeglScContext *self,
+ GeglScOutline *outline);
-static gboolean sc_context_render_cache_pt2col_update (ScContext *context,
- ScRenderInfo *info);
+static gboolean gegl_sc_context_render_cache_pt2col_update (GeglScContext *context,
+ GeglScRenderInfo *info);
-static gboolean sc_context_sample_color_difference (ScRenderInfo *info,
- gdouble x,
- gdouble y,
- ScColor *dest);
+static gboolean gegl_sc_context_sample_color_difference (GeglScRenderInfo *info,
+ gdouble x,
+ gdouble y,
+ GeglScColor *dest);
-static gboolean sc_context_sample_point (ScRenderInfo *info,
- ScSampleList *sl,
- P2trPoint *point,
- ScColor *dest);
+static gboolean gegl_sc_context_sample_point (GeglScRenderInfo *info,
+ GeglScSampleList *sl,
+ P2trPoint *point,
+ GeglScColor *dest);
-static void sc_context_render_cache_pt2col_free (ScContext *context);
+static void gegl_sc_context_render_cache_pt2col_free (GeglScContext *context);
-static GeglBuffer* sc_compute_uvt_cache (P2trMesh *mesh,
- const GeglRectangle *area);
+static GeglBuffer* gegl_sc_compute_uvt_cache (P2trMesh *mesh,
+ const GeglRectangle *area);
-static void sc_point_to_color_func (P2trPoint *point,
- gfloat *dest,
- gpointer pt2col_p);
+static void gegl_sc_point_to_color_func (P2trPoint *point,
+ gfloat *dest,
+ gpointer pt2col_p);
-static void sc_context_render_cache_free (ScContext *context);
+static void gegl_sc_context_render_cache_free (GeglScContext *context);
-ScContext*
-sc_context_new (GeglBuffer *input,
- const GeglRectangle *roi,
- gdouble threshold,
- ScCreationError *error)
+GeglScContext*
+gegl_sc_context_new (GeglBuffer *input,
+ const GeglRectangle *roi,
+ gdouble threshold,
+ GeglScCreationError *error)
{
- ScOutline *outline;
- ScContext *self;
+ GeglScContext *self;
- outline = sc_context_create_outline (input, roi, threshold, error);
+ GeglScOutline *outline
+ = gegl_sc_context_create_outline (input, roi, threshold, error);
if (outline == NULL)
return NULL;
- self = g_slice_new (ScContext);
+ self = g_slice_new (GeglScContext);
self->outline = NULL;
self->mesh = NULL;
self->sampling = NULL;
@@ -85,55 +85,56 @@ sc_context_new (GeglBuffer *input,
self->uvt = NULL;
self->render_cache = NULL;
- sc_context_update_from_outline (self, outline);
+ gegl_sc_context_update_from_outline (self, outline);
return self;
}
gboolean
-sc_context_update (ScContext *self,
- GeglBuffer *input,
- const GeglRectangle *roi,
- gdouble threshold,
- ScCreationError *error)
+gegl_sc_context_update (GeglScContext *self,
+ GeglBuffer *input,
+ const GeglRectangle *roi,
+ gdouble threshold,
+ GeglScCreationError *error)
{
- ScOutline *outline = sc_context_create_outline (input, roi,
- threshold, error);
+ GeglScOutline *outline
+ = gegl_sc_context_create_outline (input, roi, threshold, error);
if (outline == NULL)
{
return FALSE;
}
- else if (sc_outline_equals (outline, self->outline))
+ else if (gegl_sc_outline_equals (outline, self->outline))
{
- sc_outline_free (outline);
+ gegl_sc_outline_free (outline);
return TRUE;
}
else
{
- sc_context_update_from_outline (self, outline);
+ gegl_sc_context_update_from_outline (self, outline);
return TRUE;
}
}
-static ScOutline*
-sc_context_create_outline (GeglBuffer *input,
- const GeglRectangle *roi,
- gdouble threshold,
- ScCreationError *error)
+static GeglScOutline*
+gegl_sc_context_create_outline (GeglBuffer *input,
+ const GeglRectangle *roi,
+ gdouble threshold,
+ GeglScCreationError *error)
{
- gboolean ignored_islands = FALSE;
- ScOutline *outline = sc_outline_find (roi, input, threshold, &ignored_islands);
- guint length = sc_outline_length (outline);
+ gboolean ignored_islands = FALSE;
+ GeglScOutline *outline
+ = gegl_sc_outline_find (roi, input, threshold, &ignored_islands);
+ guint length = gegl_sc_outline_length (outline);
- *error = SC_CREATION_ERROR_NONE;
+ *error = GEGL_SC_CREATION_ERROR_NONE;
if (length == 0)
{
if (ignored_islands)
- *error = SC_CREATION_ERROR_TOO_SMALL;
+ *error = GEGL_SC_CREATION_ERROR_TOO_SMALL;
else
- *error = SC_CREATION_ERROR_EMPTY;
+ *error = GEGL_SC_CREATION_ERROR_EMPTY;
}
/* In order to create a triangular mesh, we need at least 3 vertices.
* Also, if we don't have 3 vertices then the area is so small that it
@@ -141,17 +142,18 @@ sc_context_create_outline (GeglBuffer *input,
*/
else if (length < 3)
{
- *error = SC_CREATION_ERROR_TOO_SMALL;
+ *error = GEGL_SC_CREATION_ERROR_TOO_SMALL;
}
else if (ignored_islands ||
- ! sc_outline_check_if_single (roi, input, threshold, outline))
+ ! gegl_sc_outline_check_if_single (roi, input,
+ threshold, outline))
{
- *error = SC_CREATION_ERROR_HOLED_OR_SPLIT;
+ *error = GEGL_SC_CREATION_ERROR_HOLED_OR_SPLIT;
}
- if (*error != SC_CREATION_ERROR_NONE)
+ if (*error != GEGL_SC_CREATION_ERROR_NONE)
{
- sc_outline_free (outline);
+ gegl_sc_outline_free (outline);
}
return outline;
@@ -159,8 +161,8 @@ sc_context_create_outline (GeglBuffer *input,
static void
-sc_context_update_from_outline (ScContext *self,
- ScOutline *outline)
+gegl_sc_context_update_from_outline (GeglScContext *self,
+ GeglScOutline *outline)
{
guint outline_length;
@@ -169,7 +171,7 @@ sc_context_update_from_outline (ScContext *self,
if (self->render_cache != NULL)
{
- sc_context_render_cache_free (self);
+ gegl_sc_context_render_cache_free (self);
}
if (self->uvt != NULL)
@@ -180,7 +182,7 @@ sc_context_update_from_outline (ScContext *self,
if (self->sampling != NULL)
{
- sc_mesh_sampling_free (self->sampling);
+ gegl_sc_mesh_sampling_free (self->sampling);
self->sampling = NULL;
}
@@ -192,31 +194,31 @@ sc_context_update_from_outline (ScContext *self,
if (self->outline != NULL)
{
- sc_outline_free (self->outline);
+ gegl_sc_outline_free (self->outline);
self->outline = NULL;
}
- outline_length = sc_outline_length (outline);
+ outline_length = gegl_sc_outline_length (outline);
self->outline = outline;
- self->mesh = sc_make_fine_mesh (self->outline,
- &self->mesh_bounds,
- 5 * outline_length);
- self->sampling = sc_mesh_sampling_compute (self->outline,
- self->mesh);
+ self->mesh = gegl_sc_make_fine_mesh (self->outline,
+ &self->mesh_bounds,
+ 5 * outline_length);
+ self->sampling = gegl_sc_mesh_sampling_compute (self->outline,
+ self->mesh);
}
/**
- * sc_make_fine_mesh:
- * @outline: An ScOutline object describing the PSLG of the mesh
+ * gegl_sc_make_fine_mesh:
+ * @outline: An GeglScOutline object describing the PSLG of the mesh
* @mesh_bounds: A rectangle in which the bounds of the mesh should be
* stored
*/
static P2trMesh*
-sc_make_fine_mesh (ScOutline *outline,
- GeglRectangle *mesh_bounds,
- int max_refine_steps)
+gegl_sc_make_fine_mesh (GeglScOutline *outline,
+ GeglRectangle *mesh_bounds,
+ int max_refine_steps)
{
GPtrArray *realOutline = (GPtrArray*) outline;
gint i, N = realOutline->len;
@@ -232,9 +234,9 @@ sc_make_fine_mesh (ScOutline *outline,
for (i = 0; i < N; i++)
{
- ScPoint *pt = (ScPoint*) g_ptr_array_index (realOutline, i);
- gdouble realX = pt->x + SC_DIRECTION_XOFFSET (pt->outside_normal, 0.25);
- gdouble realY = pt->y + SC_DIRECTION_YOFFSET (pt->outside_normal, 0.25);
+ GeglScPoint *pt = (GeglScPoint*) g_ptr_array_index (realOutline, i);
+ gdouble realX = pt->x + GEGL_SC_DIRECTION_XOFFSET (pt->outside_normal, 0.25);
+ gdouble realY = pt->y + GEGL_SC_DIRECTION_YOFFSET (pt->outside_normal, 0.25);
min_x = MIN (realX, min_x);
min_y = MIN (realY, min_y);
@@ -276,23 +278,23 @@ sc_make_fine_mesh (ScOutline *outline,
}
gboolean
-sc_context_prepare_render (ScContext *context,
- ScRenderInfo *info)
+gegl_sc_context_prepare_render (GeglScContext *context,
+ GeglScRenderInfo *info)
{
if (context->render_cache == NULL)
{
- context->render_cache = g_slice_new (ScRenderCache);
+ context->render_cache = g_slice_new (GeglScRenderCache);
context->render_cache->pt2col = NULL;
context->render_cache->is_valid = FALSE;
}
context->render_cache->is_valid = FALSE;
- if (! sc_context_render_cache_pt2col_update (context, info))
+ if (! gegl_sc_context_render_cache_pt2col_update (context, info))
return FALSE;
if (context->cache_uvt && context->uvt == NULL)
- context->uvt = sc_compute_uvt_cache (context->mesh, &info->fg_rect);
+ context->uvt = gegl_sc_compute_uvt_cache (context->mesh, &info->fg_rect);
context->render_cache->is_valid = TRUE;
@@ -302,21 +304,21 @@ sc_context_prepare_render (ScContext *context,
/**
* Compute the color assigned to all the points in the color difference
* mesh. If the color can not be computed for one or more points (due to
- * any of the reasons documented in sc_context_sample_point), this
+ * any of the reasons documented in gegl_sc_context_sample_point), this
* function will return FALSE - meaning a failure.
* IT IS THE CALLERS RESPONSIBILITY TO DETECT SUCH A STATE AND STOP THE
* RENDERING PROCESS!
*/
static gboolean
-sc_context_render_cache_pt2col_update (ScContext *context,
- ScRenderInfo *info)
+gegl_sc_context_render_cache_pt2col_update (GeglScContext *context,
+ GeglScRenderInfo *info)
{
GHashTableIter iter;
- ScColor *color_current = NULL;
- P2trPoint *pt = NULL;
- ScSampleList *sl = NULL;
- GHashTable *pt2col;
+ GeglScColor *color_current = NULL;
+ P2trPoint *pt = NULL;
+ GeglScSampleList *sl = NULL;
+ GHashTable *pt2col;
/* If this is the first time we compute the colors, we need to
* allocate the color map */
@@ -350,7 +352,7 @@ sc_context_render_cache_pt2col_update (ScContext *context,
if (! g_hash_table_lookup_extended (pt2col, pt, NULL,
(gpointer*) &color_current))
{
- color_current = sc_color_new ();
+ color_current = gegl_sc_color_new ();
g_hash_table_insert (pt2col,
p2tr_point_ref (pt),
color_current);
@@ -365,7 +367,7 @@ sc_context_render_cache_pt2col_update (ScContext *context,
* after allocating/reffing but before inserting, we would have a
* memory leak!
*/
- if (! sc_context_sample_point (info, sl, pt, color_current))
+ if (! gegl_sc_context_sample_point (info, sl, pt, color_current))
{
return FALSE;
}
@@ -384,7 +386,7 @@ sc_context_render_cache_pt2col_update (ScContext *context,
/* See if we have a sampling entry for this point? */
if (! g_hash_table_lookup_extended (context->sampling, pt, NULL, NULL))
{
- sc_color_free (color_current);
+ gegl_sc_color_free (color_current);
g_hash_table_iter_remove (&iter);
p2tr_point_unref (pt);
}
@@ -399,18 +401,18 @@ sc_context_render_cache_pt2col_update (ScContext *context,
* at a given point. This function returns FALSE if the difference can
* not be computed since the background buffer does not contain the
* point. Otherwise, the function returns TRUE.
- * THIS FUNCTION USES SC_COLORA_CHANNEL_COUNT CHANNELS! (WITH ALPHA!)
+ * THIS FUNCTION USES GEGL_SC_COLORA_CHANNEL_COUNT CHANNELS! (WITH ALPHA!)
*/
static gboolean
-sc_context_sample_color_difference (ScRenderInfo *info,
- gdouble x,
- gdouble y,
- ScColor *dest)
+gegl_sc_context_sample_color_difference (GeglScRenderInfo *info,
+ gdouble x,
+ gdouble y,
+ GeglScColor *dest)
{
- const Babl *format = babl_format (SC_COLOR_BABL_NAME);
+ const Babl *format = babl_format (GEGL_SC_COLOR_BABL_NAME);
- ScColor fg_c[SC_COLORA_CHANNEL_COUNT];
- ScColor bg_c[SC_COLORA_CHANNEL_COUNT];
+ GeglScColor fg_c[GEGL_SC_COLORA_CHANNEL_COUNT];
+ GeglScColor bg_c[GEGL_SC_COLORA_CHANNEL_COUNT];
/* If the outline point is outside the background, then we can't
* compute a propper difference there. So, don't add it to the
@@ -425,9 +427,9 @@ sc_context_sample_color_difference (ScRenderInfo *info,
* location in background coordinates is the following:
* (pt->x + info->x, pt->y + info->y).
*/
- if (! sc_point_in_rectangle (x + info->xoff,
- y + info->yoff,
- &info->bg_rect))
+ if (! gegl_sc_point_in_rectangle (x + info->xoff,
+ y + info->yoff,
+ &info->bg_rect))
{
return FALSE;
}
@@ -443,10 +445,10 @@ sc_context_sample_color_difference (ScRenderInfo *info,
NULL, bg_c, format,
GEGL_SAMPLER_NEAREST, GEGL_ABYSS_NONE);
-#define sc_color_expr(I) dest[I] = (bg_c[I] - fg_c[I])
- sc_color_process();
-#undef sc_color_expr
- dest[SC_COLOR_ALPHA_INDEX] = 1;
+#define gegl_sc_color_expr(I) dest[I] = (bg_c[I] - fg_c[I])
+ gegl_sc_color_process();
+#undef gegl_sc_color_expr
+ dest[GEGL_SC_COLOR_ALPHA_INDEX] = 1;
return TRUE;
}
@@ -459,15 +461,15 @@ sc_context_sample_color_difference (ScRenderInfo *info,
* RENDERING PROCESS!
*/
static gboolean
-sc_context_sample_point (ScRenderInfo *info,
- ScSampleList *sl,
- P2trPoint *point,
- ScColor *dest)
+gegl_sc_context_sample_point (GeglScRenderInfo *info,
+ GeglScSampleList *sl,
+ P2trPoint *point,
+ GeglScColor *dest)
{
/* If this is a direct sample, we can easily finish */
if (sl->direct_sample)
{
- return sc_context_sample_color_difference (info, point->c.x, point->c.y, dest);
+ return gegl_sc_context_sample_color_difference (info, point->c.x, point->c.y, dest);
}
else
{
@@ -478,41 +480,41 @@ sc_context_sample_point (ScRenderInfo *info,
gint i;
/* We need an alpha for this one */
- ScColor dest_c[SC_COLORA_CHANNEL_COUNT] = { 0 };
+ GeglScColor dest_c[GEGL_SC_COLORA_CHANNEL_COUNT] = { 0 };
for (i = 0; i < N; i++)
{
- ScPoint *pt = g_ptr_array_index (sl->points, i);
+ GeglScPoint *pt = g_ptr_array_index (sl->points, i);
gdouble weight = g_array_index (sl->weights, gdouble, i);
- ScColor raw_color[SC_COLORA_CHANNEL_COUNT];
+ GeglScColor raw_color[GEGL_SC_COLORA_CHANNEL_COUNT];
- if (! sc_context_sample_color_difference (info, pt->x, pt->y, raw_color))
+ if (! gegl_sc_context_sample_color_difference (info, pt->x, pt->y, raw_color))
continue;
-#define sc_color_expr(I) dest_c[I] += weight * raw_color[I]
- sc_color_process();
-#undef sc_color_expr
+#define gegl_sc_color_expr(I) dest_c[I] += weight * raw_color[I]
+ gegl_sc_color_process();
+#undef gegl_sc_color_expr
weightT += weight;
}
if (weightT == 0)
return FALSE;
-#define sc_color_expr(I) dest[I] = dest_c[I] / weightT
- sc_color_process();
-#undef sc_color_expr
- dest[SC_COLOR_ALPHA_INDEX] = 1;
+#define gegl_sc_color_expr(I) dest[I] = dest_c[I] / weightT
+ gegl_sc_color_process();
+#undef gegl_sc_color_expr
+ dest[GEGL_SC_COLOR_ALPHA_INDEX] = 1;
return TRUE;
}
}
static void
-sc_context_render_cache_pt2col_free (ScContext *context)
+gegl_sc_context_render_cache_pt2col_free (GeglScContext *context)
{
- GHashTableIter iter;
- ScColor *color_current = NULL;
- P2trPoint *pt = NULL;
+ GHashTableIter iter;
+ GeglScColor *color_current = NULL;
+ P2trPoint *pt = NULL;
if (context->render_cache->pt2col == NULL)
return;
@@ -522,7 +524,7 @@ sc_context_render_cache_pt2col_free (ScContext *context)
(gpointer*) &pt,
(gpointer*) &color_current))
{
- sc_color_free (color_current);
+ gegl_sc_color_free (color_current);
g_hash_table_iter_remove (&iter);
p2tr_point_unref (pt);
}
@@ -533,20 +535,20 @@ sc_context_render_cache_pt2col_free (ScContext *context)
}
static GeglBuffer*
-sc_compute_uvt_cache (P2trMesh *mesh,
- const GeglRectangle *area)
+gegl_sc_compute_uvt_cache (P2trMesh *mesh,
+ const GeglRectangle *area)
{
GeglBuffer *uvt;
GeglBufferIterator *iter;
P2trImageConfig config;
- uvt = gegl_buffer_new (area, SC_BABL_UVT_FORMAT);
+ uvt = gegl_buffer_new (area, GEGL_SC_BABL_UVT_FORMAT);
- iter = gegl_buffer_iterator_new (uvt, area, 0, SC_BABL_UVT_FORMAT,
+ iter = gegl_buffer_iterator_new (uvt, area, 0, GEGL_SC_BABL_UVT_FORMAT,
GEGL_BUFFER_WRITE, GEGL_ABYSS_NONE);
config.step_x = config.step_y = 1;
- config.cpp = SC_COLOR_CHANNEL_COUNT; /* Not that it will be used, but it won't harm */
+ config.cpp = GEGL_SC_COLOR_CHANNEL_COUNT; /* Not that it will be used, but it won't harm */
while (gegl_buffer_iterator_next (iter))
{
@@ -566,8 +568,8 @@ sc_compute_uvt_cache (P2trMesh *mesh,
}
void
-sc_context_set_uvt_cache (ScContext *context,
- gboolean enabled)
+gegl_sc_context_set_uvt_cache (GeglScContext *context,
+ gboolean enabled)
{
context->cache_uvt = enabled;
if (! enabled && context->uvt != NULL)
@@ -578,10 +580,10 @@ sc_context_set_uvt_cache (ScContext *context,
}
gboolean
-sc_context_render (ScContext *context,
- ScRenderInfo *info,
- const GeglRectangle *part_rect,
- GeglBuffer *part)
+gegl_sc_context_render (GeglScContext *context,
+ GeglScRenderInfo *info,
+ const GeglRectangle *part_rect,
+ GeglBuffer *part)
{
/** The area filled by the FG buf after the offset */
GeglRectangle fg_rect;
@@ -594,7 +596,7 @@ sc_context_render (ScContext *context,
gint out_index, uvt_index, fg_index;
gint xoff, yoff;
- const Babl *format = babl_format (SC_COLOR_BABL_NAME);
+ const Babl *format = babl_format (GEGL_SC_COLOR_BABL_NAME);
if (context->render_cache == NULL)
{
@@ -663,7 +665,7 @@ sc_context_render (ScContext *context,
context->uvt,
&to_render_fg,
0,
- SC_BABL_UVT_FORMAT,
+ GEGL_SC_BABL_UVT_FORMAT,
GEGL_BUFFER_READ,
GEGL_ABYSS_NONE);
}
@@ -693,8 +695,8 @@ sc_context_render (ScContext *context,
imcfg.x_samples = iter->roi[fg_index].width;
imcfg.y_samples = iter->roi[fg_index].height;
/* This is without the alpha! */
- imcfg.cpp = SC_COLOR_CHANNEL_COUNT;
- /* WARNING: This must be synched with SC_COLOR_BABL_NAME!!! */
+ imcfg.cpp = GEGL_SC_COLOR_CHANNEL_COUNT;
+ /* WARNING: This must be synched with GEGL_SC_COLOR_BABL_NAME!!! */
imcfg.alpha_last = TRUE;
out_raw = (gfloat*)iter->data[out_index];
@@ -707,7 +709,7 @@ sc_context_render (ScContext *context,
p2tr_mesh_render_from_cache_f (uvt_raw,
out_raw, iter->length,
&imcfg,
- sc_point_to_color_func,
+ gegl_sc_point_to_color_func,
context->render_cache->pt2col);
}
else
@@ -715,7 +717,7 @@ sc_context_render (ScContext *context,
p2tr_mesh_render_f (context->mesh,
out_raw,
&imcfg,
- sc_point_to_color_func,
+ gegl_sc_point_to_color_func,
context->render_cache->pt2col);
}
@@ -723,11 +725,11 @@ sc_context_render (ScContext *context,
{
for (x = 0; x < imcfg.x_samples; x++)
{
-#define sc_color_expr(I) out_raw[I] += fg_raw[I]
- sc_color_process();
-#undef sc_color_expr
- out_raw += SC_COLORA_CHANNEL_COUNT;
- fg_raw += SC_COLORA_CHANNEL_COUNT;
+#define gegl_sc_color_expr(I) out_raw[I] += fg_raw[I]
+ gegl_sc_color_process();
+#undef gegl_sc_color_expr
+ out_raw += GEGL_SC_COLORA_CHANNEL_COUNT;
+ fg_raw += GEGL_SC_COLORA_CHANNEL_COUNT;
}
}
}
@@ -736,45 +738,45 @@ sc_context_render (ScContext *context,
}
static void
-sc_point_to_color_func (P2trPoint *point,
- gfloat *dest,
- gpointer pt2col_p)
+gegl_sc_point_to_color_func (P2trPoint *point,
+ gfloat *dest,
+ gpointer pt2col_p)
{
- GHashTable *pt2col = (GHashTable*) pt2col_p;
- ScColor *col_cpy = g_hash_table_lookup (pt2col, point);
- guint i;
+ GHashTable *pt2col = (GHashTable*) pt2col_p;
+ GeglScColor *col_cpy = g_hash_table_lookup (pt2col, point);
+ guint i;
g_assert (col_cpy != NULL);
- for (i = 0; i < SC_COLORA_CHANNEL_COUNT; ++i)
+ for (i = 0; i < GEGL_SC_COLORA_CHANNEL_COUNT; ++i)
dest[i] = col_cpy[i];
}
static void
-sc_context_render_cache_free (ScContext *context)
+gegl_sc_context_render_cache_free (GeglScContext *context)
{
if (context->render_cache == NULL)
return;
- sc_context_render_cache_pt2col_free (context);
- g_slice_free (ScRenderCache, context->render_cache);
+ gegl_sc_context_render_cache_pt2col_free (context);
+ g_slice_free (GeglScRenderCache, context->render_cache);
context->render_cache = NULL;
}
void
-sc_context_free (ScContext *context)
+gegl_sc_context_free (GeglScContext *context)
{
if (context->render_cache)
- sc_context_render_cache_free (context);
+ gegl_sc_context_render_cache_free (context);
if (context->uvt != NULL)
g_object_unref (context->uvt);
- sc_mesh_sampling_free (context->sampling);
+ gegl_sc_mesh_sampling_free (context->sampling);
p2tr_mesh_unref (context->mesh);
- sc_outline_free (context->outline);
+ gegl_sc_outline_free (context->outline);
- g_slice_free (ScContext, context);
+ g_slice_free (GeglScContext, context);
}
diff --git a/operations/common/seamless-clone/sc-context.h b/operations/common/seamless-clone/sc-context.h
index e373982..ab8e3cb 100644
--- a/operations/common/seamless-clone/sc-context.h
+++ b/operations/common/seamless-clone/sc-context.h
@@ -30,7 +30,7 @@
* An opaque type representing the context for a seamless cloning
* operation
*/
-typedef struct _ScContext ScContext;
+typedef struct _GeglScContext GeglScContext;
/**
* Errors generated during the creation of a seamless cloning context
@@ -39,36 +39,36 @@ typedef enum {
/**
* No error
*/
- SC_CREATION_ERROR_NONE = 0,
+ GEGL_SC_CREATION_ERROR_NONE = 0,
/**
* The input doesn't contain an opaque area
*/
- SC_CREATION_ERROR_EMPTY,
+ GEGL_SC_CREATION_ERROR_EMPTY,
/**
*The opaque area of the input is too small
*/
- SC_CREATION_ERROR_TOO_SMALL,
+ GEGL_SC_CREATION_ERROR_TOO_SMALL,
/**
* The opaque area of the input either contains holes or is split
* to several disconnected areas
*/
- SC_CREATION_ERROR_HOLED_OR_SPLIT
-} ScCreationError;
+ GEGL_SC_CREATION_ERROR_HOLED_OR_SPLIT
+} GeglScCreationError;
/**
* Create a new seamless cloning context where the alpha of the
* given input buffer will be used to determine its outline.
*/
-ScContext* sc_context_new (GeglBuffer *input,
- const GeglRectangle *roi,
- gdouble threshold,
- ScCreationError *error);
+GeglScContext* gegl_sc_context_new (GeglBuffer *input,
+ const GeglRectangle *roi,
+ gdouble threshold,
+ GeglScCreationError *error);
-gboolean sc_context_update (ScContext *self,
- GeglBuffer *input,
- const GeglRectangle *roi,
- gdouble threshold,
- ScCreationError *error);
+gboolean gegl_sc_context_update (GeglScContext *self,
+ GeglBuffer *input,
+ const GeglRectangle *roi,
+ gdouble threshold,
+ GeglScCreationError *error);
/**
* Do the necessary caching so that rendering can happen. This function
@@ -79,8 +79,8 @@ gboolean sc_context_update (ScContext *self,
* BEHAVIOUR IS THAT THE FOREGROUND DOES NOT OVERLAP ENOUGH THE
* BACKGROUND!
*/
-gboolean sc_context_prepare_render (ScContext *context,
- ScRenderInfo *info);
+gboolean gegl_sc_context_prepare_render (GeglScContext *context,
+ GeglScRenderInfo *info);
/**
* Specifies whether the triangle containing each pixel, along with the
@@ -89,19 +89,19 @@ gboolean sc_context_prepare_render (ScContext *context,
* render the result faster.
* This function takes effect from the next call to prepare_render.
*/
-void sc_context_set_uvt_cache (ScContext *context,
- gboolean enabled);
+void gegl_sc_context_set_uvt_cache (GeglScContext *context,
+ gboolean enabled);
/**
* Call this function to render the specified area of the seamless
* cloning composition. This call must be preceeded by a call to
* the prepare function.
*/
-gboolean sc_context_render (ScContext *context,
- ScRenderInfo *info,
- const GeglRectangle *part_rect,
- GeglBuffer *part);
+gboolean gegl_sc_context_render (GeglScContext *context,
+ GeglScRenderInfo *info,
+ const GeglRectangle *part_rect,
+ GeglBuffer *part);
-void sc_context_free (ScContext *context);
+void gegl_sc_context_free (GeglScContext *context);
#endif
diff --git a/operations/common/seamless-clone/sc-outline.c b/operations/common/seamless-clone/sc-outline.c
index 0c56908..1b033b1 100644
--- a/operations/common/seamless-clone/sc-outline.c
+++ b/operations/common/seamless-clone/sc-outline.c
@@ -44,35 +44,35 @@
#include "sc-common.h"
static inline void
-sc_point_copy_to (const ScPoint *src,
- ScPoint *dst)
+gegl_sc_point_copy_to (const GeglScPoint *src,
+ GeglScPoint *dst)
{
dst->x = src->x;
dst->y = src->y;
dst->outside_normal = src->outside_normal;
}
-static inline ScPoint*
-sc_point_copy (const ScPoint *src)
+static inline GeglScPoint*
+gegl_sc_point_copy (const GeglScPoint *src)
{
- ScPoint *self = g_slice_new (ScPoint);
- sc_point_copy_to (src, self);
+ GeglScPoint *self = g_slice_new (GeglScPoint);
+ gegl_sc_point_copy_to (src, self);
return self;
}
-static inline ScPoint*
-sc_point_move (const ScPoint *src,
- ScDirection t,
- ScPoint *dst)
+static inline GeglScPoint*
+gegl_sc_point_move (const GeglScPoint *src,
+ GeglScDirection t,
+ GeglScPoint *dst)
{
- dst->x = src->x + SC_DIRECTION_XOFFSET (t, 1);
- dst->y = src->y + SC_DIRECTION_YOFFSET (t, 1);
+ dst->x = src->x + GEGL_SC_DIRECTION_XOFFSET (t, 1);
+ dst->y = src->y + GEGL_SC_DIRECTION_YOFFSET (t, 1);
return dst;
}
static inline gboolean
-sc_point_eq (const ScPoint *pt1,
- const ScPoint *pt2)
+gegl_sc_point_eq (const GeglScPoint *pt1,
+ const GeglScPoint *pt2)
{
return pt1->x == pt2->x && pt1->y == pt2->y;
}
@@ -82,17 +82,17 @@ is_opaque (const GeglRectangle *search_area,
GeglBuffer *buffer,
const Babl *format,
gdouble threshold,
- const ScPoint *pt)
+ const GeglScPoint *pt)
{
- ScColor col[SC_COLORA_CHANNEL_COUNT];
+ GeglScColor col[GEGL_SC_COLORA_CHANNEL_COUNT];
- if (! sc_point_in_rectangle (pt->x, pt->y, search_area))
+ if (! gegl_sc_point_in_rectangle (pt->x, pt->y, search_area))
return FALSE;
gegl_buffer_sample (buffer, pt->x, pt->y, NULL, col, format,
GEGL_SAMPLER_NEAREST, GEGL_ABYSS_NONE);
- return col[SC_COLOR_ALPHA_INDEX] >= threshold;
+ return col[GEGL_SC_COLOR_ALPHA_INDEX] >= threshold;
}
/* This function assumes the pixel is opaque! */
@@ -101,13 +101,13 @@ is_opaque_island (const GeglRectangle *search_area,
GeglBuffer *buffer,
const Babl *format,
gdouble threshold,
- const ScPoint *pt)
+ const GeglScPoint *pt)
{
gint i;
- ScPoint temp;
+ GeglScPoint temp;
for (i = 0; i < 8; ++i)
- if (is_opaque (search_area, buffer, format, threshold, sc_point_move (pt, i, &temp)))
+ if (is_opaque (search_area, buffer, format, threshold, gegl_sc_point_move (pt, i, &temp)))
return FALSE;
return TRUE;
@@ -120,16 +120,16 @@ is_valid_edge (const GeglRectangle *search_area,
GeglBuffer *buffer,
const Babl *format,
gdouble threshold,
- const ScPoint *pt)
+ const GeglScPoint *pt)
{
gint i;
- ScPoint temp;
+ GeglScPoint temp;
if (! is_opaque (search_area, buffer, format, threshold, pt))
return FALSE;
- for (i = 0; i < SC_DIRECTION_COUNT; ++i)
- if (is_opaque (search_area, buffer, format, threshold, sc_point_move (pt, i, &temp)))
+ for (i = 0; i < GEGL_SC_DIRECTION_COUNT; ++i)
+ if (is_opaque (search_area, buffer, format, threshold, gegl_sc_point_move (pt, i, &temp)))
return FALSE;
return TRUE;
@@ -150,24 +150,24 @@ is_valid_edge (const GeglRectangle *search_area,
* untill you find an opaque pixel. That pixel must then be the next
* edge pixel (when going in clock-wise direction)!
*/
-static inline ScDirection
+static inline GeglScDirection
walk_cw (const GeglRectangle *search_area,
GeglBuffer *buffer,
const Babl *format,
gdouble threshold,
- const ScPoint *cur_pt,
- ScDirection dir_from_prev,
- ScPoint *next_pt)
+ const GeglScPoint *cur_pt,
+ GeglScDirection dir_from_prev,
+ GeglScPoint *next_pt)
{
- ScDirection dir_to_prev = SC_DIRECTION_OPPOSITE (dir_from_prev);
- ScDirection dir_to_next = SC_DIRECTION_CW (dir_to_prev);
+ GeglScDirection dir_to_prev = GEGL_SC_DIRECTION_OPPOSITE (dir_from_prev);
+ GeglScDirection dir_to_next = GEGL_SC_DIRECTION_CW (dir_to_prev);
- sc_point_move (cur_pt, dir_to_next, next_pt);
+ gegl_sc_point_move (cur_pt, dir_to_next, next_pt);
while (! is_opaque (search_area, buffer, format, threshold, next_pt))
{
- dir_to_next = SC_DIRECTION_CW (dir_to_next);
- sc_point_move (cur_pt, dir_to_next, next_pt);
+ dir_to_next = GEGL_SC_DIRECTION_CW (dir_to_next);
+ gegl_sc_point_move (cur_pt, dir_to_next, next_pt);
}
return dir_to_next;
@@ -180,18 +180,18 @@ walk_cw (const GeglRectangle *search_area,
* the finds and returns the outline in which this edge pixel takes
* a part.
*/
-ScOutline*
-sc_outline_find (const GeglRectangle *search_area,
- GeglBuffer *buffer,
- gdouble threshold,
- gboolean *ignored_islands)
+GeglScOutline*
+gegl_sc_outline_find (const GeglRectangle *search_area,
+ GeglBuffer *buffer,
+ gdouble threshold,
+ gboolean *ignored_islands)
{
const Babl *format = babl_format("RGBA float");
- ScOutline *result = g_ptr_array_new ();
+ GeglScOutline *result = g_ptr_array_new ();
gboolean found = FALSE;
- ScPoint current, next, *first;
- ScDirection to_next;
+ GeglScPoint current, next, *first;
+ GeglScDirection to_next;
gint row_max = search_area->x + search_area->width;
gint col_max = search_area->y + search_area->height;
@@ -219,17 +219,17 @@ sc_outline_find (const GeglRectangle *search_area,
if (found)
{
- current.outside_normal = SC_DIRECTION_N;
- g_ptr_array_add (result, first = sc_point_copy (¤t));
+ current.outside_normal = GEGL_SC_DIRECTION_N;
+ g_ptr_array_add (result, first = gegl_sc_point_copy (¤t));
to_next = walk_cw (search_area, buffer, format, threshold,
- ¤t, SC_DIRECTION_E, &next);
+ ¤t, GEGL_SC_DIRECTION_E, &next);
- while (! sc_point_eq (&next, first))
+ while (! gegl_sc_point_eq (&next, first))
{
- next.outside_normal = SC_DIRECTION_CW(SC_DIRECTION_CW(to_next));
- g_ptr_array_add (result, sc_point_copy (&next));
- sc_point_copy_to (&next, ¤t);
+ next.outside_normal = GEGL_SC_DIRECTION_CW (GEGL_SC_DIRECTION_CW (to_next));
+ g_ptr_array_add (result, gegl_sc_point_copy (&next));
+ gegl_sc_point_copy_to (&next, ¤t);
to_next = walk_cw (search_area, buffer, format, threshold,
¤t, to_next, &next);
}
@@ -243,8 +243,8 @@ sc_outline_find (const GeglRectangle *search_area,
* increasing X values
*/
static gint
-sc_point_cmp (const ScPoint **pt1,
- const ScPoint **pt2)
+gegl_sc_point_cmp (const GeglScPoint **pt1,
+ const GeglScPoint **pt2)
{
if ((*pt1)->y < (*pt2)->y)
return -1;
@@ -280,16 +280,16 @@ sc_point_cmp (const ScPoint **pt1,
* (amortized) time!
*/
gboolean
-sc_outline_check_if_single (const GeglRectangle *search_area,
- GeglBuffer *buffer,
- gdouble threshold,
- ScOutline *existing)
+gegl_sc_outline_check_if_single (const GeglRectangle *search_area,
+ GeglBuffer *buffer,
+ gdouble threshold,
+ GeglScOutline *existing)
{
const Babl *format = babl_format("RGBA float");
GPtrArray *sorted_points = g_ptr_array_sized_new (existing->len);
gboolean not_single = FALSE;
- ScPoint current, *sorted_p;
+ GeglScPoint current, *sorted_p;
guint s_index;
gint row_max = search_area->x + search_area->width;
@@ -297,10 +297,10 @@ sc_outline_check_if_single (const GeglRectangle *search_area,
for (s_index = 0; s_index < existing->len; ++s_index)
g_ptr_array_add (sorted_points, g_ptr_array_index (existing, s_index));
- g_ptr_array_sort (sorted_points, (GCompareFunc) sc_point_cmp);
+ g_ptr_array_sort (sorted_points, (GCompareFunc) gegl_sc_point_cmp);
s_index = 0;
- sorted_p = (ScPoint*) g_ptr_array_index (sorted_points, s_index);
+ sorted_p = (GeglScPoint*) g_ptr_array_index (sorted_points, s_index);
for (current.y = search_area->y; current.y < row_max; ++current.y)
{
@@ -311,12 +311,12 @@ sc_outline_check_if_single (const GeglRectangle *search_area,
gboolean hit, opaque;
opaque = is_opaque (search_area, buffer, format, threshold, ¤t);
- hit = sc_point_eq (¤t, sorted_p);
+ hit = gegl_sc_point_eq (¤t, sorted_p);
if (hit && ! inside)
{
inside = TRUE;
- sorted_p = (ScPoint*) g_ptr_array_index (sorted_points, ++s_index);
+ sorted_p = (GeglScPoint*) g_ptr_array_index (sorted_points, ++s_index);
/* Prevent "leaving" the area in the next if statement */
hit = FALSE;
}
@@ -331,7 +331,7 @@ sc_outline_check_if_single (const GeglRectangle *search_area,
if (hit && inside)
{
inside = FALSE;
- sorted_p = (ScPoint*) g_ptr_array_index (sorted_points, ++s_index);
+ sorted_p = (GeglScPoint*) g_ptr_array_index (sorted_points, ++s_index);
}
}
@@ -344,30 +344,30 @@ sc_outline_check_if_single (const GeglRectangle *search_area,
}
guint
-sc_outline_length (ScOutline *self)
+gegl_sc_outline_length (GeglScOutline *self)
{
return ((GPtrArray*) self)->len;
}
gboolean
-sc_outline_equals (ScOutline *a,
- ScOutline *b)
+gegl_sc_outline_equals (GeglScOutline *a,
+ GeglScOutline *b)
{
if (a == b) /* Includes the case were both are NULL */
return TRUE;
else if ((a == NULL) != (b == NULL))
return FALSE;
- else if (sc_outline_length (a) != sc_outline_length (b))
+ else if (gegl_sc_outline_length (a) != gegl_sc_outline_length (b))
return FALSE;
else
{
- guint n = sc_outline_length (a);
+ guint n = gegl_sc_outline_length (a);
guint i;
for (i = 0; i < n; i++)
{
- const ScPoint *pA = (ScPoint*) g_ptr_array_index (a, i);
- const ScPoint *pB = (ScPoint*) g_ptr_array_index (b, i);
- if (sc_point_cmp (&pA, &pB) != 0)
+ const GeglScPoint *pA = (GeglScPoint*) g_ptr_array_index (a, i);
+ const GeglScPoint *pB = (GeglScPoint*) g_ptr_array_index (b, i);
+ if (gegl_sc_point_cmp (&pA, &pB) != 0)
return FALSE;
}
return TRUE;
@@ -375,11 +375,11 @@ sc_outline_equals (ScOutline *a,
}
void
-sc_outline_free (ScOutline *self)
+gegl_sc_outline_free (GeglScOutline *self)
{
GPtrArray *real = (GPtrArray*) self;
gint i;
for (i = 0; i < real->len; i++)
- g_slice_free (ScPoint, g_ptr_array_index (self, i));
+ g_slice_free (GeglScPoint, g_ptr_array_index (self, i));
g_ptr_array_free (real, TRUE);
}
diff --git a/operations/common/seamless-clone/sc-outline.h b/operations/common/seamless-clone/sc-outline.h
index 4636cda..bbc55a0 100644
--- a/operations/common/seamless-clone/sc-outline.h
+++ b/operations/common/seamless-clone/sc-outline.h
@@ -39,55 +39,55 @@
* </pre>
*/
typedef enum {
- SC_DIRECTION_N = 0,
- SC_DIRECTION_NE = 1,
- SC_DIRECTION_E = 2,
- SC_DIRECTION_SE = 3,
- SC_DIRECTION_S = 4,
- SC_DIRECTION_SW = 5,
- SC_DIRECTION_W = 6,
- SC_DIRECTION_NW = 7,
- SC_DIRECTION_COUNT = 8
-} ScDirection;
-
-#define SC_DIRECTION_CW(d) (((d) + 1) % 8)
-#define SC_DIRECTION_CCW(d) (((d) + 7) % 8)
-#define SC_DIRECTION_OPPOSITE(d) (((d) + 4) % 8)
-
-#define SC_DIRECTION_IS_NORTH(d) ( \
- ((d) == SC_DIRECTION_N) || \
- ((d) == SC_DIRECTION_NE) || \
- ((d) == SC_DIRECTION_NW) \
+ GEGL_SC_DIRECTION_N = 0,
+ GEGL_SC_DIRECTION_NE = 1,
+ GEGL_SC_DIRECTION_E = 2,
+ GEGL_SC_DIRECTION_SE = 3,
+ GEGL_SC_DIRECTION_S = 4,
+ GEGL_SC_DIRECTION_SW = 5,
+ GEGL_SC_DIRECTION_W = 6,
+ GEGL_SC_DIRECTION_NW = 7,
+ GEGL_SC_DIRECTION_COUNT = 8
+} GeglScDirection;
+
+#define GEGL_SC_DIRECTION_CW(d) (((d) + 1) % 8)
+#define GEGL_SC_DIRECTION_CCW(d) (((d) + 7) % 8)
+#define GEGL_SC_DIRECTION_OPPOSITE(d) (((d) + 4) % 8)
+
+#define GEGL_SC_DIRECTION_IS_NORTH(d) ( \
+ ((d) == GEGL_SC_DIRECTION_N) || \
+ ((d) == GEGL_SC_DIRECTION_NE) || \
+ ((d) == GEGL_SC_DIRECTION_NW) \
)
-#define SC_DIRECTION_IS_SOUTH(d) ( \
- ((d) == SC_DIRECTION_S) || \
- ((d) == SC_DIRECTION_SE) || \
- ((d) == SC_DIRECTION_SW) \
+#define GEGL_SC_DIRECTION_IS_SOUTH(d) ( \
+ ((d) == GEGL_SC_DIRECTION_S) || \
+ ((d) == GEGL_SC_DIRECTION_SE) || \
+ ((d) == GEGL_SC_DIRECTION_SW) \
)
-#define SC_DIRECTION_IS_EAST(d) ( \
- ((d) == SC_DIRECTION_E) || \
- ((d) == SC_DIRECTION_NE) || \
- ((d) == SC_DIRECTION_SE) \
+#define GEGL_SC_DIRECTION_IS_EAST(d) ( \
+ ((d) == GEGL_SC_DIRECTION_E) || \
+ ((d) == GEGL_SC_DIRECTION_NE) || \
+ ((d) == GEGL_SC_DIRECTION_SE) \
)
-#define SC_DIRECTION_IS_WEST(d) ( \
- ((d) == SC_DIRECTION_W) || \
- ((d) == SC_DIRECTION_NW) || \
- ((d) == SC_DIRECTION_SW) \
+#define GEGL_SC_DIRECTION_IS_WEST(d) ( \
+ ((d) == GEGL_SC_DIRECTION_W) || \
+ ((d) == GEGL_SC_DIRECTION_NW) || \
+ ((d) == GEGL_SC_DIRECTION_SW) \
)
-#define SC_DIRECTION_XOFFSET(d,s) ( \
- (SC_DIRECTION_IS_EAST(d)) ? (s) : \
- ((SC_DIRECTION_IS_WEST(d)) ? -(s) : \
- 0) \
+#define GEGL_SC_DIRECTION_XOFFSET(d,s) ( \
+ (GEGL_SC_DIRECTION_IS_EAST(d)) ? (s) : \
+ ((GEGL_SC_DIRECTION_IS_WEST(d)) ? -(s) : \
+ 0) \
)
-#define SC_DIRECTION_YOFFSET(d,s) ( \
- (SC_DIRECTION_IS_SOUTH(d)) ? (s) : \
- ((SC_DIRECTION_IS_NORTH(d)) ? -(s) : \
- 0) \
+#define GEGL_SC_DIRECTION_YOFFSET(d,s) ( \
+ (GEGL_SC_DIRECTION_IS_SOUTH(d)) ? (s) : \
+ ((GEGL_SC_DIRECTION_IS_NORTH(d)) ? -(s) : \
+ 0) \
)
/**
@@ -97,31 +97,31 @@ typedef enum {
*/
typedef struct {
gint x, y;
- ScDirection outside_normal;
-} ScPoint;
+ GeglScDirection outside_normal;
+} GeglScPoint;
/* Define a type for the outline to distinguish it from all the other
* pointer arrays in the code of the seamless cloning. Also allow later
* to pass it transparently to other places and free it, without
- * depending on the actual representation of this type.
+ * depending on the actual representation of this type.
*/
-typedef GPtrArray ScOutline;
+typedef GPtrArray GeglScOutline;
-ScOutline* sc_outline_find (const GeglRectangle *rect,
- GeglBuffer *pixels,
- gdouble threshold,
- gboolean *ignored_islands);
+GeglScOutline* gegl_sc_outline_find (const GeglRectangle *rect,
+ GeglBuffer *pixels,
+ gdouble threshold,
+ gboolean *ignored_islands);
-gboolean sc_outline_check_if_single (const GeglRectangle *search_area,
- GeglBuffer *buffer,
- gdouble threshold,
- ScOutline *existing);
+gboolean gegl_sc_outline_check_if_single (const GeglRectangle *search_area,
+ GeglBuffer *buffer,
+ gdouble threshold,
+ GeglScOutline *existing);
-guint sc_outline_length (ScOutline *self);
+guint gegl_sc_outline_length (GeglScOutline *self);
-gboolean sc_outline_equals (ScOutline *a,
- ScOutline *b);
+gboolean gegl_sc_outline_equals (GeglScOutline *a,
+ GeglScOutline *b);
-void sc_outline_free (ScOutline *self);
+void gegl_sc_outline_free (GeglScOutline *self);
#endif
diff --git a/operations/common/seamless-clone/sc-sample.c b/operations/common/seamless-clone/sc-sample.c
index 800d018..b6e7338 100644
--- a/operations/common/seamless-clone/sc-sample.c
+++ b/operations/common/seamless-clone/sc-sample.c
@@ -31,25 +31,25 @@
#define g_ptr_array_index_cyclic(array,index_) g_ptr_array_index(array,(index_)%((array)->len))
-#define SC_SAMPLE_BASE_POINT_COUNT 16
+#define GEGL_SC_SAMPLE_BASE_POINT_COUNT 16
/* This won't add the point in the second index, to allow avoiding
* insertion of a points twice from two adjacent segments. The caller
* must do that
*/
static void
-sc_compute_sample_list_part (ScOutline *outline,
- gint index1,
- gint index2,
- gdouble Px,
- gdouble Py,
- ScSampleList *sl,
- gint k)
+gegl_sc_compute_sample_list_part (GeglScOutline *outline,
+ gint index1,
+ gint index2,
+ gdouble Px,
+ gdouble Py,
+ GeglScSampleList *sl,
+ gint k)
{
GPtrArray *real = (GPtrArray*) outline;
- ScPoint *pt1 = g_ptr_array_index_cyclic (real, index1);
- ScPoint *pt2 = g_ptr_array_index_cyclic (real, index2);
+ GeglScPoint *pt1 = g_ptr_array_index_cyclic (real, index1);
+ GeglScPoint *pt2 = g_ptr_array_index_cyclic (real, index2);
/* Compute the angle pt1-x-pt2 */
gdouble dx1 = Px - pt1->x, dy1 = Py - pt1->y;
@@ -60,7 +60,7 @@ sc_compute_sample_list_part (ScOutline *outline,
gint d = index2 - index1;
- gdouble edist = real->len / (SC_SAMPLE_BASE_POINT_COUNT * pow (2.5, k));
+ gdouble edist = real->len / (GEGL_SC_SAMPLE_BASE_POINT_COUNT * pow (2.5, k));
gdouble eang = 0.75 * pow (0.8, k);
gboolean needsMore = !(norm1 > edist && norm2 > edist && angle < eang);
@@ -75,16 +75,16 @@ sc_compute_sample_list_part (ScOutline *outline,
else
{
gint index12 = (index1 + index2) / 2;
- sc_compute_sample_list_part (outline, index1, index12, Px, Py, sl, k + 1);
- sc_compute_sample_list_part (outline, index12, index2, Px, Py, sl, k + 1);
+ gegl_sc_compute_sample_list_part (outline, index1, index12, Px, Py, sl, k + 1);
+ gegl_sc_compute_sample_list_part (outline, index12, index2, Px, Py, sl, k + 1);
return;
}
}
static void
-sc_compute_sample_list_weights (gdouble Px,
- gdouble Py,
- ScSampleList *sl)
+gegl_sc_compute_sample_list_weights (gdouble Px,
+ gdouble Py,
+ GeglScSampleList *sl)
{
gint N = sl->points->len;
gdouble *tan_as_half = g_new (gdouble, N);
@@ -98,8 +98,8 @@ sc_compute_sample_list_weights (gdouble Px,
for (i = 0; i < N; i++)
{
- ScPoint *pt1 = g_ptr_array_index_cyclic (sl->points, i);
- ScPoint *pt2 = g_ptr_array_index_cyclic (sl->points, i + 1);
+ GeglScPoint *pt1 = g_ptr_array_index_cyclic (sl->points, i);
+ GeglScPoint *pt2 = g_ptr_array_index_cyclic (sl->points, i + 1);
gdouble dx1 = Px - pt1->x, dy1 = Py - pt1->y;
gdouble dx2 = Px - pt2->x, dy2 = Py - pt2->y;
@@ -154,12 +154,12 @@ sc_compute_sample_list_weights (gdouble Px,
}
}
-ScSampleList*
-sc_sample_list_compute (ScOutline *outline,
- gdouble Px,
- gdouble Py)
+GeglScSampleList*
+gegl_sc_sample_list_compute (GeglScOutline *outline,
+ gdouble Px,
+ gdouble Py)
{
- ScSampleList *sl = g_slice_new (ScSampleList);
+ GeglScSampleList *sl = g_slice_new (GeglScSampleList);
GPtrArray *real = (GPtrArray*) outline;
gint i;
@@ -167,31 +167,31 @@ sc_sample_list_compute (ScOutline *outline,
sl->points = g_ptr_array_new ();
sl->weights = g_array_new (FALSE, TRUE, sizeof (gdouble));
- if (real->len <= SC_SAMPLE_BASE_POINT_COUNT)
+ if (real->len <= GEGL_SC_SAMPLE_BASE_POINT_COUNT)
{
for (i = 0; i < real->len; i++)
g_ptr_array_add (sl->points, g_ptr_array_index (real, i));
}
else
{
- for (i = 0; i < SC_SAMPLE_BASE_POINT_COUNT; i++)
+ for (i = 0; i < GEGL_SC_SAMPLE_BASE_POINT_COUNT; i++)
{
- gint index1 = i * real->len / SC_SAMPLE_BASE_POINT_COUNT;
- gint index2 = (i + 1) * real->len / SC_SAMPLE_BASE_POINT_COUNT;
+ gint index1 = i * real->len / GEGL_SC_SAMPLE_BASE_POINT_COUNT;
+ gint index2 = (i + 1) * real->len / GEGL_SC_SAMPLE_BASE_POINT_COUNT;
- sc_compute_sample_list_part (outline, index1, index2, Px, Py, sl, 0);
+ gegl_sc_compute_sample_list_part (outline, index1, index2, Px, Py, sl, 0);
}
}
- sc_compute_sample_list_weights (Px, Py, sl);
+ gegl_sc_compute_sample_list_weights (Px, Py, sl);
return sl;
}
-ScSampleList*
-sc_sample_list_direct (void)
+GeglScSampleList*
+gegl_sc_sample_list_direct (void)
{
- ScSampleList *sl = g_slice_new (ScSampleList);
+ GeglScSampleList *sl = g_slice_new (GeglScSampleList);
sl->direct_sample = TRUE;
sl->points = NULL;
sl->weights = NULL;
@@ -200,7 +200,7 @@ sc_sample_list_direct (void)
}
void
-sc_sample_list_free (ScSampleList *self)
+gegl_sc_sample_list_free (GeglScSampleList *self)
{
if (! self->direct_sample)
{
@@ -212,12 +212,12 @@ sc_sample_list_free (ScSampleList *self)
g_assert (self->points == NULL);
g_assert (self->weights == NULL);
}
- g_slice_free (ScSampleList, self);
+ g_slice_free (GeglScSampleList, self);
}
-ScMeshSampling*
-sc_mesh_sampling_compute (ScOutline *outline,
- P2trMesh *mesh)
+GeglScMeshSampling*
+gegl_sc_mesh_sampling_compute (GeglScOutline *outline,
+ P2trMesh *mesh)
{
GHashTable *pt2sample = g_hash_table_new (g_direct_hash, g_direct_equal);
P2trPoint *pt = NULL;
@@ -226,11 +226,11 @@ sc_mesh_sampling_compute (ScOutline *outline,
p2tr_hash_set_iter_init (&iter, mesh->points);
while (p2tr_hash_set_iter_next (&iter, (gpointer*) &pt))
{
- ScSampleList *sl;
+ GeglScSampleList *sl;
if (p2tr_point_is_fully_in_domain (pt))
- sl = sc_sample_list_compute (outline, pt->c.x, pt->c.y);
+ sl = gegl_sc_sample_list_compute (outline, pt->c.x, pt->c.y);
else
- sl = sc_sample_list_direct ();
+ sl = gegl_sc_sample_list_direct ();
g_hash_table_insert (pt2sample, pt, sl);
}
@@ -238,21 +238,21 @@ sc_mesh_sampling_compute (ScOutline *outline,
}
static void
-sc_mesh_sampling_entry_free_hfunc (gpointer point,
- gpointer sampling_list,
- gpointer unused)
+gegl_sc_mesh_sampling_entry_free_hfunc (gpointer point,
+ gpointer sampling_list,
+ gpointer unused)
{
/* Unref the point returned from triangulation_get_points */
p2tr_point_unref ((P2trPoint*)point);
/* Free the sampling list */
- sc_sample_list_free ((ScSampleList*)sampling_list);
+ gegl_sc_sample_list_free ((GeglScSampleList*)sampling_list);
}
void
-sc_mesh_sampling_free (ScMeshSampling *self)
+gegl_sc_mesh_sampling_free (GeglScMeshSampling *self)
{
GHashTable *real = (GHashTable*) self;
- g_hash_table_foreach (real, sc_mesh_sampling_entry_free_hfunc, NULL);
+ g_hash_table_foreach (real, gegl_sc_mesh_sampling_entry_free_hfunc, NULL);
g_hash_table_destroy (real);
}
diff --git a/operations/common/seamless-clone/sc-sample.h b/operations/common/seamless-clone/sc-sample.h
index 0bb4fd6..40cdc8c 100644
--- a/operations/common/seamless-clone/sc-sample.h
+++ b/operations/common/seamless-clone/sc-sample.h
@@ -28,40 +28,40 @@
typedef struct {
/** Should the point behind this list be sampled directly? */
gboolean direct_sample;
- /** An array of ScPoint* (pointers) of the points to sample */
+ /** An array of GeglScPoint* (pointers) of the points to sample */
GPtrArray *points;
/** An array of weights to assign to the samples from the points */
GArray *weights;
/** The total weight of the samples, used to normalize the result */
gdouble total_weight;
-} ScSampleList;
+} GeglScSampleList;
-typedef GHashTable ScMeshSampling;
+typedef GHashTable GeglScMeshSampling;
/**
* Compute the list of points that should be sampled in order to
* compute the color assigned to the given point in the color
* difference mesh.
*/
-ScSampleList* sc_sample_list_compute (ScOutline *outline,
- gdouble x,
- gdouble y);
+GeglScSampleList* gegl_sc_sample_list_compute (GeglScOutline *outline,
+ gdouble x,
+ gdouble y);
-ScSampleList* sc_sample_list_direct (void);
+GeglScSampleList* gegl_sc_sample_list_direct (void);
/**
- * Free an ScSampleList object created by sc_sample_list_compute
+ * Free an GeglScSampleList object created by gegl_sc_sample_list_compute
*/
-void sc_sample_list_free (ScSampleList *self);
+void gegl_sc_sample_list_free (GeglScSampleList *self);
/**
* Compute the sample lists for all the points in a given mesh
*/
-ScMeshSampling* sc_mesh_sampling_compute (ScOutline *outline,
- P2trMesh *mesh);
+GeglScMeshSampling* gegl_sc_mesh_sampling_compute (GeglScOutline *outline,
+ P2trMesh *mesh);
/**
- * Free an ScMeshSampling object created by sc_mesh_sampling_compute
+ * Free an GeglScMeshSampling object created by gegl_sc_mesh_sampling_compute
*/
-void sc_mesh_sampling_free (ScMeshSampling *self);
+void gegl_sc_mesh_sampling_free (GeglScMeshSampling *self);
#endif
diff --git a/operations/common/seamless-clone/seamless-clone.c
b/operations/common/seamless-clone/seamless-clone.c
index 10fe3a3..adbf056 100644
--- a/operations/common/seamless-clone/seamless-clone.c
+++ b/operations/common/seamless-clone/seamless-clone.c
@@ -42,10 +42,10 @@ gegl_chant_string (error_msg, _("Error message"), NULL, _("An error message in c
typedef struct SCProps_
{
- GMutex mutex;
- gboolean first_processing;
- gboolean is_valid;
- ScContext *context;
+ GMutex mutex;
+ gboolean first_processing;
+ gboolean is_valid;
+ GeglScContext *context;
} SCProps;
static GeglRectangle
@@ -78,7 +78,7 @@ get_required_for_output (GeglOperation *operation,
static void
prepare (GeglOperation *operation)
{
- const Babl *format = babl_format (SC_COLOR_BABL_NAME);
+ const Babl *format = babl_format (GEGL_SC_COLOR_BABL_NAME);
GeglChantO *o = GEGL_CHANT_PROPERTIES (operation);
SCProps *props;
@@ -107,7 +107,7 @@ static void finalize (GObject *object)
SCProps *props = (SCProps*) o->chant_data;
g_mutex_clear (&props->mutex);
if (props->context)
- sc_context_free (props->context);
+ gegl_sc_context_free (props->context);
g_slice_free (SCProps, props);
o->chant_data = NULL;
}
@@ -125,8 +125,8 @@ process (GeglOperation *operation,
gboolean return_val;
GeglChantO *o = GEGL_CHANT_PROPERTIES (operation);
SCProps *props;
- ScCreationError error;
- ScRenderInfo info;
+ GeglScCreationError error;
+ GeglScRenderInfo info;
g_assert (o->chant_data != NULL);
@@ -145,25 +145,25 @@ process (GeglOperation *operation,
{
if (props->context == NULL)
{
- props->context = sc_context_new (aux, gegl_operation_source_get_bounding_box (operation, "aux"),
0.5, &error);
- sc_context_set_uvt_cache (props->context, TRUE);
+ props->context = gegl_sc_context_new (aux, gegl_operation_source_get_bounding_box (operation,
"aux"), 0.5, &error);
+ gegl_sc_context_set_uvt_cache (props->context, TRUE);
}
else
- sc_context_update (props->context, aux, gegl_operation_source_get_bounding_box (operation, "aux"),
0.5, &error);
+ gegl_sc_context_update (props->context, aux, gegl_operation_source_get_bounding_box (operation,
"aux"), 0.5, &error);
switch (error)
{
- case SC_CREATION_ERROR_NONE:
+ case GEGL_SC_CREATION_ERROR_NONE:
o->error_msg = NULL;
props->is_valid = TRUE;
break;
- case SC_CREATION_ERROR_EMPTY:
+ case GEGL_SC_CREATION_ERROR_EMPTY:
o->error_msg = _("The foreground does not contain opaque parts");
break;
- case SC_CREATION_ERROR_TOO_SMALL:
+ case GEGL_SC_CREATION_ERROR_TOO_SMALL:
o->error_msg = _("The foreground is too small to use");
break;
- case SC_CREATION_ERROR_HOLED_OR_SPLIT:
+ case GEGL_SC_CREATION_ERROR_HOLED_OR_SPLIT:
o->error_msg = _("The foreground contains holes and/or several unconnected parts");
break;
default:
@@ -173,7 +173,7 @@ process (GeglOperation *operation,
if (props->is_valid)
{
- if (! sc_context_prepare_render (props->context, &info))
+ if (! gegl_sc_context_prepare_render (props->context, &info))
{
o->error_msg = _("The opaque parts of the foreground are not above the background!");
props->is_valid = FALSE;
@@ -185,7 +185,7 @@ process (GeglOperation *operation,
g_mutex_unlock (&props->mutex);
if (props->is_valid)
- return sc_context_render (props->context, &info, result, output);
+ return gegl_sc_context_render (props->context, &info, result, output);
else
return FALSE;
return return_val;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]