Vincent Povirk : gdiplus: Implement GdipRecordMetafileStream.

Alexandre Julliard julliard at wine.codeweavers.com
Thu Apr 7 11:42:52 CDT 2016


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

Author: Vincent Povirk <vincent at codeweavers.com>
Date:   Wed Apr  6 14:36:58 2016 -0500

gdiplus: Implement GdipRecordMetafileStream.

Signed-off-by: Vincent Povirk <vincent at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/gdiplus/gdiplus_private.h |  1 +
 dlls/gdiplus/graphics.c        |  7 ------
 dlls/gdiplus/image.c           |  4 ++++
 dlls/gdiplus/metafile.c        | 52 ++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 57 insertions(+), 7 deletions(-)

diff --git a/dlls/gdiplus/gdiplus_private.h b/dlls/gdiplus/gdiplus_private.h
index 0013d75..10092f1 100644
--- a/dlls/gdiplus/gdiplus_private.h
+++ b/dlls/gdiplus/gdiplus_private.h
@@ -343,6 +343,7 @@ struct GpMetafile{
     BYTE *comment_data;
     DWORD comment_data_size;
     DWORD comment_data_length;
+    IStream *record_stream;
 
     /* playback */
     GpGraphics *playback_graphics;
diff --git a/dlls/gdiplus/graphics.c b/dlls/gdiplus/graphics.c
index 15c0bed..dac52ef 100644
--- a/dlls/gdiplus/graphics.c
+++ b/dlls/gdiplus/graphics.c
@@ -6436,13 +6436,6 @@ GpStatus WINGDIPAPI GdipDrawDriverString(GpGraphics *graphics, GDIPCONST UINT16
                               brush, positions, flags, matrix);
 }
 
-GpStatus WINGDIPAPI GdipRecordMetafileStream(IStream *stream, HDC hdc, EmfType type, GDIPCONST GpRect *frameRect,
-                                        MetafileFrameUnit frameUnit, GDIPCONST WCHAR *desc, GpMetafile **metafile)
-{
-    FIXME("(%p %p %d %p %d %p %p): stub\n", stream, hdc, type, frameRect, frameUnit, desc, metafile);
-    return NotImplemented;
-}
-
 /*****************************************************************************
  * GdipIsVisibleClipEmpty [GDIPLUS.@]
  */
diff --git a/dlls/gdiplus/image.c b/dlls/gdiplus/image.c
index f803efa..d1a5593 100644
--- a/dlls/gdiplus/image.c
+++ b/dlls/gdiplus/image.c
@@ -2142,6 +2142,10 @@ static GpStatus free_image_data(GpImage *image)
             metafile->record_graphics->image = NULL;
             metafile->record_graphics->busy = TRUE;
         }
+        if (metafile->record_stream)
+        {
+            IStream_Release(metafile->record_stream);
+        }
     }
     else
     {
diff --git a/dlls/gdiplus/metafile.c b/dlls/gdiplus/metafile.c
index 82a7abf..ee16d8e 100644
--- a/dlls/gdiplus/metafile.c
+++ b/dlls/gdiplus/metafile.c
@@ -308,6 +308,27 @@ GpStatus WINGDIPAPI GdipRecordMetafileI(HDC hdc, EmfType type, GDIPCONST GpRect
     return GdipRecordMetafile(hdc, type, pFrameRectF, frameUnit, desc, metafile);
 }
 
+GpStatus WINGDIPAPI GdipRecordMetafileStream(IStream *stream, HDC hdc, EmfType type, GDIPCONST GpRectF *frameRect,
+                                        MetafileFrameUnit frameUnit, GDIPCONST WCHAR *desc, GpMetafile **metafile)
+{
+    GpStatus stat;
+
+    TRACE("(%p %p %d %p %d %p %p)\n", stream, hdc, type, frameRect, frameUnit, desc, metafile);
+
+    if (!stream)
+        return InvalidParameter;
+
+    stat = GdipRecordMetafile(hdc, type, frameRect, frameUnit, desc, metafile);
+
+    if (stat == Ok)
+    {
+        (*metafile)->record_stream = stream;
+        IStream_AddRef(stream);
+    }
+
+    return stat;
+}
+
 GpStatus METAFILE_GetGraphicsContext(GpMetafile* metafile, GpGraphics **result)
 {
     GpStatus stat;
@@ -487,6 +508,37 @@ GpStatus METAFILE_GraphicsDeleted(GpMetafile* metafile)
         }
     }
 
+    if (stat == Ok && metafile->record_stream)
+    {
+        BYTE *buffer;
+        UINT buffer_size;
+
+        buffer_size = GetEnhMetaFileBits(metafile->hemf, 0, NULL);
+
+        buffer = heap_alloc(buffer_size);
+        if (buffer)
+        {
+            HRESULT hr;
+
+            GetEnhMetaFileBits(metafile->hemf, buffer_size, buffer);
+
+            hr = IStream_Write(metafile->record_stream, buffer, buffer_size, NULL);
+
+            if (FAILED(hr))
+                stat = hresult_to_status(hr);
+
+            heap_free(buffer);
+        }
+        else
+            stat = OutOfMemory;
+    }
+
+    if (metafile->record_stream)
+    {
+        IStream_Release(metafile->record_stream);
+        metafile->record_stream = NULL;
+    }
+
     return stat;
 }
 




More information about the wine-cvs mailing list