- Tim Jobling implemented PolyLine
authorRichard Campbell <betam4x@gmail.com>
Thu, 27 Mar 2003 03:24:04 +0000 (03:24 +0000)
committerRichard Campbell <betam4x@gmail.com>
Thu, 27 Mar 2003 03:24:04 +0000 (03:24 +0000)
svn path=/trunk/; revision=4441

reactos/lib/gdi32/misc/stubs.c
reactos/lib/gdi32/objects/line.c
reactos/subsys/win32k/eng/lineto.c
reactos/subsys/win32k/include/inteng.h
reactos/subsys/win32k/objects/line.c

index 997c71a..8c464dc 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: stubs.c,v 1.15 2003/03/20 03:04:02 mtempel Exp $
+/* $Id: stubs.c,v 1.16 2003/03/27 03:24:03 rcampbell Exp $
  *
  * reactos/lib/gdi32/misc/stubs.c
  *
@@ -2066,21 +2066,6 @@ DPtoLP(
 
 
 
-
-BOOL
-STDCALL
-Polyline(
-       HDC             a0,
-       CONST POINT     *a1,
-       int             a2
-       )
-{
-       SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
-       return FALSE;
-}
-
-
-
 BOOL
 STDCALL
 PolyBezier(
index 6e91a62..7c456d3 100644 (file)
@@ -21,4 +21,9 @@ MoveToEx(HDC hDC, int X, int Y, LPPOINT Point)
    return W32kMoveToEx(hDC, X, Y, Point);
 }
 
-
+BOOL
+STDCALL
+Polyline( HDC hdc, CONST POINT *lppt, int cPoints )
+{
+   return W32kPolyline(hdc, (CONST LPPOINT) lppt, cPoints);
+}
index 1795252..a4d2f09 100644 (file)
@@ -176,3 +176,38 @@ IntEngLineTo(SURFOBJ *DestSurf,
 
   return ret;
 }
+
+BOOL STDCALL
+IntEngPolyline(SURFOBJ *DestSurf,
+              CLIPOBJ *Clip,
+              BRUSHOBJ *Brush,
+              CONST LPPOINT  pt,
+               LONG dCount,
+              MIX mix)
+{
+  LONG i;
+  RECTL rect;
+  BOOL ret = FALSE;
+
+  //Draw the Polyline with a call to IntEngLineTo for each segment.
+  for (i=1; i<dCount; i++)
+  {
+    rect.left = MIN(pt[i-1].x, pt[i].x);
+    rect.top = MIN(pt[i-1].y, pt[i].y);
+    rect.right = MAX(pt[i-1].x, pt[i].x);
+    rect.bottom = MAX(pt[i-1].y, pt[i].y);
+    ret = IntEngLineTo(DestSurf,
+                      Clip,
+                      Brush,
+                      pt[i-1].x,
+                      pt[i-1].y,
+                      pt[i].x,
+                      pt[i].y,
+                      &rect,
+                      mix);
+    if (!ret)
+      break;
+  }
+
+  return ret;
+}
index 9274b68..8303ba0 100644 (file)
@@ -28,5 +28,11 @@ XLATEOBJ *IntEngCreateXlate(USHORT DestPalType,
                             USHORT SourcePalType,
                             HPALETTE PaletteDest,
                             HPALETTE PaletteSource);
-
+                       
+extern BOOL STDCALL IntEngPolyline(SURFOBJ *DestSurf,
+                                  CLIPOBJ *Clip,
+                                  BRUSHOBJ *Brush,
+                                  CONST LPPOINT  pt,
+                                  LONG dCount,
+                                  MIX mix);
 #endif
index 4346847..3336cbf 100644 (file)
@@ -259,7 +259,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