app: add a "layer-mode" property to GimpOperationLayerMode

This commit is contained in:
Michael Natterer
2017-01-22 14:41:21 +01:00
parent d293a00995
commit b10fc58802
4 changed files with 24 additions and 1 deletions

View File

@ -157,6 +157,7 @@ gimp_gegl_mode_node_set_mode (GeglNode *node,
*/
gegl_node_set (node,
"operation", gimp_layer_mode_get_operation (mode),
"layer-mode", mode,
"opacity", opacity,
"linear", gimp_layer_mode_is_linear (mode),
"blend-trc", gimp_layer_mode_get_blend_space (mode),

View File

@ -35,6 +35,7 @@
enum
{
PROP_0,
PROP_LAYER_MODE,
PROP_LINEAR,
PROP_OPACITY,
PROP_BLEND_TRC,
@ -86,6 +87,14 @@ gimp_operation_layer_mode_class_init (GimpOperationLayerModeClass *klass)
operation_class->prepare = gimp_operation_layer_mode_prepare;
operation_class->process = gimp_operation_layer_mode_process;
g_object_class_install_property (object_class, PROP_LAYER_MODE,
g_param_spec_enum ("layer-mode",
NULL, NULL,
GIMP_TYPE_LAYER_MODE,
GIMP_LAYER_MODE_NORMAL,
GIMP_PARAM_READWRITE |
G_PARAM_CONSTRUCT));
g_object_class_install_property (object_class, PROP_LINEAR,
g_param_spec_boolean ("linear",
NULL, NULL,
@ -149,6 +158,10 @@ gimp_operation_layer_mode_set_property (GObject *object,
switch (property_id)
{
case PROP_LAYER_MODE:
self->layer_mode = g_value_get_enum (value);
break;
case PROP_LINEAR:
self->linear = g_value_get_boolean (value);
break;
@ -185,6 +198,10 @@ gimp_operation_layer_mode_get_property (GObject *object,
switch (property_id)
{
case PROP_LAYER_MODE:
g_value_set_enum (value, self->layer_mode);
break;
case PROP_LINEAR:
g_value_set_boolean (value, self->linear);
break;

View File

@ -44,6 +44,7 @@ struct _GimpOperationLayerMode
{
GeglOperationPointComposer3 parent_instance;
GimpLayerMode layer_mode;
gboolean linear;
gdouble opacity;
GimpLayerColorSpace blend_trc;

View File

@ -305,6 +305,7 @@ do_layer_blend (GeglBuffer *src_buffer,
GeglBufferIterator *iter;
guint paint_stride;
gfloat *paint_data;
gboolean linear;
GimpLayerModeFunc apply_func;
GimpLayerColorSpace blend_trc;
GimpLayerColorSpace composite_trc;
@ -313,12 +314,13 @@ do_layer_blend (GeglBuffer *src_buffer,
paint_stride = gimp_temp_buf_get_width (paint_buf);
paint_data = (gfloat *) gimp_temp_buf_get_data (paint_buf);
linear = gimp_layer_mode_is_linear (paint_mode);
apply_func = gimp_get_layer_mode_function (paint_mode);
blend_trc = gimp_layer_mode_get_blend_space (paint_mode);
composite_trc = gimp_layer_mode_get_composite_space (paint_mode);
composite_mode = gimp_layer_mode_get_composite_mode (paint_mode);
if (gimp_layer_mode_is_linear (paint_mode))
if (linear)
iterator_format = babl_format ("RGBA float");
else
iterator_format = babl_format ("R'G'B'A float");
@ -361,6 +363,8 @@ do_layer_blend (GeglBuffer *src_buffer,
paint_pixel = paint_data + ((iter->roi[0].y - roi.y) * paint_stride + iter->roi[0].x - roi.x) * 4;
layer_data.layer_mode = paint_mode;
layer_data.linear = linear;
layer_data.opacity = opacity;
layer_data.blend_trc = blend_trc;
layer_data.composite_trc = composite_trc;