[gimp/blend-tool-fun: 7/9] app: Place shapeburst buffers at the right offset.
- From: Michael Henning <mhenning src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp/blend-tool-fun: 7/9] app: Place shapeburst buffers at the right offset.
- Date: Sun, 6 Sep 2015 23:09:28 +0000 (UTC)
commit b5c460490e3b0b1beecd6526a0f16ce1a730b494
Author: Michael Henning <drawoc darkrefraction com>
Date: Mon May 11 21:41:16 2015 -0400
app: Place shapeburst buffers at the right offset.
app/core/gimpdrawable-blend.c | 21 ++++++---------------
app/tools/gimpblendtool.c | 36 ++++++++++--------------------------
app/tools/gimpblendtool.h | 2 --
3 files changed, 16 insertions(+), 43 deletions(-)
---
diff --git a/app/core/gimpdrawable-blend.c b/app/core/gimpdrawable-blend.c
index 01002ef..a59ea1f 100644
--- a/app/core/gimpdrawable-blend.c
+++ b/app/core/gimpdrawable-blend.c
@@ -544,15 +544,11 @@ gimp_drawable_blend_shapeburst_distmap (GimpDrawable *drawable,
gimp_progress_set_text_literal (progress, _("Calculating distance map"));
/* allocate the distance map */
- dist_buffer = gegl_buffer_new (GEGL_RECTANGLE (0, 0,
- region->width, region->height),
- babl_format ("Y float"));
+ dist_buffer = gegl_buffer_new (region, babl_format ("Y float"));
/* allocate the selection mask copy
*/
- temp_buffer = gegl_buffer_new (GEGL_RECTANGLE (0, 0,
- region->width, region->height),
- babl_format ("Y float"));
+ temp_buffer = gegl_buffer_new (region, babl_format ("Y float"));
mask = gimp_image_get_mask (image);
@@ -568,9 +564,7 @@ gimp_drawable_blend_shapeburst_distmap (GimpDrawable *drawable,
/* copy the mask to the temp mask */
gegl_buffer_copy (gimp_drawable_get_buffer (GIMP_DRAWABLE (mask)),
GEGL_RECTANGLE (x + off_x, y + off_y, width, height),
- GEGL_ABYSS_NONE,
- temp_buffer,
- GEGL_RECTANGLE (0, 0, 0, 0));
+ GEGL_ABYSS_NONE, temp_buffer, region);
}
else
{
@@ -583,12 +577,9 @@ gimp_drawable_blend_shapeburst_distmap (GimpDrawable *drawable,
/* extract the aplha into the temp mask */
gegl_buffer_set_format (temp_buffer, component_format);
- gegl_buffer_copy (gimp_drawable_get_buffer (drawable),
- GEGL_RECTANGLE (region->x, region->y,
- region->width, region->height),
+ gegl_buffer_copy (gimp_drawable_get_buffer (drawable), region,
GEGL_ABYSS_NONE,
- temp_buffer,
- GEGL_RECTANGLE (0, 0, 0, 0));
+ temp_buffer, region);
gegl_buffer_set_format (temp_buffer, NULL);
}
else
@@ -617,7 +608,7 @@ gimp_drawable_blend_shapeburst_distmap (GimpDrawable *drawable,
gimp_gegl_apply_operation (temp_buffer, NULL, NULL,
shapeburst,
- dist_buffer, NULL);
+ dist_buffer, region);
g_object_unref (shapeburst);
diff --git a/app/tools/gimpblendtool.c b/app/tools/gimpblendtool.c
index 86a1453..895c59e 100644
--- a/app/tools/gimpblendtool.c
+++ b/app/tools/gimpblendtool.c
@@ -827,7 +827,6 @@ gimp_blend_tool_halt_preview (GimpBlendTool *blend_tool)
blend_tool->subtract_node = NULL;
blend_tool->divide_node = NULL;
blend_tool->dist_node = NULL;
- blend_tool->translate_node = NULL;
}
if (blend_tool->dist_buffer)
@@ -940,23 +939,15 @@ gimp_blend_tool_precalc_shapeburst (GimpBlendTool *blend_tool)
return;
buf = gimp_drawable_blend_shapeburst_distmap (drawable, FALSE,
- GEGL_RECTANGLE (0, 0, width, height),
+ GEGL_RECTANGLE (x, y, width, height),
GIMP_PROGRESS (blend_tool));
blend_tool->dist_buffer = buf;
- blend_tool->dist_buffer_off_x = x;
- blend_tool->dist_buffer_off_y = y;
if (blend_tool->dist_node)
gegl_node_set (blend_tool->dist_node,
"buffer", blend_tool->dist_buffer,
NULL);
-
- if (blend_tool->translate_node)
- gegl_node_set (blend_tool->translate_node,
- "x", (gdouble) blend_tool->dist_buffer_off_x,
- "y", (gdouble) blend_tool->dist_buffer_off_y,
- NULL);
}
/* gegl graph stuff */
@@ -966,7 +957,7 @@ gimp_blend_tool_create_graph (GimpBlendTool *blend_tool)
{
GimpBlendOptions *options = GIMP_BLEND_TOOL_GET_OPTIONS (blend_tool);
GimpContext *context = GIMP_CONTEXT (options);
- GeglNode *graph, *output, *render, *shapeburst, *translate, *subtract, *divide;
+ GeglNode *graph, *output, *render, *shapeburst, *subtract, *divide;
/* render_node is not supposed to be recreated */
g_return_if_fail (blend_tool->graph == NULL);
@@ -981,26 +972,19 @@ gimp_blend_tool_create_graph (GimpBlendTool *blend_tool)
"context", context,
NULL);
- translate = gegl_node_new_child (graph, "operation", "gegl:translate",
- "x", (gdouble) blend_tool->dist_buffer_off_x,
- "y", (gdouble) blend_tool->dist_buffer_off_y,
- NULL);
-
subtract = gegl_node_new_child (graph, "operation", "gegl:subtract", NULL);
divide = gegl_node_new_child (graph, "operation", "gegl:divide", NULL);
shapeburst = gegl_node_new_child (graph, "operation", "gegl:buffer-source",
"buffer", blend_tool->dist_buffer, NULL);
- gegl_node_link_many (shapeburst, translate, subtract, divide,
- render, output, NULL);
+ gegl_node_link_many (shapeburst, subtract, divide, render, output, NULL);
blend_tool->graph = graph;
blend_tool->render_node = render;
blend_tool->subtract_node = subtract;
blend_tool->divide_node = divide;
blend_tool->dist_node = shapeburst;
- blend_tool->translate_node = translate;
gimp_blend_tool_update_preview_coords (blend_tool);
}
@@ -1010,20 +994,23 @@ gimp_blend_tool_update_preview_coords (GimpBlendTool *blend_tool)
{
GimpTool *tool = GIMP_TOOL (blend_tool);
+ gint off_x, off_y;
+ gimp_item_get_offset (GIMP_ITEM (tool->drawable), &off_x, &off_y);
+
if (gimp_blend_tool_is_shapeburst (blend_tool))
{
gfloat start, end;
gegl_buffer_get (blend_tool->dist_buffer,
- GEGL_RECTANGLE (blend_tool->start_x - blend_tool->dist_buffer_off_x,
- blend_tool->start_y - blend_tool->dist_buffer_off_y,
+ GEGL_RECTANGLE (blend_tool->start_x - off_x,
+ blend_tool->start_y - off_y,
1, 1),
1.0, babl_format("Y float"), &start,
GEGL_AUTO_ROWSTRIDE, GEGL_ABYSS_NONE);
gegl_buffer_get (blend_tool->dist_buffer,
- GEGL_RECTANGLE (blend_tool->end_x - blend_tool->dist_buffer_off_x,
- blend_tool->end_y - blend_tool->dist_buffer_off_y,
+ GEGL_RECTANGLE (blend_tool->end_x - off_x,
+ blend_tool->end_y - off_y,
1, 1),
1.0, babl_format("Y float"), &end,
GEGL_AUTO_ROWSTRIDE, GEGL_ABYSS_NONE);
@@ -1039,9 +1026,6 @@ gimp_blend_tool_update_preview_coords (GimpBlendTool *blend_tool)
}
else
{
- gint off_x, off_y;
- gimp_item_get_offset (GIMP_ITEM (tool->drawable), &off_x, &off_y);
-
gegl_node_set (blend_tool->render_node,
"start_x", blend_tool->start_x - off_x,
"start_y", blend_tool->start_y - off_y,
diff --git a/app/tools/gimpblendtool.h b/app/tools/gimpblendtool.h
index 3d74c74..3f8a09c 100644
--- a/app/tools/gimpblendtool.h
+++ b/app/tools/gimpblendtool.h
@@ -71,9 +71,7 @@ struct _GimpBlendTool
GeglNode *subtract_node;
GeglNode *divide_node;
GeglNode *dist_node;
- GeglNode *translate_node;
GeglBuffer *dist_buffer;
- gint dist_buffer_off_x, dist_buffer_off_y;
GimpImageMap *image_map;
};
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]