Commit b0c843eb authored by Piotr Caban's avatar Piotr Caban Committed by Alexandre Julliard

wineps: Rename PSDRV_PDEVICE structure to print_ctx.

parent c1a12304
......@@ -28,18 +28,18 @@ WINE_DEFAULT_DEBUG_CHANNEL(psdrv);
*
* PSDRV_PatBlt
*/
BOOL CDECL PSDRV_PatBlt(PHYSDEV dev, struct bitblt_coords *dst, DWORD dwRop)
BOOL CDECL PSDRV_PatBlt(print_ctx *ctx, struct bitblt_coords *dst, DWORD dwRop)
{
switch(dwRop) {
case PATCOPY:
PSDRV_SetClip(dev);
PSDRV_WriteGSave(dev);
PSDRV_WriteRectangle(dev, dst->visrect.left, dst->visrect.top,
PSDRV_SetClip(ctx);
PSDRV_WriteGSave(ctx);
PSDRV_WriteRectangle(ctx, dst->visrect.left, dst->visrect.top,
dst->visrect.right - dst->visrect.left,
dst->visrect.bottom - dst->visrect.top );
PSDRV_Brush(dev, FALSE);
PSDRV_WriteGRestore(dev);
PSDRV_ResetClip(dev);
PSDRV_Brush(ctx, FALSE);
PSDRV_WriteGRestore(ctx);
PSDRV_ResetClip(ctx);
return TRUE;
case BLACKNESS:
......@@ -47,16 +47,16 @@ BOOL CDECL PSDRV_PatBlt(PHYSDEV dev, struct bitblt_coords *dst, DWORD dwRop)
{
PSCOLOR pscol;
PSDRV_SetClip(dev);
PSDRV_WriteGSave(dev);
PSDRV_WriteRectangle(dev, dst->visrect.left, dst->visrect.top,
PSDRV_SetClip(ctx);
PSDRV_WriteGSave(ctx);
PSDRV_WriteRectangle(ctx, dst->visrect.left, dst->visrect.top,
dst->visrect.right - dst->visrect.left,
dst->visrect.bottom - dst->visrect.top );
PSDRV_CreateColor( dev, &pscol, (dwRop == BLACKNESS) ? RGB(0,0,0) : RGB(0xff,0xff,0xff) );
PSDRV_WriteSetColor(dev, &pscol);
PSDRV_WriteFill(dev);
PSDRV_WriteGRestore(dev);
PSDRV_ResetClip(dev);
PSDRV_CreateColor( ctx, &pscol, (dwRop == BLACKNESS) ? RGB(0,0,0) : RGB(0xff,0xff,0xff) );
PSDRV_WriteSetColor(ctx, &pscol);
PSDRV_WriteFill(ctx);
PSDRV_WriteGRestore(ctx);
PSDRV_ResetClip(ctx);
return TRUE;
}
default:
......
......@@ -44,7 +44,7 @@ static inline int get_dib_width_bytes( int width, int depth )
* Uses level 2 PostScript
*/
static BOOL PSDRV_WriteImageHeader(PHYSDEV dev, const BITMAPINFO *info, BOOL grayscale, INT xDst,
static BOOL PSDRV_WriteImageHeader(print_ctx *ctx, const BITMAPINFO *info, BOOL grayscale, INT xDst,
INT yDst, INT widthDst, INT heightDst,
INT widthSrc, INT heightSrc)
{
......@@ -53,9 +53,9 @@ static BOOL PSDRV_WriteImageHeader(PHYSDEV dev, const BITMAPINFO *info, BOOL gra
case 1:
case 4:
case 8:
PSDRV_WriteIndexColorSpaceBegin(dev, (1 << info->bmiHeader.biBitCount) - 1);
PSDRV_WriteRGBQUAD(dev, info->bmiColors, 1 << info->bmiHeader.biBitCount);
PSDRV_WriteIndexColorSpaceEnd(dev);
PSDRV_WriteIndexColorSpaceBegin(ctx, (1 << info->bmiHeader.biBitCount) - 1);
PSDRV_WriteRGBQUAD(ctx, info->bmiColors, 1 << info->bmiHeader.biBitCount);
PSDRV_WriteIndexColorSpaceEnd(ctx);
break;
case 16:
......@@ -73,12 +73,12 @@ static BOOL PSDRV_WriteImageHeader(PHYSDEV dev, const BITMAPINFO *info, BOOL gra
pscol.type = PSCOLOR_RGB;
pscol.value.rgb.r = pscol.value.rgb.g = pscol.value.rgb.b = 0.0;
}
PSDRV_WriteSetColor(dev, &pscol);
PSDRV_WriteSetColor(ctx, &pscol);
break;
}
}
PSDRV_WriteImage(dev, info->bmiHeader.biBitCount, grayscale, xDst, yDst,
PSDRV_WriteImage(ctx, info->bmiHeader.biBitCount, grayscale, xDst, yDst,
widthDst, heightDst, widthSrc, heightSrc, FALSE, info->bmiHeader.biHeight < 0);
return TRUE;
}
......@@ -96,12 +96,11 @@ static BOOL PSDRV_WriteImageHeader(PHYSDEV dev, const BITMAPINFO *info, BOOL gra
* Uses level 2 PostScript
*/
static BOOL PSDRV_WriteImageMaskHeader(PHYSDEV dev, const BITMAPINFO *info, INT xDst,
static BOOL PSDRV_WriteImageMaskHeader(print_ctx *ctx, const BITMAPINFO *info, INT xDst,
INT yDst, INT widthDst, INT heightDst,
INT widthSrc, INT heightSrc)
{
PSCOLOR bkgnd, foregnd;
PSDRV_PDEVICE *physDev = get_psdrv_dev( dev );
assert(info->bmiHeader.biBitCount == 1);
......@@ -111,28 +110,28 @@ static BOOL PSDRV_WriteImageMaskHeader(PHYSDEV dev, const BITMAPINFO *info, INT
*/
if (!info->bmiHeader.biClrUsed)
{
PSDRV_CreateColor( dev, &foregnd, GetTextColor( dev->hdc ) );
bkgnd = physDev->bkColor;
PSDRV_CreateColor( ctx, &foregnd, GetTextColor( ctx->dev.hdc ) );
bkgnd = ctx->bkColor;
}
else
{
PSDRV_CreateColor( dev, &foregnd, RGB(info->bmiColors[0].rgbRed,
PSDRV_CreateColor( ctx, &foregnd, RGB(info->bmiColors[0].rgbRed,
info->bmiColors[0].rgbGreen,
info->bmiColors[0].rgbBlue) );
PSDRV_CreateColor( dev, &bkgnd, RGB(info->bmiColors[1].rgbRed,
PSDRV_CreateColor( ctx, &bkgnd, RGB(info->bmiColors[1].rgbRed,
info->bmiColors[1].rgbGreen,
info->bmiColors[1].rgbBlue) );
}
PSDRV_WriteGSave(dev);
PSDRV_WriteNewPath(dev);
PSDRV_WriteRectangle(dev, xDst, yDst, widthDst, heightDst);
PSDRV_WriteSetColor(dev, &bkgnd);
PSDRV_WriteFill(dev);
PSDRV_WriteGRestore(dev);
PSDRV_WriteGSave(ctx);
PSDRV_WriteNewPath(ctx);
PSDRV_WriteRectangle(ctx, xDst, yDst, widthDst, heightDst);
PSDRV_WriteSetColor(ctx, &bkgnd);
PSDRV_WriteFill(ctx);
PSDRV_WriteGRestore(ctx);
PSDRV_WriteSetColor(dev, &foregnd);
PSDRV_WriteImage(dev, 1, FALSE, xDst, yDst, widthDst, heightDst,
PSDRV_WriteSetColor(ctx, &foregnd);
PSDRV_WriteImage(ctx, 1, FALSE, xDst, yDst, widthDst, heightDst,
widthSrc, heightSrc, TRUE, info->bmiHeader.biHeight < 0);
return TRUE;
......@@ -156,7 +155,7 @@ static void CDECL free_heap_bits( struct gdi_image_bits *bits )
/***************************************************************************
* PSDRV_WriteImageBits
*/
static void PSDRV_WriteImageBits( PHYSDEV dev, const BITMAPINFO *info, BOOL grayscale, INT xDst, INT yDst,
static void PSDRV_WriteImageBits( print_ctx *ctx, const BITMAPINFO *info, BOOL grayscale, INT xDst, INT yDst,
INT widthDst, INT heightDst, INT widthSrc, INT heightSrc,
void *bits, DWORD size )
{
......@@ -165,10 +164,10 @@ static void PSDRV_WriteImageBits( PHYSDEV dev, const BITMAPINFO *info, BOOL gray
if (info->bmiHeader.biBitCount == 1)
/* Use imagemask rather than image */
PSDRV_WriteImageMaskHeader(dev, info, xDst, yDst, widthDst, heightDst,
PSDRV_WriteImageMaskHeader(ctx, info, xDst, yDst, widthDst, heightDst,
widthSrc, heightSrc);
else
PSDRV_WriteImageHeader(dev, info, grayscale, xDst, yDst, widthDst, heightDst,
PSDRV_WriteImageHeader(ctx, info, grayscale, xDst, yDst, widthDst, heightDst,
widthSrc, heightSrc);
rle = HeapAlloc(GetProcessHeap(), 0, max_rle_size(size));
......@@ -176,15 +175,15 @@ static void PSDRV_WriteImageBits( PHYSDEV dev, const BITMAPINFO *info, BOOL gray
ascii85 = HeapAlloc(GetProcessHeap(), 0, max_ascii85_size(rle_len));
ascii85_len = ASCII85_encode(rle, rle_len, ascii85);
HeapFree(GetProcessHeap(), 0, rle);
PSDRV_WriteData(dev, ascii85, ascii85_len);
PSDRV_WriteSpool(dev, "~>\n", 3);
PSDRV_WriteData(ctx, ascii85, ascii85_len);
PSDRV_WriteSpool(ctx, "~>\n", 3);
HeapFree(GetProcessHeap(), 0, ascii85);
}
/***********************************************************************
* PSDRV_PutImage
*/
DWORD CDECL PSDRV_PutImage( PHYSDEV dev, HRGN clip, BITMAPINFO *info,
DWORD CDECL PSDRV_PutImage( print_ctx *ctx, HRGN clip, BITMAPINFO *info,
const struct gdi_image_bits *bits, struct bitblt_coords *src,
struct bitblt_coords *dst, DWORD rop )
{
......@@ -192,8 +191,7 @@ DWORD CDECL PSDRV_PutImage( PHYSDEV dev, HRGN clip, BITMAPINFO *info,
int dst_x, dst_y, dst_width, dst_height;
unsigned char *src_ptr, *dst_ptr;
struct gdi_image_bits dst_bits;
PSDRV_PDEVICE *physDev = get_psdrv_dev( dev );
BOOL grayscale = info->bmiHeader.biBitCount == 24 && physDev->pi->ppd->ColorDevice == CD_False;
BOOL grayscale = info->bmiHeader.biBitCount == 24 && ctx->pi->ppd->ColorDevice == CD_False;
if (info->bmiHeader.biPlanes != 1) goto update_format;
if (info->bmiHeader.biCompression != BI_RGB) goto update_format;
......@@ -286,13 +284,13 @@ DWORD CDECL PSDRV_PutImage( PHYSDEV dev, HRGN clip, BITMAPINFO *info,
dst_height = -dst_height;
}
PSDRV_SetClip(dev);
PSDRV_WriteGSave(dev);
if (clip) PSDRV_AddClip( dev, clip );
PSDRV_WriteImageBits( dev, info, grayscale, dst_x, dst_y, dst_width, dst_height,
PSDRV_SetClip(ctx);
PSDRV_WriteGSave(ctx);
if (clip) PSDRV_AddClip( ctx, clip );
PSDRV_WriteImageBits( ctx, info, grayscale, dst_x, dst_y, dst_width, dst_height,
width, height, dst_bits.ptr, size );
PSDRV_WriteGRestore(dev);
PSDRV_ResetClip(dev);
PSDRV_WriteGRestore(ctx);
PSDRV_ResetClip(ctx);
if (dst_bits.free) dst_bits.free( &dst_bits );
return ERROR_SUCCESS;
......
......@@ -27,9 +27,8 @@ WINE_DEFAULT_DEBUG_CHANNEL(psdrv);
/***********************************************************************
* SelectBrush (WINEPS.@)
*/
HBRUSH CDECL PSDRV_SelectBrush( PHYSDEV dev, HBRUSH hbrush, const struct brush_pattern *pattern )
HBRUSH CDECL PSDRV_SelectBrush( print_ctx *ctx, HBRUSH hbrush, const struct brush_pattern *pattern )
{
PSDRV_PDEVICE *physDev = get_psdrv_dev( dev );
LOGBRUSH logbrush;
if (!GetObjectA( hbrush, sizeof(logbrush), &logbrush )) return 0;
......@@ -37,24 +36,24 @@ HBRUSH CDECL PSDRV_SelectBrush( PHYSDEV dev, HBRUSH hbrush, const struct brush_p
TRACE("hbrush = %p\n", hbrush);
if (hbrush == GetStockObject( DC_BRUSH ))
logbrush.lbColor = GetDCBrushColor( dev->hdc );
logbrush.lbColor = GetDCBrushColor( ctx->dev.hdc );
switch(logbrush.lbStyle) {
case BS_SOLID:
PSDRV_CreateColor(dev, &physDev->brush.color, logbrush.lbColor);
PSDRV_CreateColor(ctx, &ctx->brush.color, logbrush.lbColor);
break;
case BS_NULL:
break;
case BS_HATCHED:
PSDRV_CreateColor(dev, &physDev->brush.color, logbrush.lbColor);
PSDRV_CreateColor(ctx, &ctx->brush.color, logbrush.lbColor);
break;
case BS_PATTERN:
case BS_DIBPATTERN:
physDev->brush.pattern = *pattern;
ctx->brush.pattern = *pattern;
break;
default:
......@@ -62,7 +61,7 @@ HBRUSH CDECL PSDRV_SelectBrush( PHYSDEV dev, HBRUSH hbrush, const struct brush_p
break;
}
physDev->brush.set = FALSE;
ctx->brush.set = FALSE;
return hbrush;
}
......@@ -70,14 +69,12 @@ HBRUSH CDECL PSDRV_SelectBrush( PHYSDEV dev, HBRUSH hbrush, const struct brush_p
/***********************************************************************
* SetDCBrushColor (WINEPS.@)
*/
COLORREF CDECL PSDRV_SetDCBrushColor( PHYSDEV dev, COLORREF color )
COLORREF CDECL PSDRV_SetDCBrushColor( print_ctx *ctx, COLORREF color )
{
PSDRV_PDEVICE *physDev = get_psdrv_dev( dev );
if (GetCurrentObject( dev->hdc, OBJ_BRUSH ) == GetStockObject( DC_BRUSH ))
if (GetCurrentObject( ctx->dev.hdc, OBJ_BRUSH ) == GetStockObject( DC_BRUSH ))
{
PSDRV_CreateColor( dev, &physDev->brush.color, color );
physDev->brush.set = FALSE;
PSDRV_CreateColor( ctx, &ctx->brush.color, color );
ctx->brush.set = FALSE;
}
return color;
}
......@@ -88,13 +85,12 @@ COLORREF CDECL PSDRV_SetDCBrushColor( PHYSDEV dev, COLORREF color )
* PSDRV_SetBrush
*
*/
static BOOL PSDRV_SetBrush( PHYSDEV dev )
static BOOL PSDRV_SetBrush( print_ctx *ctx )
{
PSDRV_PDEVICE *physDev = get_psdrv_dev( dev );
LOGBRUSH logbrush;
BOOL ret = TRUE;
if (!GetObjectA( GetCurrentObject(dev->hdc,OBJ_BRUSH), sizeof(logbrush), &logbrush ))
if (!GetObjectA( GetCurrentObject(ctx->dev.hdc,OBJ_BRUSH), sizeof(logbrush), &logbrush ))
{
ERR("Can't get BRUSHOBJ\n");
return FALSE;
......@@ -103,7 +99,7 @@ static BOOL PSDRV_SetBrush( PHYSDEV dev )
switch (logbrush.lbStyle) {
case BS_SOLID:
case BS_HATCHED:
PSDRV_WriteSetColor(dev, &physDev->brush.color);
PSDRV_WriteSetColor(ctx, &ctx->brush.color);
break;
case BS_NULL:
......@@ -114,7 +110,7 @@ static BOOL PSDRV_SetBrush( PHYSDEV dev )
break;
}
physDev->brush.set = TRUE;
ctx->brush.set = TRUE;
return ret;
}
......@@ -124,12 +120,12 @@ static BOOL PSDRV_SetBrush( PHYSDEV dev )
* PSDRV_Fill
*
*/
static BOOL PSDRV_Fill(PHYSDEV dev, BOOL EO)
static BOOL PSDRV_Fill(print_ctx *ctx, BOOL EO)
{
if(!EO)
return PSDRV_WriteFill(dev);
return PSDRV_WriteFill(ctx);
else
return PSDRV_WriteEOFill(dev);
return PSDRV_WriteEOFill(ctx);
}
......@@ -138,12 +134,12 @@ static BOOL PSDRV_Fill(PHYSDEV dev, BOOL EO)
* PSDRV_Clip
*
*/
static BOOL PSDRV_Clip(PHYSDEV dev, BOOL EO)
static BOOL PSDRV_Clip(print_ctx *ctx, BOOL EO)
{
if(!EO)
return PSDRV_WriteClip(dev);
return PSDRV_WriteClip(ctx);
else
return PSDRV_WriteEOClip(dev);
return PSDRV_WriteEOClip(ctx);
}
/**********************************************************************
......@@ -151,16 +147,15 @@ static BOOL PSDRV_Clip(PHYSDEV dev, BOOL EO)
* PSDRV_Brush
*
*/
BOOL PSDRV_Brush(PHYSDEV dev, BOOL EO)
BOOL PSDRV_Brush(print_ctx *ctx, BOOL EO)
{
PSDRV_PDEVICE *physDev = get_psdrv_dev( dev );
LOGBRUSH logbrush;
BOOL ret = TRUE;
if(physDev->pathdepth)
if(ctx->pathdepth)
return FALSE;
if (!GetObjectA( GetCurrentObject(dev->hdc,OBJ_BRUSH), sizeof(logbrush), &logbrush ))
if (!GetObjectA( GetCurrentObject(ctx->dev.hdc,OBJ_BRUSH), sizeof(logbrush), &logbrush ))
{
ERR("Can't get BRUSHOBJ\n");
return FALSE;
......@@ -168,56 +163,56 @@ BOOL PSDRV_Brush(PHYSDEV dev, BOOL EO)
switch (logbrush.lbStyle) {
case BS_SOLID:
PSDRV_WriteGSave(dev);
PSDRV_SetBrush(dev);
PSDRV_Fill(dev, EO);
PSDRV_WriteGRestore(dev);
PSDRV_WriteGSave(ctx);
PSDRV_SetBrush(ctx);
PSDRV_Fill(ctx, EO);
PSDRV_WriteGRestore(ctx);
break;
case BS_HATCHED:
PSDRV_WriteGSave(dev);
PSDRV_SetBrush(dev);
PSDRV_WriteGSave(ctx);
PSDRV_SetBrush(ctx);
switch(logbrush.lbHatch) {
case HS_VERTICAL:
case HS_CROSS:
PSDRV_WriteGSave(dev);
PSDRV_Clip(dev, EO);
PSDRV_WriteHatch(dev);
PSDRV_WriteStroke(dev);
PSDRV_WriteGRestore(dev);
PSDRV_WriteGSave(ctx);
PSDRV_Clip(ctx, EO);
PSDRV_WriteHatch(ctx);
PSDRV_WriteStroke(ctx);
PSDRV_WriteGRestore(ctx);
if(logbrush.lbHatch == HS_VERTICAL)
break;
/* else fallthrough for HS_CROSS */
case HS_HORIZONTAL:
PSDRV_WriteGSave(dev);
PSDRV_Clip(dev, EO);
PSDRV_WriteRotate(dev, 90.0);
PSDRV_WriteHatch(dev);
PSDRV_WriteStroke(dev);
PSDRV_WriteGRestore(dev);
PSDRV_WriteGSave(ctx);
PSDRV_Clip(ctx, EO);
PSDRV_WriteRotate(ctx, 90.0);
PSDRV_WriteHatch(ctx);
PSDRV_WriteStroke(ctx);
PSDRV_WriteGRestore(ctx);
break;
case HS_FDIAGONAL:
case HS_DIAGCROSS:
PSDRV_WriteGSave(dev);
PSDRV_Clip(dev, EO);
PSDRV_WriteRotate(dev, -45.0);
PSDRV_WriteHatch(dev);
PSDRV_WriteStroke(dev);
PSDRV_WriteGRestore(dev);
PSDRV_WriteGSave(ctx);
PSDRV_Clip(ctx, EO);
PSDRV_WriteRotate(ctx, -45.0);
PSDRV_WriteHatch(ctx);
PSDRV_WriteStroke(ctx);
PSDRV_WriteGRestore(ctx);
if(logbrush.lbHatch == HS_FDIAGONAL)
break;
/* else fallthrough for HS_DIAGCROSS */
case HS_BDIAGONAL:
PSDRV_WriteGSave(dev);
PSDRV_Clip(dev, EO);
PSDRV_WriteRotate(dev, 45.0);
PSDRV_WriteHatch(dev);
PSDRV_WriteStroke(dev);
PSDRV_WriteGRestore(dev);
PSDRV_WriteGSave(ctx);
PSDRV_Clip(ctx, EO);
PSDRV_WriteRotate(ctx, 45.0);
PSDRV_WriteHatch(ctx);
PSDRV_WriteStroke(ctx);
PSDRV_WriteGRestore(ctx);
break;
default:
......@@ -225,7 +220,7 @@ BOOL PSDRV_Brush(PHYSDEV dev, BOOL EO)
ret = FALSE;
break;
}
PSDRV_WriteGRestore(dev);
PSDRV_WriteGRestore(ctx);
break;
case BS_NULL:
......@@ -233,12 +228,12 @@ BOOL PSDRV_Brush(PHYSDEV dev, BOOL EO)
case BS_PATTERN:
case BS_DIBPATTERN:
if(physDev->pi->ppd->LanguageLevel > 1) {
PSDRV_WriteGSave(dev);
ret = PSDRV_WriteDIBPatternDict(dev, physDev->brush.pattern.info,
physDev->brush.pattern.bits.ptr, physDev->brush.pattern.usage );
PSDRV_Fill(dev, EO);
PSDRV_WriteGRestore(dev);
if(ctx->pi->ppd->LanguageLevel > 1) {
PSDRV_WriteGSave(ctx);
ret = PSDRV_WriteDIBPatternDict(ctx, ctx->brush.pattern.info,
ctx->brush.pattern.bits.ptr, ctx->brush.pattern.usage );
PSDRV_Fill(ctx, EO);
PSDRV_WriteGRestore(ctx);
} else {
FIXME("Trying to set a pattern brush on a level 1 printer\n");
ret = FALSE;
......
......@@ -36,29 +36,29 @@
WINE_DEFAULT_DEBUG_CHANNEL(psdrv);
BOOL PSDRV_WriteSetBuiltinFont(PHYSDEV dev)
BOOL PSDRV_WriteSetBuiltinFont(print_ctx *ctx)
{
struct font_info font_info;
matrix size;
ExtEscape(dev->hdc, PSDRV_GET_BUILTIN_FONT_INFO, 0, NULL,
ExtEscape(ctx->dev.hdc, PSDRV_GET_BUILTIN_FONT_INFO, 0, NULL,
sizeof(font_info), (char *)&font_info);
size.xx = font_info.size.cx;
size.yy = font_info.size.cy;
size.xy = size.yx = 0;
return PSDRV_WriteSetFont(dev, font_info.font_name, size,
return PSDRV_WriteSetFont(ctx, font_info.font_name, size,
font_info.escapement, FALSE);
}
BOOL PSDRV_WriteBuiltinGlyphShow(PHYSDEV dev, LPCWSTR str, INT count)
BOOL PSDRV_WriteBuiltinGlyphShow(print_ctx *ctx, LPCWSTR str, INT count)
{
char name[32];
int i;
for (i = 0; i < count; ++i)
{
ExtEscape(dev->hdc, PSDRV_GET_GLYPH_NAME, sizeof(str[i]), (const char *)&str[i], sizeof(name), name);
PSDRV_WriteGlyphShow(dev, name);
ExtEscape(ctx->dev.hdc, PSDRV_GET_GLYPH_NAME, sizeof(str[i]), (const char *)&str[i], sizeof(name), name);
PSDRV_WriteGlyphShow(ctx, name);
}
return TRUE;
......
......@@ -27,7 +27,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(psdrv);
/***********************************************************************
* PSDRV_AddClip
*/
void PSDRV_AddClip( PHYSDEV dev, HRGN hrgn )
void PSDRV_AddClip( print_ctx *ctx, HRGN hrgn )
{
CHAR szArrayName[] = "clippath";
RECT *rect;
......@@ -43,23 +43,23 @@ void PSDRV_AddClip( PHYSDEV dev, HRGN hrgn )
{
case 0:
/* set an empty clip path. */
PSDRV_WriteRectClip(dev, 0, 0, 0, 0);
PSDRV_WriteRectClip(ctx, 0, 0, 0, 0);
break;
case 1:
/* optimize when it is a simple region */
PSDRV_WriteRectClip(dev, rect->left, rect->top,
PSDRV_WriteRectClip(ctx, rect->left, rect->top,
rect->right - rect->left, rect->bottom - rect->top);
break;
default:
PSDRV_WriteArrayDef(dev, szArrayName, data->rdh.nCount * 4);
PSDRV_WriteArrayDef(ctx, szArrayName, data->rdh.nCount * 4);
for (i = 0; i < data->rdh.nCount; i++, rect++)
{
PSDRV_WriteArrayPut(dev, szArrayName, i * 4, rect->left);
PSDRV_WriteArrayPut(dev, szArrayName, i * 4 + 1, rect->top);
PSDRV_WriteArrayPut(dev, szArrayName, i * 4 + 2, rect->right - rect->left);
PSDRV_WriteArrayPut(dev, szArrayName, i * 4 + 3, rect->bottom - rect->top);
PSDRV_WriteArrayPut(ctx, szArrayName, i * 4, rect->left);
PSDRV_WriteArrayPut(ctx, szArrayName, i * 4 + 1, rect->top);
PSDRV_WriteArrayPut(ctx, szArrayName, i * 4 + 2, rect->right - rect->left);
PSDRV_WriteArrayPut(ctx, szArrayName, i * 4 + 3, rect->bottom - rect->top);
}
PSDRV_WriteRectClip2(dev, szArrayName);
PSDRV_WriteRectClip2(ctx, szArrayName);
break;
}
HeapFree( GetProcessHeap(), 0, data );
......@@ -76,23 +76,22 @@ void PSDRV_AddClip( PHYSDEV dev, HRGN hrgn )
* small clip area in the printer dc that it can still write raw
* PostScript to the driver and expect this code not to be clipped.
*/
void PSDRV_SetClip( PHYSDEV dev )
void PSDRV_SetClip( print_ctx *ctx )
{
PSDRV_PDEVICE *physDev = get_psdrv_dev( dev );
HRGN hrgn;
TRACE("hdc=%p\n", dev->hdc);
TRACE("hdc=%p\n", ctx->dev.hdc);
if(physDev->pathdepth) {
if(ctx->pathdepth) {
TRACE("inside a path, so not clipping\n");
return;
}
hrgn = CreateRectRgn(0, 0, 0, 0);
if (GetRandomRgn(dev->hdc, hrgn, 3) == 1) /* clip && meta */
if (GetRandomRgn(ctx->dev.hdc, hrgn, 3) == 1) /* clip && meta */
{
PSDRV_WriteGSave(dev);
PSDRV_AddClip( dev, hrgn );
PSDRV_WriteGSave(ctx);
PSDRV_AddClip( ctx, hrgn );
}
DeleteObject(hrgn);
}
......@@ -101,15 +100,14 @@ void PSDRV_SetClip( PHYSDEV dev )
/***********************************************************************
* PSDRV_ResetClip
*/
void PSDRV_ResetClip( PHYSDEV dev )
void PSDRV_ResetClip( print_ctx *ctx )
{
PSDRV_PDEVICE *physDev = get_psdrv_dev( dev );
HRGN hrgn;
if (physDev->pathdepth) return;
if (ctx->pathdepth) return;
hrgn = CreateRectRgn(0, 0, 0, 0);
if (GetRandomRgn(dev->hdc, hrgn, 3) == 1) /* clip && meta */
PSDRV_WriteGRestore(dev);
if (GetRandomRgn(ctx->dev.hdc, hrgn, 3) == 1) /* clip && meta */
PSDRV_WriteGRestore(ctx);
DeleteObject(hrgn);
}
......@@ -66,9 +66,8 @@ PSRGB rgb_to_grayscale_scale( void )
* Result is grey scale if ColorDevice field of ppd is CD_False else an
* rgb colour is produced.
*/
void PSDRV_CreateColor( PHYSDEV dev, PSCOLOR *pscolor, COLORREF wincolor )
void PSDRV_CreateColor( print_ctx *ctx, PSCOLOR *pscolor, COLORREF wincolor )
{
PSDRV_PDEVICE *physDev = get_psdrv_dev( dev );
int ctype = wincolor >> 24;
float r, g, b;
......@@ -79,7 +78,7 @@ void PSDRV_CreateColor( PHYSDEV dev, PSCOLOR *pscolor, COLORREF wincolor )
g = ((wincolor >> 8) & 0xff) / 256.0;
b = ((wincolor >> 16) & 0xff) / 256.0;
if(physDev->pi->ppd->ColorDevice != CD_False) {
if(ctx->pi->ppd->ColorDevice != CD_False) {
pscolor->type = PSCOLOR_RGB;
pscolor->value.rgb.r = r;
pscolor->value.rgb.g = g;
......@@ -96,10 +95,9 @@ void PSDRV_CreateColor( PHYSDEV dev, PSCOLOR *pscolor, COLORREF wincolor )
/***********************************************************************
* PSDRV_SetBkColor
*/
COLORREF CDECL PSDRV_SetBkColor( PHYSDEV dev, COLORREF color )
COLORREF CDECL PSDRV_SetBkColor( print_ctx *ctx, COLORREF color )
{
PSDRV_PDEVICE *physDev = get_psdrv_dev( dev );
PSDRV_CreateColor(dev, &physDev->bkColor, color);
PSDRV_CreateColor(ctx, &ctx->bkColor, color);
return color;
}
......@@ -107,10 +105,9 @@ COLORREF CDECL PSDRV_SetBkColor( PHYSDEV dev, COLORREF color )
/***********************************************************************
* PSDRV_SetTextColor
*/
COLORREF CDECL PSDRV_SetTextColor( PHYSDEV dev, COLORREF color )
COLORREF CDECL PSDRV_SetTextColor( print_ctx *ctx, COLORREF color )
{
PSDRV_PDEVICE *physDev = get_psdrv_dev( dev );
PSDRV_CreateColor(dev, &physDev->font.color, color);
physDev->font.set = FALSE;
PSDRV_CreateColor(ctx, &ctx->font.color, color);
ctx->font.set = FALSE;
return color;
}
......@@ -49,7 +49,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(psdrv);
/****************************************************************************
* get_download_name
*/
static void get_download_name(PHYSDEV dev, LPOUTLINETEXTMETRICA potm, char **str, BOOL vertical)
static void get_download_name(print_ctx *ctx, LPOUTLINETEXTMETRICA potm, char **str, BOOL vertical)
{
static const char reserved_chars[] = " %/(){}[]<>\n\r\t\b\f";
static const char vertical_suffix[] = "_vert";
......@@ -57,7 +57,7 @@ static void get_download_name(PHYSDEV dev, LPOUTLINETEXTMETRICA potm, char **str
char *p;
DWORD size;
size = GetFontData(dev->hdc, MS_MAKE_TAG('n','a','m','e'), 0, NULL, 0);
size = GetFontData(ctx->dev.hdc, MS_MAKE_TAG('n','a','m','e'), 0, NULL, 0);
if(size != 0 && size != GDI_ERROR)
{
BYTE *name = HeapAlloc(GetProcessHeap(), 0, size);
......@@ -75,7 +75,7 @@ static void get_download_name(PHYSDEV dev, LPOUTLINETEXTMETRICA potm, char **str
USHORT offset;
} *name_record;
GetFontData(dev->hdc, MS_MAKE_TAG('n','a','m','e'), 0, name, size);
GetFontData(ctx->dev.hdc, MS_MAKE_TAG('n','a','m','e'), 0, name, size);
count = GET_BE_WORD(name + 2);
strings = name + GET_BE_WORD(name + 4);
name_record = (struct name_record *)(name + 6);
......@@ -135,11 +135,11 @@ done:
/****************************************************************************
* is_font_downloaded
*/
static DOWNLOAD *is_font_downloaded(PSDRV_PDEVICE *physDev, char *ps_name)
static DOWNLOAD *is_font_downloaded(print_ctx *ctx, char *ps_name)
{
DOWNLOAD *pdl;
for(pdl = physDev->downloaded_fonts; pdl; pdl = pdl->next)
for(pdl = ctx->downloaded_fonts; pdl; pdl = pdl->next)
if(!strcmp(pdl->ps_name, ps_name))
break;
return pdl;
......@@ -148,14 +148,14 @@ static DOWNLOAD *is_font_downloaded(PSDRV_PDEVICE *physDev, char *ps_name)
/****************************************************************************
* is_room_for_font
*/
static BOOL is_room_for_font(PSDRV_PDEVICE *physDev)
static BOOL is_room_for_font(print_ctx *ctx)
{
DOWNLOAD *pdl;
int count = 0;
/* FIXME: should consider vm usage of each font and available printer memory.
For now we allow up to two fonts to be downloaded at a time */
for(pdl = physDev->downloaded_fonts; pdl; pdl = pdl->next)
for(pdl = ctx->downloaded_fonts; pdl; pdl = pdl->next)
count++;
if(count > 1)
......@@ -193,16 +193,13 @@ static UINT get_bbox(HDC hdc, RECT *rc)
/****************************************************************************
* PSDRV_SelectDownloadFont
*
* Set up physDev->font for a downloadable font
* Set up ctx->font for a downloadable font
*
*/
BOOL PSDRV_SelectDownloadFont(PHYSDEV dev)
BOOL PSDRV_SelectDownloadFont(print_ctx *ctx)
{
PSDRV_PDEVICE *physDev = get_psdrv_dev( dev );
physDev->font.fontloc = Download;
physDev->font.fontinfo.Download = NULL;
ctx->font.fontloc = Download;
ctx->font.fontinfo.Download = NULL;
return TRUE;
}
......@@ -265,91 +262,90 @@ static BOOL is_fake_italic( HDC hdc )
* Write setfont for download font.
*
*/
BOOL PSDRV_WriteSetDownloadFont(PHYSDEV dev, BOOL vertical)
BOOL PSDRV_WriteSetDownloadFont(print_ctx *ctx, BOOL vertical)
{
PSDRV_PDEVICE *physDev = get_psdrv_dev( dev );
char *ps_name;
LPOUTLINETEXTMETRICA potm;
DWORD len = GetOutlineTextMetricsA(dev->hdc, 0, NULL);
DWORD len = GetOutlineTextMetricsA(ctx->dev.hdc, 0, NULL);
DOWNLOAD *pdl;
LOGFONTW lf;
UINT ppem;
XFORM xform;
INT escapement;
assert(physDev->font.fontloc == Download);
assert(ctx->font.fontloc == Download);
if (!GetObjectW( GetCurrentObject(dev->hdc, OBJ_FONT), sizeof(lf), &lf ))
if (!GetObjectW( GetCurrentObject(ctx->dev.hdc, OBJ_FONT), sizeof(lf), &lf ))
return FALSE;
potm = HeapAlloc(GetProcessHeap(), 0, len);
if (!potm)
return FALSE;
GetOutlineTextMetricsA(dev->hdc, len, potm);
GetOutlineTextMetricsA(ctx->dev.hdc, len, potm);
get_download_name(dev, potm, &ps_name, vertical);
physDev->font.fontinfo.Download = is_font_downloaded(physDev, ps_name);
get_download_name(ctx, potm, &ps_name, vertical);
ctx->font.fontinfo.Download = is_font_downloaded(ctx, ps_name);
ppem = calc_ppem_for_height(dev->hdc, lf.lfHeight);
ppem = calc_ppem_for_height(ctx->dev.hdc, lf.lfHeight);
/* Retrieve the world -> device transform */
GetTransform(dev->hdc, 0x204, &xform);
GetTransform(ctx->dev.hdc, 0x204, &xform);
if(GetGraphicsMode(dev->hdc) == GM_COMPATIBLE)
if(GetGraphicsMode(ctx->dev.hdc) == GM_COMPATIBLE)
{
if (xform.eM22 < 0) physDev->font.escapement = -physDev->font.escapement;
if (xform.eM22 < 0) ctx->font.escapement = -ctx->font.escapement;
xform.eM11 = xform.eM22 = fabs(xform.eM22);
xform.eM21 = xform.eM12 = 0;
}
physDev->font.size.xx = ps_round(ppem * xform.eM11);
physDev->font.size.xy = ps_round(ppem * xform.eM12);
physDev->font.size.yx = -ps_round(ppem * xform.eM21);
physDev->font.size.yy = -ps_round(ppem * xform.eM22);
ctx->font.size.xx = ps_round(ppem * xform.eM11);
ctx->font.size.xy = ps_round(ppem * xform.eM12);
ctx->font.size.yx = -ps_round(ppem * xform.eM21);
ctx->font.size.yy = -ps_round(ppem * xform.eM22);
if(physDev->font.fontinfo.Download == NULL) {
if(ctx->font.fontinfo.Download == NULL) {
RECT bbox;
UINT emsize = get_bbox(dev->hdc, &bbox);
UINT emsize = get_bbox(ctx->dev.hdc, &bbox);
if (!emsize) {
HeapFree(GetProcessHeap(), 0, ps_name);
HeapFree(GetProcessHeap(), 0, potm);
return FALSE;
}
if(!is_room_for_font(physDev))
PSDRV_EmptyDownloadList(dev, TRUE);
if(!is_room_for_font(ctx))
PSDRV_EmptyDownloadList(ctx, TRUE);
pdl = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*pdl));
pdl->ps_name = HeapAlloc(GetProcessHeap(), 0, strlen(ps_name)+1);
strcpy(pdl->ps_name, ps_name);
pdl->next = NULL;
if(physDev->pi->ppd->TTRasterizer == RO_Type42) {
pdl->typeinfo.Type42 = T42_download_header(dev, ps_name, &bbox, emsize);
if(ctx->pi->ppd->TTRasterizer == RO_Type42) {
pdl->typeinfo.Type42 = T42_download_header(ctx, ps_name, &bbox, emsize);
pdl->type = Type42;
}
if(pdl->typeinfo.Type42 == NULL) {
pdl->typeinfo.Type1 = T1_download_header(dev, ps_name, &bbox, emsize);
pdl->typeinfo.Type1 = T1_download_header(ctx, ps_name, &bbox, emsize);
pdl->type = Type1;
}
pdl->next = physDev->downloaded_fonts;
physDev->downloaded_fonts = pdl;
physDev->font.fontinfo.Download = pdl;
pdl->next = ctx->downloaded_fonts;
ctx->downloaded_fonts = pdl;
ctx->font.fontinfo.Download = pdl;
if(pdl->type == Type42) {
char g_name[MAX_G_NAME + 1];
get_glyph_name(dev->hdc, 0, g_name);
T42_download_glyph(dev, pdl, 0, g_name);
get_glyph_name(ctx->dev.hdc, 0, g_name);
T42_download_glyph(ctx, pdl, 0, g_name);
}
}
escapement = physDev->font.escapement;
escapement = ctx->font.escapement;
if (vertical)
escapement += 900;
PSDRV_WriteSetFont(dev, ps_name, physDev->font.size, escapement,
is_fake_italic( dev->hdc ));
PSDRV_WriteSetFont(ctx, ps_name, ctx->font.size, escapement,
is_fake_italic( ctx->dev.hdc ));
HeapFree(GetProcessHeap(), 0, ps_name);
HeapFree(GetProcessHeap(), 0, potm);
......@@ -740,33 +736,32 @@ cleanup:
* Download and write out a number of glyphs
*
*/
BOOL PSDRV_WriteDownloadGlyphShow(PHYSDEV dev, const WORD *glyphs,
BOOL PSDRV_WriteDownloadGlyphShow(print_ctx *ctx, const WORD *glyphs,
UINT count)
{
PSDRV_PDEVICE *physDev = get_psdrv_dev( dev );
UINT i;
char g_name[MAX_G_NAME + 1];
assert(physDev->font.fontloc == Download);
assert(ctx->font.fontloc == Download);
switch(physDev->font.fontinfo.Download->type) {
switch(ctx->font.fontinfo.Download->type) {
case Type42:
for(i = 0; i < count; i++) {
get_glyph_name(dev->hdc, glyphs[i], g_name);
T42_download_glyph(dev, physDev->font.fontinfo.Download, glyphs[i], g_name);
PSDRV_WriteGlyphShow(dev, g_name);
get_glyph_name(ctx->dev.hdc, glyphs[i], g_name);
T42_download_glyph(ctx, ctx->font.fontinfo.Download, glyphs[i], g_name);
PSDRV_WriteGlyphShow(ctx, g_name);
}
break;
case Type1:
for(i = 0; i < count; i++) {
get_glyph_name(dev->hdc, glyphs[i], g_name);
T1_download_glyph(dev, physDev->font.fontinfo.Download, glyphs[i], g_name);
PSDRV_WriteGlyphShow(dev, g_name);
get_glyph_name(ctx->dev.hdc, glyphs[i], g_name);
T1_download_glyph(ctx, ctx->font.fontinfo.Download, glyphs[i], g_name);
PSDRV_WriteGlyphShow(ctx, g_name);
}
break;
default:
ERR("Type = %d\n", physDev->font.fontinfo.Download->type);
ERR("Type = %d\n", ctx->font.fontinfo.Download->type);
assert(0);
}
return TRUE;
......@@ -778,26 +773,25 @@ BOOL PSDRV_WriteDownloadGlyphShow(PHYSDEV dev, const WORD *glyphs,
* Clear the list of downloaded fonts
*
*/
BOOL PSDRV_EmptyDownloadList(PHYSDEV dev, BOOL write_undef)
BOOL PSDRV_EmptyDownloadList(print_ctx *ctx, BOOL write_undef)
{
PSDRV_PDEVICE *physDev = get_psdrv_dev( dev );
DOWNLOAD *pdl, *old;
static const char undef[] = "/%s findfont 40 scalefont setfont /%s undefinefont\n";
char buf[sizeof(undef) + 200];
const char *default_font = physDev->pi->ppd->DefaultFont ?
physDev->pi->ppd->DefaultFont : "Courier";
const char *default_font = ctx->pi->ppd->DefaultFont ?
ctx->pi->ppd->DefaultFont : "Courier";
if(physDev->font.fontloc == Download) {
physDev->font.set = FALSE;
physDev->font.fontinfo.Download = NULL;
if(ctx->font.fontloc == Download) {
ctx->font.set = FALSE;
ctx->font.fontinfo.Download = NULL;
}
pdl = physDev->downloaded_fonts;
physDev->downloaded_fonts = NULL;
pdl = ctx->downloaded_fonts;
ctx->downloaded_fonts = NULL;
while(pdl) {
if(write_undef) {
sprintf(buf, undef, default_font, pdl->ps_name);
PSDRV_WriteSpool(dev, buf, strlen(buf));
PSDRV_WriteSpool(ctx, buf, strlen(buf));
}
switch(pdl->type) {
......
......@@ -38,12 +38,11 @@
WINE_DEFAULT_DEBUG_CHANNEL(psdrv);
DWORD write_spool( PHYSDEV dev, const void *data, DWORD num )
DWORD write_spool( print_ctx *ctx, const void *data, DWORD num )
{
PSDRV_PDEVICE *physDev = get_psdrv_dev( dev );
DWORD written;
if (!WritePrinter(physDev->job.hprinter, (LPBYTE) data, num, &written) || (written != num))
if (!WritePrinter(ctx->job.hprinter, (LPBYTE) data, num, &written) || (written != num))
return SP_OUTOFDISK;
return num;
......@@ -52,13 +51,11 @@ DWORD write_spool( PHYSDEV dev, const void *data, DWORD num )
/**********************************************************************
* ExtEscape (WINEPS.@)
*/
INT CDECL PSDRV_ExtEscape( PHYSDEV dev, INT nEscape, INT cbInput, LPCVOID in_data,
INT CDECL PSDRV_ExtEscape( print_ctx *ctx, INT nEscape, INT cbInput, LPCVOID in_data,
INT cbOutput, LPVOID out_data )
{
PSDRV_PDEVICE *physDev = get_psdrv_dev( dev );
TRACE("%p,%d,%d,%p,%d,%p\n",
dev->hdc, nEscape, cbInput, in_data, cbOutput, out_data);
ctx->dev.hdc, nEscape, cbInput, in_data, cbOutput, out_data);
switch(nEscape)
{
......@@ -75,30 +72,30 @@ INT CDECL PSDRV_ExtEscape( PHYSDEV dev, INT nEscape, INT cbInput, LPCVOID in_dat
* length of the string, rather than 2 more. So we'll use the WORD at
* in_data[0] instead.
*/
passthrough_enter(dev);
return write_spool(dev, ((char*)in_data) + 2, *(const WORD*)in_data);
passthrough_enter(ctx);
return write_spool(ctx, ((char*)in_data) + 2, *(const WORD*)in_data);
}
case POSTSCRIPT_IGNORE:
{
BOOL ret = physDev->job.quiet;
BOOL ret = ctx->job.quiet;
TRACE("POSTSCRIPT_IGNORE %d\n", *(const short*)in_data);
physDev->job.quiet = *(const short*)in_data;
ctx->job.quiet = *(const short*)in_data;
return ret;
}
case BEGIN_PATH:
TRACE("BEGIN_PATH\n");
if(physDev->pathdepth)
if(ctx->pathdepth)
FIXME("Nested paths not yet handled\n");
return ++physDev->pathdepth;
return ++ctx->pathdepth;
case END_PATH:
{
const struct PATH_INFO *info = (const struct PATH_INFO*)in_data;
TRACE("END_PATH\n");
if(!physDev->pathdepth) {
if(!ctx->pathdepth) {
ERR("END_PATH called without a BEGIN_PATH\n");
return -1;
}
......@@ -106,7 +103,7 @@ INT CDECL PSDRV_ExtEscape( PHYSDEV dev, INT nEscape, INT cbInput, LPCVOID in_dat
info->RenderMode, info->FillMode, info->BkMode);
switch(info->RenderMode) {
case RENDERMODE_NO_DISPLAY:
PSDRV_WriteClosePath(dev); /* not sure if this is necessary, but it can't hurt */
PSDRV_WriteClosePath(ctx); /* not sure if this is necessary, but it can't hurt */
break;
case RENDERMODE_OPEN:
case RENDERMODE_CLOSED:
......@@ -114,7 +111,7 @@ INT CDECL PSDRV_ExtEscape( PHYSDEV dev, INT nEscape, INT cbInput, LPCVOID in_dat
FIXME("END_PATH: RenderMode %d, not yet supported\n", info->RenderMode);
break;
}
return --physDev->pathdepth;
return --ctx->pathdepth;
}
case CLIP_TO_PATH:
......@@ -124,17 +121,17 @@ INT CDECL PSDRV_ExtEscape( PHYSDEV dev, INT nEscape, INT cbInput, LPCVOID in_dat
switch(mode) {
case CLIP_SAVE:
TRACE("CLIP_TO_PATH: CLIP_SAVE\n");
PSDRV_WriteGSave(dev);
PSDRV_WriteGSave(ctx);
return 1;
case CLIP_RESTORE:
TRACE("CLIP_TO_PATH: CLIP_RESTORE\n");
PSDRV_WriteGRestore(dev);
PSDRV_WriteGRestore(ctx);
return 1;
case CLIP_INCLUSIVE:
TRACE("CLIP_TO_PATH: CLIP_INCLUSIVE\n");
/* FIXME to clip or eoclip ? (see PATH_INFO.FillMode) */
PSDRV_WriteClip(dev);
PSDRV_WriteNewPath(dev);
PSDRV_WriteClip(ctx);
PSDRV_WriteNewPath(ctx);
return 1;
case CLIP_EXCLUSIVE:
FIXME("CLIP_EXCLUSIVE: not implemented\n");
......@@ -153,22 +150,20 @@ INT CDECL PSDRV_ExtEscape( PHYSDEV dev, INT nEscape, INT cbInput, LPCVOID in_dat
/************************************************************************
* PSDRV_StartPage
*/
INT CDECL PSDRV_StartPage( PHYSDEV dev )
INT CDECL PSDRV_StartPage( print_ctx *ctx )
{
PSDRV_PDEVICE *physDev = get_psdrv_dev( dev );
TRACE("%p\n", dev->hdc);
TRACE("%p\n", ctx->dev.hdc);
if(!physDev->job.OutOfPage) {
if(!ctx->job.OutOfPage) {
FIXME("Already started a page?\n");
return 1;
}
physDev->job.PageNo++;
ctx->job.PageNo++;
if(!PSDRV_WriteNewPage( dev ))
if(!PSDRV_WriteNewPage( ctx ))
return 0;
physDev->job.OutOfPage = FALSE;
ctx->job.OutOfPage = FALSE;
return 1;
}
......@@ -176,21 +171,19 @@ INT CDECL PSDRV_StartPage( PHYSDEV dev )
/************************************************************************
* PSDRV_EndPage
*/
INT CDECL PSDRV_EndPage( PHYSDEV dev )
INT CDECL PSDRV_EndPage( print_ctx *ctx )
{
PSDRV_PDEVICE *physDev = get_psdrv_dev( dev );
TRACE("%p\n", dev->hdc);
TRACE("%p\n", ctx->dev.hdc);
if(physDev->job.OutOfPage) {
if(ctx->job.OutOfPage) {
FIXME("Already ended a page?\n");
return 1;
}
passthrough_leave(dev);
if(!PSDRV_WriteEndPage( dev ))
passthrough_leave(ctx);
if(!PSDRV_WriteEndPage( ctx ))
return 0;
PSDRV_EmptyDownloadList(dev, FALSE);
physDev->job.OutOfPage = TRUE;
PSDRV_EmptyDownloadList(ctx, FALSE);
ctx->job.OutOfPage = TRUE;
return 1;
}
......@@ -38,20 +38,19 @@ WINE_DEFAULT_DEBUG_CHANNEL(psdrv);
/***********************************************************************
* SelectFont (WINEPS.@)
*/
HFONT CDECL PSDRV_SelectFont( PHYSDEV dev, HFONT hfont, UINT *aa_flags )
HFONT CDECL PSDRV_SelectFont( print_ctx *ctx, HFONT hfont, UINT *aa_flags )
{
PSDRV_PDEVICE *physDev = get_psdrv_dev( dev );
struct font_info font_info;
if (ExtEscape(dev->hdc, PSDRV_GET_BUILTIN_FONT_INFO, 0, NULL,
if (ExtEscape(ctx->dev.hdc, PSDRV_GET_BUILTIN_FONT_INFO, 0, NULL,
sizeof(font_info), (char *)&font_info))
{
physDev->font.fontloc = Builtin;
ctx->font.fontloc = Builtin;
}
else
{
physDev->font.fontloc = Download;
physDev->font.fontinfo.Download = NULL;
ctx->font.fontloc = Download;
ctx->font.fontinfo.Download = NULL;
}
return hfont;
}
......@@ -59,29 +58,27 @@ HFONT CDECL PSDRV_SelectFont( PHYSDEV dev, HFONT hfont, UINT *aa_flags )
/***********************************************************************
* PSDRV_SetFont
*/
BOOL PSDRV_SetFont( PHYSDEV dev, BOOL vertical )
BOOL PSDRV_SetFont( print_ctx *ctx, BOOL vertical )
{
PSDRV_PDEVICE *physDev = get_psdrv_dev( dev );
PSDRV_WriteSetColor(ctx, &ctx->font.color);
if (vertical && (ctx->font.set == VERTICAL_SET)) return TRUE;
if (!vertical && (ctx->font.set == HORIZONTAL_SET)) return TRUE;
PSDRV_WriteSetColor(dev, &physDev->font.color);
if (vertical && (physDev->font.set == VERTICAL_SET)) return TRUE;
if (!vertical && (physDev->font.set == HORIZONTAL_SET)) return TRUE;
switch(physDev->font.fontloc) {
switch(ctx->font.fontloc) {
case Builtin:
PSDRV_WriteSetBuiltinFont(dev);
PSDRV_WriteSetBuiltinFont(ctx);
break;
case Download:
PSDRV_WriteSetDownloadFont(dev, vertical);
PSDRV_WriteSetDownloadFont(ctx, vertical);
break;
default:
ERR("fontloc = %d\n", physDev->font.fontloc);
ERR("fontloc = %d\n", ctx->font.fontloc);
assert(1);
break;
}
if (vertical)
physDev->font.set = VERTICAL_SET;
ctx->font.set = VERTICAL_SET;
else
physDev->font.set = HORIZONTAL_SET;
ctx->font.set = HORIZONTAL_SET;
return TRUE;
}
......@@ -36,7 +36,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(psdrv);
*
* Performs a world-to-viewport transformation on the specified width.
*/
INT PSDRV_XWStoDS( PHYSDEV dev, INT width )
INT PSDRV_XWStoDS( print_ctx *ctx, INT width )
{
POINT pt[2];
......@@ -44,47 +44,45 @@ INT PSDRV_XWStoDS( PHYSDEV dev, INT width )
pt[0].y = 0;
pt[1].x = width;
pt[1].y = 0;
LPtoDP( dev->hdc, pt, 2 );
LPtoDP( ctx->dev.hdc, pt, 2 );
return pt[1].x - pt[0].x;
}
/***********************************************************************
* PSDRV_DrawLine
*/
static void PSDRV_DrawLine( PHYSDEV dev )
static void PSDRV_DrawLine( print_ctx *ctx )
{
PSDRV_PDEVICE *physDev = get_psdrv_dev( dev );
if(physDev->pathdepth)
if(ctx->pathdepth)
return;
if (physDev->pen.style == PS_NULL)
PSDRV_WriteNewPath(dev);
if (ctx->pen.style == PS_NULL)
PSDRV_WriteNewPath(ctx);
else
PSDRV_WriteStroke(dev);
PSDRV_WriteStroke(ctx);
}
/***********************************************************************
* PSDRV_LineTo
*/
BOOL CDECL PSDRV_LineTo(PHYSDEV dev, INT x, INT y)
BOOL CDECL PSDRV_LineTo(print_ctx *ctx, INT x, INT y)
{
POINT pt[2];
TRACE("%d %d\n", x, y);
GetCurrentPositionEx( dev->hdc, pt );
GetCurrentPositionEx( ctx->dev.hdc, pt );
pt[1].x = x;
pt[1].y = y;
LPtoDP( dev->hdc, pt, 2 );
LPtoDP( ctx->dev.hdc, pt, 2 );
PSDRV_SetPen(dev);
PSDRV_SetPen(ctx);
PSDRV_SetClip(dev);
PSDRV_WriteMoveTo(dev, pt[0].x, pt[0].y );
PSDRV_WriteLineTo(dev, pt[1].x, pt[1].y );
PSDRV_DrawLine(dev);
PSDRV_ResetClip(dev);
PSDRV_SetClip(ctx);
PSDRV_WriteMoveTo(ctx, pt[0].x, pt[0].y );
PSDRV_WriteLineTo(ctx, pt[1].x, pt[1].y );
PSDRV_DrawLine(ctx);
PSDRV_ResetClip(ctx);
return TRUE;
}
......@@ -93,37 +91,36 @@ BOOL CDECL PSDRV_LineTo(PHYSDEV dev, INT x, INT y)
/***********************************************************************
* PSDRV_Rectangle
*/
BOOL CDECL PSDRV_Rectangle( PHYSDEV dev, INT left, INT top, INT right, INT bottom )
BOOL CDECL PSDRV_Rectangle( print_ctx *ctx, INT left, INT top, INT right, INT bottom )
{
PSDRV_PDEVICE *physDev = get_psdrv_dev( dev );
RECT rect;
TRACE("%d %d - %d %d\n", left, top, right, bottom);
SetRect(&rect, left, top, right, bottom);
LPtoDP( dev->hdc, (POINT *)&rect, 2 );
LPtoDP( ctx->dev.hdc, (POINT *)&rect, 2 );
/* Windows does something truly hacky here. If we're in passthrough mode
and our rop is R2_NOP, then we output the string below. This is used in
Office 2k when inserting eps files */
if (physDev->job.passthrough_state == passthrough_active && GetROP2(dev->hdc) == R2_NOP)
if (ctx->job.passthrough_state == passthrough_active && GetROP2(ctx->dev.hdc) == R2_NOP)
{
char buf[256];
sprintf(buf, "N %ld %ld %ld %ld B\n", rect.right - rect.left, rect.bottom - rect.top, rect.left, rect.top);
write_spool(dev, buf, strlen(buf));
physDev->job.passthrough_state = passthrough_had_rect;
write_spool(ctx, buf, strlen(buf));
ctx->job.passthrough_state = passthrough_had_rect;
return TRUE;
}
PSDRV_SetPen(dev);
PSDRV_SetPen(ctx);
PSDRV_SetClip(dev);
PSDRV_WriteRectangle(dev, rect.left, rect.top, rect.right - rect.left,
PSDRV_SetClip(ctx);
PSDRV_WriteRectangle(ctx, rect.left, rect.top, rect.right - rect.left,
rect.bottom - rect.top );
PSDRV_Brush(dev,0);
PSDRV_DrawLine(dev);
PSDRV_ResetClip(dev);
PSDRV_Brush(ctx,0);
PSDRV_DrawLine(ctx);
PSDRV_ResetClip(ctx);
return TRUE;
}
......@@ -131,14 +128,14 @@ BOOL CDECL PSDRV_Rectangle( PHYSDEV dev, INT left, INT top, INT right, INT botto
/***********************************************************************
* PSDRV_RoundRect
*/
BOOL CDECL PSDRV_RoundRect( PHYSDEV dev, INT left, INT top, INT right,
BOOL CDECL PSDRV_RoundRect( print_ctx *ctx, INT left, INT top, INT right,
INT bottom, INT ell_width, INT ell_height )
{
RECT rect[2];
SetRect(&rect[0], left, top, right, bottom);
SetRect(&rect[1], 0, 0, ell_width, ell_height);
LPtoDP( dev->hdc, (POINT *)rect, 4 );
LPtoDP( ctx->dev.hdc, (POINT *)rect, 4 );
left = rect[0].left;
top = rect[0].top;
......@@ -152,27 +149,27 @@ BOOL CDECL PSDRV_RoundRect( PHYSDEV dev, INT left, INT top, INT right,
if (ell_width > right - left) ell_width = right - left;
if (ell_height > bottom - top) ell_height = bottom - top;
PSDRV_WriteSpool(dev, "%RoundRect\n",11);
PSDRV_SetPen(dev);
PSDRV_WriteSpool(ctx, "%RoundRect\n",11);
PSDRV_SetPen(ctx);
PSDRV_SetClip(dev);
PSDRV_WriteMoveTo( dev, left, top + ell_height/2 );
PSDRV_WriteArc( dev, left + ell_width/2, top + ell_height/2, ell_width,
PSDRV_SetClip(ctx);
PSDRV_WriteMoveTo( ctx, left, top + ell_height/2 );
PSDRV_WriteArc( ctx, left + ell_width/2, top + ell_height/2, ell_width,
ell_height, 90.0, 180.0);
PSDRV_WriteLineTo( dev, right - ell_width/2, top );
PSDRV_WriteArc( dev, right - ell_width/2, top + ell_height/2, ell_width,
PSDRV_WriteLineTo( ctx, right - ell_width/2, top );
PSDRV_WriteArc( ctx, right - ell_width/2, top + ell_height/2, ell_width,
ell_height, 0.0, 90.0);
PSDRV_WriteLineTo( dev, right, bottom - ell_height/2 );
PSDRV_WriteArc( dev, right - ell_width/2, bottom - ell_height/2, ell_width,
PSDRV_WriteLineTo( ctx, right, bottom - ell_height/2 );
PSDRV_WriteArc( ctx, right - ell_width/2, bottom - ell_height/2, ell_width,
ell_height, -90.0, 0.0);
PSDRV_WriteLineTo( dev, right - ell_width/2, bottom);
PSDRV_WriteArc( dev, left + ell_width/2, bottom - ell_height/2, ell_width,
PSDRV_WriteLineTo( ctx, right - ell_width/2, bottom);
PSDRV_WriteArc( ctx, left + ell_width/2, bottom - ell_height/2, ell_width,
ell_height, 180.0, -90.0);
PSDRV_WriteClosePath( dev );
PSDRV_WriteClosePath( ctx );
PSDRV_Brush(dev,0);
PSDRV_DrawLine(dev);
PSDRV_ResetClip(dev);
PSDRV_Brush(ctx,0);
PSDRV_DrawLine(ctx);
PSDRV_ResetClip(ctx);
return TRUE;
}
......@@ -181,7 +178,7 @@ BOOL CDECL PSDRV_RoundRect( PHYSDEV dev, INT left, INT top, INT right,
*
* Does the work of Arc, Chord and Pie. lines is 0, 1 or 2 respectively.
*/
static BOOL PSDRV_DrawArc( PHYSDEV dev, INT left, INT top,
static BOOL PSDRV_DrawArc( print_ctx *ctx, INT left, INT top,
INT right, INT bottom, INT xstart, INT ystart,
INT xend, INT yend, int lines )
{
......@@ -191,13 +188,13 @@ static BOOL PSDRV_DrawArc( PHYSDEV dev, INT left, INT top,
POINT start, end;
SetRect(&rect, left, top, right, bottom);
LPtoDP( dev->hdc, (POINT *)&rect, 2 );
LPtoDP( ctx->dev.hdc, (POINT *)&rect, 2 );
start.x = xstart;
start.y = ystart;
end.x = xend;
end.y = yend;
LPtoDP( dev->hdc, &start, 1 );
LPtoDP( dev->hdc, &end, 1 );
LPtoDP( ctx->dev.hdc, &start, 1 );
LPtoDP( ctx->dev.hdc, &end, 1 );
x = (rect.left + rect.right) / 2;
y = (rect.top + rect.bottom) / 2;
......@@ -217,25 +214,25 @@ static BOOL PSDRV_DrawArc( PHYSDEV dev, INT left, INT top,
start_angle *= 180.0 / M_PI;
end_angle *= 180.0 / M_PI;
PSDRV_WriteSpool(dev,"%DrawArc\n", 9);
PSDRV_SetPen(dev);
PSDRV_WriteSpool(ctx,"%DrawArc\n", 9);
PSDRV_SetPen(ctx);
PSDRV_SetClip(dev);
PSDRV_SetClip(ctx);
if(lines == 2) /* pie */
PSDRV_WriteMoveTo(dev, x, y);
PSDRV_WriteMoveTo(ctx, x, y);
else
PSDRV_WriteNewPath( dev );
PSDRV_WriteNewPath( ctx );
if(GetArcDirection(dev->hdc) == AD_COUNTERCLOCKWISE)
PSDRV_WriteArc(dev, x, y, w, h, start_angle, end_angle);
if(GetArcDirection(ctx->dev.hdc) == AD_COUNTERCLOCKWISE)
PSDRV_WriteArc(ctx, x, y, w, h, start_angle, end_angle);
else
PSDRV_WriteArc(dev, x, y, w, h, end_angle, start_angle);
PSDRV_WriteArc(ctx, x, y, w, h, end_angle, start_angle);
if(lines == 1 || lines == 2) { /* chord or pie */
PSDRV_WriteClosePath(dev);
PSDRV_Brush(dev,0);
PSDRV_WriteClosePath(ctx);
PSDRV_Brush(ctx,0);
}
PSDRV_DrawLine(dev);
PSDRV_ResetClip(dev);
PSDRV_DrawLine(ctx);
PSDRV_ResetClip(ctx);
return TRUE;
}
......@@ -244,36 +241,36 @@ static BOOL PSDRV_DrawArc( PHYSDEV dev, INT left, INT top,
/***********************************************************************
* PSDRV_Arc
*/
BOOL CDECL PSDRV_Arc( PHYSDEV dev, INT left, INT top, INT right, INT bottom,
BOOL CDECL PSDRV_Arc( print_ctx *ctx, INT left, INT top, INT right, INT bottom,
INT xstart, INT ystart, INT xend, INT yend )
{
return PSDRV_DrawArc( dev, left, top, right, bottom, xstart, ystart, xend, yend, 0 );
return PSDRV_DrawArc( ctx, left, top, right, bottom, xstart, ystart, xend, yend, 0 );
}
/***********************************************************************
* PSDRV_Chord
*/
BOOL CDECL PSDRV_Chord( PHYSDEV dev, INT left, INT top, INT right, INT bottom,
BOOL CDECL PSDRV_Chord( print_ctx *ctx, INT left, INT top, INT right, INT bottom,
INT xstart, INT ystart, INT xend, INT yend )
{
return PSDRV_DrawArc( dev, left, top, right, bottom, xstart, ystart, xend, yend, 1 );
return PSDRV_DrawArc( ctx, left, top, right, bottom, xstart, ystart, xend, yend, 1 );
}
/***********************************************************************
* PSDRV_Pie
*/
BOOL CDECL PSDRV_Pie( PHYSDEV dev, INT left, INT top, INT right, INT bottom,
BOOL CDECL PSDRV_Pie( print_ctx *ctx, INT left, INT top, INT right, INT bottom,
INT xstart, INT ystart, INT xend, INT yend )
{
return PSDRV_DrawArc( dev, left, top, right, bottom, xstart, ystart, xend, yend, 2 );
return PSDRV_DrawArc( ctx, left, top, right, bottom, xstart, ystart, xend, yend, 2 );
}
/***********************************************************************
* PSDRV_Ellipse
*/
BOOL CDECL PSDRV_Ellipse( PHYSDEV dev, INT left, INT top, INT right, INT bottom)
BOOL CDECL PSDRV_Ellipse( print_ctx *ctx, INT left, INT top, INT right, INT bottom)
{
INT x, y, w, h;
RECT rect;
......@@ -281,23 +278,23 @@ BOOL CDECL PSDRV_Ellipse( PHYSDEV dev, INT left, INT top, INT right, INT bottom)
TRACE("%d %d - %d %d\n", left, top, right, bottom);
SetRect(&rect, left, top, right, bottom);
LPtoDP( dev->hdc, (POINT *)&rect, 2 );
LPtoDP( ctx->dev.hdc, (POINT *)&rect, 2 );
x = (rect.left + rect.right) / 2;
y = (rect.top + rect.bottom) / 2;
w = rect.right - rect.left;
h = rect.bottom - rect.top;
PSDRV_WriteSpool(dev, "%Ellipse\n", 9);
PSDRV_SetPen(dev);
PSDRV_WriteSpool(ctx, "%Ellipse\n", 9);
PSDRV_SetPen(ctx);
PSDRV_SetClip(dev);
PSDRV_WriteNewPath(dev);
PSDRV_WriteArc(dev, x, y, w, h, 0.0, 360.0);
PSDRV_WriteClosePath(dev);
PSDRV_Brush(dev,0);
PSDRV_DrawLine(dev);
PSDRV_ResetClip(dev);
PSDRV_SetClip(ctx);
PSDRV_WriteNewPath(ctx);
PSDRV_WriteArc(ctx, x, y, w, h, 0.0, 360.0);
PSDRV_WriteClosePath(ctx);
PSDRV_Brush(ctx,0);
PSDRV_DrawLine(ctx);
PSDRV_ResetClip(ctx);
return TRUE;
}
......@@ -305,7 +302,7 @@ BOOL CDECL PSDRV_Ellipse( PHYSDEV dev, INT left, INT top, INT right, INT bottom)
/***********************************************************************
* PSDRV_PolyPolyline
*/
BOOL CDECL PSDRV_PolyPolyline( PHYSDEV dev, const POINT* pts, const DWORD* counts, DWORD polylines )
BOOL CDECL PSDRV_PolyPolyline( print_ctx *ctx, const POINT* pts, const DWORD* counts, DWORD polylines )
{
DWORD polyline, line, total;
POINT *dev_pts, *pt;
......@@ -315,24 +312,24 @@ BOOL CDECL PSDRV_PolyPolyline( PHYSDEV dev, const POINT* pts, const DWORD* count
for (polyline = total = 0; polyline < polylines; polyline++) total += counts[polyline];
if (!(dev_pts = HeapAlloc( GetProcessHeap(), 0, total * sizeof(*dev_pts) ))) return FALSE;
memcpy( dev_pts, pts, total * sizeof(*dev_pts) );
LPtoDP( dev->hdc, dev_pts, total );
LPtoDP( ctx->dev.hdc, dev_pts, total );
pt = dev_pts;
PSDRV_WriteSpool(dev, "%PolyPolyline\n",14);
PSDRV_SetPen(dev);
PSDRV_SetClip(dev);
PSDRV_WriteSpool(ctx, "%PolyPolyline\n",14);
PSDRV_SetPen(ctx);
PSDRV_SetClip(ctx);
for(polyline = 0; polyline < polylines; polyline++) {
PSDRV_WriteMoveTo(dev, pt->x, pt->y);
PSDRV_WriteMoveTo(ctx, pt->x, pt->y);
pt++;
for(line = 1; line < counts[polyline]; line++, pt++)
PSDRV_WriteLineTo(dev, pt->x, pt->y);
PSDRV_WriteLineTo(ctx, pt->x, pt->y);
}
HeapFree( GetProcessHeap(), 0, dev_pts );
PSDRV_DrawLine(dev);
PSDRV_ResetClip(dev);
PSDRV_DrawLine(ctx);
PSDRV_ResetClip(ctx);
return TRUE;
}
......@@ -340,7 +337,7 @@ BOOL CDECL PSDRV_PolyPolyline( PHYSDEV dev, const POINT* pts, const DWORD* count
/***********************************************************************
* PSDRV_PolyPolygon
*/
BOOL CDECL PSDRV_PolyPolygon( PHYSDEV dev, const POINT* pts, const INT* counts, UINT polygons )
BOOL CDECL PSDRV_PolyPolygon( print_ctx *ctx, const POINT* pts, const INT* counts, UINT polygons )
{
DWORD polygon, total;
INT line;
......@@ -351,34 +348,34 @@ BOOL CDECL PSDRV_PolyPolygon( PHYSDEV dev, const POINT* pts, const INT* counts,
for (polygon = total = 0; polygon < polygons; polygon++) total += counts[polygon];
if (!(dev_pts = HeapAlloc( GetProcessHeap(), 0, total * sizeof(*dev_pts) ))) return FALSE;
memcpy( dev_pts, pts, total * sizeof(*dev_pts) );
LPtoDP( dev->hdc, dev_pts, total );
LPtoDP( ctx->dev.hdc, dev_pts, total );
pt = dev_pts;
PSDRV_WriteSpool(dev, "%PolyPolygon\n",13);
PSDRV_SetPen(dev);
PSDRV_SetClip(dev);
PSDRV_WriteSpool(ctx, "%PolyPolygon\n",13);
PSDRV_SetPen(ctx);
PSDRV_SetClip(ctx);
for(polygon = 0; polygon < polygons; polygon++) {
PSDRV_WriteMoveTo(dev, pt->x, pt->y);
PSDRV_WriteMoveTo(ctx, pt->x, pt->y);
pt++;
for(line = 1; line < counts[polygon]; line++, pt++)
PSDRV_WriteLineTo(dev, pt->x, pt->y);
PSDRV_WriteClosePath(dev);
PSDRV_WriteLineTo(ctx, pt->x, pt->y);
PSDRV_WriteClosePath(ctx);
}
HeapFree( GetProcessHeap(), 0, dev_pts );
if(GetPolyFillMode( dev->hdc ) == ALTERNATE)
PSDRV_Brush(dev, 1);
if(GetPolyFillMode( ctx->dev.hdc ) == ALTERNATE)
PSDRV_Brush(ctx, 1);
else /* WINDING */
PSDRV_Brush(dev, 0);
PSDRV_Brush(ctx, 0);
PSDRV_DrawLine(dev);
PSDRV_ResetClip(dev);
PSDRV_DrawLine(ctx);
PSDRV_ResetClip(ctx);
return TRUE;
}
static BOOL poly_bezier( PHYSDEV dev, const POINT *pt0, const POINT *pts, DWORD count)
static BOOL poly_bezier( print_ctx *ctx, const POINT *pt0, const POINT *pts, DWORD count)
{
POINT dev_pts[3];
DWORD i;
......@@ -386,79 +383,79 @@ static BOOL poly_bezier( PHYSDEV dev, const POINT *pt0, const POINT *pts, DWORD
TRACE( "\n" );
dev_pts[0] = *pt0;
LPtoDP( dev->hdc, dev_pts, 1 );
LPtoDP( ctx->dev.hdc, dev_pts, 1 );
PSDRV_WriteSpool( dev, "%PolyBezier\n", 12 );
PSDRV_SetPen( dev );
PSDRV_SetClip( dev );
PSDRV_WriteMoveTo( dev, dev_pts[0].x, dev_pts[0].y );
PSDRV_WriteSpool( ctx, "%PolyBezier\n", 12 );
PSDRV_SetPen( ctx );
PSDRV_SetClip( ctx );
PSDRV_WriteMoveTo( ctx, dev_pts[0].x, dev_pts[0].y );
for (i = 0; i < count; i += 3)
{
memcpy( dev_pts, pts, sizeof(dev_pts) );
LPtoDP( dev->hdc, dev_pts, 3 );
PSDRV_WriteCurveTo( dev, dev_pts );
LPtoDP( ctx->dev.hdc, dev_pts, 3 );
PSDRV_WriteCurveTo( ctx, dev_pts );
}
PSDRV_DrawLine(dev);
PSDRV_ResetClip(dev);
PSDRV_DrawLine(ctx);
PSDRV_ResetClip(ctx);
return TRUE;
}
/***********************************************************************
* PSDRV_PolyBezier
*/
BOOL CDECL PSDRV_PolyBezier( PHYSDEV dev, const POINT *pts, DWORD count )
BOOL CDECL PSDRV_PolyBezier( print_ctx *ctx, const POINT *pts, DWORD count )
{
return poly_bezier( dev, pts, pts + 1, count - 1 );
return poly_bezier( ctx, pts, pts + 1, count - 1 );
}
/***********************************************************************
* PSDRV_PolyBezierTo
*/
BOOL CDECL PSDRV_PolyBezierTo( PHYSDEV dev, const POINT *pts, DWORD count )
BOOL CDECL PSDRV_PolyBezierTo( print_ctx *ctx, const POINT *pts, DWORD count )
{
POINT pt0;
GetCurrentPositionEx( dev->hdc, &pt0 );
return poly_bezier( dev, &pt0, pts, count );
GetCurrentPositionEx( ctx->dev.hdc, &pt0 );
return poly_bezier( ctx, &pt0, pts, count );
}
/***********************************************************************
* PSDRV_SetPixel
*/
COLORREF CDECL PSDRV_SetPixel( PHYSDEV dev, INT x, INT y, COLORREF color )
COLORREF CDECL PSDRV_SetPixel( print_ctx *ctx, INT x, INT y, COLORREF color )
{
PSCOLOR pscolor;
POINT pt;
pt.x = x;
pt.y = y;
LPtoDP( dev->hdc, &pt, 1 );
LPtoDP( ctx->dev.hdc, &pt, 1 );
PSDRV_SetClip(dev);
PSDRV_SetClip(ctx);
/* we bracket the setcolor in gsave/grestore so that we don't trash
the current pen colour */
PSDRV_WriteGSave(dev);
PSDRV_WriteRectangle( dev, pt.x, pt.y, 1, 1 );
PSDRV_CreateColor( dev, &pscolor, color );
PSDRV_WriteSetColor( dev, &pscolor );
PSDRV_WriteFill( dev );
PSDRV_WriteGRestore(dev);
PSDRV_ResetClip(dev);
PSDRV_WriteGSave(ctx);
PSDRV_WriteRectangle( ctx, pt.x, pt.y, 1, 1 );
PSDRV_CreateColor( ctx, &pscolor, color );
PSDRV_WriteSetColor( ctx, &pscolor );
PSDRV_WriteFill( ctx );
PSDRV_WriteGRestore(ctx);
PSDRV_ResetClip(ctx);
return color;
}
/***********************************************************************
* PSDRV_PaintRgn
*/
BOOL CDECL PSDRV_PaintRgn( PHYSDEV dev, HRGN hrgn )
BOOL CDECL PSDRV_PaintRgn( print_ctx *ctx, HRGN hrgn )
{
RGNDATA *rgndata = NULL;
RECT *pRect;
DWORD size, i;
TRACE("hdc=%p\n", dev->hdc);
TRACE("hdc=%p\n", ctx->dev.hdc);
size = GetRegionData(hrgn, 0, NULL);
rgndata = HeapAlloc( GetProcessHeap(), 0, size );
......@@ -471,66 +468,66 @@ BOOL CDECL PSDRV_PaintRgn( PHYSDEV dev, HRGN hrgn )
if (rgndata->rdh.nCount == 0)
goto end;
LPtoDP(dev->hdc, (POINT*)rgndata->Buffer, rgndata->rdh.nCount * 2);
LPtoDP(ctx->dev.hdc, (POINT*)rgndata->Buffer, rgndata->rdh.nCount * 2);
PSDRV_SetClip(dev);
PSDRV_SetClip(ctx);
for(i = 0, pRect = (RECT*)rgndata->Buffer; i < rgndata->rdh.nCount; i++, pRect++)
PSDRV_WriteRectangle(dev, pRect->left, pRect->top, pRect->right - pRect->left, pRect->bottom - pRect->top);
PSDRV_WriteRectangle(ctx, pRect->left, pRect->top, pRect->right - pRect->left, pRect->bottom - pRect->top);
PSDRV_Brush(dev, 0);
PSDRV_WriteNewPath(dev);
PSDRV_ResetClip(dev);
PSDRV_Brush(ctx, 0);
PSDRV_WriteNewPath(ctx);
PSDRV_ResetClip(ctx);
end:
HeapFree(GetProcessHeap(), 0, rgndata);
return TRUE;
}
static BOOL paint_path( PHYSDEV dev, BOOL stroke, BOOL fill )
static BOOL paint_path( print_ctx *ctx, BOOL stroke, BOOL fill )
{
POINT *points;
BYTE *types;
int i, size = GetPath( dev->hdc, NULL, NULL, 0 );
int i, size = GetPath( ctx->dev.hdc, NULL, NULL, 0 );
if (size == -1) return FALSE;
if (!size)
{
AbortPath( dev->hdc );
AbortPath( ctx->dev.hdc );
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;
LPtoDP( dev->hdc, points, size );
if (GetPath( ctx->dev.hdc, points, types, size ) == -1) goto done;
LPtoDP( ctx->dev.hdc, points, size );
if (stroke) PSDRV_SetPen(dev);
PSDRV_SetClip(dev);
if (stroke) PSDRV_SetPen(ctx);
PSDRV_SetClip(ctx);
for (i = 0; i < size; i++)
{
switch (types[i])
{
case PT_MOVETO:
PSDRV_WriteMoveTo( dev, points[i].x, points[i].y );
PSDRV_WriteMoveTo( ctx, 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 );
PSDRV_WriteLineTo( ctx, points[i].x, points[i].y );
if (types[i] & PT_CLOSEFIGURE) PSDRV_WriteClosePath( ctx );
break;
case PT_BEZIERTO:
case PT_BEZIERTO | PT_CLOSEFIGURE:
PSDRV_WriteCurveTo( dev, points + i );
if (types[i] & PT_CLOSEFIGURE) PSDRV_WriteClosePath( dev );
PSDRV_WriteCurveTo( ctx, points + i );
if (types[i] & PT_CLOSEFIGURE) PSDRV_WriteClosePath( ctx );
i += 2;
break;
}
}
if (fill) PSDRV_Brush( dev, GetPolyFillMode(dev->hdc) == ALTERNATE );
if (stroke) PSDRV_DrawLine(dev);
else PSDRV_WriteNewPath(dev);
PSDRV_ResetClip(dev);
AbortPath( dev->hdc );
if (fill) PSDRV_Brush( ctx, GetPolyFillMode(ctx->dev.hdc) == ALTERNATE );
if (stroke) PSDRV_DrawLine(ctx);
else PSDRV_WriteNewPath(ctx);
PSDRV_ResetClip(ctx);
AbortPath( ctx->dev.hdc );
done:
HeapFree( GetProcessHeap(), 0, points );
......@@ -541,23 +538,23 @@ done:
/***********************************************************************
* PSDRV_FillPath
*/
BOOL CDECL PSDRV_FillPath( PHYSDEV dev )
BOOL CDECL PSDRV_FillPath( print_ctx *ctx )
{
return paint_path( dev, FALSE, TRUE );
return paint_path( ctx, FALSE, TRUE );
}
/***********************************************************************
* PSDRV_StrokeAndFillPath
*/
BOOL CDECL PSDRV_StrokeAndFillPath( PHYSDEV dev )
BOOL CDECL PSDRV_StrokeAndFillPath( print_ctx *ctx )
{
return paint_path( dev, TRUE, TRUE );
return paint_path( ctx, TRUE, TRUE );
}
/***********************************************************************
* PSDRV_StrokePath
*/
BOOL CDECL PSDRV_StrokePath( PHYSDEV dev )
BOOL CDECL PSDRV_StrokePath( print_ctx *ctx )
{
return paint_path( dev, TRUE, FALSE );
return paint_path( ctx, TRUE, FALSE );
}
......@@ -219,122 +219,122 @@ static void dump_devmode(const DEVMODEW *dm)
TRACE("dmPelsHeight %lu\n", dm->dmPelsHeight);
}
static void PSDRV_UpdateDevCaps( PSDRV_PDEVICE *physDev )
static void PSDRV_UpdateDevCaps( print_ctx *ctx )
{
PAGESIZE *page;
RESOLUTION *res;
INT width = 0, height = 0, resx = 0, resy = 0;
dump_devmode(&physDev->Devmode->dmPublic);
dump_devmode(&ctx->Devmode->dmPublic);
if (physDev->Devmode->dmPublic.dmFields & (DM_PRINTQUALITY | DM_YRESOLUTION | DM_LOGPIXELS))
if (ctx->Devmode->dmPublic.dmFields & (DM_PRINTQUALITY | DM_YRESOLUTION | DM_LOGPIXELS))
{
if (physDev->Devmode->dmPublic.dmFields & DM_PRINTQUALITY)
resx = resy = physDev->Devmode->dmPublic.dmPrintQuality;
if (ctx->Devmode->dmPublic.dmFields & DM_PRINTQUALITY)
resx = resy = ctx->Devmode->dmPublic.dmPrintQuality;
if (physDev->Devmode->dmPublic.dmFields & DM_YRESOLUTION)
resy = physDev->Devmode->dmPublic.dmYResolution;
if (ctx->Devmode->dmPublic.dmFields & DM_YRESOLUTION)
resy = ctx->Devmode->dmPublic.dmYResolution;
if (physDev->Devmode->dmPublic.dmFields & DM_LOGPIXELS)
resx = resy = physDev->Devmode->dmPublic.dmLogPixels;
if (ctx->Devmode->dmPublic.dmFields & DM_LOGPIXELS)
resx = resy = ctx->Devmode->dmPublic.dmLogPixels;
LIST_FOR_EACH_ENTRY(res, &physDev->pi->ppd->Resolutions, RESOLUTION, entry)
LIST_FOR_EACH_ENTRY(res, &ctx->pi->ppd->Resolutions, RESOLUTION, entry)
{
if (res->resx == resx && res->resy == resy)
{
physDev->logPixelsX = resx;
physDev->logPixelsY = resy;
ctx->logPixelsX = resx;
ctx->logPixelsY = resy;
break;
}
}
if (&res->entry == &physDev->pi->ppd->Resolutions)
if (&res->entry == &ctx->pi->ppd->Resolutions)
{
WARN("Requested resolution %dx%d is not supported by device\n", resx, resy);
physDev->logPixelsX = physDev->pi->ppd->DefaultResolution;
physDev->logPixelsY = physDev->logPixelsX;
ctx->logPixelsX = ctx->pi->ppd->DefaultResolution;
ctx->logPixelsY = ctx->logPixelsX;
}
}
else
{
WARN("Using default device resolution %d\n", physDev->pi->ppd->DefaultResolution);
physDev->logPixelsX = physDev->pi->ppd->DefaultResolution;
physDev->logPixelsY = physDev->logPixelsX;
WARN("Using default device resolution %d\n", ctx->pi->ppd->DefaultResolution);
ctx->logPixelsX = ctx->pi->ppd->DefaultResolution;
ctx->logPixelsY = ctx->logPixelsX;
}
if(physDev->Devmode->dmPublic.dmFields & DM_PAPERSIZE) {
LIST_FOR_EACH_ENTRY(page, &physDev->pi->ppd->PageSizes, PAGESIZE, entry) {
if(page->WinPage == physDev->Devmode->dmPublic.dmPaperSize)
if(ctx->Devmode->dmPublic.dmFields & DM_PAPERSIZE) {
LIST_FOR_EACH_ENTRY(page, &ctx->pi->ppd->PageSizes, PAGESIZE, entry) {
if(page->WinPage == ctx->Devmode->dmPublic.dmPaperSize)
break;
}
if(&page->entry == &physDev->pi->ppd->PageSizes) {
if(&page->entry == &ctx->pi->ppd->PageSizes) {
FIXME("Can't find page\n");
SetRectEmpty(&physDev->ImageableArea);
physDev->PageSize.cx = 0;
physDev->PageSize.cy = 0;
SetRectEmpty(&ctx->ImageableArea);
ctx->PageSize.cx = 0;
ctx->PageSize.cy = 0;
} else if(page->ImageableArea) {
/* physDev sizes in device units; ppd sizes in 1/72" */
SetRect(&physDev->ImageableArea, page->ImageableArea->llx * physDev->logPixelsX / 72,
page->ImageableArea->ury * physDev->logPixelsY / 72,
page->ImageableArea->urx * physDev->logPixelsX / 72,
page->ImageableArea->lly * physDev->logPixelsY / 72);
physDev->PageSize.cx = page->PaperDimension->x *
physDev->logPixelsX / 72;
physDev->PageSize.cy = page->PaperDimension->y *
physDev->logPixelsY / 72;
/* ctx sizes in device units; ppd sizes in 1/72" */
SetRect(&ctx->ImageableArea, page->ImageableArea->llx * ctx->logPixelsX / 72,
page->ImageableArea->ury * ctx->logPixelsY / 72,
page->ImageableArea->urx * ctx->logPixelsX / 72,
page->ImageableArea->lly * ctx->logPixelsY / 72);
ctx->PageSize.cx = page->PaperDimension->x *
ctx->logPixelsX / 72;
ctx->PageSize.cy = page->PaperDimension->y *
ctx->logPixelsY / 72;
} else {
physDev->ImageableArea.left = physDev->ImageableArea.bottom = 0;
physDev->ImageableArea.right = physDev->PageSize.cx =
page->PaperDimension->x * physDev->logPixelsX / 72;
physDev->ImageableArea.top = physDev->PageSize.cy =
page->PaperDimension->y * physDev->logPixelsY / 72;
ctx->ImageableArea.left = ctx->ImageableArea.bottom = 0;
ctx->ImageableArea.right = ctx->PageSize.cx =
page->PaperDimension->x * ctx->logPixelsX / 72;
ctx->ImageableArea.top = ctx->PageSize.cy =
page->PaperDimension->y * ctx->logPixelsY / 72;
}
} else if((physDev->Devmode->dmPublic.dmFields & DM_PAPERLENGTH) &&
(physDev->Devmode->dmPublic.dmFields & DM_PAPERWIDTH)) {
/* physDev sizes in device units; Devmode sizes in 1/10 mm */
physDev->ImageableArea.left = physDev->ImageableArea.bottom = 0;
physDev->ImageableArea.right = physDev->PageSize.cx =
physDev->Devmode->dmPublic.dmPaperWidth * physDev->logPixelsX / 254;
physDev->ImageableArea.top = physDev->PageSize.cy =
physDev->Devmode->dmPublic.dmPaperLength * physDev->logPixelsY / 254;
} else if((ctx->Devmode->dmPublic.dmFields & DM_PAPERLENGTH) &&
(ctx->Devmode->dmPublic.dmFields & DM_PAPERWIDTH)) {
/* ctx sizes in device units; Devmode sizes in 1/10 mm */
ctx->ImageableArea.left = ctx->ImageableArea.bottom = 0;
ctx->ImageableArea.right = ctx->PageSize.cx =
ctx->Devmode->dmPublic.dmPaperWidth * ctx->logPixelsX / 254;
ctx->ImageableArea.top = ctx->PageSize.cy =
ctx->Devmode->dmPublic.dmPaperLength * ctx->logPixelsY / 254;
} else {
FIXME("Odd dmFields %lx\n", physDev->Devmode->dmPublic.dmFields);
SetRectEmpty(&physDev->ImageableArea);
physDev->PageSize.cx = 0;
physDev->PageSize.cy = 0;
FIXME("Odd dmFields %lx\n", ctx->Devmode->dmPublic.dmFields);
SetRectEmpty(&ctx->ImageableArea);
ctx->PageSize.cx = 0;
ctx->PageSize.cy = 0;
}
TRACE("ImageableArea = %s: PageSize = %ldx%ld\n", wine_dbgstr_rect(&physDev->ImageableArea),
physDev->PageSize.cx, physDev->PageSize.cy);
TRACE("ImageableArea = %s: PageSize = %ldx%ld\n", wine_dbgstr_rect(&ctx->ImageableArea),
ctx->PageSize.cx, ctx->PageSize.cy);
/* these are in device units */
width = physDev->ImageableArea.right - physDev->ImageableArea.left;
height = physDev->ImageableArea.top - physDev->ImageableArea.bottom;
width = ctx->ImageableArea.right - ctx->ImageableArea.left;
height = ctx->ImageableArea.top - ctx->ImageableArea.bottom;
if(physDev->Devmode->dmPublic.dmOrientation == DMORIENT_PORTRAIT) {
physDev->horzRes = width;
physDev->vertRes = height;
if(ctx->Devmode->dmPublic.dmOrientation == DMORIENT_PORTRAIT) {
ctx->horzRes = width;
ctx->vertRes = height;
} else {
physDev->horzRes = height;
physDev->vertRes = width;
ctx->horzRes = height;
ctx->vertRes = width;
}
/* these are in mm */
physDev->horzSize = (physDev->horzRes * 25.4) / physDev->logPixelsX;
physDev->vertSize = (physDev->vertRes * 25.4) / physDev->logPixelsY;
ctx->horzSize = (ctx->horzRes * 25.4) / ctx->logPixelsX;
ctx->vertSize = (ctx->vertRes * 25.4) / ctx->logPixelsY;
TRACE("devcaps: horzSize = %dmm, vertSize = %dmm, "
"horzRes = %d, vertRes = %d\n",
physDev->horzSize, physDev->vertSize,
physDev->horzRes, physDev->vertRes);
ctx->horzSize, ctx->vertSize,
ctx->horzRes, ctx->vertRes);
}
PSDRV_PDEVICE *create_psdrv_physdev( HDC hdc, const WCHAR *device,
print_ctx *create_print_ctx( HDC hdc, const WCHAR *device,
const PSDRV_DEVMODE *devmode )
{
PRINTERINFO *pi = PSDRV_FindPrinterInfo( device );
PSDRV_PDEVICE *pdev;
print_ctx *ctx;
if (!pi) return NULL;
if (!pi->Fonts)
......@@ -350,43 +350,42 @@ PSDRV_PDEVICE *create_psdrv_physdev( HDC hdc, const WCHAR *device,
}
}
pdev = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*pdev) );
if (!pdev) return NULL;
ctx = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*ctx) );
if (!ctx) return NULL;
pdev->Devmode = HeapAlloc( GetProcessHeap(), 0, sizeof(PSDRV_DEVMODE) );
if (!pdev->Devmode)
ctx->Devmode = HeapAlloc( GetProcessHeap(), 0, sizeof(PSDRV_DEVMODE) );
if (!ctx->Devmode)
{
HeapFree( GetProcessHeap(), 0, pdev );
HeapFree( GetProcessHeap(), 0, ctx );
return NULL;
}
*pdev->Devmode = *pi->Devmode;
pdev->pi = pi;
pdev->logPixelsX = pi->ppd->DefaultResolution;
pdev->logPixelsY = pi->ppd->DefaultResolution;
*ctx->Devmode = *pi->Devmode;
ctx->pi = pi;
ctx->logPixelsX = pi->ppd->DefaultResolution;
ctx->logPixelsY = pi->ppd->DefaultResolution;
if (devmode)
{
dump_devmode( &devmode->dmPublic );
PSDRV_MergeDevmodes( pdev->Devmode, devmode, pi );
PSDRV_MergeDevmodes( ctx->Devmode, devmode, pi );
}
PSDRV_UpdateDevCaps( pdev );
PSDRV_UpdateDevCaps( ctx );
ctx->dev.hdc = hdc;
SelectObject( hdc, GetStockObject( DEVICE_DEFAULT_FONT ));
return pdev;
return ctx;
}
/**********************************************************************
* ResetDC (WINEPS.@)
*/
BOOL CDECL PSDRV_ResetDC( PHYSDEV dev, const DEVMODEW *lpInitData )
BOOL CDECL PSDRV_ResetDC( print_ctx *ctx, const DEVMODEW *lpInitData )
{
PSDRV_PDEVICE *physDev = get_psdrv_dev( dev );
if (lpInitData)
{
PSDRV_MergeDevmodes(physDev->Devmode, (const PSDRV_DEVMODE *)lpInitData, physDev->pi);
PSDRV_UpdateDevCaps(physDev);
PSDRV_MergeDevmodes(ctx->Devmode, (const PSDRV_DEVMODE *)lpInitData, ctx->pi);
PSDRV_UpdateDevCaps(ctx);
}
return TRUE;
}
......
......@@ -37,9 +37,8 @@ static const DWORD PEN_alternate[] = { 1 };
/***********************************************************************
* SelectPen (WINEPS.@)
*/
HPEN CDECL PSDRV_SelectPen( PHYSDEV dev, HPEN hpen, const struct brush_pattern *pattern )
HPEN CDECL PSDRV_SelectPen( print_ctx *ctx, HPEN hpen, const struct brush_pattern *pattern )
{
PSDRV_PDEVICE *physDev = get_psdrv_dev( dev );
LOGPEN logpen;
EXTLOGPEN *elp = NULL;
......@@ -62,78 +61,78 @@ HPEN CDECL PSDRV_SelectPen( PHYSDEV dev, HPEN hpen, const struct brush_pattern *
TRACE("hpen = %p colour = %08lx\n", hpen, logpen.lopnColor);
physDev->pen.width = logpen.lopnWidth.x;
if ((logpen.lopnStyle & PS_GEOMETRIC) || (physDev->pen.width > 1))
ctx->pen.width = logpen.lopnWidth.x;
if ((logpen.lopnStyle & PS_GEOMETRIC) || (ctx->pen.width > 1))
{
physDev->pen.width = PSDRV_XWStoDS( dev, physDev->pen.width );
if(physDev->pen.width < 0) physDev->pen.width = -physDev->pen.width;
ctx->pen.width = PSDRV_XWStoDS( ctx, ctx->pen.width );
if(ctx->pen.width < 0) ctx->pen.width = -ctx->pen.width;
}
if (hpen == GetStockObject( DC_PEN ))
logpen.lopnColor = GetDCPenColor( dev->hdc );
logpen.lopnColor = GetDCPenColor( ctx->dev.hdc );
switch (logpen.lopnStyle & PS_JOIN_MASK)
{
default:
case PS_JOIN_ROUND: physDev->pen.join = 1; break;
case PS_JOIN_BEVEL: physDev->pen.join = 2; break;
case PS_JOIN_MITER: physDev->pen.join = 0; break;
case PS_JOIN_ROUND: ctx->pen.join = 1; break;
case PS_JOIN_BEVEL: ctx->pen.join = 2; break;
case PS_JOIN_MITER: ctx->pen.join = 0; break;
}
switch (logpen.lopnStyle & PS_ENDCAP_MASK)
{
default:
case PS_ENDCAP_ROUND: physDev->pen.endcap = 1; break;
case PS_ENDCAP_SQUARE: physDev->pen.endcap = 2; break;
case PS_ENDCAP_FLAT: physDev->pen.endcap = 0; break;
case PS_ENDCAP_ROUND: ctx->pen.endcap = 1; break;
case PS_ENDCAP_SQUARE: ctx->pen.endcap = 2; break;
case PS_ENDCAP_FLAT: ctx->pen.endcap = 0; break;
}
PSDRV_CreateColor(dev, &physDev->pen.color, logpen.lopnColor);
physDev->pen.style = logpen.lopnStyle & PS_STYLE_MASK;
PSDRV_CreateColor(ctx, &ctx->pen.color, logpen.lopnColor);
ctx->pen.style = logpen.lopnStyle & PS_STYLE_MASK;
switch(physDev->pen.style) {
switch(ctx->pen.style) {
case PS_DASH:
memcpy( physDev->pen.dash, PEN_dash, sizeof(PEN_dash) );
physDev->pen.dash_len = ARRAY_SIZE( PEN_dash );
memcpy( ctx->pen.dash, PEN_dash, sizeof(PEN_dash) );
ctx->pen.dash_len = ARRAY_SIZE( PEN_dash );
break;
case PS_DOT:
memcpy( physDev->pen.dash, PEN_dot, sizeof(PEN_dot) );
physDev->pen.dash_len = ARRAY_SIZE( PEN_dot );
memcpy( ctx->pen.dash, PEN_dot, sizeof(PEN_dot) );
ctx->pen.dash_len = ARRAY_SIZE( PEN_dot );
break;
case PS_DASHDOT:
memcpy( physDev->pen.dash, PEN_dashdot, sizeof(PEN_dashdot) );
physDev->pen.dash_len = ARRAY_SIZE( PEN_dashdot );
memcpy( ctx->pen.dash, PEN_dashdot, sizeof(PEN_dashdot) );
ctx->pen.dash_len = ARRAY_SIZE( PEN_dashdot );
break;
case PS_DASHDOTDOT:
memcpy( physDev->pen.dash, PEN_dashdotdot, sizeof(PEN_dashdotdot) );
physDev->pen.dash_len = ARRAY_SIZE( PEN_dashdotdot );
memcpy( ctx->pen.dash, PEN_dashdotdot, sizeof(PEN_dashdotdot) );
ctx->pen.dash_len = ARRAY_SIZE( PEN_dashdotdot );
break;
case PS_ALTERNATE:
memcpy( physDev->pen.dash, PEN_alternate, sizeof(PEN_alternate) );
physDev->pen.dash_len = ARRAY_SIZE( PEN_alternate );
memcpy( ctx->pen.dash, PEN_alternate, sizeof(PEN_alternate) );
ctx->pen.dash_len = ARRAY_SIZE( PEN_alternate );
break;
case PS_USERSTYLE:
physDev->pen.dash_len = min( elp->elpNumEntries, MAX_DASHLEN );
memcpy( physDev->pen.dash, elp->elpStyleEntry, physDev->pen.dash_len * sizeof(DWORD) );
ctx->pen.dash_len = min( elp->elpNumEntries, MAX_DASHLEN );
memcpy( ctx->pen.dash, elp->elpStyleEntry, ctx->pen.dash_len * sizeof(DWORD) );
break;
default:
physDev->pen.dash_len = 0;
ctx->pen.dash_len = 0;
}
if ((physDev->pen.width > 1) && physDev->pen.dash_len &&
physDev->pen.style != PS_USERSTYLE && physDev->pen.style != PS_ALTERNATE)
if ((ctx->pen.width > 1) && ctx->pen.dash_len &&
ctx->pen.style != PS_USERSTYLE && ctx->pen.style != PS_ALTERNATE)
{
physDev->pen.style = PS_SOLID;
physDev->pen.dash_len = 0;
ctx->pen.style = PS_SOLID;
ctx->pen.dash_len = 0;
}
HeapFree( GetProcessHeap(), 0, elp );
physDev->pen.set = FALSE;
ctx->pen.set = FALSE;
return hpen;
}
......@@ -141,12 +140,10 @@ HPEN CDECL PSDRV_SelectPen( PHYSDEV dev, HPEN hpen, const struct brush_pattern *
/***********************************************************************
* SetDCPenColor (WINEPS.@)
*/
COLORREF CDECL PSDRV_SetDCPenColor( PHYSDEV dev, COLORREF color )
COLORREF CDECL PSDRV_SetDCPenColor( print_ctx *ctx, COLORREF color )
{
PSDRV_PDEVICE *physDev = get_psdrv_dev( dev );
if (GetCurrentObject( dev->hdc, OBJ_PEN ) == GetStockObject( DC_PEN ))
PSDRV_CreateColor( dev, &physDev->pen.color, color );
if (GetCurrentObject( ctx->dev.hdc, OBJ_PEN ) == GetStockObject( DC_PEN ))
PSDRV_CreateColor( ctx, &ctx->pen.color, color );
return color;
}
......@@ -156,16 +153,14 @@ COLORREF CDECL PSDRV_SetDCPenColor( PHYSDEV dev, COLORREF color )
* PSDRV_SetPen
*
*/
BOOL PSDRV_SetPen( PHYSDEV dev )
BOOL PSDRV_SetPen( print_ctx *ctx )
{
PSDRV_PDEVICE *physDev = get_psdrv_dev( dev );
if (physDev->pen.style != PS_NULL) {
PSDRV_WriteSetColor(dev, &physDev->pen.color);
if (ctx->pen.style != PS_NULL) {
PSDRV_WriteSetColor(ctx, &ctx->pen.color);
if(!physDev->pen.set) {
PSDRV_WriteSetPen(dev);
physDev->pen.set = TRUE;
if(!ctx->pen.set) {
PSDRV_WriteSetPen(ctx);
ctx->pen.set = TRUE;
}
}
......
......@@ -43,7 +43,7 @@ struct pp_data
WCHAR *doc_name;
WCHAR *out_file;
PSDRV_PDEVICE *pdev;
print_ctx *ctx;
struct brush_pattern *patterns;
BOOL path;
......@@ -342,7 +342,7 @@ static void get_vis_rectangles(HDC hdc, struct bitblt_coords *dst,
intersect_vis_rectangles(dst, src);
}
static int stretch_blt(PHYSDEV dev, const EMRSTRETCHBLT *blt,
static int stretch_blt(print_ctx *ctx, const EMRSTRETCHBLT *blt,
const BITMAPINFO *bi, const BYTE *src_bits)
{
char dst_buffer[FIELD_OFFSET(BITMAPINFO, bmiColors[256])];
......@@ -355,14 +355,14 @@ static int stretch_blt(PHYSDEV dev, const EMRSTRETCHBLT *blt,
dst.log_y = blt->yDest;
dst.log_width = blt->cxDest;
dst.log_height = blt->cyDest;
dst.layout = GetLayout(dev->hdc);
dst.layout = GetLayout(ctx->dev.hdc);
if (blt->dwRop & NOMIRRORBITMAP)
dst.layout |= LAYOUT_BITMAPORIENTATIONPRESERVED;
if (!blt->cbBmiSrc)
{
get_vis_rectangles(dev->hdc, &dst, NULL, 0, 0, NULL);
return PSDRV_PatBlt(dev, &dst, blt->dwRop);
get_vis_rectangles(ctx->dev.hdc, &dst, NULL, 0, 0, NULL);
return PSDRV_PatBlt(ctx, &dst, blt->dwRop);
}
src.log_x = blt->xSrc;
......@@ -371,13 +371,13 @@ static int stretch_blt(PHYSDEV dev, const EMRSTRETCHBLT *blt,
src.log_height = blt->cySrc;
src.layout = 0;
get_vis_rectangles(dev->hdc, &dst, &blt->xformSrc,
get_vis_rectangles(ctx->dev.hdc, &dst, &blt->xformSrc,
bi->bmiHeader.biWidth, abs(bi->bmiHeader.biHeight), &src);
memcpy(dst_info, bi, blt->cbBmiSrc);
memset(&bits, 0, sizeof(bits));
bits.ptr = (BYTE *)src_bits;
err = PSDRV_PutImage(dev, 0, dst_info, &bits, &src, &dst, blt->dwRop);
err = PSDRV_PutImage(ctx, 0, dst_info, &bits, &src, &dst, blt->dwRop);
if (err == ERROR_BAD_FORMAT)
{
HDC hdc = CreateCompatibleDC(NULL);
......@@ -387,7 +387,7 @@ static int stretch_blt(PHYSDEV dev, const EMRSTRETCHBLT *blt,
bitmap = CreateDIBSection(hdc, dst_info, DIB_RGB_COLORS, &bits.ptr, NULL, 0);
SetDIBits(hdc, bitmap, 0, bi->bmiHeader.biHeight, src_bits, bi, blt->iUsageSrc);
err = PSDRV_PutImage(dev, 0, dst_info, &bits, &src, &dst, blt->dwRop);
err = PSDRV_PutImage(ctx, 0, dst_info, &bits, &src, &dst, blt->dwRop);
DeleteObject(bitmap);
DeleteObject(hdc);
}
......@@ -400,7 +400,7 @@ static int stretch_blt(PHYSDEV dev, const EMRSTRETCHBLT *blt,
#define FRGND_ROP3(ROP4) ((ROP4) & 0x00FFFFFF)
#define BKGND_ROP3(ROP4) (ROP3Table[((ROP4)>>24) & 0xFF])
static int mask_blt(PHYSDEV dev, const EMRMASKBLT *p, const BITMAPINFO *src_bi,
static int mask_blt(print_ctx *ctx, const EMRMASKBLT *p, const BITMAPINFO *src_bi,
const BYTE *src_bits, const BITMAPINFO *mask_bi, const BYTE *mask_bits)
{
HBITMAP bmp1, old_bmp1, bmp2, old_bmp2, bmp_src, old_bmp_src;
......@@ -563,7 +563,7 @@ static int mask_blt(PHYSDEV dev, const EMRMASKBLT *p, const BITMAPINFO *src_bi,
blt.cxSrc = p->cxDest;
blt.cySrc = p->cyDest;
return stretch_blt(dev, &blt, src_bi, src_bits);
return stretch_blt(ctx, &blt, src_bi, src_bits);
}
hdc_src = CreateCompatibleDC(NULL);
......@@ -582,10 +582,10 @@ static int mask_blt(PHYSDEV dev, const EMRMASKBLT *p, const BITMAPINFO *src_bi,
old_bmp_src = SelectObject(hdc_src, bmp_src);
bmp1 = CreateBitmap(mask_bi->bmiHeader.biWidth, mask_bi->bmiHeader.biHeight, 1, 1, NULL);
SetDIBits(dev->hdc, bmp1, 0, mask_bi->bmiHeader.biHeight, mask_bits, mask_bi, p->iUsageMask);
SetDIBits(ctx->dev.hdc, bmp1, 0, mask_bi->bmiHeader.biHeight, mask_bits, mask_bi, p->iUsageMask);
brush_mask = CreatePatternBrush(bmp1);
DeleteObject(bmp1);
brush_dest = SelectObject(dev->hdc, GetStockObject(NULL_BRUSH));
brush_dest = SelectObject(ctx->dev.hdc, GetStockObject(NULL_BRUSH));
/* make bitmap */
hdc1 = CreateCompatibleDC(NULL);
......@@ -639,10 +639,10 @@ static int mask_blt(PHYSDEV dev, const EMRMASKBLT *p, const BITMAPINFO *src_bi,
blt.cxSrc = p->cxDest;
blt.cySrc = p->cyDest;
stretch_blt(dev, &blt, bmp2_info, bits);
stretch_blt(ctx, &blt, bmp2_info, bits);
/* restore all objects */
SelectObject(dev->hdc, brush_dest);
SelectObject(ctx->dev.hdc, brush_dest);
SelectObject(hdc1, old_bmp1);
SelectObject(hdc2, old_bmp2);
SelectObject(hdc_src, old_bmp_src);
......@@ -676,7 +676,7 @@ static void combine_transform(XFORM *result, const XFORM *xform1, const XFORM *x
*result = r;
}
static int plg_blt(PHYSDEV dev, const EMRPLGBLT *p)
static int plg_blt(print_ctx *ctx, const EMRPLGBLT *p)
{
const BITMAPINFO *src_bi, *mask_bi;
const BYTE *src_bits, *mask_bits;
......@@ -723,8 +723,8 @@ static int plg_blt(PHYSDEV dev, const EMRPLGBLT *p)
combine_transform(&xf, &xf, &p->xformSrc);
GetTransform(dev->hdc, 0x203, &xform_dest);
SetWorldTransform(dev->hdc, &xf);
GetTransform(ctx->dev.hdc, 0x203, &xform_dest);
SetWorldTransform(ctx->dev.hdc, &xf);
/* now destination and source DCs use same coords */
maskblt.rclBounds = p->rclBounds;
maskblt.xDest = p->xSrc;
......@@ -752,8 +752,8 @@ static int plg_blt(PHYSDEV dev, const EMRPLGBLT *p)
src_bits = (BYTE *)p + p->offBitsSrc;
mask_bi = (const BITMAPINFO *)((BYTE *)p + p->offBmiMask);
mask_bits = (BYTE *)p + p->offBitsMask;
mask_blt(dev, &maskblt, src_bi, src_bits, mask_bi, mask_bits);
SetWorldTransform(dev->hdc, &xform_dest);
mask_blt(ctx, &maskblt, src_bi, src_bits, mask_bi, mask_bits);
SetWorldTransform(ctx->dev.hdc, &xform_dest);
return TRUE;
}
......@@ -768,7 +768,7 @@ static inline int get_dib_image_size( const BITMAPINFO *info )
* abs( info->bmiHeader.biHeight );
}
static int set_di_bits_to_device(PHYSDEV dev, const EMRSETDIBITSTODEVICE *p)
static int set_di_bits_to_device(print_ctx *ctx, const EMRSETDIBITSTODEVICE *p)
{
const BITMAPINFO *info = (const BITMAPINFO *)((BYTE *)p + p->offBmiSrc);
char bi_buffer[FIELD_OFFSET(BITMAPINFO, bmiColors[256])];
......@@ -796,7 +796,7 @@ static int set_di_bits_to_device(PHYSDEV dev, const EMRSETDIBITSTODEVICE *p)
bi->bmiHeader.biClrUsed = 1 << info->bmiHeader.biBitCount;
bi->bmiHeader.biClrImportant = bi->bmiHeader.biClrUsed;
hpal = GetCurrentObject(dev->hdc, OBJ_PAL);
hpal = GetCurrentObject(ctx->dev.hdc, OBJ_PAL);
size = GetPaletteEntries(hpal, 0, bi->bmiHeader.biClrUsed, pal);
for (i = 0; i < size; i++)
{
......@@ -810,14 +810,14 @@ static int set_di_bits_to_device(PHYSDEV dev, const EMRSETDIBITSTODEVICE *p)
bi->bmiHeader.biBitCount = 24;
}
bi->bmiHeader.biCompression = BI_RGB;
bitmap = CreateDIBSection(dev->hdc, bi, DIB_RGB_COLORS, (void **)&bits, NULL, 0);
bitmap = CreateDIBSection(ctx->dev.hdc, bi, DIB_RGB_COLORS, (void **)&bits, NULL, 0);
if (!bitmap)
return 1;
old_bitmap = SelectObject(dev->hdc, bitmap);
old_bitmap = SelectObject(ctx->dev.hdc, bitmap);
ret = SetDIBitsToDevice(dev->hdc, 0, 0, width, height, p->xSrc, p->ySrc,
ret = SetDIBitsToDevice(ctx->dev.hdc, 0, 0, width, height, p->xSrc, p->ySrc,
p->iStartScan, p->cScans, (const BYTE*)p + p->offBitsSrc, info, p->iUsageSrc);
SelectObject(dev->hdc, old_bitmap);
SelectObject(ctx->dev.hdc, old_bitmap);
if (ret)
{
EMRSTRETCHBLT blt;
......@@ -836,14 +836,14 @@ static int set_di_bits_to_device(PHYSDEV dev, const EMRSETDIBITSTODEVICE *p)
blt.cbBitsSrc = get_dib_image_size(bi);
blt.cxSrc = blt.cxDest;
blt.cySrc = blt.cyDest;
stretch_blt(dev, &blt, bi, bits);
stretch_blt(ctx, &blt, bi, bits);
}
DeleteObject(bitmap);
return 1;
}
static int stretch_di_bits(PHYSDEV dev, const EMRSTRETCHDIBITS *p)
static int stretch_di_bits(print_ctx *ctx, const EMRSTRETCHDIBITS *p)
{
char bi_buffer[FIELD_OFFSET(BITMAPINFO, bmiColors[256])];
const BYTE *bits = (BYTE *)p + p->offBitsSrc;
......@@ -860,7 +860,7 @@ static int stretch_di_bits(PHYSDEV dev, const EMRSTRETCHDIBITS *p)
HPALETTE hpal;
UINT i, size;
hpal = GetCurrentObject(dev->hdc, OBJ_PAL);
hpal = GetCurrentObject(ctx->dev.hdc, OBJ_PAL);
size = GetPaletteEntries(hpal, 0, 1 << bi->bmiHeader.biBitCount, pal);
for (i = 0; i < size; i++)
{
......@@ -886,10 +886,10 @@ static int stretch_di_bits(PHYSDEV dev, const EMRSTRETCHDIBITS *p)
blt.cbBitsSrc = p->cbBitsSrc;
blt.cxSrc = p->cxSrc;
blt.cySrc = p->cySrc;
return stretch_blt(dev, &blt, bi, bits);
return stretch_blt(ctx, &blt, bi, bits);
}
static int poly_draw(PHYSDEV dev, const POINT *points, const BYTE *types, DWORD count)
static int poly_draw(print_ctx *ctx, const POINT *points, const BYTE *types, DWORD count)
{
POINT first, cur, pts[4];
DWORD i, num_pts;
......@@ -914,7 +914,7 @@ static int poly_draw(PHYSDEV dev, const POINT *points, const BYTE *types, DWORD
}
}
GetCurrentPositionEx(dev->hdc, &cur);
GetCurrentPositionEx(ctx->dev.hdc, &cur);
first = cur;
for (i = 0; i < count; i++)
......@@ -929,7 +929,7 @@ static int poly_draw(PHYSDEV dev, const POINT *points, const BYTE *types, DWORD
pts[0] = cur;
pts[1] = points[i];
num_pts = 2;
if (!PSDRV_PolyPolyline(dev, pts, &num_pts, 1))
if (!PSDRV_PolyPolyline(ctx, pts, &num_pts, 1))
return FALSE;
break;
case PT_BEZIERTO:
......@@ -937,7 +937,7 @@ static int poly_draw(PHYSDEV dev, const POINT *points, const BYTE *types, DWORD
pts[1] = points[i];
pts[2] = points[i + 1];
pts[3] = points[i + 2];
if (!PSDRV_PolyBezier(dev, pts, 4))
if (!PSDRV_PolyBezier(ctx, pts, 4))
return FALSE;
i += 2;
break;
......@@ -949,7 +949,7 @@ static int poly_draw(PHYSDEV dev, const POINT *points, const BYTE *types, DWORD
pts[0] = cur;
pts[1] = first;
num_pts = 2;
if (!PSDRV_PolyPolyline(dev, pts, &num_pts, 1))
if (!PSDRV_PolyPolyline(ctx, pts, &num_pts, 1))
return FALSE;
}
}
......@@ -963,7 +963,7 @@ static inline void reset_bounds(RECT *bounds)
bounds->right = bounds->bottom = INT_MIN;
}
static BOOL gradient_fill(PHYSDEV dev, const TRIVERTEX *vert_array, DWORD nvert,
static BOOL gradient_fill(print_ctx *ctx, const TRIVERTEX *vert_array, DWORD nvert,
const void *grad_array, DWORD ngrad, ULONG mode)
{
char buffer[FIELD_OFFSET(BITMAPINFO, bmiColors[256])];
......@@ -980,7 +980,7 @@ static BOOL gradient_fill(PHYSDEV dev, const TRIVERTEX *vert_array, DWORD nvert,
if (!(pts = malloc(nvert * sizeof(*pts)))) return FALSE;
memcpy(pts, vert_array, sizeof(*pts) * nvert);
for (i = 0; i < nvert; i++)
LPtoDP(dev->hdc, (POINT *)&pts[i], 1);
LPtoDP(ctx->dev.hdc, (POINT *)&pts[i], 1);
/* compute bounding rect of all the rectangles/triangles */
reset_bounds(&dst.visrect);
......@@ -997,7 +997,7 @@ static BOOL gradient_fill(PHYSDEV dev, const TRIVERTEX *vert_array, DWORD nvert,
dst.y = dst.visrect.top;
dst.width = dst.visrect.right - dst.visrect.left;
dst.height = dst.visrect.bottom - dst.visrect.top;
clip_visrect(dev->hdc, &dst.visrect, &dst.visrect);
clip_visrect(ctx->dev.hdc, &dst.visrect, &dst.visrect);
info->bmiHeader.biSize = sizeof(info->bmiHeader);
info->bmiHeader.biPlanes = 1;
......@@ -1077,7 +1077,7 @@ static BOOL gradient_fill(PHYSDEV dev, const TRIVERTEX *vert_array, DWORD nvert,
OffsetRgn(rgn, dst.visrect.left, dst.visrect.top);
if (ret)
ret = (PSDRV_PutImage(dev, rgn, info, &bits, &src, &dst, SRCCOPY) == ERROR_SUCCESS);
ret = (PSDRV_PutImage(ctx, rgn, info, &bits, &src, &dst, SRCCOPY) == ERROR_SUCCESS);
DeleteObject(rgn);
DeleteObject(bmp);
return ret;
......@@ -1109,7 +1109,7 @@ static BOOL select_hbrush(struct pp_data *data, HANDLETABLE *htable, int handle_
}
}
return PSDRV_SelectBrush(&data->pdev->dev, brush, pattern) != NULL;
return PSDRV_SelectBrush(data->ctx, brush, pattern) != NULL;
}
/* Performs a device to world transformation on the specified size (which
......@@ -1730,7 +1730,7 @@ static BOOL ext_text_out(struct pp_data *data, HANDLETABLE *htable,
int handle_count, INT x, INT y, UINT flags, const RECT *rect,
const WCHAR *str, UINT count, const INT *dx)
{
HDC hdc = data->pdev->dev.hdc;
HDC hdc = data->ctx->dev.hdc;
BOOL ret = FALSE;
UINT align;
DWORD layout;
......@@ -1819,7 +1819,7 @@ static BOOL ext_text_out(struct pp_data *data, HANDLETABLE *htable,
LPtoDP(hdc, (POINT*)&rc, 2);
order_rect(&rc);
if (flags & ETO_OPAQUE)
PSDRV_ExtTextOut(&data->pdev->dev, 0, 0, ETO_OPAQUE, &rc, NULL, 0, NULL);
PSDRV_ExtTextOut(data->ctx, 0, 0, ETO_OPAQUE, &rc, NULL, 0, NULL);
}
else flags &= ~ETO_CLIPPED;
......@@ -1995,12 +1995,12 @@ static BOOL ext_text_out(struct pp_data *data, HANDLETABLE *htable,
if (flags & ETO_CLIPPED) intersect_rect(&text_box, &text_box, &rc);
if (!IsRectEmpty(&text_box))
PSDRV_ExtTextOut(&data->pdev->dev, 0, 0, ETO_OPAQUE, &text_box, NULL, 0, NULL);
PSDRV_ExtTextOut(data->ctx, 0, 0, ETO_OPAQUE, &text_box, NULL, 0, NULL);
}
}
}
ret = PSDRV_ExtTextOut(&data->pdev->dev, x, y, (flags & ~ETO_OPAQUE), &rc,
ret = PSDRV_ExtTextOut(data->ctx, x, y, (flags & ~ETO_OPAQUE), &rc,
str, count, (INT*)deltas);
done:
......@@ -2016,10 +2016,10 @@ done:
HBRUSH hbrush = CreateSolidBrush(GetTextColor(hdc));
HPEN hpen = GetStockObject(NULL_PEN);
PSDRV_SelectPen(&data->pdev->dev, hpen, NULL);
PSDRV_SelectPen(data->ctx, hpen, NULL);
hpen = SelectObject(hdc, hpen);
PSDRV_SelectBrush(&data->pdev->dev, hbrush, NULL);
PSDRV_SelectBrush(data->ctx, hbrush, NULL);
hbrush = SelectObject(hdc, hbrush);
if(!size)
......@@ -2057,7 +2057,7 @@ done:
pts[4].x = pts[0].x;
pts[4].y = pts[0].y;
DPtoLP(hdc, pts, 5);
PSDRV_PolyPolygon(&data->pdev->dev, pts, &cnt, 1);
PSDRV_PolyPolygon(data->ctx, pts, &cnt, 1);
}
if (lf.lfStrikeOut)
......@@ -2074,10 +2074,10 @@ done:
pts[4].x = pts[0].x;
pts[4].y = pts[0].y;
DPtoLP(hdc, pts, 5);
PSDRV_PolyPolygon(&data->pdev->dev, pts, &cnt, 1);
PSDRV_PolyPolygon(data->ctx, pts, &cnt, 1);
}
PSDRV_SelectPen(&data->pdev->dev, hpen, NULL);
PSDRV_SelectPen(data->ctx, hpen, NULL);
SelectObject(hdc, hpen);
select_hbrush(data, htable, handle_count, hbrush);
SelectObject(hdc, hbrush);
......@@ -2095,10 +2095,10 @@ static BOOL fill_rgn(struct pp_data *data, HANDLETABLE *htable, int handle_count
int ret;
hbrush = get_object_handle(data, htable, brush, &pattern);
PSDRV_SelectBrush(&data->pdev->dev, hbrush, pattern);
ret = PSDRV_PaintRgn(&data->pdev->dev, rgn);
select_hbrush(data, htable, handle_count, GetCurrentObject(data->pdev->dev.hdc, OBJ_BRUSH));
PSDRV_SelectBrush(&data->pdev->dev, hbrush, pattern);
PSDRV_SelectBrush(data->ctx, hbrush, pattern);
ret = PSDRV_PaintRgn(data->ctx, rgn);
select_hbrush(data, htable, handle_count, GetCurrentObject(data->ctx->dev.hdc, OBJ_BRUSH));
PSDRV_SelectBrush(data->ctx, hbrush, pattern);
return ret;
}
......@@ -2146,7 +2146,7 @@ static int WINAPI hmf_proc(HDC hdc, HANDLETABLE *htable,
struct pp_data *data = (struct pp_data *)arg;
if (data->path && is_path_record(rec->iType))
return PlayEnhMetaFileRecord(data->pdev->dev.hdc, htable, rec, handle_count);
return PlayEnhMetaFileRecord(data->ctx->dev.hdc, htable, rec, handle_count);
switch (rec->iType)
{
......@@ -2155,34 +2155,34 @@ static int WINAPI hmf_proc(HDC hdc, HANDLETABLE *htable,
const ENHMETAHEADER *header = (const ENHMETAHEADER *)rec;
data->patterns = calloc(sizeof(*data->patterns), header->nHandles);
return data->patterns && PSDRV_StartPage(&data->pdev->dev);
return data->patterns && PSDRV_StartPage(data->ctx);
}
case EMR_POLYBEZIER:
{
const EMRPOLYBEZIER *p = (const EMRPOLYBEZIER *)rec;
return PSDRV_PolyBezier(&data->pdev->dev, (const POINT *)p->aptl, p->cptl);
return PSDRV_PolyBezier(data->ctx, (const POINT *)p->aptl, p->cptl);
}
case EMR_POLYGON:
{
const EMRPOLYGON *p = (const EMRPOLYGON *)rec;
return PSDRV_PolyPolygon(&data->pdev->dev, (const POINT *)p->aptl,
return PSDRV_PolyPolygon(data->ctx, (const POINT *)p->aptl,
(const INT *)&p->cptl, 1);
}
case EMR_POLYLINE:
{
const EMRPOLYLINE *p = (const EMRPOLYLINE *)rec;
return PSDRV_PolyPolyline(&data->pdev->dev,
return PSDRV_PolyPolyline(data->ctx,
(const POINT *)p->aptl, &p->cptl, 1);
}
case EMR_POLYBEZIERTO:
{
const EMRPOLYBEZIERTO *p = (const EMRPOLYBEZIERTO *)rec;
return PSDRV_PolyBezierTo(&data->pdev->dev, (const POINT *)p->aptl, p->cptl) &&
MoveToEx(data->pdev->dev.hdc, p->aptl[p->cptl - 1].x, p->aptl[p->cptl - 1].y, NULL);
return PSDRV_PolyBezierTo(data->ctx, (const POINT *)p->aptl, p->cptl) &&
MoveToEx(data->ctx->dev.hdc, p->aptl[p->cptl - 1].x, p->aptl[p->cptl - 1].y, NULL);
}
case EMR_POLYLINETO:
{
......@@ -2195,10 +2195,10 @@ static int WINAPI hmf_proc(HDC hdc, HANDLETABLE *htable,
pts = malloc(sizeof(*pts) * cnt);
if (!pts) return 0;
GetCurrentPositionEx(data->pdev->dev.hdc, pts);
GetCurrentPositionEx(data->ctx->dev.hdc, pts);
memcpy(pts + 1, p->aptl, sizeof(*pts) * p->cptl);
ret = PSDRV_PolyPolyline(&data->pdev->dev, pts, &cnt, 1) &&
MoveToEx(data->pdev->dev.hdc, pts[cnt - 1].x, pts[cnt - 1].y, NULL);
ret = PSDRV_PolyPolyline(data->ctx, pts, &cnt, 1) &&
MoveToEx(data->ctx->dev.hdc, pts[cnt - 1].x, pts[cnt - 1].y, NULL);
free(pts);
return ret;
}
......@@ -2206,7 +2206,7 @@ static int WINAPI hmf_proc(HDC hdc, HANDLETABLE *htable,
{
const EMRPOLYPOLYLINE *p = (const EMRPOLYPOLYLINE *)rec;
return PSDRV_PolyPolyline(&data->pdev->dev,
return PSDRV_PolyPolyline(data->ctx,
(const POINT *)(p->aPolyCounts + p->nPolys),
p->aPolyCounts, p->nPolys);
}
......@@ -2214,33 +2214,33 @@ static int WINAPI hmf_proc(HDC hdc, HANDLETABLE *htable,
{
const EMRPOLYPOLYGON *p = (const EMRPOLYPOLYGON *)rec;
return PSDRV_PolyPolygon(&data->pdev->dev,
return PSDRV_PolyPolygon(data->ctx,
(const POINT *)(p->aPolyCounts + p->nPolys),
(const INT *)p->aPolyCounts, p->nPolys);
}
case EMR_EOF:
return PSDRV_EndPage(&data->pdev->dev);
return PSDRV_EndPage(data->ctx);
case EMR_SETPIXELV:
{
const EMRSETPIXELV *p = (const EMRSETPIXELV *)rec;
return PSDRV_SetPixel(&data->pdev->dev, p->ptlPixel.x,
return PSDRV_SetPixel(data->ctx, p->ptlPixel.x,
p->ptlPixel.y, p->crColor);
}
case EMR_SETTEXTCOLOR:
{
const EMRSETTEXTCOLOR *p = (const EMRSETTEXTCOLOR *)rec;
SetTextColor(data->pdev->dev.hdc, p->crColor);
PSDRV_SetTextColor(&data->pdev->dev, p->crColor);
SetTextColor(data->ctx->dev.hdc, p->crColor);
PSDRV_SetTextColor(data->ctx, p->crColor);
return 1;
}
case EMR_SETBKCOLOR:
{
const EMRSETBKCOLOR *p = (const EMRSETBKCOLOR *)rec;
SetBkColor(data->pdev->dev.hdc, p->crColor);
PSDRV_SetBkColor(&data->pdev->dev, p->crColor);
SetBkColor(data->ctx->dev.hdc, p->crColor);
PSDRV_SetBkColor(data->ctx, p->crColor);
return 1;
}
case EMR_SAVEDC:
......@@ -2274,17 +2274,17 @@ static int WINAPI hmf_proc(HDC hdc, HANDLETABLE *htable,
case EMR_RESTOREDC:
{
const EMRRESTOREDC *p = (const EMRRESTOREDC *)rec;
HDC hdc = data->pdev->dev.hdc;
HDC hdc = data->ctx->dev.hdc;
int ret = PlayEnhMetaFileRecord(hdc, htable, rec, handle_count);
UINT aa_flags;
if (ret)
{
select_hbrush(data, htable, handle_count, GetCurrentObject(hdc, OBJ_BRUSH));
PSDRV_SelectFont(&data->pdev->dev, GetCurrentObject(hdc, OBJ_FONT), &aa_flags);
PSDRV_SelectPen(&data->pdev->dev, GetCurrentObject(hdc, OBJ_PEN), NULL);
PSDRV_SetBkColor(&data->pdev->dev, GetBkColor(hdc));
PSDRV_SetTextColor(&data->pdev->dev, GetTextColor(hdc));
PSDRV_SelectFont(data->ctx, GetCurrentObject(hdc, OBJ_FONT), &aa_flags);
PSDRV_SelectPen(data->ctx, GetCurrentObject(hdc, OBJ_PEN), NULL);
PSDRV_SetBkColor(data->ctx, GetBkColor(hdc));
PSDRV_SetTextColor(data->ctx, GetTextColor(hdc));
if (p->iRelative >= 0 || data->saved_dc_top + p->iRelative < 0)
return 0;
......@@ -2302,13 +2302,13 @@ static int WINAPI hmf_proc(HDC hdc, HANDLETABLE *htable,
HGDIOBJ obj;
obj = get_object_handle(data, htable, so->ihObject, &pattern);
SelectObject(data->pdev->dev.hdc, obj);
SelectObject(data->ctx->dev.hdc, obj);
switch (GetObjectType(obj))
{
case OBJ_PEN: return PSDRV_SelectPen(&data->pdev->dev, obj, NULL) != NULL;
case OBJ_BRUSH: return PSDRV_SelectBrush(&data->pdev->dev, obj, pattern) != NULL;
case OBJ_FONT: return PSDRV_SelectFont(&data->pdev->dev, obj, &aa_flags) != NULL;
case OBJ_PEN: return PSDRV_SelectPen(data->ctx, obj, NULL) != NULL;
case OBJ_BRUSH: return PSDRV_SelectBrush(data->ctx, obj, pattern) != NULL;
case OBJ_FONT: return PSDRV_SelectFont(data->ctx, obj, &aa_flags) != NULL;
default:
FIXME("unhandled object type %ld\n", GetObjectType(obj));
return 1;
......@@ -2319,12 +2319,12 @@ static int WINAPI hmf_proc(HDC hdc, HANDLETABLE *htable,
const EMRDELETEOBJECT *p = (const EMRDELETEOBJECT *)rec;
memset(&data->patterns[p->ihObject], 0, sizeof(*data->patterns));
return PlayEnhMetaFileRecord(data->pdev->dev.hdc, htable, rec, handle_count);
return PlayEnhMetaFileRecord(data->ctx->dev.hdc, htable, rec, handle_count);
}
case EMR_ANGLEARC:
{
const EMRANGLEARC *p = (const EMRANGLEARC *)rec;
int arc_dir = SetArcDirection(data->pdev->dev.hdc,
int arc_dir = SetArcDirection(data->ctx->dev.hdc,
p->eSweepAngle >= 0 ? AD_COUNTERCLOCKWISE : AD_CLOCKWISE);
EMRARCTO arcto;
int ret;
......@@ -2344,7 +2344,7 @@ static int WINAPI hmf_proc(HDC hdc, HANDLETABLE *htable,
sin((p->eStartAngle + p->eSweepAngle) * M_PI / 180) * p->nRadius);
ret = hmf_proc(hdc, htable, (ENHMETARECORD *)&arcto, handle_count, arg);
SetArcDirection(data->pdev->dev.hdc, arc_dir);
SetArcDirection(data->ctx->dev.hdc, arc_dir);
return ret;
}
case EMR_ELLIPSE:
......@@ -2352,20 +2352,20 @@ static int WINAPI hmf_proc(HDC hdc, HANDLETABLE *htable,
const EMRELLIPSE *p = (const EMRELLIPSE *)rec;
const RECTL *r = &p->rclBox;
return PSDRV_Ellipse(&data->pdev->dev, r->left, r->top, r->right, r->bottom);
return PSDRV_Ellipse(data->ctx, r->left, r->top, r->right, r->bottom);
}
case EMR_RECTANGLE:
{
const EMRRECTANGLE *rect = (const EMRRECTANGLE *)rec;
return PSDRV_Rectangle(&data->pdev->dev, rect->rclBox.left,
return PSDRV_Rectangle(data->ctx, rect->rclBox.left,
rect->rclBox.top, rect->rclBox.right, rect->rclBox.bottom);
}
case EMR_ROUNDRECT:
{
const EMRROUNDRECT *p = (const EMRROUNDRECT *)rec;
return PSDRV_RoundRect(&data->pdev->dev, p->rclBox.left,
return PSDRV_RoundRect(data->ctx, p->rclBox.left,
p->rclBox.top, p->rclBox.right, p->rclBox.bottom,
p->szlCorner.cx, p->szlCorner.cy);
}
......@@ -2373,7 +2373,7 @@ static int WINAPI hmf_proc(HDC hdc, HANDLETABLE *htable,
{
const EMRARC *p = (const EMRARC *)rec;
return PSDRV_Arc(&data->pdev->dev, p->rclBox.left, p->rclBox.top,
return PSDRV_Arc(data->ctx, p->rclBox.left, p->rclBox.top,
p->rclBox.right, p->rclBox.bottom, p->ptlStart.x,
p->ptlStart.y, p->ptlEnd.x, p->ptlEnd.y);
}
......@@ -2381,7 +2381,7 @@ static int WINAPI hmf_proc(HDC hdc, HANDLETABLE *htable,
{
const EMRCHORD *p = (const EMRCHORD *)rec;
return PSDRV_Chord(&data->pdev->dev, p->rclBox.left, p->rclBox.top,
return PSDRV_Chord(data->ctx, p->rclBox.left, p->rclBox.top,
p->rclBox.right, p->rclBox.bottom, p->ptlStart.x,
p->ptlStart.y, p->ptlEnd.x, p->ptlEnd.y);
}
......@@ -2389,7 +2389,7 @@ static int WINAPI hmf_proc(HDC hdc, HANDLETABLE *htable,
{
const EMRPIE *p = (const EMRPIE *)rec;
return PSDRV_Pie(&data->pdev->dev, p->rclBox.left, p->rclBox.top,
return PSDRV_Pie(data->ctx, p->rclBox.left, p->rclBox.top,
p->rclBox.right, p->rclBox.bottom, p->ptlStart.x,
p->ptlStart.y, p->ptlEnd.x, p->ptlEnd.y);
}
......@@ -2397,8 +2397,8 @@ static int WINAPI hmf_proc(HDC hdc, HANDLETABLE *htable,
{
const EMRLINETO *line = (const EMRLINETO *)rec;
return PSDRV_LineTo(&data->pdev->dev, line->ptl.x, line->ptl.y) &&
MoveToEx(data->pdev->dev.hdc, line->ptl.x, line->ptl.y, NULL);
return PSDRV_LineTo(data->ctx, line->ptl.x, line->ptl.y) &&
MoveToEx(data->ctx->dev.hdc, line->ptl.x, line->ptl.y, NULL);
}
case EMR_ARCTO:
{
......@@ -2406,24 +2406,24 @@ static int WINAPI hmf_proc(HDC hdc, HANDLETABLE *htable,
POINT pt;
BOOL ret;
ret = GetCurrentPositionEx(data->pdev->dev.hdc, &pt);
ret = GetCurrentPositionEx(data->ctx->dev.hdc, &pt);
if (ret)
{
ret = ArcTo(data->pdev->dev.hdc, p->rclBox.left, p->rclBox.top,
ret = ArcTo(data->ctx->dev.hdc, p->rclBox.left, p->rclBox.top,
p->rclBox.right, p->rclBox.bottom, p->ptlStart.x,
p->ptlStart.y, p->ptlStart.x, p->ptlStart.y);
}
if (ret)
ret = PSDRV_LineTo(&data->pdev->dev, pt.x, pt.y);
ret = PSDRV_LineTo(data->ctx, pt.x, pt.y);
if (ret)
{
ret = PSDRV_Arc(&data->pdev->dev, p->rclBox.left, p->rclBox.top,
ret = PSDRV_Arc(data->ctx, p->rclBox.left, p->rclBox.top,
p->rclBox.right, p->rclBox.bottom, p->ptlStart.x,
p->ptlStart.y, p->ptlEnd.x, p->ptlEnd.y);
}
if (ret)
{
ret = ArcTo(data->pdev->dev.hdc, p->rclBox.left, p->rclBox.top,
ret = ArcTo(data->ctx->dev.hdc, p->rclBox.left, p->rclBox.top,
p->rclBox.right, p->rclBox.bottom, p->ptlEnd.x,
p->ptlEnd.y, p->ptlEnd.x, p->ptlEnd.y);
}
......@@ -2434,32 +2434,32 @@ static int WINAPI hmf_proc(HDC hdc, HANDLETABLE *htable,
const EMRPOLYDRAW *p = (const EMRPOLYDRAW *)rec;
const POINT *pts = (const POINT *)p->aptl;
return poly_draw(&data->pdev->dev, pts, (BYTE *)(p->aptl + p->cptl), p->cptl) &&
MoveToEx(data->pdev->dev.hdc, pts[p->cptl - 1].x, pts[p->cptl - 1].y, NULL);
return poly_draw(data->ctx, pts, (BYTE *)(p->aptl + p->cptl), p->cptl) &&
MoveToEx(data->ctx->dev.hdc, pts[p->cptl - 1].x, pts[p->cptl - 1].y, NULL);
}
case EMR_BEGINPATH:
{
data->path = TRUE;
return PlayEnhMetaFileRecord(data->pdev->dev.hdc, htable, rec, handle_count);
return PlayEnhMetaFileRecord(data->ctx->dev.hdc, htable, rec, handle_count);
}
case EMR_ENDPATH:
{
data->path = FALSE;
return PlayEnhMetaFileRecord(data->pdev->dev.hdc, htable, rec, handle_count);
return PlayEnhMetaFileRecord(data->ctx->dev.hdc, htable, rec, handle_count);
}
case EMR_FILLPATH:
PSDRV_FillPath(&data->pdev->dev);
PSDRV_FillPath(data->ctx);
return 1;
case EMR_STROKEANDFILLPATH:
PSDRV_StrokeAndFillPath(&data->pdev->dev);
PSDRV_StrokeAndFillPath(data->ctx);
return 1;
case EMR_STROKEPATH:
PSDRV_StrokePath(&data->pdev->dev);
PSDRV_StrokePath(data->ctx);
return 1;
case EMR_ABORTPATH:
{
data->path = FALSE;
return PlayEnhMetaFileRecord(data->pdev->dev.hdc, htable, rec, handle_count);
return PlayEnhMetaFileRecord(data->ctx->dev.hdc, htable, rec, handle_count);
}
case EMR_FILLRGN:
{
......@@ -2504,9 +2504,9 @@ static int WINAPI hmf_proc(HDC hdc, HANDLETABLE *htable,
HRGN rgn;
rgn = ExtCreateRegion(NULL, p->cbRgnData, (const RGNDATA *)p->RgnData);
old_rop = SetROP2(data->pdev->dev.hdc, R2_NOT);
old_rop = SetROP2(data->ctx->dev.hdc, R2_NOT);
ret = fill_rgn(data, htable, handle_count, 0x80000000 | BLACK_BRUSH, rgn);
SetROP2(data->pdev->dev.hdc, old_rop);
SetROP2(data->ctx->dev.hdc, old_rop);
DeleteObject(rgn);
return ret;
}
......@@ -2516,7 +2516,7 @@ static int WINAPI hmf_proc(HDC hdc, HANDLETABLE *htable,
HRGN rgn = ExtCreateRegion(NULL, p->cbRgnData, (const RGNDATA *)p->RgnData);
int ret;
ret = PSDRV_PaintRgn(&data->pdev->dev, rgn);
ret = PSDRV_PaintRgn(data->ctx, rgn);
DeleteObject(rgn);
return ret;
}
......@@ -2546,7 +2546,7 @@ static int WINAPI hmf_proc(HDC hdc, HANDLETABLE *htable,
blt.cxSrc = p->cxDest;
blt.cySrc = p->cyDest;
return stretch_blt(&data->pdev->dev, &blt, bi, src_bits);
return stretch_blt(data->ctx, &blt, bi, src_bits);
}
case EMR_STRETCHBLT:
{
......@@ -2554,7 +2554,7 @@ static int WINAPI hmf_proc(HDC hdc, HANDLETABLE *htable,
const BITMAPINFO *bi = (const BITMAPINFO *)((BYTE *)p + p->offBmiSrc);
const BYTE *src_bits = (BYTE *)p + p->offBitsSrc;
return stretch_blt(&data->pdev->dev, p, bi, src_bits);
return stretch_blt(data->ctx, p, bi, src_bits);
}
case EMR_MASKBLT:
{
......@@ -2564,22 +2564,22 @@ static int WINAPI hmf_proc(HDC hdc, HANDLETABLE *htable,
const BYTE *mask_bits = (BYTE *)p + p->offBitsMask;
const BYTE *src_bits = (BYTE *)p + p->offBitsSrc;
return mask_blt(&data->pdev->dev, p, src_bi, src_bits, mask_bi, mask_bits);
return mask_blt(data->ctx, p, src_bi, src_bits, mask_bi, mask_bits);
}
case EMR_PLGBLT:
{
const EMRPLGBLT *p = (const EMRPLGBLT *)rec;
return plg_blt(&data->pdev->dev, p);
return plg_blt(data->ctx, p);
}
case EMR_SETDIBITSTODEVICE:
return set_di_bits_to_device(&data->pdev->dev, (const EMRSETDIBITSTODEVICE *)rec);
return set_di_bits_to_device(data->ctx, (const EMRSETDIBITSTODEVICE *)rec);
case EMR_STRETCHDIBITS:
return stretch_di_bits(&data->pdev->dev, (const EMRSTRETCHDIBITS *)rec);
return stretch_di_bits(data->ctx, (const EMRSTRETCHDIBITS *)rec);
case EMR_EXTTEXTOUTW:
{
const EMREXTTEXTOUTW *p = (const EMREXTTEXTOUTW *)rec;
HDC hdc = data->pdev->dev.hdc;
HDC hdc = data->ctx->dev.hdc;
const INT *dx = NULL;
int old_mode, ret;
RECT rect;
......@@ -2617,7 +2617,7 @@ static int WINAPI hmf_proc(HDC hdc, HANDLETABLE *htable,
pts[i].x = p->apts[i].x;
pts[i].y = p->apts[i].y;
}
i = PSDRV_PolyBezier(&data->pdev->dev, pts, p->cpts);
i = PSDRV_PolyBezier(data->ctx, pts, p->cpts);
free(pts);
return i;
}
......@@ -2634,7 +2634,7 @@ static int WINAPI hmf_proc(HDC hdc, HANDLETABLE *htable,
pts[i].x = p->apts[i].x;
pts[i].y = p->apts[i].y;
}
i = PSDRV_PolyPolygon(&data->pdev->dev, pts, (const INT *)&p->cpts, 1);
i = PSDRV_PolyPolygon(data->ctx, pts, (const INT *)&p->cpts, 1);
free(pts);
return i;
}
......@@ -2651,7 +2651,7 @@ static int WINAPI hmf_proc(HDC hdc, HANDLETABLE *htable,
pts[i].x = p->apts[i].x;
pts[i].y = p->apts[i].y;
}
i = PSDRV_PolyPolyline(&data->pdev->dev, pts, &p->cpts, 1);
i = PSDRV_PolyPolyline(data->ctx, pts, &p->cpts, 1);
free(pts);
return i;
}
......@@ -2668,8 +2668,8 @@ static int WINAPI hmf_proc(HDC hdc, HANDLETABLE *htable,
pts[i].x = p->apts[i].x;
pts[i].y = p->apts[i].y;
}
i = PSDRV_PolyBezierTo(&data->pdev->dev, pts, p->cpts) &&
MoveToEx(data->pdev->dev.hdc, pts[p->cpts - 1].x, pts[p->cpts - 1].y, NULL);
i = PSDRV_PolyBezierTo(data->ctx, pts, p->cpts) &&
MoveToEx(data->ctx->dev.hdc, pts[p->cpts - 1].x, pts[p->cpts - 1].y, NULL);
free(pts);
return i;
}
......@@ -2683,14 +2683,14 @@ static int WINAPI hmf_proc(HDC hdc, HANDLETABLE *htable,
cnt = p->cpts + 1;
pts = malloc(sizeof(*pts) * cnt);
if (!pts) return 0;
GetCurrentPositionEx(data->pdev->dev.hdc, pts);
GetCurrentPositionEx(data->ctx->dev.hdc, pts);
for (i = 0; i < p->cpts; i++)
{
pts[i + 1].x = p->apts[i].x;
pts[i + 1].y = p->apts[i].y;
}
i = PSDRV_PolyPolyline(&data->pdev->dev, pts, &cnt, 1) &&
MoveToEx(data->pdev->dev.hdc, pts[cnt - 1].x, pts[cnt - 1].y, NULL);
i = PSDRV_PolyPolyline(data->ctx, pts, &cnt, 1) &&
MoveToEx(data->ctx->dev.hdc, pts[cnt - 1].x, pts[cnt - 1].y, NULL);
free(pts);
return i;
}
......@@ -2707,7 +2707,7 @@ static int WINAPI hmf_proc(HDC hdc, HANDLETABLE *htable,
pts[i].x = ((const POINTS *)(p->aPolyCounts + p->nPolys))[i].x;
pts[i].y = ((const POINTS *)(p->aPolyCounts + p->nPolys))[i].y;
}
i = PSDRV_PolyPolyline(&data->pdev->dev, pts, p->aPolyCounts, p->nPolys);
i = PSDRV_PolyPolyline(data->ctx, pts, p->aPolyCounts, p->nPolys);
free(pts);
return i;
}
......@@ -2724,7 +2724,7 @@ static int WINAPI hmf_proc(HDC hdc, HANDLETABLE *htable,
pts[i].x = ((const POINTS *)(p->aPolyCounts + p->nPolys))[i].x;
pts[i].y = ((const POINTS *)(p->aPolyCounts + p->nPolys))[i].y;
}
i = PSDRV_PolyPolygon(&data->pdev->dev, pts, (const INT *)p->aPolyCounts, p->nPolys);
i = PSDRV_PolyPolygon(data->ctx, pts, (const INT *)p->aPolyCounts, p->nPolys);
free(pts);
return i;
}
......@@ -2741,8 +2741,8 @@ static int WINAPI hmf_proc(HDC hdc, HANDLETABLE *htable,
pts[i].x = p->apts[i].x;
pts[i].y = p->apts[i].y;
}
i = poly_draw(&data->pdev->dev, pts, (BYTE *)(p->apts + p->cpts), p->cpts) &&
MoveToEx(data->pdev->dev.hdc, pts[p->cpts - 1].x, pts[p->cpts - 1].y, NULL);
i = poly_draw(data->ctx, pts, (BYTE *)(p->apts + p->cpts), p->cpts) &&
MoveToEx(data->ctx->dev.hdc, pts[p->cpts - 1].x, pts[p->cpts - 1].y, NULL);
free(pts);
return i;
}
......@@ -2750,7 +2750,7 @@ static int WINAPI hmf_proc(HDC hdc, HANDLETABLE *htable,
{
const EMRCREATEMONOBRUSH *p = (const EMRCREATEMONOBRUSH *)rec;
if (!PlayEnhMetaFileRecord(data->pdev->dev.hdc, htable, rec, handle_count))
if (!PlayEnhMetaFileRecord(data->ctx->dev.hdc, htable, rec, handle_count))
return 0;
data->patterns[p->ihBrush].usage = p->iUsage;
data->patterns[p->ihBrush].info = (BITMAPINFO *)((BYTE *)p + p->offBmi);
......@@ -2761,7 +2761,7 @@ static int WINAPI hmf_proc(HDC hdc, HANDLETABLE *htable,
{
const EMRCREATEDIBPATTERNBRUSHPT *p = (const EMRCREATEDIBPATTERNBRUSHPT *)rec;
if (!PlayEnhMetaFileRecord(data->pdev->dev.hdc, htable, rec, handle_count))
if (!PlayEnhMetaFileRecord(data->ctx->dev.hdc, htable, rec, handle_count))
return 0;
data->patterns[p->ihBrush].usage = p->iUsage;
data->patterns[p->ihBrush].info = (BITMAPINFO *)((BYTE *)p + p->offBmi);
......@@ -2778,14 +2778,14 @@ static int WINAPI hmf_proc(HDC hdc, HANDLETABLE *htable,
BYTE data[1];
} *p = (const struct EMREXTESCAPE *)rec;
PSDRV_ExtEscape(&data->pdev->dev, p->escape, p->size, p->data, 0, NULL);
PSDRV_ExtEscape(data->ctx, p->escape, p->size, p->data, 0, NULL);
return 1;
}
case EMR_GRADIENTFILL:
{
const EMRGRADIENTFILL *p = (const EMRGRADIENTFILL *)rec;
return gradient_fill(&data->pdev->dev, p->Ver, p->nVer,
return gradient_fill(data->ctx, p->Ver, p->nVer,
p->Ver + p->nVer, p->nTri, p->ulMode);
}
case EMR_SETTEXTJUSTIFICATION:
......@@ -2794,7 +2794,7 @@ static int WINAPI hmf_proc(HDC hdc, HANDLETABLE *htable,
data->break_extra = p->break_extra / p->break_count;
data->break_rem = p->break_extra - data->break_extra * p->break_count;
return PlayEnhMetaFileRecord(data->pdev->dev.hdc, htable, rec, handle_count);
return PlayEnhMetaFileRecord(data->ctx->dev.hdc, htable, rec, handle_count);
}
case EMR_EXTFLOODFILL:
......@@ -2836,7 +2836,7 @@ static int WINAPI hmf_proc(HDC hdc, HANDLETABLE *htable,
case EMR_EXTSELECTCLIPRGN:
case EMR_EXTCREATEFONTINDIRECTW:
case EMR_SETLAYOUT:
return PlayEnhMetaFileRecord(data->pdev->dev.hdc, htable, rec, handle_count);
return PlayEnhMetaFileRecord(data->ctx->dev.hdc, htable, rec, handle_count);
default:
FIXME("unsupported record: %ld\n", rec->iType);
}
......@@ -2882,20 +2882,20 @@ static BOOL print_metafile(struct pp_data *data, HANDLE hdata)
if (!hmf)
return FALSE;
AbortPath(data->pdev->dev.hdc);
MoveToEx(data->pdev->dev.hdc, 0, 0, NULL);
SetBkColor(data->pdev->dev.hdc, RGB(255, 255, 255));
SetBkMode(data->pdev->dev.hdc, OPAQUE);
SetMapMode(data->pdev->dev.hdc, MM_TEXT);
SetPolyFillMode(data->pdev->dev.hdc, ALTERNATE);
SetROP2(data->pdev->dev.hdc, R2_COPYPEN);
SetStretchBltMode(data->pdev->dev.hdc, BLACKONWHITE);
SetTextAlign(data->pdev->dev.hdc, TA_LEFT | TA_TOP);
SetTextColor(data->pdev->dev.hdc, 0);
SetTextJustification(data->pdev->dev.hdc, 0, 0);
SetWorldTransform(data->pdev->dev.hdc, &xform);
PSDRV_SetTextColor(&data->pdev->dev, 0);
PSDRV_SetBkColor(&data->pdev->dev, RGB(255, 255, 255));
AbortPath(data->ctx->dev.hdc);
MoveToEx(data->ctx->dev.hdc, 0, 0, NULL);
SetBkColor(data->ctx->dev.hdc, RGB(255, 255, 255));
SetBkMode(data->ctx->dev.hdc, OPAQUE);
SetMapMode(data->ctx->dev.hdc, MM_TEXT);
SetPolyFillMode(data->ctx->dev.hdc, ALTERNATE);
SetROP2(data->ctx->dev.hdc, R2_COPYPEN);
SetStretchBltMode(data->ctx->dev.hdc, BLACKONWHITE);
SetTextAlign(data->ctx->dev.hdc, TA_LEFT | TA_TOP);
SetTextColor(data->ctx->dev.hdc, 0);
SetTextJustification(data->ctx->dev.hdc, 0, 0);
SetWorldTransform(data->ctx->dev.hdc, &xform);
PSDRV_SetTextColor(data->ctx, 0);
PSDRV_SetBkColor(data->ctx, RGB(255, 255, 255));
ret = EnumEnhMetaFile(NULL, hmf, hmf_proc, (void *)data, NULL);
DeleteEnhMetaFile(hmf);
......@@ -2980,15 +2980,14 @@ HANDLE WINAPI OpenPrintProcessor(WCHAR *port, PRINTPROCESSOROPENDATA *open_data)
return NULL;
}
SetGraphicsMode(hdc, GM_ADVANCED);
data->pdev = create_psdrv_physdev(hdc, open_data->pPrinterName,
data->ctx = create_print_ctx(hdc, open_data->pPrinterName,
(const PSDRV_DEVMODE *)open_data->pDevMode);
if (!data->pdev)
if (!data->ctx)
{
DeleteDC(hdc);
LocalFree(data);
return NULL;
}
data->pdev->dev.hdc = hdc;
return (HANDLE)data;
}
......@@ -3014,8 +3013,8 @@ BOOL WINAPI PrintDocumentOnPrintProcessor(HANDLE pp, WCHAR *doc_name)
info.pDocName = data->doc_name;
info.pOutputFile = data->out_file;
info.pDatatype = (WCHAR *)L"RAW";
data->pdev->job.id = StartDocPrinterW(data->hport, 1, (BYTE *)&info);
if (!data->pdev->job.id)
data->ctx->job.id = StartDocPrinterW(data->hport, 1, (BYTE *)&info);
if (!data->ctx->job.id)
{
ClosePrinter(spool_data);
return FALSE;
......@@ -3040,17 +3039,17 @@ BOOL WINAPI PrintDocumentOnPrintProcessor(HANDLE pp, WCHAR *doc_name)
if (!(ret = SeekPrinter(spool_data, pos, NULL, FILE_BEGIN, FALSE)))
goto cleanup;
data->pdev->job.hprinter = data->hport;
if (!PSDRV_WriteHeader(&data->pdev->dev, data->doc_name))
data->ctx->job.hprinter = data->hport;
if (!PSDRV_WriteHeader(data->ctx, data->doc_name))
{
WARN("Failed to write header\n");
goto cleanup;
}
data->pdev->job.OutOfPage = TRUE;
data->pdev->job.PageNo = 0;
data->pdev->job.quiet = FALSE;
data->pdev->job.passthrough_state = passthrough_none;
data->pdev->job.doc_name = strdupW(data->doc_name);
data->ctx->job.OutOfPage = TRUE;
data->ctx->job.PageNo = 0;
data->ctx->job.quiet = FALSE;
data->ctx->job.passthrough_state = passthrough_none;
data->ctx->job.doc_name = strdupW(data->doc_name);
while (1)
{
......@@ -3085,7 +3084,7 @@ BOOL WINAPI PrintDocumentOnPrintProcessor(HANDLE pp, WCHAR *doc_name)
}
if (ret)
ret = PSDRV_ResetDC(&data->pdev->dev, devmode);
ret = PSDRV_ResetDC(data->ctx, devmode);
free(devmode);
if (!ret)
goto cleanup;
......@@ -3132,10 +3131,10 @@ BOOL WINAPI PrintDocumentOnPrintProcessor(HANDLE pp, WCHAR *doc_name)
}
cleanup:
if (data->pdev->job.PageNo)
PSDRV_WriteFooter(&data->pdev->dev);
if (data->ctx->job.PageNo)
PSDRV_WriteFooter(data->ctx);
HeapFree(GetProcessHeap(), 0, data->pdev->job.doc_name);
HeapFree(GetProcessHeap(), 0, data->ctx->job.doc_name);
ClosePrinter(spool_data);
return EndDocPrinter(data->hport) && ret;
}
......@@ -3159,9 +3158,9 @@ BOOL WINAPI ClosePrintProcessor(HANDLE pp)
ClosePrinter(data->hport);
free(data->doc_name);
free(data->out_file);
DeleteDC(data->pdev->dev.hdc);
HeapFree(GetProcessHeap(), 0, data->pdev->Devmode);
HeapFree(GetProcessHeap(), 0, data->pdev);
DeleteDC(data->ctx->dev.hdc);
HeapFree(GetProcessHeap(), 0, data->ctx->Devmode);
HeapFree(GetProcessHeap(), 0, data->ctx);
free(data->saved_dc);
memset(data, 0, sizeof(*data));
......
......@@ -217,46 +217,41 @@ static const char psbegindocument[] =
static const char psenddocument[] =
"\n%%EndDocument\n";
void passthrough_enter(PHYSDEV dev)
void passthrough_enter(print_ctx *ctx)
{
PSDRV_PDEVICE *physDev = get_psdrv_dev( dev );
if (ctx->job.passthrough_state != passthrough_none) return;
if (physDev->job.passthrough_state != passthrough_none) return;
write_spool(dev, psbegindocument, sizeof(psbegindocument) - 1);
physDev->job.passthrough_state = passthrough_active;
write_spool(ctx, psbegindocument, sizeof(psbegindocument) - 1);
ctx->job.passthrough_state = passthrough_active;
}
void passthrough_leave(PHYSDEV dev)
void passthrough_leave(print_ctx *ctx)
{
PSDRV_PDEVICE *physDev = get_psdrv_dev( dev );
if (physDev->job.passthrough_state == passthrough_none) return;
if (ctx->job.passthrough_state == passthrough_none) return;
write_spool(dev, psenddocument, sizeof(psenddocument) - 1);
physDev->job.passthrough_state = passthrough_none;
write_spool(ctx, psenddocument, sizeof(psenddocument) - 1);
ctx->job.passthrough_state = passthrough_none;
}
DWORD PSDRV_WriteSpool(PHYSDEV dev, LPCSTR lpData, DWORD cch)
DWORD PSDRV_WriteSpool(print_ctx *ctx, LPCSTR lpData, DWORD cch)
{
PSDRV_PDEVICE *physDev = get_psdrv_dev( dev );
int num, num_left = cch;
if(physDev->job.quiet) {
if(ctx->job.quiet) {
TRACE("ignoring output\n");
return 0;
}
passthrough_leave(dev);
passthrough_leave(ctx);
if(physDev->job.OutOfPage) { /* Will get here after NEWFRAME Escape */
if( !PSDRV_StartPage(dev) )
if(ctx->job.OutOfPage) { /* Will get here after NEWFRAME Escape */
if( !PSDRV_StartPage(ctx) )
return 0;
}
do {
num = min(num_left, 0x8000);
if(write_spool( dev, lpData, num ) != num)
if(write_spool( ctx, lpData, num ) != num)
return 0;
lpData += num;
num_left -= num;
......@@ -266,16 +261,16 @@ DWORD PSDRV_WriteSpool(PHYSDEV dev, LPCSTR lpData, DWORD cch)
}
static INT PSDRV_WriteFeature(PHYSDEV dev, LPCSTR feature, LPCSTR value, LPCSTR invocation)
static INT PSDRV_WriteFeature(print_ctx *ctx, LPCSTR feature, LPCSTR value, LPCSTR invocation)
{
char *buf = HeapAlloc( GetProcessHeap(), 0, sizeof(psbeginfeature) +
strlen(feature) + strlen(value));
sprintf(buf, psbeginfeature, feature, value);
write_spool( dev, buf, strlen(buf) );
write_spool( dev, invocation, strlen(invocation) );
write_spool( dev, psendfeature, strlen(psendfeature) );
write_spool( ctx, buf, strlen(buf) );
write_spool( ctx, invocation, strlen(invocation) );
write_spool( ctx, psendfeature, strlen(psendfeature) );
HeapFree( GetProcessHeap(), 0, buf );
return 1;
......@@ -350,9 +345,8 @@ struct ticket_info
DUPLEX *duplex;
};
static void write_cups_job_ticket( PHYSDEV dev, const struct ticket_info *info )
static void write_cups_job_ticket( print_ctx *ctx, const struct ticket_info *info )
{
PSDRV_PDEVICE *physDev = get_psdrv_dev( dev );
char buf[256];
int len;
......@@ -364,7 +358,7 @@ static void write_cups_job_ticket( PHYSDEV dev, const struct ticket_info *info )
memcpy( buf, media, sizeof(media) );
strcat( buf, info->page->Name );
strcat( buf, "\n");
write_spool( dev, buf, len - 1 );
write_spool( ctx, buf, len - 1 );
}
else
WARN( "paper name %s will be too long for DSC\n", info->page->Name );
......@@ -375,38 +369,37 @@ static void write_cups_job_ticket( PHYSDEV dev, const struct ticket_info *info )
if (info->duplex->WinDuplex >= 1 && info->duplex->WinDuplex <= 3)
{
const char *str = cups_duplexes[ info->duplex->WinDuplex - 1 ];
write_spool( dev, str, strlen( str ) );
write_spool( ctx, str, strlen( str ) );
}
}
if (physDev->Devmode->dmPublic.dmCopies > 1)
if (ctx->Devmode->dmPublic.dmCopies > 1)
{
len = snprintf( buf, sizeof(buf), "%%cupsJobTicket: copies=%d\n",
physDev->Devmode->dmPublic.dmCopies );
ctx->Devmode->dmPublic.dmCopies );
if (len > 0 && len < sizeof(buf))
write_spool( dev, buf, len );
write_spool( ctx, buf, len );
if (physDev->Devmode->dmPublic.dmFields & DM_COLLATE)
if (ctx->Devmode->dmPublic.dmFields & DM_COLLATE)
{
if (physDev->Devmode->dmPublic.dmCollate == DMCOLLATE_FALSE)
write_spool( dev, cups_collate_false, sizeof(cups_collate_false) - 1 );
else if (physDev->Devmode->dmPublic.dmCollate == DMCOLLATE_TRUE)
write_spool( dev, cups_collate_true, sizeof(cups_collate_true) - 1 );
if (ctx->Devmode->dmPublic.dmCollate == DMCOLLATE_FALSE)
write_spool( ctx, cups_collate_false, sizeof(cups_collate_false) - 1 );
else if (ctx->Devmode->dmPublic.dmCollate == DMCOLLATE_TRUE)
write_spool( ctx, cups_collate_true, sizeof(cups_collate_true) - 1 );
}
}
if (!(physDev->Devmode->dmPublic.dmFields & DM_DEFAULTSOURCE) ||
physDev->Devmode->dmPublic.dmDefaultSource == DMBIN_AUTO)
write_spool( dev, cups_ap_d_inputslot, sizeof(cups_ap_d_inputslot) - 1 );
if (!(ctx->Devmode->dmPublic.dmFields & DM_DEFAULTSOURCE) ||
ctx->Devmode->dmPublic.dmDefaultSource == DMBIN_AUTO)
write_spool( ctx, cups_ap_d_inputslot, sizeof(cups_ap_d_inputslot) - 1 );
}
INT PSDRV_WriteHeader( PHYSDEV dev, LPCWSTR title )
INT PSDRV_WriteHeader( print_ctx *ctx, LPCWSTR title )
{
PSDRV_PDEVICE *physDev = get_psdrv_dev( dev );
char *buf, *escaped_title;
INPUTSLOT *slot = find_slot( physDev->pi->ppd, physDev->Devmode );
PAGESIZE *page = find_pagesize( physDev->pi->ppd, physDev->Devmode );
DUPLEX *duplex = find_duplex( physDev->pi->ppd, physDev->Devmode );
INPUTSLOT *slot = find_slot( ctx->pi->ppd, ctx->Devmode );
PAGESIZE *page = find_pagesize( ctx->pi->ppd, ctx->Devmode );
DUPLEX *duplex = find_duplex( ctx->pi->ppd, ctx->Devmode );
int llx, lly, urx, ury;
int ret, len;
const char * dmOrientation;
......@@ -416,14 +409,14 @@ INT PSDRV_WriteHeader( PHYSDEV dev, LPCWSTR title )
TRACE("%s\n", debugstr_w(title));
len = strlen( psadobe );
ret = write_spool( dev, psadobe, len );
ret = write_spool( ctx, psadobe, len );
if (ret != len)
{
WARN("WriteSpool error\n");
return 0;
}
write_cups_job_ticket( dev, &ticket_info );
write_cups_job_ticket( ctx, &ticket_info );
escaped_title = escape_title(title);
buf = HeapAlloc( GetProcessHeap(), 0, sizeof(psheader) +
......@@ -436,45 +429,44 @@ INT PSDRV_WriteHeader( PHYSDEV dev, LPCWSTR title )
/* BBox co-ords are in default user co-ord system so urx < ury even in
landscape mode */
llx = physDev->ImageableArea.left * 72.0 / physDev->logPixelsX;
lly = physDev->ImageableArea.bottom * 72.0 / physDev->logPixelsY;
urx = physDev->ImageableArea.right * 72.0 / physDev->logPixelsX;
ury = physDev->ImageableArea.top * 72.0 / physDev->logPixelsY;
llx = ctx->ImageableArea.left * 72.0 / ctx->logPixelsX;
lly = ctx->ImageableArea.bottom * 72.0 / ctx->logPixelsY;
urx = ctx->ImageableArea.right * 72.0 / ctx->logPixelsX;
ury = ctx->ImageableArea.top * 72.0 / ctx->logPixelsY;
/* FIXME should do something better with BBox */
dmOrientation = (physDev->Devmode->dmPublic.dmOrientation == DMORIENT_LANDSCAPE ? "Landscape" : "Portrait");
dmOrientation = (ctx->Devmode->dmPublic.dmOrientation == DMORIENT_LANDSCAPE ? "Landscape" : "Portrait");
sprintf(buf, psheader, escaped_title, llx, lly, urx, ury, dmOrientation);
HeapFree(GetProcessHeap(), 0, escaped_title);
len = strlen( buf );
write_spool( dev, buf, len );
write_spool( ctx, buf, len );
HeapFree( GetProcessHeap(), 0, buf );
write_spool( dev, psbeginprolog, strlen(psbeginprolog) );
write_spool( dev, psprolog, strlen(psprolog) );
write_spool( dev, psendprolog, strlen(psendprolog) );
write_spool( dev, psbeginsetup, strlen(psbeginsetup) );
write_spool( ctx, psbeginprolog, strlen(psbeginprolog) );
write_spool( ctx, psprolog, strlen(psprolog) );
write_spool( ctx, psendprolog, strlen(psendprolog) );
write_spool( ctx, psbeginsetup, strlen(psbeginsetup) );
if (slot && slot->InvocationString)
PSDRV_WriteFeature( dev, "*InputSlot", slot->Name, slot->InvocationString );
PSDRV_WriteFeature( ctx, "*InputSlot", slot->Name, slot->InvocationString );
if (page && page->InvocationString)
PSDRV_WriteFeature( dev, "*PageSize", page->Name, page->InvocationString );
PSDRV_WriteFeature( ctx, "*PageSize", page->Name, page->InvocationString );
if (duplex && duplex->InvocationString)
PSDRV_WriteFeature( dev, "*Duplex", duplex->Name, duplex->InvocationString );
PSDRV_WriteFeature( ctx, "*Duplex", duplex->Name, duplex->InvocationString );
write_spool( dev, psendsetup, strlen(psendsetup) );
write_spool( ctx, psendsetup, strlen(psendsetup) );
return 1;
}
INT PSDRV_WriteFooter( PHYSDEV dev )
INT PSDRV_WriteFooter( print_ctx *ctx )
{
PSDRV_PDEVICE *physDev = get_psdrv_dev( dev );
char *buf;
int ret = 1;
......@@ -484,9 +476,9 @@ INT PSDRV_WriteFooter( PHYSDEV dev )
return 0;
}
sprintf(buf, psfooter, physDev->job.PageNo);
sprintf(buf, psfooter, ctx->job.PageNo);
if( write_spool( dev, buf, strlen(buf) ) != strlen(buf) ) {
if( write_spool( ctx, buf, strlen(buf) ) != strlen(buf) ) {
WARN("WriteSpool error\n");
ret = 0;
}
......@@ -496,9 +488,9 @@ INT PSDRV_WriteFooter( PHYSDEV dev )
INT PSDRV_WriteEndPage( PHYSDEV dev )
INT PSDRV_WriteEndPage( print_ctx *ctx )
{
if( write_spool( dev, psendpage, sizeof(psendpage)-1 ) != sizeof(psendpage)-1 ) {
if( write_spool( ctx, psendpage, sizeof(psendpage)-1 ) != sizeof(psendpage)-1 ) {
WARN("WriteSpool error\n");
return 0;
}
......@@ -508,15 +500,14 @@ INT PSDRV_WriteEndPage( PHYSDEV dev )
INT PSDRV_WriteNewPage( PHYSDEV dev )
INT PSDRV_WriteNewPage( print_ctx *ctx )
{
PSDRV_PDEVICE *physDev = get_psdrv_dev( dev );
char *buf;
char name[100];
signed int xtrans, ytrans, rotation;
int ret = 1;
sprintf(name, "%d", physDev->job.PageNo);
sprintf(name, "%d", ctx->job.PageNo);
buf = HeapAlloc( GetProcessHeap(), 0, sizeof(psnewpage) + 200 );
if(!buf) {
......@@ -524,27 +515,27 @@ INT PSDRV_WriteNewPage( PHYSDEV dev )
return 0;
}
if(physDev->Devmode->dmPublic.dmOrientation == DMORIENT_LANDSCAPE) {
if(physDev->pi->ppd->LandscapeOrientation == -90) {
xtrans = physDev->ImageableArea.right;
ytrans = physDev->ImageableArea.top;
if(ctx->Devmode->dmPublic.dmOrientation == DMORIENT_LANDSCAPE) {
if(ctx->pi->ppd->LandscapeOrientation == -90) {
xtrans = ctx->ImageableArea.right;
ytrans = ctx->ImageableArea.top;
rotation = 90;
} else {
xtrans = physDev->ImageableArea.left;
ytrans = physDev->ImageableArea.bottom;
xtrans = ctx->ImageableArea.left;
ytrans = ctx->ImageableArea.bottom;
rotation = -90;
}
} else {
xtrans = physDev->ImageableArea.left;
ytrans = physDev->ImageableArea.top;
xtrans = ctx->ImageableArea.left;
ytrans = ctx->ImageableArea.top;
rotation = 0;
}
sprintf(buf, psnewpage, name, physDev->job.PageNo,
physDev->logPixelsX, physDev->logPixelsY,
sprintf(buf, psnewpage, name, ctx->job.PageNo,
ctx->logPixelsX, ctx->logPixelsY,
xtrans, ytrans, rotation);
if( write_spool( dev, buf, strlen(buf) ) != strlen(buf) ) {
if( write_spool( ctx, buf, strlen(buf) ) != strlen(buf) ) {
WARN("WriteSpool error\n");
ret = 0;
}
......@@ -553,40 +544,40 @@ INT PSDRV_WriteNewPage( PHYSDEV dev )
}
BOOL PSDRV_WriteMoveTo(PHYSDEV dev, INT x, INT y)
BOOL PSDRV_WriteMoveTo(print_ctx *ctx, INT x, INT y)
{
char buf[100];
sprintf(buf, psmoveto, x, y);
return PSDRV_WriteSpool(dev, buf, strlen(buf));
return PSDRV_WriteSpool(ctx, buf, strlen(buf));
}
BOOL PSDRV_WriteLineTo(PHYSDEV dev, INT x, INT y)
BOOL PSDRV_WriteLineTo(print_ctx *ctx, INT x, INT y)
{
char buf[100];
sprintf(buf, pslineto, x, y);
return PSDRV_WriteSpool(dev, buf, strlen(buf));
return PSDRV_WriteSpool(ctx, buf, strlen(buf));
}
BOOL PSDRV_WriteStroke(PHYSDEV dev)
BOOL PSDRV_WriteStroke(print_ctx *ctx)
{
return PSDRV_WriteSpool(dev, psstroke, sizeof(psstroke)-1);
return PSDRV_WriteSpool(ctx, psstroke, sizeof(psstroke)-1);
}
BOOL PSDRV_WriteRectangle(PHYSDEV dev, INT x, INT y, INT width,
BOOL PSDRV_WriteRectangle(print_ctx *ctx, INT x, INT y, INT width,
INT height)
{
char buf[100];
sprintf(buf, psrectangle, x, y, width, height, -width);
return PSDRV_WriteSpool(dev, buf, strlen(buf));
return PSDRV_WriteSpool(ctx, buf, strlen(buf));
}
BOOL PSDRV_WriteArc(PHYSDEV dev, INT x, INT y, INT w, INT h, double ang1,
BOOL PSDRV_WriteArc(print_ctx *ctx, INT x, INT y, INT w, INT h, double ang1,
double ang2)
{
char buf[256];
......@@ -596,18 +587,18 @@ BOOL PSDRV_WriteArc(PHYSDEV dev, INT x, INT y, INT w, INT h, double ang1,
push_lc_numeric("C");
sprintf(buf, psarc, x, y, w, h, -ang2, -ang1);
pop_lc_numeric();
return PSDRV_WriteSpool(dev, buf, strlen(buf));
return PSDRV_WriteSpool(ctx, buf, strlen(buf));
}
BOOL PSDRV_WriteCurveTo(PHYSDEV dev, POINT pts[3])
BOOL PSDRV_WriteCurveTo(print_ctx *ctx, 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));
return PSDRV_WriteSpool(ctx, buf, strlen(buf));
}
BOOL PSDRV_WriteSetFont(PHYSDEV dev, const char *name, matrix size, INT escapement, BOOL fake_italic)
BOOL PSDRV_WriteSetFont(print_ctx *ctx, const char *name, matrix size, INT escapement, BOOL fake_italic)
{
char *buf;
......@@ -619,46 +610,45 @@ BOOL PSDRV_WriteSetFont(PHYSDEV dev, const char *name, matrix size, INT escapeme
}
sprintf( buf, psfindfont, name );
PSDRV_WriteSpool( dev, buf, strlen(buf) );
PSDRV_WriteSpool( ctx, buf, strlen(buf) );
if (fake_italic) PSDRV_WriteSpool( dev, psfakeitalic, sizeof(psfakeitalic) - 1 );
if (fake_italic) PSDRV_WriteSpool( ctx, psfakeitalic, sizeof(psfakeitalic) - 1 );
sprintf( buf, pssizematrix, size.xx, size.xy, size.yx, size.yy );
PSDRV_WriteSpool( dev, buf, strlen(buf) );
PSDRV_WriteSpool( ctx, buf, strlen(buf) );
if (fake_italic) PSDRV_WriteSpool( dev, psconcat, sizeof(psconcat) - 1 );
if (fake_italic) PSDRV_WriteSpool( ctx, psconcat, sizeof(psconcat) - 1 );
if (escapement)
{
sprintf( buf, psrotatefont, -escapement );
PSDRV_WriteSpool( dev, buf, strlen(buf) );
PSDRV_WriteSpool( ctx, buf, strlen(buf) );
}
PSDRV_WriteSpool( dev, pssetfont, sizeof(pssetfont) - 1 );
PSDRV_WriteSpool( ctx, pssetfont, sizeof(pssetfont) - 1 );
HeapFree( GetProcessHeap(), 0, buf );
return TRUE;
}
BOOL PSDRV_WriteSetColor(PHYSDEV dev, PSCOLOR *color)
BOOL PSDRV_WriteSetColor(print_ctx *ctx, PSCOLOR *color)
{
PSDRV_PDEVICE *physDev = get_psdrv_dev( dev );
char buf[256];
PSDRV_CopyColor(&physDev->inkColor, color);
PSDRV_CopyColor(&ctx->inkColor, color);
switch(color->type) {
case PSCOLOR_RGB:
push_lc_numeric("C");
sprintf(buf, pssetrgbcolor, color->value.rgb.r, color->value.rgb.g,
color->value.rgb.b);
pop_lc_numeric();
return PSDRV_WriteSpool(dev, buf, strlen(buf));
return PSDRV_WriteSpool(ctx, buf, strlen(buf));
case PSCOLOR_GRAY:
push_lc_numeric("C");
sprintf(buf, pssetgray, color->value.gray.i);
pop_lc_numeric();
return PSDRV_WriteSpool(dev, buf, strlen(buf));
return PSDRV_WriteSpool(ctx, buf, strlen(buf));
default:
ERR("Unknown colour type %d\n", color->type);
......@@ -668,31 +658,30 @@ BOOL PSDRV_WriteSetColor(PHYSDEV dev, PSCOLOR *color)
return FALSE;
}
BOOL PSDRV_WriteSetPen(PHYSDEV dev)
BOOL PSDRV_WriteSetPen(print_ctx *ctx)
{
PSDRV_PDEVICE *physDev = get_psdrv_dev( dev );
char buf[256];
DWORD i, pos;
sprintf(buf, pssetline, physDev->pen.width, physDev->pen.join, physDev->pen.endcap);
PSDRV_WriteSpool(dev, buf, strlen(buf));
sprintf(buf, pssetline, ctx->pen.width, ctx->pen.join, ctx->pen.endcap);
PSDRV_WriteSpool(ctx, buf, strlen(buf));
if (physDev->pen.dash_len)
if (ctx->pen.dash_len)
{
for (i = pos = 0; i < physDev->pen.dash_len; i++)
pos += sprintf( buf + pos, " %lu", physDev->pen.dash[i] );
for (i = pos = 0; i < ctx->pen.dash_len; i++)
pos += sprintf( buf + pos, " %lu", ctx->pen.dash[i] );
buf[0] = '[';
sprintf(buf + pos, "] %u setdash\n", 0);
}
else
sprintf(buf, "[] %u setdash\n", 0);
PSDRV_WriteSpool(dev, buf, strlen(buf));
PSDRV_WriteSpool(ctx, buf, strlen(buf));
return TRUE;
}
BOOL PSDRV_WriteGlyphShow(PHYSDEV dev, LPCSTR g_name)
BOOL PSDRV_WriteGlyphShow(print_ctx *ctx, LPCSTR g_name)
{
char buf[128];
int l;
......@@ -704,79 +693,79 @@ BOOL PSDRV_WriteGlyphShow(PHYSDEV dev, LPCSTR g_name)
return FALSE;
}
PSDRV_WriteSpool(dev, buf, l);
PSDRV_WriteSpool(ctx, buf, l);
return TRUE;
}
BOOL PSDRV_WriteFill(PHYSDEV dev)
BOOL PSDRV_WriteFill(print_ctx *ctx)
{
return PSDRV_WriteSpool(dev, psfill, sizeof(psfill)-1);
return PSDRV_WriteSpool(ctx, psfill, sizeof(psfill)-1);
}
BOOL PSDRV_WriteEOFill(PHYSDEV dev)
BOOL PSDRV_WriteEOFill(print_ctx *ctx)
{
return PSDRV_WriteSpool(dev, pseofill, sizeof(pseofill)-1);
return PSDRV_WriteSpool(ctx, pseofill, sizeof(pseofill)-1);
}
BOOL PSDRV_WriteGSave(PHYSDEV dev)
BOOL PSDRV_WriteGSave(print_ctx *ctx)
{
return PSDRV_WriteSpool(dev, psgsave, sizeof(psgsave)-1);
return PSDRV_WriteSpool(ctx, psgsave, sizeof(psgsave)-1);
}
BOOL PSDRV_WriteGRestore(PHYSDEV dev)
BOOL PSDRV_WriteGRestore(print_ctx *ctx)
{
return PSDRV_WriteSpool(dev, psgrestore, sizeof(psgrestore)-1);
return PSDRV_WriteSpool(ctx, psgrestore, sizeof(psgrestore)-1);
}
BOOL PSDRV_WriteNewPath(PHYSDEV dev)
BOOL PSDRV_WriteNewPath(print_ctx *ctx)
{
return PSDRV_WriteSpool(dev, psnewpath, sizeof(psnewpath)-1);
return PSDRV_WriteSpool(ctx, psnewpath, sizeof(psnewpath)-1);
}
BOOL PSDRV_WriteClosePath(PHYSDEV dev)
BOOL PSDRV_WriteClosePath(print_ctx *ctx)
{
return PSDRV_WriteSpool(dev, psclosepath, sizeof(psclosepath)-1);
return PSDRV_WriteSpool(ctx, psclosepath, sizeof(psclosepath)-1);
}
BOOL PSDRV_WriteClip(PHYSDEV dev)
BOOL PSDRV_WriteClip(print_ctx *ctx)
{
return PSDRV_WriteSpool(dev, psclip, sizeof(psclip)-1);
return PSDRV_WriteSpool(ctx, psclip, sizeof(psclip)-1);
}
BOOL PSDRV_WriteEOClip(PHYSDEV dev)
BOOL PSDRV_WriteEOClip(print_ctx *ctx)
{
return PSDRV_WriteSpool(dev, pseoclip, sizeof(pseoclip)-1);
return PSDRV_WriteSpool(ctx, pseoclip, sizeof(pseoclip)-1);
}
BOOL PSDRV_WriteHatch(PHYSDEV dev)
BOOL PSDRV_WriteHatch(print_ctx *ctx)
{
return PSDRV_WriteSpool(dev, pshatch, sizeof(pshatch)-1);
return PSDRV_WriteSpool(ctx, pshatch, sizeof(pshatch)-1);
}
BOOL PSDRV_WriteRotate(PHYSDEV dev, float ang)
BOOL PSDRV_WriteRotate(print_ctx *ctx, float ang)
{
char buf[256];
push_lc_numeric("C");
sprintf(buf, psrotate, ang);
pop_lc_numeric();
return PSDRV_WriteSpool(dev, buf, strlen(buf));
return PSDRV_WriteSpool(ctx, buf, strlen(buf));
}
BOOL PSDRV_WriteIndexColorSpaceBegin(PHYSDEV dev, int size)
BOOL PSDRV_WriteIndexColorSpaceBegin(print_ctx *ctx, int size)
{
char buf[256];
sprintf(buf, "[/Indexed /DeviceRGB %d\n<\n", size);
return PSDRV_WriteSpool(dev, buf, strlen(buf));
return PSDRV_WriteSpool(ctx, buf, strlen(buf));
}
BOOL PSDRV_WriteIndexColorSpaceEnd(PHYSDEV dev)
BOOL PSDRV_WriteIndexColorSpaceEnd(print_ctx *ctx)
{
static const char buf[] = ">\n] setcolorspace\n";
return PSDRV_WriteSpool(dev, buf, sizeof(buf) - 1);
return PSDRV_WriteSpool(ctx, buf, sizeof(buf) - 1);
}
static BOOL PSDRV_WriteRGB(PHYSDEV dev, COLORREF *map, int number)
static BOOL PSDRV_WriteRGB(print_ctx *ctx, COLORREF *map, int number)
{
char *buf = HeapAlloc( GetProcessHeap(), 0, number * 7 + 1 ), *ptr;
int i;
......@@ -788,12 +777,12 @@ static BOOL PSDRV_WriteRGB(PHYSDEV dev, COLORREF *map, int number)
((i & 0x7) == 0x7) || (i == number - 1) ? '\n' : ' ');
ptr += 7;
}
PSDRV_WriteSpool(dev, buf, number * 7);
PSDRV_WriteSpool(ctx, buf, number * 7);
HeapFree( GetProcessHeap(), 0, buf );
return TRUE;
}
BOOL PSDRV_WriteRGBQUAD(PHYSDEV dev, const RGBQUAD *rgb, int number)
BOOL PSDRV_WriteRGBQUAD(print_ctx *ctx, const RGBQUAD *rgb, int number)
{
char *buf = HeapAlloc( GetProcessHeap(), 0, number * 7 + 1 ), *ptr;
int i;
......@@ -803,12 +792,12 @@ BOOL PSDRV_WriteRGBQUAD(PHYSDEV dev, const RGBQUAD *rgb, int number)
ptr += sprintf(ptr, "%02x%02x%02x%c", rgb->rgbRed, rgb->rgbGreen, rgb->rgbBlue,
((i & 0x7) == 0x7) || (i == number - 1) ? '\n' : ' ');
PSDRV_WriteSpool(dev, buf, ptr - buf);
PSDRV_WriteSpool(ctx, buf, ptr - buf);
HeapFree( GetProcessHeap(), 0, buf );
return TRUE;
}
static BOOL PSDRV_WriteImageDict(PHYSDEV dev, WORD depth, BOOL grayscale,
static BOOL PSDRV_WriteImageDict(print_ctx *ctx, WORD depth, BOOL grayscale,
INT widthSrc, INT heightSrc, char *bits, BOOL top_down)
{
static const char start[] = "<<\n"
......@@ -829,7 +818,7 @@ static BOOL PSDRV_WriteImageDict(PHYSDEV dev, WORD depth, BOOL grayscale,
sprintf(buf, start, widthSrc, heightSrc,
(depth < 8) ? depth : 8, widthSrc, -heightSrc, heightSrc);
PSDRV_WriteSpool(dev, buf, strlen(buf));
PSDRV_WriteSpool(ctx, buf, strlen(buf));
switch(depth) {
case 8:
......@@ -852,19 +841,19 @@ static BOOL PSDRV_WriteImageDict(PHYSDEV dev, WORD depth, BOOL grayscale,
break;
}
PSDRV_WriteSpool(dev, buf, strlen(buf));
PSDRV_WriteSpool(ctx, buf, strlen(buf));
if(!bits) {
PSDRV_WriteSpool(dev, end, sizeof(end) - 1);
PSDRV_WriteSpool(ctx, end, sizeof(end) - 1);
} else {
sprintf(buf, endbits, bits);
PSDRV_WriteSpool(dev, buf, strlen(buf));
PSDRV_WriteSpool(ctx, buf, strlen(buf));
}
return TRUE;
}
BOOL PSDRV_WriteImage(PHYSDEV dev, WORD depth, BOOL grayscale, INT xDst, INT yDst,
BOOL PSDRV_WriteImage(print_ctx *ctx, WORD depth, BOOL grayscale, INT xDst, INT yDst,
INT widthDst, INT heightDst, INT widthSrc,
INT heightSrc, BOOL mask, BOOL top_down)
{
......@@ -874,17 +863,17 @@ BOOL PSDRV_WriteImage(PHYSDEV dev, WORD depth, BOOL grayscale, INT xDst, INT yDs
char buf[100];
sprintf(buf, start, xDst, yDst, widthDst, heightDst);
PSDRV_WriteSpool(dev, buf, strlen(buf));
PSDRV_WriteImageDict(dev, depth, grayscale, widthSrc, heightSrc, NULL, top_down);
PSDRV_WriteSpool(ctx, buf, strlen(buf));
PSDRV_WriteImageDict(ctx, depth, grayscale, widthSrc, heightSrc, NULL, top_down);
if(mask)
PSDRV_WriteSpool(dev, imagemask, sizeof(imagemask) - 1);
PSDRV_WriteSpool(ctx, imagemask, sizeof(imagemask) - 1);
else
PSDRV_WriteSpool(dev, image, sizeof(image) - 1);
PSDRV_WriteSpool(ctx, image, sizeof(image) - 1);
return TRUE;
}
BOOL PSDRV_WriteBytes(PHYSDEV dev, const BYTE *bytes, DWORD number)
BOOL PSDRV_WriteBytes(print_ctx *ctx, const BYTE *bytes, DWORD number)
{
char *buf = HeapAlloc( GetProcessHeap(), 0, number * 3 + 1 );
char *ptr;
......@@ -900,19 +889,19 @@ BOOL PSDRV_WriteBytes(PHYSDEV dev, const BYTE *bytes, DWORD number)
ptr++;
}
}
PSDRV_WriteSpool(dev, buf, ptr - buf);
PSDRV_WriteSpool(ctx, buf, ptr - buf);
HeapFree( GetProcessHeap(), 0, buf );
return TRUE;
}
BOOL PSDRV_WriteData(PHYSDEV dev, const BYTE *data, DWORD number)
BOOL PSDRV_WriteData(print_ctx *ctx, const BYTE *data, DWORD number)
{
int num, num_left = number;
do {
num = min(num_left, 60);
PSDRV_WriteSpool(dev, (LPCSTR)data, num);
PSDRV_WriteSpool(dev, "\n", 1);
PSDRV_WriteSpool(ctx, (LPCSTR)data, num);
PSDRV_WriteSpool(ctx, "\n", 1);
data += num;
num_left -= num;
} while(num_left);
......@@ -920,45 +909,44 @@ BOOL PSDRV_WriteData(PHYSDEV dev, const BYTE *data, DWORD number)
return TRUE;
}
BOOL PSDRV_WriteArrayPut(PHYSDEV dev, CHAR *pszArrayName, INT nIndex, LONG lObject)
BOOL PSDRV_WriteArrayPut(print_ctx *ctx, CHAR *pszArrayName, INT nIndex, LONG lObject)
{
char buf[100];
sprintf(buf, psarrayput, pszArrayName, nIndex, lObject);
return PSDRV_WriteSpool(dev, buf, strlen(buf));
return PSDRV_WriteSpool(ctx, buf, strlen(buf));
}
BOOL PSDRV_WriteArrayDef(PHYSDEV dev, CHAR *pszArrayName, INT nSize)
BOOL PSDRV_WriteArrayDef(print_ctx *ctx, CHAR *pszArrayName, INT nSize)
{
char buf[100];
sprintf(buf, psarraydef, pszArrayName, nSize);
return PSDRV_WriteSpool(dev, buf, strlen(buf));
return PSDRV_WriteSpool(ctx, buf, strlen(buf));
}
BOOL PSDRV_WriteRectClip(PHYSDEV dev, INT x, INT y, INT w, INT h)
BOOL PSDRV_WriteRectClip(print_ctx *ctx, INT x, INT y, INT w, INT h)
{
char buf[100];
sprintf(buf, psrectclip, x, y, w, h);
return PSDRV_WriteSpool(dev, buf, strlen(buf));
return PSDRV_WriteSpool(ctx, buf, strlen(buf));
}
BOOL PSDRV_WriteRectClip2(PHYSDEV dev, CHAR *pszArrayName)
BOOL PSDRV_WriteRectClip2(print_ctx *ctx, CHAR *pszArrayName)
{
char buf[100];
sprintf(buf, psrectclip2, pszArrayName);
return PSDRV_WriteSpool(dev, buf, strlen(buf));
return PSDRV_WriteSpool(ctx, buf, strlen(buf));
}
BOOL PSDRV_WriteDIBPatternDict(PHYSDEV dev, const BITMAPINFO *bmi, BYTE *bits, UINT usage)
BOOL PSDRV_WriteDIBPatternDict(print_ctx *ctx, const BITMAPINFO *bmi, BYTE *bits, UINT usage)
{
static const char mypat[] = "/mypat\n";
static const char do_pattern[] = "<<\n /PaintType 1\n /PatternType 1\n /TilingType 1\n "
"/BBox [0 0 %d %d]\n /XStep %d\n /YStep %d\n /PaintProc {\n begin\n 0 0 translate\n"
" %d %d scale\n mypat image\n end\n }\n>>\n matrix makepattern setpattern\n";
PSDRV_PDEVICE *physDev = get_psdrv_dev( dev );
char *buf, *ptr;
INT w, h, x, y, w_mult, h_mult, abs_height = abs( bmi->bmiHeader.biHeight );
COLORREF map[2];
......@@ -983,21 +971,21 @@ BOOL PSDRV_WriteDIBPatternDict(PHYSDEV dev, const BITMAPINFO *bmi, BYTE *bits, U
ptr += 2;
}
}
PSDRV_WriteSpool(dev, mypat, sizeof(mypat) - 1);
PSDRV_WriteImageDict(dev, 1, FALSE, 8, 8, buf, bmi->bmiHeader.biHeight < 0);
PSDRV_WriteSpool(dev, "def\n", 4);
PSDRV_WriteSpool(ctx, mypat, sizeof(mypat) - 1);
PSDRV_WriteImageDict(ctx, 1, FALSE, 8, 8, buf, bmi->bmiHeader.biHeight < 0);
PSDRV_WriteSpool(ctx, "def\n", 4);
PSDRV_WriteIndexColorSpaceBegin(dev, 1);
map[0] = GetTextColor( dev->hdc );
map[1] = GetBkColor( dev->hdc );
PSDRV_WriteRGB(dev, map, 2);
PSDRV_WriteIndexColorSpaceEnd(dev);
PSDRV_WriteIndexColorSpaceBegin(ctx, 1);
map[0] = GetTextColor( ctx->dev.hdc );
map[1] = GetBkColor( ctx->dev.hdc );
PSDRV_WriteRGB(ctx, map, 2);
PSDRV_WriteIndexColorSpaceEnd(ctx);
/* Windows seems to scale patterns so that a one pixel corresponds to 1/300" */
w_mult = (physDev->logPixelsX + 150) / 300;
h_mult = (physDev->logPixelsY + 150) / 300;
w_mult = (ctx->logPixelsX + 150) / 300;
h_mult = (ctx->logPixelsY + 150) / 300;
sprintf(buf, do_pattern, w * w_mult, h * h_mult, w * w_mult, h * h_mult, w * w_mult, h * h_mult);
PSDRV_WriteSpool(dev, buf, strlen(buf));
PSDRV_WriteSpool(ctx, buf, strlen(buf));
HeapFree( GetProcessHeap(), 0, buf );
return TRUE;
}
......@@ -380,14 +380,9 @@ typedef struct
int logPixelsY;
int pathdepth;
} PSDRV_PDEVICE;
} print_ctx;
static inline PSDRV_PDEVICE *get_psdrv_dev( PHYSDEV dev )
{
return (PSDRV_PDEVICE *)dev;
}
extern PSDRV_PDEVICE *create_psdrv_physdev( HDC hdc, const WCHAR *device,
extern print_ctx *create_print_ctx( HDC hdc, const WCHAR *device,
const PSDRV_DEVMODE *devmode ) DECLSPEC_HIDDEN;
/*
......@@ -417,44 +412,44 @@ extern PAGESIZE *find_pagesize( PPD *ppd, const PSDRV_DEVMODE *dm ) DECLSPEC_HID
extern DUPLEX *find_duplex( PPD *ppd, const PSDRV_DEVMODE *dm ) DECLSPEC_HIDDEN;
/* GDI driver functions */
extern BOOL CDECL PSDRV_Arc( PHYSDEV dev, INT left, INT top, INT right, INT bottom,
extern BOOL CDECL PSDRV_Arc( print_ctx *ctx, INT left, INT top, INT right, INT bottom,
INT xstart, INT ystart, INT xend, INT yend ) DECLSPEC_HIDDEN;
extern BOOL CDECL PSDRV_Chord( PHYSDEV dev, INT left, INT top, INT right, INT bottom,
extern BOOL CDECL PSDRV_Chord( print_ctx *ctx, INT left, INT top, INT right, INT bottom,
INT xstart, INT ystart, INT xend, INT yend ) DECLSPEC_HIDDEN;
extern BOOL CDECL PSDRV_Ellipse( PHYSDEV dev, INT left, INT top, INT right, INT bottom) DECLSPEC_HIDDEN;
extern INT CDECL PSDRV_EndPage( PHYSDEV dev ) DECLSPEC_HIDDEN;
extern INT CDECL PSDRV_ExtEscape( PHYSDEV dev, INT nEscape, INT cbInput, LPCVOID in_data,
extern BOOL CDECL PSDRV_Ellipse( print_ctx *ctx, INT left, INT top, INT right, INT bottom) DECLSPEC_HIDDEN;
extern INT CDECL PSDRV_EndPage( print_ctx *ctx ) DECLSPEC_HIDDEN;
extern INT CDECL PSDRV_ExtEscape( print_ctx *ctx, INT nEscape, INT cbInput, LPCVOID in_data,
INT cbOutput, LPVOID out_data ) DECLSPEC_HIDDEN;
extern BOOL CDECL PSDRV_ExtTextOut( PHYSDEV dev, INT x, INT y, UINT flags,
extern BOOL CDECL PSDRV_ExtTextOut( print_ctx *ctx, INT x, INT y, UINT flags,
const RECT *lprect, LPCWSTR str, UINT count, const INT *lpDx ) DECLSPEC_HIDDEN;
extern BOOL CDECL PSDRV_FillPath( PHYSDEV dev ) DECLSPEC_HIDDEN;
extern BOOL CDECL PSDRV_LineTo(PHYSDEV dev, INT x, INT y) DECLSPEC_HIDDEN;
extern BOOL CDECL PSDRV_PaintRgn( PHYSDEV dev, HRGN hrgn ) DECLSPEC_HIDDEN;
extern BOOL CDECL PSDRV_PatBlt(PHYSDEV dev, struct bitblt_coords *dst, DWORD dwRop) DECLSPEC_HIDDEN;
extern BOOL CDECL PSDRV_Pie( PHYSDEV dev, INT left, INT top, INT right, INT bottom,
extern BOOL CDECL PSDRV_FillPath( print_ctx *ctx ) DECLSPEC_HIDDEN;
extern BOOL CDECL PSDRV_LineTo(print_ctx *ctx, INT x, INT y) DECLSPEC_HIDDEN;
extern BOOL CDECL PSDRV_PaintRgn( print_ctx *ctx, HRGN hrgn ) DECLSPEC_HIDDEN;
extern BOOL CDECL PSDRV_PatBlt(print_ctx *ctx, struct bitblt_coords *dst, DWORD dwRop) DECLSPEC_HIDDEN;
extern BOOL CDECL PSDRV_Pie( print_ctx *ctx, INT left, INT top, INT right, INT bottom,
INT xstart, INT ystart, INT xend, INT yend ) DECLSPEC_HIDDEN;
extern BOOL CDECL PSDRV_PolyBezier( PHYSDEV dev, const POINT *pts, DWORD count ) DECLSPEC_HIDDEN;
extern BOOL CDECL PSDRV_PolyBezierTo( PHYSDEV dev, const POINT *pts, DWORD count ) DECLSPEC_HIDDEN;
extern BOOL CDECL PSDRV_PolyPolygon( PHYSDEV dev, const POINT* pts, const INT* counts, UINT polygons ) DECLSPEC_HIDDEN;
extern BOOL CDECL PSDRV_PolyPolyline( PHYSDEV dev, const POINT* pts, const DWORD* counts, DWORD polylines ) DECLSPEC_HIDDEN;
extern DWORD CDECL PSDRV_PutImage( PHYSDEV dev, HRGN clip, BITMAPINFO *info,
extern BOOL CDECL PSDRV_PolyBezier( print_ctx *ctx, const POINT *pts, DWORD count ) DECLSPEC_HIDDEN;
extern BOOL CDECL PSDRV_PolyBezierTo( print_ctx *ctx, const POINT *pts, DWORD count ) DECLSPEC_HIDDEN;
extern BOOL CDECL PSDRV_PolyPolygon( print_ctx *ctx, const POINT* pts, const INT* counts, UINT polygons ) DECLSPEC_HIDDEN;
extern BOOL CDECL PSDRV_PolyPolyline( print_ctx *ctx, const POINT* pts, const DWORD* counts, DWORD polylines ) DECLSPEC_HIDDEN;
extern DWORD CDECL PSDRV_PutImage( print_ctx *ctx, HRGN clip, BITMAPINFO *info,
const struct gdi_image_bits *bits, struct bitblt_coords *src,
struct bitblt_coords *dst, DWORD rop ) DECLSPEC_HIDDEN;
extern BOOL CDECL PSDRV_Rectangle( PHYSDEV dev, INT left, INT top, INT right, INT bottom ) DECLSPEC_HIDDEN;
extern BOOL CDECL PSDRV_RoundRect( PHYSDEV dev, INT left, INT top, INT right,
extern BOOL CDECL PSDRV_Rectangle( print_ctx *ctx, INT left, INT top, INT right, INT bottom ) DECLSPEC_HIDDEN;
extern BOOL CDECL PSDRV_RoundRect( print_ctx *ctx, INT left, INT top, INT right,
INT bottom, INT ell_width, INT ell_height ) DECLSPEC_HIDDEN;
extern HBRUSH CDECL PSDRV_SelectBrush( PHYSDEV dev, HBRUSH hbrush, const struct brush_pattern *pattern ) DECLSPEC_HIDDEN;
extern HFONT CDECL PSDRV_SelectFont( PHYSDEV dev, HFONT hfont, UINT *aa_flags ) DECLSPEC_HIDDEN;
extern HPEN CDECL PSDRV_SelectPen( PHYSDEV dev, HPEN hpen, const struct brush_pattern *pattern ) DECLSPEC_HIDDEN;
extern COLORREF CDECL PSDRV_SetBkColor( PHYSDEV dev, COLORREF color ) DECLSPEC_HIDDEN;
extern COLORREF CDECL PSDRV_SetDCBrushColor( PHYSDEV dev, COLORREF color ) DECLSPEC_HIDDEN;
extern COLORREF CDECL PSDRV_SetDCPenColor( PHYSDEV dev, COLORREF color ) DECLSPEC_HIDDEN;
extern COLORREF CDECL PSDRV_SetPixel( PHYSDEV dev, INT x, INT y, COLORREF color ) DECLSPEC_HIDDEN;
extern COLORREF CDECL PSDRV_SetTextColor( PHYSDEV dev, COLORREF color ) DECLSPEC_HIDDEN;
extern BOOL CDECL PSDRV_StrokeAndFillPath( PHYSDEV dev ) DECLSPEC_HIDDEN;
extern BOOL CDECL PSDRV_StrokePath( PHYSDEV dev ) DECLSPEC_HIDDEN;
extern BOOL CDECL PSDRV_ResetDC( PHYSDEV dev, const DEVMODEW *lpInitData ) DECLSPEC_HIDDEN;
extern HBRUSH CDECL PSDRV_SelectBrush( print_ctx *ctx, HBRUSH hbrush, const struct brush_pattern *pattern ) DECLSPEC_HIDDEN;
extern HFONT CDECL PSDRV_SelectFont( print_ctx *ctx, HFONT hfont, UINT *aa_flags ) DECLSPEC_HIDDEN;
extern HPEN CDECL PSDRV_SelectPen( print_ctx *ctx, HPEN hpen, const struct brush_pattern *pattern ) DECLSPEC_HIDDEN;
extern COLORREF CDECL PSDRV_SetBkColor( print_ctx *ctx, COLORREF color ) DECLSPEC_HIDDEN;
extern COLORREF CDECL PSDRV_SetDCBrushColor( print_ctx *ctx, COLORREF color ) DECLSPEC_HIDDEN;
extern COLORREF CDECL PSDRV_SetDCPenColor( print_ctx *ctx, COLORREF color ) DECLSPEC_HIDDEN;
extern COLORREF CDECL PSDRV_SetPixel( print_ctx *ctx, INT x, INT y, COLORREF color ) DECLSPEC_HIDDEN;
extern COLORREF CDECL PSDRV_SetTextColor( print_ctx *ctx, COLORREF color ) DECLSPEC_HIDDEN;
extern BOOL CDECL PSDRV_StrokeAndFillPath( print_ctx *ctx ) DECLSPEC_HIDDEN;
extern BOOL CDECL PSDRV_StrokePath( print_ctx *ctx ) DECLSPEC_HIDDEN;
extern BOOL CDECL PSDRV_ResetDC( print_ctx *ctx, const DEVMODEW *lpInitData ) DECLSPEC_HIDDEN;
extern void PSDRV_MergeDevmodes(PSDRV_DEVMODE *dm1, const PSDRV_DEVMODE *dm2,
PRINTERINFO *pi) DECLSPEC_HIDDEN;
extern BOOL PSDRV_GetFontMetrics(void) DECLSPEC_HIDDEN;
......@@ -465,66 +460,66 @@ extern BOOL PSDRV_AddAFMtoList(FONTFAMILY **head, const AFM *afm,
BOOL *p_added) DECLSPEC_HIDDEN;
extern void PSDRV_FreeAFMList( FONTFAMILY *head ) DECLSPEC_HIDDEN;
extern INT PSDRV_XWStoDS( PHYSDEV dev, INT width ) DECLSPEC_HIDDEN;
extern INT PSDRV_XWStoDS( print_ctx *ctx, INT width ) DECLSPEC_HIDDEN;
extern BOOL PSDRV_Brush(PHYSDEV dev, BOOL EO) DECLSPEC_HIDDEN;
extern BOOL PSDRV_SetFont( PHYSDEV dev, BOOL vertical ) DECLSPEC_HIDDEN;
extern BOOL PSDRV_SetPen( PHYSDEV dev ) DECLSPEC_HIDDEN;
extern BOOL PSDRV_Brush(print_ctx *ctx, BOOL EO) DECLSPEC_HIDDEN;
extern BOOL PSDRV_SetFont( print_ctx *ctx, BOOL vertical ) DECLSPEC_HIDDEN;
extern BOOL PSDRV_SetPen( print_ctx *ctx ) DECLSPEC_HIDDEN;
extern void PSDRV_AddClip( PHYSDEV dev, HRGN hrgn ) DECLSPEC_HIDDEN;
extern void PSDRV_SetClip( PHYSDEV dev ) DECLSPEC_HIDDEN;
extern void PSDRV_ResetClip( PHYSDEV dev ) DECLSPEC_HIDDEN;
extern void PSDRV_AddClip( print_ctx *ctx, HRGN hrgn ) DECLSPEC_HIDDEN;
extern void PSDRV_SetClip( print_ctx *ctx ) DECLSPEC_HIDDEN;
extern void PSDRV_ResetClip( print_ctx *ctx ) DECLSPEC_HIDDEN;
extern BOOL PSDRV_CopyColor(PSCOLOR *col1, PSCOLOR *col2) DECLSPEC_HIDDEN;
extern void PSDRV_CreateColor( PHYSDEV dev, PSCOLOR *pscolor,
extern void PSDRV_CreateColor( print_ctx *ctx, PSCOLOR *pscolor,
COLORREF wincolor ) DECLSPEC_HIDDEN;
extern PSRGB rgb_to_grayscale_scale( void ) DECLSPEC_HIDDEN;
extern char PSDRV_UnicodeToANSI(int u) DECLSPEC_HIDDEN;
extern INT PSDRV_WriteHeader( PHYSDEV dev, LPCWSTR title ) DECLSPEC_HIDDEN;
extern INT PSDRV_WriteFooter( PHYSDEV dev ) DECLSPEC_HIDDEN;
extern INT PSDRV_WriteNewPage( PHYSDEV dev ) DECLSPEC_HIDDEN;
extern INT PSDRV_WriteEndPage( PHYSDEV dev ) DECLSPEC_HIDDEN;
extern BOOL PSDRV_WriteMoveTo(PHYSDEV dev, INT x, INT y) DECLSPEC_HIDDEN;
extern BOOL PSDRV_WriteLineTo(PHYSDEV dev, INT x, INT y) DECLSPEC_HIDDEN;
extern BOOL PSDRV_WriteStroke(PHYSDEV dev) DECLSPEC_HIDDEN;
extern BOOL PSDRV_WriteRectangle(PHYSDEV dev, INT x, INT y, INT width, INT height) DECLSPEC_HIDDEN;
extern BOOL PSDRV_WriteRRectangle(PHYSDEV dev, INT x, INT y, INT width, INT height) DECLSPEC_HIDDEN;
extern BOOL PSDRV_WriteSetFont(PHYSDEV dev, const char *name, matrix size, INT escapement,
extern INT PSDRV_WriteHeader( print_ctx *ctx, LPCWSTR title ) DECLSPEC_HIDDEN;
extern INT PSDRV_WriteFooter( print_ctx *ctx ) DECLSPEC_HIDDEN;
extern INT PSDRV_WriteNewPage( print_ctx *ctx ) DECLSPEC_HIDDEN;
extern INT PSDRV_WriteEndPage( print_ctx *ctx ) DECLSPEC_HIDDEN;
extern BOOL PSDRV_WriteMoveTo(print_ctx *ctx, INT x, INT y) DECLSPEC_HIDDEN;
extern BOOL PSDRV_WriteLineTo(print_ctx *ctx, INT x, INT y) DECLSPEC_HIDDEN;
extern BOOL PSDRV_WriteStroke(print_ctx *ctx) DECLSPEC_HIDDEN;
extern BOOL PSDRV_WriteRectangle(print_ctx *ctx, INT x, INT y, INT width, INT height) DECLSPEC_HIDDEN;
extern BOOL PSDRV_WriteRRectangle(print_ctx *ctx, INT x, INT y, INT width, INT height) DECLSPEC_HIDDEN;
extern BOOL PSDRV_WriteSetFont(print_ctx *ctx, const char *name, matrix size, INT escapement,
BOOL fake_italic) DECLSPEC_HIDDEN;
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,
extern BOOL PSDRV_WriteGlyphShow(print_ctx *ctx, LPCSTR g_name) DECLSPEC_HIDDEN;
extern BOOL PSDRV_WriteSetPen(print_ctx *ctx) DECLSPEC_HIDDEN;
extern BOOL PSDRV_WriteArc(print_ctx *ctx, 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;
extern BOOL PSDRV_WriteEOFill(PHYSDEV dev) DECLSPEC_HIDDEN;
extern BOOL PSDRV_WriteGSave(PHYSDEV dev) DECLSPEC_HIDDEN;
extern BOOL PSDRV_WriteGRestore(PHYSDEV dev) DECLSPEC_HIDDEN;
extern BOOL PSDRV_WriteNewPath(PHYSDEV dev) DECLSPEC_HIDDEN;
extern BOOL PSDRV_WriteClosePath(PHYSDEV dev) DECLSPEC_HIDDEN;
extern BOOL PSDRV_WriteClip(PHYSDEV dev) DECLSPEC_HIDDEN;
extern BOOL PSDRV_WriteRectClip(PHYSDEV dev, INT x, INT y, INT w, INT h) DECLSPEC_HIDDEN;
extern BOOL PSDRV_WriteRectClip2(PHYSDEV dev, CHAR *pszArrayName) DECLSPEC_HIDDEN;
extern BOOL PSDRV_WriteEOClip(PHYSDEV dev) DECLSPEC_HIDDEN;
extern BOOL PSDRV_WriteHatch(PHYSDEV dev) DECLSPEC_HIDDEN;
extern BOOL PSDRV_WriteRotate(PHYSDEV dev, float ang) DECLSPEC_HIDDEN;
extern BOOL PSDRV_WriteIndexColorSpaceBegin(PHYSDEV dev, int size) DECLSPEC_HIDDEN;
extern BOOL PSDRV_WriteIndexColorSpaceEnd(PHYSDEV dev) DECLSPEC_HIDDEN;
extern BOOL PSDRV_WriteRGBQUAD(PHYSDEV dev, const RGBQUAD *rgb, int number) DECLSPEC_HIDDEN;
extern BOOL PSDRV_WriteImage(PHYSDEV dev, WORD depth, BOOL grayscale, INT xDst, INT yDst,
extern BOOL PSDRV_WriteCurveTo(print_ctx *ctx, POINT pts[3]) DECLSPEC_HIDDEN;
extern BOOL PSDRV_WriteSetColor(print_ctx *ctx, PSCOLOR *color) DECLSPEC_HIDDEN;
extern BOOL PSDRV_WriteSetBrush(print_ctx *ctx) DECLSPEC_HIDDEN;
extern BOOL PSDRV_WriteFill(print_ctx *ctx) DECLSPEC_HIDDEN;
extern BOOL PSDRV_WriteEOFill(print_ctx *ctx) DECLSPEC_HIDDEN;
extern BOOL PSDRV_WriteGSave(print_ctx *ctx) DECLSPEC_HIDDEN;
extern BOOL PSDRV_WriteGRestore(print_ctx *ctx) DECLSPEC_HIDDEN;
extern BOOL PSDRV_WriteNewPath(print_ctx *ctx) DECLSPEC_HIDDEN;
extern BOOL PSDRV_WriteClosePath(print_ctx *ctx) DECLSPEC_HIDDEN;
extern BOOL PSDRV_WriteClip(print_ctx *ctx) DECLSPEC_HIDDEN;
extern BOOL PSDRV_WriteRectClip(print_ctx *ctx, INT x, INT y, INT w, INT h) DECLSPEC_HIDDEN;
extern BOOL PSDRV_WriteRectClip2(print_ctx *ctx, CHAR *pszArrayName) DECLSPEC_HIDDEN;
extern BOOL PSDRV_WriteEOClip(print_ctx *ctx) DECLSPEC_HIDDEN;
extern BOOL PSDRV_WriteHatch(print_ctx *ctx) DECLSPEC_HIDDEN;
extern BOOL PSDRV_WriteRotate(print_ctx *ctx, float ang) DECLSPEC_HIDDEN;
extern BOOL PSDRV_WriteIndexColorSpaceBegin(print_ctx *ctx, int size) DECLSPEC_HIDDEN;
extern BOOL PSDRV_WriteIndexColorSpaceEnd(print_ctx *ctx) DECLSPEC_HIDDEN;
extern BOOL PSDRV_WriteRGBQUAD(print_ctx *ctx, const RGBQUAD *rgb, int number) DECLSPEC_HIDDEN;
extern BOOL PSDRV_WriteImage(print_ctx *ctx, WORD depth, BOOL grayscale, INT xDst, INT yDst,
INT widthDst, INT heightDst, INT widthSrc,
INT heightSrc, BOOL mask, BOOL top_down) DECLSPEC_HIDDEN;
extern BOOL PSDRV_WriteBytes(PHYSDEV dev, const BYTE *bytes, DWORD number) DECLSPEC_HIDDEN;
extern BOOL PSDRV_WriteData(PHYSDEV dev, const BYTE *byte, DWORD number) DECLSPEC_HIDDEN;
extern DWORD PSDRV_WriteSpool(PHYSDEV dev, LPCSTR lpData, DWORD cch) DECLSPEC_HIDDEN;
extern BOOL PSDRV_WriteDIBPatternDict(PHYSDEV dev, const BITMAPINFO *bmi, BYTE *bits, UINT usage) DECLSPEC_HIDDEN;
extern BOOL PSDRV_WriteArrayPut(PHYSDEV dev, CHAR *pszArrayName, INT nIndex, LONG lCoord) DECLSPEC_HIDDEN;
extern BOOL PSDRV_WriteArrayDef(PHYSDEV dev, CHAR *pszArrayName, INT nSize) DECLSPEC_HIDDEN;
extern BOOL PSDRV_WriteBytes(print_ctx *ctx, const BYTE *bytes, DWORD number) DECLSPEC_HIDDEN;
extern BOOL PSDRV_WriteData(print_ctx *ctx, const BYTE *byte, DWORD number) DECLSPEC_HIDDEN;
extern DWORD PSDRV_WriteSpool(print_ctx *ctx, LPCSTR lpData, DWORD cch) DECLSPEC_HIDDEN;
extern BOOL PSDRV_WriteDIBPatternDict(print_ctx *ctx, const BITMAPINFO *bmi, BYTE *bits, UINT usage) DECLSPEC_HIDDEN;
extern BOOL PSDRV_WriteArrayPut(print_ctx *ctx, CHAR *pszArrayName, INT nIndex, LONG lCoord) DECLSPEC_HIDDEN;
extern BOOL PSDRV_WriteArrayDef(print_ctx *ctx, CHAR *pszArrayName, INT nSize) DECLSPEC_HIDDEN;
extern INT CDECL PSDRV_StartPage( PHYSDEV dev ) DECLSPEC_HIDDEN;
extern INT CDECL PSDRV_StartPage( print_ctx *ctx ) DECLSPEC_HIDDEN;
INT PSDRV_GlyphListInit(void) DECLSPEC_HIDDEN;
const GLYPHNAME *PSDRV_GlyphName(LPCSTR szName) DECLSPEC_HIDDEN;
......@@ -533,36 +528,36 @@ BOOL PSDRV_GetType1Metrics(void) DECLSPEC_HIDDEN;
const AFMMETRICS *PSDRV_UVMetrics(LONG UV, const AFM *afm) DECLSPEC_HIDDEN;
SHORT PSDRV_CalcAvgCharWidth(const AFM *afm) DECLSPEC_HIDDEN;
extern BOOL PSDRV_WriteSetBuiltinFont(PHYSDEV dev) DECLSPEC_HIDDEN;
extern BOOL PSDRV_WriteBuiltinGlyphShow(PHYSDEV dev, LPCWSTR str, INT count) DECLSPEC_HIDDEN;
extern BOOL PSDRV_WriteSetBuiltinFont(print_ctx *ctx) DECLSPEC_HIDDEN;
extern BOOL PSDRV_WriteBuiltinGlyphShow(print_ctx *ctx, LPCWSTR str, INT count) DECLSPEC_HIDDEN;
extern BOOL PSDRV_SelectDownloadFont(PHYSDEV dev) DECLSPEC_HIDDEN;
extern BOOL PSDRV_WriteSetDownloadFont(PHYSDEV dev, BOOL vertical) DECLSPEC_HIDDEN;
extern BOOL PSDRV_WriteDownloadGlyphShow(PHYSDEV dev, const WORD *glyphs, UINT count) DECLSPEC_HIDDEN;
extern BOOL PSDRV_EmptyDownloadList(PHYSDEV dev, BOOL write_undef) DECLSPEC_HIDDEN;
extern BOOL PSDRV_SelectDownloadFont(print_ctx *ctx) DECLSPEC_HIDDEN;
extern BOOL PSDRV_WriteSetDownloadFont(print_ctx *ctx, BOOL vertical) DECLSPEC_HIDDEN;
extern BOOL PSDRV_WriteDownloadGlyphShow(print_ctx *ctx, const WORD *glyphs, UINT count) DECLSPEC_HIDDEN;
extern BOOL PSDRV_EmptyDownloadList(print_ctx *ctx, BOOL write_undef) DECLSPEC_HIDDEN;
extern DWORD write_spool( PHYSDEV dev, const void *data, DWORD num ) DECLSPEC_HIDDEN;
extern DWORD write_spool( print_ctx *ctx, const void *data, DWORD num ) DECLSPEC_HIDDEN;
#define MAX_G_NAME 31 /* max length of PS glyph name */
extern void get_glyph_name(HDC hdc, WORD index, char *name) DECLSPEC_HIDDEN;
extern TYPE1 *T1_download_header(PHYSDEV dev, char *ps_name,
extern TYPE1 *T1_download_header(print_ctx *ctx, char *ps_name,
RECT *bbox, UINT emsize) DECLSPEC_HIDDEN;
extern BOOL T1_download_glyph(PHYSDEV dev, DOWNLOAD *pdl,
extern BOOL T1_download_glyph(print_ctx *ctx, DOWNLOAD *pdl,
DWORD index, char *glyph_name) DECLSPEC_HIDDEN;
extern void T1_free(TYPE1 *t1) DECLSPEC_HIDDEN;
extern TYPE42 *T42_download_header(PHYSDEV dev, char *ps_name,
extern TYPE42 *T42_download_header(print_ctx *ctx, char *ps_name,
RECT *bbox, UINT emsize) DECLSPEC_HIDDEN;
extern BOOL T42_download_glyph(PHYSDEV dev, DOWNLOAD *pdl,
extern BOOL T42_download_glyph(print_ctx *ctx, DOWNLOAD *pdl,
DWORD index, char *glyph_name) DECLSPEC_HIDDEN;
extern void T42_free(TYPE42 *t42) DECLSPEC_HIDDEN;
extern DWORD RLE_encode(BYTE *in_buf, DWORD len, BYTE *out_buf) DECLSPEC_HIDDEN;
extern DWORD ASCII85_encode(BYTE *in_buf, DWORD len, BYTE *out_buf) DECLSPEC_HIDDEN;
extern void passthrough_enter(PHYSDEV dev) DECLSPEC_HIDDEN;
extern void passthrough_leave(PHYSDEV dev) DECLSPEC_HIDDEN;
extern void passthrough_enter(print_ctx *ctx) DECLSPEC_HIDDEN;
extern void passthrough_leave(print_ctx *ctx) DECLSPEC_HIDDEN;
#define push_lc_numeric(x) do { \
const char *tmplocale = setlocale(LC_NUMERIC,NULL); \
......
......@@ -36,7 +36,7 @@ typedef struct tagRun {
INT y;
}Run;
static BOOL PSDRV_Text(PHYSDEV dev, INT x, INT y, UINT flags,
static BOOL PSDRV_Text(print_ctx *ctx, INT x, INT y, UINT flags,
LPCWSTR str, UINT count,
BOOL bDrawBackground, const INT *lpDx);
......@@ -56,7 +56,7 @@ static BOOL check_unicode_tategaki(WCHAR uchar)
return (orientation == 1 || orientation == 2 || orientation == 3);
}
static Run* build_vertical_runs(PHYSDEV dev, UINT flags, LPCWSTR str, UINT count, INT *run_count)
static Run* build_vertical_runs(print_ctx *ctx, UINT flags, LPCWSTR str, UINT count, INT *run_count)
{
BOOL last_vert;
INT start, end;
......@@ -65,7 +65,7 @@ static Run* build_vertical_runs(PHYSDEV dev, UINT flags, LPCWSTR str, UINT count
int index = 0;
LOGFONTW lf;
if (count && str && (!(flags & ETO_GLYPH_INDEX)) && GetObjectW( GetCurrentObject(dev->hdc, OBJ_FONT), sizeof(lf), &lf ) && (lf.lfFaceName[0] == '@'))
if (count && str && (!(flags & ETO_GLYPH_INDEX)) && GetObjectW( GetCurrentObject(ctx->dev.hdc, OBJ_FONT), sizeof(lf), &lf ) && (lf.lfFaceName[0] == '@'))
{
last_vert = check_unicode_tategaki(str[0]);
start = end = 0;
......@@ -84,15 +84,15 @@ static Run* build_vertical_runs(PHYSDEV dev, UINT flags, LPCWSTR str, UINT count
if (run[index].vertical)
{
TEXTMETRICW tm;
GetTextMetricsW(dev->hdc, &tm);
offset += PSDRV_XWStoDS(dev, tm.tmAscent - tm.tmInternalLeading);
GetTextMetricsW(ctx->dev.hdc, &tm);
offset += PSDRV_XWStoDS(ctx, tm.tmAscent - tm.tmInternalLeading);
}
if (start > 0)
{
SIZE size;
GetTextExtentPointW(dev->hdc, str, start, &size);
offset += PSDRV_XWStoDS(dev, size.cx);
GetTextExtentPointW(ctx->dev.hdc, str, start, &size);
offset += PSDRV_XWStoDS(ctx, size.cx);
}
if (offset)
......@@ -129,10 +129,9 @@ static Run* build_vertical_runs(PHYSDEV dev, UINT flags, LPCWSTR str, UINT count
/***********************************************************************
* PSDRV_ExtTextOut
*/
BOOL CDECL PSDRV_ExtTextOut( PHYSDEV dev, INT x, INT y, UINT flags, const RECT *lprect, LPCWSTR str, UINT count,
BOOL CDECL PSDRV_ExtTextOut( print_ctx *ctx, INT x, INT y, UINT flags, const RECT *lprect, LPCWSTR str, UINT count,
const INT *lpDx )
{
PSDRV_PDEVICE *physDev = get_psdrv_dev( dev );
BOOL bResult = TRUE;
BOOL bClipped = FALSE;
BOOL bOpaque = FALSE;
......@@ -143,24 +142,24 @@ BOOL CDECL PSDRV_ExtTextOut( PHYSDEV dev, INT x, INT y, UINT flags, const RECT *
TRACE("(x=%d, y=%d, flags=0x%08x, str=%s, count=%d, lpDx=%p)\n", x, y,
flags, debugstr_wn(str, count), count, lpDx);
if(physDev->job.id == 0) return FALSE;
if(ctx->job.id == 0) return FALSE;
runs = build_vertical_runs(dev, flags, str, count, &run_count);
runs = build_vertical_runs(ctx, flags, str, count, &run_count);
/* set draw background */
if ((flags & ETO_OPAQUE) && (lprect != NULL))
{
PSDRV_SetClip(dev);
PSDRV_WriteGSave(dev);
PSDRV_WriteRectangle(dev, lprect->left, lprect->top, lprect->right - lprect->left,
PSDRV_SetClip(ctx);
PSDRV_WriteGSave(ctx);
PSDRV_WriteRectangle(ctx, lprect->left, lprect->top, lprect->right - lprect->left,
lprect->bottom - lprect->top);
bOpaque = TRUE;
PSDRV_WriteSetColor(dev, &physDev->bkColor);
PSDRV_WriteFill(dev);
PSDRV_WriteSetColor(ctx, &ctx->bkColor);
PSDRV_WriteFill(ctx);
PSDRV_WriteGRestore(dev);
PSDRV_ResetClip(dev);
PSDRV_WriteGRestore(ctx);
PSDRV_ResetClip(ctx);
}
while (i < run_count)
......@@ -172,30 +171,30 @@ BOOL CDECL PSDRV_ExtTextOut( PHYSDEV dev, INT x, INT y, UINT flags, const RECT *
else
cnt = count - runs[i].start;
PSDRV_SetFont(dev, runs[i].vertical);
PSDRV_SetFont(ctx, runs[i].vertical);
PSDRV_SetClip(dev);
PSDRV_SetClip(ctx);
/* set clipping */
if ((flags & ETO_CLIPPED) && (lprect != NULL))
{
PSDRV_WriteGSave(dev);
PSDRV_WriteGSave(ctx);
PSDRV_WriteRectangle(dev, lprect->left, lprect->top, lprect->right - lprect->left,
PSDRV_WriteRectangle(ctx, lprect->left, lprect->top, lprect->right - lprect->left,
lprect->bottom - lprect->top);
bClipped = TRUE;
PSDRV_WriteClip(dev);
PSDRV_WriteClip(ctx);
bResult = PSDRV_Text(dev, runs[i].x+x, runs[i].y+y, flags, &str[runs[i].start], cnt, !(bClipped && bOpaque), (lpDx)?&lpDx[runs[i].start]:NULL);
bResult = PSDRV_Text(ctx, runs[i].x+x, runs[i].y+y, flags, &str[runs[i].start], cnt, !(bClipped && bOpaque), (lpDx)?&lpDx[runs[i].start]:NULL);
PSDRV_WriteGRestore(dev);
PSDRV_WriteGRestore(ctx);
}
else
bResult = PSDRV_Text(dev, runs[i].x+x, runs[i].y+y, flags, &str[runs[i].start], cnt, TRUE, (lpDx)?&lpDx[runs[i].start]:NULL);
bResult = PSDRV_Text(ctx, runs[i].x+x, runs[i].y+y, flags, &str[runs[i].start], cnt, TRUE, (lpDx)?&lpDx[runs[i].start]:NULL);
i++;
PSDRV_ResetClip(dev);
PSDRV_ResetClip(ctx);
}
HeapFree(GetProcessHeap(),0,runs);
......@@ -205,39 +204,38 @@ BOOL CDECL PSDRV_ExtTextOut( PHYSDEV dev, INT x, INT y, UINT flags, const RECT *
/***********************************************************************
* PSDRV_Text
*/
static BOOL PSDRV_Text(PHYSDEV dev, INT x, INT y, UINT flags, LPCWSTR str,
static BOOL PSDRV_Text(print_ctx *ctx, INT x, INT y, UINT flags, LPCWSTR str,
UINT count, BOOL bDrawBackground, const INT *lpDx)
{
PSDRV_PDEVICE *physDev = get_psdrv_dev( dev );
WORD *glyphs = NULL;
if (!count)
return TRUE;
if(physDev->font.fontloc == Download && !(flags & ETO_GLYPH_INDEX))
if(ctx->font.fontloc == Download && !(flags & ETO_GLYPH_INDEX))
{
glyphs = HeapAlloc( GetProcessHeap(), 0, count * sizeof(WORD) );
GetGlyphIndicesW( dev->hdc, str, count, glyphs, 0 );
GetGlyphIndicesW( ctx->dev.hdc, str, count, glyphs, 0 );
str = glyphs;
}
PSDRV_WriteMoveTo(dev, x, y);
PSDRV_WriteMoveTo(ctx, x, y);
if(!lpDx) {
if(physDev->font.fontloc == Download)
PSDRV_WriteDownloadGlyphShow(dev, str, count);
if(ctx->font.fontloc == Download)
PSDRV_WriteDownloadGlyphShow(ctx, str, count);
else
PSDRV_WriteBuiltinGlyphShow(dev, str, count);
PSDRV_WriteBuiltinGlyphShow(ctx, str, count);
}
else {
UINT i;
POINT offset = {0, 0};
for(i = 0; i < count-1; i++) {
if(physDev->font.fontloc == Download)
PSDRV_WriteDownloadGlyphShow(dev, str + i, 1);
if(ctx->font.fontloc == Download)
PSDRV_WriteDownloadGlyphShow(ctx, str + i, 1);
else
PSDRV_WriteBuiltinGlyphShow(dev, str + i, 1);
PSDRV_WriteBuiltinGlyphShow(ctx, str + i, 1);
if(flags & ETO_PDY)
{
offset.x += lpDx[i * 2];
......@@ -245,12 +243,12 @@ static BOOL PSDRV_Text(PHYSDEV dev, INT x, INT y, UINT flags, LPCWSTR str,
}
else
offset.x += lpDx[i];
PSDRV_WriteMoveTo(dev, x + offset.x, y + offset.y);
PSDRV_WriteMoveTo(ctx, x + offset.x, y + offset.y);
}
if(physDev->font.fontloc == Download)
PSDRV_WriteDownloadGlyphShow(dev, str + i, 1);
if(ctx->font.fontloc == Download)
PSDRV_WriteDownloadGlyphShow(ctx, str + i, 1);
else
PSDRV_WriteBuiltinGlyphShow(dev, str + i, 1);
PSDRV_WriteBuiltinGlyphShow(ctx, str + i, 1);
}
HeapFree( GetProcessHeap(), 0, glyphs );
......
......@@ -67,7 +67,7 @@ static inline WORD get_be_word(const void *p) { return RtlUshortByteSwap(*(con
static inline DWORD get_be_dword(const void *p) { return RtlUlongByteSwap(*(const DWORD*)p); }
#endif
TYPE1 *T1_download_header(PHYSDEV dev, char *ps_name, RECT *bbox, UINT emsize)
TYPE1 *T1_download_header(print_ctx *ctx, char *ps_name, RECT *bbox, UINT emsize)
{
char *buf;
TYPE1 *t1;
......@@ -110,7 +110,7 @@ TYPE1 *T1_download_header(PHYSDEV dev, char *ps_name, RECT *bbox, UINT emsize)
sprintf(buf, dict, ps_name, t1->emsize, t1->emsize,
bbox->left, bbox->bottom, bbox->right, bbox->top);
PSDRV_WriteSpool(dev, buf, strlen(buf));
PSDRV_WriteSpool(ctx, buf, strlen(buf));
HeapFree(GetProcessHeap(), 0, buf);
return t1;
......@@ -530,7 +530,7 @@ static inline BOOL on_point(const glyph_outline *outline, WORD pt)
return outline->flags[pt] & 1;
}
BOOL T1_download_glyph(PHYSDEV dev, DOWNLOAD *pdl, DWORD index, char *glyph_name)
BOOL T1_download_glyph(print_ctx *ctx, DOWNLOAD *pdl, DWORD index, char *glyph_name)
{
DWORD len;
WORD cur_pt, cont;
......@@ -568,9 +568,9 @@ BOOL T1_download_glyph(PHYSDEV dev, DOWNLOAD *pdl, DWORD index, char *glyph_name
outline.flags = NULL;
outline.end_pts = NULL;
outline.pts = NULL;
get_hmetrics(dev->hdc, index, &outline.lsb, &outline.advance);
get_hmetrics(ctx->dev.hdc, index, &outline.lsb, &outline.advance);
if(!append_glyph_outline(dev->hdc, index, &outline)) return FALSE;
if(!append_glyph_outline(ctx->dev.hdc, index, &outline)) return FALSE;
charstring = str_init(100);
curpos.x = outline.lsb;
......@@ -650,14 +650,14 @@ BOOL T1_download_glyph(PHYSDEV dev, DOWNLOAD *pdl, DWORD index, char *glyph_name
strlen(pdl->ps_name) + strlen(glyph_name) + 100);
sprintf(buf, "%%%%glyph %04lx\n", index);
PSDRV_WriteSpool(dev, buf, strlen(buf));
PSDRV_WriteSpool(ctx, buf, strlen(buf));
len = str_get_bytes(charstring, &bytes);
sprintf(buf, glyph_def_begin, pdl->ps_name, glyph_name, len);
PSDRV_WriteSpool(dev, buf, strlen(buf));
PSDRV_WriteBytes(dev, bytes, len);
PSDRV_WriteSpool(ctx, buf, strlen(buf));
PSDRV_WriteBytes(ctx, bytes, len);
sprintf(buf, glyph_def_end);
PSDRV_WriteSpool(dev, buf, strlen(buf));
PSDRV_WriteSpool(ctx, buf, strlen(buf));
str_free(charstring);
t1->glyph_sent[index] = TRUE;
......
......@@ -136,7 +136,7 @@ static BOOL get_glyf_pos(TYPE42 *t42, DWORD index, DWORD *start, DWORD *end)
return TRUE;
}
TYPE42 *T42_download_header(PHYSDEV dev, char *ps_name,
TYPE42 *T42_download_header(print_ctx *ctx, char *ps_name,
RECT *bbox, UINT emsize)
{
DWORD i, j, tablepos, nb_blocks, glyf_off = 0, loca_off = 0, cur_off;
......@@ -175,7 +175,7 @@ TYPE42 *T42_download_header(PHYSDEV dev, char *ps_name,
t42->num_of_written_tables = 0;
for(i = 0; i < num_of_tables; i++) {
LoadTable(dev->hdc, t42->tables + i);
LoadTable(ctx->dev.hdc, t42->tables + i);
if(t42->tables[i].len > 0xffff && t42->tables[i].write) break;
if(t42->tables[i].write) t42->num_of_written_tables++;
if(t42->tables[i].MS_tag == MS_MAKE_TAG('l','o','c','a'))
......@@ -209,13 +209,13 @@ TYPE42 *T42_download_header(PHYSDEV dev, char *ps_name,
(float)bbox->right / emsize, (float)bbox->top / emsize);
pop_lc_numeric();
PSDRV_WriteSpool(dev, buf, strlen(buf));
PSDRV_WriteSpool(ctx, buf, strlen(buf));
t42->num_of_written_tables++; /* explicitly add glyf */
sprintf(buf, TT_offset_table, t42->num_of_written_tables,
t42->num_of_written_tables, t42->num_of_written_tables, t42->num_of_written_tables);
PSDRV_WriteSpool(dev, buf, strlen(buf));
PSDRV_WriteSpool(ctx, buf, strlen(buf));
tablepos = 12 + t42->num_of_written_tables * 16;
cur_off = 12;
......@@ -224,7 +224,7 @@ TYPE42 *T42_download_header(PHYSDEV dev, char *ps_name,
sprintf(buf, TT_table_dir_entry, FLIP_ORDER(t42->tables[i].MS_tag),
t42->tables[i].check, t42->tables[i].len ? tablepos : 0,
t42->tables[i].len);
PSDRV_WriteSpool(dev, buf, strlen(buf));
PSDRV_WriteSpool(ctx, buf, strlen(buf));
tablepos += ((t42->tables[i].len + 3) & ~3);
if(t42->tables[i].MS_tag == MS_MAKE_TAG('l','o','c','a'))
loca_off = cur_off;
......@@ -232,19 +232,19 @@ TYPE42 *T42_download_header(PHYSDEV dev, char *ps_name,
}
sprintf(buf, TT_table_dir_entry, FLIP_ORDER(t42->tables[t42->glyf_tab].MS_tag),
t42->tables[t42->glyf_tab].check, tablepos, t42->tables[t42->glyf_tab].len);
PSDRV_WriteSpool(dev, buf, strlen(buf));
PSDRV_WriteSpool(dev, "00>\n", 4); /* add an extra byte for old PostScript rips */
PSDRV_WriteSpool(ctx, buf, strlen(buf));
PSDRV_WriteSpool(ctx, "00>\n", 4); /* add an extra byte for old PostScript rips */
glyf_off = cur_off;
for(i = 0; i < num_of_tables; i++) {
if(t42->tables[i].len == 0 || !t42->tables[i].write) continue;
PSDRV_WriteSpool(dev, "<", 1);
PSDRV_WriteSpool(ctx, "<", 1);
for(j = 0; j < ((t42->tables[i].len + 3) & ~3); j++) {
sprintf(buf, "%02x", t42->tables[i].data[j]);
PSDRV_WriteSpool(dev, buf, strlen(buf));
if(j % 16 == 15) PSDRV_WriteSpool(dev, "\n", 1);
PSDRV_WriteSpool(ctx, buf, strlen(buf));
if(j % 16 == 15) PSDRV_WriteSpool(ctx, "\n", 1);
}
PSDRV_WriteSpool(dev, "00>\n", 4); /* add an extra byte for old PostScript rips */
PSDRV_WriteSpool(ctx, "00>\n", 4); /* add an extra byte for old PostScript rips */
}
/* glyf_blocks is a 0 terminated list, holding the start offset of each block. For simplicity
......@@ -263,17 +263,17 @@ TYPE42 *T42_download_header(PHYSDEV dev, char *ps_name,
t42->glyf_blocks[nb_blocks-1] = end;
}
PSDRV_WriteSpool(dev, "[ ", 2);
PSDRV_WriteSpool(ctx, "[ ", 2);
for(i = 1; t42->glyf_blocks[i]; i++) {
sprintf(buf,"%ld ", t42->glyf_blocks[i] - t42->glyf_blocks[i-1] + 1);
/* again add one byte for old PostScript rips */
PSDRV_WriteSpool(dev, buf, strlen(buf));
PSDRV_WriteSpool(ctx, buf, strlen(buf));
if(i % 8 == 0)
PSDRV_WriteSpool(dev, "\n", 1);
PSDRV_WriteSpool(ctx, "\n", 1);
}
PSDRV_WriteSpool(dev, storage, sizeof(storage) - 1);
PSDRV_WriteSpool(ctx, storage, sizeof(storage) - 1);
sprintf(buf, end, loca_off, glyf_off);
PSDRV_WriteSpool(dev, buf, strlen(buf));
PSDRV_WriteSpool(ctx, buf, strlen(buf));
HeapFree(GetProcessHeap(), 0, buf);
return t42;
}
......@@ -281,7 +281,7 @@ TYPE42 *T42_download_header(PHYSDEV dev, char *ps_name,
BOOL T42_download_glyph(PHYSDEV dev, DOWNLOAD *pdl, DWORD index,
BOOL T42_download_glyph(print_ctx *ctx, DOWNLOAD *pdl, DWORD index,
char *glyph_name)
{
DWORD start, end, i;
......@@ -328,8 +328,8 @@ BOOL T42_download_glyph(PHYSDEV dev, DOWNLOAD *pdl, DWORD index,
sg_index = GET_BE_WORD(sg_start + 2);
TRACE("Sending subglyph %04lx for glyph %04lx\n", sg_index, index);
get_glyph_name(dev->hdc, sg_index, sg_name);
T42_download_glyph(dev, pdl, sg_index, sg_name);
get_glyph_name(ctx->dev.hdc, sg_index, sg_name);
T42_download_glyph(ctx, pdl, sg_index, sg_name);
sg_start += 4;
if(sg_flags & ARG_1_AND_2_ARE_WORDS)
sg_start += 4;
......@@ -353,18 +353,18 @@ BOOL T42_download_glyph(PHYSDEV dev, DOWNLOAD *pdl, DWORD index,
/* we don't have a string for the gdir and glyf tables, but we do have a
string for the TT header. So the offset we need is tables - 2 */
sprintf(buf, "%ld %ld\n", t42->num_of_written_tables - 2 + i, start - t42->glyf_blocks[i-1]);
PSDRV_WriteSpool(dev, buf, strlen(buf));
PSDRV_WriteSpool(ctx, buf, strlen(buf));
PSDRV_WriteSpool(dev, "<", 1);
PSDRV_WriteSpool(ctx, "<", 1);
for(i = start; i < end; i++) {
sprintf(buf, "%02x", *(t42->tables[t42->glyf_tab].data + i));
PSDRV_WriteSpool(dev, buf, strlen(buf));
PSDRV_WriteSpool(ctx, buf, strlen(buf));
if((i - start) % 16 == 15)
PSDRV_WriteSpool(dev, "\n", 1);
PSDRV_WriteSpool(ctx, "\n", 1);
}
PSDRV_WriteSpool(dev, ">\n", 2);
PSDRV_WriteSpool(ctx, ">\n", 2);
sprintf(buf, glyph_def, pdl->ps_name, index, glyph_name, index);
PSDRV_WriteSpool(dev, buf, strlen(buf));
PSDRV_WriteSpool(ctx, buf, strlen(buf));
t42->glyph_sent[index] = TRUE;
HeapFree(GetProcessHeap(), 0, buf);
......
......@@ -60,6 +60,13 @@ struct printer_info
static struct list printer_info_list = LIST_INIT( printer_info_list );
typedef print_ctx PSDRV_PDEVICE;
static inline PSDRV_PDEVICE *get_psdrv_dev(PHYSDEV dev)
{
return (PSDRV_PDEVICE *)dev;
}
/* copied from kernelbase */
static int muldiv(int a, int b, int c)
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment