gdi32: Completely implement SaveDC in the driver, having it call save_dc_state if necessary.

This commit is contained in:
Alexandre Julliard 2009-04-07 20:32:58 +02:00
parent d4c54be272
commit bbb1626bf8
3 changed files with 33 additions and 18 deletions

View File

@ -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 );
release_dc_ptr( dc );
return ret;
}

View File

@ -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;
if (ret)
{
emr.emr.iType = EMR_SAVEDC;
emr.emr.nSize = sizeof(emr);
return EMFDRV_WriteRecord( dev, &emr.emr );
EMFDRV_WriteRecord( dev, &emr.emr );
}
return ret;
}
BOOL CDECL EMFDRV_RestoreDC( PHYSDEV dev, INT level )

View File

@ -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());