Commit 1dd2c52e authored by Michael Natterer's avatar Michael Natterer 😴

app, pdb, libgimp: add PDB API for layer blend space and compositing space

parent ac36497c
......@@ -25,12 +25,12 @@
GType gimp_layer_color_space_get_type (void) G_GNUC_CONST;
typedef enum /*< pdb-skip >*/
typedef enum
{
GIMP_LAYER_COLOR_SPACE_AUTO, /*< desc="Auto" >*/
GIMP_LAYER_COLOR_SPACE_RGB_LINEAR, /*< desc="RGB (linear)" >*/
GIMP_LAYER_COLOR_SPACE_RGB_PERCEPTUAL, /*< desc="RGB (perceptual)" >*/
GIMP_LAYER_COLOR_SPACE_LAB, /*< desc="LAB" >*/
GIMP_LAYER_COLOR_SPACE_LAB, /*< desc="LAB", pdb-skip >*/
} GimpLayerColorSpace;
......
......@@ -28,7 +28,7 @@
#include "internal-procs.h"
/* 804 procedures registered total */
/* 808 procedures registered total */
void
internal_procs_init (GimpPDB *pdb)
......
......@@ -1163,6 +1163,112 @@ layer_set_mode_invoker (GimpProcedure *procedure,
error ? *error : NULL);
}
static GimpValueArray *
layer_get_blend_space_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
const GimpValueArray *args,
GError **error)
{
gboolean success = TRUE;
GimpValueArray *return_vals;
GimpLayer *layer;
gint32 blend_space = 0;
layer = gimp_value_get_layer (gimp_value_array_index (args, 0), gimp);
if (success)
{
blend_space = gimp_layer_get_blend_space (layer);
}
return_vals = gimp_procedure_get_return_values (procedure, success,
error ? *error : NULL);
if (success)
g_value_set_enum (gimp_value_array_index (return_vals, 1), blend_space);
return return_vals;
}
static GimpValueArray *
layer_set_blend_space_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
const GimpValueArray *args,
GError **error)
{
gboolean success = TRUE;
GimpLayer *layer;
gint32 blend_space;
layer = gimp_value_get_layer (gimp_value_array_index (args, 0), gimp);
blend_space = g_value_get_enum (gimp_value_array_index (args, 1));
if (success)
{
gimp_layer_set_blend_space (layer, blend_space, TRUE);
}
return gimp_procedure_get_return_values (procedure, success,
error ? *error : NULL);
}
static GimpValueArray *
layer_get_composite_space_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
const GimpValueArray *args,
GError **error)
{
gboolean success = TRUE;
GimpValueArray *return_vals;
GimpLayer *layer;
gint32 composite_space = 0;
layer = gimp_value_get_layer (gimp_value_array_index (args, 0), gimp);
if (success)
{
composite_space = gimp_layer_get_composite_space (layer);
}
return_vals = gimp_procedure_get_return_values (procedure, success,
error ? *error : NULL);
if (success)
g_value_set_enum (gimp_value_array_index (return_vals, 1), composite_space);
return return_vals;
}
static GimpValueArray *
layer_set_composite_space_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
const GimpValueArray *args,
GError **error)
{
gboolean success = TRUE;
GimpLayer *layer;
gint32 composite_space;
layer = gimp_value_get_layer (gimp_value_array_index (args, 0), gimp);
composite_space = g_value_get_enum (gimp_value_array_index (args, 1));
if (success)
{
gimp_layer_set_composite_space (layer, composite_space, TRUE);
}
return gimp_procedure_get_return_values (procedure, success,
error ? *error : NULL);
}
static GimpValueArray *
layer_get_composite_mode_invoker (GimpProcedure *procedure,
Gimp *gimp,
......@@ -2249,6 +2355,126 @@ register_layer_procs (GimpPDB *pdb)
gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* gimp-layer-get-blend-space
*/
procedure = gimp_procedure_new (layer_get_blend_space_invoker);
gimp_object_set_static_name (GIMP_OBJECT (procedure),
"gimp-layer-get-blend-space");
gimp_procedure_set_static_strings (procedure,
"gimp-layer-get-blend-space",
"Get the blend space of the specified layer.",
"This procedure returns the specified layer's blend space.",
"Ell",
"Ell",
"2017",
NULL);
gimp_procedure_add_argument (procedure,
gimp_param_spec_layer_id ("layer",
"layer",
"The layer",
pdb->gimp, FALSE,
GIMP_PARAM_READWRITE));
gimp_procedure_add_return_value (procedure,
g_param_spec_enum ("blend-space",
"blend space",
"The layer blend space",
GIMP_TYPE_LAYER_COLOR_SPACE,
GIMP_LAYER_COLOR_SPACE_AUTO,
GIMP_PARAM_READWRITE));
gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* gimp-layer-set-blend-space
*/
procedure = gimp_procedure_new (layer_set_blend_space_invoker);
gimp_object_set_static_name (GIMP_OBJECT (procedure),
"gimp-layer-set-blend-space");
gimp_procedure_set_static_strings (procedure,
"gimp-layer-set-blend-space",
"Set the blend space of the specified layer.",
"This procedure sets the specified layer's blend space.",
"Ell",
"Ell",
"2017",
NULL);
gimp_procedure_add_argument (procedure,
gimp_param_spec_layer_id ("layer",
"layer",
"The layer",
pdb->gimp, FALSE,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
g_param_spec_enum ("blend-space",
"blend space",
"The new layer blend space",
GIMP_TYPE_LAYER_COLOR_SPACE,
GIMP_LAYER_COLOR_SPACE_AUTO,
GIMP_PARAM_READWRITE));
gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* gimp-layer-get-composite-space
*/
procedure = gimp_procedure_new (layer_get_composite_space_invoker);
gimp_object_set_static_name (GIMP_OBJECT (procedure),
"gimp-layer-get-composite-space");
gimp_procedure_set_static_strings (procedure,
"gimp-layer-get-composite-space",
"Get the composite space of the specified layer.",
"This procedure returns the specified layer's composite space.",
"Ell",
"Ell",
"2017",
NULL);
gimp_procedure_add_argument (procedure,
gimp_param_spec_layer_id ("layer",
"layer",
"The layer",
pdb->gimp, FALSE,
GIMP_PARAM_READWRITE));
gimp_procedure_add_return_value (procedure,
g_param_spec_enum ("composite-space",
"composite space",
"The layer composite space",
GIMP_TYPE_LAYER_COLOR_SPACE,
GIMP_LAYER_COLOR_SPACE_AUTO,
GIMP_PARAM_READWRITE));
gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* gimp-layer-set-composite-space
*/
procedure = gimp_procedure_new (layer_set_composite_space_invoker);
gimp_object_set_static_name (GIMP_OBJECT (procedure),
"gimp-layer-set-composite-space");
gimp_procedure_set_static_strings (procedure,
"gimp-layer-set-composite-space",
"Set the composite space of the specified layer.",
"This procedure sets the specified layer's composite space.",
"Ell",
"Ell",
"2017",
NULL);
gimp_procedure_add_argument (procedure,
gimp_param_spec_layer_id ("layer",
"layer",
"The layer",
pdb->gimp, FALSE,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
g_param_spec_enum ("composite-space",
"composite space",
"The new layer composite space",
GIMP_TYPE_LAYER_COLOR_SPACE,
GIMP_LAYER_COLOR_SPACE_AUTO,
GIMP_PARAM_READWRITE));
gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* gimp-layer-get-composite-mode
*/
......
......@@ -590,13 +590,16 @@ EXPORTS
gimp_item_transform_shear
gimp_layer_add_alpha
gimp_layer_add_mask
gimp_layer_color_space_get_type
gimp_layer_composite_mode_get_type
gimp_layer_copy
gimp_layer_create_mask
gimp_layer_flatten
gimp_layer_from_mask
gimp_layer_get_apply_mask
gimp_layer_get_blend_space
gimp_layer_get_composite_mode
gimp_layer_get_composite_space
gimp_layer_get_edit_mask
gimp_layer_get_lock_alpha
gimp_layer_get_mask
......@@ -618,7 +621,9 @@ EXPORTS
gimp_layer_scale
gimp_layer_scale_full
gimp_layer_set_apply_mask
gimp_layer_set_blend_space
gimp_layer_set_composite_mode
gimp_layer_set_composite_space
gimp_layer_set_edit_mask
gimp_layer_set_lock_alpha
gimp_layer_set_mode
......
......@@ -35,6 +35,7 @@ static const GimpGetTypeFunc get_type_funcs[] =
gimp_ink_blob_type_get_type,
gimp_interpolation_type_get_type,
gimp_join_style_get_type,
gimp_layer_color_space_get_type,
gimp_layer_composite_mode_get_type,
gimp_layer_mode_get_type,
gimp_mask_apply_mode_get_type,
......@@ -100,6 +101,7 @@ static const gchar * const type_names[] =
"GimpInkBlobType",
"GimpInterpolationType",
"GimpJoinStyle",
"GimpLayerColorSpace",
"GimpLayerCompositeMode",
"GimpLayerMode",
"GimpMaskApplyMode",
......
......@@ -63,6 +63,18 @@ typedef enum
} GimpHistogramChannel;
#define GIMP_TYPE_LAYER_COLOR_SPACE (gimp_layer_color_space_get_type ())
GType gimp_layer_color_space_get_type (void) G_GNUC_CONST;
typedef enum
{
GIMP_LAYER_COLOR_SPACE_AUTO,
GIMP_LAYER_COLOR_SPACE_RGB_LINEAR,
GIMP_LAYER_COLOR_SPACE_RGB_PERCEPTUAL
} GimpLayerColorSpace;
#define GIMP_TYPE_LAYER_COMPOSITE_MODE (gimp_layer_composite_mode_get_type ())
GType gimp_layer_composite_mode_get_type (void) G_GNUC_CONST;
......
......@@ -1153,6 +1153,138 @@ gimp_layer_set_mode (gint32 layer_ID,
return success;
}
/**
* gimp_layer_get_blend_space:
* @layer_ID: The layer.
*
* Get the blend space of the specified layer.
*
* This procedure returns the specified layer's blend space.
*
* Returns: The layer blend space.
*
* Since: 2.10
**/
GimpLayerColorSpace
gimp_layer_get_blend_space (gint32 layer_ID)
{
GimpParam *return_vals;
gint nreturn_vals;
GimpLayerColorSpace blend_space = 0;
return_vals = gimp_run_procedure ("gimp-layer-get-blend-space",
&nreturn_vals,
GIMP_PDB_LAYER, layer_ID,
GIMP_PDB_END);
if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
blend_space = return_vals[1].data.d_int32;
gimp_destroy_params (return_vals, nreturn_vals);
return blend_space;
}
/**
* gimp_layer_set_blend_space:
* @layer_ID: The layer.
* @blend_space: The new layer blend space.
*
* Set the blend space of the specified layer.
*
* This procedure sets the specified layer's blend space.
*
* Returns: TRUE on success.
*
* Since: 2.10
**/
gboolean
gimp_layer_set_blend_space (gint32 layer_ID,
GimpLayerColorSpace blend_space)
{
GimpParam *return_vals;
gint nreturn_vals;
gboolean success = TRUE;
return_vals = gimp_run_procedure ("gimp-layer-set-blend-space",
&nreturn_vals,
GIMP_PDB_LAYER, layer_ID,
GIMP_PDB_INT32, blend_space,
GIMP_PDB_END);
success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
gimp_destroy_params (return_vals, nreturn_vals);
return success;
}
/**
* gimp_layer_get_composite_space:
* @layer_ID: The layer.
*
* Get the composite space of the specified layer.
*
* This procedure returns the specified layer's composite space.
*
* Returns: The layer composite space.
*
* Since: 2.10
**/
GimpLayerColorSpace
gimp_layer_get_composite_space (gint32 layer_ID)
{
GimpParam *return_vals;
gint nreturn_vals;
GimpLayerColorSpace composite_space = 0;
return_vals = gimp_run_procedure ("gimp-layer-get-composite-space",
&nreturn_vals,
GIMP_PDB_LAYER, layer_ID,
GIMP_PDB_END);
if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
composite_space = return_vals[1].data.d_int32;
gimp_destroy_params (return_vals, nreturn_vals);
return composite_space;
}
/**
* gimp_layer_set_composite_space:
* @layer_ID: The layer.
* @composite_space: The new layer composite space.
*
* Set the composite space of the specified layer.
*
* This procedure sets the specified layer's composite space.
*
* Returns: TRUE on success.
*
* Since: 2.10
**/
gboolean
gimp_layer_set_composite_space (gint32 layer_ID,
GimpLayerColorSpace composite_space)
{
GimpParam *return_vals;
gint nreturn_vals;
gboolean success = TRUE;
return_vals = gimp_run_procedure ("gimp-layer-set-composite-space",
&nreturn_vals,
GIMP_PDB_LAYER, layer_ID,
GIMP_PDB_INT32, composite_space,
GIMP_PDB_END);
success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
gimp_destroy_params (return_vals, nreturn_vals);
return success;
}
/**
* gimp_layer_get_composite_mode:
* @layer_ID: The layer.
......
......@@ -98,6 +98,12 @@ gboolean gimp_layer_set_opacity (gint32
GimpLayerMode gimp_layer_get_mode (gint32 layer_ID);
gboolean gimp_layer_set_mode (gint32 layer_ID,
GimpLayerMode mode);
GimpLayerColorSpace gimp_layer_get_blend_space (gint32 layer_ID);
gboolean gimp_layer_set_blend_space (gint32 layer_ID,
GimpLayerColorSpace blend_space);
GimpLayerColorSpace gimp_layer_get_composite_space (gint32 layer_ID);
gboolean gimp_layer_set_composite_space (gint32 layer_ID,
GimpLayerColorSpace composite_space);
GimpLayerCompositeMode gimp_layer_get_composite_mode (gint32 layer_ID);
gboolean gimp_layer_set_composite_mode (gint32 layer_ID,
GimpLayerCompositeMode composite_mode);
......
......@@ -669,6 +669,16 @@ package Gimp::CodeGen::enums;
GIMP_COLOR_RENDERING_INTENT_SATURATION => '2',
GIMP_COLOR_RENDERING_INTENT_ABSOLUTE_COLORIMETRIC => '3' }
},
GimpLayerColorSpace =>
{ contig => 1,
header => 'operations/operations-enums.h',
symbols => [ qw(GIMP_LAYER_COLOR_SPACE_AUTO
GIMP_LAYER_COLOR_SPACE_RGB_LINEAR
GIMP_LAYER_COLOR_SPACE_RGB_PERCEPTUAL) ],
mapping => { GIMP_LAYER_COLOR_SPACE_AUTO => '0',
GIMP_LAYER_COLOR_SPACE_RGB_LINEAR => '1',
GIMP_LAYER_COLOR_SPACE_RGB_PERCEPTUAL => '2' }
},
GimpLayerCompositeMode =>
{ contig => 1,
header => 'operations/operations-enums.h',
......
......@@ -1210,6 +1210,100 @@ CODE
);
}
sub layer_get_blend_space {
$blurb = 'Get the blend space of the specified layer.';
$help = "This procedure returns the specified layer's blend space.";
&ell_pdb_misc('2017', '2.10');
@inargs = (
{ name => 'layer', type => 'layer',
desc => 'The layer' }
);
@outargs = (
{ name => 'blend_space', type => 'enum GimpLayerColorSpace',
desc => 'The layer blend space' }
);
%invoke = (
code => <<'CODE'
{
blend_space = gimp_layer_get_blend_space (layer);
}
CODE
);
}
sub layer_set_blend_space {
$blurb = 'Set the blend space of the specified layer.';
$help = "This procedure sets the specified layer's blend space.";
&ell_pdb_misc('2017', '2.10');
@inargs = (
{ name => 'layer', type => 'layer',
desc => 'The layer' },
{ name => 'blend_space', type => 'enum GimpLayerColorSpace',
desc => 'The new layer blend space' }
);
%invoke = (
code => <<'CODE'
{
gimp_layer_set_blend_space (layer, blend_space, TRUE);
}
CODE
);
}
sub layer_get_composite_space {
$blurb = 'Get the composite space of the specified layer.';
$help = "This procedure returns the specified layer's composite space.";
&ell_pdb_misc('2017', '2.10');
@inargs = (
{ name => 'layer', type => 'layer',
desc => 'The layer' }
);
@outargs = (
{ name => 'composite_space', type => 'enum GimpLayerColorSpace',
desc => 'The layer composite space' }
);
%invoke = (
code => <<'CODE'
{
composite_space = gimp_layer_get_composite_space (layer);
}
CODE
);
}
sub layer_set_composite_space {
$blurb = 'Set the composite space of the specified layer.';
$help = "This procedure sets the specified layer's composite space.";
&ell_pdb_misc('2017', '2.10');
@inargs = (
{ name => 'layer', type => 'layer',
desc => 'The layer' },
{ name => 'composite_space', type => 'enum GimpLayerColorSpace',
desc => 'The new layer composite space' }
);
%invoke = (
code => <<'CODE'
{
gimp_layer_set_composite_space (layer, composite_space, TRUE);
}
CODE
);
}
sub layer_get_composite_mode {
$blurb = 'Get the composite mode of the specified layer.';
$help = "This procedure returns the specified layer's composite mode.";
......@@ -1295,6 +1389,8 @@ CODE
layer_get_edit_mask layer_set_edit_mask
layer_get_opacity layer_set_opacity
layer_get_mode layer_set_mode
layer_get_blend_space layer_set_blend_space
layer_get_composite_space layer_set_composite_space
layer_get_composite_mode layer_set_composite_mode);
%exports = (app => [@procs], lib => [@procs]);
......
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