[gimp] app: add "hard mix" blend mode
- From: N/A <ell src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app: add "hard mix" blend mode
- Date: Sun, 5 Feb 2017 02:31:51 +0000 (UTC)
commit 8f4700b83908169a2da6adc900389f79e7f0e30d
Author: Ell <ell_se yahoo com>
Date: Sat Feb 4 16:04:59 2017 -0500
app: add "hard mix" blend mode
Similar to the Photoshop mode of the same name. Assigns
either 0 or 1 to each of the channels, depending on whether the
sum of source and destination channel values is less than, or
greater than (or equals to), one, respectively.
This is equivalent to inverting the source, and using it to perform
per-pixel, per-channel threshold against the destination, which is
useful for various effects.
app/core/core-enums.c | 4 ++
app/core/core-enums.h | 2 +
app/core/gimp-layer-modes.c | 10 +++++
.../layer-modes/gimpoperationlayermode.c | 42 ++++++++++++++++++++
app/widgets/gimplayermodecombobox.c | 6 +-
libgimp/gimpenums.h | 2 +
tools/pdbgen/enums.pl | 20 ++++++----
7 files changed, 75 insertions(+), 11 deletions(-)
---
diff --git a/app/core/core-enums.c b/app/core/core-enums.c
index bf4925d..c76109f 100644
--- a/app/core/core-enums.c
+++ b/app/core/core-enums.c
@@ -356,6 +356,8 @@ gimp_layer_mode_get_type (void)
{ GIMP_LAYER_MODE_PIN_LIGHT_LINEAR, "GIMP_LAYER_MODE_PIN_LIGHT_LINEAR", "pin-light-linear" },
{ GIMP_LAYER_MODE_LINEAR_LIGHT, "GIMP_LAYER_MODE_LINEAR_LIGHT", "linear-light" },
{ GIMP_LAYER_MODE_LINEAR_LIGHT_LINEAR, "GIMP_LAYER_MODE_LINEAR_LIGHT_LINEAR", "linear-light-linear" },
+ { GIMP_LAYER_MODE_HARD_MIX, "GIMP_LAYER_MODE_HARD_MIX", "hard-mix" },
+ { GIMP_LAYER_MODE_HARD_MIX_LINEAR, "GIMP_LAYER_MODE_HARD_MIX_LINEAR", "hard-mix-linear" },
{ GIMP_LAYER_MODE_EXCLUSION, "GIMP_LAYER_MODE_EXCLUSION", "exclusion" },
{ GIMP_LAYER_MODE_EXCLUSION_LINEAR, "GIMP_LAYER_MODE_EXCLUSION_LINEAR", "exclusion-linear" },
{ GIMP_LAYER_MODE_LINEAR_BURN, "GIMP_LAYER_MODE_LINEAR_BURN", "linear-burn" },
@@ -439,6 +441,8 @@ gimp_layer_mode_get_type (void)
{ GIMP_LAYER_MODE_PIN_LIGHT_LINEAR, NC_("layer-mode", "Pin light (linear)"), NULL },
{ GIMP_LAYER_MODE_LINEAR_LIGHT, NC_("layer-mode", "Linear light"), NULL },
{ GIMP_LAYER_MODE_LINEAR_LIGHT_LINEAR, NC_("layer-mode", "Linear light (linear)"), NULL },
+ { GIMP_LAYER_MODE_HARD_MIX, NC_("layer-mode", "Hard mix"), NULL },
+ { GIMP_LAYER_MODE_HARD_MIX_LINEAR, NC_("layer-mode", "Hard mix (linear)"), NULL },
{ GIMP_LAYER_MODE_EXCLUSION, NC_("layer-mode", "Exclusion"), NULL },
{ GIMP_LAYER_MODE_EXCLUSION_LINEAR, NC_("layer-mode", "Exclusion (linear)"), NULL },
{ GIMP_LAYER_MODE_LINEAR_BURN, NC_("layer-mode", "Linear burn"), NULL },
diff --git a/app/core/core-enums.h b/app/core/core-enums.h
index b027bd5..75b59a1 100644
--- a/app/core/core-enums.h
+++ b/app/core/core-enums.h
@@ -226,6 +226,8 @@ typedef enum
GIMP_LAYER_MODE_PIN_LIGHT_LINEAR, /*< desc="Pin light (linear)" >*/
GIMP_LAYER_MODE_LINEAR_LIGHT, /*< desc="Linear light" >*/
GIMP_LAYER_MODE_LINEAR_LIGHT_LINEAR, /*< desc="Linear light (linear)" >*/
+ GIMP_LAYER_MODE_HARD_MIX, /*< desc="Hard mix" >*/
+ GIMP_LAYER_MODE_HARD_MIX_LINEAR, /*< desc="Hard mix (linear)" >*/
GIMP_LAYER_MODE_EXCLUSION, /*< desc="Exclusion" >*/
GIMP_LAYER_MODE_EXCLUSION_LINEAR, /*< desc="Exclusion (linear)" >*/
GIMP_LAYER_MODE_LINEAR_BURN, /*< desc="Linear burn" >*/
diff --git a/app/core/gimp-layer-modes.c b/app/core/gimp-layer-modes.c
index 02e0215..9e0d0a7 100644
--- a/app/core/gimp-layer-modes.c
+++ b/app/core/gimp-layer-modes.c
@@ -54,6 +54,7 @@ static const GimpLayerMode layer_mode_group_default[] =
GIMP_LAYER_MODE_VIVID_LIGHT,
GIMP_LAYER_MODE_PIN_LIGHT,
GIMP_LAYER_MODE_LINEAR_LIGHT,
+ GIMP_LAYER_MODE_HARD_MIX,
GIMP_LAYER_MODE_DIFFERENCE,
GIMP_LAYER_MODE_SUBTRACT,
@@ -92,6 +93,7 @@ static const GimpLayerMode layer_mode_group_linear[] =
GIMP_LAYER_MODE_VIVID_LIGHT_LINEAR,
GIMP_LAYER_MODE_PIN_LIGHT_LINEAR,
GIMP_LAYER_MODE_LINEAR_LIGHT_LINEAR,
+ GIMP_LAYER_MODE_HARD_MIX_LINEAR,
GIMP_LAYER_MODE_DIFFERENCE_LINEAR,
GIMP_LAYER_MODE_SUBTRACT_LINEAR,
@@ -125,6 +127,7 @@ static const GimpLayerMode layer_mode_group_perceptual[] =
GIMP_LAYER_MODE_VIVID_LIGHT,
GIMP_LAYER_MODE_PIN_LIGHT,
GIMP_LAYER_MODE_LINEAR_LIGHT,
+ GIMP_LAYER_MODE_HARD_MIX,
GIMP_LAYER_MODE_DIFFERENCE,
GIMP_LAYER_MODE_SUBTRACT,
@@ -360,6 +363,13 @@ static const GimpLayerMode layer_mode_groups[][4] =
},
{
+ GIMP_LAYER_MODE_HARD_MIX,
+ GIMP_LAYER_MODE_HARD_MIX_LINEAR,
+ GIMP_LAYER_MODE_HARD_MIX,
+ -1
+ },
+
+ {
GIMP_LAYER_MODE_EXCLUSION,
GIMP_LAYER_MODE_EXCLUSION_LINEAR,
GIMP_LAYER_MODE_EXCLUSION,
diff --git a/app/operations/layer-modes/gimpoperationlayermode.c
b/app/operations/layer-modes/gimpoperationlayermode.c
index bfc62b2..a47adab 100644
--- a/app/operations/layer-modes/gimpoperationlayermode.c
+++ b/app/operations/layer-modes/gimpoperationlayermode.c
@@ -1839,6 +1839,31 @@ blendfun_pin_light (const float *dest,
}
static inline void
+blendfun_hard_mix (const float *dest,
+ const float *src,
+ float *out,
+ int samples)
+{
+ while (samples--)
+ {
+ if (dest[ALPHA] != 0.0f && src[ALPHA] != 0.0f)
+ {
+ gint c;
+
+ for (c = 0; c < 3; c++)
+ {
+ out[c] = dest[c] + src[c] < 1.0f ? 0.0f : 1.0f;
+ }
+ }
+ out[ALPHA] = src[ALPHA];
+
+ out += 4;
+ src += 4;
+ dest += 4;
+ }
+}
+
+static inline void
blendfun_exclusion (const float *dest,
const float *src,
float *out,
@@ -1863,6 +1888,7 @@ blendfun_exclusion (const float *dest,
}
}
+
static inline void dummy_fun(void)
{
}
@@ -1919,6 +1945,8 @@ static inline GimpBlendFunc gimp_layer_mode_get_blend_fun (GimpLayerMode mode)
case GIMP_LAYER_MODE_PIN_LIGHT: return blendfun_pin_light;
case GIMP_LAYER_MODE_LINEAR_LIGHT_LINEAR:
case GIMP_LAYER_MODE_LINEAR_LIGHT: return blendfun_linear_light;
+ case GIMP_LAYER_MODE_HARD_MIX_LINEAR:
+ case GIMP_LAYER_MODE_HARD_MIX: return blendfun_hard_mix;
case GIMP_LAYER_MODE_EXCLUSION_LINEAR:
case GIMP_LAYER_MODE_EXCLUSION: return blendfun_exclusion;
case GIMP_LAYER_MODE_LINEAR_BURN_LINEAR:
@@ -2385,6 +2413,20 @@ static GimpLayerModeInfo gimp_layer_mode_infos[]=
GIMP_LAYER_COLOR_SPACE_RGB_LINEAR,
GIMP_LAYER_COLOR_SPACE_RGB_LINEAR
},
+ { GIMP_LAYER_MODE_HARD_MIX,
+ "gimp:layer-mode",
+ GIMP_LAYER_MODE_FLAG_WANTS_LINEAR_DATA,
+ GIMP_LAYER_COMPOSITE_SRC_ATOP,
+ GIMP_LAYER_COLOR_SPACE_RGB_LINEAR,
+ GIMP_LAYER_COLOR_SPACE_RGB_PERCEPTUAL
+ },
+ { GIMP_LAYER_MODE_HARD_MIX_LINEAR,
+ "gimp:layer-mode",
+ GIMP_LAYER_MODE_FLAG_WANTS_LINEAR_DATA,
+ GIMP_LAYER_COMPOSITE_SRC_ATOP,
+ GIMP_LAYER_COLOR_SPACE_RGB_LINEAR,
+ GIMP_LAYER_COLOR_SPACE_RGB_LINEAR
+ },
{ GIMP_LAYER_MODE_EXCLUSION,
"gimp:layer-mode",
GIMP_LAYER_MODE_FLAG_WANTS_LINEAR_DATA,
diff --git a/app/widgets/gimplayermodecombobox.c b/app/widgets/gimplayermodecombobox.c
index 4d727aa..733773d 100644
--- a/app/widgets/gimplayermodecombobox.c
+++ b/app/widgets/gimplayermodecombobox.c
@@ -391,7 +391,7 @@ gimp_layer_mode_combo_box_fix_default_store (GimpLayerModeComboBox *combo,
GIMP_LAYER_MODE_BURN, -1);
gimp_layer_mode_combo_box_insert_separator (store,
- GIMP_LAYER_MODE_LINEAR_LIGHT, -1);
+ GIMP_LAYER_MODE_HARD_MIX, -1);
gimp_layer_mode_combo_box_insert_separator (store,
GIMP_LAYER_MODE_DIVIDE, -1);
@@ -437,7 +437,7 @@ gimp_layer_mode_combo_box_fix_linear_store (GimpLayerModeComboBox *combo,
GIMP_LAYER_MODE_BURN_LINEAR, -1);
gimp_layer_mode_combo_box_insert_separator (store,
- GIMP_LAYER_MODE_LINEAR_LIGHT_LINEAR, -1);
+ GIMP_LAYER_MODE_HARD_MIX_LINEAR, -1);
gimp_layer_mode_combo_box_insert_separator (store,
GIMP_LAYER_MODE_DIVIDE_LINEAR, -1);
@@ -477,7 +477,7 @@ gimp_layer_mode_combo_box_fix_perceptual_store (GimpLayerModeComboBox *combo,
GIMP_LAYER_MODE_BURN, -1);
gimp_layer_mode_combo_box_insert_separator (store,
- GIMP_LAYER_MODE_LINEAR_LIGHT, -1);
+ GIMP_LAYER_MODE_HARD_MIX, -1);
gimp_layer_mode_combo_box_insert_separator (store,
GIMP_LAYER_MODE_DIVIDE, -1);
diff --git a/libgimp/gimpenums.h b/libgimp/gimpenums.h
index b21de2b..d01a2bf 100644
--- a/libgimp/gimpenums.h
+++ b/libgimp/gimpenums.h
@@ -150,6 +150,8 @@ typedef enum
GIMP_LAYER_MODE_PIN_LIGHT_LINEAR,
GIMP_LAYER_MODE_LINEAR_LIGHT,
GIMP_LAYER_MODE_LINEAR_LIGHT_LINEAR,
+ GIMP_LAYER_MODE_HARD_MIX,
+ GIMP_LAYER_MODE_HARD_MIX_LINEAR,
GIMP_LAYER_MODE_EXCLUSION,
GIMP_LAYER_MODE_EXCLUSION_LINEAR,
GIMP_LAYER_MODE_LINEAR_BURN,
diff --git a/tools/pdbgen/enums.pl b/tools/pdbgen/enums.pl
index 46a3d20..e60ef62 100644
--- a/tools/pdbgen/enums.pl
+++ b/tools/pdbgen/enums.pl
@@ -771,6 +771,8 @@ package Gimp::CodeGen::enums;
GIMP_LAYER_MODE_PIN_LIGHT_LINEAR
GIMP_LAYER_MODE_LINEAR_LIGHT
GIMP_LAYER_MODE_LINEAR_LIGHT_LINEAR
+ GIMP_LAYER_MODE_HARD_MIX
+ GIMP_LAYER_MODE_HARD_MIX_LINEAR
GIMP_LAYER_MODE_EXCLUSION
GIMP_LAYER_MODE_EXCLUSION_LINEAR
GIMP_LAYER_MODE_LINEAR_BURN
@@ -846,14 +848,16 @@ package Gimp::CodeGen::enums;
GIMP_LAYER_MODE_PIN_LIGHT_LINEAR => '64',
GIMP_LAYER_MODE_LINEAR_LIGHT => '65',
GIMP_LAYER_MODE_LINEAR_LIGHT_LINEAR => '66',
- GIMP_LAYER_MODE_EXCLUSION => '67',
- GIMP_LAYER_MODE_EXCLUSION_LINEAR => '68',
- GIMP_LAYER_MODE_LINEAR_BURN => '69',
- GIMP_LAYER_MODE_LINEAR_BURN_LINEAR => '70',
- GIMP_LAYER_MODE_LUMA_DARKEN_ONLY => '71',
- GIMP_LAYER_MODE_LUMINANCE_DARKEN_ONLY => '72',
- GIMP_LAYER_MODE_LUMA_LIGHTEN_ONLY => '73',
- GIMP_LAYER_MODE_LUMINANCE_LIGHTEN_ONLY => '74' }
+ GIMP_LAYER_MODE_HARD_MIX => '67',
+ GIMP_LAYER_MODE_HARD_MIX_LINEAR => '68',
+ GIMP_LAYER_MODE_EXCLUSION => '69',
+ GIMP_LAYER_MODE_EXCLUSION_LINEAR => '70',
+ GIMP_LAYER_MODE_LINEAR_BURN => '71',
+ GIMP_LAYER_MODE_LINEAR_BURN_LINEAR => '72',
+ GIMP_LAYER_MODE_LUMA_DARKEN_ONLY => '73',
+ GIMP_LAYER_MODE_LUMINANCE_DARKEN_ONLY => '74',
+ GIMP_LAYER_MODE_LUMA_LIGHTEN_ONLY => '75',
+ GIMP_LAYER_MODE_LUMINANCE_LIGHTEN_ONLY => '76' }
},
GimpBrushApplicationMode =>
{ contig => 1,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]