small optimzing of drawing line by George Veskov (jkxxster at gmail dot com) irc nick jkxx

svn path=/trunk/; revision=25110
This commit is contained in:
Magnus Olsen
2006-12-10 07:39:20 +00:00
parent 5ad7b6a0c9
commit da0a71a8bc
+38 -1
View File
@@ -43,7 +43,44 @@ BOOL STDCALL LineDDA(INT nXStart, INT nYStart, INT nXEnd, INT nYEnd,
INT cnt;
INT dx = nXEnd - nXStart;
INT dy = nYEnd - nYStart;
// optimized for vertical and horizontal lines so we avoid unnecessary math
if(nXStart == nXEnd)
{
// vertical line - use dx,dy as temp variables so we don't waste stack space
if(nYStart < nYEnd)
{
dx = nYStart;
dy = nYEnd;
} else {
dx = nYEnd;
dy = nYStart;
}
for(cnt = dx; cnt <= dy; cnt++)
{
lpLineFunc(nXStart,cnt,lpData);
}
return TRUE;
}
if(nYStart == nYEnd)
{
// horizontal line - use dx,dy as temp variables so we don't waste stack space
if(nXStart < nXEnd)
{
dx = nXStart;
dy = nXEnd;
} else {
dx = nXEnd;
dy = nXStart;
}
for(cnt = dx; cnt <= dy; cnt++)
{
lpLineFunc(cnt, nYStart,lpData);
}
return TRUE;
}
// end of H/V line code
if (dx < 0) {
dx = -dx; xadd = -1;
}