mirror of
https://gitlab.gnome.org/GNOME/gimp.git
synced 2025-07-04 01:43:24 +00:00
app: use gimp_transform_polygon() in GimpCanvasBoundary
... so that clipping is done properly.
This commit is contained in:
parent
4626190ac7
commit
258e60f1b7
1 changed files with 43 additions and 22 deletions
|
@ -29,6 +29,7 @@
|
||||||
#include "display-types.h"
|
#include "display-types.h"
|
||||||
|
|
||||||
#include "core/gimp-cairo.h"
|
#include "core/gimp-cairo.h"
|
||||||
|
#include "core/gimp-transform-utils.h"
|
||||||
#include "core/gimpboundary.h"
|
#include "core/gimpboundary.h"
|
||||||
#include "core/gimpparamspecs.h"
|
#include "core/gimpparamspecs.h"
|
||||||
|
|
||||||
|
@ -219,35 +220,44 @@ gimp_canvas_boundary_get_property (GObject *object,
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gimp_canvas_boundary_transform (GimpCanvasItem *item,
|
gimp_canvas_boundary_transform (GimpCanvasItem *item,
|
||||||
GimpSegment *segs)
|
GimpSegment *segs,
|
||||||
|
gint *n_segs)
|
||||||
{
|
{
|
||||||
GimpCanvasBoundaryPrivate *private = GET_PRIVATE (item);
|
GimpCanvasBoundaryPrivate *private = GET_PRIVATE (item);
|
||||||
gint i;
|
gint i;
|
||||||
|
|
||||||
if (private->transform)
|
if (private->transform)
|
||||||
{
|
{
|
||||||
|
gint n = 0;
|
||||||
|
|
||||||
for (i = 0; i < private->n_segs; i++)
|
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,
|
vertices[0] = (GimpVector2) { private->segs[i].x1, private->segs[i].y1 };
|
||||||
private->segs[i].x1,
|
vertices[1] = (GimpVector2) { private->segs[i].x2, private->segs[i].y2 };
|
||||||
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);
|
|
||||||
|
|
||||||
gimp_matrix3_transform_point (private->transform,
|
gimp_transform_polygon (private->transform, vertices, 2, FALSE,
|
||||||
private->segs[i].x2,
|
t_vertices, &n_t_vertices);
|
||||||
private->segs[i].y2,
|
|
||||||
&tx, &ty);
|
if (n_t_vertices == 2)
|
||||||
gimp_canvas_item_transform_xy (item,
|
{
|
||||||
tx + private->offset_x,
|
gimp_canvas_item_transform_xy (item,
|
||||||
ty + private->offset_y,
|
t_vertices[0].x + private->offset_x,
|
||||||
&segs[i].x2, &segs[i].y2);
|
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
|
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);
|
GimpCanvasBoundaryPrivate *private = GET_PRIVATE (item);
|
||||||
GimpSegment *segs;
|
GimpSegment *segs;
|
||||||
|
gint n_segs;
|
||||||
|
|
||||||
segs = g_new0 (GimpSegment, private->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);
|
_gimp_canvas_item_stroke (item, cr);
|
||||||
|
|
||||||
|
@ -311,19 +324,27 @@ gimp_canvas_boundary_get_extents (GimpCanvasItem *item)
|
||||||
GimpCanvasBoundaryPrivate *private = GET_PRIVATE (item);
|
GimpCanvasBoundaryPrivate *private = GET_PRIVATE (item);
|
||||||
cairo_rectangle_int_t rectangle;
|
cairo_rectangle_int_t rectangle;
|
||||||
GimpSegment *segs;
|
GimpSegment *segs;
|
||||||
|
gint n_segs;
|
||||||
gint x1, y1, x2, y2;
|
gint x1, y1, x2, y2;
|
||||||
gint i;
|
gint i;
|
||||||
|
|
||||||
segs = g_new0 (GimpSegment, private->n_segs);
|
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);
|
x1 = MIN (segs[0].x1, segs[0].x2);
|
||||||
y1 = MIN (segs[0].y1, segs[0].y2);
|
y1 = MIN (segs[0].y1, segs[0].y2);
|
||||||
x2 = MAX (segs[0].x1, segs[0].x2);
|
x2 = MAX (segs[0].x1, segs[0].x2);
|
||||||
y2 = MAX (segs[0].y1, segs[0].y2);
|
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 x3 = MIN (segs[i].x1, segs[i].x2);
|
||||||
gint y3 = MIN (segs[i].y1, segs[i].y2);
|
gint y3 = MIN (segs[i].y1, segs[i].y2);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue