mirror of https://github.com/GNOME/gimp.git
app: use gimp_transform_polygon() in GimpCanvasBoundary
... so that clipping is done properly.
This commit is contained in:
parent
4626190ac7
commit
258e60f1b7
|
@ -29,6 +29,7 @@
|
|||
#include "display-types.h"
|
||||
|
||||
#include "core/gimp-cairo.h"
|
||||
#include "core/gimp-transform-utils.h"
|
||||
#include "core/gimpboundary.h"
|
||||
#include "core/gimpparamspecs.h"
|
||||
|
||||
|
@ -219,35 +220,44 @@ gimp_canvas_boundary_get_property (GObject *object,
|
|||
|
||||
static void
|
||||
gimp_canvas_boundary_transform (GimpCanvasItem *item,
|
||||
GimpSegment *segs)
|
||||
GimpSegment *segs,
|
||||
gint *n_segs)
|
||||
{
|
||||
GimpCanvasBoundaryPrivate *private = GET_PRIVATE (item);
|
||||
gint i;
|
||||
|
||||
if (private->transform)
|
||||
{
|
||||
gint n = 0;
|
||||
|
||||
for (i = 0; i < private->n_segs; i++)
|
||||
{
|
||||
gdouble tx, ty;
|
||||
GimpVector2 vertices[2];
|
||||
GimpVector2 t_vertices[2];
|
||||
gint n_t_vertices;
|
||||
|
||||
gimp_matrix3_transform_point (private->transform,
|
||||
private->segs[i].x1,
|
||||
private->segs[i].y1,
|
||||
&tx, &ty);
|
||||
gimp_canvas_item_transform_xy (item,
|
||||
tx + private->offset_x,
|
||||
ty + private->offset_y,
|
||||
&segs[i].x1, &segs[i].y1);
|
||||
vertices[0] = (GimpVector2) { private->segs[i].x1, private->segs[i].y1 };
|
||||
vertices[1] = (GimpVector2) { private->segs[i].x2, private->segs[i].y2 };
|
||||
|
||||
gimp_matrix3_transform_point (private->transform,
|
||||
private->segs[i].x2,
|
||||
private->segs[i].y2,
|
||||
&tx, &ty);
|
||||
gimp_canvas_item_transform_xy (item,
|
||||
tx + private->offset_x,
|
||||
ty + private->offset_y,
|
||||
&segs[i].x2, &segs[i].y2);
|
||||
gimp_transform_polygon (private->transform, vertices, 2, FALSE,
|
||||
t_vertices, &n_t_vertices);
|
||||
|
||||
if (n_t_vertices == 2)
|
||||
{
|
||||
gimp_canvas_item_transform_xy (item,
|
||||
t_vertices[0].x + private->offset_x,
|
||||
t_vertices[0].y + private->offset_y,
|
||||
&segs[n].x1, &segs[n].y1);
|
||||
gimp_canvas_item_transform_xy (item,
|
||||
t_vertices[1].x + private->offset_x,
|
||||
t_vertices[1].y + private->offset_y,
|
||||
&segs[n].x2, &segs[n].y2);
|
||||
|
||||
n++;
|
||||
}
|
||||
}
|
||||
|
||||
*n_segs = n;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -284,6 +294,8 @@ gimp_canvas_boundary_transform (GimpCanvasItem *item,
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
*n_segs = private->n_segs;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -293,12 +305,13 @@ gimp_canvas_boundary_draw (GimpCanvasItem *item,
|
|||
{
|
||||
GimpCanvasBoundaryPrivate *private = GET_PRIVATE (item);
|
||||
GimpSegment *segs;
|
||||
gint n_segs;
|
||||
|
||||
segs = g_new0 (GimpSegment, private->n_segs);
|
||||
|
||||
gimp_canvas_boundary_transform (item, segs);
|
||||
gimp_canvas_boundary_transform (item, segs, &n_segs);
|
||||
|
||||
gimp_cairo_add_segments (cr, segs, private->n_segs);
|
||||
gimp_cairo_add_segments (cr, segs, n_segs);
|
||||
|
||||
_gimp_canvas_item_stroke (item, cr);
|
||||
|
||||
|
@ -311,19 +324,27 @@ gimp_canvas_boundary_get_extents (GimpCanvasItem *item)
|
|||
GimpCanvasBoundaryPrivate *private = GET_PRIVATE (item);
|
||||
cairo_rectangle_int_t rectangle;
|
||||
GimpSegment *segs;
|
||||
gint n_segs;
|
||||
gint x1, y1, x2, y2;
|
||||
gint i;
|
||||
|
||||
segs = g_new0 (GimpSegment, private->n_segs);
|
||||
|
||||
gimp_canvas_boundary_transform (item, segs);
|
||||
gimp_canvas_boundary_transform (item, segs, &n_segs);
|
||||
|
||||
if (n_segs == 0)
|
||||
{
|
||||
g_free (segs);
|
||||
|
||||
return cairo_region_create ();
|
||||
}
|
||||
|
||||
x1 = MIN (segs[0].x1, segs[0].x2);
|
||||
y1 = MIN (segs[0].y1, segs[0].y2);
|
||||
x2 = MAX (segs[0].x1, segs[0].x2);
|
||||
y2 = MAX (segs[0].y1, segs[0].y2);
|
||||
|
||||
for (i = 1; i < private->n_segs; i++)
|
||||
for (i = 1; i < n_segs; i++)
|
||||
{
|
||||
gint x3 = MIN (segs[i].x1, segs[i].x2);
|
||||
gint y3 = MIN (segs[i].y1, segs[i].y2);
|
||||
|
|
Loading…
Reference in New Issue