app: add gimp_layer_mode_is_alpha_only()

... which determines if a layer mode's blend function only affects
the alpha, maintaining the backdrop's color.  This is currently
true only for ERASE, SPLIT, and ANTI_ERASE modes.
This commit is contained in:
Ell 2018-05-07 16:35:42 -04:00
parent 2e68088c35
commit 2c58598172
3 changed files with 21 additions and 5 deletions

View File

@ -774,7 +774,8 @@ static const GimpLayerModeInfo layer_mode_infos[] =
.op_name = "gimp:erase",
.flags = GIMP_LAYER_MODE_FLAG_BLEND_SPACE_IMMUTABLE |
GIMP_LAYER_MODE_FLAG_SUBTRACTIVE,
GIMP_LAYER_MODE_FLAG_SUBTRACTIVE |
GIMP_LAYER_MODE_FLAG_ALPHA_ONLY,
.context = GIMP_LAYER_MODE_CONTEXT_ALL,
.paint_composite_mode = GIMP_LAYER_COMPOSITE_CLIP_TO_BACKDROP,
.composite_mode = GIMP_LAYER_COMPOSITE_CLIP_TO_BACKDROP,
@ -796,7 +797,8 @@ static const GimpLayerModeInfo layer_mode_infos[] =
.op_name = "gimp:split",
.flags = GIMP_LAYER_MODE_FLAG_BLEND_SPACE_IMMUTABLE |
GIMP_LAYER_MODE_FLAG_COMPOSITE_SPACE_IMMUTABLE |
GIMP_LAYER_MODE_FLAG_SUBTRACTIVE,
GIMP_LAYER_MODE_FLAG_SUBTRACTIVE |
GIMP_LAYER_MODE_FLAG_ALPHA_ONLY,
.context = GIMP_LAYER_MODE_CONTEXT_ALL,
.paint_composite_mode = GIMP_LAYER_COMPOSITE_CLIP_TO_BACKDROP,
.composite_mode = GIMP_LAYER_COMPOSITE_CLIP_TO_BACKDROP
@ -825,8 +827,9 @@ static const GimpLayerModeInfo layer_mode_infos[] =
{ GIMP_LAYER_MODE_ANTI_ERASE,
.op_name = "gimp:anti-erase",
.flags = GIMP_LAYER_MODE_FLAG_BLEND_SPACE_IMMUTABLE |
GIMP_LAYER_MODE_FLAG_COMPOSITE_SPACE_IMMUTABLE,
.flags = GIMP_LAYER_MODE_FLAG_BLEND_SPACE_IMMUTABLE |
GIMP_LAYER_MODE_FLAG_COMPOSITE_SPACE_IMMUTABLE |
GIMP_LAYER_MODE_FLAG_ALPHA_ONLY,
.context = GIMP_LAYER_MODE_CONTEXT_FADE,
.paint_composite_mode = GIMP_LAYER_COMPOSITE_UNION,
.composite_mode = GIMP_LAYER_COMPOSITE_UNION
@ -1175,6 +1178,17 @@ gimp_layer_mode_is_subtractive (GimpLayerMode mode)
return (info->flags & GIMP_LAYER_MODE_FLAG_SUBTRACTIVE) != 0;
}
gboolean
gimp_layer_mode_is_alpha_only (GimpLayerMode mode)
{
const GimpLayerModeInfo *info = gimp_layer_mode_info (mode);
if (! info)
return FALSE;
return (info->flags & GIMP_LAYER_MODE_FLAG_ALPHA_ONLY) != 0;
}
GimpLayerColorSpace
gimp_layer_mode_get_blend_space (GimpLayerMode mode)
{

View File

@ -32,6 +32,7 @@ gboolean gimp_layer_mode_is_composite_space_mutable (GimpLayer
gboolean gimp_layer_mode_is_composite_mode_mutable (GimpLayerMode mode);
gboolean gimp_layer_mode_is_subtractive (GimpLayerMode mode);
gboolean gimp_layer_mode_is_alpha_only (GimpLayerMode mode);
GimpLayerColorSpace gimp_layer_mode_get_blend_space (GimpLayerMode mode);
GimpLayerColorSpace gimp_layer_mode_get_composite_space (GimpLayerMode mode);

View File

@ -181,7 +181,8 @@ typedef enum /*< pdb-skip, skip >*/
GIMP_LAYER_MODE_FLAG_BLEND_SPACE_IMMUTABLE = 1 << 1,
GIMP_LAYER_MODE_FLAG_COMPOSITE_SPACE_IMMUTABLE = 1 << 2,
GIMP_LAYER_MODE_FLAG_COMPOSITE_MODE_IMMUTABLE = 1 << 3,
GIMP_LAYER_MODE_FLAG_SUBTRACTIVE = 1 << 4
GIMP_LAYER_MODE_FLAG_SUBTRACTIVE = 1 << 4,
GIMP_LAYER_MODE_FLAG_ALPHA_ONLY = 1 << 5
} GimpLayerModeFlags;