Alexandre Julliard : wineps: Stroke and fill GDI paths using Postscript paths.

Alexandre Julliard julliard at winehq.org
Tue Nov 1 13:23:15 CDT 2011


Module: wine
Branch: master
Commit: c9c568dda9801f16ded902ad7b35d578eda24352
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=c9c568dda9801f16ded902ad7b35d578eda24352

Author: Alexandre Julliard <julliard at winehq.org>
Date:   Mon Oct 31 19:58:12 2011 +0100

wineps: Stroke and fill GDI paths using Postscript paths.

---

 dlls/wineps.drv/graphics.c |   71 ++++++++++++++++++++++++++++++++++++++++++++
 dlls/wineps.drv/init.c     |    6 ++--
 dlls/wineps.drv/psdrv.h    |    3 ++
 3 files changed, 77 insertions(+), 3 deletions(-)

diff --git a/dlls/wineps.drv/graphics.c b/dlls/wineps.drv/graphics.c
index a7670b6..3459fe1 100644
--- a/dlls/wineps.drv/graphics.c
+++ b/dlls/wineps.drv/graphics.c
@@ -525,3 +525,74 @@ BOOL PSDRV_PaintRgn( PHYSDEV dev, HRGN hrgn )
     HeapFree(GetProcessHeap(), 0, rgndata);
     return TRUE;
 }
+
+static BOOL paint_path( PHYSDEV dev, BOOL stroke, BOOL fill )
+{
+    POINT *points;
+    BYTE *types;
+    BOOL ret = FALSE;
+    int i, size = GetPath( dev->hdc, NULL, NULL, 0 );
+
+    if (size == -1) return FALSE;
+    if (!size) return TRUE;
+    points = HeapAlloc( GetProcessHeap(), 0, size * sizeof(*points) );
+    types = HeapAlloc( GetProcessHeap(), 0, size * sizeof(*types) );
+    if (!points || !types) goto done;
+    if (GetPath( dev->hdc, points, types, size ) == -1) goto done;
+
+    if (fill) PSDRV_SetPen(dev);
+    PSDRV_SetClip(dev);
+    for (i = 0; i < size; i++)
+    {
+        switch (types[i] & ~PT_CLOSEFIGURE)
+        {
+        case PT_MOVETO:
+            PSDRV_WriteMoveTo( dev, points[i].x, points[i].y );
+            break;
+        case PT_LINETO:
+        case PT_LINETO | PT_CLOSEFIGURE:
+            PSDRV_WriteLineTo( dev, points[i].x, points[i].y );
+            if (types[i] & PT_CLOSEFIGURE) PSDRV_WriteClosePath( dev );
+            break;
+        case PT_BEZIERTO:
+        case PT_BEZIERTO | PT_CLOSEFIGURE:
+            PSDRV_WriteCurveTo( dev, points + i );
+            if (types[i] & PT_CLOSEFIGURE) PSDRV_WriteClosePath( dev );
+            i += 2;
+            break;
+        }
+    }
+    if (fill) PSDRV_Brush( dev, GetPolyFillMode(dev->hdc) == ALTERNATE );
+    if (stroke) PSDRV_DrawLine(dev);
+    else PSDRV_WriteNewPath(dev);
+    PSDRV_ResetClip(dev);
+
+done:
+    HeapFree( GetProcessHeap(), 0, points );
+    HeapFree( GetProcessHeap(), 0, types );
+    return ret;
+}
+
+/***********************************************************************
+ *           PSDRV_FillPath
+ */
+BOOL PSDRV_FillPath( PHYSDEV dev )
+{
+    return paint_path( dev, FALSE, TRUE );
+}
+
+/***********************************************************************
+ *           PSDRV_StrokeAndFillPath
+ */
+BOOL PSDRV_StrokeAndFillPath( PHYSDEV dev )
+{
+    return paint_path( dev, TRUE, TRUE );
+}
+
+/***********************************************************************
+ *           PSDRV_StrokePath
+ */
+BOOL PSDRV_StrokePath( PHYSDEV dev )
+{
+    return paint_path( dev, TRUE, FALSE );
+}
diff --git a/dlls/wineps.drv/init.c b/dlls/wineps.drv/init.c
index 66b014c..b92157e 100644
--- a/dlls/wineps.drv/init.c
+++ b/dlls/wineps.drv/init.c
@@ -850,7 +850,7 @@ static const struct gdi_dc_funcs psdrv_funcs =
     NULL,                               /* pExtFloodFill */
     NULL,                               /* pExtSelectClipRgn */
     PSDRV_ExtTextOut,                   /* pExtTextOut */
-    NULL,                               /* pFillPath */
+    PSDRV_FillPath,                     /* pFillPath */
     NULL,                               /* pFillRgn */
     NULL,                               /* pFlattenPath */
     NULL,                               /* pFontIsLinked */
@@ -945,8 +945,8 @@ static const struct gdi_dc_funcs psdrv_funcs =
     PSDRV_StartPage,                    /* pStartPage */
     NULL,                               /* pStretchBlt */
     NULL,                               /* pStretchDIBits */
-    NULL,                               /* pStrokeAndFillPath */
-    NULL,                               /* pStrokePath */
+    PSDRV_StrokeAndFillPath,            /* pStrokeAndFillPath */
+    PSDRV_StrokePath,                   /* pStrokePath */
     NULL,                               /* pSwapBuffers */
     NULL,                               /* pUnrealizePalette */
     NULL,                               /* pWidenPath */
diff --git a/dlls/wineps.drv/psdrv.h b/dlls/wineps.drv/psdrv.h
index 2b24617..6337cb4 100644
--- a/dlls/wineps.drv/psdrv.h
+++ b/dlls/wineps.drv/psdrv.h
@@ -433,6 +433,7 @@ extern INT PSDRV_ExtEscape( PHYSDEV dev, INT nEscape, INT cbInput, LPCVOID in_da
                             INT cbOutput, LPVOID out_data ) DECLSPEC_HIDDEN;
 extern BOOL PSDRV_ExtTextOut( PHYSDEV dev, INT x, INT y, UINT flags,
                               const RECT *lprect, LPCWSTR str, UINT count, const INT *lpDx ) DECLSPEC_HIDDEN;
+extern BOOL PSDRV_FillPath( PHYSDEV dev ) DECLSPEC_HIDDEN;
 extern BOOL PSDRV_GetCharWidth(PHYSDEV dev, UINT firstChar, UINT lastChar, LPINT buffer) DECLSPEC_HIDDEN;
 extern BOOL PSDRV_GetTextExtentExPoint(PHYSDEV dev, LPCWSTR str, INT count,
                                        INT maxExt, LPINT lpnFit, LPINT alpDx, LPSIZE size) DECLSPEC_HIDDEN;
@@ -464,6 +465,8 @@ extern COLORREF PSDRV_SetDCPenColor( PHYSDEV dev, COLORREF color ) DECLSPEC_HIDD
 extern COLORREF PSDRV_SetPixel( PHYSDEV dev, INT x, INT y, COLORREF color ) DECLSPEC_HIDDEN;
 extern COLORREF PSDRV_SetTextColor( PHYSDEV dev, COLORREF color ) DECLSPEC_HIDDEN;
 extern INT PSDRV_StartDoc( PHYSDEV dev, const DOCINFOW *doc ) DECLSPEC_HIDDEN;
+extern BOOL PSDRV_StrokeAndFillPath( PHYSDEV dev ) DECLSPEC_HIDDEN;
+extern BOOL PSDRV_StrokePath( PHYSDEV dev ) DECLSPEC_HIDDEN;
 
 extern void PSDRV_MergeDevmodes(PSDRV_DEVMODEA *dm1, PSDRV_DEVMODEA *dm2,
 			 PRINTERINFO *pi) DECLSPEC_HIDDEN;




More information about the wine-cvs mailing list