Commit 3e88582a authored by Alexandre Julliard's avatar Alexandre Julliard

gdi32: Determine the virtual resolution dynamically if it hasn't been set.

parent fa37b635
...@@ -29,6 +29,30 @@ ...@@ -29,6 +29,30 @@
WINE_DEFAULT_DEBUG_CHANNEL(dc); WINE_DEFAULT_DEBUG_CHANNEL(dc);
static SIZE get_dc_virtual_size( DC *dc )
{
SIZE ret = dc->virtual_size;
if (!ret.cx)
{
ret.cx = GetDeviceCaps( dc->hSelf, HORZSIZE );
ret.cy = GetDeviceCaps( dc->hSelf, VERTSIZE );
}
return ret;
}
static SIZE get_dc_virtual_res( DC *dc )
{
SIZE ret = dc->virtual_res;
if (!ret.cx)
{
ret.cx = GetDeviceCaps( dc->hSelf, HORZRES );
ret.cy = GetDeviceCaps( dc->hSelf, VERTRES );
}
return ret;
}
/*********************************************************************** /***********************************************************************
* MAPPING_FixIsotropic * MAPPING_FixIsotropic
* *
...@@ -36,10 +60,10 @@ WINE_DEFAULT_DEBUG_CHANNEL(dc); ...@@ -36,10 +60,10 @@ WINE_DEFAULT_DEBUG_CHANNEL(dc);
*/ */
static void MAPPING_FixIsotropic( DC * dc ) static void MAPPING_FixIsotropic( DC * dc )
{ {
double xdim = fabs((double)dc->vportExtX * dc->virtual_size.cx / SIZE virtual_size = get_dc_virtual_size( dc );
(dc->virtual_res.cx * dc->wndExtX)); SIZE virtual_res = get_dc_virtual_res( dc );
double ydim = fabs((double)dc->vportExtY * dc->virtual_size.cy / double xdim = fabs((double)dc->vportExtX * virtual_size.cx / (virtual_res.cx * dc->wndExtX));
(dc->virtual_res.cy * dc->wndExtY)); double ydim = fabs((double)dc->vportExtY * virtual_size.cy / (virtual_res.cy * dc->wndExtY));
if (xdim > ydim) if (xdim > ydim)
{ {
...@@ -136,14 +160,12 @@ INT nulldrv_SetMapMode( PHYSDEV dev, INT mode ) ...@@ -136,14 +160,12 @@ INT nulldrv_SetMapMode( PHYSDEV dev, INT mode )
{ {
DC *dc = get_nulldrv_dc( dev ); DC *dc = get_nulldrv_dc( dev );
INT ret = dc->MapMode; INT ret = dc->MapMode;
INT horzSize, vertSize, horzRes, vertRes; SIZE virtual_size, virtual_res;
if (mode == dc->MapMode && (mode == MM_ISOTROPIC || mode == MM_ANISOTROPIC)) return ret; if (mode == dc->MapMode && (mode == MM_ISOTROPIC || mode == MM_ANISOTROPIC)) return ret;
horzSize = dc->virtual_size.cx; virtual_size = get_dc_virtual_size( dc );
vertSize = dc->virtual_size.cy; virtual_res = get_dc_virtual_res( dc );
horzRes = dc->virtual_res.cx;
vertRes = dc->virtual_res.cy;
switch (mode) switch (mode)
{ {
case MM_TEXT: case MM_TEXT:
...@@ -154,34 +176,34 @@ INT nulldrv_SetMapMode( PHYSDEV dev, INT mode ) ...@@ -154,34 +176,34 @@ INT nulldrv_SetMapMode( PHYSDEV dev, INT mode )
break; break;
case MM_LOMETRIC: case MM_LOMETRIC:
case MM_ISOTROPIC: case MM_ISOTROPIC:
dc->wndExtX = horzSize * 10; dc->wndExtX = virtual_size.cx * 10;
dc->wndExtY = vertSize * 10; dc->wndExtY = virtual_size.cy * 10;
dc->vportExtX = horzRes; dc->vportExtX = virtual_res.cx;
dc->vportExtY = -vertRes; dc->vportExtY = -virtual_res.cy;
break; break;
case MM_HIMETRIC: case MM_HIMETRIC:
dc->wndExtX = horzSize * 100; dc->wndExtX = virtual_size.cx * 100;
dc->wndExtY = vertSize * 100; dc->wndExtY = virtual_size.cy * 100;
dc->vportExtX = horzRes; dc->vportExtX = virtual_res.cx;
dc->vportExtY = -vertRes; dc->vportExtY = -virtual_res.cy;
break; break;
case MM_LOENGLISH: case MM_LOENGLISH:
dc->wndExtX = MulDiv(1000, horzSize, 254); dc->wndExtX = MulDiv(1000, virtual_size.cx, 254);
dc->wndExtY = MulDiv(1000, vertSize, 254); dc->wndExtY = MulDiv(1000, virtual_size.cy, 254);
dc->vportExtX = horzRes; dc->vportExtX = virtual_res.cx;
dc->vportExtY = -vertRes; dc->vportExtY = -virtual_res.cy;
break; break;
case MM_HIENGLISH: case MM_HIENGLISH:
dc->wndExtX = MulDiv(10000, horzSize, 254); dc->wndExtX = MulDiv(10000, virtual_size.cx, 254);
dc->wndExtY = MulDiv(10000, vertSize, 254); dc->wndExtY = MulDiv(10000, virtual_size.cy, 254);
dc->vportExtX = horzRes; dc->vportExtX = virtual_res.cx;
dc->vportExtY = -vertRes; dc->vportExtY = -virtual_res.cy;
break; break;
case MM_TWIPS: case MM_TWIPS:
dc->wndExtX = MulDiv(14400, horzSize, 254); dc->wndExtX = MulDiv(14400, virtual_size.cx, 254);
dc->wndExtY = MulDiv(14400, vertSize, 254); dc->wndExtY = MulDiv(14400, virtual_size.cy, 254);
dc->vportExtX = horzRes; dc->vportExtX = virtual_res.cx;
dc->vportExtY = -vertRes; dc->vportExtY = -virtual_res.cy;
break; break;
case MM_ANISOTROPIC: case MM_ANISOTROPIC:
break; break;
...@@ -596,15 +618,11 @@ BOOL WINAPI SetVirtualResolution(HDC hdc, DWORD horz_res, DWORD vert_res, ...@@ -596,15 +618,11 @@ BOOL WINAPI SetVirtualResolution(HDC hdc, DWORD horz_res, DWORD vert_res,
DC * dc; DC * dc;
TRACE("(%p %d %d %d %d)\n", hdc, horz_res, vert_res, horz_size, vert_size); TRACE("(%p %d %d %d %d)\n", hdc, horz_res, vert_res, horz_size, vert_size);
if(horz_res == 0 && vert_res == 0 && horz_size == 0 && vert_size == 0) if (!horz_res || !vert_res || !horz_size || !vert_size)
{ {
horz_res = GetDeviceCaps(hdc, HORZRES); /* they must be all zero */
vert_res = GetDeviceCaps(hdc, VERTRES); if (horz_res || vert_res || horz_size || vert_size) return FALSE;
horz_size = GetDeviceCaps(hdc, HORZSIZE);
vert_size = GetDeviceCaps(hdc, VERTSIZE);
} }
else if(horz_res == 0 || vert_res == 0 || horz_size == 0 || vert_size == 0)
return FALSE;
dc = get_dc_ptr( hdc ); dc = get_dc_ptr( hdc );
if (!dc) return FALSE; if (!dc) return FALSE;
......
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