[PATCH] wincodecs: Add IWICImagingFactory2 stub.

Nikolay Sivov nsivov at codeweavers.com
Sat Sep 29 14:59:48 CDT 2018


Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=45709
Signed-off-by: Nikolay Sivov <nsivov at codeweavers.com>
---
 dlls/windowscodecs/clsfactory.c |   1 +
 dlls/windowscodecs/imgfactory.c | 239 ++++++++++++++++++++++++++++++++
 dlls/windowscodecs/tests/info.c |  33 +++++
 3 files changed, 273 insertions(+)

diff --git a/dlls/windowscodecs/clsfactory.c b/dlls/windowscodecs/clsfactory.c
index 77eeedc428..2e8cc8e22d 100644
--- a/dlls/windowscodecs/clsfactory.c
+++ b/dlls/windowscodecs/clsfactory.c
@@ -44,6 +44,7 @@ typedef struct {
 
 static const classinfo wic_classes[] = {
     {&CLSID_WICImagingFactory, ComponentFactory_CreateInstance},
+    {&CLSID_WICImagingFactory2, ComponentFactory_CreateInstance},
     {&CLSID_WICBmpDecoder, BmpDecoder_CreateInstance},
     {&CLSID_WICPngDecoder, PngDecoder_CreateInstance},
     {&CLSID_WICPngEncoder, PngEncoder_CreateInstance},
diff --git a/dlls/windowscodecs/imgfactory.c b/dlls/windowscodecs/imgfactory.c
index 06e3f6aceb..f23c824473 100644
--- a/dlls/windowscodecs/imgfactory.c
+++ b/dlls/windowscodecs/imgfactory.c
@@ -37,6 +37,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(wincodecs);
 
 typedef struct {
     IWICComponentFactory IWICComponentFactory_iface;
+    IWICImagingFactory2 IWICImagingFactory2_iface;
     LONG ref;
 } ComponentFactory;
 
@@ -45,6 +46,11 @@ static inline ComponentFactory *impl_from_IWICComponentFactory(IWICComponentFact
     return CONTAINING_RECORD(iface, ComponentFactory, IWICComponentFactory_iface);
 }
 
+static inline ComponentFactory *impl_from_IWICImagingFactory2(IWICImagingFactory2 *iface)
+{
+    return CONTAINING_RECORD(iface, ComponentFactory, IWICImagingFactory2_iface);
+}
+
 static HRESULT WINAPI ComponentFactory_QueryInterface(IWICComponentFactory *iface, REFIID iid,
     void **ppv)
 {
@@ -59,6 +65,10 @@ static HRESULT WINAPI ComponentFactory_QueryInterface(IWICComponentFactory *ifac
     {
         *ppv = &This->IWICComponentFactory_iface;
     }
+    else if (IsEqualIID(&IID_IWICImagingFactory2, iid))
+    {
+        *ppv = &This->IWICImagingFactory2_iface;
+    }
     else
     {
         *ppv = NULL;
@@ -1181,6 +1191,234 @@ static const IWICComponentFactoryVtbl ComponentFactory_Vtbl = {
     ComponentFactory_CreateEncoderPropertyBag
 };
 
+static HRESULT WINAPI ImagingFactory_QueryInterface(IWICImagingFactory2 *iface, REFIID iid, void **ppv)
+{
+    ComponentFactory *This = impl_from_IWICImagingFactory2(iface);
+    return IWICComponentFactory_QueryInterface(&This->IWICComponentFactory_iface, iid, ppv);
+}
+
+static ULONG WINAPI ImagingFactory_AddRef(IWICImagingFactory2 *iface)
+{
+    ComponentFactory *This = impl_from_IWICImagingFactory2(iface);
+    return IWICComponentFactory_AddRef(&This->IWICComponentFactory_iface);
+}
+
+static ULONG WINAPI ImagingFactory_Release(IWICImagingFactory2 *iface)
+{
+    ComponentFactory *This = impl_from_IWICImagingFactory2(iface);
+    return IWICComponentFactory_Release(&This->IWICComponentFactory_iface);
+}
+
+static HRESULT WINAPI ImagingFactory_CreateDecoderFromFilename(IWICImagingFactory2 *iface, LPCWSTR filename,
+    const GUID *vendor, DWORD desired_access, WICDecodeOptions options, IWICBitmapDecoder **decoder)
+{
+    ComponentFactory *This = impl_from_IWICImagingFactory2(iface);
+    return IWICComponentFactory_CreateDecoderFromFilename(&This->IWICComponentFactory_iface, filename, vendor,
+        desired_access, options, decoder);
+}
+
+static HRESULT WINAPI ImagingFactory_CreateDecoderFromStream(IWICImagingFactory2 *iface, IStream *stream,
+    const GUID *vendor, WICDecodeOptions options, IWICBitmapDecoder **decoder)
+{
+    ComponentFactory *This = impl_from_IWICImagingFactory2(iface);
+    return IWICComponentFactory_CreateDecoderFromStream(&This->IWICComponentFactory_iface, stream, vendor,
+        options, decoder);
+}
+
+static HRESULT WINAPI ImagingFactory_CreateDecoderFromFileHandle(IWICImagingFactory2 *iface, ULONG_PTR hFile,
+    const GUID *vendor, WICDecodeOptions options, IWICBitmapDecoder **decoder)
+{
+    ComponentFactory *This = impl_from_IWICImagingFactory2(iface);
+    return IWICComponentFactory_CreateDecoderFromFileHandle(&This->IWICComponentFactory_iface, hFile, vendor,
+        options, decoder);
+}
+
+static HRESULT WINAPI ImagingFactory_CreateComponentInfo(IWICImagingFactory2 *iface, REFCLSID component,
+    IWICComponentInfo **info)
+{
+    ComponentFactory *This = impl_from_IWICImagingFactory2(iface);
+    return IWICComponentFactory_CreateComponentInfo(&This->IWICComponentFactory_iface, component, info);
+}
+
+static HRESULT WINAPI ImagingFactory_CreateDecoder(IWICImagingFactory2 *iface, REFGUID format, const GUID *vendor,
+    IWICBitmapDecoder **decoder)
+{
+    ComponentFactory *This = impl_from_IWICImagingFactory2(iface);
+    return IWICComponentFactory_CreateDecoder(&This->IWICComponentFactory_iface, format, vendor, decoder);
+}
+
+static HRESULT WINAPI ImagingFactory_CreateEncoder(IWICImagingFactory2 *iface, REFGUID format, const GUID *vendor,
+    IWICBitmapEncoder **encoder)
+{
+    ComponentFactory *This = impl_from_IWICImagingFactory2(iface);
+    return IWICComponentFactory_CreateEncoder(&This->IWICComponentFactory_iface, format, vendor, encoder);
+}
+
+static HRESULT WINAPI ImagingFactory_CreatePalette(IWICImagingFactory2 *iface, IWICPalette **palette)
+{
+    ComponentFactory *This = impl_from_IWICImagingFactory2(iface);
+    return IWICComponentFactory_CreatePalette(&This->IWICComponentFactory_iface, palette);
+}
+
+static HRESULT WINAPI ImagingFactory_CreateFormatConverter(IWICImagingFactory2 *iface, IWICFormatConverter **converter)
+{
+    ComponentFactory *This = impl_from_IWICImagingFactory2(iface);
+    return IWICComponentFactory_CreateFormatConverter(&This->IWICComponentFactory_iface, converter);
+}
+
+static HRESULT WINAPI ImagingFactory_CreateBitmapScaler(IWICImagingFactory2 *iface, IWICBitmapScaler **scaler)
+{
+    ComponentFactory *This = impl_from_IWICImagingFactory2(iface);
+    return IWICComponentFactory_CreateBitmapScaler(&This->IWICComponentFactory_iface, scaler);
+}
+
+static HRESULT WINAPI ImagingFactory_CreateBitmapClipper(IWICImagingFactory2 *iface, IWICBitmapClipper **clipper)
+{
+    ComponentFactory *This = impl_from_IWICImagingFactory2(iface);
+    return IWICComponentFactory_CreateBitmapClipper(&This->IWICComponentFactory_iface, clipper);
+}
+
+static HRESULT WINAPI ImagingFactory_CreateBitmapFlipRotator(IWICImagingFactory2 *iface, IWICBitmapFlipRotator **fliprotator)
+{
+    ComponentFactory *This = impl_from_IWICImagingFactory2(iface);
+    return IWICComponentFactory_CreateBitmapFlipRotator(&This->IWICComponentFactory_iface, fliprotator);
+}
+
+static HRESULT WINAPI ImagingFactory_CreateStream(IWICImagingFactory2 *iface, IWICStream **stream)
+{
+    ComponentFactory *This = impl_from_IWICImagingFactory2(iface);
+    return IWICComponentFactory_CreateStream(&This->IWICComponentFactory_iface, stream);
+}
+
+static HRESULT WINAPI ImagingFactory_CreateColorContext(IWICImagingFactory2 *iface, IWICColorContext **context)
+{
+    ComponentFactory *This = impl_from_IWICImagingFactory2(iface);
+    return IWICComponentFactory_CreateColorContext(&This->IWICComponentFactory_iface, context);
+}
+
+static HRESULT WINAPI ImagingFactory_CreateColorTransformer(IWICImagingFactory2 *iface, IWICColorTransform **transformer)
+{
+    ComponentFactory *This = impl_from_IWICImagingFactory2(iface);
+    return IWICComponentFactory_CreateColorTransformer(&This->IWICComponentFactory_iface, transformer);
+}
+
+static HRESULT WINAPI ImagingFactory_CreateBitmap(IWICImagingFactory2 *iface, UINT width, UINT height, REFWICPixelFormatGUID pixel_format,
+    WICBitmapCreateCacheOption option, IWICBitmap **bitmap)
+{
+    ComponentFactory *This = impl_from_IWICImagingFactory2(iface);
+    return IWICComponentFactory_CreateBitmap(&This->IWICComponentFactory_iface, width, height, pixel_format, option, bitmap);
+}
+
+static HRESULT WINAPI ImagingFactory_CreateBitmapFromSource(IWICImagingFactory2 *iface, IWICBitmapSource *source,
+    WICBitmapCreateCacheOption option, IWICBitmap **bitmap)
+{
+    ComponentFactory *This = impl_from_IWICImagingFactory2(iface);
+    return IWICComponentFactory_CreateBitmapFromSource(&This->IWICComponentFactory_iface, source, option, bitmap);
+}
+
+static HRESULT WINAPI ImagingFactory_CreateBitmapFromSourceRect(IWICImagingFactory2 *iface, IWICBitmapSource *source,
+    UINT x, UINT y, UINT width, UINT height, IWICBitmap **bitmap)
+{
+    ComponentFactory *This = impl_from_IWICImagingFactory2(iface);
+    return IWICComponentFactory_CreateBitmapFromSourceRect(&This->IWICComponentFactory_iface, source, x, y, width, height, bitmap);
+}
+
+static HRESULT WINAPI ImagingFactory_CreateBitmapFromMemory(IWICImagingFactory2 *iface, UINT width, UINT height,
+    REFWICPixelFormatGUID format, UINT stride, UINT size, BYTE *buffer, IWICBitmap **bitmap)
+{
+    ComponentFactory *This = impl_from_IWICImagingFactory2(iface);
+    return IWICComponentFactory_CreateBitmapFromMemory(&This->IWICComponentFactory_iface, width, height, format, stride,
+        size, buffer, bitmap);
+}
+
+static HRESULT WINAPI ImagingFactory_CreateBitmapFromHBITMAP(IWICImagingFactory2 *iface, HBITMAP hbm, HPALETTE hpal,
+    WICBitmapAlphaChannelOption option, IWICBitmap **bitmap)
+{
+    ComponentFactory *This = impl_from_IWICImagingFactory2(iface);
+    return IWICComponentFactory_CreateBitmapFromHBITMAP(&This->IWICComponentFactory_iface, hbm, hpal, option, bitmap);
+}
+
+static HRESULT WINAPI ImagingFactory_CreateBitmapFromHICON(IWICImagingFactory2 *iface, HICON hicon, IWICBitmap **bitmap)
+{
+    ComponentFactory *This = impl_from_IWICImagingFactory2(iface);
+    return IWICComponentFactory_CreateBitmapFromHICON(&This->IWICComponentFactory_iface, hicon, bitmap);
+}
+
+static HRESULT WINAPI ImagingFactory_CreateComponentEnumerator(IWICImagingFactory2 *iface, DWORD component_types,
+    DWORD options, IEnumUnknown **enumerator)
+{
+    ComponentFactory *This = impl_from_IWICImagingFactory2(iface);
+    return IWICComponentFactory_CreateComponentEnumerator(&This->IWICComponentFactory_iface, component_types,
+        options, enumerator);
+}
+
+static HRESULT WINAPI ImagingFactory_CreateFastMetadataEncoderFromDecoder(IWICImagingFactory2 *iface, IWICBitmapDecoder *decoder,
+    IWICFastMetadataEncoder **encoder)
+{
+    ComponentFactory *This = impl_from_IWICImagingFactory2(iface);
+    return IWICComponentFactory_CreateFastMetadataEncoderFromDecoder(&This->IWICComponentFactory_iface, decoder, encoder);
+}
+
+static HRESULT WINAPI ImagingFactory_CreateFastMetadataEncoderFromFrameDecode(IWICImagingFactory2 *iface,
+    IWICBitmapFrameDecode *frame_decode, IWICFastMetadataEncoder **encoder)
+{
+    ComponentFactory *This = impl_from_IWICImagingFactory2(iface);
+    return IWICComponentFactory_CreateFastMetadataEncoderFromFrameDecode(&This->IWICComponentFactory_iface, frame_decode, encoder);
+}
+
+static HRESULT WINAPI ImagingFactory_CreateQueryWriter(IWICImagingFactory2 *iface, REFGUID format, const GUID *vendor,
+    IWICMetadataQueryWriter **writer)
+{
+    ComponentFactory *This = impl_from_IWICImagingFactory2(iface);
+    return IWICComponentFactory_CreateQueryWriter(&This->IWICComponentFactory_iface, format, vendor, writer);
+}
+
+static HRESULT WINAPI ImagingFactory_CreateQueryWriterFromReader(IWICImagingFactory2 *iface, IWICMetadataQueryReader *reader,
+    const GUID *vendor, IWICMetadataQueryWriter **writer)
+{
+    ComponentFactory *This = impl_from_IWICImagingFactory2(iface);
+    return IWICComponentFactory_CreateQueryWriterFromReader(&This->IWICComponentFactory_iface, reader, vendor, writer);
+}
+
+static HRESULT WINAPI ImagingFactory_CreateImageEncoder(IWICImagingFactory2 *iface, ID2D1Device *device, IWICImageEncoder **encoder)
+{
+    FIXME("%p,%p,%p stub.\n", iface, device, encoder);
+
+    return E_NOTIMPL;
+}
+
+static const IWICImagingFactory2Vtbl ImagingFactory_Vtbl = {
+    ImagingFactory_QueryInterface,
+    ImagingFactory_AddRef,
+    ImagingFactory_Release,
+    ImagingFactory_CreateDecoderFromFilename,
+    ImagingFactory_CreateDecoderFromStream,
+    ImagingFactory_CreateDecoderFromFileHandle,
+    ImagingFactory_CreateComponentInfo,
+    ImagingFactory_CreateDecoder,
+    ImagingFactory_CreateEncoder,
+    ImagingFactory_CreatePalette,
+    ImagingFactory_CreateFormatConverter,
+    ImagingFactory_CreateBitmapScaler,
+    ImagingFactory_CreateBitmapClipper,
+    ImagingFactory_CreateBitmapFlipRotator,
+    ImagingFactory_CreateStream,
+    ImagingFactory_CreateColorContext,
+    ImagingFactory_CreateColorTransformer,
+    ImagingFactory_CreateBitmap,
+    ImagingFactory_CreateBitmapFromSource,
+    ImagingFactory_CreateBitmapFromSourceRect,
+    ImagingFactory_CreateBitmapFromMemory,
+    ImagingFactory_CreateBitmapFromHBITMAP,
+    ImagingFactory_CreateBitmapFromHICON,
+    ImagingFactory_CreateComponentEnumerator,
+    ImagingFactory_CreateFastMetadataEncoderFromDecoder,
+    ImagingFactory_CreateFastMetadataEncoderFromFrameDecode,
+    ImagingFactory_CreateQueryWriter,
+    ImagingFactory_CreateQueryWriterFromReader,
+    ImagingFactory_CreateImageEncoder,
+};
+
 HRESULT ComponentFactory_CreateInstance(REFIID iid, void** ppv)
 {
     ComponentFactory *This;
@@ -1194,6 +1432,7 @@ HRESULT ComponentFactory_CreateInstance(REFIID iid, void** ppv)
     if (!This) return E_OUTOFMEMORY;
 
     This->IWICComponentFactory_iface.lpVtbl = &ComponentFactory_Vtbl;
+    This->IWICImagingFactory2_iface.lpVtbl = &ImagingFactory_Vtbl;
     This->ref = 1;
 
     ret = IWICComponentFactory_QueryInterface(&This->IWICComponentFactory_iface, iid, ppv);
diff --git a/dlls/windowscodecs/tests/info.c b/dlls/windowscodecs/tests/info.c
index b647601495..ee95784166 100644
--- a/dlls/windowscodecs/tests/info.c
+++ b/dlls/windowscodecs/tests/info.c
@@ -637,6 +637,38 @@ todo_wine
     IWICImagingFactory_Release(factory);
 }
 
+static void test_imagingfactory_interfaces(void)
+{
+    IWICComponentFactory *component_factory;
+    IWICImagingFactory2 *factory2;
+    IWICImagingFactory *factory;
+    HRESULT hr;
+
+    hr = CoCreateInstance(&CLSID_WICImagingFactory, NULL, CLSCTX_INPROC_SERVER,
+        &IID_IWICImagingFactory2, (void **)&factory2);
+    if (FAILED(hr))
+    {
+        win_skip("IWICImagingFactory2 is not supported.\n");
+        return;
+    }
+
+    hr = IWICImagingFactory2_QueryInterface(factory2, &IID_IWICComponentFactory, (void **)&component_factory);
+    ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
+
+    hr = IWICComponentFactory_QueryInterface(component_factory, &IID_IWICImagingFactory, (void **)&factory);
+    ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
+    ok(factory == (IWICImagingFactory *)component_factory, "Unexpected factory pointer.\n");
+    IWICImagingFactory_Release(factory);
+
+    hr = IWICImagingFactory2_QueryInterface(factory2, &IID_IWICImagingFactory, (void **)&factory);
+    ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
+    ok(factory == (IWICImagingFactory *)component_factory, "Unexpected factory pointer.\n");
+
+    IWICComponentFactory_Release(component_factory);
+    IWICImagingFactory2_Release(factory2);
+    IWICImagingFactory_Release(factory);
+}
+
 START_TEST(info)
 {
     CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
@@ -644,6 +676,7 @@ START_TEST(info)
     test_decoder_info();
     test_reader_info();
     test_pixelformat_info();
+    test_imagingfactory_interfaces();
 
     CoUninitialize();
 }
-- 
2.19.0




More information about the wine-devel mailing list