app: improve warp-tool cropped-area calculation

In the warp tool, use the gegl:map-relative node to calculate the
affected drawable area to which the filter is cropped, to account
for box filtering.

(cherry picked from commit daa09ef602)
This commit is contained in:
Ell
2019-03-04 08:25:39 -05:00
parent 2758a34b02
commit 6ae957088a

View File

@ -123,9 +123,10 @@ static void gimp_warp_tool_set_sampler (GimpWarpTool *wt,
gboolean commit); gboolean commit);
static GeglRectangle static GeglRectangle
gimp_warp_tool_get_stroke_bounds (GeglNode *node); gimp_warp_tool_get_stroke_bounds (GeglNode *node);
static GeglRectangle static GeglRectangle gimp_warp_tool_get_node_bounds (GeglNode *node);
gimp_warp_tool_get_node_bounds (GeglNode *node);
static void gimp_warp_tool_clear_node_bounds (GeglNode *node); static void gimp_warp_tool_clear_node_bounds (GeglNode *node);
static GeglRectangle gimp_warp_tool_get_invalidated_by_change (GimpWarpTool *wt,
const GeglRectangle *area);
static void gimp_warp_tool_update_bounds (GimpWarpTool *wt); static void gimp_warp_tool_update_bounds (GimpWarpTool *wt);
static void gimp_warp_tool_update_area (GimpWarpTool *wt, static void gimp_warp_tool_update_area (GimpWarpTool *wt,
const GeglRectangle *area, const GeglRectangle *area,
@ -620,6 +621,7 @@ gimp_warp_tool_options_notify (GimpTool *tool,
{ {
gimp_warp_tool_set_sampler (wt, /* commit = */ FALSE); gimp_warp_tool_set_sampler (wt, /* commit = */ FALSE);
gimp_warp_tool_update_bounds (wt);
gimp_warp_tool_update_stroke (wt, NULL); gimp_warp_tool_update_stroke (wt, NULL);
} }
} }
@ -638,6 +640,7 @@ gimp_warp_tool_options_notify (GimpTool *tool,
{ {
gimp_warp_tool_set_sampler (wt, /* commit = */ FALSE); gimp_warp_tool_set_sampler (wt, /* commit = */ FALSE);
gimp_warp_tool_update_bounds (wt);
gimp_warp_tool_update_stroke (wt, NULL); gimp_warp_tool_update_stroke (wt, NULL);
} }
} }
@ -1072,6 +1075,26 @@ gimp_warp_tool_clear_node_bounds (GeglNode *node)
g_object_set_data (G_OBJECT (node), "gimp-warp-tool-bounds", NULL); g_object_set_data (G_OBJECT (node), "gimp-warp-tool-bounds", NULL);
} }
static GeglRectangle
gimp_warp_tool_get_invalidated_by_change (GimpWarpTool *wt,
const GeglRectangle *area)
{
GeglRectangle result = *area;
if (! wt->filter)
return result;
if (wt->render_node)
{
GeglOperation *operation = gegl_node_get_gegl_operation (wt->render_node);
result = gegl_operation_get_invalidated_by_change (operation,
"aux", area);
}
return result;
}
static void static void
gimp_warp_tool_update_bounds (GimpWarpTool *wt) gimp_warp_tool_update_bounds (GimpWarpTool *wt)
{ {
@ -1085,6 +1108,8 @@ gimp_warp_tool_update_bounds (GimpWarpTool *wt)
GeglNode *node = gegl_node_get_producer (wt->render_node, "aux", NULL); GeglNode *node = gegl_node_get_producer (wt->render_node, "aux", NULL);
bounds = gimp_warp_tool_get_node_bounds (node); bounds = gimp_warp_tool_get_node_bounds (node);
bounds = gimp_warp_tool_get_invalidated_by_change (wt, &bounds);
} }
gimp_drawable_filter_set_crop (wt->filter, &bounds, FALSE); gimp_drawable_filter_set_crop (wt->filter, &bounds, FALSE);
@ -1095,17 +1120,12 @@ gimp_warp_tool_update_area (GimpWarpTool *wt,
const GeglRectangle *area, const GeglRectangle *area,
gboolean synchronous) gboolean synchronous)
{ {
GeglRectangle rect = *area; GeglRectangle rect;
if (! wt->filter) if (! wt->filter)
return; return;
if (wt->render_node) rect = gimp_warp_tool_get_invalidated_by_change (wt, area);
{
GeglOperation *operation = gegl_node_get_gegl_operation (wt->render_node);
rect = gegl_operation_get_invalidated_by_change (operation, "aux", &rect);
}
if (synchronous) if (synchronous)
{ {