Commit f9ebe5ab authored by Alexandre Julliard's avatar Alexandre Julliard

gdi32: Don't store a DC pointer in the metafile devices.

parent 0a134e9e
......@@ -34,6 +34,7 @@ INT EMFDRV_SaveDC( PHYSDEV dev )
BOOL EMFDRV_RestoreDC( PHYSDEV dev, INT level )
{
EMFDRV_PDEVICE* physDev = (EMFDRV_PDEVICE*)dev;
DC *dc = get_dc_ptr( physDev->hdc );
EMRRESTOREDC emr;
emr.emr.iType = EMR_RESTOREDC;
......@@ -42,10 +43,11 @@ BOOL EMFDRV_RestoreDC( PHYSDEV dev, INT level )
if (level < 0)
emr.iRelative = level;
else
emr.iRelative = level - physDev->dc->saveLevel - 1;
emr.iRelative = level - dc->saveLevel - 1;
EMFDRV_WriteRecord( dev, &emr.emr );
release_dc_ptr( dc );
return TRUE;
}
......
......@@ -33,7 +33,6 @@
typedef struct
{
HDC hdc;
DC *dc;
ENHMETAHEADER *emh; /* Pointer to enhanced metafile header */
UINT handles_size, cur_handles;
HGDIOBJ *handles;
......
......@@ -159,10 +159,9 @@ static const DC_FUNCTIONS EMFDRV_Funcs =
/**********************************************************************
* EMFDRV_DeleteDC
*/
static BOOL EMFDRV_DeleteDC( PHYSDEV dev )
static BOOL EMFDRV_DeleteDC( DC *dc )
{
EMFDRV_PDEVICE *physDev = (EMFDRV_PDEVICE *)dev;
DC *dc = physDev->dc;
EMFDRV_PDEVICE *physDev = (EMFDRV_PDEVICE *)dc->physDev;
UINT index;
if (physDev->emh) HeapFree( GetProcessHeap(), 0, physDev->emh );
......@@ -324,7 +323,6 @@ HDC WINAPI CreateEnhMetaFileW(
}
dc->physDev = (PHYSDEV)physDev;
physDev->hdc = dc->hSelf;
physDev->dc = dc;
if(description) { /* App name\0Title\0\0 */
length = lstrlenW(description);
......@@ -405,11 +403,11 @@ HDC WINAPI CreateEnhMetaFileW(
{
if ((hFile = CreateFileW(filename, GENERIC_WRITE | GENERIC_READ, 0,
NULL, CREATE_ALWAYS, 0, 0)) == INVALID_HANDLE_VALUE) {
EMFDRV_DeleteDC( dc->physDev );
EMFDRV_DeleteDC( dc );
return 0;
}
if (!WriteFile( hFile, (LPSTR)physDev->emh, size, NULL, NULL )) {
EMFDRV_DeleteDC( dc->physDev );
EMFDRV_DeleteDC( dc );
return 0;
}
physDev->hFile = hFile;
......@@ -479,7 +477,7 @@ HENHMETAFILE WINAPI CloseEnhMetaFile(HDC hdc) /* [in] metafile DC */
if (SetFilePointer(physDev->hFile, 0, NULL, FILE_BEGIN) != 0)
{
CloseHandle( physDev->hFile );
EMFDRV_DeleteDC( dc->physDev );
EMFDRV_DeleteDC( dc );
return 0;
}
......@@ -487,7 +485,7 @@ HENHMETAFILE WINAPI CloseEnhMetaFile(HDC hdc) /* [in] metafile DC */
sizeof(*physDev->emh), NULL, NULL))
{
CloseHandle( physDev->hFile );
EMFDRV_DeleteDC( dc->physDev );
EMFDRV_DeleteDC( dc );
return 0;
}
HeapFree( GetProcessHeap(), 0, physDev->emh );
......@@ -502,6 +500,6 @@ HENHMETAFILE WINAPI CloseEnhMetaFile(HDC hdc) /* [in] metafile DC */
hmf = EMF_Create_HENHMETAFILE( physDev->emh, (physDev->hFile != 0) );
physDev->emh = NULL; /* So it won't be deleted */
EMFDRV_DeleteDC( dc->physDev );
EMFDRV_DeleteDC( dc );
return hmf;
}
......@@ -175,7 +175,6 @@ static DC *MFDRV_AllocMetaFile(void)
}
dc->physDev = (PHYSDEV)physDev;
physDev->hdc = dc->hSelf;
physDev->dc = dc;
if (!(physDev->mh = HeapAlloc( GetProcessHeap(), 0, sizeof(*physDev->mh) )))
{
......@@ -204,10 +203,9 @@ static DC *MFDRV_AllocMetaFile(void)
/**********************************************************************
* MFDRV_DeleteDC
*/
static BOOL MFDRV_DeleteDC( PHYSDEV dev )
static BOOL MFDRV_DeleteDC( DC *dc )
{
METAFILEDRV_PDEVICE *physDev = (METAFILEDRV_PDEVICE *)dev;
DC *dc = physDev->dc;
METAFILEDRV_PDEVICE *physDev = (METAFILEDRV_PDEVICE *)dc->physDev;
DWORD index;
HeapFree( GetProcessHeap(), 0, physDev->mh );
......@@ -251,12 +249,12 @@ HDC WINAPI CreateMetaFileW( LPCWSTR filename )
physDev->mh->mtType = METAFILE_DISK;
if ((hFile = CreateFileW(filename, GENERIC_WRITE, 0, NULL,
CREATE_ALWAYS, 0, 0)) == INVALID_HANDLE_VALUE) {
MFDRV_DeleteDC( dc->physDev );
MFDRV_DeleteDC( dc );
return 0;
}
if (!WriteFile( hFile, physDev->mh, sizeof(*physDev->mh), NULL,
NULL )) {
MFDRV_DeleteDC( dc->physDev );
MFDRV_DeleteDC( dc );
return 0;
}
physDev->hFile = hFile;
......@@ -328,21 +326,21 @@ static DC *MFDRV_CloseMetaFile( HDC hdc )
if (!MFDRV_MetaParam0(dc->physDev, META_EOF))
{
MFDRV_DeleteDC( dc->physDev );
MFDRV_DeleteDC( dc );
return 0;
}
if (physDev->mh->mtType == METAFILE_DISK) /* disk based metafile */
{
if (SetFilePointer(physDev->hFile, 0, NULL, FILE_BEGIN) != 0) {
MFDRV_DeleteDC( dc->physDev );
MFDRV_DeleteDC( dc );
return 0;
}
physDev->mh->mtType = METAFILE_MEMORY; /* This is what windows does */
if (!WriteFile(physDev->hFile, (LPSTR)physDev->mh,
sizeof(*physDev->mh), NULL, NULL)) {
MFDRV_DeleteDC( dc->physDev );
MFDRV_DeleteDC( dc );
return 0;
}
CloseHandle(physDev->hFile);
......@@ -394,7 +392,7 @@ HMETAFILE16 WINAPI CloseMetaFile16(HDC16 hdc)
hmf = MF_Create_HMETAFILE16( physDev->mh );
physDev->mh = NULL; /* So it won't be deleted */
MFDRV_DeleteDC( dc->physDev );
MFDRV_DeleteDC( dc );
return hmf;
}
......@@ -423,7 +421,7 @@ HMETAFILE WINAPI CloseMetaFile(HDC hdc)
hmf = MF_Create_HMETAFILE( physDev->mh );
physDev->mh = NULL; /* So it won't be deleted */
MFDRV_DeleteDC( dc->physDev );
MFDRV_DeleteDC( dc );
return hmf;
}
......
......@@ -33,7 +33,6 @@
typedef struct
{
HDC hdc;
DC *dc;
METAHEADER *mh; /* Pointer to metafile header */
UINT handles_size, cur_handles;
HGDIOBJ *handles;
......
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