summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJehan <jehan@girinstud.io>2014-04-27 22:27:07 +1200
committerJehan <jehan@girinstud.io>2015-07-12 19:40:56 +0200
commit346139b4fb9d2ce9fe5de89ecb4f74e23cb50286 (patch)
tree0d00edd7bfa160d37b204a5fd21ddccfe1bb1efb
parentd0bfae0970c6a3b8934600ec09e5ef121cc117e0 (diff)
seamless-clone: max-refine-steps is not used.
Make it max-refine-scale instead, whose default value is 5 (making default behavior unchanged).
-rw-r--r--operations/seamless-clone/seamless-clone.c40
-rw-r--r--seamless-clone/sc-context.c18
-rw-r--r--seamless-clone/sc-context.h2
3 files changed, 49 insertions, 11 deletions
diff --git a/operations/seamless-clone/seamless-clone.c b/operations/seamless-clone/seamless-clone.c
index 29c2a27b..58eab7ec 100644
--- a/operations/seamless-clone/seamless-clone.c
+++ b/operations/seamless-clone/seamless-clone.c
@@ -19,8 +19,8 @@
#ifdef GEGL_PROPERTIES
-property_int (max_refine_steps, _("Refinement steps"), 2000)
- description (_("Maximal amount of refinement points to be used for the interpolation mesh"))
+property_int (max_refine_scale, _("Refinement scale"), 5)
+ description (_("Maximal scale of refinement points to be used for the interpolation mesh"))
value_range (0, 100000)
property_int (xoff, _("Offset X"), 0)
@@ -156,11 +156,22 @@ process (GeglOperation *operation,
const gchar *error_msg = "";
if (props->context == NULL)
{
- props->context = gegl_sc_context_new (aux, gegl_operation_source_get_bounding_box (operation, "aux"), 0.5, &error);
+ props->context = gegl_sc_context_new (aux,
+ gegl_operation_source_get_bounding_box (operation, "aux"),
+ 0.5,
+ o->max_refine_scale,
+ &error);
gegl_sc_context_set_uvt_cache (props->context, TRUE);
}
else
- gegl_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,
+ o->max_refine_scale,
+ &error);
+ }
switch (error)
{
@@ -205,12 +216,33 @@ process (GeglOperation *operation,
}
static void
+notify (GObject *object,
+ GParamSpec *pspec)
+{
+ if (strcmp (pspec->name, "max-refine-steps") == 0)
+ {
+ GeglProperties *o = GEGL_PROPERTIES (object);
+
+ if (o->user_data)
+ {
+ g_free (o->user_data);
+ o->user_data = NULL;
+ }
+ }
+
+ if (G_OBJECT_CLASS (gegl_op_parent_class)->notify)
+ G_OBJECT_CLASS (gegl_op_parent_class)->notify (object, pspec);
+}
+
+static void
gegl_op_class_init (GeglOpClass *klass)
{
GeglOperationClass *operation_class = GEGL_OPERATION_CLASS (klass);
GeglOperationComposerClass *composer_class = GEGL_OPERATION_COMPOSER_CLASS (klass);
G_OBJECT_CLASS (klass)->finalize = finalize;
+ G_OBJECT_CLASS (klass)->notify = notify;
+
operation_class->prepare = prepare;
composer_class->process = process;
diff --git a/seamless-clone/sc-context.c b/seamless-clone/sc-context.c
index 383fb0d6..db791555 100644
--- a/seamless-clone/sc-context.c
+++ b/seamless-clone/sc-context.c
@@ -33,10 +33,11 @@ static GeglScOutline* gegl_sc_context_create_outline (GeglBuffer
static P2trMesh* gegl_sc_make_fine_mesh (GeglScOutline *outline,
GeglRectangle *mesh_bounds,
- int max_refine_steps);
+ int max_refine_scale);
static void gegl_sc_context_update_from_outline (GeglScContext *self,
- GeglScOutline *outline);
+ GeglScOutline *outline,
+ gint max_refine_scale);
static gboolean gegl_sc_context_render_cache_pt2col_update (GeglScContext *context,
GeglScRenderInfo *info);
@@ -66,6 +67,7 @@ GeglScContext*
gegl_sc_context_new (GeglBuffer *input,
const GeglRectangle *roi,
gdouble threshold,
+ gint max_refine_scale,
GeglScCreationError *error)
{
GeglScContext *self;
@@ -84,7 +86,7 @@ gegl_sc_context_new (GeglBuffer *input,
self->uvt = NULL;
self->render_cache = NULL;
- gegl_sc_context_update_from_outline (self, outline);
+ gegl_sc_context_update_from_outline (self, outline, max_refine_scale);
return self;
}
@@ -94,6 +96,7 @@ gegl_sc_context_update (GeglScContext *self,
GeglBuffer *input,
const GeglRectangle *roi,
gdouble threshold,
+ gint max_refine_scale,
GeglScCreationError *error)
{
GeglScOutline *outline
@@ -110,7 +113,7 @@ gegl_sc_context_update (GeglScContext *self,
}
else
{
- gegl_sc_context_update_from_outline (self, outline);
+ gegl_sc_context_update_from_outline (self, outline, max_refine_scale);
return TRUE;
}
}
@@ -161,7 +164,8 @@ gegl_sc_context_create_outline (GeglBuffer *input,
static void
gegl_sc_context_update_from_outline (GeglScContext *self,
- GeglScOutline *outline)
+ GeglScOutline *outline,
+ gint max_refine_scale)
{
guint outline_length;
@@ -203,7 +207,7 @@ gegl_sc_context_update_from_outline (GeglScContext *self,
self->outline = outline;
self->mesh = gegl_sc_make_fine_mesh (self->outline,
&self->mesh_bounds,
- 5 * outline_length);
+ max_refine_scale * outline_length);
self->sampling = gegl_sc_mesh_sampling_compute (self->outline,
self->mesh);
}
@@ -216,7 +220,7 @@ gegl_sc_context_update_from_outline (GeglScContext *self,
* stored
*/
static P2trMesh*
-gegl_sc_make_fine_mesh (GeglScOutline *outline,
+gegl_sc_make_fine_mesh (GeglScOutline *outline,
GeglRectangle *mesh_bounds,
int max_refine_steps)
{
diff --git a/seamless-clone/sc-context.h b/seamless-clone/sc-context.h
index ab8e3cb9..48a360e1 100644
--- a/seamless-clone/sc-context.h
+++ b/seamless-clone/sc-context.h
@@ -62,12 +62,14 @@ typedef enum {
GeglScContext* gegl_sc_context_new (GeglBuffer *input,
const GeglRectangle *roi,
gdouble threshold,
+ gint max_refine_scale,
GeglScCreationError *error);
gboolean gegl_sc_context_update (GeglScContext *self,
GeglBuffer *input,
const GeglRectangle *roi,
gdouble threshold,
+ gint max_refine_scale,
GeglScCreationError *error);
/**