]> git.saurik.com Git - wxWidgets.git/commitdiff
don't draw the endpoint in DrawLine at least in the common cases of vertical and...
authorVáclav Slavík <vslavik@fastmail.fm>
Fri, 27 Oct 2006 12:41:28 +0000 (12:41 +0000)
committerVáclav Slavík <vslavik@fastmail.fm>
Fri, 27 Oct 2006 12:41:28 +0000 (12:41 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@42521 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/dfb/dc.cpp

index 4e171feb3d47fbc41ea6e2d4e0c146c5a7439e7a..6df38389329e0f3e99f286a999f3639e82d537f8 100644 (file)
@@ -180,8 +180,32 @@ void wxDC::DoDrawLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2)
     if ( m_pen.GetStyle() == wxTRANSPARENT )
         return;
 
-    m_surface->DrawLine(XLOG2DEV(x1), YLOG2DEV(y1),
-                        XLOG2DEV(x2), YLOG2DEV(y2));
+    wxCoord xx1 = XLOG2DEV(x1);
+    wxCoord yy1 = XLOG2DEV(y1);
+    wxCoord xx2 = XLOG2DEV(x2);
+    wxCoord yy2 = XLOG2DEV(y2);
+
+    // FIXME: DrawLine() shouldn't draw the last pixel, but DFB's DrawLine()
+    //        does draw it. We should undo any change to the last pixel by
+    //        using GetPixel() and PutPixel(), but until they are implemented,
+    //        handle at least the special case of vertical and horizontal
+    //        lines correctly:
+    if ( xx1 == xx2 )
+    {
+        if ( yy1 < yy2 )
+            yy2--;
+        else if ( yy1 > yy2 )
+            yy2++;
+    }
+    if ( yy1 == yy2 )
+    {
+        if ( xx1 < xx2 )
+            xx2--;
+        else if ( xx1 > xx2 )
+            xx2++;
+    }
+
+    m_surface->DrawLine(xx1, yy1, xx2, yy2);
 
     CalcBoundingBox(x1, y1);
     CalcBoundingBox(x2, y2);