[gegl] gegl: move color-reduction's GeglDitherStrategy enum to gegl-enums.[ch]



commit a2df606a799f1d1620d35bd1d49901301c085f66
Author: Michael Natterer <mitch gimp org>
Date:   Mon Sep 26 15:16:43 2016 +0200

    gegl: move color-reduction's GeglDitherStrategy enum to gegl-enums.[ch]
    
    and rename it to GeglDitherMethod.

 gegl/gegl-enums.c                   |   29 +++++++++++++++++++++++++++++
 gegl/gegl-enums.h                   |   14 ++++++++++++++
 operations/common/color-reduction.c |   29 ++++++++++-------------------
 3 files changed, 53 insertions(+), 19 deletions(-)
---
diff --git a/gegl/gegl-enums.c b/gegl/gegl-enums.c
index a915fea..7dd4631 100644
--- a/gegl/gegl-enums.c
+++ b/gegl/gegl-enums.c
@@ -77,6 +77,35 @@ gegl_access_mode_get_type (void)
 }
 
 GType
+gegl_dither_method_get_type (void)
+{
+  static GType etype = 0;
+
+  if (etype == 0)
+    {
+      static GEnumValue values[] = {
+        { GEGL_DITHER_NONE,             N_("None"),             "none"             },
+        { GEGL_DITHER_RANDOM,           N_("Random"),           "random"           },
+        { GEGL_DITHER_RESILIENT,        N_("Resilient"),        "resilient"        },
+        { GEGL_DITHER_RANDOM_COVARIANT, N_("Random Covariant"), "random-covariant" },
+        { GEGL_DITHER_BAYER,            N_("Bayer"),            "bayer"            },
+        { GEGL_DITHER_FLOYD_STEINBERG,  N_("Floyd-Steinberg"),  "floyd-steinberg"  },
+        { 0, NULL, NULL }
+      };
+      gint i;
+
+      for (i = 0; i < G_N_ELEMENTS (values); i++)
+        if (values[i].value_name)
+          values[i].value_name =
+            dgettext (GETTEXT_PACKAGE, values[i].value_name);
+
+      etype = g_enum_register_static ("GeglDitherMethod", values);
+    }
+
+  return etype;
+}
+
+GType
 gegl_orientation_get_type (void)
 {
   static GType etype = 0;
diff --git a/gegl/gegl-enums.h b/gegl/gegl-enums.h
index af00843..3c08716 100644
--- a/gegl/gegl-enums.h
+++ b/gegl/gegl-enums.h
@@ -61,6 +61,20 @@ GType gegl_access_mode_get_type (void) G_GNUC_CONST;
 
 
 typedef enum {
+  GEGL_DITHER_NONE,
+  GEGL_DITHER_RANDOM,
+  GEGL_DITHER_RESILIENT,
+  GEGL_DITHER_RANDOM_COVARIANT,
+  GEGL_DITHER_BAYER,
+  GEGL_DITHER_FLOYD_STEINBERG
+} GeglDitherMethod;
+
+GType gegl_dither_method_get_type (void) G_GNUC_CONST;
+
+#define GEGL_TYPE_DITHER_METHOD (gegl_dither_method_get_type ())
+
+
+typedef enum {
   GEGL_ORIENTATION_HORIZONTAL,
   GEGL_ORIENTATION_VERTICAL
 } GeglOrientation;
diff --git a/operations/common/color-reduction.c b/operations/common/color-reduction.c
index 245e263..8cd8109 100644
--- a/operations/common/color-reduction.c
+++ b/operations/common/color-reduction.c
@@ -23,15 +23,6 @@
 
 #ifdef GEGL_PROPERTIES
 
-enum_start (gegl_dither_strategy)
-  enum_value (GEGL_DITHER_NONE,             "none",             N_("None"))
-  enum_value (GEGL_DITHER_RANDOM,           "random",           N_("Random"))
-  enum_value (GEGL_DITHER_RESILIENT,        "resilient",        N_("Resilient"))
-  enum_value (GEGL_DITHER_RANDOM_COVARIANT, "random-covariant", N_("Random Covariant"))
-  enum_value (GEGL_DITHER_BAYER,            "bayer",            N_("Bayer"))
-  enum_value (GEGL_DITHER_FLOYD_STEINBERG,  "floyd-steinberg",  N_("Floyd-Steinberg"))
-enum_end (GeglDitherStrategy)
-
 property_int  (red_bits, _("Red bits"), 8)
     description(_("Number of bits for red channel"))
     value_range (1, 16)
@@ -48,9 +39,9 @@ property_int  (alpha_bits, _("Alpha bits"), 8)
     description(_("Number of bits for alpha channel"))
     value_range (1, 16)
 
-property_enum (dither_strategy, _("Dithering strategy"),
-               GeglDitherStrategy, gegl_dither_strategy, GEGL_DITHER_RESILIENT)
-    description (_("The dithering strategy to use"))
+property_enum (dither_method, _("Dithering method"),
+               GeglDitherMethod, gegl_dither_method, GEGL_DITHER_RESILIENT)
+    description (_("The dithering method to use"))
 
 property_seed (seed, _("Random seed"), rand)
 
@@ -380,7 +371,7 @@ process_standard (GeglBuffer          *input,
                   const GeglRectangle *result,
                   guint               *channel_bits,
                   GeglRandom          *rand,
-                  GeglDitherStrategy   dither_strategy)
+                  GeglDitherMethod     dither_method)
 {
   GeglBufferIterator *gi;
   guint               channel_mask [4];
@@ -398,7 +389,7 @@ process_standard (GeglBuffer          *input,
       guint    y;
       for (y = 0; y < gi->roi->height; y++)
         {
-          switch (dither_strategy)
+          switch (dither_method)
             {
             case GEGL_DITHER_NONE:
               process_row_no_dither (gi, channel_mask, channel_bits, y);
@@ -432,7 +423,7 @@ get_required_for_output (GeglOperation       *self,
 {
   GeglProperties *o = GEGL_PROPERTIES (self);
 
-  if (o->dither_strategy == GEGL_DITHER_FLOYD_STEINBERG)
+  if (o->dither_method == GEGL_DITHER_FLOYD_STEINBERG)
     return *gegl_operation_source_get_bounding_box (self, "input");
   else
     return *roi;
@@ -444,7 +435,7 @@ get_cached_region (GeglOperation       *self,
 {
   GeglProperties *o = GEGL_PROPERTIES (self);
 
-  if (o->dither_strategy == GEGL_DITHER_FLOYD_STEINBERG)
+  if (o->dither_method == GEGL_DITHER_FLOYD_STEINBERG)
     return *gegl_operation_source_get_bounding_box (self, "input");
   else
     return *roi;
@@ -465,9 +456,9 @@ process (GeglOperation       *operation,
   channel_bits [2] = o->blue_bits;
   channel_bits [3] = o->alpha_bits;
 
-  if (o->dither_strategy != GEGL_DITHER_FLOYD_STEINBERG)
+  if (o->dither_method != GEGL_DITHER_FLOYD_STEINBERG)
     process_standard (input, output, result, channel_bits,
-                      o->rand, o->dither_strategy);
+                      o->rand, o->dither_method);
   else
     process_floyd_steinberg (input, output, result, channel_bits);
 
@@ -487,7 +478,7 @@ gegl_op_class_init (GeglOpClass *klass)
     "    <param name='green-bits'>2</param>"
     "    <param name='blue-bits'>2</param>"
     "    <param name='alpha-bits'>2</param>"
-    "    <param name='dither-strategy'>floyd-steinberg</param>"
+    "    <param name='dither-method'>floyd-steinberg</param>"
     "  </params>"
     "</node>"
     "<node operation='gegl:load'>"


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