[gegl] transform: add a clip-to-input property



commit 363b1c983be018c5fb344f1e482f1dbd0e6fe6a6
Author: Øyvind Kolås <pippin gimp org>
Date:   Tue Nov 8 16:42:36 2016 +0100

    transform: add a clip-to-input property
    
    Add a property for GIMP to set when the used transformation matrix would
    make the size of the output explode. ref bug #316479

 operations/transform/transform-core.c |   19 +++++++++++++++++--
 operations/transform/transform-core.h |    1 +
 2 files changed, 18 insertions(+), 2 deletions(-)
---
diff --git a/operations/transform/transform-core.c b/operations/transform/transform-core.c
index b975b29..8f0ef9d 100644
--- a/operations/transform/transform-core.c
+++ b/operations/transform/transform-core.c
@@ -42,7 +42,8 @@ enum
 {
   PROP_ORIGIN_X = 1,
   PROP_ORIGIN_Y,
-  PROP_SAMPLER
+  PROP_SAMPLER,
+  PROP_CLIP_TO_INPUT
 };
 
 static void          gegl_transform_get_property                 (GObject              *object,
@@ -195,6 +196,13 @@ op_transform_class_init (OpTransformClass *klass)
                                      gegl_sampler_type_get_type (),
                                      GEGL_SAMPLER_LINEAR,
                                      G_PARAM_CONSTRUCT | G_PARAM_READWRITE));
+  g_object_class_install_property (gobject_class, PROP_CLIP_TO_INPUT,
+                                   g_param_spec_boolean (
+                                     "clip-to-input",
+                                     _("Clip to input"),
+                                     _("Force output bounding box to be input bounding box."),
+                                     FALSE,
+                                     G_PARAM_CONSTRUCT | G_PARAM_READWRITE));
 }
 
 static void
@@ -221,6 +229,9 @@ gegl_transform_get_property (GObject    *object,
     case PROP_SAMPLER:
       g_value_set_enum (value, self->sampler);
       break;
+    case PROP_CLIP_TO_INPUT:
+      g_value_set_boolean (value, self->clip_to_input);
+      break;
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
       break;
@@ -246,6 +257,9 @@ gegl_transform_set_property (GObject      *object,
     case PROP_SAMPLER:
       self->sampler = g_value_get_enum (value);
       break;
+    case PROP_CLIP_TO_INPUT:
+      self->clip_to_input = g_value_get_boolean (value);
+      break;
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
       break;
@@ -451,7 +465,8 @@ gegl_transform_get_bounding_box (GeglOperation *op)
   gegl_transform_create_composite_matrix (transform, &matrix);
 
   if (gegl_transform_is_intermediate_node (transform) ||
-      gegl_matrix3_is_identity (&matrix))
+      gegl_matrix3_is_identity (&matrix) ||
+      transform->clip_to_input)
     return in_rect;
 
   /*
diff --git a/operations/transform/transform-core.h b/operations/transform/transform-core.h
index 8f8c087..1a523dc 100644
--- a/operations/transform/transform-core.h
+++ b/operations/transform/transform-core.h
@@ -20,6 +20,7 @@ struct _OpTransform
   gdouble             origin_x;
   gdouble             origin_y;
   GeglSamplerType     sampler;
+  gboolean            clip_to_input;
 };
 
 typedef struct _OpTransformClass OpTransformClass;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]