[gimp/pippin/linear-is-the-new-black: 7/10] app: start implementing consolidated non-legacy blend mode op
- From: Øyvind Kolås <ok src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp/pippin/linear-is-the-new-black: 7/10] app: start implementing consolidated non-legacy blend mode op
- Date: Mon, 23 Jan 2017 16:20:02 +0000 (UTC)
commit 62e8b69ae5f5ddaa3ad9a97a9ebb8919355eb876
Author: Øyvind Kolås <pippin gimp org>
Date: Sun Jan 22 19:48:49 2017 +0100
app: start implementing consolidated non-legacy blend mode op
app/core/gimp-layer-modes.c | 70 +---------------
.../layer-modes/gimpoperationlayermode.c | 89 ++++++++++++++++++-
2 files changed, 86 insertions(+), 73 deletions(-)
---
diff --git a/app/core/gimp-layer-modes.c b/app/core/gimp-layer-modes.c
index 10236e8..b401450 100644
--- a/app/core/gimp-layer-modes.c
+++ b/app/core/gimp-layer-modes.c
@@ -375,65 +375,31 @@ gimp_layer_mode_get_operation (GimpLayerMode mode)
case GIMP_LAYER_MODE_MULTIPLY_LEGACY:
return "gimp:multiply-legacy";
- case GIMP_LAYER_MODE_MULTIPLY:
- case GIMP_LAYER_MODE_MULTIPLY_LINEAR:
- return "gimp:multiply";
-
case GIMP_LAYER_MODE_SCREEN_LEGACY:
return "gimp:screen-legacy";
- case GIMP_LAYER_MODE_SCREEN:
- case GIMP_LAYER_MODE_SCREEN_LINEAR:
- return "gimp:screen";
-
case GIMP_LAYER_MODE_OVERLAY_LEGACY:
- return "gimp:softlight-legacy";
- case GIMP_LAYER_MODE_OVERLAY:
- case GIMP_LAYER_MODE_OVERLAY_LINEAR:
- return "gimp:overlay";
+ return "gimp:softlight-legacy";
case GIMP_LAYER_MODE_DIFFERENCE_LEGACY:
return "gimp:difference-legacy";
- case GIMP_LAYER_MODE_DIFFERENCE:
- case GIMP_LAYER_MODE_DIFFERENCE_LINEAR:
- return "gimp:difference";
-
case GIMP_LAYER_MODE_ADDITION_LEGACY:
return "gimp:addition-legacy";
- case GIMP_LAYER_MODE_ADDITION:
- case GIMP_LAYER_MODE_ADDITION_LINEAR:
- return "gimp:addition";
-
case GIMP_LAYER_MODE_SUBTRACT_LEGACY:
return "gimp:subtract-legacy";
- case GIMP_LAYER_MODE_SUBTRACT:
- case GIMP_LAYER_MODE_SUBTRACT_LINEAR:
- return "gimp:subtract";
-
case GIMP_LAYER_MODE_DARKEN_ONLY_LEGACY:
return "gimp:darken-only-legacy";
- case GIMP_LAYER_MODE_DARKEN_ONLY:
- case GIMP_LAYER_MODE_DARKEN_ONLY_LINEAR:
- return "gimp:darken-only";
-
case GIMP_LAYER_MODE_LIGHTEN_ONLY_LEGACY:
return "gimp:lighten-only-legacy";
- case GIMP_LAYER_MODE_LIGHTEN_ONLY:
- case GIMP_LAYER_MODE_LIGHTEN_ONLY_LINEAR:
- return "gimp:lighten-only";
-
case GIMP_LAYER_MODE_HSV_HUE_LEGACY:
return "gimp:hsv-hue-legacy";
- case GIMP_LAYER_MODE_HSV_HUE:
- return "gimp:hsv-hue";
-
case GIMP_LAYER_MODE_HSV_SATURATION_LEGACY:
return "gimp:hsv-saturation-legacy";
@@ -455,38 +421,18 @@ gimp_layer_mode_get_operation (GimpLayerMode mode)
case GIMP_LAYER_MODE_DIVIDE_LEGACY:
return "gimp:divide-legacy";
- case GIMP_LAYER_MODE_DIVIDE:
- case GIMP_LAYER_MODE_DIVIDE_LINEAR:
- return "gimp:divide";
-
case GIMP_LAYER_MODE_DODGE_LEGACY:
return "gimp:dodge-legacy";
- case GIMP_LAYER_MODE_DODGE:
- case GIMP_LAYER_MODE_DODGE_LINEAR:
- return "gimp:dodge";
-
case GIMP_LAYER_MODE_BURN_LEGACY:
return "gimp:burn-legacy";
- case GIMP_LAYER_MODE_BURN:
- case GIMP_LAYER_MODE_BURN_LINEAR:
- return "gimp:burn";
-
case GIMP_LAYER_MODE_HARDLIGHT_LEGACY:
return "gimp:hardlight-legacy";
- case GIMP_LAYER_MODE_HARDLIGHT:
- case GIMP_LAYER_MODE_HARDLIGHT_LINEAR:
- return "gimp:hardlight";
-
case GIMP_LAYER_MODE_SOFTLIGHT_LEGACY:
return "gimp:softlight-legacy";
- case GIMP_LAYER_MODE_SOFTLIGHT:
- case GIMP_LAYER_MODE_SOFTLIGHT_LINEAR:
- return "gimp:softlight";
-
case GIMP_LAYER_MODE_GRAIN_EXTRACT_LEGACY:
return "gimp:grain-extract-legacy";
@@ -504,18 +450,6 @@ gimp_layer_mode_get_operation (GimpLayerMode mode)
case GIMP_LAYER_MODE_COLOR_ERASE:
return "gimp:color-erase";
- case GIMP_LAYER_MODE_LCH_HUE:
- return "gimp:lch-hue";
-
- case GIMP_LAYER_MODE_LCH_CHROMA:
- return "gimp:lch-chroma";
-
- case GIMP_LAYER_MODE_LCH_COLOR:
- return "gimp:lch-color";
-
- case GIMP_LAYER_MODE_LCH_LIGHTNESS:
- return "gimp:lch-lightness";
-
case GIMP_LAYER_MODE_ERASE:
return "gimp:erase";
@@ -526,5 +460,5 @@ gimp_layer_mode_get_operation (GimpLayerMode mode)
return "gimp:anti-erase";
}
- return NULL;
+ return "gimp:layer-mode";
}
diff --git a/app/operations/layer-modes/gimpoperationlayermode.c
b/app/operations/layer-modes/gimpoperationlayermode.c
index e339d11..7d715dc 100644
--- a/app/operations/layer-modes/gimpoperationlayermode.c
+++ b/app/operations/layer-modes/gimpoperationlayermode.c
@@ -30,6 +30,7 @@
#include "../operations-types.h"
#include "gimpoperationlayermode.h"
+#include "gimpblendcomposite.h"
enum
@@ -59,7 +60,14 @@ static gboolean gimp_operation_layer_mode_process (GeglOperation *op
const gchar *output_prop,
const GeglRectangle *result,
gint level);
-
+static gboolean gimp_operation_layer_mode_process_pixels (GeglOperation *operation,
+ void *in,
+ void *layer,
+ void *mask,
+ void *out,
+ glong samples,
+ const GeglRectangle *roi,
+ gint level);
G_DEFINE_TYPE (GimpOperationLayerMode, gimp_operation_layer_mode,
GEGL_TYPE_OPERATION_POINT_COMPOSER3)
@@ -78,14 +86,23 @@ const Babl *_gimp_fish_laba_to_perceptual = NULL;
static void
gimp_operation_layer_mode_class_init (GimpOperationLayerModeClass *klass)
{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
- GeglOperationClass *operation_class = GEGL_OPERATION_CLASS (klass);
+ GObjectClass *object_class;
+ GeglOperationClass *operation_class;
+ GeglOperationPointComposer3Class *point_composer3_class;
+
+ object_class = G_OBJECT_CLASS (klass);
+ operation_class = GEGL_OPERATION_CLASS (klass);
+ point_composer3_class = GEGL_OPERATION_POINT_COMPOSER3_CLASS (klass);
+
+ gegl_operation_class_set_keys (operation_class,
+ "name", "gimp:layer-mode", NULL);
object_class->set_property = gimp_operation_layer_mode_set_property;
object_class->get_property = gimp_operation_layer_mode_get_property;
- operation_class->prepare = gimp_operation_layer_mode_prepare;
- operation_class->process = gimp_operation_layer_mode_process;
+ operation_class->prepare = gimp_operation_layer_mode_prepare;
+ operation_class->process = gimp_operation_layer_mode_process;
+ point_composer3_class->process = gimp_operation_layer_mode_process_pixels;
g_object_class_install_property (object_class, PROP_LAYER_MODE,
g_param_spec_enum ("layer-mode",
@@ -276,3 +293,65 @@ gimp_operation_layer_mode_process (GeglOperation *operation,
output_prop, result,
level);
}
+
+static inline void dummy_fun(void)
+{
+}
+
+static inline GimpBlendFunc gimp_layer_mode_get_blend_fun (GimpLayerMode mode)
+{
+ switch (mode)
+ {
+ case GIMP_LAYER_MODE_SCREEN: return blendfun_screen;
+ case GIMP_LAYER_MODE_ADDITION: return blendfun_addition;
+ case GIMP_LAYER_MODE_SUBTRACT: return blendfun_subtract;
+ case GIMP_LAYER_MODE_MULTIPLY: return blendfun_multiply;
+ case GIMP_LAYER_MODE_NORMAL: return blendfun_normal;
+ case GIMP_LAYER_MODE_BURN: return blendfun_burn;
+ case GIMP_LAYER_MODE_GRAIN_MERGE_LINEAR:
+ case GIMP_LAYER_MODE_GRAIN_MERGE: return blendfun_grain_merge;
+ case GIMP_LAYER_MODE_GRAIN_EXTRACT_LINEAR:
+ case GIMP_LAYER_MODE_GRAIN_EXTRACT: return blendfun_grain_merge;
+ case GIMP_LAYER_MODE_DODGE_LINEAR:
+ case GIMP_LAYER_MODE_DODGE: return blendfun_dodge;
+ case GIMP_LAYER_MODE_OVERLAY: return blendfun_overlay;
+ case GIMP_LAYER_MODE_HSV_COLOR: return blendfun_hsv_color;
+ case GIMP_LAYER_MODE_HSV_HUE: return blendfun_hsv_hue;
+ case GIMP_LAYER_MODE_HSV_SATURATION: return blendfun_hsv_saturation;
+ case GIMP_LAYER_MODE_HSV_VALUE: return blendfun_hsv_value;
+ case GIMP_LAYER_MODE_LCH_CHROMA: return blendfun_lch_chroma;
+ case GIMP_LAYER_MODE_LCH_COLOR: return blendfun_lch_color;
+ case GIMP_LAYER_MODE_LCH_HUE: return blendfun_lch_hue;
+ case GIMP_LAYER_MODE_LCH_LIGHTNESS: return blendfun_lch_lightness;
+ case GIMP_LAYER_MODE_HARDLIGHT: return blendfun_hardlight;
+ case GIMP_LAYER_MODE_SOFTLIGHT: return blendfun_softlight;
+ case GIMP_LAYER_MODE_DIVIDE: return blendfun_divide;
+ case GIMP_LAYER_MODE_DIVIDE_LINEAR: return blendfun_divide;
+ case GIMP_LAYER_MODE_DIFFERENCE: return blendfun_difference;
+ case GIMP_LAYER_MODE_DARKEN_ONLY: return blendfun_darken_only;
+ case GIMP_LAYER_MODE_LIGHTEN_ONLY: return blendfun_lighten_only;
+ //case GIMP_LAYER_MODE_VIVID_LIGHT: return blendfun_vivid_light;
+ //case GIMP_LAYER_MODE_PIN_LIGHT: return blendfun_pin_light;
+ //case GIMP_LAYER_MODE_LINEAR_LIGHT: return blendfun_linear_light;
+ //case GIMP_LAYER_MODE_EXCLUSION: return blendfun_exclusion;
+ //case GIMP_LAYER_MODE_LINEAR_BURN: return blendfun_linear_burn;
+ default:
+ return (void*)dummy_fun;
+ }
+}
+
+static gboolean
+gimp_operation_layer_mode_process_pixels (GeglOperation *operation,
+ void *in,
+ void *layer,
+ void *mask,
+ void *out,
+ glong samples,
+ const GeglRectangle *roi,
+ gint level)
+{
+ GimpOperationLayerMode *layer_mode = (GimpOperationLayerMode*)(operation);
+ gimp_composite_blend (operation, in, layer, mask, out, samples,
+ gimp_layer_mode_get_blend_fun (layer_mode->layer_mode));
+ return TRUE;
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]