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;
}
......@@ -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;
}
......@@ -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;
}
}
......
......@@ -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