[gimp/metadata-browser] app: remove the legacy posterize code



commit c0076c7f4b6167470092bef2ecd1b767e67da8ac
Author: Michael Natterer <mitch gimp org>
Date:   Wed Mar 14 00:09:21 2012 +0100

    app: remove the legacy posterize code

 app/base/lut-funcs.c              |   46 -------------------------------------
 app/base/lut-funcs.h              |    6 -----
 app/core/gimpdrawable-posterize.c |   46 ++++++++++--------------------------
 app/tools/gimpposterizetool.c     |   40 --------------------------------
 app/tools/gimpposterizetool.h     |    1 -
 5 files changed, 13 insertions(+), 126 deletions(-)
---
diff --git a/app/base/lut-funcs.c b/app/base/lut-funcs.c
index de9d642..d612565 100644
--- a/app/base/lut-funcs.c
+++ b/app/base/lut-funcs.c
@@ -236,52 +236,6 @@ threshold_lut_new (gdouble value,
   return lut;
 }
 
-/* --------------- posterize ---------------- */
-
-static gfloat
-posterize_lut_func (gint   *ilevels,
-                    gint    n_channels,
-                    gint    channel,
-                    gfloat  value)
-{
-  gint levels;
-
-  /* don't posterize the alpha channel */
-  if ((n_channels == 2 || n_channels == 4) && channel == n_channels -1)
-    return value;
-
-  if (*ilevels < 2)
-    levels = 2;
-  else
-    levels = *ilevels;
-
-  value = RINT (value * (levels - 1.0)) / (levels - 1.0);
-
-  return value;
-}
-
-void
-posterize_lut_setup (GimpLut *lut,
-                     gint     levels,
-                     gint     n_channels)
-{
-  g_return_if_fail (lut != NULL);
-
-  gimp_lut_setup_exact (lut,
-                        (GimpLutFunc) posterize_lut_func, &levels, n_channels);
-}
-
-GimpLut *
-posterize_lut_new (gint levels,
-                   gint n_channels)
-{
-  GimpLut *lut = gimp_lut_new ();
-
-  posterize_lut_setup (lut, levels, n_channels);
-
-  return lut;
-}
-
 /* --------------- equalize ------------- */
 
 typedef struct
diff --git a/app/base/lut-funcs.h b/app/base/lut-funcs.h
index c2779b6..647e4b6 100644
--- a/app/base/lut-funcs.h
+++ b/app/base/lut-funcs.h
@@ -38,12 +38,6 @@ GimpLut * intersect_lut_new             (gdouble        value,
 GimpLut * threshold_lut_new             (gdouble        value,
                                          gint           n_channels);
 
-GimpLut * posterize_lut_new             (gint           levels,
-                                         gint           n_channels);
-void      posterize_lut_setup           (GimpLut       *lut,
-                                         gint           levels,
-                                         gint           n_channels);
-
 GimpLut * equalize_lut_new              (GimpHistogram *histogram,
                                          gint           n_channels);
 
diff --git a/app/core/gimpdrawable-posterize.c b/app/core/gimpdrawable-posterize.c
index fda5d43..540ca48 100644
--- a/app/core/gimpdrawable-posterize.c
+++ b/app/core/gimpdrawable-posterize.c
@@ -21,19 +21,11 @@
 
 #include "core-types.h"
 
-#include "base/gimplut.h"
-#include "base/lut-funcs.h"
-
 #include "gegl/gimpposterizeconfig.h"
 
-/* temp */
-#include "gimp.h"
-#include "gimpimage.h"
-
 #include "gimpdrawable.h"
 #include "gimpdrawable-operation.h"
 #include "gimpdrawable-posterize.h"
-#include "gimpdrawable-process.h"
 
 #include "gimp-intl.h"
 
@@ -45,40 +37,28 @@ gimp_drawable_posterize (GimpDrawable *drawable,
                          GimpProgress *progress,
                          gint          levels)
 {
-  GimpPosterizeConfig *config;
+  GeglNode *node;
+  GObject  *config;
 
   g_return_if_fail (GIMP_IS_DRAWABLE (drawable));
   g_return_if_fail (! gimp_drawable_is_indexed (drawable));
   g_return_if_fail (gimp_item_is_attached (GIMP_ITEM (drawable)));
 
+  node = g_object_new (GEGL_TYPE_NODE,
+                       "operation", "gimp:posterize",
+                       NULL);
+
   config = g_object_new (GIMP_TYPE_POSTERIZE_CONFIG,
                          "levels", levels,
                          NULL);
 
-  if (gimp_use_gegl (gimp_item_get_image (GIMP_ITEM (drawable))->gimp))
-    {
-      GeglNode *node;
-
-      node = g_object_new (GEGL_TYPE_NODE,
-                           "operation", "gimp:posterize",
-                           NULL);
-      gegl_node_set (node,
-                     "config", config,
-                     NULL);
-
-      gimp_drawable_apply_operation (drawable, progress, _("Posterize"),
-                                     node, TRUE);
-      g_object_unref (node);
-    }
-  else
-    {
-      GimpLut *lut;
-
-      lut = posterize_lut_new (config->levels, gimp_drawable_bytes (drawable));
-
-      gimp_drawable_process_lut (drawable, progress, _("Posterize"), lut);
-      gimp_lut_free (lut);
-    }
+  gegl_node_set (node,
+                 "config", config,
+                 NULL);
 
   g_object_unref (config);
+
+  gimp_drawable_apply_operation (drawable, progress, _("Posterize"),
+                                 node, TRUE);
+  g_object_unref (node);
 }
diff --git a/app/tools/gimpposterizetool.c b/app/tools/gimpposterizetool.c
index 8f057b4..2cbc79f 100644
--- a/app/tools/gimpposterizetool.c
+++ b/app/tools/gimpposterizetool.c
@@ -26,9 +26,6 @@
 
 #include "tools-types.h"
 
-#include "base/gimplut.h"
-#include "base/lut-funcs.h"
-
 #include "gegl/gimpposterizeconfig.h"
 
 #include "core/gimpdrawable.h"
@@ -48,15 +45,12 @@
 #define SLIDER_WIDTH 200
 
 
-static void       gimp_posterize_tool_finalize       (GObject           *object);
-
 static gboolean   gimp_posterize_tool_initialize     (GimpTool          *tool,
                                                       GimpDisplay       *display,
                                                       GError           **error);
 
 static GeglNode * gimp_posterize_tool_get_operation  (GimpImageMapTool  *im_tool,
                                                       GObject          **config);
-static void       gimp_posterize_tool_map            (GimpImageMapTool  *im_tool);
 static void       gimp_posterize_tool_dialog         (GimpImageMapTool  *im_tool);
 
 static void       gimp_posterize_tool_config_notify  (GObject           *object,
@@ -92,44 +86,20 @@ gimp_posterize_tool_register (GimpToolRegisterCallback  callback,
 static void
 gimp_posterize_tool_class_init (GimpPosterizeToolClass *klass)
 {
-  GObjectClass          *object_class  = G_OBJECT_CLASS (klass);
   GimpToolClass         *tool_class    = GIMP_TOOL_CLASS (klass);
   GimpImageMapToolClass *im_tool_class = GIMP_IMAGE_MAP_TOOL_CLASS (klass);
 
-  object_class->finalize       = gimp_posterize_tool_finalize;
-
   tool_class->initialize       = gimp_posterize_tool_initialize;
 
   im_tool_class->dialog_desc   = _("Posterize (Reduce Number of Colors)");
 
   im_tool_class->get_operation = gimp_posterize_tool_get_operation;
-  im_tool_class->map           = gimp_posterize_tool_map;
   im_tool_class->dialog        = gimp_posterize_tool_dialog;
 }
 
 static void
 gimp_posterize_tool_init (GimpPosterizeTool *posterize_tool)
 {
-  GimpImageMapTool *im_tool = GIMP_IMAGE_MAP_TOOL (posterize_tool);
-
-  posterize_tool->lut = gimp_lut_new ();
-
-  im_tool->apply_func = (GimpImageMapApplyFunc) gimp_lut_process;
-  im_tool->apply_data = posterize_tool->lut;
-}
-
-static void
-gimp_posterize_tool_finalize (GObject *object)
-{
-  GimpPosterizeTool *posterize_tool = GIMP_POSTERIZE_TOOL (object);
-
-  if (posterize_tool->lut)
-    {
-      gimp_lut_free (posterize_tool->lut);
-      posterize_tool->lut = NULL;
-    }
-
-  G_OBJECT_CLASS (parent_class)->finalize (object);
 }
 
 static gboolean
@@ -194,16 +164,6 @@ gimp_posterize_tool_get_operation (GimpImageMapTool  *image_map_tool,
   return node;
 }
 
-static void
-gimp_posterize_tool_map (GimpImageMapTool *image_map_tool)
-{
-  GimpPosterizeTool *posterize_tool = GIMP_POSTERIZE_TOOL (image_map_tool);
-
-  posterize_lut_setup (posterize_tool->lut,
-                       posterize_tool->config->levels,
-                       gimp_drawable_bytes (image_map_tool->drawable));
-}
-
 
 /**********************/
 /*  Posterize dialog  */
diff --git a/app/tools/gimpposterizetool.h b/app/tools/gimpposterizetool.h
index 91ccf20..e2f747b 100644
--- a/app/tools/gimpposterizetool.h
+++ b/app/tools/gimpposterizetool.h
@@ -38,7 +38,6 @@ struct _GimpPosterizeTool
   GimpImageMapTool     parent_instance;
 
   GimpPosterizeConfig *config;
-  GimpLut             *lut;
 
   /*  dialog  */
   GtkAdjustment       *levels_data;



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