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

wineps: Don't store logPixels in print_ctx.

parent 3fca78fb
......@@ -410,47 +410,12 @@ static void dump_devmode(const DEVMODEW *dm)
static void PSDRV_UpdateDevCaps( print_ctx *ctx )
{
int log_pixels_x = GetDeviceCaps(ctx->hdc, ASPECTX);
int log_pixels_y = GetDeviceCaps(ctx->hdc, ASPECTY);
PAGESIZE *page;
RESOLUTION *res;
INT resx = 0, resy = 0;
dump_devmode(&ctx->Devmode->dmPublic);
if (ctx->Devmode->dmPublic.dmFields & (DM_PRINTQUALITY | DM_YRESOLUTION | DM_LOGPIXELS))
{
if (ctx->Devmode->dmPublic.dmFields & DM_PRINTQUALITY)
resx = resy = ctx->Devmode->dmPublic.dmPrintQuality;
if (ctx->Devmode->dmPublic.dmFields & DM_YRESOLUTION)
resy = ctx->Devmode->dmPublic.dmYResolution;
if (ctx->Devmode->dmPublic.dmFields & DM_LOGPIXELS)
resx = resy = ctx->Devmode->dmPublic.dmLogPixels;
LIST_FOR_EACH_ENTRY(res, &ctx->pi->ppd->Resolutions, RESOLUTION, entry)
{
if (res->resx == resx && res->resy == resy)
{
ctx->logPixelsX = resx;
ctx->logPixelsY = resy;
break;
}
}
if (&res->entry == &ctx->pi->ppd->Resolutions)
{
WARN("Requested resolution %dx%d is not supported by device\n", resx, resy);
ctx->logPixelsX = ctx->pi->ppd->DefaultResolution;
ctx->logPixelsY = ctx->logPixelsX;
}
}
else
{
WARN("Using default device resolution %d\n", ctx->pi->ppd->DefaultResolution);
ctx->logPixelsX = ctx->pi->ppd->DefaultResolution;
ctx->logPixelsY = ctx->logPixelsX;
}
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)
......@@ -462,25 +427,23 @@ static void PSDRV_UpdateDevCaps( print_ctx *ctx )
SetRectEmpty(&ctx->ImageableArea);
} else if(page->ImageableArea) {
/* 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);
SetRect(&ctx->ImageableArea, page->ImageableArea->llx * log_pixels_x / 72,
page->ImageableArea->ury * log_pixels_y / 72,
page->ImageableArea->urx * log_pixels_x / 72,
page->ImageableArea->lly * log_pixels_y / 72);
} else {
ctx->ImageableArea.left = ctx->ImageableArea.bottom = 0;
ctx->ImageableArea.right =
page->PaperDimension->x * ctx->logPixelsX / 72;
ctx->ImageableArea.top =
page->PaperDimension->y * ctx->logPixelsY / 72;
ctx->ImageableArea.right = page->PaperDimension->x * log_pixels_x / 72;
ctx->ImageableArea.top = page->PaperDimension->y * log_pixels_y / 72;
}
} 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->Devmode->dmPublic.dmPaperWidth * ctx->logPixelsX / 254;
ctx->Devmode->dmPublic.dmPaperWidth * log_pixels_x / 254;
ctx->ImageableArea.top =
ctx->Devmode->dmPublic.dmPaperLength * ctx->logPixelsY / 254;
ctx->Devmode->dmPublic.dmPaperLength * log_pixels_y / 254;
} else {
FIXME("Odd dmFields %lx\n", ctx->Devmode->dmPublic.dmFields);
SetRectEmpty(&ctx->ImageableArea);
......@@ -523,8 +486,7 @@ print_ctx *create_print_ctx( HDC hdc, const WCHAR *device,
memcpy( ctx->Devmode, pi->Devmode,
pi->Devmode->dmPublic.dmSize + pi->Devmode->dmPublic.dmDriverExtra );
ctx->pi = pi;
ctx->logPixelsX = pi->ppd->DefaultResolution;
ctx->logPixelsY = pi->ppd->DefaultResolution;
ctx->hdc = hdc;
if (devmode)
{
......@@ -533,7 +495,6 @@ print_ctx *create_print_ctx( HDC hdc, const WCHAR *device,
}
PSDRV_UpdateDevCaps( ctx );
ctx->hdc = hdc;
SelectObject( hdc, GetStockObject( DEVICE_DEFAULT_FONT ));
return ctx;
}
......
......@@ -400,7 +400,7 @@ INT PSDRV_WriteHeader( print_ctx *ctx, LPCWSTR title )
INPUTSLOT *slot = find_slot( ctx->pi->ppd, &ctx->Devmode->dmPublic );
PAGESIZE *page = find_pagesize( ctx->pi->ppd, &ctx->Devmode->dmPublic );
DUPLEX *duplex = find_duplex( ctx->pi->ppd, &ctx->Devmode->dmPublic );
int llx, lly, urx, ury;
int llx, lly, urx, ury, log_pixels_x, log_pixels_y;
int ret, len;
const char * dmOrientation;
......@@ -429,10 +429,12 @@ INT PSDRV_WriteHeader( print_ctx *ctx, LPCWSTR title )
/* BBox co-ords are in default user co-ord system so urx < ury even in
landscape mode */
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;
log_pixels_x = GetDeviceCaps(ctx->hdc, ASPECTX);
log_pixels_y = GetDeviceCaps(ctx->hdc, ASPECTY);
llx = ctx->ImageableArea.left * 72.0 / log_pixels_x;
lly = ctx->ImageableArea.bottom * 72.0 / log_pixels_y;
urx = ctx->ImageableArea.right * 72.0 / log_pixels_x;
ury = ctx->ImageableArea.top * 72.0 / log_pixels_y;
/* FIXME should do something better with BBox */
dmOrientation = (ctx->Devmode->dmPublic.dmOrientation == DMORIENT_LANDSCAPE ? "Landscape" : "Portrait");
......@@ -532,7 +534,7 @@ INT PSDRV_WriteNewPage( print_ctx *ctx )
}
sprintf(buf, psnewpage, name, ctx->job.PageNo,
ctx->logPixelsX, ctx->logPixelsY,
GetDeviceCaps(ctx->hdc, ASPECTX), GetDeviceCaps(ctx->hdc, ASPECTY),
xtrans, ytrans, rotation);
if( write_spool( ctx, buf, strlen(buf) ) != strlen(buf) ) {
......@@ -981,8 +983,8 @@ BOOL PSDRV_WriteDIBPatternDict(print_ctx *ctx, const BITMAPINFO *bmi, BYTE *bits
PSDRV_WriteIndexColorSpaceEnd(ctx);
/* Windows seems to scale patterns so that a one pixel corresponds to 1/300" */
w_mult = (ctx->logPixelsX + 150) / 300;
h_mult = (ctx->logPixelsY + 150) / 300;
w_mult = (GetDeviceCaps(ctx->hdc, ASPECTX) + 150) / 300;
h_mult = (GetDeviceCaps(ctx->hdc, ASPECTY) + 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(ctx, buf, strlen(buf));
HeapFree( GetProcessHeap(), 0, buf );
......
......@@ -346,9 +346,6 @@ typedef struct
are not rotated in landscape mode,
so PageSize.cx is generally
< PageSize.cy */
int logPixelsX;
int logPixelsY;
int pathdepth;
} print_ctx;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment