Author: greatlrd
Date: Sun Dec 10 10:39:20 2006
New Revision: 25110
URL:
http://svn.reactos.org/svn/reactos?rev=25110&view=rev
Log:
small optimzing of drawing line by George Veskov (jkxxster at gmail dot com) irc nick
jkxx
Modified:
trunk/reactos/dll/win32/gdi32/objects/linedda.c
Modified: trunk/reactos/dll/win32/gdi32/objects/linedda.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/gdi32/objects/li…
==============================================================================
--- trunk/reactos/dll/win32/gdi32/objects/linedda.c (original)
+++ trunk/reactos/dll/win32/gdi32/objects/linedda.c Sun Dec 10 10:39:20 2006
@@ -43,7 +43,44 @@
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;
}