Author: cwittich
Date: Wed Jul 6 06:20:36 2016
New Revision: 71831
URL:
http://svn.reactos.org/svn/reactos?rev=71831&view=rev
Log:
[GDI32]
reduce diff to wine (metafile)
Modified:
trunk/reactos/win32ss/gdi/gdi32/wine/enhmetafile.c
trunk/reactos/win32ss/gdi/gdi32/wine/gdi_private.h
trunk/reactos/win32ss/gdi/gdi32/wine/metafile.c
trunk/reactos/win32ss/reactx/ntddraw/ddraw.c
Modified: trunk/reactos/win32ss/gdi/gdi32/wine/enhmetafile.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/gdi/gdi32/wine/enh…
==============================================================================
--- trunk/reactos/win32ss/gdi/gdi32/wine/enhmetafile.c [iso-8859-1] (original)
+++ trunk/reactos/win32ss/gdi/gdi32/wine/enhmetafile.c [iso-8859-1] Wed Jul 6 06:20:36
2016
@@ -2182,20 +2182,20 @@
case EMR_POLYDRAW16:
case EMR_GLSRECORD:
case EMR_GLSBOUNDEDRECORD:
- case EMR_DRAWESCAPE :
- case EMR_EXTESCAPE:
- case EMR_STARTDOC:
- case EMR_SMALLTEXTOUT:
- case EMR_FORCEUFIMAPPING:
- case EMR_NAMEDESCAPE:
- case EMR_COLORCORRECTPALETTE:
- case EMR_SETICMPROFILEA:
- case EMR_SETICMPROFILEW:
- case EMR_TRANSPARENTBLT:
- case EMR_GRADIENTFILL:
- case EMR_SETLINKEDUFI:
- case EMR_COLORMATCHTOTARGETW:
- case EMR_CREATECOLORSPACEW:
+ case EMR_DRAWESCAPE:
+ case EMR_EXTESCAPE:
+ case EMR_STARTDOC:
+ case EMR_SMALLTEXTOUT:
+ case EMR_FORCEUFIMAPPING:
+ case EMR_NAMEDESCAPE:
+ case EMR_COLORCORRECTPALETTE:
+ case EMR_SETICMPROFILEA:
+ case EMR_SETICMPROFILEW:
+ case EMR_TRANSPARENTBLT:
+ case EMR_GRADIENTFILL:
+ case EMR_SETLINKEDUFI:
+ case EMR_COLORMATCHTOTARGETW:
+ case EMR_CREATECOLORSPACEW:
default:
/* From docs: If PlayEnhMetaFileRecord doesn't recognize a
@@ -2679,7 +2679,60 @@
return infoForCallBack.cEntries;
}
-typedef struct gdi_mf_comment
+/******************************************************************
+ * extract_emf_from_comment
+ *
+ * If the WMF was created by GetWinMetaFileBits, then extract the
+ * original EMF that is stored in MFCOMMENT chunks.
+ */
+static HENHMETAFILE extract_emf_from_comment( const BYTE *buf, UINT mf_size )
+{
+ METAHEADER *mh = (METAHEADER *)buf;
+ METARECORD *mr;
+ emf_in_wmf_comment *chunk;
+ WORD checksum = 0;
+ DWORD size = 0, remaining, chunks;
+ BYTE *emf_bits = NULL, *ptr;
+ UINT offset;
+ HENHMETAFILE emf = NULL;
+
+ if (mf_size < sizeof(*mh)) return NULL;
+
+ for (offset = mh->mtHeaderSize * 2; offset < mf_size; offset += (mr->rdSize
* 2))
+ {
+ mr = (METARECORD *)((char *)mh + offset);
+ chunk = (emf_in_wmf_comment *)(mr->rdParm + 2);
+
+ if (mr->rdFunction != META_ESCAPE || mr->rdParm[0] != MFCOMMENT) goto
done;
+ if (chunk->magic != WMFC_MAGIC) goto done;
+
+ if (!emf_bits)
+ {
+ size = remaining = chunk->emf_size;
+ chunks = chunk->num_chunks;
+ emf_bits = ptr = HeapAlloc( GetProcessHeap(), 0, size );
+ if (!emf_bits) goto done;
+ }
+ if (chunk->chunk_size > remaining) goto done;
+ remaining -= chunk->chunk_size;
+ if (chunk->remaining_size != remaining) goto done;
+ memcpy( ptr, chunk->emf_data, chunk->chunk_size );
+ ptr += chunk->chunk_size;
+ if (--chunks == 0) break;
+ }
+
+ for (offset = 0; offset < mf_size / 2; offset++)
+ checksum += *((WORD *)buf + offset);
+ if (checksum) goto done;
+
+ emf = SetEnhMetaFileBits( size, emf_bits );
+
+done:
+ HeapFree( GetProcessHeap(), 0, emf_bits );
+ return emf;
+}
+
+typedef struct wmf_in_emf_comment
{
DWORD ident;
DWORD iComment;
@@ -2687,7 +2740,7 @@
DWORD nChecksum;
DWORD fFlags;
DWORD cbWinMetaFile;
-} gdi_mf_comment;
+} wmf_in_emf_comment;
/******************************************************************
* SetWinMetaFileBits (GDI32.@)
@@ -2714,6 +2767,9 @@
WARN("SetMetaFileBitsEx failed\n");
return NULL;
}
+
+ ret = extract_emf_from_comment( lpbBuffer, cbBuffer );
+ if (ret) return ret;
if(!hdcRef)
hdcRef = hdcdisp = CreateDCW(szDisplayW, NULL, NULL, NULL);
@@ -2767,10 +2823,10 @@
*/
if (mm != MM_TEXT)
{
- gdi_mf_comment *mfcomment;
+ wmf_in_emf_comment *mfcomment;
UINT mfcomment_size;
- mfcomment_size = sizeof (gdi_mf_comment) + cbBuffer;
+ mfcomment_size = sizeof (*mfcomment) + cbBuffer;
mfcomment = HeapAlloc(GetProcessHeap(), 0, mfcomment_size);
if (mfcomment)
{
Modified: trunk/reactos/win32ss/gdi/gdi32/wine/gdi_private.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/gdi/gdi32/wine/gdi…
==============================================================================
--- trunk/reactos/win32ss/gdi/gdi32/wine/gdi_private.h [iso-8859-1] (original)
+++ trunk/reactos/win32ss/gdi/gdi32/wine/gdi_private.h [iso-8859-1] Wed Jul 6 06:20:36
2016
@@ -93,6 +93,26 @@
extern HMETAFILE MF_Create_HMETAFILE(METAHEADER *mh) DECLSPEC_HIDDEN;
extern METAHEADER *MF_CreateMetaHeaderDisk(METAHEADER *mr, LPCVOID filename, BOOL unicode
) DECLSPEC_HIDDEN;
+/* Format of comment record added by GetWinMetaFileBits */
+#include <pshpack2.h>
+typedef struct
+{
+ DWORD magic; /* WMFC */
+ WORD unk04; /* 1 */
+ WORD unk06; /* 0 */
+ WORD unk08; /* 0 */
+ WORD unk0a; /* 1 */
+ WORD checksum;
+ DWORD unk0e; /* 0 */
+ DWORD num_chunks;
+ DWORD chunk_size;
+ DWORD remaining_size;
+ DWORD emf_size;
+ BYTE emf_data[1];
+} emf_in_wmf_comment;
+#include <poppack.h>
+
+#define WMFC_MAGIC 0x43464d57
/* palette.c */
extern HPALETTE WINAPI GDISelectPalette( HDC hdc, HPALETTE hpal, WORD wBkg)
DECLSPEC_HIDDEN;
extern UINT WINAPI GDIRealizePalette( HDC hdc ) DECLSPEC_HIDDEN;
Modified: trunk/reactos/win32ss/gdi/gdi32/wine/metafile.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/gdi/gdi32/wine/met…
==============================================================================
--- trunk/reactos/win32ss/gdi/gdi32/wine/metafile.c [iso-8859-1] (original)
+++ trunk/reactos/win32ss/gdi/gdi32/wine/metafile.c [iso-8859-1] Wed Jul 6 06:20:36 2016
@@ -1115,26 +1115,6 @@
return mfSize;
}
-#include <pshpack2.h>
-typedef struct
-{
- DWORD magic; /* WMFC */
- WORD unk04; /* 1 */
- WORD unk06; /* 0 */
- WORD unk08; /* 0 */
- WORD unk0a; /* 1 */
- WORD checksum;
- DWORD unk0e; /* 0 */
- DWORD num_chunks;
- DWORD chunk_size;
- DWORD remaining_size;
- DWORD emf_size;
- BYTE *emf_data;
-} mf_comment_chunk;
-#include <poppack.h>
-
-static const DWORD wmfc_magic = 0x43464d57;
-
/******************************************************************
* add_mf_comment
*
@@ -1147,7 +1127,7 @@
{
DWORD size = GetEnhMetaFileBits(emf, 0, NULL), i;
BYTE *bits, *chunk_data;
- mf_comment_chunk *chunk = NULL;
+ emf_in_wmf_comment *chunk = NULL;
BOOL ret = FALSE;
static const DWORD max_chunk_size = 0x2000;
@@ -1156,10 +1136,10 @@
if(!bits) return FALSE;
if(!GetEnhMetaFileBits(emf, size, bits)) goto end;
- chunk = HeapAlloc(GetProcessHeap(), 0, max_chunk_size +
FIELD_OFFSET(mf_comment_chunk, emf_data));
+ chunk = HeapAlloc(GetProcessHeap(), 0, FIELD_OFFSET(emf_in_wmf_comment,
emf_data[max_chunk_size]));
if(!chunk) goto end;
- chunk->magic = wmfc_magic;
+ chunk->magic = WMFC_MAGIC;
chunk->unk04 = 1;
chunk->unk06 = 0;
chunk->unk08 = 0;
@@ -1177,10 +1157,10 @@
chunk->chunk_size = chunk->remaining_size;
chunk->remaining_size -= chunk->chunk_size;
- memcpy(&chunk->emf_data, chunk_data, chunk->chunk_size);
+ memcpy(chunk->emf_data, chunk_data, chunk->chunk_size);
chunk_data += chunk->chunk_size;
- if(!Escape(hdc, MFCOMMENT, chunk->chunk_size + FIELD_OFFSET(mf_comment_chunk,
emf_data), (char*)chunk, NULL))
+ if(!Escape(hdc, MFCOMMENT, FIELD_OFFSET(emf_in_wmf_comment,
emf_data[chunk->chunk_size]), (char*)chunk, NULL))
goto end;
}
ret = TRUE;
Modified: trunk/reactos/win32ss/reactx/ntddraw/ddraw.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/reactx/ntddraw/ddr…
==============================================================================
--- trunk/reactos/win32ss/reactx/ntddraw/ddraw.c [iso-8859-1] (original)
+++ trunk/reactos/win32ss/reactx/ntddraw/ddraw.c [iso-8859-1] Wed Jul 6 06:20:36 2016
@@ -65,7 +65,7 @@
if ( ( pDev->DriverFunctions.DisableDirectDraw == NULL) ||
( pDev->DriverFunctions.EnableDirectDraw == NULL))
{
- DPRINT1("Waring : DisableDirectDraw and EnableDirectDraw are NULL, no dx
driver \n");
+ DPRINT1("Warning : DisableDirectDraw and EnableDirectDraw are NULL, no dx
driver \n");
}
else
{