Vincent Povirk : gdiplus: Add test for metafile enumeration.

Alexandre Julliard julliard at winehq.org
Mon May 23 13:24:56 CDT 2011


Module: wine
Branch: master
Commit: 11248262be5af8478e68430e0260450e4312ba83
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=11248262be5af8478e68430e0260450e4312ba83

Author: Vincent Povirk <vincent at codeweavers.com>
Date:   Sat May 21 17:22:12 2011 -0500

gdiplus: Add test for metafile enumeration.

---

 dlls/gdiplus/gdiplus.spec     |    2 +-
 dlls/gdiplus/metafile.c       |   19 +++++++++++++
 dlls/gdiplus/tests/metafile.c |   60 ++++++++++++++++++++++++++++++++++++++++-
 include/gdiplus.h             |    4 +-
 include/gdiplusflat.h         |    3 ++
 include/gdiplustypes.h        |    2 +
 6 files changed, 86 insertions(+), 4 deletions(-)

diff --git a/dlls/gdiplus/gdiplus.spec b/dlls/gdiplus/gdiplus.spec
index c583996..533bf0f 100644
--- a/dlls/gdiplus/gdiplus.spec
+++ b/dlls/gdiplus/gdiplus.spec
@@ -198,7 +198,7 @@
 198 stub GdipEnumerateMetafileDestRectI
 199 stub GdipEnumerateMetafileSrcRectDestPoint
 200 stub GdipEnumerateMetafileSrcRectDestPointI
-201 stub GdipEnumerateMetafileSrcRectDestPoints
+201 stdcall GdipEnumerateMetafileSrcRectDestPoints(ptr ptr ptr long ptr long ptr ptr ptr)
 202 stub GdipEnumerateMetafileSrcRectDestPointsI
 203 stub GdipEnumerateMetafileSrcRectDestRect
 204 stub GdipEnumerateMetafileSrcRectDestRectI
diff --git a/dlls/gdiplus/metafile.c b/dlls/gdiplus/metafile.c
index 99b1621..665d1a3 100644
--- a/dlls/gdiplus/metafile.c
+++ b/dlls/gdiplus/metafile.c
@@ -322,3 +322,22 @@ GpStatus WINGDIPAPI GdipGetHemfFromMetafile(GpMetafile *metafile, HENHMETAFILE *
 
     return Ok;
 }
+
+GpStatus WINGDIPAPI GdipEnumerateMetafileSrcRectDestPoints(GpGraphics *graphics,
+    GDIPCONST GpMetafile *metafile, GDIPCONST GpPointF *destPoints, INT count,
+    GDIPCONST GpRectF *srcRect, Unit srcUnit, EnumerateMetafileProc callback,
+    VOID *callbackData, GDIPCONST GpImageAttributes *imageAttributes)
+{
+    FIXME("(%p,%p,%p,%i,%p,%i,%p,%p,%p): stub\n", graphics, metafile,
+        destPoints, count, srcRect, srcUnit, callback, callbackData,
+        imageAttributes);
+
+    if (!graphics || !metafile || !destPoints || count != 3 || !srcRect)
+        return InvalidParameter;
+
+    TRACE("%s %i -> %s %s %s\n", debugstr_rectf(srcRect), srcUnit,
+        debugstr_pointf(&destPoints[0]), debugstr_pointf(&destPoints[1]),
+        debugstr_pointf(&destPoints[2]));
+
+    return NotImplemented;
+}
diff --git a/dlls/gdiplus/tests/metafile.c b/dlls/gdiplus/tests/metafile.c
index 8dcda25..8b13c20 100644
--- a/dlls/gdiplus/tests/metafile.c
+++ b/dlls/gdiplus/tests/metafile.c
@@ -140,6 +140,61 @@ static void check_emfplus(HENHMETAFILE hemf, const emfplus_record *expected, con
     ok(expected[state.count].record_type == 0, "%s: Got %i records, expecting more\n", desc, state.count);
 }
 
+static BOOL CALLBACK enum_metafile_proc(EmfPlusRecordType record_type, unsigned int flags,
+    unsigned int dataSize, const unsigned char *pStr, void *userdata)
+{
+    emfplus_check_state *state = (emfplus_check_state*)userdata;
+    emfplus_record actual;
+
+    actual.todo = 0;
+    actual.record_type = record_type;
+    actual.is_emfplus = ((record_type & GDIP_EMFPLUS_RECORD_BASE) == GDIP_EMFPLUS_RECORD_BASE);
+
+    if (dataSize == 0)
+        ok(pStr == NULL, "non-NULL pStr\n");
+
+    if (state->expected[state->count].record_type)
+    {
+        check_record(state->count, state->desc, &state->expected[state->count], &actual);
+
+        state->count++;
+    }
+    else
+    {
+        ok(0, "%s: Unexpected EMF 0x%x record\n", state->desc, record_type);
+    }
+
+    return TRUE;
+}
+
+static void check_metafile(GpMetafile *metafile, const emfplus_record *expected, const char *desc,
+    const GpPointF *dst_points, const GpRectF *src_rect, Unit src_unit)
+{
+    GpStatus stat;
+    HDC hdc;
+    GpGraphics *graphics;
+    emfplus_check_state state;
+
+    state.desc = desc;
+    state.count = 0;
+    state.expected = expected;
+
+    hdc = CreateCompatibleDC(0);
+
+    stat = GdipCreateFromHDC(hdc, &graphics);
+    expect(Ok, stat);
+
+    stat = GdipEnumerateMetafileSrcRectDestPoints(graphics, metafile, dst_points,
+        3, src_rect, src_unit, enum_metafile_proc, &state, NULL);
+    todo_wine expect(Ok, stat);
+
+    todo_wine ok(expected[state.count].record_type == 0, "%s: Got %i records, expecting more\n", desc, state.count);
+
+    GdipDeleteGraphics(graphics);
+
+    DeleteDC(hdc);
+}
+
 static const emfplus_record empty_records[] = {
     {0, EMR_HEADER, 0},
     {0, EmfPlusRecordTypeHeader, 1},
@@ -157,6 +212,7 @@ static void test_empty(void)
     HENHMETAFILE hemf, dummy;
     BOOL ret;
     static const GpRectF frame = {0.0, 0.0, 100.0, 100.0};
+    static const GpPointF dst_points[3] = {{0.0,0.0},{100.0,0.0},{0.0,100.0}};
     static const WCHAR description[] = {'w','i','n','e','t','e','s','t',0};
 
     hdc = CreateCompatibleDC(0);
@@ -199,6 +255,8 @@ static void test_empty(void)
     stat = GdipDeleteGraphics(graphics);
     expect(Ok, stat);
 
+    check_metafile(metafile, empty_records, "empty metafile", dst_points, &frame, UnitPixel);
+
     stat = GdipGetHemfFromMetafile(metafile, &hemf);
     expect(Ok, stat);
 
@@ -208,7 +266,7 @@ static void test_empty(void)
     stat = GdipDisposeImage((GpImage*)metafile);
     expect(Ok, stat);
 
-    check_emfplus(hemf, empty_records, "empty");
+    check_emfplus(hemf, empty_records, "empty emf");
 
     ret = DeleteEnhMetaFile(hemf);
     ok(ret != 0, "Failed to delete enhmetafile %p\n", hemf);
diff --git a/include/gdiplus.h b/include/gdiplus.h
index c8385db..f063b3e 100644
--- a/include/gdiplus.h
+++ b/include/gdiplus.h
@@ -28,8 +28,8 @@ namespace Gdiplus
 #include "gdiplusmem.h"
     };
 
-#include "gdiplustypes.h"
 #include "gdiplusenums.h"
+#include "gdiplustypes.h"
 #include "gdiplusinit.h"
 #include "gdipluspixelformats.h"
 #include "gdiplusmetaheader.h"
@@ -48,8 +48,8 @@ namespace Gdiplus
 
 #include "gdiplusmem.h"
 
-#include "gdiplustypes.h"
 #include "gdiplusenums.h"
+#include "gdiplustypes.h"
 #include "gdiplusinit.h"
 #include "gdipluspixelformats.h"
 #include "gdiplusmetaheader.h"
diff --git a/include/gdiplusflat.h b/include/gdiplusflat.h
index b35048f..676a78e 100644
--- a/include/gdiplusflat.h
+++ b/include/gdiplusflat.h
@@ -206,6 +206,9 @@ GpStatus WINGDIPAPI GdipDrawRectanglesI(GpGraphics*,GpPen*,GDIPCONST GpRect*,INT
 GpStatus WINGDIPAPI GdipDrawString(GpGraphics*,GDIPCONST WCHAR*,INT,
     GDIPCONST GpFont*,GDIPCONST RectF*, GDIPCONST GpStringFormat*,
     GDIPCONST GpBrush*);
+GpStatus WINGDIPAPI GdipEnumerateMetafileSrcRectDestPoints(GpGraphics*,
+    GDIPCONST GpMetafile*,GDIPCONST GpPointF*,INT,GDIPCONST GpRectF*,Unit,
+    EnumerateMetafileProc,VOID*,GDIPCONST GpImageAttributes*);
 GpStatus WINGDIPAPI GdipFillClosedCurve2(GpGraphics*,GpBrush*,GDIPCONST GpPointF*,INT,
     REAL,GpFillMode);
 GpStatus WINGDIPAPI GdipFillClosedCurve2I(GpGraphics*,GpBrush*,GDIPCONST GpPoint*,INT,
diff --git a/include/gdiplustypes.h b/include/gdiplustypes.h
index 816dba8..2e46bb4 100644
--- a/include/gdiplustypes.h
+++ b/include/gdiplustypes.h
@@ -55,6 +55,8 @@ typedef BOOL (CALLBACK * ImageAbort)(VOID *);
 typedef ImageAbort DrawImageAbort;
 typedef ImageAbort GetThumbnailImageAbort;
 
+typedef BOOL (CALLBACK * EnumerateMetafileProc)(EmfPlusRecordType,UINT,UINT,const BYTE*,VOID*);
+
 #ifdef __cplusplus
 }
 #endif




More information about the wine-cvs mailing list