Commit 8f4700b8 authored by Ell's avatar Ell
Browse files

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.
parent 5c873bd9
......@@ -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 },
......
......@@ -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" >*/
......
......@@ -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,
......@@ -359,6 +362,13 @@ static const GimpLayerMode layer_mode_groups[][4] =
-1
},
{
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,
......
......@@ -1838,6 +1838,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,
......@@ -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,
......
......@@ -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);
......
......@@ -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,
......
......@@ -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,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment