mirror of https://github.com/GNOME/gimp.git
app: add gimp_layer_mode_get_included_region()
Takes a layer mode and a composite mode, and returns the region included in the composition. Use this function in GimpOperationLayerMode, instead of testing for specific composite modes directly. Will also be used by the next commit. Indentation cleanup in gimp_layer_modes.h
This commit is contained in:
parent
c78cecd76d
commit
a67135658e
|
@ -1440,3 +1440,29 @@ gimp_layer_mode_get_format (GimpLayerMode mode,
|
|||
|
||||
g_return_val_if_reached (babl_format ("RGBA float"));
|
||||
}
|
||||
|
||||
GimpLayerCompositeRegion
|
||||
gimp_layer_mode_get_included_region (GimpLayerMode mode,
|
||||
GimpLayerCompositeMode composite_mode)
|
||||
{
|
||||
if (composite_mode == GIMP_LAYER_COMPOSITE_AUTO)
|
||||
composite_mode = gimp_layer_mode_get_composite_mode (mode);
|
||||
|
||||
switch (composite_mode)
|
||||
{
|
||||
case GIMP_LAYER_COMPOSITE_SRC_OVER:
|
||||
return GIMP_LAYER_COMPOSITE_REGION_UNION;
|
||||
|
||||
case GIMP_LAYER_COMPOSITE_SRC_ATOP:
|
||||
return GIMP_LAYER_COMPOSITE_REGION_DESTINATION;
|
||||
|
||||
case GIMP_LAYER_COMPOSITE_DST_ATOP:
|
||||
return GIMP_LAYER_COMPOSITE_REGION_SOURCE;
|
||||
|
||||
case GIMP_LAYER_COMPOSITE_SRC_IN:
|
||||
return GIMP_LAYER_COMPOSITE_REGION_INTERSECTION;
|
||||
|
||||
default:
|
||||
g_return_val_if_reached (GIMP_LAYER_COMPOSITE_REGION_INTERSECTION);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,45 +23,47 @@
|
|||
#define __GIMP_LAYER_MODES_H__
|
||||
|
||||
|
||||
void gimp_layer_modes_init (void);
|
||||
void gimp_layer_modes_init (void);
|
||||
|
||||
gboolean gimp_layer_mode_is_legacy (GimpLayerMode mode);
|
||||
gboolean gimp_layer_mode_is_legacy (GimpLayerMode mode);
|
||||
|
||||
gboolean gimp_layer_mode_is_blend_space_mutable (GimpLayerMode mode);
|
||||
gboolean gimp_layer_mode_is_composite_space_mutable (GimpLayerMode mode);
|
||||
gboolean gimp_layer_mode_is_composite_mode_mutable (GimpLayerMode mode);
|
||||
gboolean gimp_layer_mode_is_blend_space_mutable (GimpLayerMode mode);
|
||||
gboolean gimp_layer_mode_is_composite_space_mutable (GimpLayerMode mode);
|
||||
gboolean gimp_layer_mode_is_composite_mode_mutable (GimpLayerMode mode);
|
||||
|
||||
gboolean gimp_layer_mode_is_subtractive (GimpLayerMode mode);
|
||||
gboolean gimp_layer_mode_is_subtractive (GimpLayerMode mode);
|
||||
|
||||
GimpLayerColorSpace gimp_layer_mode_get_blend_space (GimpLayerMode mode);
|
||||
GimpLayerColorSpace gimp_layer_mode_get_composite_space (GimpLayerMode mode);
|
||||
GimpLayerCompositeMode gimp_layer_mode_get_composite_mode (GimpLayerMode mode);
|
||||
GimpLayerCompositeMode gimp_layer_mode_get_paint_composite_mode
|
||||
(GimpLayerMode mode);
|
||||
GimpLayerColorSpace gimp_layer_mode_get_blend_space (GimpLayerMode mode);
|
||||
GimpLayerColorSpace gimp_layer_mode_get_composite_space (GimpLayerMode mode);
|
||||
GimpLayerCompositeMode gimp_layer_mode_get_composite_mode (GimpLayerMode mode);
|
||||
GimpLayerCompositeMode gimp_layer_mode_get_paint_composite_mode (GimpLayerMode mode);
|
||||
|
||||
const gchar * gimp_layer_mode_get_operation (GimpLayerMode mode);
|
||||
const gchar * gimp_layer_mode_get_operation (GimpLayerMode mode);
|
||||
|
||||
GimpLayerModeFunc gimp_layer_mode_get_function (GimpLayerMode mode);
|
||||
GimpLayerModeFunc gimp_layer_mode_get_function (GimpLayerMode mode);
|
||||
|
||||
GimpLayerModeContext gimp_layer_mode_get_context (GimpLayerMode mode);
|
||||
GimpLayerModeContext gimp_layer_mode_get_context (GimpLayerMode mode);
|
||||
|
||||
GimpLayerMode * gimp_layer_mode_get_context_array (GimpLayerMode mode,
|
||||
GimpLayerModeContext context,
|
||||
gint *n_modes);
|
||||
GimpLayerMode * gimp_layer_mode_get_context_array (GimpLayerMode mode,
|
||||
GimpLayerModeContext context,
|
||||
gint *n_modes);
|
||||
|
||||
GimpLayerModeGroup gimp_layer_mode_get_group (GimpLayerMode mode);
|
||||
GimpLayerModeGroup gimp_layer_mode_get_group (GimpLayerMode mode);
|
||||
|
||||
const GimpLayerMode * gimp_layer_mode_get_group_array (GimpLayerModeGroup group,
|
||||
gint *n_modes);
|
||||
const GimpLayerMode * gimp_layer_mode_get_group_array (GimpLayerModeGroup group,
|
||||
gint *n_modes);
|
||||
|
||||
gboolean gimp_layer_mode_get_for_group (GimpLayerMode old_mode,
|
||||
GimpLayerModeGroup new_group,
|
||||
GimpLayerMode *new_mode);
|
||||
gboolean gimp_layer_mode_get_for_group (GimpLayerMode old_mode,
|
||||
GimpLayerModeGroup new_group,
|
||||
GimpLayerMode *new_mode);
|
||||
|
||||
const Babl * gimp_layer_mode_get_format (GimpLayerMode mode,
|
||||
GimpLayerColorSpace composite_space,
|
||||
GimpLayerColorSpace blend_space,
|
||||
const Babl *preferred_format);
|
||||
const Babl * gimp_layer_mode_get_format (GimpLayerMode mode,
|
||||
GimpLayerColorSpace composite_space,
|
||||
GimpLayerColorSpace blend_space,
|
||||
const Babl *preferred_format);
|
||||
|
||||
GimpLayerCompositeRegion gimp_layer_mode_get_included_region (GimpLayerMode mode,
|
||||
GimpLayerCompositeMode composite_mode);
|
||||
|
||||
|
||||
#endif /* __GIMP_LAYER_MODES_H__ */
|
||||
|
|
|
@ -375,11 +375,12 @@ gimp_operation_layer_mode_process (GeglOperation *operation,
|
|||
const GeglRectangle *result,
|
||||
gint level)
|
||||
{
|
||||
GimpOperationLayerMode *point = GIMP_OPERATION_LAYER_MODE (operation);
|
||||
GObject *input;
|
||||
GObject *aux;
|
||||
gboolean has_input;
|
||||
gboolean has_aux;
|
||||
GimpOperationLayerMode *point = GIMP_OPERATION_LAYER_MODE (operation);
|
||||
GObject *input;
|
||||
GObject *aux;
|
||||
gboolean has_input;
|
||||
gboolean has_aux;
|
||||
GimpLayerCompositeRegion included_region;
|
||||
|
||||
/* get the raw values. this does not increase the reference count. */
|
||||
input = gegl_operation_context_get_object (context, "input");
|
||||
|
@ -402,13 +403,14 @@ gimp_operation_layer_mode_process (GeglOperation *operation,
|
|||
gegl_buffer_get_extent (GEGL_BUFFER (aux)),
|
||||
result);
|
||||
|
||||
included_region = gimp_layer_mode_get_included_region (point->layer_mode,
|
||||
point->composite_mode);
|
||||
|
||||
/* if there's no 'input' ... */
|
||||
if (! has_input)
|
||||
{
|
||||
/* ... and there's 'aux', and the composite mode includes it ... */
|
||||
if (has_aux &&
|
||||
(point->composite_mode == GIMP_LAYER_COMPOSITE_SRC_OVER ||
|
||||
point->composite_mode == GIMP_LAYER_COMPOSITE_DST_ATOP))
|
||||
if (has_aux && (included_region & GIMP_LAYER_COMPOSITE_REGION_SOURCE))
|
||||
{
|
||||
GimpLayerCompositeRegion affected_region;
|
||||
|
||||
|
@ -445,8 +447,7 @@ gimp_operation_layer_mode_process (GeglOperation *operation,
|
|||
else if (! has_aux)
|
||||
{
|
||||
/* ... and the composite mode includes 'input' ... */
|
||||
if (point->composite_mode == GIMP_LAYER_COMPOSITE_SRC_OVER ||
|
||||
point->composite_mode == GIMP_LAYER_COMPOSITE_SRC_ATOP)
|
||||
if (included_region & GIMP_LAYER_COMPOSITE_REGION_DESTINATION)
|
||||
{
|
||||
GimpLayerCompositeRegion affected_region;
|
||||
|
||||
|
|
Loading…
Reference in New Issue