Alexandre Julliard : gdi32: Completely implement SaveDC in the driver, having it call save_dc_state if necessary.
Alexandre Julliard
julliard at winehq.org
Wed Apr 8 10:05:31 CDT 2009
Module: wine
Branch: master
Commit: bbb1626bf8629e20778b514c2aed26a7a341f553
URL: http://source.winehq.org/git/wine.git/?a=commit;h=bbb1626bf8629e20778b514c2aed26a7a341f553
Author: Alexandre Julliard <julliard at winehq.org>
Date: Tue Apr 7 20:32:58 2009 +0200
gdi32: Completely implement SaveDC in the driver, having it call save_dc_state if necessary.
---
dlls/gdi32/dc.c | 12 +++---------
dlls/gdi32/enhmfdrv/dc.c | 13 ++++++++++---
dlls/gdi32/tests/metafile.c | 26 ++++++++++++++++++++------
3 files changed, 33 insertions(+), 18 deletions(-)
diff --git a/dlls/gdi32/dc.c b/dlls/gdi32/dc.c
index ae58479..4694c3e 100644
--- a/dlls/gdi32/dc.c
+++ b/dlls/gdi32/dc.c
@@ -578,19 +578,13 @@ INT WINAPI SaveDC( HDC hdc )
DC * dc;
INT ret;
- dc = get_dc_ptr( hdc );
- if (!dc) return 0;
+ if (!(dc = get_dc_ptr( hdc ))) return 0;
if(dc->funcs->pSaveDC)
- {
ret = dc->funcs->pSaveDC( dc->physDev );
- if(ret)
- ret = ++dc->saveLevel;
- release_dc_ptr( dc );
- return ret;
- }
+ else
+ ret = save_dc_state( hdc );
- ret = save_dc_state( hdc );
release_dc_ptr( dc );
return ret;
}
diff --git a/dlls/gdi32/enhmfdrv/dc.c b/dlls/gdi32/enhmfdrv/dc.c
index f08b17d..bd5dbd5 100644
--- a/dlls/gdi32/enhmfdrv/dc.c
+++ b/dlls/gdi32/enhmfdrv/dc.c
@@ -25,10 +25,17 @@ WINE_DEFAULT_DEBUG_CHANNEL(enhmetafile);
INT CDECL EMFDRV_SaveDC( PHYSDEV dev )
{
+ EMFDRV_PDEVICE* physDev = (EMFDRV_PDEVICE*)dev;
+ INT ret = save_dc_state( physDev->hdc );
EMRSAVEDC emr;
- emr.emr.iType = EMR_SAVEDC;
- emr.emr.nSize = sizeof(emr);
- return EMFDRV_WriteRecord( dev, &emr.emr );
+
+ if (ret)
+ {
+ emr.emr.iType = EMR_SAVEDC;
+ emr.emr.nSize = sizeof(emr);
+ EMFDRV_WriteRecord( dev, &emr.emr );
+ }
+ return ret;
}
BOOL CDECL EMFDRV_RestoreDC( PHYSDEV dev, INT level )
diff --git a/dlls/gdi32/tests/metafile.c b/dlls/gdi32/tests/metafile.c
index 63c2cc4..2524af1 100644
--- a/dlls/gdi32/tests/metafile.c
+++ b/dlls/gdi32/tests/metafile.c
@@ -643,6 +643,11 @@ static void test_SaveDC(void)
todo_wine ok(hFontOld == hFontCheck && hFontCheck != hFont && hFontCheck != hFont2,
"Font not reverted with DC Restore\n");
+ ret = RestoreDC(hdcMetafile, -20);
+ ok(!ret, "ret = %d\n", ret);
+ ret = RestoreDC(hdcMetafile, 20);
+ ok(!ret, "ret = %d\n", ret);
+
hMetafile = CloseEnhMetaFile(hdcMetafile);
ok(hMetafile != 0, "CloseEnhMetaFile error %d\n", GetLastError());
@@ -702,7 +707,7 @@ static void test_mf_SaveDC(void)
SetPixelV(hdcMetafile, 50, 50, 0);
ret = SaveDC(hdcMetafile);
- todo_wine ok(ret == 1, "ret = %d\n", ret);
+ ok(ret == 1, "ret = %d\n", ret);
SetWindowOrgEx(hdcMetafile, -2, -2, NULL);
SetViewportOrgEx(hdcMetafile, 20, 20, NULL);
@@ -715,7 +720,7 @@ static void test_mf_SaveDC(void)
SetBkColor( hdcMetafile, 0 );
ret = SaveDC(hdcMetafile);
- todo_wine ok(ret == 1, "ret = %d\n", ret);
+ ok(ret == 1, "ret = %d\n", ret);
SetWindowOrgEx(hdcMetafile, -3, -3, NULL);
SetViewportOrgEx(hdcMetafile, 30, 30, NULL);
@@ -731,10 +736,10 @@ static void test_mf_SaveDC(void)
SetPixelV(hdcMetafile, 50, 50, 0);
ret = RestoreDC(hdcMetafile, -1);
- ok(ret, "ret = %d\n", ret);
+ todo_wine ok(ret, "ret = %d\n", ret);
ret = SaveDC(hdcMetafile);
- todo_wine ok(ret == 1, "ret = %d\n", ret);
+ ok(ret == 1, "ret = %d\n", ret);
ret = RestoreDC(hdcMetafile, 1);
todo_wine ok(ret, "ret = %d\n", ret);
@@ -748,10 +753,10 @@ static void test_mf_SaveDC(void)
SetPixelV(hdcMetafile, 50, 50, 0);
ret = SaveDC(hdcMetafile);
- todo_wine ok(ret == 1, "ret = %d\n", ret);
+ ok(ret == 1, "ret = %d\n", ret);
ret = SaveDC(hdcMetafile);
- todo_wine ok(ret == 1, "ret = %d\n", ret);
+ ok(ret == 1, "ret = %d\n", ret);
memset(&orig_lf, 0, sizeof(orig_lf));
orig_lf.lfCharSet = ANSI_CHARSET;
@@ -774,10 +779,19 @@ static void test_mf_SaveDC(void)
SetPixelV(hdcMetafile, 50, 50, 0);
ret = RestoreDC(hdcMetafile, 1);
+ todo_wine ok(ret, "ret = %d\n", ret);
hFontCheck = SelectObject(hdcMetafile, hFontOld);
ok(hFontOld != hFontCheck && hFontCheck == hFont2, "Font incorrectly reverted with DC Restore\n");
+ /* restore level is ignored */
+ ret = RestoreDC(hdcMetafile, -20);
+ todo_wine ok(ret, "ret = %d\n", ret);
+ ret = RestoreDC(hdcMetafile, 20);
+ todo_wine ok(ret, "ret = %d\n", ret);
+ ret = RestoreDC(hdcMetafile, 0);
+ todo_wine ok(ret, "ret = %d\n", ret);
+
hMetafile = CloseMetaFile(hdcMetafile);
ok(hMetafile != 0, "CloseEnhMetaFile error %d\n", GetLastError());
More information about the wine-cvs
mailing list