Commit f6cab98d authored by Dmitry Timoshkov's avatar Dmitry Timoshkov Committed by Alexandre Julliard

windowscodecs: Improve compatibility of IMILBitmap interface.

parent f3e45c37
/*
* Copyright 2012 Vincent Povirk for CodeWeavers
* Copyright 2016 Dmitry Timoshkov
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
......@@ -28,6 +29,7 @@
#include "wincodecs_private.h"
#include "wine/asm.h"
#include "wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL(wincodecs);
......@@ -38,7 +40,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(wincodecs);
typedef struct BitmapImpl {
IMILUnknown1 IMILUnknown1_iface;
LONG ref;
IMILBitmapSource IMILBitmapSource_iface;
IMILBitmap IMILBitmap_iface;
IWICBitmap IWICBitmap_iface;
IMILUnknown2 IMILUnknown2_iface;
IWICPalette *palette;
......@@ -68,9 +70,9 @@ static inline BitmapImpl *impl_from_IWICBitmap(IWICBitmap *iface)
return CONTAINING_RECORD(iface, BitmapImpl, IWICBitmap_iface);
}
static inline BitmapImpl *impl_from_IMILBitmapSource(IMILBitmapSource *iface)
static inline BitmapImpl *impl_from_IMILBitmap(IMILBitmap *iface)
{
return CONTAINING_RECORD(iface, BitmapImpl, IMILBitmapSource_iface);
return CONTAINING_RECORD(iface, BitmapImpl, IMILBitmap_iface);
}
static inline BitmapImpl *impl_from_IMILUnknown1(IMILUnknown1 *iface)
......@@ -137,6 +139,7 @@ static HRESULT WINAPI BitmapLockImpl_QueryInterface(IWICBitmapLock *iface, REFII
}
else
{
FIXME("unknown interface %s\n", debugstr_guid(iid));
*ppv = NULL;
return E_NOINTERFACE;
}
......@@ -250,12 +253,14 @@ static HRESULT WINAPI BitmapImpl_QueryInterface(IWICBitmap *iface, REFIID iid,
{
*ppv = &This->IWICBitmap_iface;
}
else if (IsEqualIID(&IID_IMILBitmapSource, iid))
else if (IsEqualIID(&IID_IMILBitmap, iid) ||
IsEqualIID(&IID_IMILBitmapSource, iid))
{
*ppv = &This->IMILBitmapSource_iface;
*ppv = &This->IMILBitmap_iface;
}
else
{
FIXME("unknown interface %s\n", debugstr_guid(iid));
*ppv = NULL;
return E_NOINTERFACE;
}
......@@ -475,42 +480,31 @@ static const IWICBitmapVtbl BitmapImpl_Vtbl = {
BitmapImpl_SetResolution
};
static HRESULT WINAPI IMILBitmapImpl_QueryInterface(IMILBitmapSource *iface, REFIID iid,
static HRESULT WINAPI IMILBitmapImpl_QueryInterface(IMILBitmap *iface, REFIID iid,
void **ppv)
{
BitmapImpl *This = impl_from_IMILBitmapSource(iface);
BitmapImpl *This = impl_from_IMILBitmap(iface);
TRACE("(%p,%s,%p)\n", iface, debugstr_guid(iid), ppv);
if (!ppv) return E_INVALIDARG;
if (IsEqualIID(&IID_IUnknown, iid) ||
IsEqualIID(&IID_IMILBitmapSource, iid))
{
IUnknown_AddRef(&This->IMILBitmapSource_iface);
*ppv = &This->IMILBitmapSource_iface;
return S_OK;
}
*ppv = NULL;
return E_NOINTERFACE;
return IWICBitmap_QueryInterface(&This->IWICBitmap_iface, iid, ppv);
}
static ULONG WINAPI IMILBitmapImpl_AddRef(IMILBitmapSource *iface)
static ULONG WINAPI IMILBitmapImpl_AddRef(IMILBitmap *iface)
{
BitmapImpl *This = impl_from_IMILBitmapSource(iface);
BitmapImpl *This = impl_from_IMILBitmap(iface);
return IWICBitmap_AddRef(&This->IWICBitmap_iface);
}
static ULONG WINAPI IMILBitmapImpl_Release(IMILBitmapSource *iface)
static ULONG WINAPI IMILBitmapImpl_Release(IMILBitmap *iface)
{
BitmapImpl *This = impl_from_IMILBitmapSource(iface);
BitmapImpl *This = impl_from_IMILBitmap(iface);
return IWICBitmap_Release(&This->IWICBitmap_iface);
}
static HRESULT WINAPI IMILBitmapImpl_GetSize(IMILBitmapSource *iface,
static HRESULT WINAPI IMILBitmapImpl_GetSize(IMILBitmap *iface,
UINT *width, UINT *height)
{
BitmapImpl *This = impl_from_IMILBitmapSource(iface);
BitmapImpl *This = impl_from_IMILBitmap(iface);
TRACE("(%p,%p,%p)\n", iface, width, height);
return IWICBitmap_GetSize(&This->IWICBitmap_iface, width, height);
}
......@@ -543,10 +537,10 @@ static const struct
{ &GUID_WICPixelFormat32bppCMYK, 0x1c }
};
static HRESULT WINAPI IMILBitmapImpl_GetPixelFormat(IMILBitmapSource *iface,
static HRESULT WINAPI IMILBitmapImpl_GetPixelFormat(IMILBitmap *iface,
int *format)
{
BitmapImpl *This = impl_from_IMILBitmapSource(iface);
BitmapImpl *This = impl_from_IMILBitmap(iface);
int i;
TRACE("(%p,%p)\n", iface, format);
......@@ -564,45 +558,83 @@ static HRESULT WINAPI IMILBitmapImpl_GetPixelFormat(IMILBitmapSource *iface,
}
}
TRACE("=> %u\n", *format);
return S_OK;
}
static HRESULT WINAPI IMILBitmapImpl_GetResolution(IMILBitmapSource *iface,
static HRESULT WINAPI IMILBitmapImpl_GetResolution(IMILBitmap *iface,
double *dpix, double *dpiy)
{
BitmapImpl *This = impl_from_IMILBitmapSource(iface);
BitmapImpl *This = impl_from_IMILBitmap(iface);
TRACE("(%p,%p,%p)\n", iface, dpix, dpiy);
return IWICBitmap_GetResolution(&This->IWICBitmap_iface, dpix, dpiy);
}
static HRESULT WINAPI IMILBitmapImpl_CopyPalette(IMILBitmapSource *iface,
static HRESULT WINAPI IMILBitmapImpl_CopyPalette(IMILBitmap *iface,
IWICPalette *palette)
{
BitmapImpl *This = impl_from_IMILBitmapSource(iface);
BitmapImpl *This = impl_from_IMILBitmap(iface);
TRACE("(%p,%p)\n", iface, palette);
return IWICBitmap_CopyPalette(&This->IWICBitmap_iface, palette);
}
static HRESULT WINAPI IMILBitmapImpl_CopyPixels(IMILBitmapSource *iface,
static HRESULT WINAPI IMILBitmapImpl_CopyPixels(IMILBitmap *iface,
const WICRect *rc, UINT stride, UINT size, BYTE *buffer)
{
BitmapImpl *This = impl_from_IMILBitmapSource(iface);
BitmapImpl *This = impl_from_IMILBitmap(iface);
TRACE("(%p,%p,%u,%u,%p)\n", iface, rc, stride, size, buffer);
return IWICBitmap_CopyPixels(&This->IWICBitmap_iface, rc, stride, size, buffer);
}
static HRESULT WINAPI IMILBitmapImpl_UnknownMethod1(IMILBitmapSource *iface, void **ppv)
static HRESULT WINAPI IMILBitmapImpl_unknown1(IMILBitmap *iface, void **ppv)
{
BitmapImpl *This = impl_from_IMILBitmapSource(iface);
BitmapImpl *This = impl_from_IMILBitmap(iface);
TRACE("(%p,%p)\n", iface, ppv);
if (!ppv) return E_INVALIDARG;
IUnknown_AddRef(&This->IMILUnknown1_iface);
/* reference count is not incremented here */
*ppv = &This->IMILUnknown1_iface;
return S_OK;
}
static const IMILBitmapSourceVtbl IMILBitmapImpl_Vtbl =
static HRESULT WINAPI IMILBitmapImpl_Lock(IMILBitmap *iface, const WICRect *rc, DWORD flags, IWICBitmapLock **lock)
{
BitmapImpl *This = impl_from_IMILBitmap(iface);
TRACE("(%p,%p,%08x,%p)\n", iface, rc, flags, lock);
return IWICBitmap_Lock(&This->IWICBitmap_iface, rc, flags, lock);
}
static HRESULT WINAPI IMILBitmapImpl_Unlock(IMILBitmap *iface, IWICBitmapLock *lock)
{
TRACE("(%p,%p)\n", iface, lock);
IWICBitmapLock_Release(lock);
return S_OK;
}
static HRESULT WINAPI IMILBitmapImpl_SetPalette(IMILBitmap *iface, IWICPalette *palette)
{
BitmapImpl *This = impl_from_IMILBitmap(iface);
TRACE("(%p,%p)\n", iface, palette);
return IWICBitmap_SetPalette(&This->IWICBitmap_iface, palette);
}
static HRESULT WINAPI IMILBitmapImpl_SetResolution(IMILBitmap *iface, double dpix, double dpiy)
{
BitmapImpl *This = impl_from_IMILBitmap(iface);
TRACE("(%p,%f,%f)\n", iface, dpix, dpiy);
return IWICBitmap_SetResolution(&This->IWICBitmap_iface, dpix, dpiy);
}
static HRESULT WINAPI IMILBitmapImpl_AddDirtyRect(IMILBitmap *iface, const WICRect *rc)
{
FIXME("(%p,%p): stub\n", iface, rc);
return E_NOTIMPL;
}
static const IMILBitmapVtbl IMILBitmapImpl_Vtbl =
{
IMILBitmapImpl_QueryInterface,
IMILBitmapImpl_AddRef,
......@@ -612,26 +644,21 @@ static const IMILBitmapSourceVtbl IMILBitmapImpl_Vtbl =
IMILBitmapImpl_GetResolution,
IMILBitmapImpl_CopyPalette,
IMILBitmapImpl_CopyPixels,
IMILBitmapImpl_UnknownMethod1,
IMILBitmapImpl_unknown1,
IMILBitmapImpl_Lock,
IMILBitmapImpl_Unlock,
IMILBitmapImpl_SetPalette,
IMILBitmapImpl_SetResolution,
IMILBitmapImpl_AddDirtyRect
};
static HRESULT WINAPI IMILUnknown1Impl_QueryInterface(IMILUnknown1 *iface, REFIID iid,
void **ppv)
{
BitmapImpl *This = impl_from_IMILUnknown1(iface);
TRACE("(%p,%s,%p)\n", iface, debugstr_guid(iid), ppv);
if (!ppv) return E_INVALIDARG;
if (IsEqualIID(&IID_IUnknown, iid))
{
IUnknown_AddRef(&This->IMILUnknown1_iface);
*ppv = iface;
return S_OK;
}
return IWICBitmap_QueryInterface(&This->IWICBitmap_iface, iid, ppv);
/* It's not clear what interface should be returned here */
FIXME("(%p,%s,%p): stub\n", iface, debugstr_guid(iid), ppv);
*ppv = NULL;
return E_NOINTERFACE;
}
static ULONG WINAPI IMILUnknown1Impl_AddRef(IMILUnknown1 *iface)
......@@ -646,56 +673,118 @@ static ULONG WINAPI IMILUnknown1Impl_Release(IMILUnknown1 *iface)
return IWICBitmap_Release(&This->IWICBitmap_iface);
}
DEFINE_THISCALL_WRAPPER(IMILUnknown1Impl_unknown1, 8)
DECLSPEC_HIDDEN void __thiscall IMILUnknown1Impl_unknown1(IMILUnknown1 *iface, void *arg)
{
FIXME("(%p,%p): stub\n", iface, arg);
}
static HRESULT WINAPI IMILUnknown1Impl_unknown2(IMILUnknown1 *iface, void *arg1, void *arg2)
{
FIXME("(%p,%p,%p): stub\n", iface, arg1, arg2);
return E_NOTIMPL;
}
DEFINE_THISCALL_WRAPPER(IMILUnknown1Impl_unknown3, 8)
DECLSPEC_HIDDEN HRESULT __thiscall IMILUnknown1Impl_unknown3(IMILUnknown1 *iface, void *arg)
{
FIXME("(%p,%p): stub\n", iface, arg);
return E_NOTIMPL;
}
static HRESULT WINAPI IMILUnknown1Impl_unknown4(IMILUnknown1 *iface, void *arg)
{
FIXME("(%p,%p): stub\n", iface, arg);
return E_NOTIMPL;
}
static HRESULT WINAPI IMILUnknown1Impl_unknown5(IMILUnknown1 *iface, void *arg)
{
FIXME("(%p,%p): stub\n", iface, arg);
return E_NOTIMPL;
}
static HRESULT WINAPI IMILUnknown1Impl_unknown6(IMILUnknown1 *iface, DWORD64 arg)
{
FIXME("(%p,%s): stub\n", iface, wine_dbgstr_longlong(arg));
return E_NOTIMPL;
}
static HRESULT WINAPI IMILUnknown1Impl_unknown7(IMILUnknown1 *iface, void *arg)
{
FIXME("(%p,%p): stub\n", iface, arg);
return E_NOTIMPL;
}
DEFINE_THISCALL_WRAPPER(IMILUnknown1Impl_unknown8, 4)
DECLSPEC_HIDDEN HRESULT __thiscall IMILUnknown1Impl_unknown8(IMILUnknown1 *iface)
{
FIXME("(%p): stub\n", iface);
return E_NOTIMPL;
}
static const IMILUnknown1Vtbl IMILUnknown1Impl_Vtbl =
{
IMILUnknown1Impl_QueryInterface,
IMILUnknown1Impl_AddRef,
IMILUnknown1Impl_Release,
THISCALL(IMILUnknown1Impl_unknown1),
IMILUnknown1Impl_unknown2,
THISCALL(IMILUnknown1Impl_unknown3),
IMILUnknown1Impl_unknown4,
IMILUnknown1Impl_unknown5,
IMILUnknown1Impl_unknown6,
IMILUnknown1Impl_unknown7,
THISCALL(IMILUnknown1Impl_unknown8)
};
static HRESULT WINAPI IMILUnknown2Impl_QueryInterface(IMILUnknown2 *iface, REFIID iid,
void **ppv)
{
BitmapImpl *This = impl_from_IMILUnknown2(iface);
TRACE("(%p,%s,%p)\n", iface, debugstr_guid(iid), ppv);
if (!ppv) return E_INVALIDARG;
if (IsEqualIID(&IID_IUnknown, iid))
{
IUnknown_AddRef(&This->IMILUnknown2_iface);
*ppv = iface;
return S_OK;
}
return IWICBitmap_QueryInterface(&This->IWICBitmap_iface, iid, ppv);
FIXME("(%p,%s,%p): stub\n", iface, debugstr_guid(iid), ppv);
*ppv = NULL;
return E_NOINTERFACE;
}
static ULONG WINAPI IMILUnknown2Impl_AddRef(IMILUnknown2 *iface)
{
BitmapImpl *This = impl_from_IMILUnknown2(iface);
return IWICBitmap_AddRef(&This->IWICBitmap_iface);
FIXME("(%p): stub\n", iface);
return 0;
}
static ULONG WINAPI IMILUnknown2Impl_Release(IMILUnknown2 *iface)
{
BitmapImpl *This = impl_from_IMILUnknown2(iface);
return IWICBitmap_Release(&This->IWICBitmap_iface);
FIXME("(%p): stub\n", iface);
return 0;
}
static HRESULT WINAPI IMILUnknown2Impl_unknown1(IMILUnknown2 *iface, void *arg1, void **arg2)
{
FIXME("(%p,%p,%p): stub\n", iface, arg1, arg2);
if (arg2) *arg2 = NULL;
return E_NOTIMPL;
}
static HRESULT WINAPI IMILUnknown2Impl_UnknownMethod1(IMILUnknown2 *iface, void *arg1, void *arg2)
static HRESULT WINAPI IMILUnknown2Impl_unknown2(IMILUnknown2 *iface, void *arg1, void *arg2)
{
FIXME("(%p,%p,%p): stub\n", iface, arg1, arg2);
return E_NOTIMPL;
}
static HRESULT WINAPI IMILUnknown2Impl_unknown3(IMILUnknown2 *iface, void *arg1)
{
FIXME("(%p,%p): stub\n", iface, arg1);
return E_NOTIMPL;
}
static const IMILUnknown2Vtbl IMILUnknown2Impl_Vtbl =
{
IMILUnknown2Impl_QueryInterface,
IMILUnknown2Impl_AddRef,
IMILUnknown2Impl_Release,
IMILUnknown2Impl_UnknownMethod1,
IMILUnknown2Impl_unknown1,
IMILUnknown2Impl_unknown2,
IMILUnknown2Impl_unknown3
};
HRESULT BitmapImpl_Create(UINT uiWidth, UINT uiHeight, UINT stride, UINT datasize, void *view,
......@@ -727,7 +816,7 @@ HRESULT BitmapImpl_Create(UINT uiWidth, UINT uiHeight, UINT stride, UINT datasiz
}
This->IWICBitmap_iface.lpVtbl = &BitmapImpl_Vtbl;
This->IMILBitmapSource_iface.lpVtbl = &IMILBitmapImpl_Vtbl;
This->IMILBitmap_iface.lpVtbl = &IMILBitmapImpl_Vtbl;
This->IMILUnknown1_iface.lpVtbl = &IMILUnknown1Impl_Vtbl;
This->IMILUnknown2_iface.lpVtbl = &IMILUnknown2Impl_Vtbl;
This->ref = 1;
......
......@@ -33,7 +33,13 @@ DEFINE_GUID(GUID_WineContainerFormatTga, 0x0c44fda1,0xa5c5,0x4298,0x96,0x85,0x47
DEFINE_GUID(GUID_VendorWine, 0xddf46da1,0x7dc1,0x404e,0x98,0xf2,0xef,0xa4,0x8d,0xfc,0x95,0x0a);
DEFINE_GUID(IID_IMILBitmap,0xb1784d3f,0x8115,0x4763,0x13,0xaa,0x32,0xed,0xdb,0x68,0x29,0x4a);
DEFINE_GUID(IID_IMILBitmapSource,0x7543696a,0xbc8d,0x46b0,0x5f,0x81,0x8d,0x95,0x72,0x89,0x72,0xbe);
DEFINE_GUID(IID_IMILBitmapLock,0xa67b2b53,0x8fa1,0x4155,0x8f,0x64,0x0c,0x24,0x7a,0x8f,0x84,0xcd);
DEFINE_GUID(IID_IMILBitmapScaler,0xa767b0f0,0x1c8c,0x4aef,0x56,0x8f,0xad,0xf9,0x6d,0xcf,0xd5,0xcb);
DEFINE_GUID(IID_IMILFormatConverter,0x7e2a746f,0x25c5,0x4851,0xb3,0xaf,0x44,0x3b,0x79,0x63,0x9e,0xc0);
DEFINE_GUID(IID_IMILPalette,0xca8e206f,0xf22c,0x4af7,0x6f,0xba,0x7b,0xed,0x5e,0xb1,0xc9,0x2f);
#define INTERFACE IMILBitmapSource
DECLARE_INTERFACE_(IMILBitmapSource,IUnknown)
{
......@@ -41,13 +47,35 @@ DECLARE_INTERFACE_(IMILBitmapSource,IUnknown)
STDMETHOD_(HRESULT,QueryInterface)(THIS_ REFIID,void **) PURE;
STDMETHOD_(ULONG,AddRef)(THIS) PURE;
STDMETHOD_(ULONG,Release)(THIS) PURE;
/*** IMILBitmapSource methods ***/
STDMETHOD_(HRESULT,GetSize)(THIS_ UINT *,UINT *);
STDMETHOD_(HRESULT,GetPixelFormat)(THIS_ int *);
STDMETHOD_(HRESULT,GetResolution)(THIS_ double *,double *);
STDMETHOD_(HRESULT,CopyPalette)(THIS_ IWICPalette *);
STDMETHOD_(HRESULT,CopyPixels)(THIS_ const WICRect *,UINT,UINT,BYTE *);
STDMETHOD_(HRESULT,UnknownMethod1)(THIS_ void **);
/*** IWICBitmapSource methods ***/
STDMETHOD_(HRESULT,GetSize)(THIS_ UINT *,UINT *) PURE;
STDMETHOD_(HRESULT,GetPixelFormat)(THIS_ int *) PURE;
STDMETHOD_(HRESULT,GetResolution)(THIS_ double *,double *) PURE;
STDMETHOD_(HRESULT,CopyPalette)(THIS_ IWICPalette *) PURE;
STDMETHOD_(HRESULT,CopyPixels)(THIS_ const WICRect *,UINT,UINT,BYTE *) PURE;
};
#undef INTERFACE
#define INTERFACE IMILBitmap
DECLARE_INTERFACE_(IMILBitmap,IMILBitmapSource)
{
/*** IUnknown methods ***/
STDMETHOD_(HRESULT,QueryInterface)(THIS_ REFIID,void **) PURE;
STDMETHOD_(ULONG,AddRef)(THIS) PURE;
STDMETHOD_(ULONG,Release)(THIS) PURE;
/*** IWICBitmapSource methods ***/
STDMETHOD_(HRESULT,GetSize)(THIS_ UINT *,UINT *) PURE;
STDMETHOD_(HRESULT,GetPixelFormat)(THIS_ int *) PURE;
STDMETHOD_(HRESULT,GetResolution)(THIS_ double *,double *) PURE;
STDMETHOD_(HRESULT,CopyPalette)(THIS_ IWICPalette *) PURE;
STDMETHOD_(HRESULT,CopyPixels)(THIS_ const WICRect *,UINT,UINT,BYTE *) PURE;
/*** IMILBitmap methods ***/
STDMETHOD_(HRESULT,unknown1)(THIS_ void **) PURE;
STDMETHOD_(HRESULT,Lock)(THIS_ const WICRect *,DWORD,IWICBitmapLock **) PURE;
STDMETHOD_(HRESULT,Unlock)(THIS_ IWICBitmapLock *) PURE;
STDMETHOD_(HRESULT,SetPalette)(THIS_ IWICPalette *) PURE;
STDMETHOD_(HRESULT,SetResolution)(THIS_ double,double) PURE;
STDMETHOD_(HRESULT,AddDirtyRect)(THIS_ const WICRect *) PURE;
};
#undef INTERFACE
......@@ -58,6 +86,19 @@ DECLARE_INTERFACE_(IMILUnknown1,IUnknown)
STDMETHOD_(HRESULT,QueryInterface)(THIS_ REFIID,void **) PURE;
STDMETHOD_(ULONG,AddRef)(THIS) PURE;
STDMETHOD_(ULONG,Release)(THIS) PURE;
/*** thiscall method ***/
STDMETHOD_(void,unknown1)(THIS_ void*) PURE;
/*** stdcall ***/
STDMETHOD_(HRESULT,unknown2)(THIS_ void*, void*) PURE;
/*** thiscall method ***/
STDMETHOD_(HRESULT,unknown3)(THIS_ void*) PURE;
/*** stdcall ***/
STDMETHOD_(HRESULT,unknown4)(THIS_ void*) PURE;
STDMETHOD_(HRESULT,unknown5)(THIS_ void*) PURE;
STDMETHOD_(HRESULT,unknown6)(THIS_ DWORD64) PURE;
STDMETHOD_(HRESULT,unknown7)(THIS_ void*) PURE;
/*** thiscall method ***/
STDMETHOD_(HRESULT,unknown8)(THIS) PURE;
};
#undef INTERFACE
......@@ -69,7 +110,9 @@ DECLARE_INTERFACE_(IMILUnknown2,IUnknown)
STDMETHOD_(ULONG,AddRef)(THIS) PURE;
STDMETHOD_(ULONG,Release)(THIS) PURE;
/*** unknown methods ***/
STDMETHOD_(HRESULT,UnknownMethod1)(THIS_ void *, void *) PURE;
STDMETHOD_(HRESULT,unknown1)(THIS_ void *,void **) PURE;
STDMETHOD_(HRESULT,unknown2)(THIS_ void *,void *) PURE;
STDMETHOD_(HRESULT,unknown3)(THIS_ void *) PURE;
};
#undef INTERFACE
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment