Commit faf22178 authored by Pedro Gimeno Fortea's avatar Pedro Gimeno Fortea

Bug 696958 - In-image preview in Transform tools is off by one screen pixel

Simplify the loops without any significant loss in performance, separating
the positive and negative X directions to treat each correctly. Fixes this
bug.
parent c83e7790
......@@ -1177,85 +1177,50 @@ gimp_canvas_transform_preview_trace_tri_edge (gint *dest,
gint x2,
gint y2)
{
const gint dy = y2 - y1;
gint dx;
gint xdir;
const gint dx = x2 - x1;
const gint dy = y2 - y1;
gint b = dy;
gint *dptr = dest;
gint errorterm;
gint b;
gint *dptr;
if (dy <= 0)
return;
g_return_if_fail (dest != NULL);
errorterm = 0;
dptr = dest;
if (x2 < x1)
{
dx = x1 - x2;
xdir = -1;
}
else
if (dx >= 0)
{
dx = x2 - x1;
xdir = 1;
}
errorterm = 0;
if (dx >= dy)
{
b = dy;
while (b --)
while (b--)
{
*dptr = x1;
*dptr++ = x1;
errorterm += dx;
while (errorterm > dy)
{
x1 += xdir;
x1++;
errorterm -= dy;
}
dptr ++;
}
}
else if (dy >= dx)
else
{
b = dy;
while (b --)
{
*dptr = x1;
errorterm += dx;
errorterm = dy;
if (errorterm > dy)
while (b--)
{
while (errorterm > dy)
{
x1 += xdir;
x1--;
errorterm -= dy;
}
dptr ++;
}
}
else if (dx == 0)
{
b = dy;
while (b --)
{
*dptr = x1;
dptr ++;
}
}
else /* dy == dx */
{
b = dy;
while (b --)
{
*dptr = x1;
x1 += xdir;
/* dx is negative here, so this is effectively an addition: */
errorterm -= dx;
dptr ++;
*dptr++ = x1;
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment