[gegl] operations: implement GeglOperationAreaFilter::get_abyss_policy() ...



commit b1b7ee0e742fab0a4a42438530c200b43030692c
Author: Ell <ell_se yahoo com>
Date:   Thu Apr 26 14:18:49 2018 -0400

    operations: implement GeglOperationAreaFilter::get_abyss_policy() ...
    
    ... in various operations
    
    This guarantees that their required/invalidated rectangles are
    calculated correctly regardless of the used abyss policy.  See the
    previous commit.

 operations/common-gpl3+/edge.c         |   16 ++++++++++++++--
 operations/common-gpl3+/ripple.c       |   21 ++++++++++++++++-----
 operations/common-gpl3+/waves.c        |   22 +++++++++++++++++-----
 operations/common/convolution-matrix.c |   17 +++++++++++++++--
 4 files changed, 62 insertions(+), 14 deletions(-)
---
diff --git a/operations/common-gpl3+/edge.c b/operations/common-gpl3+/edge.c
index feb4f08..988ec85 100644
--- a/operations/common-gpl3+/edge.c
+++ b/operations/common-gpl3+/edge.c
@@ -240,6 +240,15 @@ get_bounding_box (GeglOperation *operation)
   return result;
 }
 
+static GeglAbyssPolicy
+get_abyss_policy (GeglOperation *operation,
+                  const gchar   *input_pad)
+{
+  GeglProperties *o = GEGL_PROPERTIES (operation);
+
+  return o->border_behavior;
+}
+
 static gboolean
 process (GeglOperation       *operation,
          GeglBuffer          *input,
@@ -335,12 +344,15 @@ process (GeglOperation       *operation,
 static void
 gegl_op_class_init (GeglOpClass *klass)
 {
-  GeglOperationClass       *operation_class;
-  GeglOperationFilterClass *filter_class;
+  GeglOperationClass           *operation_class;
+  GeglOperationFilterClass     *filter_class;
+  GeglOperationAreaFilterClass *area_class;
 
   operation_class = GEGL_OPERATION_CLASS (klass);
   filter_class    = GEGL_OPERATION_FILTER_CLASS (klass);
+  area_class      = GEGL_OPERATION_AREA_FILTER_CLASS (klass);
 
+  area_class->get_abyss_policy      = get_abyss_policy;
   filter_class->process             = process;
   operation_class->prepare          = prepare;
   operation_class->get_bounding_box = get_bounding_box;
diff --git a/operations/common-gpl3+/ripple.c b/operations/common-gpl3+/ripple.c
index 17dcb1f..72c9ed1 100644
--- a/operations/common-gpl3+/ripple.c
+++ b/operations/common-gpl3+/ripple.c
@@ -91,6 +91,15 @@ prepare (GeglOperation *operation)
                              babl_format ("RGBA float"));
 }
 
+static GeglAbyssPolicy
+get_abyss_policy (GeglOperation *operation,
+                  const gchar   *input_pad)
+{
+  GeglProperties *o = GEGL_PROPERTIES (operation);
+
+  return o->abyss_policy;
+}
+
 static gboolean
 process (GeglOperation       *operation,
          GeglBuffer          *input,
@@ -227,18 +236,20 @@ process (GeglOperation       *operation,
   return TRUE;
 }
 
-
 static void
 gegl_op_class_init (GeglOpClass *klass)
 {
-  GeglOperationClass       *operation_class;
-  GeglOperationFilterClass *filter_class;
+  GeglOperationClass           *operation_class;
+  GeglOperationFilterClass     *filter_class;
+  GeglOperationAreaFilterClass *area_class;
 
   operation_class = GEGL_OPERATION_CLASS (klass);
   filter_class    = GEGL_OPERATION_FILTER_CLASS (klass);
+  area_class      = GEGL_OPERATION_AREA_FILTER_CLASS (klass);
 
-  operation_class->prepare = prepare;
-  filter_class->process    = process;
+  operation_class->prepare     = prepare;
+  filter_class->process        = process;
+  area_class->get_abyss_policy = get_abyss_policy;
 
   gegl_operation_class_set_keys (operation_class,
     "name",               "gegl:ripple",
diff --git a/operations/common-gpl3+/waves.c b/operations/common-gpl3+/waves.c
index 5cdca60..7348ae3 100644
--- a/operations/common-gpl3+/waves.c
+++ b/operations/common-gpl3+/waves.c
@@ -79,6 +79,15 @@ prepare (GeglOperation *operation)
   gegl_operation_set_format (operation, "output", babl_format ("RGBA float"));
 }
 
+static GeglAbyssPolicy
+get_abyss_policy (GeglOperation *operation,
+                  const gchar   *input_pad)
+{
+  GeglProperties *o = GEGL_PROPERTIES (operation);
+
+  return o->clamp ? GEGL_ABYSS_CLAMP : GEGL_ABYSS_NONE;
+}
+
 static gboolean
 process (GeglOperation       *operation,
          GeglBuffer          *input,
@@ -94,7 +103,7 @@ process (GeglOperation       *operation,
   GeglRectangle      *in_extent = gegl_operation_source_get_bounding_box (operation, "input");
   GeglBufferIterator *iter;
 
-  GeglAbyssPolicy abyss = o->clamp ? GEGL_ABYSS_CLAMP : GEGL_ABYSS_NONE;
+  GeglAbyssPolicy abyss = get_abyss_policy (operation, "input");
 
   gdouble px_x = gegl_coordinate_relative_to_pixel (o->x, in_extent->width);
   gdouble px_y = gegl_coordinate_relative_to_pixel (o->y, in_extent->height);
@@ -170,14 +179,17 @@ process (GeglOperation       *operation,
 static void
 gegl_op_class_init (GeglOpClass *klass)
 {
-  GeglOperationClass       *operation_class;
-  GeglOperationFilterClass *filter_class;
+  GeglOperationClass           *operation_class;
+  GeglOperationFilterClass     *filter_class;
+  GeglOperationAreaFilterClass *area_class;
 
   operation_class = GEGL_OPERATION_CLASS (klass);
   filter_class    = GEGL_OPERATION_FILTER_CLASS (klass);
+  area_class      = GEGL_OPERATION_AREA_FILTER_CLASS (klass);
 
-  operation_class->prepare = prepare;
-  filter_class->process    = process;
+  operation_class->prepare     = prepare;
+  filter_class->process        = process;
+  area_class->get_abyss_policy = get_abyss_policy;
 
   gegl_operation_class_set_keys (operation_class,
     "name",               "gegl:waves",
diff --git a/operations/common/convolution-matrix.c b/operations/common/convolution-matrix.c
index 77fa811..4ec9fe5 100644
--- a/operations/common/convolution-matrix.c
+++ b/operations/common/convolution-matrix.c
@@ -598,14 +598,27 @@ get_required_for_output (GeglOperation       *operation,
   return get_bounding_box (operation);
 }
 
+static GeglAbyssPolicy
+get_abyss_policy (GeglOperation *operation,
+                  const gchar   *input_pad)
+{
+  GeglProperties *o = GEGL_PROPERTIES (operation);
+
+  return o->border;
+}
+
 static void
 gegl_op_class_init (GeglOpClass *klass)
 {
-  GeglOperationClass       *operation_class;
-  GeglOperationFilterClass *filter_class;
+  GeglOperationClass           *operation_class;
+  GeglOperationFilterClass     *filter_class;
+  GeglOperationAreaFilterClass *area_class;
 
   operation_class = GEGL_OPERATION_CLASS (klass);
   filter_class    = GEGL_OPERATION_FILTER_CLASS (klass);
+  area_class      = GEGL_OPERATION_AREA_FILTER_CLASS (klass);
+
+  area_class->get_abyss_policy             = get_abyss_policy;
   filter_class->process                    = process;
   operation_class->prepare                 = prepare;
   operation_class->get_bounding_box        = get_bounding_box;


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