[gimp/goat-invasion: 230/412] app: remove the legacy curves cruft
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp/goat-invasion: 230/412] app: remove the legacy curves cruft
- Date: Tue, 3 Apr 2012 09:52:26 +0000 (UTC)
commit d16b688565f77cf1ae31cbcf995056ca9df076bd
Author: Michael Natterer <mitch gimp org>
Date: Fri Mar 23 09:55:35 2012 +0100
app: remove the legacy curves cruft
and move PDB parameter collection into GimpCurvesConfig convenience
constructors.
app/base/Makefile.am | 2 -
app/base/base-types.h | 1 -
app/base/curves.c | 100 ----------------------
app/base/curves.h | 35 --------
app/core/Makefile.am | 2 -
app/core/gimpdrawable-curves.c | 182 ----------------------------------------
app/core/gimpdrawable-curves.h | 34 --------
app/gegl/gimpcurvesconfig.c | 97 ++++++++++++++-------
app/gegl/gimpcurvesconfig.h | 13 ++--
app/pdb/color-cmds.c | 62 +++++++++-----
app/tools/gimpcurvestool.c | 50 +-----------
app/tools/gimpcurvestool.h | 1 -
tools/pdbgen/pdb/color.pdb | 64 +++++++++-----
13 files changed, 151 insertions(+), 492 deletions(-)
---
diff --git a/app/base/Makefile.am b/app/base/Makefile.am
index 46f93da..0381afa 100644
--- a/app/base/Makefile.am
+++ b/app/base/Makefile.am
@@ -26,8 +26,6 @@ libappbase_a_SOURCES = \
color-balance.h \
cpercep.c \
cpercep.h \
- curves.c \
- curves.h \
gimphistogram.c \
gimphistogram.h \
gimplut.c \
diff --git a/app/base/base-types.h b/app/base/base-types.h
index eb269dd..41c2752 100644
--- a/app/base/base-types.h
+++ b/app/base/base-types.h
@@ -51,7 +51,6 @@ typedef struct _GimpHistogram GimpHistogram;
typedef struct _GimpLut GimpLut;
typedef struct _ColorBalance ColorBalance;
-typedef struct _Curves Curves;
typedef struct _HueSaturation HueSaturation;
typedef struct _Levels Levels;
typedef struct _Threshold Threshold;
diff --git a/app/core/Makefile.am b/app/core/Makefile.am
index 64b8344..9abcb10 100644
--- a/app/core/Makefile.am
+++ b/app/core/Makefile.am
@@ -132,8 +132,6 @@ libappcore_a_sources = \
gimpdrawable-combine.h \
gimpdrawable-convert.c \
gimpdrawable-convert.h \
- gimpdrawable-curves.c \
- gimpdrawable-curves.h \
gimpdrawable-equalize.c \
gimpdrawable-equalize.h \
gimpdrawable-foreground-extract.c \
diff --git a/app/gegl/gimpcurvesconfig.c b/app/gegl/gimpcurvesconfig.c
index 6bb96f9..c5a0663 100644
--- a/app/gegl/gimpcurvesconfig.c
+++ b/app/gegl/gimpcurvesconfig.c
@@ -34,9 +34,6 @@
#include "base/gimphistogram.h"
-/* temp cruft */
-#include "base/curves.h"
-
#include "core/gimpcurve.h"
#include "gimpcurvesconfig.h"
@@ -354,6 +351,70 @@ gimp_curves_config_curve_dirty (GimpCurve *curve,
/* public functions */
+GObject *
+gimp_curves_config_new_spline (gint32 channel,
+ const guint8 *points,
+ gint n_points)
+{
+ GimpCurvesConfig *config;
+ GimpCurve *curve;
+ gint i;
+
+ g_return_val_if_fail (channel >= GIMP_HISTOGRAM_VALUE &&
+ channel <= GIMP_HISTOGRAM_ALPHA, NULL);
+
+ config = g_object_new (GIMP_TYPE_CURVES_CONFIG, NULL);
+
+ curve = config->curve[channel];
+
+ gimp_data_freeze (GIMP_DATA (curve));
+
+ /* FIXME: create a curves object with the right number of points */
+ /* unset the last point */
+ gimp_curve_set_point (curve, curve->n_points - 1, -1, -1);
+
+ n_points = MIN (n_points / 2, curve->n_points);
+
+ for (i = 0; i < n_points; i++)
+ gimp_curve_set_point (curve, i,
+ (gdouble) points[i * 2] / 255.0,
+ (gdouble) points[i * 2 + 1] / 255.0);
+
+ gimp_data_thaw (GIMP_DATA (curve));
+
+ return G_OBJECT (config);
+}
+
+GObject *
+gimp_curves_config_new_explicit (gint32 channel,
+ const guint8 *points,
+ gint n_points)
+{
+ GimpCurvesConfig *config;
+ GimpCurve *curve;
+ gint i;
+
+ g_return_val_if_fail (channel >= GIMP_HISTOGRAM_VALUE &&
+ channel <= GIMP_HISTOGRAM_ALPHA, NULL);
+
+ config = g_object_new (GIMP_TYPE_CURVES_CONFIG, NULL);
+
+ curve = config->curve[channel];
+
+ gimp_data_freeze (GIMP_DATA (curve));
+
+ gimp_curve_set_curve_type (curve, GIMP_CURVE_FREE);
+
+ for (i = 0; i < 256; i++)
+ gimp_curve_set_curve (curve,
+ (gdouble) i / 255.0,
+ (gdouble) points[i] / 255.0);
+
+ gimp_data_thaw (GIMP_DATA (curve));
+
+ return G_OBJECT (config);
+}
+
void
gimp_curves_config_reset_channel (GimpCurvesConfig *config)
{
@@ -506,33 +567,3 @@ gimp_curves_config_save_cruft (GimpCurvesConfig *config,
return TRUE;
}
-
-
-/* temp cruft */
-
-void
-gimp_curves_config_to_cruft (GimpCurvesConfig *config,
- Curves *cruft,
- gboolean is_color)
-{
- GimpHistogramChannel channel;
-
- g_return_if_fail (GIMP_IS_CURVES_CONFIG (config));
- g_return_if_fail (cruft != NULL);
-
- for (channel = GIMP_HISTOGRAM_VALUE;
- channel <= GIMP_HISTOGRAM_ALPHA;
- channel++)
- {
- gimp_curve_get_uchar (config->curve[channel],
- sizeof (cruft->curve[channel]),
- cruft->curve[channel]);
- }
-
- if (! is_color)
- {
- gimp_curve_get_uchar (config->curve[GIMP_HISTOGRAM_ALPHA],
- sizeof (cruft->curve[1]),
- cruft->curve[1]);
- }
-}
diff --git a/app/gegl/gimpcurvesconfig.h b/app/gegl/gimpcurvesconfig.h
index 169772c..ecfd15e 100644
--- a/app/gegl/gimpcurvesconfig.h
+++ b/app/gegl/gimpcurvesconfig.h
@@ -52,6 +52,13 @@ struct _GimpCurvesConfigClass
GType gimp_curves_config_get_type (void) G_GNUC_CONST;
+GObject * gimp_curves_config_new_spline (gint32 channel,
+ const guint8 *points,
+ gint n_points);
+GObject * gimp_curves_config_new_explicit (gint32 channel,
+ const guint8 *points,
+ gint n_points);
+
void gimp_curves_config_reset_channel (GimpCurvesConfig *config);
gboolean gimp_curves_config_load_cruft (GimpCurvesConfig *config,
@@ -62,10 +69,4 @@ gboolean gimp_curves_config_save_cruft (GimpCurvesConfig *config,
GError **error);
-/* temp cruft */
-void gimp_curves_config_to_cruft (GimpCurvesConfig *config,
- Curves *cruft,
- gboolean is_color);
-
-
#endif /* __GIMP_CURVES_CONFIG_H__ */
diff --git a/app/pdb/color-cmds.c b/app/pdb/color-cmds.c
index f270d7e..67c71a9 100644
--- a/app/pdb/color-cmds.c
+++ b/app/pdb/color-cmds.c
@@ -25,7 +25,6 @@
#include "base/gimphistogram.h"
#include "core/gimpdrawable-color-balance.h"
-#include "core/gimpdrawable-curves.h"
#include "core/gimpdrawable-equalize.h"
#include "core/gimpdrawable-histogram.h"
#include "core/gimpdrawable-hue-saturation.h"
@@ -35,6 +34,7 @@
#include "core/gimpparamspecs.h"
#include "gegl/gimpbrightnesscontrastconfig.h"
#include "gegl/gimpcolorizeconfig.h"
+#include "gegl/gimpcurvesconfig.h"
#include "gegl/gimpdesaturateconfig.h"
#include "gegl/gimpposterizeconfig.h"
#include "gegl/gimpthresholdconfig.h"
@@ -393,18 +393,26 @@ curves_spline_invoker (GimpProcedure *procedure,
if (success)
{
- if (! gimp_pdb_item_is_attached (GIMP_ITEM (drawable), NULL, TRUE, error) ||
- ! gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), error) ||
- gimp_drawable_is_indexed (drawable) || (num_points & 1) ||
- (! gimp_drawable_has_alpha (drawable) &&
- channel == GIMP_HISTOGRAM_ALPHA) ||
- (gimp_drawable_is_gray (drawable) &&
- channel != GIMP_HISTOGRAM_VALUE && channel != GIMP_HISTOGRAM_ALPHA))
- success = FALSE;
+ if (gimp_pdb_item_is_attached (GIMP_ITEM (drawable), NULL, TRUE, error) &&
+ gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), error) &&
+ ! (num_points & 1) &&
+ (gimp_drawable_has_alpha (drawable) || channel != GIMP_HISTOGRAM_ALPHA) &&
+ (! gimp_drawable_is_gray (drawable) ||
+ channel == GIMP_HISTOGRAM_VALUE || channel == GIMP_HISTOGRAM_ALPHA))
+ {
+ GObject *config = gimp_curves_config_new_spline (channel,
+ control_pts,
+ num_points);
- if (success)
- gimp_drawable_curves_spline (drawable, progress,
- channel, control_pts, num_points);
+ gimp_drawable_apply_operation_by_name (drawable, progress,
+ C_("undo-type", "Curves"),
+ "gimp:curves",
+ config, TRUE);
+
+ g_object_unref (config);
+ }
+ else
+ success = FALSE;
}
return gimp_procedure_get_return_values (procedure, success,
@@ -432,18 +440,26 @@ curves_explicit_invoker (GimpProcedure *procedure,
if (success)
{
- if (! gimp_pdb_item_is_attached (GIMP_ITEM (drawable), NULL, TRUE, error) ||
- ! gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), error) ||
- gimp_drawable_is_indexed (drawable) || (num_bytes != 256) ||
- (! gimp_drawable_has_alpha (drawable) &&
- channel == GIMP_HISTOGRAM_ALPHA) ||
- (gimp_drawable_is_gray (drawable) &&
- channel != GIMP_HISTOGRAM_VALUE && channel != GIMP_HISTOGRAM_ALPHA))
- success = FALSE;
+ if (gimp_pdb_item_is_attached (GIMP_ITEM (drawable), NULL, TRUE, error) &&
+ gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), error) &&
+ (num_bytes == 256) &&
+ (gimp_drawable_has_alpha (drawable) || channel != GIMP_HISTOGRAM_ALPHA) &&
+ (! gimp_drawable_is_gray (drawable) ||
+ channel == GIMP_HISTOGRAM_VALUE || channel == GIMP_HISTOGRAM_ALPHA))
+ {
+ GObject *config = gimp_curves_config_new_spline (channel,
+ curve,
+ num_bytes);
- if (success)
- gimp_drawable_curves_explicit (drawable, progress,
- channel, curve, num_bytes);
+ gimp_drawable_apply_operation_by_name (drawable, progress,
+ C_("undo-type", "Curves"),
+ "gimp:curves",
+ config, TRUE);
+
+ g_object_unref (config);
+ }
+ else
+ success = FALSE;
}
return gimp_procedure_get_return_values (procedure, success,
diff --git a/app/tools/gimpcurvestool.c b/app/tools/gimpcurvestool.c
index f2f6603..a53457b 100644
--- a/app/tools/gimpcurvestool.c
+++ b/app/tools/gimpcurvestool.c
@@ -30,9 +30,7 @@
#include "tools-types.h"
-#include "base/curves.h"
#include "base/gimphistogram.h"
-#include "base/gimplut.h"
#include "gegl/gimpcurvesconfig.h"
#include "gegl/gimpoperationcurves.h"
@@ -65,8 +63,6 @@
/* local function prototypes */
-static void gimp_curves_tool_finalize (GObject *object);
-
static gboolean gimp_curves_tool_initialize (GimpTool *tool,
GimpDisplay *display,
GError **error);
@@ -92,7 +88,6 @@ static void gimp_curves_tool_color_picked (GimpColorTool *color_t
gint color_index);
static GeglNode * gimp_curves_tool_get_operation (GimpImageMapTool *image_map_tool,
GObject **config);
-static void gimp_curves_tool_map (GimpImageMapTool *image_map_tool);
static void gimp_curves_tool_dialog (GimpImageMapTool *image_map_tool);
static void gimp_curves_tool_reset (GimpImageMapTool *image_map_tool);
static gboolean gimp_curves_tool_settings_import(GimpImageMapTool *image_map_tool,
@@ -161,13 +156,10 @@ gimp_curves_tool_register (GimpToolRegisterCallback callback,
static void
gimp_curves_tool_class_init (GimpCurvesToolClass *klass)
{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
GimpToolClass *tool_class = GIMP_TOOL_CLASS (klass);
GimpColorToolClass *color_tool_class = GIMP_COLOR_TOOL_CLASS (klass);
GimpImageMapToolClass *im_tool_class = GIMP_IMAGE_MAP_TOOL_CLASS (klass);
- object_class->finalize = gimp_curves_tool_finalize;
-
tool_class->initialize = gimp_curves_tool_initialize;
tool_class->button_release = gimp_curves_tool_button_release;
tool_class->key_press = gimp_curves_tool_key_press;
@@ -181,7 +173,6 @@ gimp_curves_tool_class_init (GimpCurvesToolClass *klass)
im_tool_class->export_dialog_title = _("Export Curves");
im_tool_class->get_operation = gimp_curves_tool_get_operation;
- im_tool_class->map = gimp_curves_tool_map;
im_tool_class->dialog = gimp_curves_tool_dialog;
im_tool_class->reset = gimp_curves_tool_reset;
im_tool_class->settings_import = gimp_curves_tool_settings_import;
@@ -191,26 +182,10 @@ gimp_curves_tool_class_init (GimpCurvesToolClass *klass)
static void
gimp_curves_tool_init (GimpCurvesTool *tool)
{
- GimpImageMapTool *im_tool = GIMP_IMAGE_MAP_TOOL (tool);
- gint i;
-
- tool->lut = gimp_lut_new ();
+ gint i;
for (i = 0; i < G_N_ELEMENTS (tool->picked_color); i++)
tool->picked_color[i] = -1.0;
-
- im_tool->apply_func = (GimpImageMapApplyFunc) gimp_lut_process;
- im_tool->apply_data = tool->lut;
-}
-
-static void
-gimp_curves_tool_finalize (GObject *object)
-{
- GimpCurvesTool *tool = GIMP_CURVES_TOOL (object);
-
- gimp_lut_free (tool->lut);
-
- G_OBJECT_CLASS (parent_class)->finalize (object);
}
static gboolean
@@ -226,13 +201,6 @@ gimp_curves_tool_initialize (GimpTool *tool,
if (! drawable)
return FALSE;
- if (gimp_drawable_is_indexed (drawable))
- {
- g_set_error_literal (error, GIMP_ERROR, GIMP_FAILED,
- _("Curves does not operate on indexed layers."));
- return FALSE;
- }
-
gimp_config_reset (GIMP_CONFIG (c_tool->config));
if (! GIMP_TOOL_CLASS (parent_class)->initialize (tool, display, error))
@@ -408,22 +376,6 @@ gimp_curves_tool_get_operation (GimpImageMapTool *image_map_tool,
return node;
}
-static void
-gimp_curves_tool_map (GimpImageMapTool *image_map_tool)
-{
- GimpCurvesTool *tool = GIMP_CURVES_TOOL (image_map_tool);
- GimpDrawable *drawable = image_map_tool->drawable;
- Curves curves;
-
- gimp_curves_config_to_cruft (tool->config, &curves,
- gimp_drawable_is_rgb (drawable));
-
- gimp_lut_setup (tool->lut,
- (GimpLutFunc) curves_lut_func,
- &curves,
- gimp_drawable_bytes (drawable));
-}
-
/*******************/
/* Curves dialog */
diff --git a/app/tools/gimpcurvestool.h b/app/tools/gimpcurvestool.h
index 0c45be6..fea4f32 100644
--- a/app/tools/gimpcurvestool.h
+++ b/app/tools/gimpcurvestool.h
@@ -37,7 +37,6 @@ struct _GimpCurvesTool
GimpImageMapTool parent_instance;
GimpCurvesConfig *config;
- GimpLut *lut;
/* dialog */
gdouble picked_color[5];
diff --git a/tools/pdbgen/pdb/color.pdb b/tools/pdbgen/pdb/color.pdb
index 31863aa..9c615e1 100644
--- a/tools/pdbgen/pdb/color.pdb
+++ b/tools/pdbgen/pdb/color.pdb
@@ -415,21 +415,29 @@ HELP
);
%invoke = (
- headers => [ qw("core/gimpdrawable-curves.h") ],
+ headers => [ qw("gegl/gimpcurvesconfig.h") ],
code => <<'CODE'
{
- if (! gimp_pdb_item_is_attached (GIMP_ITEM (drawable), NULL, TRUE, error) ||
- ! gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), error) ||
- gimp_drawable_is_indexed (drawable) || (num_points & 1) ||
- (! gimp_drawable_has_alpha (drawable) &&
- channel == GIMP_HISTOGRAM_ALPHA) ||
- (gimp_drawable_is_gray (drawable) &&
- channel != GIMP_HISTOGRAM_VALUE && channel != GIMP_HISTOGRAM_ALPHA))
- success = FALSE;
+ if (gimp_pdb_item_is_attached (GIMP_ITEM (drawable), NULL, TRUE, error) &&
+ gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), error) &&
+ ! (num_points & 1) &&
+ (gimp_drawable_has_alpha (drawable) || channel != GIMP_HISTOGRAM_ALPHA) &&
+ (! gimp_drawable_is_gray (drawable) ||
+ channel == GIMP_HISTOGRAM_VALUE || channel == GIMP_HISTOGRAM_ALPHA))
+ {
+ GObject *config = gimp_curves_config_new_spline (channel,
+ control_pts,
+ num_points);
- if (success)
- gimp_drawable_curves_spline (drawable, progress,
- channel, control_pts, num_points);
+ gimp_drawable_apply_operation_by_name (drawable, progress,
+ C_("undo-type", "Curves"),
+ "gimp:curves",
+ config, TRUE);
+
+ g_object_unref (config);
+ }
+ else
+ success = FALSE;
}
CODE
);
@@ -462,21 +470,29 @@ HELP
);
%invoke = (
- headers => [ qw("core/gimpdrawable-curves.h") ],
+ headers => [ qw("gegl/gimpcurvesconfig.h") ],
code => <<'CODE'
{
- if (! gimp_pdb_item_is_attached (GIMP_ITEM (drawable), NULL, TRUE, error) ||
- ! gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), error) ||
- gimp_drawable_is_indexed (drawable) || (num_bytes != 256) ||
- (! gimp_drawable_has_alpha (drawable) &&
- channel == GIMP_HISTOGRAM_ALPHA) ||
- (gimp_drawable_is_gray (drawable) &&
- channel != GIMP_HISTOGRAM_VALUE && channel != GIMP_HISTOGRAM_ALPHA))
- success = FALSE;
+ if (gimp_pdb_item_is_attached (GIMP_ITEM (drawable), NULL, TRUE, error) &&
+ gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), error) &&
+ (num_bytes == 256) &&
+ (gimp_drawable_has_alpha (drawable) || channel != GIMP_HISTOGRAM_ALPHA) &&
+ (! gimp_drawable_is_gray (drawable) ||
+ channel == GIMP_HISTOGRAM_VALUE || channel == GIMP_HISTOGRAM_ALPHA))
+ {
+ GObject *config = gimp_curves_config_new_spline (channel,
+ curve,
+ num_bytes);
- if (success)
- gimp_drawable_curves_explicit (drawable, progress,
- channel, curve, num_bytes);
+ gimp_drawable_apply_operation_by_name (drawable, progress,
+ C_("undo-type", "Curves"),
+ "gimp:curves",
+ config, TRUE);
+
+ g_object_unref (config);
+ }
+ else
+ success = FALSE;
}
CODE
);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]