Removed enhmetafile.h. Simplified ENHMETAFILEOBJ structure a bit.

This commit is contained in:
Alexandre Julliard 2001-07-24 22:15:47 +00:00
parent 5f728cae70
commit e6c0642e79
4 changed files with 35 additions and 54 deletions

View File

@ -10,7 +10,6 @@
#include "wingdi.h"
#include "gdi.h"
#include "heap.h"
#include "enhmetafile.h"
#include "enhmetafiledrv.h"
#include "debugtools.h"
@ -378,13 +377,17 @@ HENHMETAFILE WINAPI CloseEnhMetaFile(HDC hdc) /* [in] metafile DC */
if (physDev->hFile) /* disk based metafile */
{
if (SetFilePointer(physDev->hFile, 0, NULL, FILE_BEGIN) != 0) {
if (SetFilePointer(physDev->hFile, 0, NULL, FILE_BEGIN) != 0)
{
CloseHandle( physDev->hFile );
EMFDRV_DeleteDC( dc );
return 0;
}
if (!WriteFile(physDev->hFile, (LPSTR)physDev->emh,
sizeof(*physDev->emh), NULL, NULL)) {
sizeof(*physDev->emh), NULL, NULL))
{
CloseHandle( physDev->hFile );
EMFDRV_DeleteDC( dc );
return 0;
}
@ -394,13 +397,12 @@ HENHMETAFILE WINAPI CloseEnhMetaFile(HDC hdc) /* [in] metafile DC */
TRACE("hMapping = %08x\n", hMapping );
physDev->emh = MapViewOfFile(hMapping, FILE_MAP_READ, 0, 0, 0);
TRACE("view = %p\n", physDev->emh );
CloseHandle( hMapping );
CloseHandle( physDev->hFile );
}
hmf = EMF_Create_HENHMETAFILE( physDev->emh, physDev->hFile, hMapping );
hmf = EMF_Create_HENHMETAFILE( physDev->emh, (physDev->hFile != 0) );
physDev->emh = NULL; /* So it won't be deleted */
EMFDRV_DeleteDC( dc );
return hmf;
}

View File

@ -1,28 +0,0 @@
/*
* Enhanced Metafile definitions
*
*/
#ifndef __WINE_ENHMETAFILE_H
#define __WINE_ENHMETAFILE_H
#include "gdi.h"
#include "windef.h"
#include "wingdi.h"
/* GDI32 enhanced metafile object */
typedef struct
{
GDIOBJHDR header;
ENHMETAHEADER *emh;
HFILE hFile; /* File handle if EMF is disk-based */
HANDLE hMapping; /* Mapping handle if EMF is disk-based */
} ENHMETAFILEOBJ;
extern HENHMETAFILE EMF_Create_HENHMETAFILE(ENHMETAHEADER *emh, HFILE hFile,
HANDLE hMapping);
#endif /* __WINE_ENHMETAFILE_H */

View File

@ -589,4 +589,7 @@ INT CLIPPING_IntersectVisRect( DC * dc, INT left, INT top,
INT right, INT bottom, BOOL exclude );
extern void CLIPPING_UpdateGCRegion( DC * dc );
/* objects/enhmetafile.c */
extern HENHMETAFILE EMF_Create_HENHMETAFILE(ENHMETAHEADER *emh, BOOL on_disk );
#endif /* __WINE_GDI_H */

View File

@ -22,18 +22,23 @@
#include "winbase.h"
#include "wingdi.h"
#include "winerror.h"
#include "enhmetafile.h"
#include "debugtools.h"
#include "heap.h"
#include "metafile.h"
DEFAULT_DEBUG_CHANNEL(enhmetafile);
typedef struct
{
GDIOBJHDR header;
ENHMETAHEADER *emh;
BOOL on_disk; /* true if metafile is on disk */
} ENHMETAFILEOBJ;
/****************************************************************************
* EMF_Create_HENHMETAFILE
*/
HENHMETAFILE EMF_Create_HENHMETAFILE(ENHMETAHEADER *emh, HFILE hFile, HANDLE
hMapping )
HENHMETAFILE EMF_Create_HENHMETAFILE(ENHMETAHEADER *emh, BOOL on_disk )
{
HENHMETAFILE hmf = 0;
ENHMETAFILEOBJ *metaObj = GDI_AllocObject( sizeof(ENHMETAFILEOBJ),
@ -41,8 +46,7 @@ HENHMETAFILE EMF_Create_HENHMETAFILE(ENHMETAHEADER *emh, HFILE hFile, HANDLE
if (metaObj)
{
metaObj->emh = emh;
metaObj->hFile = hFile;
metaObj->hMapping = hMapping;
metaObj->on_disk = on_disk;
GDI_ReleaseObj( hmf );
}
return hmf;
@ -56,11 +60,10 @@ static BOOL EMF_Delete_HENHMETAFILE( HENHMETAFILE hmf )
ENHMETAFILEOBJ *metaObj = (ENHMETAFILEOBJ *)GDI_GetObjPtr( hmf,
ENHMETAFILE_MAGIC );
if(!metaObj) return FALSE;
if(metaObj->hMapping) {
if(metaObj->on_disk)
UnmapViewOfFile( metaObj->emh );
CloseHandle( metaObj->hMapping );
CloseHandle( metaObj->hFile );
} else
else
HeapFree( GetProcessHeap(), 0, metaObj->emh );
return GDI_FreeObject( hmf, metaObj );
}
@ -100,15 +103,17 @@ static HENHMETAFILE EMF_GetEnhMetaFile( HANDLE hFile )
hMapping = CreateFileMappingA( hFile, NULL, PAGE_READONLY, 0, 0, NULL );
emh = MapViewOfFile( hMapping, FILE_MAP_READ, 0, 0, 0 );
CloseHandle( hMapping );
if (!emh) return 0;
if (emh->iType != EMR_HEADER || emh->dSignature != ENHMETA_SIGNATURE) {
WARN("Invalid emf header type 0x%08lx sig 0x%08lx.\n",
emh->iType, emh->dSignature);
UnmapViewOfFile( emh );
CloseHandle( hMapping );
return 0;
}
return EMF_Create_HENHMETAFILE( emh, hFile, hMapping );
return EMF_Create_HENHMETAFILE( emh, TRUE );
}
@ -131,7 +136,6 @@ HENHMETAFILE WINAPI GetEnhMetaFileA(
return 0;
}
hmf = EMF_GetEnhMetaFile( hFile );
if(!hmf)
CloseHandle( hFile );
return hmf;
}
@ -152,7 +156,6 @@ HENHMETAFILE WINAPI GetEnhMetaFileW(
return 0;
}
hmf = EMF_GetEnhMetaFile( hFile );
if(!hmf)
CloseHandle( hFile );
return hmf;
}
@ -261,7 +264,7 @@ HENHMETAFILE WINAPI SetEnhMetaFileBits(UINT bufsize, const BYTE *buf)
{
ENHMETAHEADER *emh = HeapAlloc( GetProcessHeap(), 0, bufsize );
memmove(emh, buf, bufsize);
return EMF_Create_HENHMETAFILE( emh, 0, 0 );
return EMF_Create_HENHMETAFILE( emh, FALSE );
}
/*****************************************************************************
@ -1701,13 +1704,14 @@ HENHMETAFILE WINAPI CopyEnhMetaFileA(
if (!file) {
emrDst = HeapAlloc( GetProcessHeap(), 0, emrSrc->nBytes );
memcpy( emrDst, emrSrc, emrSrc->nBytes );
hmfDst = EMF_Create_HENHMETAFILE( emrDst, 0, 0 );
hmfDst = EMF_Create_HENHMETAFILE( emrDst, FALSE );
} else {
HANDLE hFile;
hFile = CreateFileA( file, GENERIC_WRITE | GENERIC_READ, 0, NULL,
CREATE_ALWAYS, 0, 0);
WriteFile( hFile, emrSrc, emrSrc->nBytes, 0, 0);
hmfDst = EMF_GetEnhMetaFile( hFile );
CloseHandle( hFile );
}
EMF_ReleaseEnhMetaHeader( hmfSrc );
return hmfDst;