update for HEAD-2003050101
[reactos.git] / subsys / win32k / objects / line.c
index c4b1ac1..a71e204 100644 (file)
@@ -2,16 +2,19 @@
 
 #undef WIN32_LEAN_AND_MEAN
 #include <windows.h>
+#include <internal/safe.h>
 #include <ddk/ntddk.h>
 #include <win32k/dc.h>
 #include <win32k/line.h>
 #include <win32k/path.h>
 #include <win32k/pen.h>
 #include <win32k/region.h>
+#include <include/inteng.h>
 
-// #define NDEBUG
+#define NDEBUG
 #include <win32k/debug1.h>
 
+
 BOOL
 STDCALL
 W32kAngleArc(HDC  hDC,
@@ -109,6 +112,9 @@ W32kLineTo(HDC  hDC,
   BOOL ret;
   PPENOBJ   pen;
   PROSRGNDATA  reg;
+#ifndef TODO
+  RECT defaultrect;
+#endif
 
   if(!dc) return FALSE;
 
@@ -120,18 +126,28 @@ W32kLineTo(HDC  hDC,
 
        ASSERT( pen );
        // not yet implemented ASSERT( reg );
+#ifndef TODO
+  if (NULL == reg) {
+    defaultrect.left = 0;
+    defaultrect.top = 0;
+    defaultrect.right = 640;
+    defaultrect.bottom = 480;
+
+    reg = &defaultrect;
+  }
+#endif
 
     /* Draw the line according to the DC origin */
-    ret = EngLineTo(SurfObj,
-                    NULL, // ClipObj
-                    PenToBrushObj(dc, pen),
-                    dc->w.DCOrgX + dc->w.CursPosX, dc->w.DCOrgY + dc->w.CursPosY,
-                    dc->w.DCOrgX + XEnd,           dc->w.DCOrgY + YEnd,
-                    reg, // Bounding rectangle
-                    dc->w.ROPmode); // MIX
-
-       GDIOBJ_UnlockObj( dc->w.hGCClipRgn, GO_REGION_MAGIC );
-       GDIOBJ_UnlockObj( dc->w.hPen, GO_PEN_MAGIC);
+    ret = IntEngLineTo(SurfObj,
+                       NULL, // ClipObj
+                       PenToBrushObj(dc, pen),
+                       dc->w.DCOrgX + dc->w.CursPosX, dc->w.DCOrgY + dc->w.CursPosY,
+                       dc->w.DCOrgX + XEnd,           dc->w.DCOrgY + YEnd,
+                       reg, // Bounding rectangle
+                       dc->w.ROPmode); // MIX
+
+    GDIOBJ_UnlockObj( dc->w.hGCClipRgn, GO_REGION_MAGIC );
+    GDIOBJ_UnlockObj( dc->w.hPen, GO_PEN_MAGIC);
   }
   if(ret) {
     dc->w.CursPosX = XEnd;
@@ -244,7 +260,72 @@ W32kPolyline(HDC  hDC,
                    CONST LPPOINT  pt,
                    int  Count)
 {
-   UNIMPLEMENTED;
+  DC           *dc = DC_HandleToPtr(hDC);
+  SURFOBJ      *SurfObj = (SURFOBJ*)AccessUserObject(dc->Surface);
+  BOOL ret;
+  LONG i;
+  PPENOBJ   pen;
+  PROSRGNDATA  reg;
+  POINT *pts;
+
+  if (!dc) 
+    return(FALSE);
+
+  if(PATH_IsPathOpen(dc->w.path))
+  {
+    ret = PATH_Polyline(hDC, pt, Count);
+  }
+  else
+  {
+    pen = (PPENOBJ) GDIOBJ_LockObj(dc->w.hPen, GO_PEN_MAGIC);
+    reg = (PROSRGNDATA)GDIOBJ_LockObj(dc->w.hGCClipRgn, GO_REGION_MAGIC);
+
+    ASSERT( pen );
+
+    //FIXME: Do somthing with reg...
+
+    //Allocate "Count" bytes of memory to hold a safe copy of pt
+    if (!(pts=ExAllocatePool(NonPagedPool, sizeof(POINT) * Count))) 
+    {
+      GDIOBJ_UnlockObj( dc->w.hGCClipRgn, GO_REGION_MAGIC );
+      GDIOBJ_UnlockObj( dc->w.hPen, GO_PEN_MAGIC);
+      DC_ReleasePtr( hDC );
+      return(FALSE);
+    }
+    //safly copy pt to local version
+    if (STATUS_SUCCESS!=MmCopyFromCaller(pts, pt, sizeof(POINT) * Count))
+    {
+      ExFreePool(pts);
+      GDIOBJ_UnlockObj( dc->w.hGCClipRgn, GO_REGION_MAGIC );
+      GDIOBJ_UnlockObj( dc->w.hPen, GO_PEN_MAGIC);
+      DC_ReleasePtr( hDC );
+      return(FALSE);
+    }
+    //offset the array of point by the dc->w.DCOrg
+    for(i=0; i<Count; i++)
+    {
+      pts[i].x += dc->w.DCOrgX;
+      pts[i].y += dc->w.DCOrgY;
+    }
+  
+    //get IntEngPolyline to do the drawing.
+    ret = IntEngPolyline(SurfObj,
+                        NULL,
+                        PenToBrushObj(dc, pen),
+                        pts,
+                         Count,
+                        dc->w.ROPmode);
+
+    //Clean up
+    ExFreePool(pts);
+    GDIOBJ_UnlockObj( dc->w.hGCClipRgn, GO_REGION_MAGIC );
+    GDIOBJ_UnlockObj( dc->w.hPen, GO_PEN_MAGIC);
+  }
+
+  DC_ReleasePtr( hDC );
+  return(ret);
 }
 
 BOOL