Alexandre Julliard : wineps: Implement PolyBezier using the Postscript curveto function.
Alexandre Julliard
julliard at winehq.org
Tue Nov 1 13:23:15 CDT 2011
Module: wine
Branch: master
Commit: da3511fd3bdb92216ddd92b490c5ab0f2ac33846
URL: http://source.winehq.org/git/wine.git/?a=commit;h=da3511fd3bdb92216ddd92b490c5ab0f2ac33846
Author: Alexandre Julliard <julliard at winehq.org>
Date: Mon Oct 31 19:39:02 2011 +0100
wineps: Implement PolyBezier using the Postscript curveto function.
---
dlls/wineps.drv/graphics.c | 54 ++++++++++++++++++++++++++++++++++++++++++++
dlls/wineps.drv/init.c | 4 +-
dlls/wineps.drv/ps.c | 11 +++++++++
dlls/wineps.drv/psdrv.h | 3 ++
4 files changed, 70 insertions(+), 2 deletions(-)
diff --git a/dlls/wineps.drv/graphics.c b/dlls/wineps.drv/graphics.c
index ce7013e..a7670b6 100644
--- a/dlls/wineps.drv/graphics.c
+++ b/dlls/wineps.drv/graphics.c
@@ -411,6 +411,60 @@ BOOL PSDRV_Polygon( PHYSDEV dev, const POINT* pt, INT count )
/***********************************************************************
+ * PSDRV_PolyBezier
+ */
+BOOL PSDRV_PolyBezier( PHYSDEV dev, const POINT *pts, DWORD count )
+{
+ DWORD i;
+ POINT *dev_pts;
+
+ TRACE("\n");
+
+ if (!(dev_pts = HeapAlloc( GetProcessHeap(), 0, count * sizeof(*dev_pts) ))) return FALSE;
+ memcpy( dev_pts, pts, count * sizeof(*dev_pts) );
+ LPtoDP( dev->hdc, dev_pts, count );
+
+ PSDRV_WriteSpool(dev, "%PolyBezier\n",12);
+ PSDRV_SetPen(dev);
+ PSDRV_SetClip(dev);
+ PSDRV_WriteMoveTo(dev, dev_pts[0].x, dev_pts[0].y );
+ for (i = 1; i < count; i += 3) PSDRV_WriteCurveTo( dev, dev_pts + i );
+ PSDRV_DrawLine(dev);
+ PSDRV_ResetClip(dev);
+ HeapFree( GetProcessHeap(), 0, dev_pts );
+ return TRUE;
+}
+
+
+/***********************************************************************
+ * PSDRV_PolyBezierTo
+ */
+BOOL PSDRV_PolyBezierTo( PHYSDEV dev, const POINT *pts, DWORD count )
+{
+ DWORD i;
+ POINT *dev_pts;
+
+ TRACE("\n");
+
+ count++; /* add initial position */
+ if (!(dev_pts = HeapAlloc( GetProcessHeap(), 0, count * sizeof(*dev_pts) ))) return FALSE;
+ GetCurrentPositionEx( dev->hdc, dev_pts );
+ memcpy( dev_pts + 1, pts, (count - 1) * sizeof(*dev_pts) );
+ LPtoDP( dev->hdc, dev_pts, count );
+
+ PSDRV_WriteSpool(dev, "%PolyBezier\n",12);
+ PSDRV_SetPen(dev);
+ PSDRV_SetClip(dev);
+ PSDRV_WriteMoveTo(dev, dev_pts[0].x, dev_pts[0].y );
+ for (i = 1; i < count; i += 3) PSDRV_WriteCurveTo( dev, dev_pts + i );
+ PSDRV_DrawLine(dev);
+ PSDRV_ResetClip(dev);
+ HeapFree( GetProcessHeap(), 0, dev_pts );
+ return TRUE;
+}
+
+
+/***********************************************************************
* PSDRV_SetPixel
*/
COLORREF PSDRV_SetPixel( PHYSDEV dev, INT x, INT y, COLORREF color )
diff --git a/dlls/wineps.drv/init.c b/dlls/wineps.drv/init.c
index 5235998..66b014c 100644
--- a/dlls/wineps.drv/init.c
+++ b/dlls/wineps.drv/init.c
@@ -890,8 +890,8 @@ static const struct gdi_dc_funcs psdrv_funcs =
PSDRV_PaintRgn, /* pPaintRgn */
PSDRV_PatBlt, /* pPatBlt */
PSDRV_Pie, /* pPie */
- NULL, /* pPolyBezier */
- NULL, /* pPolyBezierTo */
+ PSDRV_PolyBezier, /* pPolyBezier */
+ PSDRV_PolyBezierTo, /* pPolyBezierTo */
NULL, /* pPolyDraw */
PSDRV_PolyPolygon, /* pPolyPolygon */
PSDRV_PolyPolyline, /* pPolyPolyline */
diff --git a/dlls/wineps.drv/ps.c b/dlls/wineps.drv/ps.c
index 4b70f79..a456253 100644
--- a/dlls/wineps.drv/ps.c
+++ b/dlls/wineps.drv/ps.c
@@ -138,6 +138,9 @@ static const char psarc[] = /* x, y, w, h, ang1, ang2 */
"0 0 0.5 %.1f %.1f arc\n"
"tmpmtrx setmatrix\n";
+static const char pscurveto[] = /* x1, y1, x2, y2, x3, y3 */
+"%d %d %d %d %d %d curveto\n";
+
static const char psgsave[] =
"gsave\n";
@@ -501,6 +504,14 @@ BOOL PSDRV_WriteArc(PHYSDEV dev, INT x, INT y, INT w, INT h, double ang1,
return PSDRV_WriteSpool(dev, buf, strlen(buf));
}
+BOOL PSDRV_WriteCurveTo(PHYSDEV dev, POINT pts[3])
+{
+ char buf[256];
+
+ sprintf(buf, pscurveto, pts[0].x, pts[0].y, pts[1].x, pts[1].y, pts[2].x, pts[2].y );
+ return PSDRV_WriteSpool(dev, buf, strlen(buf));
+}
+
BOOL PSDRV_WriteSetFont(PHYSDEV dev, const char *name, matrix size, INT escapement)
{
diff --git a/dlls/wineps.drv/psdrv.h b/dlls/wineps.drv/psdrv.h
index bf01d15..2b24617 100644
--- a/dlls/wineps.drv/psdrv.h
+++ b/dlls/wineps.drv/psdrv.h
@@ -442,6 +442,8 @@ extern BOOL PSDRV_PaintRgn( PHYSDEV dev, HRGN hrgn ) DECLSPEC_HIDDEN;
extern BOOL PSDRV_PatBlt(PHYSDEV dev, struct bitblt_coords *dst, DWORD dwRop) DECLSPEC_HIDDEN;
extern BOOL PSDRV_Pie( PHYSDEV dev, INT left, INT top, INT right, INT bottom,
INT xstart, INT ystart, INT xend, INT yend ) DECLSPEC_HIDDEN;
+extern BOOL PSDRV_PolyBezier( PHYSDEV dev, const POINT *pts, DWORD count ) DECLSPEC_HIDDEN;
+extern BOOL PSDRV_PolyBezierTo( PHYSDEV dev, const POINT *pts, DWORD count ) DECLSPEC_HIDDEN;
extern BOOL PSDRV_PolyPolygon( PHYSDEV dev, const POINT* pts, const INT* counts, UINT polygons ) DECLSPEC_HIDDEN;
extern BOOL PSDRV_PolyPolyline( PHYSDEV dev, const POINT* pts, const DWORD* counts, DWORD polylines ) DECLSPEC_HIDDEN;
extern BOOL PSDRV_Polygon( PHYSDEV dev, const POINT* pt, INT count ) DECLSPEC_HIDDEN;
@@ -502,6 +504,7 @@ extern BOOL PSDRV_WriteGlyphShow(PHYSDEV dev, LPCSTR g_name) DECLSPEC_HIDDEN;
extern BOOL PSDRV_WriteSetPen(PHYSDEV dev) DECLSPEC_HIDDEN;
extern BOOL PSDRV_WriteArc(PHYSDEV dev, INT x, INT y, INT w, INT h,
double ang1, double ang2) DECLSPEC_HIDDEN;
+extern BOOL PSDRV_WriteCurveTo(PHYSDEV dev, POINT pts[3]) DECLSPEC_HIDDEN;
extern BOOL PSDRV_WriteSetColor(PHYSDEV dev, PSCOLOR *color) DECLSPEC_HIDDEN;
extern BOOL PSDRV_WriteSetBrush(PHYSDEV dev) DECLSPEC_HIDDEN;
extern BOOL PSDRV_WriteFill(PHYSDEV dev) DECLSPEC_HIDDEN;
More information about the wine-cvs
mailing list