Huw Davies : gdi32: Implement SetVirtualResolution.
Alexandre Julliard
julliard at winehq.org
Tue Jun 23 10:02:51 CDT 2009
Module: wine
Branch: master
Commit: 5c386041fc0814b52887f8e208e0215e32c54809
URL: http://source.winehq.org/git/wine.git/?a=commit;h=5c386041fc0814b52887f8e208e0215e32c54809
Author: Huw Davies <huw at codeweavers.com>
Date: Tue Jun 23 14:55:32 2009 +0100
gdi32: Implement SetVirtualResolution.
---
dlls/gdi32/dc.c | 16 +++-------
dlls/gdi32/enhmfdrv/init.c | 2 +
dlls/gdi32/gdi_private.h | 4 ++
dlls/gdi32/mapping.c | 70 +++++++++++++++++++++++++++++++++++++++-----
dlls/gdi32/mfdrv/init.c | 2 +
5 files changed, 75 insertions(+), 19 deletions(-)
diff --git a/dlls/gdi32/dc.c b/dlls/gdi32/dc.c
index 04e4942..30bd7a4 100644
--- a/dlls/gdi32/dc.c
+++ b/dlls/gdi32/dc.c
@@ -252,6 +252,7 @@ void DC_InitDC( DC* dc )
SelectObject( dc->hSelf, dc->hBrush );
SelectObject( dc->hSelf, dc->hFont );
CLIPPING_UpdateGCRegion( dc );
+ SetVirtualResolution( dc->hSelf, 0, 0, 0, 0 );
}
@@ -386,6 +387,8 @@ INT save_dc_state( HDC hdc )
newdc->vportOrgY = dc->vportOrgY;
newdc->vportExtX = dc->vportExtX;
newdc->vportExtY = dc->vportExtY;
+ newdc->virtual_res = dc->virtual_res;
+ newdc->virtual_size = dc->virtual_size;
newdc->BoundsRect = dc->BoundsRect;
newdc->gdiFont = dc->gdiFont;
@@ -524,6 +527,8 @@ BOOL restore_dc_state( HDC hdc, INT level )
dc->vportOrgY = dcs->vportOrgY;
dc->vportExtX = dcs->vportExtX;
dc->vportExtY = dcs->vportExtY;
+ dc->virtual_res = dcs->virtual_res;
+ dc->virtual_size = dcs->virtual_size;
if (dcs->hClipRgn)
{
@@ -2103,17 +2108,6 @@ BOOL WINAPI CancelDC(HDC hdc)
return TRUE;
}
-/***********************************************************************
- * SetVirtualResolution (GDI32.@)
- *
- * Undocumented on msdn. Called when PowerPoint XP saves a file.
- */
-DWORD WINAPI SetVirtualResolution(HDC hdc, DWORD dw2, DWORD dw3, DWORD dw4, DWORD dw5)
-{
- FIXME("(%p %08x %08x %08x %08x): stub!\n", hdc, dw2, dw3, dw4, dw5);
- return FALSE;
-}
-
/*******************************************************************
* GetMiterLimit [GDI32.@]
*
diff --git a/dlls/gdi32/enhmfdrv/init.c b/dlls/gdi32/enhmfdrv/init.c
index 5d2453a..dd0b89e 100644
--- a/dlls/gdi32/enhmfdrv/init.c
+++ b/dlls/gdi32/enhmfdrv/init.c
@@ -358,6 +358,8 @@ HDC WINAPI CreateEnhMetaFileW(
physDev->numcolors = GetDeviceCaps(hRefDC, NUMCOLORS);
physDev->restoring = 0;
+ SetVirtualResolution(dc->hSelf, 0, 0, 0, 0);
+
physDev->emh->iType = EMR_HEADER;
physDev->emh->nSize = size;
diff --git a/dlls/gdi32/gdi_private.h b/dlls/gdi32/gdi_private.h
index da66ade..d7f1d91 100644
--- a/dlls/gdi32/gdi_private.h
+++ b/dlls/gdi32/gdi_private.h
@@ -263,6 +263,8 @@ typedef struct tagDC
INT vportOrgY;
INT vportExtX; /* Viewport extent */
INT vportExtY;
+ SIZE virtual_res; /* Initially HORZRES,VERTRES. Changed by SetVirtualResolution */
+ SIZE virtual_size; /* Initially HORZSIZE,VERTSIZE. Changed by SetVirtualResolution */
FLOAT miterLimit;
int flags;
@@ -511,4 +513,6 @@ extern BOOL REGION_FrameRgn( HRGN dest, HRGN src, INT x, INT y ) DECLSPEC_HIDDEN
BOOL WINAPI FontIsLinked(HDC);
+BOOL WINAPI SetVirtualResolution(HDC hdc, DWORD horz_res, DWORD vert_res, DWORD horz_size, DWORD vert_size);
+
#endif /* __WINE_GDI_PRIVATE_H */
diff --git a/dlls/gdi32/mapping.c b/dlls/gdi32/mapping.c
index c802a10..e199dd3 100644
--- a/dlls/gdi32/mapping.c
+++ b/dlls/gdi32/mapping.c
@@ -37,10 +37,10 @@ WINE_DEFAULT_DEBUG_CHANNEL(dc);
*/
static void MAPPING_FixIsotropic( DC * dc )
{
- double xdim = fabs((double)dc->vportExtX * GetDeviceCaps( dc->hSelf, HORZSIZE ) /
- (GetDeviceCaps( dc->hSelf, HORZRES ) * dc->wndExtX));
- double ydim = fabs((double)dc->vportExtY * GetDeviceCaps( dc->hSelf, VERTSIZE ) /
- (GetDeviceCaps( dc->hSelf, VERTRES ) * dc->wndExtY));
+ double xdim = fabs((double)dc->vportExtX * dc->virtual_size.cx /
+ (dc->virtual_res.cx * dc->wndExtX));
+ double ydim = fabs((double)dc->vportExtY * dc->virtual_size.cy /
+ (dc->virtual_res.cy * dc->wndExtY));
if (xdim > ydim)
{
@@ -137,10 +137,10 @@ INT WINAPI SetMapMode( HDC hdc, INT mode )
if (mode == dc->MapMode && (mode == MM_ISOTROPIC || mode == MM_ANISOTROPIC))
goto done;
- horzSize = GetDeviceCaps( hdc, HORZSIZE );
- vertSize = GetDeviceCaps( hdc, VERTSIZE );
- horzRes = GetDeviceCaps( hdc, HORZRES );
- vertRes = GetDeviceCaps( hdc, VERTRES );
+ horzSize = dc->virtual_size.cx;
+ vertSize = dc->virtual_size.cy;
+ horzRes = dc->virtual_res.cx;
+ vertRes = dc->virtual_res.cy;
switch(mode)
{
case MM_TEXT:
@@ -481,3 +481,57 @@ BOOL WINAPI ScaleWindowExtEx( HDC hdc, INT xNum, INT xDenom,
release_dc_ptr( dc );
return ret;
}
+
+/***********************************************************************
+ * SetVirtualResolution (GDI32.@)
+ *
+ * Undocumented on msdn.
+ *
+ * Changes the values of screen size in pixels and millimeters used by
+ * the mapping mode functions.
+ *
+ * PARAMS
+ * hdc [I] Device context
+ * horz_res [I] Width in pixels (equivalent to HORZRES device cap).
+ * vert_res [I] Height in pixels (equivalent to VERTRES device cap).
+ * horz_size [I] Width in mm (equivalent to HORZSIZE device cap).
+ * vert_size [I] Height in mm (equivalent to VERTSIZE device cap).
+ *
+ * RETURNS
+ * TRUE if successful.
+ * FALSE if any (but not all) of the last four params are zero.
+ *
+ * NOTES
+ * This doesn't change the values returned by GetDeviceCaps, just the
+ * scaling of the mapping modes.
+ *
+ * Calling with the last four params equal to zero sets the values
+ * back to their defaults obtained by calls to GetDeviceCaps.
+ */
+BOOL WINAPI SetVirtualResolution(HDC hdc, DWORD horz_res, DWORD vert_res,
+ DWORD horz_size, DWORD vert_size)
+{
+ DC * dc;
+ 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)
+ {
+ horz_res = GetDeviceCaps(hdc, HORZRES);
+ vert_res = GetDeviceCaps(hdc, VERTRES);
+ 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 );
+ if (!dc) return FALSE;
+
+ dc->virtual_res.cx = horz_res;
+ dc->virtual_res.cy = vert_res;
+ dc->virtual_size.cx = horz_size;
+ dc->virtual_size.cy = vert_size;
+
+ release_dc_ptr( dc );
+ return TRUE;
+}
diff --git a/dlls/gdi32/mfdrv/init.c b/dlls/gdi32/mfdrv/init.c
index ad29cb0..a5b18d3 100644
--- a/dlls/gdi32/mfdrv/init.c
+++ b/dlls/gdi32/mfdrv/init.c
@@ -197,6 +197,8 @@ static DC *MFDRV_AllocMetaFile(void)
physDev->mh->mtMaxRecord = 0;
physDev->mh->mtNoParameters = 0;
+ SetVirtualResolution(dc->hSelf, 0, 0, 0, 0);
+
return dc;
}
More information about the wine-cvs
mailing list