Piotr Caban : gdiplus: Don't use CoCreateInstance in decode_image_wic.

Alexandre Julliard julliard at wine.codeweavers.com
Fri Mar 6 06:27:28 CST 2015


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

Author: Piotr Caban <piotr at codeweavers.com>
Date:   Fri Mar  6 11:20:33 2015 +0100

gdiplus: Don't use CoCreateInstance in decode_image_wic.

---

 dlls/gdiplus/image.c | 26 +++++++++++++++-----------
 1 file changed, 15 insertions(+), 11 deletions(-)

diff --git a/dlls/gdiplus/image.c b/dlls/gdiplus/image.c
index e6921f5..e2342d5 100644
--- a/dlls/gdiplus/image.c
+++ b/dlls/gdiplus/image.c
@@ -40,6 +40,8 @@
 
 WINE_DEFAULT_DEBUG_CHANNEL(gdiplus);
 
+HRESULT WINAPI WICCreateImagingFactory_Proxy(UINT, IWICImagingFactory**);
+
 #define PIXELFORMATBPP(x) ((x) ? ((x) >> 8) & 255 : 24)
 
 static const struct
@@ -3403,12 +3405,13 @@ static void gif_metadata_reader(GpBitmap *bitmap, IWICBitmapDecoder *decoder, UI
 
 typedef void (*metadata_reader_func)(GpBitmap *bitmap, IWICBitmapDecoder *decoder, UINT frame);
 
-static GpStatus decode_image_wic(IStream *stream, GDIPCONST CLSID *clsid,
+static GpStatus decode_image_wic(IStream *stream, REFGUID container,
     UINT active_frame, metadata_reader_func metadata_reader, GpImage **image)
 {
     GpStatus status=Ok;
     GpBitmap *bitmap;
     HRESULT hr;
+    IWICImagingFactory *factory;
     IWICBitmapDecoder *decoder;
     IWICBitmapFrameDecode *frame;
     IWICBitmapSource *source=NULL;
@@ -3423,12 +3426,13 @@ static GpStatus decode_image_wic(IStream *stream, GDIPCONST CLSID *clsid,
     WICRect wrc;
     HRESULT initresult;
 
-    TRACE("%p,%s,%u,%p\n", stream, wine_dbgstr_guid(clsid), active_frame, image);
+    TRACE("%p,%s,%u,%p\n", stream, wine_dbgstr_guid(container), active_frame, image);
 
     initresult = CoInitialize(NULL);
-
-    hr = CoCreateInstance(clsid, NULL, CLSCTX_INPROC_SERVER,
-        &IID_IWICBitmapDecoder, (void**)&decoder);
+    hr = WICCreateImagingFactory_Proxy(WINCODEC_SDK_VERSION, &factory);
+    if (FAILED(hr)) goto end;
+    hr = IWICImagingFactory_CreateDecoder(factory, container, NULL, &decoder);
+    IWICImagingFactory_Release(factory);
     if (FAILED(hr)) goto end;
 
     hr = IWICBitmapDecoder_Initialize(decoder, stream, WICDecodeMetadataCacheOnLoad);
@@ -3571,7 +3575,7 @@ end:
 
 static GpStatus decode_image_icon(IStream* stream, REFCLSID clsid, UINT active_frame, GpImage **image)
 {
-    return decode_image_wic(stream, &CLSID_WICIcoDecoder, active_frame, NULL, image);
+    return decode_image_wic(stream, &GUID_ContainerFormatIco, active_frame, NULL, image);
 }
 
 static GpStatus decode_image_bmp(IStream* stream, REFCLSID clsid, UINT active_frame, GpImage **image)
@@ -3579,7 +3583,7 @@ static GpStatus decode_image_bmp(IStream* stream, REFCLSID clsid, UINT active_fr
     GpStatus status;
     GpBitmap* bitmap;
 
-    status = decode_image_wic(stream, &CLSID_WICBmpDecoder, active_frame, NULL, image);
+    status = decode_image_wic(stream, &GUID_ContainerFormatBmp, active_frame, NULL, image);
 
     bitmap = (GpBitmap*)*image;
 
@@ -3594,22 +3598,22 @@ static GpStatus decode_image_bmp(IStream* stream, REFCLSID clsid, UINT active_fr
 
 static GpStatus decode_image_jpeg(IStream* stream, REFCLSID clsid, UINT active_frame, GpImage **image)
 {
-    return decode_image_wic(stream, &CLSID_WICJpegDecoder, active_frame, NULL, image);
+    return decode_image_wic(stream, &GUID_ContainerFormatJpeg, active_frame, NULL, image);
 }
 
 static GpStatus decode_image_png(IStream* stream, REFCLSID clsid, UINT active_frame, GpImage **image)
 {
-    return decode_image_wic(stream, &CLSID_WICPngDecoder, active_frame, NULL, image);
+    return decode_image_wic(stream, &GUID_ContainerFormatPng, active_frame, NULL, image);
 }
 
 static GpStatus decode_image_gif(IStream* stream, REFCLSID clsid, UINT active_frame, GpImage **image)
 {
-    return decode_image_wic(stream, &CLSID_WICGifDecoder, active_frame, gif_metadata_reader, image);
+    return decode_image_wic(stream, &GUID_ContainerFormatGif, active_frame, gif_metadata_reader, image);
 }
 
 static GpStatus decode_image_tiff(IStream* stream, REFCLSID clsid, UINT active_frame, GpImage **image)
 {
-    return decode_image_wic(stream, &CLSID_WICTiffDecoder, active_frame, NULL, image);
+    return decode_image_wic(stream, &GUID_ContainerFormatTiff, active_frame, NULL, image);
 }
 
 static GpStatus decode_image_olepicture_metafile(IStream* stream, REFCLSID clsid, UINT active_frame, GpImage **image)




More information about the wine-cvs mailing list