Commit c20838fa authored by Michael Natterer's avatar Michael Natterer 😴

app: add gimp_applicator_dup_apply_buffer()

which copies a rectangle of the layer mode node's "aux" input into
a newly allocated buffer.
parent a80795e2
......@@ -408,3 +408,43 @@ gimp_applicator_blit (GimpApplicator *applicator,
gegl_node_blit (applicator->dest_node, 1.0, rect,
NULL, NULL, 0, GEGL_BLIT_DEFAULT);
}
GeglBuffer *
gimp_applicator_dup_apply_buffer (GimpApplicator *applicator,
const GeglRectangle *rect)
{
GeglBuffer *buffer;
GeglNode *offset;
GeglNode *dest;
buffer = gegl_buffer_new (GEGL_RECTANGLE (0, 0, rect->width, rect->height),
babl_format ("RGBA float"));
offset = gegl_node_new_child (applicator->node,
"operation", "gegl:translate",
"x",
(gdouble) - applicator->apply_offset_x - rect->x,
"y",
(gdouble) - applicator->apply_offset_y - rect->y,
NULL);
dest = gegl_node_new_child (applicator->node,
"operation", "gegl:write-buffer",
"buffer", buffer,
NULL);
gegl_node_link_many (applicator->apply_offset_node,
offset,
dest,
NULL);
gegl_node_blit (dest, 1.0, GEGL_RECTANGLE (0, 0, rect->width, rect->height),
NULL, NULL, 0, GEGL_BLIT_DEFAULT);
gegl_node_disconnect (offset, "input");
gegl_node_remove_child (applicator->node, offset);
gegl_node_remove_child (applicator->node, dest);
return buffer;
}
......@@ -75,35 +75,38 @@ struct _GimpApplicatorClass
};
GType gimp_applicator_get_type (void) G_GNUC_CONST;
GimpApplicator * gimp_applicator_new (GeglNode *parent);
void gimp_applicator_set_src_buffer (GimpApplicator *applicator,
GeglBuffer *dest_buffer);
void gimp_applicator_set_dest_buffer (GimpApplicator *applicator,
GeglBuffer *dest_buffer);
void gimp_applicator_set_mask_buffer (GimpApplicator *applicator,
GeglBuffer *mask_buffer);
void gimp_applicator_set_mask_offset (GimpApplicator *applicator,
gint mask_offset_x,
gint mask_offset_y);
void gimp_applicator_set_apply_buffer (GimpApplicator *applicator,
GeglBuffer *apply_buffer);
void gimp_applicator_set_apply_offset (GimpApplicator *applicator,
gint apply_offset_x,
gint apply_offset_y);
void gimp_applicator_set_mode (GimpApplicator *applicator,
gdouble opacity,
GimpLayerModeEffects paint_mode);
void gimp_applicator_set_affect (GimpApplicator *applicator,
GimpComponentMask affect);
void gimp_applicator_blit (GimpApplicator *applicator,
const GeglRectangle *rect);
GType gimp_applicator_get_type (void) G_GNUC_CONST;
GimpApplicator * gimp_applicator_new (GeglNode *parent);
void gimp_applicator_set_src_buffer (GimpApplicator *applicator,
GeglBuffer *dest_buffer);
void gimp_applicator_set_dest_buffer (GimpApplicator *applicator,
GeglBuffer *dest_buffer);
void gimp_applicator_set_mask_buffer (GimpApplicator *applicator,
GeglBuffer *mask_buffer);
void gimp_applicator_set_mask_offset (GimpApplicator *applicator,
gint mask_offset_x,
gint mask_offset_y);
void gimp_applicator_set_apply_buffer (GimpApplicator *applicator,
GeglBuffer *apply_buffer);
void gimp_applicator_set_apply_offset (GimpApplicator *applicator,
gint apply_offset_x,
gint apply_offset_y);
void gimp_applicator_set_mode (GimpApplicator *applicator,
gdouble opacity,
GimpLayerModeEffects paint_mode);
void gimp_applicator_set_affect (GimpApplicator *applicator,
GimpComponentMask affect);
void gimp_applicator_blit (GimpApplicator *applicator,
const GeglRectangle *rect);
GeglBuffer * gimp_applicator_dup_apply_buffer (GimpApplicator *applicator,
const GeglRectangle *rect);
#endif /* __GIMP_APPLICATOR_H__ */
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