gimp r27400 - in trunk: . app/core app/gegl
- From: martinn svn gnome org
- To: svn-commits-list gnome org
- Subject: gimp r27400 - in trunk: . app/core app/gegl
- Date: Sat, 25 Oct 2008 13:29:55 +0000 (UTC)
Author: martinn
Date: Sat Oct 25 13:29:55 2008
New Revision: 27400
URL: http://svn.gnome.org/viewvc/gimp?rev=27400&view=rev
Log:
Instead of having one GEGL operation per layer mode, make
GimpOperationLayerMode instantiable and add a GimpLayerModeEffects
property to it that we check in ::process() to blend pixels
together.
* app/gegl/gimpoperationlayermode.[ch]: Do the change described
above. Currently only Normal and Addition are implemented. Normal
so that we don't need a special case for the gegl:normal op. Also,
the Dissolve layer mode is not a point op and needs to be
implemented elsewhere.
* app/gegl/gimpoperation*mode.c: Removed.
* app/gegl/gimp-gegl-utils.[ch]: Removed
gimp_layer_mode_to_gegl_operation().
* app/core/gimplayer.c
* app/gegl/Makefile.am
* app/gegl/gimp-gegl.c: Adapt.
Removed:
trunk/app/gegl/gimpoperationadditionmode.c
trunk/app/gegl/gimpoperationadditionmode.h
trunk/app/gegl/gimpoperationantierasemode.c
trunk/app/gegl/gimpoperationantierasemode.h
trunk/app/gegl/gimpoperationbehindmode.c
trunk/app/gegl/gimpoperationbehindmode.h
trunk/app/gegl/gimpoperationburnmode.c
trunk/app/gegl/gimpoperationburnmode.h
trunk/app/gegl/gimpoperationcolorerasemode.c
trunk/app/gegl/gimpoperationcolorerasemode.h
trunk/app/gegl/gimpoperationcolormode.c
trunk/app/gegl/gimpoperationcolormode.h
trunk/app/gegl/gimpoperationdarkenonlymode.c
trunk/app/gegl/gimpoperationdarkenonlymode.h
trunk/app/gegl/gimpoperationdifferencemode.c
trunk/app/gegl/gimpoperationdifferencemode.h
trunk/app/gegl/gimpoperationdissolvemode.c
trunk/app/gegl/gimpoperationdissolvemode.h
trunk/app/gegl/gimpoperationdividemode.c
trunk/app/gegl/gimpoperationdividemode.h
trunk/app/gegl/gimpoperationdodgemode.c
trunk/app/gegl/gimpoperationdodgemode.h
trunk/app/gegl/gimpoperationerasemode.c
trunk/app/gegl/gimpoperationerasemode.h
trunk/app/gegl/gimpoperationgrainextractmode.c
trunk/app/gegl/gimpoperationgrainextractmode.h
trunk/app/gegl/gimpoperationgrainmergemode.c
trunk/app/gegl/gimpoperationgrainmergemode.h
trunk/app/gegl/gimpoperationhardlightmode.c
trunk/app/gegl/gimpoperationhardlightmode.h
trunk/app/gegl/gimpoperationhuemode.c
trunk/app/gegl/gimpoperationhuemode.h
trunk/app/gegl/gimpoperationlightenonlymode.c
trunk/app/gegl/gimpoperationlightenonlymode.h
trunk/app/gegl/gimpoperationmultiplymode.c
trunk/app/gegl/gimpoperationmultiplymode.h
trunk/app/gegl/gimpoperationoverlaymode.c
trunk/app/gegl/gimpoperationoverlaymode.h
trunk/app/gegl/gimpoperationreplacemode.c
trunk/app/gegl/gimpoperationreplacemode.h
trunk/app/gegl/gimpoperationsaturationmode.c
trunk/app/gegl/gimpoperationsaturationmode.h
trunk/app/gegl/gimpoperationscreenmode.c
trunk/app/gegl/gimpoperationscreenmode.h
trunk/app/gegl/gimpoperationsoftlightmode.c
trunk/app/gegl/gimpoperationsoftlightmode.h
trunk/app/gegl/gimpoperationsubtractmode.c
trunk/app/gegl/gimpoperationsubtractmode.h
trunk/app/gegl/gimpoperationvaluemode.c
trunk/app/gegl/gimpoperationvaluemode.h
Modified:
trunk/ChangeLog
trunk/app/core/gimplayer.c
trunk/app/gegl/Makefile.am
trunk/app/gegl/gimp-gegl-utils.c
trunk/app/gegl/gimp-gegl-utils.h
trunk/app/gegl/gimp-gegl.c
trunk/app/gegl/gimpoperationlayermode.c
trunk/app/gegl/gimpoperationlayermode.h
Modified: trunk/app/core/gimplayer.c
==============================================================================
--- trunk/app/core/gimplayer.c (original)
+++ trunk/app/core/gimplayer.c Sat Oct 25 13:29:55 2008
@@ -561,7 +561,8 @@
mode_node = gimp_drawable_get_mode_node (drawable);
gegl_node_set (mode_node,
- "operation", gimp_layer_mode_to_gegl_operation (layer->mode),
+ "operation", "gimp:layer-mode",
+ "blend-mode", layer->mode,
NULL);
gegl_node_connect_to (layer->opacity_node, "output",
@@ -2035,7 +2036,8 @@
mode_node = gimp_drawable_get_mode_node (GIMP_DRAWABLE (layer));
gegl_node_set (mode_node,
- "operation", gimp_layer_mode_to_gegl_operation (layer->mode),
+ "operation", "gimp:layer-mode",
+ "blend-mode", layer->mode,
NULL);
}
Modified: trunk/app/gegl/Makefile.am
==============================================================================
--- trunk/app/gegl/Makefile.am (original)
+++ trunk/app/gegl/Makefile.am Sat Oct 25 13:29:55 2008
@@ -65,54 +65,4 @@
gimpoperationthreshold.h \
\
gimpoperationlayermode.c \
- gimpoperationlayermode.h \
- gimpoperationdissolvemode.c \
- gimpoperationdissolvemode.h \
- gimpoperationbehindmode.c \
- gimpoperationbehindmode.h \
- gimpoperationmultiplymode.c \
- gimpoperationmultiplymode.h \
- gimpoperationscreenmode.c \
- gimpoperationscreenmode.h \
- gimpoperationoverlaymode.c \
- gimpoperationoverlaymode.h \
- gimpoperationdifferencemode.c \
- gimpoperationdifferencemode.h \
- gimpoperationadditionmode.c \
- gimpoperationadditionmode.h \
- gimpoperationsubtractmode.c \
- gimpoperationsubtractmode.h \
- gimpoperationdarkenonlymode.c \
- gimpoperationdarkenonlymode.h \
- gimpoperationlightenonlymode.c \
- gimpoperationlightenonlymode.h \
- gimpoperationhuemode.c \
- gimpoperationhuemode.h \
- gimpoperationsaturationmode.c \
- gimpoperationsaturationmode.h \
- gimpoperationcolormode.c \
- gimpoperationcolormode.h \
- gimpoperationvaluemode.c \
- gimpoperationvaluemode.h \
- gimpoperationdividemode.c \
- gimpoperationdividemode.h \
- gimpoperationdodgemode.c \
- gimpoperationdodgemode.h \
- gimpoperationburnmode.c \
- gimpoperationburnmode.h \
- gimpoperationhardlightmode.c \
- gimpoperationhardlightmode.h \
- gimpoperationsoftlightmode.c \
- gimpoperationsoftlightmode.h \
- gimpoperationgrainextractmode.c \
- gimpoperationgrainextractmode.h \
- gimpoperationgrainmergemode.c \
- gimpoperationgrainmergemode.h \
- gimpoperationcolorerasemode.c \
- gimpoperationcolorerasemode.h \
- gimpoperationerasemode.c \
- gimpoperationerasemode.h \
- gimpoperationreplacemode.c \
- gimpoperationreplacemode.h \
- gimpoperationantierasemode.c \
- gimpoperationantierasemode.h
+ gimpoperationlayermode.h
Modified: trunk/app/gegl/gimp-gegl-utils.c
==============================================================================
--- trunk/app/gegl/gimp-gegl-utils.c (original)
+++ trunk/app/gegl/gimp-gegl-utils.c Sat Oct 25 13:29:55 2008
@@ -75,41 +75,3 @@
return NULL;
}
-
-const gchar *
-gimp_layer_mode_to_gegl_operation (GimpLayerModeEffects mode)
-{
- switch (mode)
- {
- case GIMP_NORMAL_MODE: return "gegl:normal";
- case GIMP_DISSOLVE_MODE: return "gimp-dissolve-mode";
- case GIMP_BEHIND_MODE: return "gimp-behind-mode";
- case GIMP_MULTIPLY_MODE: return "gimp-multiply-mode";
- case GIMP_SCREEN_MODE: return "gimp-screen-mode";
- case GIMP_OVERLAY_MODE: return "gimp-overlay-mode";
- case GIMP_DIFFERENCE_MODE: return "gimp-difference-mode";
- case GIMP_ADDITION_MODE: return "gimp-addition-mode";
- case GIMP_SUBTRACT_MODE: return "gimp-subtract-mode";
- case GIMP_DARKEN_ONLY_MODE: return "gimp-darken-mode";
- case GIMP_LIGHTEN_ONLY_MODE: return "gimp-lighten-mode";
- case GIMP_HUE_MODE: return "gimp-hue-mode";
- case GIMP_SATURATION_MODE: return "gimp-saturation-mode";
- case GIMP_COLOR_MODE: return "gimp-color-mode";
- case GIMP_VALUE_MODE: return "gimp-value-mode";
- case GIMP_DIVIDE_MODE: return "gimp-divide-mode";
- case GIMP_DODGE_MODE: return "gimp-dodge-mode";
- case GIMP_BURN_MODE: return "gimp-burn-mode";
- case GIMP_HARDLIGHT_MODE: return "gimp-hardlight-mode";
- case GIMP_SOFTLIGHT_MODE: return "gimp-softlight-mode";
- case GIMP_GRAIN_EXTRACT_MODE: return "gimp-grain-extract-mode";
- case GIMP_GRAIN_MERGE_MODE: return "gimp-grain-merge-mode";
- case GIMP_COLOR_ERASE_MODE: return "gimp-color-erase-mode";
- case GIMP_ERASE_MODE: return "gimp-erase-mode";
- case GIMP_REPLACE_MODE: return "gimp-replace-mode";
- case GIMP_ANTI_ERASE_MODE: return "gimp-anti-erase-mode";
- default:
- break;
- }
-
- return "gegl:normal";
-}
Modified: trunk/app/gegl/gimp-gegl-utils.h
==============================================================================
--- trunk/app/gegl/gimp-gegl-utils.h (original)
+++ trunk/app/gegl/gimp-gegl-utils.h Sat Oct 25 13:29:55 2008
@@ -26,7 +26,5 @@
const Babl * gimp_bpp_to_babl_format (guint bpp,
gboolean linear) G_GNUC_CONST;
-const gchar * gimp_layer_mode_to_gegl_operation (GimpLayerModeEffects mode) G_GNUC_CONST;
-
#endif /* __GIMP_GEGL_UTILS_H__ */
Modified: trunk/app/gegl/gimp-gegl.c
==============================================================================
--- trunk/app/gegl/gimp-gegl.c (original)
+++ trunk/app/gegl/gimp-gegl.c Sat Oct 25 13:29:55 2008
@@ -39,31 +39,7 @@
#include "gimpoperationtilesink.h"
#include "gimpoperationtilesource.h"
-#include "gimpoperationdissolvemode.h"
-#include "gimpoperationbehindmode.h"
-#include "gimpoperationmultiplymode.h"
-#include "gimpoperationscreenmode.h"
-#include "gimpoperationoverlaymode.h"
-#include "gimpoperationdifferencemode.h"
-#include "gimpoperationadditionmode.h"
-#include "gimpoperationsubtractmode.h"
-#include "gimpoperationdarkenonlymode.h"
-#include "gimpoperationlightenonlymode.h"
-#include "gimpoperationhuemode.h"
-#include "gimpoperationsaturationmode.h"
-#include "gimpoperationcolormode.h"
-#include "gimpoperationvaluemode.h"
-#include "gimpoperationdividemode.h"
-#include "gimpoperationdodgemode.h"
-#include "gimpoperationburnmode.h"
-#include "gimpoperationhardlightmode.h"
-#include "gimpoperationsoftlightmode.h"
-#include "gimpoperationgrainextractmode.h"
-#include "gimpoperationgrainmergemode.h"
-#include "gimpoperationcolorerasemode.h"
-#include "gimpoperationerasemode.h"
-#include "gimpoperationreplacemode.h"
-#include "gimpoperationantierasemode.h"
+#include "gimpoperationlayermode.h"
void
@@ -86,29 +62,5 @@
g_type_class_ref (GIMP_TYPE_OPERATION_POSTERIZE);
g_type_class_ref (GIMP_TYPE_OPERATION_THRESHOLD);
- g_type_class_ref (GIMP_TYPE_OPERATION_DISSOLVE_MODE);
- g_type_class_ref (GIMP_TYPE_OPERATION_BEHIND_MODE);
- g_type_class_ref (GIMP_TYPE_OPERATION_MULTIPLY_MODE);
- g_type_class_ref (GIMP_TYPE_OPERATION_SCREEN_MODE);
- g_type_class_ref (GIMP_TYPE_OPERATION_OVERLAY_MODE);
- g_type_class_ref (GIMP_TYPE_OPERATION_DIFFERENCE_MODE);
- g_type_class_ref (GIMP_TYPE_OPERATION_ADDITION_MODE);
- g_type_class_ref (GIMP_TYPE_OPERATION_SUBTRACT_MODE);
- g_type_class_ref (GIMP_TYPE_OPERATION_DARKEN_ONLY_MODE);
- g_type_class_ref (GIMP_TYPE_OPERATION_LIGHTEN_ONLY_MODE);
- g_type_class_ref (GIMP_TYPE_OPERATION_HUE_MODE);
- g_type_class_ref (GIMP_TYPE_OPERATION_SATURATION_MODE);
- g_type_class_ref (GIMP_TYPE_OPERATION_COLOR_MODE);
- g_type_class_ref (GIMP_TYPE_OPERATION_VALUE_MODE);
- g_type_class_ref (GIMP_TYPE_OPERATION_DIVIDE_MODE);
- g_type_class_ref (GIMP_TYPE_OPERATION_DODGE_MODE);
- g_type_class_ref (GIMP_TYPE_OPERATION_BURN_MODE);
- g_type_class_ref (GIMP_TYPE_OPERATION_HARDLIGHT_MODE);
- g_type_class_ref (GIMP_TYPE_OPERATION_SOFTLIGHT_MODE);
- g_type_class_ref (GIMP_TYPE_OPERATION_GRAIN_EXTRACT_MODE);
- g_type_class_ref (GIMP_TYPE_OPERATION_GRAIN_MERGE_MODE);
- g_type_class_ref (GIMP_TYPE_OPERATION_COLOR_ERASE_MODE);
- g_type_class_ref (GIMP_TYPE_OPERATION_ERASE_MODE);
- g_type_class_ref (GIMP_TYPE_OPERATION_REPLACE_MODE);
- g_type_class_ref (GIMP_TYPE_OPERATION_ANTI_ERASE_MODE);
+ g_type_class_ref (GIMP_TYPE_OPERATION_LAYER_MODE);
}
Modified: trunk/app/gegl/gimpoperationlayermode.c
==============================================================================
--- trunk/app/gegl/gimpoperationlayermode.c (original)
+++ trunk/app/gegl/gimpoperationlayermode.c Sat Oct 25 13:29:55 2008
@@ -29,30 +29,73 @@
#include "gimpoperationlayermode.h"
-static void gimp_operation_layer_mode_prepare (GeglOperation *operation);
-static gboolean gimp_operation_layer_mode_process (GeglOperation *operation,
- void *in_buf,
- void *aux_buf,
- void *out_buf,
- glong samples,
- const GeglRectangle *roi);
+enum
+{
+ PROP_0,
+ PROP_BLEND_MODE
+};
+
+
+typedef struct _GimpOperationLayerModeClass GimpOperationLayerModeClass;
+
+struct _GimpOperationLayerModeClass
+{
+ GeglOperationPointComposerClass parent_class;
+};
+
+struct _GimpOperationLayerMode
+{
+ GeglOperationPointComposer parent_instance;
+
+ GimpLayerModeEffects blend_mode;
+};
+
+static void gimp_operation_layer_mode_set_property (GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec);
+static void gimp_operation_layer_mode_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec);
+
+static void gimp_operation_layer_mode_prepare (GeglOperation *operation);
+static gboolean gimp_operation_layer_mode_process (GeglOperation *operation,
+ void *in_buf,
+ void *aux_buf,
+ void *out_buf,
+ glong samples,
+ const GeglRectangle *roi);
-G_DEFINE_ABSTRACT_TYPE (GimpOperationLayerMode, gimp_operation_layer_mode,
- GEGL_TYPE_OPERATION_POINT_COMPOSER)
+
+G_DEFINE_TYPE (GimpOperationLayerMode, gimp_operation_layer_mode,
+ GEGL_TYPE_OPERATION_POINT_COMPOSER)
static void
gimp_operation_layer_mode_class_init (GimpOperationLayerModeClass *klass)
{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
GeglOperationClass *operation_class = GEGL_OPERATION_CLASS (klass);
GeglOperationPointComposerClass *point_class = GEGL_OPERATION_POINT_COMPOSER_CLASS (klass);
- operation_class->categories = "compositors";
+ object_class->set_property = gimp_operation_layer_mode_set_property;
+ object_class->get_property = gimp_operation_layer_mode_get_property;
+
+ operation_class->name = "gimp:layer-mode";
+ operation_class->description = "GIMP layer mode operation";
+ operation_class->categories = "compositors";
operation_class->prepare = gimp_operation_layer_mode_prepare;
point_class->process = gimp_operation_layer_mode_process;
+
+ g_object_class_install_property (object_class, PROP_BLEND_MODE,
+ g_param_spec_enum ("blend-mode", NULL, NULL,
+ GIMP_TYPE_LAYER_MODE_EFFECTS,
+ GIMP_NORMAL_MODE,
+ GIMP_PARAM_READWRITE));
}
static void
@@ -61,6 +104,46 @@
}
static void
+gimp_operation_layer_mode_set_property (GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ GimpOperationLayerMode *self = GIMP_OPERATION_LAYER_MODE (object);
+
+ switch (property_id)
+ {
+ case PROP_BLEND_MODE:
+ self->blend_mode = g_value_get_enum (value);
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ break;
+ }
+}
+
+static void
+gimp_operation_layer_mode_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ GimpOperationLayerMode *self = GIMP_OPERATION_LAYER_MODE (object);
+
+ switch (property_id)
+ {
+ case PROP_BLEND_MODE:
+ g_value_set_enum (value, self->blend_mode);
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ break;
+ }
+}
+
+static void
gimp_operation_layer_mode_prepare (GeglOperation *operation)
{
Babl *format = babl_format ("RaGaBaA float");
@@ -78,10 +161,82 @@
glong samples,
const GeglRectangle *roi)
{
- return GIMP_OPERATION_LAYER_MODE_GET_CLASS (operation)->process (operation,
- in_buf,
- aux_buf,
- out_buf,
- samples,
- roi);
+ GimpOperationLayerMode *self = GIMP_OPERATION_LAYER_MODE (operation);
+
+ gfloat *in = in_buf;
+ gfloat *layer = aux_buf;
+ gfloat *out = out_buf;
+
+ while (samples--)
+ {
+ out[ALPHA] = in[ALPHA] + layer[ALPHA] - in[ALPHA] * layer[ALPHA];
+
+ switch (self->blend_mode)
+ {
+ case GIMP_NORMAL_MODE:
+ out[RED] = layer[RED] + in[RED] * (1 - layer[ALPHA]);
+ out[GREEN] = layer[GREEN] + in[GREEN] * (1 - layer[ALPHA]);
+ out[BLUE] = layer[BLUE] + in[BLUE] * (1 - layer[ALPHA]);
+ break;
+
+ case GIMP_DISSOLVE_MODE:
+ g_warning ("Not a point filter and cannot be implemented here.");
+ break;
+
+ case GIMP_BEHIND_MODE:
+ case GIMP_MULTIPLY_MODE:
+ case GIMP_SCREEN_MODE:
+ case GIMP_OVERLAY_MODE:
+ case GIMP_DIFFERENCE_MODE:
+ /* TODO */
+ break;
+
+ case GIMP_ADDITION_MODE:
+ /* To be more mathematically correct we would have to either
+ * adjust the formula for the resulting opacity or adapt the
+ * other channels to the change in opacity. Compare to the
+ * 'plus' compositing operation in SVG 1.2.
+ *
+ * Since this doesn't matter for completely opaque layers, and
+ * since consistency in how the alpha channel of layers is
+ * interpreted is more important than mathematically correct
+ * results, we don't bother.
+ */
+ out[RED] = in[RED] + layer[RED];
+ out[GREEN] = in[GREEN] + layer[GREEN];
+ out[BLUE] = in[BLUE] + layer[BLUE];
+ break;
+
+ case GIMP_SUBTRACT_MODE:
+ case GIMP_DARKEN_ONLY_MODE:
+ case GIMP_LIGHTEN_ONLY_MODE:
+ case GIMP_HUE_MODE:
+ case GIMP_SATURATION_MODE:
+ case GIMP_COLOR_MODE:
+ case GIMP_VALUE_MODE:
+ case GIMP_DIVIDE_MODE:
+ case GIMP_DODGE_MODE:
+ case GIMP_BURN_MODE:
+ case GIMP_HARDLIGHT_MODE:
+ case GIMP_SOFTLIGHT_MODE:
+ case GIMP_GRAIN_EXTRACT_MODE:
+ case GIMP_GRAIN_MERGE_MODE:
+ case GIMP_COLOR_ERASE_MODE:
+ case GIMP_ERASE_MODE:
+ case GIMP_REPLACE_MODE:
+ case GIMP_ANTI_ERASE_MODE:
+ /* TODO */
+ break;
+
+ default:
+ g_error ("Unknown layer mode");
+ break;
+ }
+
+ in += 4;
+ layer += 4;
+ out += 4;
+ }
+
+ return TRUE;
}
Modified: trunk/app/gegl/gimpoperationlayermode.h
==============================================================================
--- trunk/app/gegl/gimpoperationlayermode.h (original)
+++ trunk/app/gegl/gimpoperationlayermode.h Sat Oct 25 13:29:55 2008
@@ -35,26 +35,6 @@
#define GIMP_OPERATION_LAYER_MODE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_OPERATION_LAYER_MODE, GimpOperationLayerModeClass))
-typedef struct _GimpOperationLayerModeClass GimpOperationLayerModeClass;
-
-struct _GimpOperationLayerMode
-{
- GeglOperationPointComposer parent_instance;
-};
-
-struct _GimpOperationLayerModeClass
-{
- GeglOperationPointComposerClass parent_class;
-
- gboolean (* process) (GeglOperation *operation,
- void *in_buf,
- void *aux_buf,
- void *out_buf,
- glong samples,
- const GeglRectangle *roi);
-};
-
-
GType gimp_operation_layer_mode_get_type (void) G_GNUC_CONST;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]