[gegl] gegl, operations: add GeglOrientation to gegl-enums.[ch]
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gegl] gegl, operations: add GeglOrientation to gegl-enums.[ch]
- Date: Sun, 25 May 2014 23:09:12 +0000 (UTC)
commit 43068450713eec8c3e8ec989fefa2721fd212165
Author: Michael Natterer <mitch gimp org>
Date: Mon May 26 01:06:45 2014 +0200
gegl, operations: add GeglOrientation to gegl-enums.[ch]
and remove various orientation and direction enums from the ops.
gegl/gegl-enums.c | 25 +++++++++++++++++++++++++
gegl/gegl-enums.h | 14 ++++++++++++--
operations/common/deinterlace.c | 5 -----
operations/common/mosaic.c | 22 ++++++++--------------
operations/common/shift.c | 17 ++++++-----------
operations/workshop/gblur-1d.c | 27 +++++++++++----------------
6 files changed, 62 insertions(+), 48 deletions(-)
---
diff --git a/gegl/gegl-enums.c b/gegl/gegl-enums.c
index 67bf98f..8e92c5f 100644
--- a/gegl/gegl-enums.c
+++ b/gegl/gegl-enums.c
@@ -51,6 +51,31 @@ gegl_abyss_policy_get_type (void)
}
GType
+gegl_orientation_get_type (void)
+{
+ static GType etype = 0;
+
+ if (etype == 0)
+ {
+ static GEnumValue values[] = {
+ { GEGL_ORIENTATION_HORIZONTAL, N_("Horizontal"), "hotizontal" },
+ { GEGL_ORIENTATION_VERTICAL, N_("Vertical"), "vertical" },
+ { 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 ("GeglOrientation", values);
+ }
+
+ return etype;
+}
+
+GType
gegl_sampler_type_get_type (void)
{
static GType etype = 0;
diff --git a/gegl/gegl-enums.h b/gegl/gegl-enums.h
index c0470fc..4024bb3 100644
--- a/gegl/gegl-enums.h
+++ b/gegl/gegl-enums.h
@@ -46,7 +46,17 @@ typedef enum {
GType gegl_abyss_policy_get_type (void) G_GNUC_CONST;
-#define GEGL_TYPE_ABYSS_POLICY (gegl_abyss_policy_get_type())
+#define GEGL_TYPE_ABYSS_POLICY (gegl_abyss_policy_get_type ())
+
+
+typedef enum {
+ GEGL_ORIENTATION_HORIZONTAL,
+ GEGL_ORIENTATION_VERTICAL
+} GeglOrientation;
+
+GType gegl_orientation_get_type (void) G_GNUC_CONST;
+
+#define GEGL_TYPE_ORIENTATION (gegl_orientation_get_type ())
typedef enum {
@@ -59,7 +69,7 @@ typedef enum {
GType gegl_sampler_type_get_type (void) G_GNUC_CONST;
-#define GEGL_TYPE_SAMPLER_TYPE (gegl_sampler_type_get_type())
+#define GEGL_TYPE_SAMPLER_TYPE (gegl_sampler_type_get_type ())
G_END_DECLS
diff --git a/operations/common/deinterlace.c b/operations/common/deinterlace.c
index c10440f..cf50d66 100644
--- a/operations/common/deinterlace.c
+++ b/operations/common/deinterlace.c
@@ -32,11 +32,6 @@ enum_start (gegl_deinterlace_keep)
enum_value (GEGL_DEINTERLACE_KEEP_ODD, "odd", N_("Keep odd fields"))
enum_end (GeglDeinterlaceKeep)
-enum_start (gegl_orientation)
- enum_value (GEGL_ORIENTATION_HORIZONTAL, "horizontal", N_("Horizontal"))
- enum_value (GEGL_ORIENTATION_VERTICAL, "vertical", N_("Vertical"))
-enum_end (GeglOrientation)
-
property_enum (keep, _("Keep"),
GeglDeinterlaceKeep, gegl_deinterlace_keep,
GEGL_DEINTERLACE_KEEP_EVEN)
diff --git a/operations/common/mosaic.c b/operations/common/mosaic.c
index 8439a45..bab03dd 100644
--- a/operations/common/mosaic.c
+++ b/operations/common/mosaic.c
@@ -110,12 +110,6 @@ typedef enum
TRIANGLES = 3
} TileType;
-typedef enum
-{
- HORIZONTAL = 0,
- VERTICAL = 1
-} Direction;
-
#define SMOOTH FALSE
#define ROUGH TRUE
@@ -184,7 +178,7 @@ static void find_max_gradient (gfloat *src_rgn,
/* gaussian & 1st derivative */
static void gaussian_deriv (gfloat *src_rgn,
gfloat *dest_rgn,
- Direction direction,
+ GeglOrientation direction,
gdouble std_dev,
const GeglRectangle *result);
static void make_curve (gfloat *curve,
@@ -467,11 +461,11 @@ find_gradients (gfloat *input_buf,
dest_rgn = g_new (gfloat, result->width * result->height * NB_CPN);
- gaussian_deriv (input_buf, dest_rgn, HORIZONTAL, std_dev, result);
+ gaussian_deriv (input_buf, dest_rgn, GEGL_ORIENTATION_HORIZONTAL, std_dev, result);
find_max_gradient (dest_rgn, mdatas->h_grad, result->width, result->height);
- gaussian_deriv (input_buf, dest_rgn, VERTICAL, std_dev, result);
+ gaussian_deriv (input_buf, dest_rgn, GEGL_ORIENTATION_VERTICAL, std_dev, result);
find_max_gradient (dest_rgn, mdatas->v_grad, result->width, result->height);
@@ -537,7 +531,7 @@ find_max_gradient (gfloat *src_rgn,
static void
gaussian_deriv (gfloat *src_rgn,
gfloat *dest_rgn,
- Direction direction,
+ GeglOrientation direction,
gdouble std_dev,
const GeglRectangle *result)
{
@@ -569,7 +563,7 @@ gaussian_deriv (gfloat *src_rgn,
sum = sum_array + length;
buf = g_new (gfloat, MAX (width, height) * NB_CPN);
- if (direction == VERTICAL)
+ if (direction == GEGL_ORIENTATION_VERTICAL)
{
make_curve_d (curve, sum, std_dev, length);
total = sum[0] * -2;
@@ -625,7 +619,7 @@ gaussian_deriv (gfloat *src_rgn,
}
b = buf;
- if (direction == VERTICAL)
+ if (direction == GEGL_ORIENTATION_VERTICAL)
for (row = 0; row < height; row++)
{
for (chan = 0; chan < NB_CPN; chan++)
@@ -648,7 +642,7 @@ gaussian_deriv (gfloat *src_rgn,
}
}
- if (direction == HORIZONTAL)
+ if (direction == GEGL_ORIENTATION_HORIZONTAL)
{
make_curve_d (curve, sum, std_dev, length);
total = sum[0] * -2;
@@ -705,7 +699,7 @@ gaussian_deriv (gfloat *src_rgn,
}
b = buf;
- if (direction == HORIZONTAL)
+ if (direction == GEGL_ORIENTATION_HORIZONTAL)
for (col = 0; col < width; col++)
{
for (chan = 0; chan < NB_CPN; chan++)
diff --git a/operations/common/shift.c b/operations/common/shift.c
index 8cff8fa..cbe5e80 100644
--- a/operations/common/shift.c
+++ b/operations/common/shift.c
@@ -23,19 +23,14 @@
#ifdef GEGL_PROPERTIES
-enum_start (gegl_shift_direction)
- enum_value (GEGL_SHIFT_DIRECTION_HORIZONTAL, "horizontal", N_("Horizontal"))
- enum_value (GEGL_SHIFT_DIRECTION_VERTICAL, "vertical", N_("Vertical"))
-enum_end (GeglShiftDirection)
-
property_int (shift, _("Shift"), 5)
description(_("Maximum amount to shift"))
value_range (0, 200)
ui_meta ("unit", "pixel-distance")
property_enum (direction, _("Shift direction"),
- GeglShiftDirection, gegl_shift_direction,
- GEGL_SHIFT_DIRECTION_HORIZONTAL)
+ GeglOrientation, gegl_orientation,
+ GEGL_ORIENTATION_HORIZONTAL)
property_seed (seed, _("Random seed"), rand)
@@ -53,14 +48,14 @@ prepare (GeglOperation *operation)
GeglOperationAreaFilter *op_area = GEGL_OPERATION_AREA_FILTER (operation);
const Babl *format;
- if (o->direction == GEGL_SHIFT_DIRECTION_HORIZONTAL)
+ if (o->direction == GEGL_ORIENTATION_HORIZONTAL)
{
op_area->left = o->shift;
op_area->right = o->shift;
op_area->top = 0;
op_area->bottom = 0;
}
- else if (o->direction == GEGL_SHIFT_DIRECTION_VERTICAL)
+ else if (o->direction == GEGL_ORIENTATION_VERTICAL)
{
op_area->top = o->shift;
op_area->bottom = o->shift;
@@ -87,7 +82,7 @@ process (GeglOperation *operation,
GeglRectangle dst_rect;
- if (o->direction == GEGL_SHIFT_DIRECTION_HORIZONTAL)
+ if (o->direction == GEGL_ORIENTATION_HORIZONTAL)
{
size = result->height;
dst_rect.width = result->width;
@@ -111,7 +106,7 @@ process (GeglOperation *operation,
gint shift = gegl_random_int_range (o->rand, i + pos, 0, 0, 0,
-o->shift, o->shift + 1);
- if (o->direction == GEGL_SHIFT_DIRECTION_HORIZONTAL)
+ if (o->direction == GEGL_ORIENTATION_HORIZONTAL)
{
dst_rect.y = i + result->y;
src_rect = dst_rect;
diff --git a/operations/workshop/gblur-1d.c b/operations/workshop/gblur-1d.c
index 9e62f99..e1297da 100644
--- a/operations/workshop/gblur-1d.c
+++ b/operations/workshop/gblur-1d.c
@@ -34,11 +34,6 @@ enum_start (gegl_gblur_1d_policy)
enum_value (GEGL_GBLUR_1D_ABYSS_WHITE, "white", N_("White"))
enum_end (GeglGblur1dPolicy)
-enum_start (gegl_gblur_1d_orientation)
- enum_value (GEGL_GBLUR_1D_HORIZONTAL, "horizontal", N_("Horizontal"))
- enum_value (GEGL_GBLUR_1D_VERTICAL, "vertical", N_("Vertical"))
- enum_end (GeglGblur1dOrientation)
-
enum_start (gegl_gblur_1d_filter)
enum_value (GEGL_GBLUR_1D_AUTO, "auto", N_("Auto"))
enum_value (GEGL_GBLUR_1D_FIR, "fir", N_("FIR"))
@@ -52,8 +47,8 @@ property_double (std_dev, _("Size"), 1.5)
ui_gamma (3.0)
property_enum (orientation, _("Orientation"),
- GeglGblur1dOrientation, gegl_gblur_1d_orientation,
- GEGL_GBLUR_1D_HORIZONTAL)
+ GeglOrientation, gegl_orientation,
+ GEGL_ORIENTATION_HORIZONTAL)
description (_("The orientation of the blur - hor/ver"))
property_enum (filter, _("Filter"),
@@ -393,7 +388,7 @@ cl_gaussian_blur (cl_mem in_tex,
const GeglRectangle *roi,
cl_mem cl_cmatrix,
gint clen,
- GeglGblur1dOrientation orientation)
+ GeglOrientation orientation)
{
cl_int cl_err = 0;
size_t global_ws[2];
@@ -408,7 +403,7 @@ cl_gaussian_blur (cl_mem in_tex,
if (!cl_data)
return TRUE;
- if (orientation == GEGL_GBLUR_1D_VERTICAL)
+ if (orientation == GEGL_ORIENTATION_VERTICAL)
kernel_num = 0;
else
kernel_num = 1;
@@ -446,7 +441,7 @@ fir_cl_process (GeglBuffer *input,
const Babl *format,
gfloat *cmatrix,
gint clen,
- GeglGblur1dOrientation orientation,
+ GeglOrientation orientation,
GeglAbyssPolicy abyss)
{
gboolean err = FALSE;
@@ -456,7 +451,7 @@ fir_cl_process (GeglBuffer *input,
gint read;
gint left, right, top, bottom;
- if (orientation == GEGL_GBLUR_1D_HORIZONTAL)
+ if (orientation == GEGL_ORIENTATION_HORIZONTAL)
{
right = left = clen / 2;
top = bottom = 0;
@@ -637,7 +632,7 @@ gegl_gblur_1d_enlarge_extent (GeglProperties *o,
GeglRectangle bounding_box = *input_extent;
- if (o->orientation == GEGL_GBLUR_1D_HORIZONTAL)
+ if (o->orientation == GEGL_ORIENTATION_HORIZONTAL)
{
bounding_box.x -= clen / 2;
bounding_box.width += clen - 1;
@@ -671,7 +666,7 @@ gegl_gblur_1d_get_required_for_output (GeglOperation *operation,
{
required_for_output = *output_roi;
- if (o->orientation == GEGL_GBLUR_1D_HORIZONTAL)
+ if (o->orientation == GEGL_ORIENTATION_HORIZONTAL)
{
required_for_output.x = in_rect->x;
required_for_output.width = in_rect->width;
@@ -745,7 +740,7 @@ gegl_gblur_1d_get_cached_region (GeglOperation *operation,
cached_region = *output_roi;
- if (o->orientation == GEGL_GBLUR_1D_HORIZONTAL)
+ if (o->orientation == GEGL_ORIENTATION_HORIZONTAL)
{
cached_region.x = in_rect.x;
cached_region.width = in_rect.width;
@@ -805,7 +800,7 @@ gegl_gblur_1d_process (GeglOperation *operation,
iir_young_find_constants (o->std_dev, b, m);
- if (o->orientation == GEGL_GBLUR_1D_HORIZONTAL)
+ if (o->orientation == GEGL_ORIENTATION_HORIZONTAL)
iir_young_hor_blur (input, result, output, b, m, abyss_policy, format);
else
iir_young_ver_blur (input, result, output, b, m, abyss_policy, format);
@@ -824,7 +819,7 @@ gegl_gblur_1d_process (GeglOperation *operation,
cmatrix, clen, o->orientation, abyss_policy))
return TRUE;
- if (o->orientation == GEGL_GBLUR_1D_HORIZONTAL)
+ if (o->orientation == GEGL_ORIENTATION_HORIZONTAL)
fir_hor_blur (input, result, output, cmatrix, clen, abyss_policy, format);
else
fir_ver_blur (input, result, output, cmatrix, clen, abyss_policy, format);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]