Commit a85213cd authored by Michael Natterer's avatar Michael Natterer 😴 Committed by Michael Natterer

app/gegl/Makefile.am app/gegl/gegl-types.h new parent class for all image

2008-01-25  Michael Natterer  <mitch@gimp.org>

	* app/gegl/Makefile.am
	* app/gegl/gegl-types.h
	* app/gegl/gimpoperationpointfilter.[ch]: new parent class for all
	image map operations. Features a "config" member and "public"
	get_property() and set_property() functions to be used by
	subclasses.

	* app/gegl/gimpoperationcolorbalance.[ch]
	* app/gegl/gimpoperationcolorize.[ch]
	* app/gegl/gimpoperationcurves.[ch]
	* app/gegl/gimpoperationhuesaturation.[ch]
	* app/gegl/gimpoperationlevels.[ch]
	* app/gegl/gimpoperationposterize.[ch]
	* app/gegl/gimpoperationthreshold.[ch]: derive from
	GimpOperationPointFilter, remove "config" members, remove
	finalize(), get_property() and set_property() implementations and
	use the ones provided by the parent class.


svn path=/trunk/; revision=24713
parent e79955d9
2008-01-25 Michael Natterer <mitch@gimp.org>
* app/gegl/Makefile.am
* app/gegl/gegl-types.h
* app/gegl/gimpoperationpointfilter.[ch]: new parent class for all
image map operations. Features a "config" member and "public"
get_property() and set_property() functions to be used by
subclasses.
* app/gegl/gimpoperationcolorbalance.[ch]
* app/gegl/gimpoperationcolorize.[ch]
* app/gegl/gimpoperationcurves.[ch]
* app/gegl/gimpoperationhuesaturation.[ch]
* app/gegl/gimpoperationlevels.[ch]
* app/gegl/gimpoperationposterize.[ch]
* app/gegl/gimpoperationthreshold.[ch]: derive from
GimpOperationPointFilter, remove "config" members, remove
finalize(), get_property() and set_property() implementations and
use the ones provided by the parent class.
2008-01-25 Michael Natterer <mitch@gimp.org>
* app/gegl/Makefile.am
......
......@@ -35,6 +35,8 @@ libappgegl_a_SOURCES = \
gimpoperationhuesaturation.h \
gimpoperationlevels.c \
gimpoperationlevels.h \
gimpoperationpointfilter.c \
gimpoperationpointfilter.h \
gimpoperationposterize.c \
gimpoperationposterize.h \
gimpoperationthreshold.c \
......
......@@ -34,6 +34,7 @@ typedef struct _GimpOperationCurves GimpOperationCurves;
typedef struct _GimpOperationDesaturate GimpOperationDesaturate;
typedef struct _GimpOperationHueSaturation GimpOperationHueSaturation;
typedef struct _GimpOperationLevels GimpOperationLevels;
typedef struct _GimpOperationPointFilter GimpOperationPointFilter;
typedef struct _GimpOperationPosterize GimpOperationPosterize;
typedef struct _GimpOperationThreshold GimpOperationThreshold;
typedef struct _GimpOperationTileSink GimpOperationTileSink;
......
......@@ -32,51 +32,34 @@
#include "gimpoperationcolorbalance.h"
enum
{
PROP_0,
PROP_CONFIG
};
static void gimp_operation_color_balance_finalize (GObject *object);
static void gimp_operation_color_balance_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec);
static void gimp_operation_color_balance_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec);
static gboolean gimp_operation_color_balance_process (GeglOperation *operation,
void *in_buf,
void *out_buf,
glong samples);
static gboolean gimp_operation_color_balance_process (GeglOperation *operation,
void *in_buf,
void *out_buf,
glong samples);
G_DEFINE_TYPE (GimpOperationColorBalance, gimp_operation_color_balance,
GEGL_TYPE_OPERATION_POINT_FILTER)
GIMP_TYPE_OPERATION_POINT_FILTER)
#define parent_class gimp_operation_color_balance_parent_class
static void
gimp_operation_color_balance_class_init (GimpOperationColorBalanceClass * klass)
gimp_operation_color_balance_class_init (GimpOperationColorBalanceClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GeglOperationClass *operation_class = GEGL_OPERATION_CLASS (klass);
GeglOperationPointFilterClass *point_class = GEGL_OPERATION_POINT_FILTER_CLASS (klass);
object_class->finalize = gimp_operation_color_balance_finalize;
object_class->set_property = gimp_operation_color_balance_set_property;
object_class->get_property = gimp_operation_color_balance_get_property;
object_class->set_property = gimp_operation_point_filter_set_property;
object_class->get_property = gimp_operation_point_filter_get_property;
point_class->process = gimp_operation_color_balance_process;
gegl_operation_class_set_name (operation_class, "gimp-color-balance");
g_object_class_install_property (object_class, PROP_CONFIG,
g_object_class_install_property (object_class,
GIMP_OPERATION_POINT_FILTER_PROP_CONFIG,
g_param_spec_object ("config",
"Config",
"The config object",
......@@ -90,62 +73,6 @@ gimp_operation_color_balance_init (GimpOperationColorBalance *self)
{
}
static void
gimp_operation_color_balance_finalize (GObject *object)
{
GimpOperationColorBalance *self = GIMP_OPERATION_COLOR_BALANCE (object);
if (self->config)
{
g_object_unref (self->config);
self->config = NULL;
}
G_OBJECT_CLASS (parent_class)->finalize (object);
}
static void
gimp_operation_color_balance_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec)
{
GimpOperationColorBalance *self = GIMP_OPERATION_COLOR_BALANCE (object);
switch (property_id)
{
case PROP_CONFIG:
g_value_set_object (value, self->config);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
static void
gimp_operation_color_balance_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec)
{
GimpOperationColorBalance *self = GIMP_OPERATION_COLOR_BALANCE (object);
switch (property_id)
{
case PROP_CONFIG:
if (self->config)
g_object_unref (self->config);
self->config = g_value_dup_object (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
static inline gfloat
gimp_operation_color_balance_map (gfloat value,
gdouble shadows,
......@@ -188,11 +115,11 @@ gimp_operation_color_balance_process (GeglOperation *operation,
void *out_buf,
glong samples)
{
GimpOperationColorBalance *self = GIMP_OPERATION_COLOR_BALANCE (operation);
GimpColorBalanceConfig *config = self->config;
gfloat *src = in_buf;
gfloat *dest = out_buf;
glong sample;
GimpOperationPointFilter *point = GIMP_OPERATION_POINT_FILTER (operation);
GimpColorBalanceConfig *config = GIMP_COLOR_BALANCE_CONFIG (point->config);
gfloat *src = in_buf;
gfloat *dest = out_buf;
glong sample;
if (! config)
return FALSE;
......
......@@ -23,8 +23,7 @@
#define __GIMP_OPERATION_COLOR_BALANCE_H__
#include <gegl-plugin.h>
#include <operation/gegl-operation-point-filter.h>
#include "gimpoperationpointfilter.h"
#define GIMP_TYPE_OPERATION_COLOR_BALANCE (gimp_operation_color_balance_get_type ())
......@@ -39,14 +38,12 @@ typedef struct _GimpOperationColorBalanceClass GimpOperationColorBalanceClass;
struct _GimpOperationColorBalance
{
GeglOperationPointFilter parent_instance;
GimpColorBalanceConfig *config;
GimpOperationPointFilter parent_instance;
};
struct _GimpOperationColorBalanceClass
{
GeglOperationPointFilterClass parent_class;
GimpOperationPointFilterClass parent_class;
};
......
......@@ -31,51 +31,34 @@
#include "gimpoperationcolorize.h"
enum
{
PROP_0,
PROP_CONFIG
};
static void gimp_operation_colorize_finalize (GObject *object);
static void gimp_operation_colorize_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec);
static void gimp_operation_colorize_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec);
static gboolean gimp_operation_colorize_process (GeglOperation *operation,
void *in_buf,
void *out_buf,
glong samples);
static gboolean gimp_operation_colorize_process (GeglOperation *operation,
void *in_buf,
void *out_buf,
glong samples);
G_DEFINE_TYPE (GimpOperationColorize, gimp_operation_colorize,
GEGL_TYPE_OPERATION_POINT_FILTER)
GIMP_TYPE_OPERATION_POINT_FILTER)
#define parent_class gimp_operation_colorize_parent_class
static void
gimp_operation_colorize_class_init (GimpOperationColorizeClass * klass)
gimp_operation_colorize_class_init (GimpOperationColorizeClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GeglOperationClass *operation_class = GEGL_OPERATION_CLASS (klass);
GeglOperationPointFilterClass *point_class = GEGL_OPERATION_POINT_FILTER_CLASS (klass);
object_class->finalize = gimp_operation_colorize_finalize;
object_class->set_property = gimp_operation_colorize_set_property;
object_class->get_property = gimp_operation_colorize_get_property;
object_class->set_property = gimp_operation_point_filter_set_property;
object_class->get_property = gimp_operation_point_filter_get_property;
point_class->process = gimp_operation_colorize_process;
gegl_operation_class_set_name (operation_class, "gimp-colorize");
g_object_class_install_property (object_class, PROP_CONFIG,
g_object_class_install_property (object_class,
GIMP_OPERATION_POINT_FILTER_PROP_CONFIG,
g_param_spec_object ("config",
"Config",
"The config object",
......@@ -89,74 +72,21 @@ gimp_operation_colorize_init (GimpOperationColorize *self)
{
}
static void
gimp_operation_colorize_finalize (GObject *object)
{
GimpOperationColorize *self = GIMP_OPERATION_COLORIZE (object);
if (self->config)
{
g_object_unref (self->config);
self->config = NULL;
}
G_OBJECT_CLASS (parent_class)->finalize (object);
}
static void
gimp_operation_colorize_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec)
{
GimpOperationColorize *self = GIMP_OPERATION_COLORIZE (object);
switch (property_id)
{
case PROP_CONFIG:
g_value_set_object (value, self->config);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
static void
gimp_operation_colorize_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec)
{
GimpOperationColorize *self = GIMP_OPERATION_COLORIZE (object);
switch (property_id)
{
case PROP_CONFIG:
if (self->config)
g_object_unref (self->config);
self->config = g_value_dup_object (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
static gboolean
gimp_operation_colorize_process (GeglOperation *operation,
void *in_buf,
void *out_buf,
glong samples)
{
GimpOperationColorize *self = GIMP_OPERATION_COLORIZE (operation);
GimpColorizeConfig *config = self->config;
gfloat *src = in_buf;
gfloat *dest = out_buf;
GimpHSL hsl;
glong sample;
GimpOperationPointFilter *point = GIMP_OPERATION_POINT_FILTER (operation);
GimpColorizeConfig *config = GIMP_COLORIZE_CONFIG (point->config);
gfloat *src = in_buf;
gfloat *dest = out_buf;
GimpHSL hsl;
glong sample;
if (! config)
return FALSE;
hsl.h = config->hue;
hsl.s = config->saturation;
......
......@@ -22,8 +22,8 @@
#ifndef __GIMP_OPERATION_COLORIZE_H__
#define __GIMP_OPERATION_COLORIZE_H__
#include <gegl-plugin.h>
#include <operation/gegl-operation-point-filter.h>
#include "gimpoperationpointfilter.h"
#define GIMP_TYPE_OPERATION_COLORIZE (gimp_operation_colorize_get_type ())
......@@ -38,14 +38,12 @@ typedef struct _GimpOperationColorizeClass GimpOperationColorizeClass;
struct _GimpOperationColorize
{
GeglOperationPointFilter parent_instance;
GimpColorizeConfig *config;
GimpOperationPointFilter parent_instance;
};
struct _GimpOperationColorizeClass
{
GeglOperationPointFilterClass parent_class;
GimpOperationPointFilterClass parent_class;
};
......
......@@ -32,51 +32,34 @@
#include "gimpoperationcurves.h"
enum
{
PROP_0,
PROP_CONFIG
};
static void gimp_operation_curves_finalize (GObject *object);
static void gimp_operation_curves_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec);
static void gimp_operation_curves_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec);
static gboolean gimp_operation_curves_process (GeglOperation *operation,
void *in_buf,
void *out_buf,
glong samples);
static gboolean gimp_operation_curves_process (GeglOperation *operation,
void *in_buf,
void *out_buf,
glong samples);
G_DEFINE_TYPE (GimpOperationCurves, gimp_operation_curves,
GEGL_TYPE_OPERATION_POINT_FILTER)
GIMP_TYPE_OPERATION_POINT_FILTER)
#define parent_class gimp_operation_curves_parent_class
static void
gimp_operation_curves_class_init (GimpOperationCurvesClass * klass)
gimp_operation_curves_class_init (GimpOperationCurvesClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GeglOperationClass *operation_class = GEGL_OPERATION_CLASS (klass);
GeglOperationPointFilterClass *point_class = GEGL_OPERATION_POINT_FILTER_CLASS (klass);
object_class->finalize = gimp_operation_curves_finalize;
object_class->set_property = gimp_operation_curves_set_property;
object_class->get_property = gimp_operation_curves_get_property;
object_class->set_property = gimp_operation_point_filter_set_property;
object_class->get_property = gimp_operation_point_filter_get_property;
point_class->process = gimp_operation_curves_process;
gegl_operation_class_set_name (operation_class, "gimp-curves");
g_object_class_install_property (object_class, PROP_CONFIG,
g_object_class_install_property (object_class,
GIMP_OPERATION_POINT_FILTER_PROP_CONFIG,
g_param_spec_object ("config",
"Config",
"The config object",
......@@ -90,62 +73,6 @@ gimp_operation_curves_init (GimpOperationCurves *self)
{
}
static void
gimp_operation_curves_finalize (GObject *object)
{
GimpOperationCurves *self = GIMP_OPERATION_CURVES (object);
if (self->config)
{
g_object_unref (self->config);
self->config = NULL;
}
G_OBJECT_CLASS (parent_class)->finalize (object);
}
static void
gimp_operation_curves_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec)
{
GimpOperationCurves *self = GIMP_OPERATION_CURVES (object);
switch (property_id)
{
case PROP_CONFIG:
g_value_set_object (value, self->config);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
static void
gimp_operation_curves_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec)
{
GimpOperationCurves *self = GIMP_OPERATION_CURVES (object);
switch (property_id)
{
case PROP_CONFIG:
if (self->config)
g_object_unref (self->config);
self->config = g_value_dup_object (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
static inline gdouble
gimp_operation_curves_map (gdouble value,
GimpCurve *curve)
......@@ -176,11 +103,11 @@ gimp_operation_curves_process (GeglOperation *operation,
void *out_buf,
glong samples)
{
GimpOperationCurves *self = GIMP_OPERATION_CURVES (operation);
GimpCurvesConfig *config = self->config;
gfloat *src = in_buf;
gfloat *dest = out_buf;
glong sample;
GimpOperationPointFilter *point = GIMP_OPERATION_POINT_FILTER (operation);
GimpCurvesConfig *config = GIMP_CURVES_CONFIG (point->config);
gfloat *src = in_buf;
gfloat *dest = out_buf;
glong sample;
if (! config)
return FALSE;
......
......@@ -23,8 +23,7 @@
#define __GIMP_OPERATION_CURVES_H__
#include <gegl-plugin.h>
#include <operation/gegl-operation-point-filter.h>
#include "gimpoperationpointfilter.h"
#define GIMP_TYPE_OPERATION_CURVES (gimp_operation_curves_get_type ())
......@@ -39,14 +38,12 @@ typedef struct _GimpOperationCurvesClass GimpOperationCurvesClass;
struct _GimpOperationCurves
{
GeglOperationPointFilter parent_instance;
GimpCurvesConfig *config;
GimpOperationPointFilter parent_instance;
};
struct _GimpOperationCurvesClass
{
GeglOperationPointFilterClass parent_class;
GimpOperationPointFilterClass parent_class;
};
......
......@@ -32,51 +32,34 @@
#include "gimpoperationhuesaturation.h"
enum
{
PROP_0,
PROP_CONFIG
};
static void gimp_operation_hue_saturation_finalize (GObject *object);
static void gimp_operation_hue_saturation_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec);
static void gimp_operation_hue_saturation_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec);
static gboolean gimp_operation_hue_saturation_process (GeglOperation *operation,
void *in_buf,
void *out_buf,
glong samples);
static gboolean gimp_operation_hue_saturation_process (GeglOperation *operation,
void *in_buf,
void *out_buf,
glong samples);
G_DEFINE_TYPE (GimpOperationHueSaturation, gimp_operation_hue_saturation,
GEGL_TYPE_OPERATION_POINT_FILTER)
GIMP_TYPE_OPERATION_POINT_FILTER)
#define parent_class gimp_operation_hue_saturation_parent_class
static void
gimp_operation_hue_saturation_class_init (GimpOperationHueSaturationClass * klass)
gimp_operation_hue_saturation_class_init (GimpOperationHueSaturationClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GeglOperationClass *operation_class = GEGL_OPERATION_CLASS (klass);
GeglOperationPointFilterClass *point_class = GEGL_OPERATION_POINT_FILTER_CLASS (klass);
object_class->finalize = gimp_operation_hue_saturation_finalize;
object_class->set_property = gimp_operation_hue_saturation_set_property;
object_class->get_property = gimp_operation_hue_saturation_get_property;
object_class->set_property = gimp_operation_point_filter_set_property;
object_class->get_property = gimp_operation_point_filter_get_property;
point_class->process = gimp_operation_hue_saturation_process;
gegl_operation_class_set_name (operation_class, "gimp-hue-saturation");
g_object_class_install_property (object_class, PROP_CONFIG,
g_object_class_install_property (object_class,
GIMP_OPERATION_POINT_FILTER_PROP_CONFIG,
g_param_spec_object ("config",
"Config",
"The config object",
......@@ -90,62 +73,6 @@ gimp_operation_hue_saturation_init (GimpOperationHueSaturation *self)
{
}
static void
gimp_operation_hue_saturation_finalize (GObject *object)
{
GimpOperationHueSaturation *self = GIMP_OPERATION_HUE_SATURATION (object);
if (self->config)
{
g_object_unref (self->config);
self->config = NULL;
}
G_OBJECT_CLASS (parent_class)->finalize (object);
}
static void
gimp_operation_hue_saturation_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec)
{
GimpOperationHueSaturation *self = GIMP_OPERATION_HUE_SATURATION (object);
switch (property_id)
{
case PROP_CONFIG:
g_value_set_object (value, self->config);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
static void
gimp_operation_hue_saturation_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec)
{
GimpOperationHueSaturation *self = GIMP_OPERATION_HUE_SATURATION (object);
switch (property_id)
{
case PROP_CONFIG:
if (self->config)
g_object_unref (self->config);
self->config = g_value_dup_object (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
static inline gdouble
map_hue (GimpHueSaturationConfig *config,
GimpHueRange range,
......@@ -200,12 +127,15 @@ gimp_operation_hue_saturation_process (GeglOperation *operation,
void *out_buf,
glong samples)
{
GimpOperationHueSaturation *self = GIMP_OPERATION_HUE_SATURATION (operation);
GimpHueSaturationConfig *config = self->config;
gfloat *src = in_buf;
gfloat *dest = out_buf;
gfloat overlap = config->overlap / 2.0;
glong sample;
GimpOperationPointFilter *point = GIMP_OPERATION_POINT_FILTER (operation);
GimpHueSaturationConfig *config = GIMP_HUE_SATURATION_CONFIG (point->config);
gfloat *src = in_buf;
gfloat *dest = out_buf;
gfloat overlap = config->overlap / 2.0;
glong sample;
if (! config)
return FALSE;
for (sample = 0; sample < samples; sample++)
{
......
......@@ -22,8 +22,8 @@
#ifndef __GIMP_OPERATION_HUE_SATURATION_H__
#define __GIMP_OPERATION_HUE_SATURATION_H__
#include <gegl-plugin.h>
#include <operation/gegl-operation-point-filter.h>
#include "gimpoperationpointfilter.h"
#define GIMP_TYPE_OPERATION_HUE_SATURATION (gimp_operation_hue_saturation_get_type ())
......@@ -38,14 +38,12 @@ typedef struct _GimpOperationHueSaturationClass GimpOperationHueSaturationClass;
struct _GimpOperationHueSaturation
{
GeglOperationPointFilter parent_instance;
GimpHueSaturationConfig *config;
GimpOperationPointFilter parent_instance;
};
struct _GimpOperationHueSaturationClass
{
GeglOperationPointFilterClass parent_class;
GimpOperationPointFilterClass parent_class;
};
......
......@@ -32,51 +32,34 @@
#include "gimpoperationlevels.h"
enum
{
PROP_0,
PROP_CONFIG