hackathon-dev #1

Merged
amy merged 101 commits from hackathon-dev into develop 2019-12-12 13:56:11 -07:00
Showing only changes of commit d66aa4de24 - Show all commits

View File

@ -5,7 +5,7 @@
#include "gfxobj.h"
#include "devctxt.h"
inline static BYTE line_clip_outcode(INT32 x, INT32 y, INT32 xmin, INT32 ymin, INT32 xmax, INT32 ymax)
inline static BYTE line_clip_outcode(INT64 x, INT64 y, INT64 xmin, INT64 ymin, INT64 xmax, INT64 ymax)
{
BYTE rc = 0;
if (y < ymin)
@ -19,12 +19,12 @@ inline static BYTE line_clip_outcode(INT32 x, INT32 y, INT32 xmin, INT32 ymin, I
return rc;
}
static BOOL line_clip(PINT32 output, INT32 x1, INT32 y1, INT32 x2, INT32 y2, INT32 xmin, INT32 ymin, INT32 xmax, INT32 ymax)
static BOOL line_clip(PINT32 output, INT64 x1, INT64 y1, INT64 x2, INT64 y2, INT64 xmin, INT64 ymin, INT64 xmax, INT64 ymax)
{
BYTE outcode1, outcode2;
INT32 tmp;
INT64 tmp;
Log(LDEBUG, "clipping line from (%d, %d) to (%d, %d) against bounding box (%d, %d, %d, %d)", x1 >> 16, y1 >> 16, x2 >> 16, y2 >> 16,
Log(LDEBUG, "clipping line from (%lld, %lld) to (%lld, %lld) against bounding box (%lld, %lld, %lld, %lld)", x1 >> 16, y1 >> 16, x2 >> 16, y2 >> 16,
xmin >> 16, ymin >> 16, xmax >> 16, ymax >> 16);
/* Cohen-Sutherland line-clipping algorithm (see Foley & Van Dam, pp. 145-149) */
@ -58,39 +58,35 @@ static BOOL line_clip(PINT32 output, INT32 x1, INT32 y1, INT32 x2, INT32 y2, INT
tmp = (x2 - x1) * ((ymin - y1) / (y2 - y1));
x1 += tmp;
y1 = ymin;
Log(LDEBUG, "clipped against top to point (%d, %d), dx=%d/%d", x1 >> 16, y1 >> 16, tmp >> 16, tmp);
Log(LDEBUG, "clipped against top to point (%lld, %lld), dx=%lld/%lld", x1 >> 16, y1 >> 16, tmp >> 16, tmp);
}
else if (outcode1 & 0x4)
{
tmp = (x2 - x1) * ((ymax - y1) / (y2 - y1));
x1 += tmp;
y1 = ymax;
Log(LDEBUG, "clipped against bottom to point (%d, %d), dx=%d/%d", x1 >> 16, y1 >> 16, tmp >> 16, tmp);
Log(LDEBUG, "clipped against bottom to point (%lld, %lld), dx=%lld/%lld", x1 >> 16, y1 >> 16, tmp >> 16, tmp);
}
else if (outcode1 & 0x2)
{
tmp = (y2 - y1) * ((xmax - x1) / (x2 - x1));
y1 -= tmp;
x1 = xmax;
Log(LDEBUG, "clipped against right to point (%d, %d), dy=%d/%d", x1 >> 16, y1 >> 16, tmp >> 16, tmp);
Log(LDEBUG, "clipped against right to point (%lld, %lld), dy=%lld/%lld", x1 >> 16, y1 >> 16, tmp >> 16, tmp);
}
else if (outcode1 & 0x1)
{
int term1 = y2 - y1;
int term2 = xmin - x1;
int term3 = x2 - x1;
Log(LDEBUG, "term1=%d term2=%d term3=%d i1=%d i2=%d", term1 >> 16, term2 >> 16, term3 >> 16, (term1 * term2) >> 16, (term2 / term3) >> 16);
tmp = (y2 - y1) * ((xmin - x1) / (x2 - x1));
y1 -= tmp;
x1 = xmin;
Log(LDEBUG, "clipped against left to point (%d, %d), dy=%d/%d", x1 >> 16, y1 >> 16, tmp >> 16, tmp);
Log(LDEBUG, "clipped against left to point (%lld, %lld), dy=%lld/%lld", x1 >> 16, y1 >> 16, tmp >> 16, tmp);
}
}
Log(LDEBUG, "final line is from (%d, %d) to (%d, %d)", x1 >> 16, y1 >> 16, x2 >> 16, y2 >> 16);
output[0] = x1;
output[1] = y1;
output[2] = x2;
output[3] = y2;
Log(LDEBUG, "final line is from (%lld, %lld) to (%lld, %lld)", x1 >> 16, y1 >> 16, x2 >> 16, y2 >> 16);
output[0] = (INT32)x1;
output[1] = (INT32)y1;
output[2] = (INT32)x2;
output[3] = (INT32)y2;
return TRUE;
}