diff --git a/graphics/psdrv/Makefile.in b/graphics/psdrv/Makefile.in index aa3dddeff7e..764a09294b2 100644 --- a/graphics/psdrv/Makefile.in +++ b/graphics/psdrv/Makefile.in @@ -7,6 +7,7 @@ MODULE = psdrv C_SRCS = \ afm.c \ + bitmap.c \ brush.c \ color.c \ driver.c \ diff --git a/graphics/psdrv/bitmap.c b/graphics/psdrv/bitmap.c new file mode 100644 index 00000000000..1a0698b8051 --- /dev/null +++ b/graphics/psdrv/bitmap.c @@ -0,0 +1,30 @@ +/* + * PostScript driver bitmap functions + * + * Copyright 1998 Huw D M Davies + * + */ + +#include "windows.h" +#include "gdi.h" +#include "psdrv.h" +#include "debug.h" + + +/*************************************************************************** + * + * PSDRV_StretchDIBits + */ +INT32 PSDRV_StretchDIBits( DC *dc, INT32 xDst, INT32 yDst, INT32 widthDst, + INT32 heightDst, INT32 xSrc, INT32 ySrc, + INT32 widthSrc, INT32 heightSrc, const void *bits, + const BITMAPINFO *info, UINT32 wUsage, DWORD dwRop ) +{ + TRACE(psdrv, "(%d,%d %dx%d) -> (%d,%d %dx%d) on %08x. %d colour bits\n", + xSrc, ySrc, widthSrc, heightSrc, xDst, yDst, widthDst, heightDst, + dc->hSelf, info->bmiHeader.biBitCount); + + + FIXME(psdrv, "stub\n"); + return FALSE; +} diff --git a/graphics/psdrv/brush.c b/graphics/psdrv/brush.c index 8a82afd539a..2579e4c9e49 100644 --- a/graphics/psdrv/brush.c +++ b/graphics/psdrv/brush.c @@ -9,7 +9,7 @@ #include "psdrv.h" #include "brush.h" #include "debug.h" - +#include "gdi.h" /*********************************************************************** * PSDRV_BRUSH_SelectObject @@ -25,16 +25,18 @@ HBRUSH32 PSDRV_BRUSH_SelectObject( DC * dc, HBRUSH32 hbrush, BRUSHOBJ * brush ) switch(brush->logbrush.lbStyle) { case BS_SOLID: - physDev->brush.style = BS_SOLID; PSDRV_CreateColor(physDev, &physDev->brush.color, brush->logbrush.lbColor); break; case BS_NULL: - physDev->brush.style = BS_NULL; break; case BS_HATCHED: + PSDRV_CreateColor(physDev, &physDev->brush.color, + brush->logbrush.lbColor); + break; + case BS_PATTERN: FIXME(psdrv, "Unsupported brush style %d\n", brush->logbrush.lbStyle); break; @@ -54,15 +56,25 @@ HBRUSH32 PSDRV_BRUSH_SelectObject( DC * dc, HBRUSH32 hbrush, BRUSHOBJ * brush ) * PSDRV_SetBrush * */ -BOOL32 PSDRV_SetBrush(DC *dc) +static BOOL32 PSDRV_SetBrush(DC *dc) { PSDRV_PDEVICE *physDev = (PSDRV_PDEVICE *)dc->physDev; + BRUSHOBJ *brush = (BRUSHOBJ *)GDI_GetObjPtr( dc->w.hBrush, BRUSH_MAGIC ); - switch (physDev->brush.style) { + if(!brush) { + ERR(psdrv, "Can't get BRUSHOBJ\n"); + return FALSE; + } + + switch (brush->logbrush.lbStyle) { case BS_SOLID: + case BS_HATCHED: PSDRV_WriteSetColor(dc, &physDev->brush.color); break; + case BS_NULL: + break; + default: return FALSE; break; @@ -71,3 +83,120 @@ BOOL32 PSDRV_SetBrush(DC *dc) physDev->brush.set = TRUE; return TRUE; } + + +/********************************************************************** + * + * PSDRV_Fill + * + */ +static BOOL32 PSDRV_Fill(DC *dc, BOOL32 EO) +{ + if(!EO) + return PSDRV_WriteFill(dc); + else + return PSDRV_WriteEOFill(dc); +} + + +/********************************************************************** + * + * PSDRV_Clip + * + */ +static BOOL32 PSDRV_Clip(DC *dc, BOOL32 EO) +{ + if(!EO) + return PSDRV_WriteClip(dc); + else + return PSDRV_WriteEOClip(dc); +} + +/********************************************************************** + * + * PSDRV_Brush + * + */ +BOOL32 PSDRV_Brush(DC *dc, BOOL32 EO) +{ + BRUSHOBJ *brush = (BRUSHOBJ *)GDI_GetObjPtr( dc->w.hBrush, BRUSH_MAGIC ); + + if(!brush) { + ERR(psdrv, "Can't get BRUSHOBJ\n"); + return FALSE; + } + + switch (brush->logbrush.lbStyle) { + case BS_SOLID: + PSDRV_SetBrush(dc); + PSDRV_WriteGSave(dc); + PSDRV_Fill(dc, EO); + PSDRV_WriteGRestore(dc); + return TRUE; + break; + + case BS_HATCHED: + PSDRV_SetBrush(dc); + + switch(brush->logbrush.lbHatch) { + case HS_VERTICAL: + case HS_CROSS: + PSDRV_WriteGSave(dc); + PSDRV_Clip(dc, EO); + PSDRV_WriteHatch(dc); + PSDRV_WriteStroke(dc); + PSDRV_WriteGRestore(dc); + if(brush->logbrush.lbHatch == HS_VERTICAL) + break; + /* else fallthrough for HS_CROSS */ + + case HS_HORIZONTAL: + PSDRV_WriteGSave(dc); + PSDRV_Clip(dc, EO); + PSDRV_WriteRotate(dc, 90.0); + PSDRV_WriteHatch(dc); + PSDRV_WriteStroke(dc); + PSDRV_WriteGRestore(dc); + break; + + case HS_FDIAGONAL: + case HS_DIAGCROSS: + PSDRV_WriteGSave(dc); + PSDRV_Clip(dc, EO); + PSDRV_WriteRotate(dc, -45.0); + PSDRV_WriteHatch(dc); + PSDRV_WriteStroke(dc); + PSDRV_WriteGRestore(dc); + if(brush->logbrush.lbHatch == HS_FDIAGONAL) + break; + /* else fallthrough for HS_DIAGCROSS */ + + case HS_BDIAGONAL: + PSDRV_WriteGSave(dc); + PSDRV_Clip(dc, EO); + PSDRV_WriteRotate(dc, 45.0); + PSDRV_WriteHatch(dc); + PSDRV_WriteStroke(dc); + PSDRV_WriteGRestore(dc); + break; + + default: + ERR(psdrv, "Unknown hatch style\n"); + return FALSE; + } + return TRUE; + break; + + case BS_NULL: + return TRUE; + break; + + default: + return FALSE; + break; + } +} + + + + diff --git a/graphics/psdrv/font.c b/graphics/psdrv/font.c index 6a058806fea..ba73a42a4e0 100644 --- a/graphics/psdrv/font.c +++ b/graphics/psdrv/font.c @@ -178,6 +178,24 @@ BOOL32 PSDRV_GetTextExtentPoint( DC *dc, LPCSTR str, INT32 count, } +/*********************************************************************** + * PSDRV_GetCharWidth + */ +BOOL32 PSDRV_GetCharWidth( DC *dc, UINT32 firstChar, UINT32 lastChar, + LPINT32 buffer ) +{ + PSDRV_PDEVICE *physDev = (PSDRV_PDEVICE *)dc->physDev; + UINT32 i; + + TRACE(psdrv, "first = %d last = %d\n", firstChar, lastChar); + + for( i = firstChar; i <= lastChar; i++ ) + *buffer++ = physDev->font.afm->CharWidths[i] * physDev->font.scale; + + return TRUE; +} + + /*********************************************************************** * PSDRV_SetFont */ diff --git a/graphics/psdrv/graphics.c b/graphics/psdrv/graphics.c index 70a84ce69df..6d2cceb59f6 100644 --- a/graphics/psdrv/graphics.c +++ b/graphics/psdrv/graphics.c @@ -5,10 +5,14 @@ * */ #include +#include #include "windows.h" #include "psdrv.h" #include "debug.h" #include "print.h" +#ifndef PI +#define PI M_PI +#endif /********************************************************************** * PSDRV_MoveToEx @@ -27,6 +31,7 @@ BOOL32 PSDRV_MoveToEx(DC *dc, INT32 x, INT32 y, LPPOINT32 pt) return TRUE; } + /*********************************************************************** * PSDRV_LineTo */ @@ -45,11 +50,12 @@ BOOL32 PSDRV_LineTo(DC *dc, INT32 x, INT32 y) return TRUE; } + /*********************************************************************** * PSDRV_Rectangle */ -BOOL32 PSDRV_Rectangle(DC *dc, INT32 left, INT32 top, INT32 right, - INT32 bottom) +BOOL32 PSDRV_Rectangle( DC *dc, INT32 left, INT32 top, INT32 right, + INT32 bottom ) { INT32 width = XLSTODS(dc, right - left); INT32 height = YLSTODS(dc, bottom - top); @@ -60,77 +66,241 @@ BOOL32 PSDRV_Rectangle(DC *dc, INT32 left, INT32 top, INT32 right, PSDRV_WriteRectangle(dc, XLPTODP(dc, left), YLPTODP(dc, top), width, height); - PSDRV_SetBrush(dc); - PSDRV_Writegsave(dc); - PSDRV_WriteFill(dc); - PSDRV_Writegrestore(dc); + PSDRV_Brush(dc,0); PSDRV_SetPen(dc); PSDRV_WriteStroke(dc); return TRUE; } +/*********************************************************************** + * PSDRV_RoundRect + */ +BOOL32 PSDRV_RoundRect( DC *dc, INT32 left, INT32 top, INT32 right, + INT32 bottom, INT32 ell_width, INT32 ell_height ) +{ + left = XLPTODP( dc, left ); + right = XLPTODP( dc, right ); + top = YLPTODP( dc, top ); + bottom = YLPTODP( dc, bottom ); + ell_width = XLSTODS( dc, ell_width ); + ell_height = YLSTODS( dc, ell_height ); + + if( left > right ) { INT32 tmp = left; left = right; right = tmp; } + if( top > bottom ) { INT32 tmp = top; top = bottom; bottom = tmp; } + + if(ell_width > right - left) ell_width = right - left; + if(ell_height > bottom - top) ell_height = bottom - top; + + PSDRV_WriteMoveTo( dc, left, top + ell_height/2 ); + PSDRV_WriteArc( dc, left + ell_width/2, top + ell_height/2, ell_width, + ell_height, 90.0, 180.0); + PSDRV_WriteLineTo( dc, right - ell_width/2, top ); + PSDRV_WriteArc( dc, right - ell_width/2, top + ell_height/2, ell_width, + ell_height, 0.0, 90.0); + PSDRV_WriteLineTo( dc, right, bottom - ell_height/2 ); + PSDRV_WriteArc( dc, right - ell_width/2, bottom - ell_height/2, ell_width, + ell_height, -90.0, 0.0); + PSDRV_WriteLineTo( dc, right - ell_width/2, bottom); + PSDRV_WriteArc( dc, left + ell_width/2, bottom - ell_height/2, ell_width, + ell_height, 180.0, -90.0); + PSDRV_WriteClosePath( dc ); + + PSDRV_Brush(dc,0); + PSDRV_SetPen(dc); + PSDRV_WriteStroke(dc); + return TRUE; +} + +/*********************************************************************** + * PSDRV_DrawArc + * + * Does the work of Arc, Chord and Pie. lines is 0, 1 or 2 respectively. + */ +static BOOL32 PSDRV_DrawArc( DC *dc, INT32 left, INT32 top, + INT32 right, INT32 bottom, + INT32 xstart, INT32 ystart, + INT32 xend, INT32 yend, + int lines ) +{ + INT32 x, y, h, w; + double start_angle, end_angle, ratio; + + x = XLPTODP(dc, (left + right)/2); + y = YLPTODP(dc, (top + bottom)/2); + + w = XLSTODS(dc, (right - left)); + h = YLSTODS(dc, (bottom - top)); + + if(w < 0) w = -w; + if(h < 0) h = -h; + ratio = ((double)w)/h; + + /* angle is the angle after the rectangle is transformed to a square and is + measured anticlockwise from the +ve x-axis */ + + start_angle = atan2((double)(y - ystart) * ratio, (double)(xstart - x)); + end_angle = atan2((double)(y - yend) * ratio, (double)(xend - x)); + + start_angle *= 180.0 / PI; + end_angle *= 180.0 / PI; + + if(lines == 2) /* pie */ + PSDRV_WriteMoveTo(dc, x, y); + PSDRV_WriteArc(dc, x, y, w, h, start_angle, end_angle); + if(lines == 1 || lines == 2) { /* chord or pie */ + PSDRV_WriteClosePath(dc); + PSDRV_Brush(dc,0); + } + PSDRV_SetPen(dc); + PSDRV_WriteStroke(dc); + return TRUE; +} + + +/*********************************************************************** + * PSDRV_Arc + */ +BOOL32 PSDRV_Arc( DC *dc, INT32 left, INT32 top, INT32 right, INT32 bottom, + INT32 xstart, INT32 ystart, INT32 xend, INT32 yend ) +{ + return PSDRV_DrawArc( dc, left, top, right, bottom, xstart, ystart, + xend, yend, 0 ); +} + +/*********************************************************************** + * PSDRV_Chord + */ +BOOL32 PSDRV_Chord( DC *dc, INT32 left, INT32 top, INT32 right, INT32 bottom, + INT32 xstart, INT32 ystart, INT32 xend, INT32 yend ) +{ + return PSDRV_DrawArc( dc, left, top, right, bottom, xstart, ystart, + xend, yend, 1 ); +} + + +/*********************************************************************** + * PSDRV_Pie + */ +BOOL32 PSDRV_Pie( DC *dc, INT32 left, INT32 top, INT32 right, INT32 bottom, + INT32 xstart, INT32 ystart, INT32 xend, INT32 yend ) +{ + return PSDRV_DrawArc( dc, left, top, right, bottom, xstart, ystart, + xend, yend, 2 ); +} + + /*********************************************************************** * PSDRV_Ellipse */ BOOL32 PSDRV_Ellipse( DC *dc, INT32 left, INT32 top, INT32 right, INT32 bottom) { - INT32 x, y, a, b; + INT32 x, y, w, h; TRACE(psdrv, "%d %d - %d %d\n", left, top, right, bottom); x = XLPTODP(dc, (left + right)/2); y = YLPTODP(dc, (top + bottom)/2); - a = XLSTODS(dc, (right - left)/2); - b = YLSTODS(dc, (bottom - top)/2); + w = XLSTODS(dc, (right - left)); + h = YLSTODS(dc, (bottom - top)); - PSDRV_WriteEllispe(dc, x, y, a, b); - PSDRV_SetBrush(dc); - PSDRV_Writegsave(dc); - PSDRV_WriteFill(dc); - PSDRV_Writegrestore(dc); + PSDRV_WriteArc(dc, x, y, w, h, 0.0, 360.0); + PSDRV_WriteClosePath(dc); + PSDRV_Brush(dc,0); PSDRV_SetPen(dc); PSDRV_WriteStroke(dc); return TRUE; } +/*********************************************************************** + * PSDRV_PolyPolyline + */ +BOOL32 PSDRV_PolyPolyline( DC *dc, LPPOINT32 pts, LPDWORD counts, + DWORD polylines ) +{ + DWORD polyline, line; + LPPOINT32 pt; + TRACE(psdrv, "\n"); + + pt = pts; + for(polyline = 0; polyline < polylines; polyline++) { + PSDRV_WriteMoveTo(dc, XLPTODP(dc, pt->x), YLPTODP(dc, pt->y)); + pt++; + for(line = 1; line < counts[polyline]; line++) { + PSDRV_WriteLineTo(dc, XLPTODP(dc, pt->x), YLPTODP(dc, pt->y)); + pt++; + } + } + PSDRV_SetPen(dc); + PSDRV_WriteStroke(dc); + return TRUE; +} + + /*********************************************************************** * PSDRV_Polyline */ BOOL32 PSDRV_Polyline( DC *dc, const LPPOINT32 pt, INT32 count ) { - INT32 i; - TRACE(psdrv, "count = %d\n", count); - + return PSDRV_PolyPolyline( dc, pt, (LPDWORD) &count, 1 ); +} + + +/*********************************************************************** + * PSDRV_PolyPolygon + */ +BOOL32 PSDRV_PolyPolygon( DC *dc, LPPOINT32 pts, LPINT32 counts, + UINT32 polygons ) +{ + DWORD polygon, line; + LPPOINT32 pt; + TRACE(psdrv, "\n"); + + pt = pts; + for(polygon = 0; polygon < polygons; polygon++) { + PSDRV_WriteMoveTo(dc, XLPTODP(dc, pt->x), YLPTODP(dc, pt->y)); + pt++; + for(line = 1; line < counts[polygon]; line++) { + PSDRV_WriteLineTo(dc, XLPTODP(dc, pt->x), YLPTODP(dc, pt->y)); + pt++; + } + PSDRV_WriteClosePath(dc); + } + + if(dc->w.polyFillMode == ALTERNATE) + PSDRV_Brush(dc, 1); + else /* WINDING */ + PSDRV_Brush(dc, 0); PSDRV_SetPen(dc); - PSDRV_WriteMoveTo(dc, XLPTODP(dc, pt[0].x), YLPTODP(dc, pt[0].y)); - for(i = 1; i < count; i++) - PSDRV_WriteLineTo(dc, XLPTODP(dc, pt[i].x), YLPTODP(dc, pt[i].y)); PSDRV_WriteStroke(dc); return TRUE; } - /*********************************************************************** * PSDRV_Polygon */ BOOL32 PSDRV_Polygon( DC *dc, LPPOINT32 pt, INT32 count ) { - INT32 i; - TRACE(psdrv, "count = %d\n", count); - FIXME(psdrv, "Hack!\n"); - - PSDRV_SetPen(dc); - PSDRV_WriteMoveTo(dc, XLPTODP(dc, pt[0].x), YLPTODP(dc, pt[0].y)); - for(i = 1; i < count; i++) - PSDRV_WriteLineTo(dc, XLPTODP(dc, pt[i].x), YLPTODP(dc, pt[i].y)); - - if(pt[0].x != pt[count-1].x || pt[0].y != pt[count-1].y) - PSDRV_WriteLineTo(dc, XLPTODP(dc, pt[0].x), YLPTODP(dc, pt[0].y)); - - PSDRV_WriteStroke(dc); - return TRUE; + return PSDRV_PolyPolygon( dc, pt, &count, 1 ); } + +/*********************************************************************** + * PSDRV_SetPixel + */ +COLORREF PSDRV_SetPixel( DC *dc, INT32 x, INT32 y, COLORREF color ) +{ + PSDRV_PDEVICE *physDev = (PSDRV_PDEVICE *)dc->physDev; + PSCOLOR pscolor; + + x = XLPTODP(dc, x); + y = YLPTODP(dc, y); + + PSDRV_WriteRectangle( dc, x, y, 0, 0 ); + PSDRV_CreateColor( physDev, &pscolor, color ); + PSDRV_WriteSetColor( dc, &pscolor ); + PSDRV_WriteFill( dc ); + return color; +} diff --git a/graphics/psdrv/init.c b/graphics/psdrv/init.c index cc43a6d3132..55d4d81ff9b 100644 --- a/graphics/psdrv/init.c +++ b/graphics/psdrv/init.c @@ -20,9 +20,9 @@ static BOOL32 PSDRV_DeleteDC( DC *dc ); static const DC_FUNCTIONS PSDRV_Funcs = { - NULL, /* pArc */ + PSDRV_Arc, /* pArc */ NULL, /* pBitBlt */ - NULL, /* pChord */ + PSDRV_Chord, /* pChord */ PSDRV_CreateDC, /* pCreateDC */ PSDRV_DeleteDC, /* pDeleteDC */ NULL, /* pDeleteObject */ @@ -33,7 +33,7 @@ static const DC_FUNCTIONS PSDRV_Funcs = NULL, /* pExcludeVisRect */ NULL, /* pExtFloodFill */ PSDRV_ExtTextOut, /* pExtTextOut */ - NULL, /* pGetCharWidth */ + PSDRV_GetCharWidth, /* pGetCharWidth */ NULL, /* pGetPixel */ PSDRV_GetTextExtentPoint, /* pGetTextExtentPoint */ PSDRV_GetTextMetrics, /* pGetTextMetrics */ @@ -46,16 +46,16 @@ static const DC_FUNCTIONS PSDRV_Funcs = NULL, /* pOffsetWindowOrg (optional) */ NULL, /* pPaintRgn */ NULL, /* pPatBlt */ - NULL, /* pPie */ - NULL, /* pPolyPolygon */ - NULL, /* pPolyPolyline */ + PSDRV_Pie, /* pPie */ + PSDRV_PolyPolygon, /* pPolyPolygon */ + PSDRV_PolyPolyline, /* pPolyPolyline */ PSDRV_Polygon, /* pPolygon */ PSDRV_Polyline, /* pPolyline */ NULL, /* pPolyBezier */ NULL, /* pRealizePalette */ PSDRV_Rectangle, /* pRectangle */ NULL, /* pRestoreDC */ - NULL, /* pRoundRect */ + PSDRV_RoundRect, /* pRoundRect */ NULL, /* pSaveDC */ NULL, /* pScaleViewportExt (optional) */ NULL, /* pScaleWindowExt (optional) */ @@ -68,7 +68,7 @@ static const DC_FUNCTIONS PSDRV_Funcs = NULL, /* pSetDIBitsToDevice */ NULL, /* pSetMapMode (optional) */ NULL, /* pSetMapperFlags */ - NULL, /* pSetPixel */ + PSDRV_SetPixel, /* pSetPixel */ NULL, /* pSetPolyFillMode */ NULL, /* pSetROP2 */ NULL, /* pSetRelAbs */ @@ -82,7 +82,7 @@ static const DC_FUNCTIONS PSDRV_Funcs = NULL, /* pSetWindowExt (optional) */ NULL, /* pSetWindowOrg (optional) */ NULL, /* pStretchBlt */ - NULL /* pStretchDIBits */ + PSDRV_StretchDIBits /* pStretchDIBits */ }; diff --git a/graphics/psdrv/ps.c b/graphics/psdrv/ps.c index d301c36082b..b972d682b27 100644 --- a/graphics/psdrv/ps.c +++ b/graphics/psdrv/ps.c @@ -35,15 +35,24 @@ static char psvectorend[] = static char psprolog[] = /* output ANSIEncoding vector first */ "/reencodefont {\n" -"findfont\n" -"dup length dict begin\n" -"{1 index /FID ne {def} {pop pop} ifelse} forall\n" -"/Encoding ANSIEncoding def\n" -"currentdict\n" -"end\n" -"definefont pop\n" +" findfont\n" +" dup length dict begin\n" +" {1 index /FID ne {def} {pop pop} ifelse} forall\n" +" /Encoding ANSIEncoding def\n" +" currentdict\n" +" end\n" +" definefont pop\n" "} bind def\n" -"/tmpmtrx matrix def\n"; +"/tmpmtrx matrix def\n" +"/hatch {\n" +" pathbbox\n" +" /b exch def /r exch def /t exch def /l exch def /gap 32 def\n" +" l cvi gap idiv gap mul\n" +" gap\n" +" r cvi gap idiv gap mul\n" +" {t moveto 0 b t sub rlineto}\n" +" for\n" +"} bind def\n"; static char psbeginsetup[] = "%%BeginSetup\n"; @@ -116,11 +125,11 @@ static char pssetgray[] = /* gray */ static char pssetrgbcolor[] = /* r, g, b */ "%.2f %.2f %.2f setrgbcolor\n"; -static char psellipse[] = /* x, y, a, b */ +static char psarc[] = /* x, y, w, h, ang1, ang2 */ "tmpmtrx currentmatrix pop\n" "%d %d translate\n" "%d %d scale\n" -"0 0 1 0 360 arc\n" +"0 0 0.5 %.1f %.1f arc\n" "tmpmtrx setmatrix\n"; static char psgsave[] = @@ -132,6 +141,24 @@ static char psgrestore[] = static char psfill[] = "fill\n"; +static char pseofill[] = +"eofill\n"; + +static char psclosepath[] = +"closepath\n"; + +static char psclip[] = +"clip\n"; + +static char pseoclip[] = +"eoclip\n"; + +static char pshatch[] = +"hatch\n"; + +static char psrotate[] = /* ang */ +"%.1f rotate\n"; + char *PSDRV_ANSIVector[256] = { NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, @@ -454,11 +481,14 @@ BOOL32 PSDRV_WriteRectangle(DC *dc, INT32 x, INT32 y, INT32 width, return PSDRV_WriteSpool(dc, buf, strlen(buf)); } -BOOL32 PSDRV_WriteEllispe(DC *dc, INT32 x, INT32 y, INT32 a, INT32 b) +BOOL32 PSDRV_WriteArc(DC *dc, INT32 x, INT32 y, INT32 w, INT32 h, double ang1, + double ang2) { char buf[256]; - sprintf(buf, psellipse, x, y, a, b); + /* Make angles -ve and swap order because we're working with an upside + down y-axis */ + sprintf(buf, psarc, x, y, w, h, -ang2, -ang1); return PSDRV_WriteSpool(dc, buf, strlen(buf)); } @@ -618,17 +648,47 @@ BOOL32 PSDRV_WriteFill(DC *dc) return PSDRV_WriteSpool(dc, psfill, sizeof(psfill)-1); } -BOOL32 PSDRV_Writegsave(DC *dc) +BOOL32 PSDRV_WriteEOFill(DC *dc) +{ + return PSDRV_WriteSpool(dc, pseofill, sizeof(pseofill)-1); +} + +BOOL32 PSDRV_WriteGSave(DC *dc) { return PSDRV_WriteSpool(dc, psgsave, sizeof(psgsave)-1); } -BOOL32 PSDRV_Writegrestore(DC *dc) +BOOL32 PSDRV_WriteGRestore(DC *dc) { return PSDRV_WriteSpool(dc, psgrestore, sizeof(psgrestore)-1); } - - +BOOL32 PSDRV_WriteClosePath(DC *dc) +{ + return PSDRV_WriteSpool(dc, psclosepath, sizeof(psclosepath)-1); +} + +BOOL32 PSDRV_WriteClip(DC *dc) +{ + return PSDRV_WriteSpool(dc, psclip, sizeof(psclip)-1); +} + +BOOL32 PSDRV_WriteEOClip(DC *dc) +{ + return PSDRV_WriteSpool(dc, pseoclip, sizeof(pseoclip)-1); +} + +BOOL32 PSDRV_WriteHatch(DC *dc) +{ + return PSDRV_WriteSpool(dc, pshatch, sizeof(pshatch)-1); +} + +BOOL32 PSDRV_WriteRotate(DC *dc, float ang) +{ + char buf[256]; + + sprintf(buf, psrotate, ang); + return PSDRV_WriteSpool(dc, buf, strlen(buf)); +} diff --git a/include/gdi.h b/include/gdi.h index 09e1a83a75e..21f0f062747 100644 --- a/include/gdi.h +++ b/include/gdi.h @@ -233,7 +233,7 @@ typedef struct tagDC_FUNCS BOOL32 (*pSetWindowExt)(DC*,INT32,INT32); BOOL32 (*pSetWindowOrg)(DC*,INT32,INT32); BOOL32 (*pStretchBlt)(DC*,INT32,INT32,INT32,INT32,DC*,INT32,INT32,INT32,INT32,DWORD); - INT32 (*pStretchDIBits)(DC*,INT32,INT32,INT32,INT32,INT32,INT32,INT32,INT32,LPSTR,LPBITMAPINFO,WORD,DWORD); + INT32 (*pStretchDIBits)(DC*,INT32,INT32,INT32,INT32,INT32,INT32,INT32,INT32,const void *,const BITMAPINFO *,UINT32,DWORD); } DC_FUNCTIONS; /* DC hook codes */ diff --git a/include/psdrv.h b/include/psdrv.h index f3ee787b7ae..b32e3e228fa 100644 --- a/include/psdrv.h +++ b/include/psdrv.h @@ -197,7 +197,6 @@ typedef struct { typedef struct { PSCOLOR color; - UINT32 style; BOOL32 set; } PSBRUSH; @@ -245,7 +244,7 @@ extern HPEN32 PSDRV_PEN_SelectObject( DC * dc, HPEN32 hpen, PENOBJ * pen ); extern HBRUSH32 PSDRV_BRUSH_SelectObject( DC * dc, HBRUSH32 hbrush, BRUSHOBJ * brush ); -extern BOOL32 PSDRV_SetBrush(DC *dc); +extern BOOL32 PSDRV_Brush(DC *dc, BOOL32 EO); extern BOOL32 PSDRV_SetFont( DC *dc ); extern BOOL32 PSDRV_SetPen( DC *dc ); @@ -268,39 +267,69 @@ extern BOOL32 PSDRV_WriteSetFont(DC *dc, BOOL32 UseANSI); extern BOOL32 PSDRV_WriteShow(DC *dc, char *str, INT32 count); extern BOOL32 PSDRV_WriteReencodeFont(DC *dc); extern BOOL32 PSDRV_WriteSetPen(DC *dc); -extern BOOL32 PSDRV_WriteEllispe(DC *dc, INT32 x, INT32 y, INT32 a, INT32 b); +extern BOOL32 PSDRV_WriteArc(DC *dc, INT32 x, INT32 y, INT32 w, INT32 h, + double ang1, double ang2); extern BOOL32 PSDRV_WriteSetColor(DC *dc, PSCOLOR *color); extern BOOL32 PSDRV_WriteSetBrush(DC *dc); extern BOOL32 PSDRV_WriteFill(DC *dc); -extern BOOL32 PSDRV_Writegsave(DC *dc); -extern BOOL32 PSDRV_Writegrestore(DC *dc); +extern BOOL32 PSDRV_WriteEOFill(DC *dc); +extern BOOL32 PSDRV_WriteGSave(DC *dc); +extern BOOL32 PSDRV_WriteGRestore(DC *dc); +extern BOOL32 PSDRV_WriteClosePath(DC *dc); +extern BOOL32 PSDRV_WriteClip(DC *dc); +extern BOOL32 PSDRV_WriteEOClip(DC *dc); +extern BOOL32 PSDRV_WriteHatch(DC *dc); +extern BOOL32 PSDRV_WriteRotate(DC *dc, float ang); - -extern BOOL32 PSDRV_Ellipse(DC *dc, INT32 left, INT32 top, INT32 right, - INT32 bottom); +extern BOOL32 PSDRV_Arc( DC *dc, INT32 left, INT32 top, INT32 right, + INT32 bottom, INT32 xstart, INT32 ystart, + INT32 xend, INT32 yend ); +extern BOOL32 PSDRV_Chord( DC *dc, INT32 left, INT32 top, INT32 right, + INT32 bottom, INT32 xstart, INT32 ystart, + INT32 xend, INT32 yend ); +extern BOOL32 PSDRV_Ellipse( DC *dc, INT32 left, INT32 top, INT32 right, + INT32 bottom ); extern BOOL32 PSDRV_EnumDeviceFonts( DC* dc, LPLOGFONT16 plf, - DEVICEFONTENUMPROC proc, LPARAM lp ); + DEVICEFONTENUMPROC proc, LPARAM lp ); extern INT32 PSDRV_Escape( DC *dc, INT32 nEscape, INT32 cbInput, - SEGPTR lpInData, SEGPTR lpOutData ); + SEGPTR lpInData, SEGPTR lpOutData ); extern BOOL32 PSDRV_ExtTextOut( DC *dc, INT32 x, INT32 y, UINT32 flags, - const RECT32 *lprect, LPCSTR str, UINT32 count, - const INT32 *lpDx ); + const RECT32 *lprect, LPCSTR str, UINT32 count, + const INT32 *lpDx ); +extern BOOL32 PSDRV_GetCharWidth( DC *dc, UINT32 firstChar, UINT32 lastChar, + LPINT32 buffer ); extern BOOL32 PSDRV_GetTextExtentPoint( DC *dc, LPCSTR str, INT32 count, - LPSIZE32 size ); + LPSIZE32 size ); extern BOOL32 PSDRV_GetTextMetrics( DC *dc, TEXTMETRIC32A *metrics ); extern BOOL32 PSDRV_LineTo( DC *dc, INT32 x, INT32 y ); extern BOOL32 PSDRV_MoveToEx( DC *dc, INT32 x, INT32 y, LPPOINT32 pt ); +extern BOOL32 PSDRV_Pie( DC *dc, INT32 left, INT32 top, INT32 right, + INT32 bottom, INT32 xstart, INT32 ystart, + INT32 xend, INT32 yend ); extern BOOL32 PSDRV_Polygon( DC *dc, LPPOINT32 pt, INT32 count ); extern BOOL32 PSDRV_Polyline( DC *dc, const LPPOINT32 pt, INT32 count ); -extern BOOL32 PSDRV_Rectangle(DC *dc, INT32 left, INT32 top, INT32 right, - INT32 bottom); +extern BOOL32 PSDRV_PolyPolygon( DC *dc, LPPOINT32 pts, LPINT32 counts, + UINT32 polygons ); +extern BOOL32 PSDRV_PolyPolyline( DC *dc, LPPOINT32 pts, LPDWORD counts, + DWORD polylines ); +extern BOOL32 PSDRV_Rectangle( DC *dc, INT32 left, INT32 top, INT32 right, + INT32 bottom ); +extern BOOL32 PSDRV_RoundRect(DC *dc, INT32 left, INT32 top, INT32 right, + INT32 bottom, INT32 ell_width, INT32 ell_height); extern HGDIOBJ32 PSDRV_SelectObject( DC *dc, HGDIOBJ32 handle ); extern COLORREF PSDRV_SetBkColor( DC *dc, COLORREF color ); +extern COLORREF PSDRV_SetPixel( DC *dc, INT32 x, INT32 y, COLORREF color ); extern COLORREF PSDRV_SetTextColor( DC *dc, COLORREF color ); +extern INT32 PSDRV_StretchDIBits( DC *dc, INT32 xDst, INT32 yDst, + INT32 widthDst, INT32 heightDst, INT32 xSrc, + INT32 ySrc, INT32 widthSrc, INT32 heightSrc, + const void *bits, const BITMAPINFO *info, + UINT32 wUsage, DWORD dwRop ); + diff --git a/objects/dib.c b/objects/dib.c index a19f841534c..72cea4defcd 100644 --- a/objects/dib.c +++ b/objects/dib.c @@ -1178,19 +1178,29 @@ INT32 WINAPI StretchDIBits32(HDC32 hdc, INT32 xDst, INT32 yDst, INT32 widthDst, INT32 heightSrc, const void *bits, const BITMAPINFO *info, UINT32 wUsage, DWORD dwRop ) { - HBITMAP32 hBitmap, hOldBitmap; - HDC32 hdcMem; + DC *dc = DC_GetDCPtr( hdc ); + if(!dc) return FALSE; - hBitmap = CreateDIBitmap32( hdc, &info->bmiHeader, CBM_INIT, - bits, info, wUsage ); - hdcMem = CreateCompatibleDC32( hdc ); - hOldBitmap = SelectObject32( hdcMem, hBitmap ); - StretchBlt32( hdc, xDst, yDst, widthDst, heightDst, - hdcMem, xSrc, ySrc, widthSrc, heightSrc, dwRop ); - SelectObject32( hdcMem, hOldBitmap ); - DeleteDC32( hdcMem ); - DeleteObject32( hBitmap ); - return heightSrc; + if(dc->funcs->pStretchDIBits) + return dc->funcs->pStretchDIBits(dc, xDst, yDst, widthDst, + heightDst, xSrc, ySrc, widthSrc, + heightSrc, bits, info, wUsage, + dwRop); + else { /* use StretchBlt32 */ + HBITMAP32 hBitmap, hOldBitmap; + HDC32 hdcMem; + + hBitmap = CreateDIBitmap32( hdc, &info->bmiHeader, CBM_INIT, + bits, info, wUsage ); + hdcMem = CreateCompatibleDC32( hdc ); + hOldBitmap = SelectObject32( hdcMem, hBitmap ); + StretchBlt32( hdc, xDst, yDst, widthDst, heightDst, + hdcMem, xSrc, ySrc, widthSrc, heightSrc, dwRop ); + SelectObject32( hdcMem, hOldBitmap ); + DeleteDC32( hdcMem ); + DeleteObject32( hBitmap ); + return heightSrc; + } }