mirror of https://github.com/GNOME/gimp.git
app: fix drawing artifacts in GimpCanvasRectangle
The width/height returned by gimp_canvas_rectangle_transform() were off-by-one if the rectangle's width/height were exactly 0.0 and its x/y exact integers, causing too much drawing and/or too little invalidation.
This commit is contained in:
parent
cad5c1e2fb
commit
b75b7de064
|
@ -206,36 +206,43 @@ gimp_canvas_rectangle_transform (GimpCanvasItem *item,
|
||||||
gdouble *h)
|
gdouble *h)
|
||||||
{
|
{
|
||||||
GimpCanvasRectanglePrivate *private = GET_PRIVATE (item);
|
GimpCanvasRectanglePrivate *private = GET_PRIVATE (item);
|
||||||
|
gdouble x1, y1;
|
||||||
|
gdouble x2, y2;
|
||||||
|
|
||||||
gimp_display_shell_transform_xy_f (shell,
|
gimp_display_shell_transform_xy_f (shell,
|
||||||
MIN (private->x,
|
MIN (private->x,
|
||||||
private->x + private->width),
|
private->x + private->width),
|
||||||
MIN (private->y,
|
MIN (private->y,
|
||||||
private->y + private->height),
|
private->y + private->height),
|
||||||
x, y);
|
&x1, &y1);
|
||||||
gimp_display_shell_transform_xy_f (shell,
|
gimp_display_shell_transform_xy_f (shell,
|
||||||
MAX (private->x,
|
MAX (private->x,
|
||||||
private->x + private->width),
|
private->x + private->width),
|
||||||
MAX (private->y,
|
MAX (private->y,
|
||||||
private->y + private->height),
|
private->y + private->height),
|
||||||
w, h);
|
&x2, &y2);
|
||||||
|
|
||||||
*w -= *x;
|
x1 = floor (x1);
|
||||||
*h -= *y;
|
y1 = floor (y1);
|
||||||
|
x2 = ceil (x2);
|
||||||
|
y2 = ceil (y2);
|
||||||
|
|
||||||
if (private->filled)
|
if (private->filled)
|
||||||
{
|
{
|
||||||
*x = floor (*x);
|
*x = x1;
|
||||||
*y = floor (*y);
|
*y = y1;
|
||||||
*w = ceil (*w);
|
*w = x2 - x1;
|
||||||
*h = ceil (*h);
|
*h = y2 - y1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
*x = floor (*x) + 0.5;
|
*x = x1 + 0.5;
|
||||||
*y = floor (*y) + 0.5;
|
*y = y1 + 0.5;
|
||||||
*w = ceil (*w) - 1.0;
|
*w = x2 - 0.5 - *x;
|
||||||
*h = ceil (*h) - 1.0;
|
*h = y2 - 0.5 - *y;
|
||||||
|
|
||||||
|
*w = MAX (0.0, *w);
|
||||||
|
*h = MAX (0.0, *h);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue