-- v3: wineps: Define PSDRV_PDEVICE structure in unixlib. wineps: Rename PSDRV_PDEVICE structure to print_ctx. wineps: Move remaining DC driver functions to unixlib. gdi32: Add device name to wine_get_gdi_driver call. wineps: Remove no longer used PSDRV_StartDoc and PSDRV_EndDoc functions. wineps: Remove no longer used font selection code from PE side. wineps: Don't use BUILTIN structure on PE side.
From: Piotr Caban piotr@codeweavers.com
--- dlls/wineps.drv/init.c | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-)
diff --git a/dlls/wineps.drv/init.c b/dlls/wineps.drv/init.c index b08f02ddb11..97f68d19a91 100644 --- a/dlls/wineps.drv/init.c +++ b/dlls/wineps.drv/init.c @@ -93,12 +93,6 @@ static const PSDRV_DEVMODE DefaultDevmode = HINSTANCE PSDRV_hInstance = 0; HANDLE PSDRV_Heap = 0;
-static HFONT PSDRV_DefaultFont = 0; -static const LOGFONTA DefaultLogFont = { - 100, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, ANSI_CHARSET, 0, 0, - DEFAULT_QUALITY, FIXED_PITCH | FF_MODERN, "" -}; - static struct gdi_dc_funcs psdrv_funcs;
/********************************************************************* @@ -134,18 +128,11 @@ BOOL WINAPI DllMain( HINSTANCE hinst, DWORD reason, LPVOID reserved ) HeapDestroy(PSDRV_Heap); return FALSE; } - - PSDRV_DefaultFont = CreateFontIndirectA(&DefaultLogFont); - if (PSDRV_DefaultFont == NULL) { - HeapDestroy(PSDRV_Heap); - return FALSE; - } break; }
case DLL_PROCESS_DETACH: if (reserved) break; - DeleteObject( PSDRV_DefaultFont ); HeapDestroy( PSDRV_Heap ); break; } @@ -391,7 +378,7 @@ PSDRV_PDEVICE *create_psdrv_physdev( HDC hdc, const WCHAR *device, }
PSDRV_UpdateDevCaps( pdev ); - SelectObject( hdc, PSDRV_DefaultFont ); + SelectObject( hdc, GetStockObject( DEVICE_DEFAULT_FONT )); return pdev; }
From: Piotr Caban piotr@codeweavers.com
--- dlls/wineps.drv/builtin.c | 7 ++-- dlls/wineps.drv/unixlib.c | 67 +++++++++++++++++++++++---------------- dlls/wineps.drv/unixlib.h | 2 ++ 3 files changed, 44 insertions(+), 32 deletions(-)
diff --git a/dlls/wineps.drv/builtin.c b/dlls/wineps.drv/builtin.c index 74ffda36f92..4fdbc58f099 100644 --- a/dlls/wineps.drv/builtin.c +++ b/dlls/wineps.drv/builtin.c @@ -31,6 +31,7 @@ #include "winternl.h"
#include "psdrv.h" +#include "unixlib.h" #include "wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL(psdrv); @@ -244,14 +245,12 @@ BOOL PSDRV_WriteSetBuiltinFont(PHYSDEV dev)
BOOL PSDRV_WriteBuiltinGlyphShow(PHYSDEV dev, LPCWSTR str, INT count) { - PSDRV_PDEVICE *physDev = get_psdrv_dev( dev ); + char name[32]; int i; - LPCSTR name;
for (i = 0; i < count; ++i) { - name = PSDRV_UVMetrics(str[i], physDev->font.fontinfo.Builtin.afm)->N->sz; - + ExtEscape(dev->hdc, PSDRV_GET_GLYPH_NAME, sizeof(str[i]), (const char *)&str[i], sizeof(name), name); PSDRV_WriteGlyphShow(dev, name); }
diff --git a/dlls/wineps.drv/unixlib.c b/dlls/wineps.drv/unixlib.c index 72f63c81300..36971f65495 100644 --- a/dlls/wineps.drv/unixlib.c +++ b/dlls/wineps.drv/unixlib.c @@ -518,6 +518,34 @@ static BOOL CDECL reset_dc(PHYSDEV dev, const DEVMODEW *devmode) return TRUE; }
+static int metrics_by_uv(const void *a, const void *b) +{ + return (int)(((const AFMMETRICS *)a)->UV - ((const AFMMETRICS *)b)->UV); +} + +const AFMMETRICS *uv_metrics(LONG uv, const AFM *afm) +{ + const AFMMETRICS *needle; + AFMMETRICS key; + + /* + * Ugly work-around for symbol fonts. Wine is sending characters which + * belong in the Unicode private use range (U+F020 - U+F0FF) as ASCII + * characters (U+0020 - U+00FF). + */ + if ((afm->Metrics->UV & 0xff00) == 0xf000 && uv < 0x100) + uv |= 0xf000; + + key.UV = uv; + needle = bsearch(&key, afm->Metrics, afm->NumofMetrics, sizeof(AFMMETRICS), metrics_by_uv); + if (!needle) + { + WARN("No glyph for U+%.4X in '%s'\n", (int)uv, afm->FontName); + needle = afm->Metrics; + } + return needle; +} + static int CDECL ext_escape(PHYSDEV dev, int escape, int input_size, const void *input, int output_size, void *output) { @@ -770,6 +798,17 @@ static int CDECL ext_escape(PHYSDEV dev, int escape, int input_size, const void
case CLIP_TO_PATH: return 1; + + case PSDRV_GET_GLYPH_NAME: + { + PSDRV_PDEVICE *pdev = get_psdrv_dev(dev); + WCHAR *uv = (WCHAR *)input; + const char *name = uv_metrics(*uv, pdev->font.fontinfo.Builtin.afm)->N->sz; + + lstrcpynA(output, name, output_size); + return 1; + } + default: FIXME("Unimplemented code %d\n", escape); return 0; @@ -1135,34 +1174,6 @@ static BOOL CDECL enum_fonts(PHYSDEV dev, LPLOGFONTW plf, FONTENUMPROCW proc, LP return ret; }
-static int metrics_by_uv(const void *a, const void *b) -{ - return (int)(((const AFMMETRICS *)a)->UV - ((const AFMMETRICS *)b)->UV); -} - -const AFMMETRICS *uv_metrics(LONG uv, const AFM *afm) -{ - const AFMMETRICS *needle; - AFMMETRICS key; - - /* - * Ugly work-around for symbol fonts. Wine is sending characters which - * belong in the Unicode private use range (U+F020 - U+F0FF) as ASCII - * characters (U+0020 - U+00FF). - */ - if ((afm->Metrics->UV & 0xff00) == 0xf000 && uv < 0x100) - uv |= 0xf000; - - key.UV = uv; - needle = bsearch(&key, afm->Metrics, afm->NumofMetrics, sizeof(AFMMETRICS), metrics_by_uv); - if (!needle) - { - WARN("No glyph for U+%.4X in '%s'\n", (int)uv, afm->FontName); - needle = afm->Metrics; - } - return needle; -} - static BOOL CDECL get_char_width(PHYSDEV dev, UINT first, UINT count, const WCHAR *chars, INT *buffer) { PSDRV_PDEVICE *pdev = get_psdrv_dev(dev); diff --git a/dlls/wineps.drv/unixlib.h b/dlls/wineps.drv/unixlib.h index 95efdd4c310..eb82188807c 100644 --- a/dlls/wineps.drv/unixlib.h +++ b/dlls/wineps.drv/unixlib.h @@ -19,6 +19,8 @@ #include "ntuser.h" #include "wine/unixlib.h"
+#define PSDRV_GET_GLYPH_NAME 0x10000 + enum wineps_funcs { unix_init_dc,
From: Piotr Caban piotr@codeweavers.com
--- dlls/wineps.drv/builtin.c | 5 ----- dlls/wineps.drv/download.c | 5 ----- dlls/wineps.drv/psdrv.h | 5 ----- dlls/wineps.drv/unixlib.c | 5 ----- 4 files changed, 20 deletions(-)
diff --git a/dlls/wineps.drv/builtin.c b/dlls/wineps.drv/builtin.c index 4fdbc58f099..f4be5eb37fb 100644 --- a/dlls/wineps.drv/builtin.c +++ b/dlls/wineps.drv/builtin.c @@ -138,11 +138,6 @@ static VOID ScaleFont(const AFM *afm, LONG lfHeight, PSFONT *font, tm->tmMaxCharWidth = (LONG)Round( (afm->FontBBox.urx - afm->FontBBox.llx) * font->fontinfo.Builtin.scale);
- font->underlinePosition = afm->UnderlinePosition * font->fontinfo.Builtin.scale; - font->underlineThickness = afm->UnderlineThickness * font->fontinfo.Builtin.scale; - font->strikeoutPosition = tm->tmAscent / 2; - font->strikeoutThickness = font->underlineThickness; - TRACE("Selected PS font '%s' size %d weight %ld.\n", afm->FontName, font->size.xx, tm->tmWeight ); TRACE("H = %ld As = %ld Des = %ld IL = %ld EL = %ld\n", tm->tmHeight, diff --git a/dlls/wineps.drv/download.c b/dlls/wineps.drv/download.c index e8c3299e17c..191f8703e61 100644 --- a/dlls/wineps.drv/download.c +++ b/dlls/wineps.drv/download.c @@ -308,11 +308,6 @@ BOOL PSDRV_WriteSetDownloadFont(PHYSDEV dev, BOOL vertical) physDev->font.size.yx = -ps_round(ppem * xform.eM21); physDev->font.size.yy = -ps_round(ppem * xform.eM22);
- physDev->font.underlineThickness = potm->otmsUnderscoreSize; - physDev->font.underlinePosition = potm->otmsUnderscorePosition; - physDev->font.strikeoutThickness = potm->otmsStrikeoutSize; - physDev->font.strikeoutPosition = potm->otmsStrikeoutPosition; - if(physDev->font.fontinfo.Download == NULL) { RECT bbox; UINT emsize = get_bbox(dev->hdc, &bbox); diff --git a/dlls/wineps.drv/psdrv.h b/dlls/wineps.drv/psdrv.h index 40f590d0afd..3e6952f9618 100644 --- a/dlls/wineps.drv/psdrv.h +++ b/dlls/wineps.drv/psdrv.h @@ -316,11 +316,6 @@ typedef struct {
/* These are needed by PSDRV_ExtTextOut */ int escapement; - int underlineThickness; - int underlinePosition; - int strikeoutThickness; - int strikeoutPosition; - } PSFONT;
typedef struct { diff --git a/dlls/wineps.drv/unixlib.c b/dlls/wineps.drv/unixlib.c index 36971f65495..73181d9cd93 100644 --- a/dlls/wineps.drv/unixlib.c +++ b/dlls/wineps.drv/unixlib.c @@ -904,11 +904,6 @@ static void scale_font(const AFM *afm, LONG height, PSFONT *font, TEXTMETRICW *t tm->tmMaxCharWidth = (LONG)gdi_round( (afm->FontBBox.urx - afm->FontBBox.llx) * font->fontinfo.Builtin.scale);
- font->underlinePosition = afm->UnderlinePosition * font->fontinfo.Builtin.scale; - font->underlineThickness = afm->UnderlineThickness * font->fontinfo.Builtin.scale; - font->strikeoutPosition = tm->tmAscent / 2; - font->strikeoutThickness = font->underlineThickness; - TRACE("Selected PS font '%s' size %d weight %d.\n", afm->FontName, font->size.xx, (int)tm->tmWeight); TRACE("H = %d As = %d Des = %d IL = %d EL = %d\n", (int)tm->tmHeight,
From: Piotr Caban piotr@codeweavers.com
--- dlls/wineps.drv/builtin.c | 57 ++++++++++++++++++++------------------- dlls/wineps.drv/unixlib.c | 16 +++++++++++ dlls/wineps.drv/unixlib.h | 8 ++++++ 3 files changed, 53 insertions(+), 28 deletions(-)
diff --git a/dlls/wineps.drv/builtin.c b/dlls/wineps.drv/builtin.c index f4be5eb37fb..39d2b9d7942 100644 --- a/dlls/wineps.drv/builtin.c +++ b/dlls/wineps.drv/builtin.c @@ -68,30 +68,26 @@ static VOID ScaleFont(const AFM *afm, LONG lfHeight, PSFONT *font, const WINMETRICS *wm = &(afm->WinMetrics); USHORT usUnitsPerEm, usWinAscent, usWinDescent; SHORT sAscender, sDescender, sLineGap, sAvgCharWidth; + float scale;
TRACE("'%s' %li\n", afm->FontName, lfHeight);
if (lfHeight < 0) /* match em height */ - { - font->fontinfo.Builtin.scale = - ((float)lfHeight / (float)(wm->usUnitsPerEm)); - } + scale = - ((float)lfHeight / (float)(wm->usUnitsPerEm)); else /* match cell height */ - { - font->fontinfo.Builtin.scale = (float)lfHeight / - (float)(wm->usWinAscent + wm->usWinDescent); - } + scale = (float)lfHeight / (float)(wm->usWinAscent + wm->usWinDescent);
- font->size.xx = (INT)Round(font->fontinfo.Builtin.scale * (float)wm->usUnitsPerEm); + font->size.xx = (INT)Round(scale * (float)wm->usUnitsPerEm); font->size.xy = font->size.yx = 0; - font->size.yy = -(INT)Round(font->fontinfo.Builtin.scale * (float)wm->usUnitsPerEm); + font->size.yy = -(INT)Round(scale * (float)wm->usUnitsPerEm);
- usUnitsPerEm = (USHORT)Round((float)(wm->usUnitsPerEm) * font->fontinfo.Builtin.scale); - sAscender = (SHORT)Round((float)(wm->sAscender) * font->fontinfo.Builtin.scale); - sDescender = (SHORT)Round((float)(wm->sDescender) * font->fontinfo.Builtin.scale); - sLineGap = (SHORT)Round((float)(wm->sLineGap) * font->fontinfo.Builtin.scale); - usWinAscent = (USHORT)Round((float)(wm->usWinAscent) * font->fontinfo.Builtin.scale); - usWinDescent = (USHORT)Round((float)(wm->usWinDescent) * font->fontinfo.Builtin.scale); - sAvgCharWidth = (SHORT)Round((float)(wm->sAvgCharWidth) * font->fontinfo.Builtin.scale); + usUnitsPerEm = (USHORT)Round((float)(wm->usUnitsPerEm) * scale); + sAscender = (SHORT)Round((float)(wm->sAscender) * scale); + sDescender = (SHORT)Round((float)(wm->sDescender) * scale); + sLineGap = (SHORT)Round((float)(wm->sLineGap) * scale); + usWinAscent = (USHORT)Round((float)(wm->usWinAscent) * scale); + usWinDescent = (USHORT)Round((float)(wm->usWinDescent) * scale); + sAvgCharWidth = (SHORT)Round((float)(wm->sAvgCharWidth) * scale);
tm->tmAscent = (LONG)usWinAscent; tm->tmDescent = (LONG)usWinDescent; @@ -133,10 +129,10 @@ static VOID ScaleFont(const AFM *afm, LONG lfHeight, PSFONT *font, * similarly adjusted.. */
- font->fontinfo.Builtin.scale *= (float)wm->usUnitsPerEm / 1000.0; + scale *= (float)wm->usUnitsPerEm / 1000.0;
tm->tmMaxCharWidth = (LONG)Round( - (afm->FontBBox.urx - afm->FontBBox.llx) * font->fontinfo.Builtin.scale); + (afm->FontBBox.urx - afm->FontBBox.llx) * scale);
TRACE("Selected PS font '%s' size %d weight %ld.\n", afm->FontName, font->size.xx, tm->tmWeight ); @@ -159,6 +155,7 @@ BOOL PSDRV_SelectBuiltinFont(PHYSDEV dev, HFONT hfont, AFMLISTENTRY *afmle; FONTFAMILY *family; BOOL bd = FALSE, it = FALSE; + TEXTMETRICW tm; LONG height;
TRACE("Trying to find facename %s\n", debugstr_w(face_name)); @@ -207,7 +204,6 @@ BOOL PSDRV_SelectBuiltinFont(PHYSDEV dev, HFONT hfont, TRACE("Got font '%s'\n", afmle->afm->FontName);
physDev->font.fontloc = Builtin; - physDev->font.fontinfo.Builtin.afm = afmle->afm;
height = plf->lfHeight; /* stock fonts ignore the mapping mode */ @@ -218,24 +214,29 @@ BOOL PSDRV_SelectBuiltinFont(PHYSDEV dev, HFONT hfont, LPtoDP(dev->hdc, pts, 2); height = pts[1].y - pts[0].y; } - ScaleFont(physDev->font.fontinfo.Builtin.afm, height, - &(physDev->font), &(physDev->font.fontinfo.Builtin.tm)); + ScaleFont(afmle->afm, height, + &(physDev->font), &tm);
/* Does anyone know if these are supposed to be reversed like this? */ - - physDev->font.fontinfo.Builtin.tm.tmDigitizedAspectX = physDev->logPixelsY; - physDev->font.fontinfo.Builtin.tm.tmDigitizedAspectY = physDev->logPixelsX; + tm.tmDigitizedAspectX = physDev->logPixelsY; + tm.tmDigitizedAspectY = physDev->logPixelsX;
return TRUE; }
BOOL PSDRV_WriteSetBuiltinFont(PHYSDEV dev) { - PSDRV_PDEVICE *physDev = get_psdrv_dev( dev ); - - return PSDRV_WriteSetFont(dev, physDev->font.fontinfo.Builtin.afm->FontName, - physDev->font.size, physDev->font.escapement, FALSE); + struct font_info font_info; + matrix size; + + ExtEscape(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, + font_info.escapement, FALSE); }
BOOL PSDRV_WriteBuiltinGlyphShow(PHYSDEV dev, LPCWSTR str, INT count) diff --git a/dlls/wineps.drv/unixlib.c b/dlls/wineps.drv/unixlib.c index 73181d9cd93..66d11a5f9b4 100644 --- a/dlls/wineps.drv/unixlib.c +++ b/dlls/wineps.drv/unixlib.c @@ -809,6 +809,22 @@ static int CDECL ext_escape(PHYSDEV dev, int escape, int input_size, const void return 1; }
+ case PSDRV_GET_BUILTIN_FONT_INFO: + { + PSDRV_PDEVICE *pdev = get_psdrv_dev(dev); + struct font_info *font_info = (struct font_info *)output; + + if (pdev->font.fontloc != Builtin) + return 0; + + lstrcpynA(font_info->font_name, pdev->font.fontinfo.Builtin.afm->FontName, + sizeof(font_info->font_name)); + font_info->size.cx = pdev->font.size.xx; + font_info->size.cy = pdev->font.size.yy; + font_info->escapement = pdev->font.escapement; + return 1; + } + default: FIXME("Unimplemented code %d\n", escape); return 0; diff --git a/dlls/wineps.drv/unixlib.h b/dlls/wineps.drv/unixlib.h index eb82188807c..9e6c0298086 100644 --- a/dlls/wineps.drv/unixlib.h +++ b/dlls/wineps.drv/unixlib.h @@ -20,6 +20,14 @@ #include "wine/unixlib.h"
#define PSDRV_GET_GLYPH_NAME 0x10000 +#define PSDRV_GET_BUILTIN_FONT_INFO 0x10001 + +struct font_info +{ + char font_name[LF_FACESIZE]; + SIZE size; + int escapement; +};
enum wineps_funcs {
From: Piotr Caban piotr@codeweavers.com
--- dlls/wineps.drv/builtin.c | 189 ------------------------------------ dlls/wineps.drv/font.c | 82 ++-------------- dlls/wineps.drv/printproc.c | 29 ------ dlls/wineps.drv/psdrv.h | 2 - 4 files changed, 8 insertions(+), 294 deletions(-)
diff --git a/dlls/wineps.drv/builtin.c b/dlls/wineps.drv/builtin.c index 39d2b9d7942..ca89d93271c 100644 --- a/dlls/wineps.drv/builtin.c +++ b/dlls/wineps.drv/builtin.c @@ -36,195 +36,6 @@
WINE_DEFAULT_DEBUG_CHANNEL(psdrv);
- -/*********************************************************************** - * is_stock_font - */ -static inline BOOL is_stock_font( HFONT font ) -{ - int i; - for (i = OEM_FIXED_FONT; i <= DEFAULT_GUI_FONT; i++) - { - if (i != DEFAULT_PALETTE && font == GetStockObject(i)) return TRUE; - } - return FALSE; -} - - -/******************************************************************************* - * ScaleFont - * - * Scale builtin font to requested lfHeight - * - */ -static inline float Round(float f) -{ - return (f > 0) ? (f + 0.5) : (f - 0.5); -} - -static VOID ScaleFont(const AFM *afm, LONG lfHeight, PSFONT *font, - TEXTMETRICW *tm) -{ - const WINMETRICS *wm = &(afm->WinMetrics); - USHORT usUnitsPerEm, usWinAscent, usWinDescent; - SHORT sAscender, sDescender, sLineGap, sAvgCharWidth; - float scale; - - TRACE("'%s' %li\n", afm->FontName, lfHeight); - - if (lfHeight < 0) /* match em height */ - scale = - ((float)lfHeight / (float)(wm->usUnitsPerEm)); - else /* match cell height */ - scale = (float)lfHeight / (float)(wm->usWinAscent + wm->usWinDescent); - - font->size.xx = (INT)Round(scale * (float)wm->usUnitsPerEm); - font->size.xy = font->size.yx = 0; - font->size.yy = -(INT)Round(scale * (float)wm->usUnitsPerEm); - - usUnitsPerEm = (USHORT)Round((float)(wm->usUnitsPerEm) * scale); - sAscender = (SHORT)Round((float)(wm->sAscender) * scale); - sDescender = (SHORT)Round((float)(wm->sDescender) * scale); - sLineGap = (SHORT)Round((float)(wm->sLineGap) * scale); - usWinAscent = (USHORT)Round((float)(wm->usWinAscent) * scale); - usWinDescent = (USHORT)Round((float)(wm->usWinDescent) * scale); - sAvgCharWidth = (SHORT)Round((float)(wm->sAvgCharWidth) * scale); - - tm->tmAscent = (LONG)usWinAscent; - tm->tmDescent = (LONG)usWinDescent; - tm->tmHeight = tm->tmAscent + tm->tmDescent; - - tm->tmInternalLeading = tm->tmHeight - (LONG)usUnitsPerEm; - if (tm->tmInternalLeading < 0) - tm->tmInternalLeading = 0; - - tm->tmExternalLeading = - (LONG)(sAscender - sDescender + sLineGap) - tm->tmHeight; - if (tm->tmExternalLeading < 0) - tm->tmExternalLeading = 0; - - tm->tmAveCharWidth = (LONG)sAvgCharWidth; - - tm->tmWeight = afm->Weight; - tm->tmItalic = (afm->ItalicAngle != 0.0); - tm->tmUnderlined = 0; - tm->tmStruckOut = 0; - tm->tmFirstChar = (WCHAR)(afm->Metrics[0].UV); - tm->tmLastChar = (WCHAR)(afm->Metrics[afm->NumofMetrics - 1].UV); - tm->tmDefaultChar = 0x001f; /* Win2K does this - FIXME? */ - tm->tmBreakChar = tm->tmFirstChar; /* should be 'space' */ - - tm->tmPitchAndFamily = TMPF_DEVICE | TMPF_VECTOR; - if (!afm->IsFixedPitch) - tm->tmPitchAndFamily |= TMPF_FIXED_PITCH; /* yes, it's backwards */ - if (wm->usUnitsPerEm != 1000) - tm->tmPitchAndFamily |= TMPF_TRUETYPE; - - tm->tmCharSet = ANSI_CHARSET; /* FIXME */ - tm->tmOverhang = 0; - - /* - * This is kludgy. font->scale is used in several places in the driver - * to adjust PostScript-style metrics. Since these metrics have been - * "normalized" to an em-square size of 1000, font->scale needs to be - * similarly adjusted.. - */ - - scale *= (float)wm->usUnitsPerEm / 1000.0; - - tm->tmMaxCharWidth = (LONG)Round( - (afm->FontBBox.urx - afm->FontBBox.llx) * scale); - - TRACE("Selected PS font '%s' size %d weight %ld.\n", afm->FontName, - font->size.xx, tm->tmWeight ); - TRACE("H = %ld As = %ld Des = %ld IL = %ld EL = %ld\n", tm->tmHeight, - tm->tmAscent, tm->tmDescent, tm->tmInternalLeading, - tm->tmExternalLeading); -} - - -/**************************************************************************** - * PSDRV_SelectBuiltinFont - * - * Set up physDev->font for a builtin font - * - */ -BOOL PSDRV_SelectBuiltinFont(PHYSDEV dev, HFONT hfont, - LOGFONTW *plf, WCHAR *face_name) -{ - PSDRV_PDEVICE *physDev = get_psdrv_dev( dev ); - AFMLISTENTRY *afmle; - FONTFAMILY *family; - BOOL bd = FALSE, it = FALSE; - TEXTMETRICW tm; - LONG height; - - TRACE("Trying to find facename %s\n", debugstr_w(face_name)); - - /* Look for a matching font family */ - for(family = physDev->pi->Fonts; family; family = family->next) { - if(!wcsicmp(face_name, family->FamilyName)) - break; - } - - if(!family) { - /* Fallback for Window's font families to common PostScript families */ - if(!wcscmp(face_name, L"Arial")) - wcscpy(face_name, L"Helvetica"); - else if(!wcscmp(face_name, L"System")) - wcscpy(face_name, L"Helvetica"); - else if(!wcscmp(face_name, L"Times New Roman")) - wcscpy(face_name, L"Times"); - else if(!wcscmp(face_name, L"Courier New")) - wcscpy(face_name, L"Courier"); - - for(family = physDev->pi->Fonts; family; family = family->next) { - if(!wcscmp(face_name, family->FamilyName)) - break; - } - } - /* If all else fails, use the first font defined for the printer */ - if(!family) - family = physDev->pi->Fonts; - - TRACE("Got family %s\n", debugstr_w(family->FamilyName)); - - if(plf->lfItalic) - it = TRUE; - if(plf->lfWeight > 550) - bd = TRUE; - - for(afmle = family->afmlist; afmle; afmle = afmle->next) { - if( (bd == (afmle->afm->Weight == FW_BOLD)) && - (it == (afmle->afm->ItalicAngle != 0.0)) ) - break; - } - if(!afmle) - afmle = family->afmlist; /* not ideal */ - - TRACE("Got font '%s'\n", afmle->afm->FontName); - - physDev->font.fontloc = Builtin; - - height = plf->lfHeight; - /* stock fonts ignore the mapping mode */ - if (!is_stock_font( hfont )) { - POINT pts[2]; - pts[0].x = pts[0].y = pts[1].x = 0; - pts[1].y = height; - LPtoDP(dev->hdc, pts, 2); - height = pts[1].y - pts[0].y; - } - ScaleFont(afmle->afm, height, - &(physDev->font), &tm); - - - /* Does anyone know if these are supposed to be reversed like this? */ - tm.tmDigitizedAspectX = physDev->logPixelsY; - tm.tmDigitizedAspectY = physDev->logPixelsX; - - return TRUE; -} - BOOL PSDRV_WriteSetBuiltinFont(PHYSDEV dev) { struct font_info font_info; diff --git a/dlls/wineps.drv/font.c b/dlls/wineps.drv/font.c index cc219724aee..02bd1b2af62 100644 --- a/dlls/wineps.drv/font.c +++ b/dlls/wineps.drv/font.c @@ -30,6 +30,7 @@ #include "winternl.h"
#include "psdrv.h" +#include "unixlib.h" #include "wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL(psdrv); @@ -40,85 +41,18 @@ WINE_DEFAULT_DEBUG_CHANNEL(psdrv); HFONT CDECL PSDRV_SelectFont( PHYSDEV dev, HFONT hfont, UINT *aa_flags ) { PSDRV_PDEVICE *physDev = get_psdrv_dev( dev ); - PHYSDEV next = GET_NEXT_PHYSDEV( dev, pSelectFont ); - HFONT ret; - LOGFONTW lf; - BOOL subst = FALSE; + struct font_info font_info;
- if (!GetObjectW( hfont, sizeof(lf), &lf )) return 0; - - *aa_flags = GGO_BITMAP; /* no anti-aliasing on printer devices */ - - TRACE("FaceName = %s Height = %ld Italic = %d Weight = %ld\n", - debugstr_w(lf.lfFaceName), lf.lfHeight, lf.lfItalic, - lf.lfWeight); - - if(lf.lfFaceName[0] == '\0') { - switch(lf.lfPitchAndFamily & 0xf0) { - case FF_DONTCARE: - break; - case FF_ROMAN: - case FF_SCRIPT: - wcscpy(lf.lfFaceName, L"Times"); - break; - case FF_SWISS: - wcscpy(lf.lfFaceName, L"Helvetica"); - break; - case FF_MODERN: - wcscpy(lf.lfFaceName, L"Courier"); - break; - case FF_DECORATIVE: - wcscpy(lf.lfFaceName, L"Symbol"); - break; - } - } - - if(lf.lfFaceName[0] == '\0') { - switch(lf.lfPitchAndFamily & 0x0f) { - case VARIABLE_PITCH: - wcscpy(lf.lfFaceName, L"Times"); - break; - default: - wcscpy(lf.lfFaceName, L"Courier"); - break; - } - } - - if (physDev->pi->FontSubTableSize != 0) + if (ExtEscape(dev->hdc, PSDRV_GET_BUILTIN_FONT_INFO, 0, NULL, + sizeof(font_info), (char *)&font_info)) { - DWORD i; - - for (i = 0; i < physDev->pi->FontSubTableSize; ++i) - { - if (!wcsicmp (lf.lfFaceName, - physDev->pi->FontSubTable[i].pValueName)) - { - TRACE("substituting facename %s for %s\n", - debugstr_w((WCHAR *)physDev->pi->FontSubTable[i].pData), debugstr_w(lf.lfFaceName)); - if (wcslen((WCHAR *)physDev->pi->FontSubTable[i].pData) < LF_FACESIZE) - { - wcscpy(lf.lfFaceName, (WCHAR *)physDev->pi->FontSubTable[i].pData); - subst = TRUE; - } - else - WARN("Facename %s is too long; ignoring substitution\n", - debugstr_w((WCHAR *)physDev->pi->FontSubTable[i].pData)); - break; - } - } + physDev->font.fontloc = Builtin; } - - physDev->font.escapement = lf.lfEscapement; - physDev->font.set = UNSET; - - if (!subst && ((ret = next->funcs->pSelectFont( next, hfont, aa_flags )))) + else { - PSDRV_SelectDownloadFont(dev); - return ret; + physDev->font.fontloc = Download; + physDev->font.fontinfo.Download = NULL; } - - PSDRV_SelectBuiltinFont(dev, hfont, &lf, lf.lfFaceName); - next->funcs->pSelectFont( next, 0, aa_flags ); /* tell next driver that we selected a device font */ return hfont; }
diff --git a/dlls/wineps.drv/printproc.c b/dlls/wineps.drv/printproc.c index a58a23a281b..5c340b6a778 100644 --- a/dlls/wineps.drv/printproc.c +++ b/dlls/wineps.drv/printproc.c @@ -44,7 +44,6 @@ struct pp_data WCHAR *out_file;
PSDRV_PDEVICE *pdev; - struct gdi_physdev font_dev;
struct brush_pattern *patterns; BOOL path; @@ -155,31 +154,6 @@ static struct pp_data* get_handle_data(HANDLE pp) return ret; }
-static HFONT CDECL font_SelectFont(PHYSDEV dev, HFONT hfont, UINT *aa_flags) -{ - HFONT tt_font, old_font; - LOGFONTW lf; - - *aa_flags = GGO_BITMAP; - if (!GetObjectW(hfont, sizeof(lf), &lf)) - return 0; - - lf.lfOutPrecision = OUT_TT_ONLY_PRECIS; - tt_font = CreateFontIndirectW(&lf); - if (!tt_font) - return 0; - - old_font = SelectObject(dev->hdc, tt_font); - DeleteObject(tt_font); - return old_font ? hfont : 0; -} - -static const struct gdi_dc_funcs font_funcs = -{ - .pSelectFont = font_SelectFont, - .priority = GDI_PRIORITY_FONT_DRV -}; - static inline INT GDI_ROUND(double val) { return (int)floor(val + 0.5); @@ -3015,9 +2989,6 @@ HANDLE WINAPI OpenPrintProcessor(WCHAR *port, PRINTPROCESSOROPENDATA *open_data) return NULL; } data->pdev->dev.hdc = hdc; - data->pdev->dev.next = &data->font_dev; - data->font_dev.funcs = &font_funcs; - data->font_dev.hdc = hdc; return (HANDLE)data; }
diff --git a/dlls/wineps.drv/psdrv.h b/dlls/wineps.drv/psdrv.h index 3e6952f9618..baa080a56df 100644 --- a/dlls/wineps.drv/psdrv.h +++ b/dlls/wineps.drv/psdrv.h @@ -535,8 +535,6 @@ 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_SelectBuiltinFont(PHYSDEV dev, HFONT hfont, - LOGFONTW *plf, WCHAR *face_name) DECLSPEC_HIDDEN; extern BOOL PSDRV_WriteSetBuiltinFont(PHYSDEV dev) DECLSPEC_HIDDEN; extern BOOL PSDRV_WriteBuiltinGlyphShow(PHYSDEV dev, LPCWSTR str, INT count) DECLSPEC_HIDDEN;
From: Piotr Caban piotr@codeweavers.com
--- dlls/wineps.drv/escape.c | 90 ---------------------------------------- dlls/wineps.drv/psdrv.h | 2 - 2 files changed, 92 deletions(-)
diff --git a/dlls/wineps.drv/escape.c b/dlls/wineps.drv/escape.c index e85ccb0f9e5..9bf16ba0a31 100644 --- a/dlls/wineps.drv/escape.c +++ b/dlls/wineps.drv/escape.c @@ -194,93 +194,3 @@ INT CDECL PSDRV_EndPage( PHYSDEV dev ) physDev->job.OutOfPage = TRUE; return 1; } - - -/************************************************************************ - * PSDRV_StartDoc - */ -INT CDECL PSDRV_StartDoc( PHYSDEV dev, const DOCINFOW *doc ) -{ - PSDRV_PDEVICE *physDev = get_psdrv_dev( dev ); - DOC_INFO_1W di; - PRINTER_DEFAULTSW prn_def; - - TRACE("(%p, %p) => %s, %s, %s\n", physDev, doc, debugstr_w(doc->lpszDocName), - debugstr_w(doc->lpszOutput), debugstr_w(doc->lpszDatatype)); - - if(physDev->job.id) { - FIXME("hJob != 0. Now what?\n"); - return 0; - } - - prn_def.pDatatype = NULL; - prn_def.pDevMode = &physDev->pi->Devmode->dmPublic; - prn_def.DesiredAccess = PRINTER_ACCESS_USE; - - if (!OpenPrinterW( physDev->pi->friendly_name, &physDev->job.hprinter, &prn_def )) - { - WARN("OpenPrinter(%s, ...) failed: %ld\n", - debugstr_w(physDev->pi->friendly_name), GetLastError()); - return 0; - } - - di.pDocName = (LPWSTR) doc->lpszDocName; - di.pOutputFile = (LPWSTR) doc->lpszOutput; - di.pDatatype = NULL; - - /* redirection located in HKCU\Software\Wine\Printing\Spooler - is done during winspool.drv,ScheduleJob */ - physDev->job.id = StartDocPrinterW(physDev->job.hprinter, 1, (LPBYTE) &di); - if(!physDev->job.id) { - WARN("StartDocPrinter() failed: %ld\n", GetLastError()); - ClosePrinter(physDev->job.hprinter); - return 0; - } - - if (!PSDRV_WriteHeader( dev, doc->lpszDocName )) { - WARN("Failed to write header\n"); - ClosePrinter(physDev->job.hprinter); - return 0; - } - - physDev->job.OutOfPage = TRUE; - physDev->job.PageNo = 0; - physDev->job.quiet = FALSE; - physDev->job.passthrough_state = passthrough_none; - physDev->job.doc_name = strdupW( doc->lpszDocName ); - - return physDev->job.id; -} - -/************************************************************************ - * PSDRV_EndDoc - */ -INT CDECL PSDRV_EndDoc( PHYSDEV dev ) -{ - PSDRV_PDEVICE *physDev = get_psdrv_dev( dev ); - INT ret = 1; - - TRACE("%p\n", dev->hdc); - - if(!physDev->job.id) { - FIXME("hJob == 0. Now what?\n"); - return 0; - } - - if(!physDev->job.OutOfPage) { - WARN("Somebody forgot an EndPage\n"); - PSDRV_EndPage( dev ); - } - - if (physDev->job.PageNo) - PSDRV_WriteFooter( dev ); - - ret = EndDocPrinter(physDev->job.hprinter); - ClosePrinter(physDev->job.hprinter); - physDev->job.hprinter = NULL; - physDev->job.id = 0; - HeapFree( GetProcessHeap(), 0, physDev->job.doc_name ); - physDev->job.doc_name = NULL; - - return ret; -} diff --git a/dlls/wineps.drv/psdrv.h b/dlls/wineps.drv/psdrv.h index baa080a56df..6c05ce51392 100644 --- a/dlls/wineps.drv/psdrv.h +++ b/dlls/wineps.drv/psdrv.h @@ -422,7 +422,6 @@ extern BOOL CDECL PSDRV_Arc( PHYSDEV dev, INT left, INT top, INT right, INT bott extern BOOL CDECL PSDRV_Chord( PHYSDEV dev, 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_EndDoc( PHYSDEV dev ) 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, INT cbOutput, LPVOID out_data ) DECLSPEC_HIDDEN; @@ -452,7 +451,6 @@ extern COLORREF CDECL PSDRV_SetDCBrushColor( PHYSDEV dev, COLORREF color ) DECLS 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 INT CDECL PSDRV_StartDoc( PHYSDEV dev, const DOCINFOW *doc ) DECLSPEC_HIDDEN; extern BOOL CDECL PSDRV_StrokeAndFillPath( PHYSDEV dev ) DECLSPEC_HIDDEN; extern BOOL CDECL PSDRV_StrokePath( PHYSDEV dev ) DECLSPEC_HIDDEN;
From: Piotr Caban piotr@codeweavers.com
--- dlls/gdi32/dc.c | 2 +- dlls/win32u/dc.c | 4 ++-- dlls/wineps.drv/init.c | 2 +- dlls/wineps.drv/wineps.drv.spec | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/dlls/gdi32/dc.c b/dlls/gdi32/dc.c index c747d3a478e..a0308ffa118 100644 --- a/dlls/gdi32/dc.c +++ b/dlls/gdi32/dc.c @@ -42,7 +42,7 @@ static CRITICAL_SECTION_DEBUG critsect_debug = }; static CRITICAL_SECTION driver_section = { &critsect_debug, -1, 0, 0, 0, 0 };
-typedef const void * (CDECL *driver_entry_point)( unsigned int version ); +typedef const void * (CDECL *driver_entry_point)( unsigned int version, const WCHAR *device );
struct graphics_driver { diff --git a/dlls/win32u/dc.c b/dlls/win32u/dc.c index 8379cd353ef..bcfbed29426 100644 --- a/dlls/win32u/dc.c +++ b/dlls/win32u/dc.c @@ -719,8 +719,8 @@ HDC WINAPI NtGdiOpenDCW( UNICODE_STRING *device, const DEVMODEW *devmode, UNICOD funcs = get_display_driver(); else if (hspool) { - const struct gdi_dc_funcs * (CDECL *wine_get_gdi_driver)( unsigned int ) = hspool; - funcs = wine_get_gdi_driver( WINE_GDI_DRIVER_VERSION ); + const struct gdi_dc_funcs * (CDECL *wine_get_gdi_driver)( unsigned int, const WCHAR * ) = hspool; + funcs = wine_get_gdi_driver( WINE_GDI_DRIVER_VERSION, device ? device->Buffer : NULL ); } if (!funcs) { diff --git a/dlls/wineps.drv/init.c b/dlls/wineps.drv/init.c index 97f68d19a91..c5bb855ea93 100644 --- a/dlls/wineps.drv/init.c +++ b/dlls/wineps.drv/init.c @@ -687,7 +687,7 @@ static struct gdi_dc_funcs psdrv_funcs = /****************************************************************************** * PSDRV_get_gdi_driver */ -const struct gdi_dc_funcs * CDECL PSDRV_get_gdi_driver( unsigned int version ) +const struct gdi_dc_funcs * CDECL PSDRV_get_gdi_driver( unsigned int version, const WCHAR *name ) { if (version != WINE_GDI_DRIVER_VERSION) { diff --git a/dlls/wineps.drv/wineps.drv.spec b/dlls/wineps.drv/wineps.drv.spec index 45b7d114e7e..aca8ed2d10f 100644 --- a/dlls/wineps.drv/wineps.drv.spec +++ b/dlls/wineps.drv/wineps.drv.spec @@ -1,4 +1,4 @@ -@ cdecl wine_get_gdi_driver(long) PSDRV_get_gdi_driver +@ cdecl wine_get_gdi_driver(long str) PSDRV_get_gdi_driver @ stdcall -private DllRegisterServer()
# Printer driver config exports
From: Piotr Caban piotr@codeweavers.com
--- dlls/wineps.drv/init.c | 78 +++---------------- dlls/wineps.drv/unixlib.c | 152 ++++++++++++++++++++++++++++++++++++-- dlls/wineps.drv/unixlib.h | 6 +- 3 files changed, 159 insertions(+), 77 deletions(-)
diff --git a/dlls/wineps.drv/init.c b/dlls/wineps.drv/init.c index c5bb855ea93..cc06c7017c9 100644 --- a/dlls/wineps.drv/init.c +++ b/dlls/wineps.drv/init.c @@ -28,8 +28,8 @@ #include "winreg.h" #include "winnls.h" #include "winuser.h" -#include "unixlib.h" #include "psdrv.h" +#include "unixlib.h" #include "winspool.h" #include "wine/debug.h"
@@ -93,8 +93,6 @@ static const PSDRV_DEVMODE DefaultDevmode = HINSTANCE PSDRV_hInstance = 0; HANDLE PSDRV_Heap = 0;
-static struct gdi_dc_funcs psdrv_funcs; - /********************************************************************* * DllMain * @@ -109,16 +107,11 @@ BOOL WINAPI DllMain( HINSTANCE hinst, DWORD reason, LPVOID reserved )
case DLL_PROCESS_ATTACH: { - struct init_dc_params params = { &psdrv_funcs }; - PSDRV_hInstance = hinst; DisableThreadLibraryCalls(hinst);
if (__wine_init_unix_call()) return FALSE; - if (!WINE_UNIX_CALL( unix_init_dc, ¶ms )) - return FALSE; -
PSDRV_Heap = HeapCreate(0, 0x10000, 0); if (PSDRV_Heap == NULL) @@ -133,6 +126,7 @@ BOOL WINAPI DllMain( HINSTANCE hinst, DWORD reason, LPVOID reserved )
case DLL_PROCESS_DETACH: if (reserved) break; + WINE_UNIX_CALL(unix_free_printer_info, NULL); HeapDestroy( PSDRV_Heap ); break; } @@ -382,55 +376,6 @@ PSDRV_PDEVICE *create_psdrv_physdev( HDC hdc, const WCHAR *device, return pdev; }
-/********************************************************************** - * PSDRV_CreateDC - */ -static BOOL CDECL PSDRV_CreateDC( PHYSDEV *pdev, LPCWSTR device, LPCWSTR output, - const DEVMODEW *initData ) -{ - PSDRV_PDEVICE *physDev; - - TRACE("(%s %s %p)\n", debugstr_w(device), debugstr_w(output), initData); - - if (!device) return FALSE; - if (!(physDev = create_psdrv_physdev( (*pdev)->hdc, device, - (const PSDRV_DEVMODE *)initData ))) return FALSE; - push_dc_driver( pdev, &physDev->dev, &psdrv_funcs ); - return TRUE; -} - - -/********************************************************************** - * PSDRV_CreateCompatibleDC - */ -static BOOL CDECL PSDRV_CreateCompatibleDC( PHYSDEV orig, PHYSDEV *pdev ) -{ - PSDRV_PDEVICE *physDev, *orig_dev = get_psdrv_dev( orig ); - - if (!(physDev = create_psdrv_physdev( (*pdev)->hdc, orig_dev->pi->friendly_name, - orig_dev->Devmode ))) return FALSE; - push_dc_driver( pdev, &physDev->dev, &psdrv_funcs ); - return TRUE; -} - - - -/********************************************************************** - * PSDRV_DeleteDC - */ -static BOOL CDECL PSDRV_DeleteDC( PHYSDEV dev ) -{ - PSDRV_PDEVICE *physDev = get_psdrv_dev( dev ); - - TRACE("\n"); - - HeapFree( GetProcessHeap(), 0, physDev->Devmode ); - HeapFree( GetProcessHeap(), 0, physDev ); - - return TRUE; -} - - /********************************************************************** * ResetDC (WINEPS.@) */ @@ -674,25 +619,22 @@ fail: return NULL; }
- -static struct gdi_dc_funcs psdrv_funcs = -{ - .pCreateCompatibleDC = PSDRV_CreateCompatibleDC, - .pCreateDC = PSDRV_CreateDC, - .pDeleteDC = PSDRV_DeleteDC, - .priority = GDI_PRIORITY_GRAPHICS_DRV -}; - - /****************************************************************************** * PSDRV_get_gdi_driver */ const struct gdi_dc_funcs * CDECL PSDRV_get_gdi_driver( unsigned int version, const WCHAR *name ) { + PRINTERINFO *pi = PSDRV_FindPrinterInfo( name ); + struct init_dc_params params = { NULL, pi, pi->friendly_name }; + + if (!pi) + return NULL; if (version != WINE_GDI_DRIVER_VERSION) { ERR( "version mismatch, gdi32 wants %u but wineps has %u\n", version, WINE_GDI_DRIVER_VERSION ); return NULL; } - return &psdrv_funcs; + if (!WINE_UNIX_CALL( unix_init_dc, ¶ms )) + return FALSE; + return params.funcs; } diff --git a/dlls/wineps.drv/unixlib.c b/dlls/wineps.drv/unixlib.c index 66d11a5f9b4..ab9aba5d826 100644 --- a/dlls/wineps.drv/unixlib.c +++ b/dlls/wineps.drv/unixlib.c @@ -49,6 +49,16 @@ static const WCHAR systemW[] = {'S','y','s','t','e','m',0}; static const WCHAR times_new_romanW[] = {'T','i','m','e','s',' ','N','e','w',' ','R','o','m','a','n',0}; static const WCHAR courier_newW[] = {'C','o','u','r','i','e','r',' ','N','e','w',0};
+static const struct gdi_dc_funcs psdrv_funcs; + +struct printer_info +{ + struct list entry; + const WCHAR *name; + PRINTERINFO *pi; +}; + +static struct list printer_info_list = LIST_INIT( printer_info_list );
/* copied from kernelbase */ static int muldiv(int a, int b, int c) @@ -1250,24 +1260,150 @@ static BOOL CDECL get_text_extent_ex_point(PHYSDEV dev, const WCHAR *str, int co return TRUE; }
+static struct printer_info *find_printer_info(const WCHAR *name) +{ + struct printer_info *pi; + + LIST_FOR_EACH_ENTRY(pi, &printer_info_list, struct printer_info, entry) + { + if (!wcscmp(pi->name, name)) + return pi; + } + return NULL; +} + +static PSDRV_PDEVICE *create_physdev(HDC hdc, const WCHAR *device, + const PSDRV_DEVMODE *devmode) +{ + struct printer_info *pi = find_printer_info(device); + PSDRV_PDEVICE *pdev; + + if (!pi) return NULL; + if (!pi->pi->Fonts) + { + RASTERIZER_STATUS status; + if (!NtGdiGetRasterizerCaps(&status, sizeof(status)) || + !(status.wFlags & TT_AVAILABLE) || + !(status.wFlags & TT_ENABLED)) + { + MESSAGE("Disabling printer %s since it has no builtin fonts and " + "there are no TrueType fonts available.\n", debugstr_w(device)); + return FALSE; + } + } + + pdev = malloc(sizeof(*pdev)); + if (!pdev) return NULL; + + pdev->Devmode = malloc(sizeof(PSDRV_DEVMODE)); + if (!pdev->Devmode) + { + free(pdev); + return NULL; + } + + *pdev->Devmode = *pi->pi->Devmode; + pdev->pi = pi->pi; + pdev->logPixelsX = pi->pi->ppd->DefaultResolution; + pdev->logPixelsY = pi->pi->ppd->DefaultResolution; + + if (devmode) + { + dump_devmode(&devmode->dmPublic); + merge_devmodes(pdev->Devmode, devmode, pi->pi); + } + + update_dev_caps(pdev); + NtGdiSelectFont(hdc, GetStockObject(DEVICE_DEFAULT_FONT)); + return pdev; +} + +static BOOL CDECL create_dc(PHYSDEV *dev, const WCHAR *device, + const WCHAR *output, const DEVMODEW *devmode) +{ + PSDRV_PDEVICE *pdev; + + TRACE("(%s %s %p)\n", debugstr_w(device), debugstr_w(output), devmode); + + if (!device) return FALSE; + if (!(pdev = create_physdev((*dev)->hdc, device, + (const PSDRV_DEVMODE *)devmode))) return FALSE; + push_dc_driver(dev, &pdev->dev, &psdrv_funcs); + return TRUE; +} + +static BOOL CDECL create_compatible_dc(PHYSDEV orig, PHYSDEV *dev) +{ + PSDRV_PDEVICE *pdev, *orig_dev = get_psdrv_dev(orig); + + if (!(pdev = create_physdev((*dev)->hdc, orig_dev->pi->friendly_name, + orig_dev->Devmode))) return FALSE; + push_dc_driver(dev, &pdev->dev, &psdrv_funcs); + return TRUE; +} + +static BOOL CDECL delete_dc(PHYSDEV dev) +{ + PSDRV_PDEVICE *pdev = get_psdrv_dev(dev); + + TRACE("\n"); + + free(pdev->Devmode); + free(pdev); + return TRUE; +} + +static const struct gdi_dc_funcs psdrv_funcs = +{ + .pCreateCompatibleDC = create_compatible_dc, + .pCreateDC = create_dc, + .pDeleteDC = delete_dc, + .pEnumFonts = enum_fonts, + .pExtEscape = ext_escape, + .pGetCharWidth = get_char_width, + .pGetDeviceCaps = get_device_caps, + .pGetTextExtentExPoint = get_text_extent_ex_point, + .pGetTextMetrics = get_text_metrics, + .pResetDC = reset_dc, + .pSelectFont = select_font, + .priority = GDI_PRIORITY_GRAPHICS_DRV +}; + static NTSTATUS init_dc(void *arg) { struct init_dc_params *params = arg; + struct printer_info *pi; + + pi = find_printer_info(params->name); + if (!pi) + { + pi = malloc(sizeof(*pi)); + if (!pi) return FALSE;
- params->funcs->pGetDeviceCaps = get_device_caps; - params->funcs->pResetDC = reset_dc; - params->funcs->pExtEscape = ext_escape; - params->funcs->pSelectFont = select_font; - params->funcs->pEnumFonts = enum_fonts; - params->funcs->pGetCharWidth = get_char_width; - params->funcs->pGetTextMetrics = get_text_metrics; - params->funcs->pGetTextExtentExPoint = get_text_extent_ex_point; + pi->name = params->name; + pi->pi = params->pi; + list_add_head(&printer_info_list, &pi->entry); + } + + params->funcs = &psdrv_funcs; return TRUE; }
+static NTSTATUS free_printer_info(void *arg) +{ + struct printer_info *pi, *next; + + LIST_FOR_EACH_ENTRY_SAFE(pi, next, &printer_info_list, struct printer_info, entry) + { + free(pi); + } + return 0; +} + const unixlib_entry_t __wine_unix_call_funcs[] = { init_dc, + free_printer_info, };
C_ASSERT(ARRAYSIZE(__wine_unix_call_funcs) == unix_funcs_count); diff --git a/dlls/wineps.drv/unixlib.h b/dlls/wineps.drv/unixlib.h index 9e6c0298086..09ba9d3c662 100644 --- a/dlls/wineps.drv/unixlib.h +++ b/dlls/wineps.drv/unixlib.h @@ -32,10 +32,14 @@ struct font_info enum wineps_funcs { unix_init_dc, + unix_free_printer_info, unix_funcs_count, };
struct init_dc_params { - struct gdi_dc_funcs *funcs; + const struct gdi_dc_funcs *funcs; + PRINTERINFO *pi; + + const WCHAR *name; };
From: Piotr Caban piotr@codeweavers.com
--- dlls/wineps.drv/bitblt.c | 30 ++-- dlls/wineps.drv/bitmap.c | 66 ++++--- dlls/wineps.drv/brush.c | 123 +++++++------ dlls/wineps.drv/builtin.c | 12 +- dlls/wineps.drv/clipping.c | 40 ++--- dlls/wineps.drv/color.c | 17 +- dlls/wineps.drv/download.c | 126 +++++++------ dlls/wineps.drv/escape.c | 67 ++++--- dlls/wineps.drv/font.c | 33 ++-- dlls/wineps.drv/graphics.c | 313 ++++++++++++++++----------------- dlls/wineps.drv/init.c | 165 +++++++++-------- dlls/wineps.drv/pen.c | 89 +++++----- dlls/wineps.drv/printproc.c | 327 +++++++++++++++++----------------- dlls/wineps.drv/ps.c | 342 +++++++++++++++++------------------- dlls/wineps.drv/psdrv.h | 189 ++++++++++---------- dlls/wineps.drv/text.c | 82 +++++---- dlls/wineps.drv/type1.c | 18 +- dlls/wineps.drv/type42.c | 50 +++--- dlls/wineps.drv/unixlib.c | 7 + 19 files changed, 1023 insertions(+), 1073 deletions(-)
diff --git a/dlls/wineps.drv/bitblt.c b/dlls/wineps.drv/bitblt.c index 4fa7f9cdbf8..d357e5db00f 100644 --- a/dlls/wineps.drv/bitblt.c +++ b/dlls/wineps.drv/bitblt.c @@ -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: diff --git a/dlls/wineps.drv/bitmap.c b/dlls/wineps.drv/bitmap.c index 59fbf1c1544..fecd02fbf27 100644 --- a/dlls/wineps.drv/bitmap.c +++ b/dlls/wineps.drv/bitmap.c @@ -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;
diff --git a/dlls/wineps.drv/brush.c b/dlls/wineps.drv/brush.c index bbf636761c4..3d9bd8042b3 100644 --- a/dlls/wineps.drv/brush.c +++ b/dlls/wineps.drv/brush.c @@ -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; diff --git a/dlls/wineps.drv/builtin.c b/dlls/wineps.drv/builtin.c index ca89d93271c..5ce1b3c7212 100644 --- a/dlls/wineps.drv/builtin.c +++ b/dlls/wineps.drv/builtin.c @@ -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; diff --git a/dlls/wineps.drv/clipping.c b/dlls/wineps.drv/clipping.c index 62022c97c03..4b387a77600 100644 --- a/dlls/wineps.drv/clipping.c +++ b/dlls/wineps.drv/clipping.c @@ -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); } diff --git a/dlls/wineps.drv/color.c b/dlls/wineps.drv/color.c index 6a28e4c748b..26c235a8c6c 100644 --- a/dlls/wineps.drv/color.c +++ b/dlls/wineps.drv/color.c @@ -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; } diff --git a/dlls/wineps.drv/download.c b/dlls/wineps.drv/download.c index 191f8703e61..7dcdcac3ab8 100644 --- a/dlls/wineps.drv/download.c +++ b/dlls/wineps.drv/download.c @@ -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) { diff --git a/dlls/wineps.drv/escape.c b/dlls/wineps.drv/escape.c index 9bf16ba0a31..095affc2a0a 100644 --- a/dlls/wineps.drv/escape.c +++ b/dlls/wineps.drv/escape.c @@ -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; } diff --git a/dlls/wineps.drv/font.c b/dlls/wineps.drv/font.c index 02bd1b2af62..6925ddc160c 100644 --- a/dlls/wineps.drv/font.c +++ b/dlls/wineps.drv/font.c @@ -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; } diff --git a/dlls/wineps.drv/graphics.c b/dlls/wineps.drv/graphics.c index 469a1587464..d571b4c76be 100644 --- a/dlls/wineps.drv/graphics.c +++ b/dlls/wineps.drv/graphics.c @@ -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 ); } diff --git a/dlls/wineps.drv/init.c b/dlls/wineps.drv/init.c index cc06c7017c9..c4745d1fd96 100644 --- a/dlls/wineps.drv/init.c +++ b/dlls/wineps.drv/init.c @@ -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; } diff --git a/dlls/wineps.drv/pen.c b/dlls/wineps.drv/pen.c index c0dcb51abda..da3915824a1 100644 --- a/dlls/wineps.drv/pen.c +++ b/dlls/wineps.drv/pen.c @@ -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; } }
diff --git a/dlls/wineps.drv/printproc.c b/dlls/wineps.drv/printproc.c index 5c340b6a778..ea31272f655 100644 --- a/dlls/wineps.drv/printproc.c +++ b/dlls/wineps.drv/printproc.c @@ -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)); diff --git a/dlls/wineps.drv/ps.c b/dlls/wineps.drv/ps.c index b0b27e62ac2..94a8e571eec 100644 --- a/dlls/wineps.drv/ps.c +++ b/dlls/wineps.drv/ps.c @@ -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; } diff --git a/dlls/wineps.drv/psdrv.h b/dlls/wineps.drv/psdrv.h index 6c05ce51392..9ef53f5a805 100644 --- a/dlls/wineps.drv/psdrv.h +++ b/dlls/wineps.drv/psdrv.h @@ -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); \ diff --git a/dlls/wineps.drv/text.c b/dlls/wineps.drv/text.c index 767b1529c24..c69c037ee3b 100644 --- a/dlls/wineps.drv/text.c +++ b/dlls/wineps.drv/text.c @@ -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 ); diff --git a/dlls/wineps.drv/type1.c b/dlls/wineps.drv/type1.c index f31c6dd3bee..8501dc7aed8 100644 --- a/dlls/wineps.drv/type1.c +++ b/dlls/wineps.drv/type1.c @@ -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; diff --git a/dlls/wineps.drv/type42.c b/dlls/wineps.drv/type42.c index 13b5c627e38..60ff1101909 100644 --- a/dlls/wineps.drv/type42.c +++ b/dlls/wineps.drv/type42.c @@ -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); diff --git a/dlls/wineps.drv/unixlib.c b/dlls/wineps.drv/unixlib.c index ab9aba5d826..fbcfc8c3b51 100644 --- a/dlls/wineps.drv/unixlib.c +++ b/dlls/wineps.drv/unixlib.c @@ -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) {
From: Piotr Caban piotr@codeweavers.com
--- dlls/wineps.drv/unixlib.c | 388 +++++++++++++++++++------------------- 1 file changed, 197 insertions(+), 191 deletions(-)
diff --git a/dlls/wineps.drv/unixlib.c b/dlls/wineps.drv/unixlib.c index fbcfc8c3b51..1f510353375 100644 --- a/dlls/wineps.drv/unixlib.c +++ b/dlls/wineps.drv/unixlib.c @@ -60,7 +60,29 @@ struct printer_info
static struct list printer_info_list = LIST_INIT( printer_info_list );
-typedef print_ctx PSDRV_PDEVICE; +typedef struct +{ + struct gdi_physdev dev; + PSDRV_DEVMODE *devmode; + struct printer_info *pi; + + /* builtin font info */ + BOOL builtin; + SIZE size; + const AFM *afm; + float scale; + TEXTMETRICW tm; + int escapement; + + SIZE page_size; /* Physical page size in device units */ + RECT imageable_area; /* Imageable area in device units */ + int horz_res; /* device caps */ + int vert_res; + int horz_size; + int vert_size; + int log_pixels_x; + int log_pixels_y; +} PSDRV_PDEVICE;
static inline PSDRV_PDEVICE *get_psdrv_dev(PHYSDEV dev) { @@ -185,13 +207,13 @@ static INT CDECL get_device_caps(PHYSDEV dev, INT cap) case TECHNOLOGY: return DT_RASPRINTER; case HORZSIZE: - return muldiv(pdev->horzSize, 100, pdev->Devmode->dmPublic.dmScale); + return muldiv(pdev->horz_size, 100, pdev->devmode->dmPublic.dmScale); case VERTSIZE: - return muldiv(pdev->vertSize, 100, pdev->Devmode->dmPublic.dmScale); + return muldiv(pdev->vert_size, 100, pdev->devmode->dmPublic.dmScale); case HORZRES: - return pdev->horzRes; + return pdev->horz_res; case VERTRES: - return pdev->vertRes; + return pdev->vert_res; case BITSPIXEL: /* Although Windows returns 1 for monochrome printers, we want CreateCompatibleBitmap to provide something other than 1 bpp */ @@ -210,42 +232,42 @@ static INT CDECL get_device_caps(PHYSDEV dev, INT cap) return (RC_BITBLT | RC_BITMAP64 | RC_GDI20_OUTPUT | RC_DIBTODEV | RC_STRETCHBLT | RC_STRETCHDIB); /* psdrv 0x6e99 */ case ASPECTX: - return pdev->logPixelsX; + return pdev->log_pixels_x; case ASPECTY: - return pdev->logPixelsY; + return pdev->log_pixels_y; case LOGPIXELSX: - return muldiv(pdev->logPixelsX, pdev->Devmode->dmPublic.dmScale, 100); + return muldiv(pdev->log_pixels_x, pdev->devmode->dmPublic.dmScale, 100); case LOGPIXELSY: - return muldiv(pdev->logPixelsY, pdev->Devmode->dmPublic.dmScale, 100); + return muldiv(pdev->log_pixels_y, pdev->devmode->dmPublic.dmScale, 100); case NUMRESERVED: return 0; case COLORRES: return 0; case PHYSICALWIDTH: - return (pdev->Devmode->dmPublic.dmOrientation == DMORIENT_LANDSCAPE) ? - pdev->PageSize.cy : pdev->PageSize.cx; + return (pdev->devmode->dmPublic.dmOrientation == DMORIENT_LANDSCAPE) ? + pdev->page_size.cy : pdev->page_size.cx; case PHYSICALHEIGHT: - return (pdev->Devmode->dmPublic.dmOrientation == DMORIENT_LANDSCAPE) ? - pdev->PageSize.cx : pdev->PageSize.cy; + return (pdev->devmode->dmPublic.dmOrientation == DMORIENT_LANDSCAPE) ? + pdev->page_size.cx : pdev->page_size.cy; case PHYSICALOFFSETX: - if (pdev->Devmode->dmPublic.dmOrientation == DMORIENT_LANDSCAPE) + if (pdev->devmode->dmPublic.dmOrientation == DMORIENT_LANDSCAPE) { - if (pdev->pi->ppd->LandscapeOrientation == -90) - return pdev->PageSize.cy - pdev->ImageableArea.top; + if (pdev->pi->pi->ppd->LandscapeOrientation == -90) + return pdev->page_size.cy - pdev->imageable_area.top; else - return pdev->ImageableArea.bottom; + return pdev->imageable_area.bottom; } - return pdev->ImageableArea.left; + return pdev->imageable_area.left;
case PHYSICALOFFSETY: - if (pdev->Devmode->dmPublic.dmOrientation == DMORIENT_LANDSCAPE) + if (pdev->devmode->dmPublic.dmOrientation == DMORIENT_LANDSCAPE) { - if (pdev->pi->ppd->LandscapeOrientation == -90) - return pdev->PageSize.cx - pdev->ImageableArea.right; + if (pdev->pi->pi->ppd->LandscapeOrientation == -90) + return pdev->page_size.cx - pdev->imageable_area.right; else - return pdev->ImageableArea.left; + return pdev->imageable_area.left; } - return pdev->PageSize.cy - pdev->ImageableArea.top; + return pdev->page_size.cy - pdev->imageable_area.top;
default: dev = GET_NEXT_PHYSDEV(dev, pGetDeviceCaps); @@ -280,7 +302,8 @@ static PAGESIZE *unix_find_pagesize(PPD *ppd, const PSDRV_DEVMODE *dm) return NULL; }
-static void merge_devmodes(PSDRV_DEVMODE *dm1, const PSDRV_DEVMODE *dm2, PRINTERINFO *pi) +static void merge_devmodes(PSDRV_DEVMODE *dm1, const PSDRV_DEVMODE *dm2, + struct printer_info *pi) { /* some sanity checks here on dm2 */
@@ -298,7 +321,7 @@ static void merge_devmodes(PSDRV_DEVMODE *dm1, const PSDRV_DEVMODE *dm2, PRINTER /* NB PaperWidth is always < PaperLength */ if (dm2->dmPublic.dmFields & DM_PAPERSIZE) { - PAGESIZE *page = unix_find_pagesize(pi->ppd, dm2); + PAGESIZE *page = unix_find_pagesize(pi->pi->ppd, dm2);
if (page) { @@ -355,7 +378,7 @@ static void merge_devmodes(PSDRV_DEVMODE *dm1, const PSDRV_DEVMODE *dm2, PRINTER
if (dm2->dmPublic.dmFields & DM_DEFAULTSOURCE) { - INPUTSLOT *slot = unix_find_slot(pi->ppd, dm2); + INPUTSLOT *slot = unix_find_slot(pi->pi->ppd, dm2);
if (slot) { @@ -374,7 +397,7 @@ static void merge_devmodes(PSDRV_DEVMODE *dm1, const PSDRV_DEVMODE *dm2, PRINTER dm1->dmPublic.dmPrintQuality = dm2->dmPublic.dmPrintQuality; if (dm2->dmPublic.dmFields & DM_COLOR) dm1->dmPublic.dmColor = dm2->dmPublic.dmColor; - if (dm2->dmPublic.dmFields & DM_DUPLEX && pi->ppd->DefaultDuplex && pi->ppd->DefaultDuplex->WinDuplex != 0) + if (dm2->dmPublic.dmFields & DM_DUPLEX && pi->pi->ppd->DefaultDuplex && pi->pi->ppd->DefaultDuplex->WinDuplex != 0) dm1->dmPublic.dmDuplex = dm2->dmPublic.dmDuplex; if (dm2->dmPublic.dmFields & DM_YRESOLUTION) dm1->dmPublic.dmYResolution = dm2->dmPublic.dmYResolution; @@ -418,109 +441,109 @@ static void update_dev_caps(PSDRV_PDEVICE *pdev) RESOLUTION *res; PAGESIZE *page;
- dump_devmode(&pdev->Devmode->dmPublic); + dump_devmode(&pdev->devmode->dmPublic);
- if (pdev->Devmode->dmPublic.dmFields & (DM_PRINTQUALITY | DM_YRESOLUTION | DM_LOGPIXELS)) + if (pdev->devmode->dmPublic.dmFields & (DM_PRINTQUALITY | DM_YRESOLUTION | DM_LOGPIXELS)) { - if (pdev->Devmode->dmPublic.dmFields & DM_PRINTQUALITY) - resx = resy = pdev->Devmode->dmPublic.dmPrintQuality; + if (pdev->devmode->dmPublic.dmFields & DM_PRINTQUALITY) + resx = resy = pdev->devmode->dmPublic.dmPrintQuality;
- if (pdev->Devmode->dmPublic.dmFields & DM_YRESOLUTION) - resy = pdev->Devmode->dmPublic.dmYResolution; + if (pdev->devmode->dmPublic.dmFields & DM_YRESOLUTION) + resy = pdev->devmode->dmPublic.dmYResolution;
- if (pdev->Devmode->dmPublic.dmFields & DM_LOGPIXELS) - resx = resy = pdev->Devmode->dmPublic.dmLogPixels; + if (pdev->devmode->dmPublic.dmFields & DM_LOGPIXELS) + resx = resy = pdev->devmode->dmPublic.dmLogPixels;
- LIST_FOR_EACH_ENTRY(res, &pdev->pi->ppd->Resolutions, RESOLUTION, entry) + LIST_FOR_EACH_ENTRY(res, &pdev->pi->pi->ppd->Resolutions, RESOLUTION, entry) { if (res->resx == resx && res->resy == resy) { - pdev->logPixelsX = resx; - pdev->logPixelsY = resy; + pdev->log_pixels_x = resx; + pdev->log_pixels_y = resy; break; } }
- if (&res->entry == &pdev->pi->ppd->Resolutions) + if (&res->entry == &pdev->pi->pi->ppd->Resolutions) { WARN("Requested resolution %dx%d is not supported by device\n", resx, resy); - pdev->logPixelsX = pdev->pi->ppd->DefaultResolution; - pdev->logPixelsY = pdev->logPixelsX; + pdev->log_pixels_x = pdev->pi->pi->ppd->DefaultResolution; + pdev->log_pixels_y = pdev->log_pixels_x; } } else { - WARN("Using default device resolution %d\n", pdev->pi->ppd->DefaultResolution); - pdev->logPixelsX = pdev->pi->ppd->DefaultResolution; - pdev->logPixelsY = pdev->logPixelsX; + WARN("Using default device resolution %d\n", pdev->pi->pi->ppd->DefaultResolution); + pdev->log_pixels_x = pdev->pi->pi->ppd->DefaultResolution; + pdev->log_pixels_y = pdev->log_pixels_x; }
- if (pdev->Devmode->dmPublic.dmFields & DM_PAPERSIZE) { - LIST_FOR_EACH_ENTRY(page, &pdev->pi->ppd->PageSizes, PAGESIZE, entry) { - if (page->WinPage == pdev->Devmode->dmPublic.dmPaperSize) + if (pdev->devmode->dmPublic.dmFields & DM_PAPERSIZE) { + LIST_FOR_EACH_ENTRY(page, &pdev->pi->pi->ppd->PageSizes, PAGESIZE, entry) { + if (page->WinPage == pdev->devmode->dmPublic.dmPaperSize) break; }
- if (&page->entry == &pdev->pi->ppd->PageSizes) { + if (&page->entry == &pdev->pi->pi->ppd->PageSizes) { FIXME("Can't find page\n"); - SetRectEmpty(&pdev->ImageableArea); - pdev->PageSize.cx = 0; - pdev->PageSize.cy = 0; + SetRectEmpty(&pdev->imageable_area); + pdev->page_size.cx = 0; + pdev->page_size.cy = 0; } else if (page->ImageableArea) { /* pdev sizes in device units; ppd sizes in 1/72" */ - SetRect(&pdev->ImageableArea, page->ImageableArea->llx * pdev->logPixelsX / 72, - page->ImageableArea->ury * pdev->logPixelsY / 72, - page->ImageableArea->urx * pdev->logPixelsX / 72, - page->ImageableArea->lly * pdev->logPixelsY / 72); - pdev->PageSize.cx = page->PaperDimension->x * - pdev->logPixelsX / 72; - pdev->PageSize.cy = page->PaperDimension->y * - pdev->logPixelsY / 72; + SetRect(&pdev->imageable_area, page->ImageableArea->llx * pdev->log_pixels_x / 72, + page->ImageableArea->ury * pdev->log_pixels_y / 72, + page->ImageableArea->urx * pdev->log_pixels_x / 72, + page->ImageableArea->lly * pdev->log_pixels_y / 72); + pdev->page_size.cx = page->PaperDimension->x * + pdev->log_pixels_x / 72; + pdev->page_size.cy = page->PaperDimension->y * + pdev->log_pixels_y / 72; } else { - pdev->ImageableArea.left = pdev->ImageableArea.bottom = 0; - pdev->ImageableArea.right = pdev->PageSize.cx = - page->PaperDimension->x * pdev->logPixelsX / 72; - pdev->ImageableArea.top = pdev->PageSize.cy = - page->PaperDimension->y * pdev->logPixelsY / 72; + pdev->imageable_area.left = pdev->imageable_area.bottom = 0; + pdev->imageable_area.right = pdev->page_size.cx = + page->PaperDimension->x * pdev->log_pixels_x / 72; + pdev->imageable_area.top = pdev->page_size.cy = + page->PaperDimension->y * pdev->log_pixels_y / 72; } - } else if ((pdev->Devmode->dmPublic.dmFields & DM_PAPERLENGTH) && - (pdev->Devmode->dmPublic.dmFields & DM_PAPERWIDTH)) { - /* pdev sizes in device units; Devmode sizes in 1/10 mm */ - pdev->ImageableArea.left = pdev->ImageableArea.bottom = 0; - pdev->ImageableArea.right = pdev->PageSize.cx = - pdev->Devmode->dmPublic.dmPaperWidth * pdev->logPixelsX / 254; - pdev->ImageableArea.top = pdev->PageSize.cy = - pdev->Devmode->dmPublic.dmPaperLength * pdev->logPixelsY / 254; + } else if ((pdev->devmode->dmPublic.dmFields & DM_PAPERLENGTH) && + (pdev->devmode->dmPublic.dmFields & DM_PAPERWIDTH)) { + /* pdev sizes in device units; devmode sizes in 1/10 mm */ + pdev->imageable_area.left = pdev->imageable_area.bottom = 0; + pdev->imageable_area.right = pdev->page_size.cx = + pdev->devmode->dmPublic.dmPaperWidth * pdev->log_pixels_x / 254; + pdev->imageable_area.top = pdev->page_size.cy = + pdev->devmode->dmPublic.dmPaperLength * pdev->log_pixels_y / 254; } else { - FIXME("Odd dmFields %x\n", (int)pdev->Devmode->dmPublic.dmFields); - SetRectEmpty(&pdev->ImageableArea); - pdev->PageSize.cx = 0; - pdev->PageSize.cy = 0; + FIXME("Odd dmFields %x\n", (int)pdev->devmode->dmPublic.dmFields); + SetRectEmpty(&pdev->imageable_area); + pdev->page_size.cx = 0; + pdev->page_size.cy = 0; }
- TRACE("ImageableArea = %s: PageSize = %dx%d\n", wine_dbgstr_rect(&pdev->ImageableArea), - (int)pdev->PageSize.cx, (int)pdev->PageSize.cy); + TRACE("imageable_area = %s: page_size = %dx%d\n", wine_dbgstr_rect(&pdev->imageable_area), + (int)pdev->page_size.cx, (int)pdev->page_size.cy);
/* these are in device units */ - width = pdev->ImageableArea.right - pdev->ImageableArea.left; - height = pdev->ImageableArea.top - pdev->ImageableArea.bottom; + width = pdev->imageable_area.right - pdev->imageable_area.left; + height = pdev->imageable_area.top - pdev->imageable_area.bottom;
- if (pdev->Devmode->dmPublic.dmOrientation == DMORIENT_PORTRAIT) { - pdev->horzRes = width; - pdev->vertRes = height; + if (pdev->devmode->dmPublic.dmOrientation == DMORIENT_PORTRAIT) { + pdev->horz_res = width; + pdev->vert_res = height; } else { - pdev->horzRes = height; - pdev->vertRes = width; + pdev->horz_res = height; + pdev->vert_res = width; }
/* these are in mm */ - pdev->horzSize = (pdev->horzRes * 25.4) / pdev->logPixelsX; - pdev->vertSize = (pdev->vertRes * 25.4) / pdev->logPixelsY; + pdev->horz_size = (pdev->horz_res * 25.4) / pdev->log_pixels_x; + pdev->vert_size = (pdev->vert_res * 25.4) / pdev->log_pixels_y;
- TRACE("devcaps: horzSize = %dmm, vertSize = %dmm, " - "horzRes = %d, vertRes = %d\n", - pdev->horzSize, pdev->vertSize, - pdev->horzRes, pdev->vertRes); + TRACE("devcaps: horz_size = %dmm, vert_size = %dmm, " + "horz_res = %d, vert_res = %d\n", + pdev->horz_size, pdev->vert_size, + pdev->horz_res, pdev->vert_res); }
static BOOL CDECL reset_dc(PHYSDEV dev, const DEVMODEW *devmode) @@ -529,7 +552,7 @@ static BOOL CDECL reset_dc(PHYSDEV dev, const DEVMODEW *devmode)
if (devmode) { - merge_devmodes(pdev->Devmode, (const PSDRV_DEVMODE *)devmode, pdev->pi); + merge_devmodes(pdev->devmode, (const PSDRV_DEVMODE *)devmode, pdev->pi); update_dev_caps(pdev); } return TRUE; @@ -820,7 +843,7 @@ static int CDECL ext_escape(PHYSDEV dev, int escape, int input_size, const void { PSDRV_PDEVICE *pdev = get_psdrv_dev(dev); WCHAR *uv = (WCHAR *)input; - const char *name = uv_metrics(*uv, pdev->font.fontinfo.Builtin.afm)->N->sz; + const char *name = uv_metrics(*uv, pdev->afm)->N->sz;
lstrcpynA(output, name, output_size); return 1; @@ -831,14 +854,12 @@ static int CDECL ext_escape(PHYSDEV dev, int escape, int input_size, const void PSDRV_PDEVICE *pdev = get_psdrv_dev(dev); struct font_info *font_info = (struct font_info *)output;
- if (pdev->font.fontloc != Builtin) + if (!pdev->builtin) return 0;
- lstrcpynA(font_info->font_name, pdev->font.fontinfo.Builtin.afm->FontName, - sizeof(font_info->font_name)); - font_info->size.cx = pdev->font.size.xx; - font_info->size.cy = pdev->font.size.yy; - font_info->escapement = pdev->font.escapement; + lstrcpynA(font_info->font_name, pdev->afm->FontName, sizeof(font_info->font_name)); + font_info->size = pdev->size; + font_info->escapement = pdev->escapement; return 1; }
@@ -848,49 +869,36 @@ static int CDECL ext_escape(PHYSDEV dev, int escape, int input_size, const void } }
-static BOOL select_download_font(PHYSDEV dev) -{ - PSDRV_PDEVICE *pdev = get_psdrv_dev(dev); - - pdev->font.fontloc = Download; - pdev->font.fontinfo.Download = NULL; - return TRUE; -} - static inline float gdi_round(float f) { return f > 0 ? f + 0.5 : f - 0.5; }
-static void scale_font(const AFM *afm, LONG height, PSFONT *font, TEXTMETRICW *tm) +static void scale_font(PSDRV_PDEVICE *pdev, const AFM *afm, LONG height, TEXTMETRICW *tm) { const WINMETRICS *wm = &(afm->WinMetrics); USHORT units_per_em, win_ascent, win_descent; SHORT ascender, descender, line_gap, avg_char_width; + float scale; + SIZE size;
TRACE("'%s' %i\n", afm->FontName, (int)height);
if (height < 0) /* match em height */ - { - font->fontinfo.Builtin.scale = -((float)height / (float)wm->usUnitsPerEm); - } + scale = -(height / (float)wm->usUnitsPerEm); else /* match cell height */ - { - font->fontinfo.Builtin.scale = (float)height / - (float)(wm->usWinAscent + wm->usWinDescent); - } + scale = height / (float)(wm->usWinAscent + wm->usWinDescent);
- font->size.xx = (INT)gdi_round(font->fontinfo.Builtin.scale * (float)wm->usUnitsPerEm); - font->size.xy = font->size.yx = 0; - font->size.yy = -(INT)gdi_round(font->fontinfo.Builtin.scale * (float)wm->usUnitsPerEm); + size.cx = (INT)gdi_round(scale * (float)wm->usUnitsPerEm); + size.cy = -(INT)gdi_round(scale * (float)wm->usUnitsPerEm);
- units_per_em = (USHORT)gdi_round((float)wm->usUnitsPerEm * font->fontinfo.Builtin.scale); - ascender = (SHORT)gdi_round((float)wm->sAscender * font->fontinfo.Builtin.scale); - descender = (SHORT)gdi_round((float)wm->sDescender * font->fontinfo.Builtin.scale); - line_gap = (SHORT)gdi_round((float)wm->sLineGap * font->fontinfo.Builtin.scale); - win_ascent = (USHORT)gdi_round((float)wm->usWinAscent * font->fontinfo.Builtin.scale); - win_descent = (USHORT)gdi_round((float)wm->usWinDescent * font->fontinfo.Builtin.scale); - avg_char_width = (SHORT)gdi_round((float)wm->sAvgCharWidth * font->fontinfo.Builtin.scale); + units_per_em = (USHORT)gdi_round((float)wm->usUnitsPerEm * scale); + ascender = (SHORT)gdi_round((float)wm->sAscender * scale); + descender = (SHORT)gdi_round((float)wm->sDescender * scale); + line_gap = (SHORT)gdi_round((float)wm->sLineGap * scale); + win_ascent = (USHORT)gdi_round((float)wm->usWinAscent * scale); + win_descent = (USHORT)gdi_round((float)wm->usWinDescent * scale); + avg_char_width = (SHORT)gdi_round((float)wm->sAvgCharWidth * scale);
tm->tmAscent = (LONG)win_ascent; tm->tmDescent = (LONG)win_descent; @@ -932,13 +940,18 @@ static void scale_font(const AFM *afm, LONG height, PSFONT *font, TEXTMETRICW *t * similarly adjusted.. */
- font->fontinfo.Builtin.scale *= (float)wm->usUnitsPerEm / 1000.0; + scale *= (float)wm->usUnitsPerEm / 1000.0; + + tm->tmMaxCharWidth = (LONG)gdi_round((afm->FontBBox.urx - afm->FontBBox.llx) * scale);
- tm->tmMaxCharWidth = (LONG)gdi_round( - (afm->FontBBox.urx - afm->FontBBox.llx) * font->fontinfo.Builtin.scale); + if (pdev) + { + pdev->scale = scale; + pdev->size = size; + }
TRACE("Selected PS font '%s' size %d weight %d.\n", afm->FontName, - font->size.xx, (int)tm->tmWeight); + (int)size.cx, (int)tm->tmWeight); TRACE("H = %d As = %d Des = %d IL = %d EL = %d\n", (int)tm->tmHeight, (int)tm->tmAscent, (int)tm->tmDescent, (int)tm->tmInternalLeading, (int)tm->tmExternalLeading); @@ -954,8 +967,7 @@ static inline BOOL is_stock_font(HFONT font) return FALSE; }
-static BOOL select_builtin_font(PHYSDEV dev, HFONT hfont, - LOGFONTW *plf, WCHAR *face_name) +static BOOL select_builtin_font(PHYSDEV dev, HFONT hfont, LOGFONTW *plf) { PSDRV_PDEVICE *pdev = get_psdrv_dev(dev); AFMLISTENTRY *afmle; @@ -963,36 +975,36 @@ static BOOL select_builtin_font(PHYSDEV dev, HFONT hfont, BOOL bd = FALSE, it = FALSE; LONG height;
- TRACE("Trying to find facename %s\n", debugstr_w(face_name)); + TRACE("Trying to find facename %s\n", debugstr_w(plf->lfFaceName));
/* Look for a matching font family */ - for (family = pdev->pi->Fonts; family; family = family->next) + for (family = pdev->pi->pi->Fonts; family; family = family->next) { - if (!wcsicmp(face_name, family->FamilyName)) + if (!wcsicmp(plf->lfFaceName, family->FamilyName)) break; }
if (!family) { /* Fallback for Window's font families to common PostScript families */ - if (!wcscmp(face_name, arialW)) - wcscpy(face_name, helveticaW); - else if (!wcscmp(face_name, systemW)) - wcscpy(face_name, helveticaW); - else if (!wcscmp(face_name, times_new_romanW)) - wcscpy(face_name, timesW); - else if (!wcscmp(face_name, courier_newW)) - wcscpy(face_name, courierW); - - for (family = pdev->pi->Fonts; family; family = family->next) + if (!wcscmp(plf->lfFaceName, arialW)) + wcscpy(plf->lfFaceName, helveticaW); + else if (!wcscmp(plf->lfFaceName, systemW)) + wcscpy(plf->lfFaceName, helveticaW); + else if (!wcscmp(plf->lfFaceName, times_new_romanW)) + wcscpy(plf->lfFaceName, timesW); + else if (!wcscmp(plf->lfFaceName, courier_newW)) + wcscpy(plf->lfFaceName, courierW); + + for (family = pdev->pi->pi->Fonts; family; family = family->next) { - if (!wcscmp(face_name, family->FamilyName)) + if (!wcscmp(plf->lfFaceName, family->FamilyName)) break; } } /* If all else fails, use the first font defined for the printer */ if (!family) - family = pdev->pi->Fonts; + family = pdev->pi->pi->Fonts;
TRACE("Got family %s\n", debugstr_w(family->FamilyName));
@@ -1012,8 +1024,8 @@ static BOOL select_builtin_font(PHYSDEV dev, HFONT hfont,
TRACE("Got font '%s'\n", afmle->afm->FontName);
- pdev->font.fontloc = Builtin; - pdev->font.fontinfo.Builtin.afm = afmle->afm; + pdev->builtin = TRUE; + pdev->afm = afmle->afm;
height = plf->lfHeight; /* stock fonts ignore the mapping mode */ @@ -1025,13 +1037,12 @@ static BOOL select_builtin_font(PHYSDEV dev, HFONT hfont, NtGdiTransformPoints(dev->hdc, pts, pts, 2, NtGdiLPtoDP); height = pts[1].y - pts[0].y; } - scale_font(pdev->font.fontinfo.Builtin.afm, height, - &(pdev->font), &(pdev->font.fontinfo.Builtin.tm)); + scale_font(pdev, pdev->afm, height, &pdev->tm);
/* Does anyone know if these are supposed to be reversed like this? */ - pdev->font.fontinfo.Builtin.tm.tmDigitizedAspectX = pdev->logPixelsY; - pdev->font.fontinfo.Builtin.tm.tmDigitizedAspectY = pdev->logPixelsX; + pdev->tm.tmDigitizedAspectX = pdev->log_pixels_y; + pdev->tm.tmDigitizedAspectY = pdev->log_pixels_x; return TRUE; }
@@ -1086,57 +1097,54 @@ static HFONT CDECL select_font(PHYSDEV dev, HFONT hfont, UINT *aa_flags) } }
- if (pdev->pi->FontSubTableSize != 0) + if (pdev->pi->pi->FontSubTableSize != 0) { DWORD i;
- for (i = 0; i < pdev->pi->FontSubTableSize; ++i) + for (i = 0; i < pdev->pi->pi->FontSubTableSize; ++i) { - if (!wcsicmp(lf.lfFaceName, pdev->pi->FontSubTable[i].pValueName)) + if (!wcsicmp(lf.lfFaceName, pdev->pi->pi->FontSubTable[i].pValueName)) { TRACE("substituting facename %s for %s\n", - debugstr_w((WCHAR *)pdev->pi->FontSubTable[i].pData), debugstr_w(lf.lfFaceName)); - if (wcslen((WCHAR *)pdev->pi->FontSubTable[i].pData) < LF_FACESIZE) + debugstr_w((WCHAR *)pdev->pi->pi->FontSubTable[i].pData), debugstr_w(lf.lfFaceName)); + if (wcslen((WCHAR *)pdev->pi->pi->FontSubTable[i].pData) < LF_FACESIZE) { - wcscpy(lf.lfFaceName, (WCHAR *)pdev->pi->FontSubTable[i].pData); + wcscpy(lf.lfFaceName, (WCHAR *)pdev->pi->pi->FontSubTable[i].pData); subst = TRUE; } else { WARN("Facename %s is too long; ignoring substitution\n", - debugstr_w((WCHAR *)pdev->pi->FontSubTable[i].pData)); + debugstr_w((WCHAR *)pdev->pi->pi->FontSubTable[i].pData)); } break; } } }
- pdev->font.escapement = lf.lfEscapement; - pdev->font.set = UNSET; + pdev->escapement = lf.lfEscapement;
if (!subst && ((ret = next->funcs->pSelectFont(next, hfont, aa_flags)))) { - select_download_font(dev); + pdev->builtin = FALSE; return ret; }
- select_builtin_font(dev, hfont, &lf, lf.lfFaceName); + select_builtin_font(dev, hfont, &lf); next->funcs->pSelectFont(next, 0, aa_flags); /* tell next driver that we selected a device font */ return hfont; }
-static UINT get_font_metric(HDC hdc, const AFM *afm, - NEWTEXTMETRICEXW *ntmx, ENUMLOGFONTEXW *elfx) +static UINT get_font_metric(const AFM *afm, NEWTEXTMETRICEXW *ntmx, ENUMLOGFONTEXW *elfx) { /* ntmx->ntmTm is NEWTEXTMETRICW; compatible w/ TEXTMETRICW per Win32 doc */ TEXTMETRICW *tm = (TEXTMETRICW *)&(ntmx->ntmTm); LOGFONTW *lf = &(elfx->elfLogFont); - PSFONT font;
memset(ntmx, 0, sizeof(*ntmx)); memset(elfx, 0, sizeof(*elfx));
- scale_font(afm, -(LONG)afm->WinMetrics.usUnitsPerEm, &font, tm); + scale_font(NULL, afm, -(LONG)afm->WinMetrics.usUnitsPerEm, tm);
lf->lfHeight = tm->tmHeight; lf->lfWidth = tm->tmAveCharWidth; @@ -1166,7 +1174,7 @@ static BOOL CDECL enum_fonts(PHYSDEV dev, LPLOGFONTW plf, FONTENUMPROCW proc, LP if (plf && plf->lfFaceName[0]) { TRACE("lfFaceName = %s\n", debugstr_w(plf->lfFaceName)); - for (family = pdev->pi->Fonts; family; family = family->next) + for (family = pdev->pi->pi->Fonts; family; family = family->next) { if (!wcsncmp(plf->lfFaceName, family->FamilyName, wcslen(family->FamilyName))) @@ -1179,7 +1187,7 @@ static BOOL CDECL enum_fonts(PHYSDEV dev, LPLOGFONTW plf, FONTENUMPROCW proc, LP UINT fm;
TRACE("Got '%s'\n", afmle->afm->FontName); - fm = get_font_metric(dev->hdc, afmle->afm, &tm, &lf); + fm = get_font_metric(afmle->afm, &tm, &lf); if (!(ret = (*proc)(&lf.elfLogFont, (TEXTMETRICW *)&tm, fm, lp))) break; } @@ -1188,13 +1196,13 @@ static BOOL CDECL enum_fonts(PHYSDEV dev, LPLOGFONTW plf, FONTENUMPROCW proc, LP else { TRACE("lfFaceName = NULL\n"); - for (family = pdev->pi->Fonts; family; family = family->next) + for (family = pdev->pi->pi->Fonts; family; family = family->next) { UINT fm;
afmle = family->afmlist; TRACE("Got '%s'\n", afmle->afm->FontName); - fm = get_font_metric(dev->hdc, afmle->afm, &tm, &lf); + fm = get_font_metric(afmle->afm, &tm, &lf); if (!(ret = (*proc)(&lf.elfLogFont, (TEXTMETRICW *)&tm, fm, lp))) break; } @@ -1207,7 +1215,7 @@ static BOOL CDECL get_char_width(PHYSDEV dev, UINT first, UINT count, const WCHA PSDRV_PDEVICE *pdev = get_psdrv_dev(dev); UINT i, c;
- if (pdev->font.fontloc == Download) + if (!pdev->builtin) { dev = GET_NEXT_PHYSDEV(dev, pGetCharWidth); return dev->funcs->pGetCharWidth(dev, first, count, chars, buffer); @@ -1222,8 +1230,7 @@ static BOOL CDECL get_char_width(PHYSDEV dev, UINT first, UINT count, const WCHA if (c > 0xffff) return FALSE;
- *buffer = floor(uv_metrics(c, pdev->font.fontinfo.Builtin.afm)->WX - * pdev->font.fontinfo.Builtin.scale + 0.5); + *buffer = floor(uv_metrics(c, pdev->afm)->WX * pdev->scale + 0.5); TRACE("U+%.4X: %i\n", i, *buffer); ++buffer; } @@ -1234,14 +1241,13 @@ static BOOL CDECL get_text_metrics(PHYSDEV dev, TEXTMETRICW *metrics) { PSDRV_PDEVICE *pdev = get_psdrv_dev(dev);
- if (pdev->font.fontloc == Download) + if (!pdev->builtin) { dev = GET_NEXT_PHYSDEV(dev, pGetTextMetrics); return dev->funcs->pGetTextMetrics(dev, metrics); }
- memcpy(metrics, &(pdev->font.fontinfo.Builtin.tm), - sizeof(pdev->font.fontinfo.Builtin.tm)); + memcpy(metrics, &pdev->tm, sizeof(pdev->tm)); return TRUE; }
@@ -1251,7 +1257,7 @@ static BOOL CDECL get_text_extent_ex_point(PHYSDEV dev, const WCHAR *str, int co int i; float width = 0.0;
- if (pdev->font.fontloc == Download) + if (!pdev->builtin) { dev = GET_NEXT_PHYSDEV(dev, pGetTextExtentExPoint); return dev->funcs->pGetTextExtentExPoint(dev, str, count, dx); @@ -1261,8 +1267,8 @@ static BOOL CDECL get_text_extent_ex_point(PHYSDEV dev, const WCHAR *str, int co
for (i = 0; i < count; ++i) { - width += uv_metrics(str[i], pdev->font.fontinfo.Builtin.afm)->WX; - dx[i] = width * pdev->font.fontinfo.Builtin.scale; + width += uv_metrics(str[i], pdev->afm)->WX; + dx[i] = width * pdev->scale; } return TRUE; } @@ -1302,22 +1308,22 @@ static PSDRV_PDEVICE *create_physdev(HDC hdc, const WCHAR *device, pdev = malloc(sizeof(*pdev)); if (!pdev) return NULL;
- pdev->Devmode = malloc(sizeof(PSDRV_DEVMODE)); - if (!pdev->Devmode) + pdev->devmode = malloc(sizeof(PSDRV_DEVMODE)); + if (!pdev->devmode) { free(pdev); return NULL; }
- *pdev->Devmode = *pi->pi->Devmode; - pdev->pi = pi->pi; - pdev->logPixelsX = pi->pi->ppd->DefaultResolution; - pdev->logPixelsY = pi->pi->ppd->DefaultResolution; + *pdev->devmode = *pi->pi->Devmode; + pdev->pi = pi; + pdev->log_pixels_x = pi->pi->ppd->DefaultResolution; + pdev->log_pixels_y = pi->pi->ppd->DefaultResolution;
if (devmode) { dump_devmode(&devmode->dmPublic); - merge_devmodes(pdev->Devmode, devmode, pi->pi); + merge_devmodes(pdev->devmode, devmode, pi); }
update_dev_caps(pdev); @@ -1343,8 +1349,8 @@ static BOOL CDECL create_compatible_dc(PHYSDEV orig, PHYSDEV *dev) { PSDRV_PDEVICE *pdev, *orig_dev = get_psdrv_dev(orig);
- if (!(pdev = create_physdev((*dev)->hdc, orig_dev->pi->friendly_name, - orig_dev->Devmode))) return FALSE; + if (!(pdev = create_physdev((*dev)->hdc, orig_dev->pi->name, + orig_dev->devmode))) return FALSE; push_dc_driver(dev, &pdev->dev, &psdrv_funcs); return TRUE; } @@ -1355,7 +1361,7 @@ static BOOL CDECL delete_dc(PHYSDEV dev)
TRACE("\n");
- free(pdev->Devmode); + free(pdev->devmode); free(pdev); return TRUE; }
This merge request was approved by Huw Davies.