windowscodecs: Add helper to create internal COM classes without CoCreateInstance call if possible.
This commit is contained in:
parent
2b40f9b01e
commit
df9ec3c178
|
@ -202,3 +202,14 @@ HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID iid, LPVOID *ppv)
|
|||
TRACE("<-- %08X\n", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
HRESULT create_instance(CLSID *clsid, const IID *iid, void **ppv)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i=0; wic_classes[i].classid; i++)
|
||||
if (IsEqualCLSID(wic_classes[i].classid, clsid))
|
||||
return wic_classes[i].constructor(iid, ppv);
|
||||
|
||||
return CoCreateInstance(clsid, NULL, CLSCTX_INPROC_SERVER, iid, ppv);
|
||||
}
|
||||
|
|
|
@ -623,8 +623,7 @@ static HRESULT WINAPI BitmapDecoderInfo_CreateInstance(IWICBitmapDecoderInfo *if
|
|||
|
||||
TRACE("(%p,%p)\n", iface, ppIBitmapDecoder);
|
||||
|
||||
return CoCreateInstance(&This->clsid, NULL, CLSCTX_INPROC_SERVER,
|
||||
&IID_IWICBitmapDecoder, (void**)ppIBitmapDecoder);
|
||||
return create_instance(&This->clsid, &IID_IWICBitmapDecoder, (void**)ppIBitmapDecoder);
|
||||
}
|
||||
|
||||
static const IWICBitmapDecoderInfoVtbl BitmapDecoderInfo_Vtbl = {
|
||||
|
@ -917,8 +916,7 @@ static HRESULT WINAPI BitmapEncoderInfo_CreateInstance(IWICBitmapEncoderInfo *if
|
|||
|
||||
TRACE("(%p,%p)\n", iface, ppIBitmapEncoder);
|
||||
|
||||
return CoCreateInstance(&This->clsid, NULL, CLSCTX_INPROC_SERVER,
|
||||
&IID_IWICBitmapEncoder, (void**)ppIBitmapEncoder);
|
||||
return create_instance(&This->clsid, &IID_IWICBitmapEncoder, (void**)ppIBitmapEncoder);
|
||||
}
|
||||
|
||||
static const IWICBitmapEncoderInfoVtbl BitmapEncoderInfo_Vtbl = {
|
||||
|
@ -1125,8 +1123,8 @@ static HRESULT WINAPI FormatConverterInfo_CreateInstance(IWICFormatConverterInfo
|
|||
|
||||
TRACE("(%p,%p)\n", iface, ppIFormatConverter);
|
||||
|
||||
return CoCreateInstance(&This->clsid, NULL, CLSCTX_INPROC_SERVER,
|
||||
&IID_IWICFormatConverter, (void**)ppIFormatConverter);
|
||||
return create_instance(&This->clsid, &IID_IWICFormatConverter,
|
||||
(void**)ppIFormatConverter);
|
||||
}
|
||||
|
||||
static BOOL ConverterSupportsFormat(IWICFormatConverterInfo *iface, const WCHAR *formatguid)
|
||||
|
@ -1871,8 +1869,7 @@ static HRESULT WINAPI MetadataReaderInfo_CreateInstance(IWICMetadataReaderInfo *
|
|||
|
||||
TRACE("(%p,%p)\n", iface, reader);
|
||||
|
||||
return CoCreateInstance(&This->clsid, NULL, CLSCTX_INPROC_SERVER,
|
||||
&IID_IWICMetadataReader, (void **)reader);
|
||||
return create_instance(&This->clsid, &IID_IWICMetadataReader, (void **)reader);
|
||||
}
|
||||
|
||||
static const IWICMetadataReaderInfoVtbl MetadataReaderInfo_Vtbl = {
|
||||
|
|
|
@ -25,6 +25,8 @@
|
|||
#include "wincodec.h"
|
||||
#include "wine/test.h"
|
||||
|
||||
HRESULT WINAPI WICCreateImagingFactory_Proxy(UINT, IWICImagingFactory**);
|
||||
|
||||
static const char gif_global_palette[] = {
|
||||
/* LSD */'G','I','F','8','7','a',0x01,0x00,0x01,0x00,0xa1,0x02,0x00,
|
||||
/* palette */0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0a,0x0b,0x0c,
|
||||
|
@ -344,4 +346,14 @@ START_TEST(gifformat)
|
|||
|
||||
IWICImagingFactory_Release(factory);
|
||||
CoUninitialize();
|
||||
|
||||
/* run the same tests with no COM initialization */
|
||||
hr = WICCreateImagingFactory_Proxy(WINCODEC_SDK_VERSION, &factory);
|
||||
ok(hr == S_OK, "WICCreateImagingFactory_Proxy error %#x\n", hr);
|
||||
|
||||
test_global_gif_palette();
|
||||
test_global_gif_palette_2frames();
|
||||
test_local_gif_palette();
|
||||
|
||||
IWICImagingFactory_Release(factory);
|
||||
}
|
||||
|
|
|
@ -67,6 +67,8 @@ DECLARE_INTERFACE_(IMILUnknown2,IUnknown)
|
|||
};
|
||||
#undef INTERFACE
|
||||
|
||||
HRESULT create_instance(CLSID *clsid, const IID *iid, void **ppv) DECLSPEC_HIDDEN;
|
||||
|
||||
typedef HRESULT(*class_constructor)(REFIID,void**);
|
||||
extern HRESULT FormatConverter_CreateInstance(REFIID riid, void** ppv) DECLSPEC_HIDDEN;
|
||||
extern HRESULT ComponentFactory_CreateInstance(REFIID riid, void** ppv) DECLSPEC_HIDDEN;
|
||||
|
|
Loading…
Reference in New Issue