windowscodecs: Use ifaces instead of vtbl pointers in BmpDecoder.
This commit is contained in:
parent
1515b36aaa
commit
2785e905bc
|
@ -62,8 +62,8 @@ typedef struct {
|
|||
typedef HRESULT (*ReadDataFunc)(BmpDecoder* This);
|
||||
|
||||
struct BmpDecoder {
|
||||
const IWICBitmapDecoderVtbl *lpVtbl;
|
||||
const IWICBitmapFrameDecodeVtbl *lpFrameVtbl;
|
||||
IWICBitmapDecoder IWICBitmapDecoder_iface;
|
||||
IWICBitmapFrameDecode IWICBitmapFrameDecode_iface;
|
||||
LONG ref;
|
||||
BOOL initialized;
|
||||
IStream *stream;
|
||||
|
@ -81,9 +81,14 @@ struct BmpDecoder {
|
|||
int icoframe; /* If TRUE, this is a frame of a .ico file. */
|
||||
};
|
||||
|
||||
static inline BmpDecoder *impl_from_frame(IWICBitmapFrameDecode *iface)
|
||||
static inline BmpDecoder *impl_from_IWICBitmapDecoder(IWICBitmapDecoder *iface)
|
||||
{
|
||||
return CONTAINING_RECORD(iface, BmpDecoder, lpFrameVtbl);
|
||||
return CONTAINING_RECORD(iface, BmpDecoder, IWICBitmapDecoder_iface);
|
||||
}
|
||||
|
||||
static inline BmpDecoder *impl_from_IWICBitmapFrameDecode(IWICBitmapFrameDecode *iface)
|
||||
{
|
||||
return CONTAINING_RECORD(iface, BmpDecoder, IWICBitmapFrameDecode_iface);
|
||||
}
|
||||
|
||||
static HRESULT WINAPI BmpFrameDecode_QueryInterface(IWICBitmapFrameDecode *iface, REFIID iid,
|
||||
|
@ -111,22 +116,22 @@ static HRESULT WINAPI BmpFrameDecode_QueryInterface(IWICBitmapFrameDecode *iface
|
|||
|
||||
static ULONG WINAPI BmpFrameDecode_AddRef(IWICBitmapFrameDecode *iface)
|
||||
{
|
||||
BmpDecoder *This = impl_from_frame(iface);
|
||||
BmpDecoder *This = impl_from_IWICBitmapFrameDecode(iface);
|
||||
|
||||
return IUnknown_AddRef((IUnknown*)This);
|
||||
return IWICBitmapDecoder_AddRef(&This->IWICBitmapDecoder_iface);
|
||||
}
|
||||
|
||||
static ULONG WINAPI BmpFrameDecode_Release(IWICBitmapFrameDecode *iface)
|
||||
{
|
||||
BmpDecoder *This = impl_from_frame(iface);
|
||||
BmpDecoder *This = impl_from_IWICBitmapFrameDecode(iface);
|
||||
|
||||
return IUnknown_Release((IUnknown*)This);
|
||||
return IWICBitmapDecoder_Release(&This->IWICBitmapDecoder_iface);
|
||||
}
|
||||
|
||||
static HRESULT WINAPI BmpFrameDecode_GetSize(IWICBitmapFrameDecode *iface,
|
||||
UINT *puiWidth, UINT *puiHeight)
|
||||
{
|
||||
BmpDecoder *This = impl_from_frame(iface);
|
||||
BmpDecoder *This = impl_from_IWICBitmapFrameDecode(iface);
|
||||
TRACE("(%p,%p,%p)\n", iface, puiWidth, puiHeight);
|
||||
|
||||
if (This->bih.bV5Size == sizeof(BITMAPCOREHEADER))
|
||||
|
@ -146,7 +151,7 @@ static HRESULT WINAPI BmpFrameDecode_GetSize(IWICBitmapFrameDecode *iface,
|
|||
static HRESULT WINAPI BmpFrameDecode_GetPixelFormat(IWICBitmapFrameDecode *iface,
|
||||
WICPixelFormatGUID *pPixelFormat)
|
||||
{
|
||||
BmpDecoder *This = impl_from_frame(iface);
|
||||
BmpDecoder *This = impl_from_IWICBitmapFrameDecode(iface);
|
||||
TRACE("(%p,%p)\n", iface, pPixelFormat);
|
||||
|
||||
memcpy(pPixelFormat, This->pixelformat, sizeof(GUID));
|
||||
|
@ -177,7 +182,7 @@ static HRESULT BmpHeader_GetResolution(BITMAPV5HEADER *bih, double *pDpiX, doubl
|
|||
static HRESULT WINAPI BmpFrameDecode_GetResolution(IWICBitmapFrameDecode *iface,
|
||||
double *pDpiX, double *pDpiY)
|
||||
{
|
||||
BmpDecoder *This = impl_from_frame(iface);
|
||||
BmpDecoder *This = impl_from_IWICBitmapFrameDecode(iface);
|
||||
TRACE("(%p,%p,%p)\n", iface, pDpiX, pDpiY);
|
||||
|
||||
return BmpHeader_GetResolution(&This->bih, pDpiX, pDpiY);
|
||||
|
@ -187,7 +192,7 @@ static HRESULT WINAPI BmpFrameDecode_CopyPalette(IWICBitmapFrameDecode *iface,
|
|||
IWICPalette *pIPalette)
|
||||
{
|
||||
HRESULT hr;
|
||||
BmpDecoder *This = impl_from_frame(iface);
|
||||
BmpDecoder *This = impl_from_IWICBitmapFrameDecode(iface);
|
||||
int count;
|
||||
WICColor *wiccolors=NULL;
|
||||
RGBTRIPLE *bgrcolors=NULL;
|
||||
|
@ -299,7 +304,7 @@ end:
|
|||
static HRESULT WINAPI BmpFrameDecode_CopyPixels(IWICBitmapFrameDecode *iface,
|
||||
const WICRect *prc, UINT cbStride, UINT cbBufferSize, BYTE *pbBuffer)
|
||||
{
|
||||
BmpDecoder *This = impl_from_frame(iface);
|
||||
BmpDecoder *This = impl_from_IWICBitmapFrameDecode(iface);
|
||||
HRESULT hr=S_OK;
|
||||
UINT width, height;
|
||||
TRACE("(%p,%p,%u,%u,%p)\n", iface, prc, cbStride, cbBufferSize, pbBuffer);
|
||||
|
@ -403,7 +408,7 @@ static HRESULT BmpFrameDecode_ReadRGB8(BmpDecoder* This)
|
|||
HRESULT hr;
|
||||
UINT width, height;
|
||||
|
||||
hr = IWICBitmapFrameDecode_GetSize((IWICBitmapFrameDecode*)&This->lpFrameVtbl, &width, &height);
|
||||
hr = IWICBitmapFrameDecode_GetSize(&This->IWICBitmapFrameDecode_iface, &width, &height);
|
||||
|
||||
if (SUCCEEDED(hr))
|
||||
{
|
||||
|
@ -954,7 +959,7 @@ static HRESULT BmpDecoder_ReadHeaders(BmpDecoder* This, IStream *stream)
|
|||
static HRESULT WINAPI BmpDecoder_QueryInterface(IWICBitmapDecoder *iface, REFIID iid,
|
||||
void **ppv)
|
||||
{
|
||||
BmpDecoder *This = (BmpDecoder*)iface;
|
||||
BmpDecoder *This = impl_from_IWICBitmapDecoder(iface);
|
||||
TRACE("(%p,%s,%p)\n", iface, debugstr_guid(iid), ppv);
|
||||
|
||||
if (!ppv) return E_INVALIDARG;
|
||||
|
@ -975,7 +980,7 @@ static HRESULT WINAPI BmpDecoder_QueryInterface(IWICBitmapDecoder *iface, REFIID
|
|||
|
||||
static ULONG WINAPI BmpDecoder_AddRef(IWICBitmapDecoder *iface)
|
||||
{
|
||||
BmpDecoder *This = (BmpDecoder*)iface;
|
||||
BmpDecoder *This = impl_from_IWICBitmapDecoder(iface);
|
||||
ULONG ref = InterlockedIncrement(&This->ref);
|
||||
|
||||
TRACE("(%p) refcount=%u\n", iface, ref);
|
||||
|
@ -985,7 +990,7 @@ static ULONG WINAPI BmpDecoder_AddRef(IWICBitmapDecoder *iface)
|
|||
|
||||
static ULONG WINAPI BmpDecoder_Release(IWICBitmapDecoder *iface)
|
||||
{
|
||||
BmpDecoder *This = (BmpDecoder*)iface;
|
||||
BmpDecoder *This = impl_from_IWICBitmapDecoder(iface);
|
||||
ULONG ref = InterlockedDecrement(&This->ref);
|
||||
|
||||
TRACE("(%p) refcount=%u\n", iface, ref);
|
||||
|
@ -1006,7 +1011,7 @@ static HRESULT WINAPI BmpDecoder_QueryCapability(IWICBitmapDecoder *iface, IStre
|
|||
DWORD *pdwCapability)
|
||||
{
|
||||
HRESULT hr;
|
||||
BmpDecoder *This = (BmpDecoder*)iface;
|
||||
BmpDecoder *This = impl_from_IWICBitmapDecoder(iface);
|
||||
|
||||
EnterCriticalSection(&This->lock);
|
||||
hr = BmpDecoder_ReadHeaders(This, pIStream);
|
||||
|
@ -1025,7 +1030,7 @@ static HRESULT WINAPI BmpDecoder_Initialize(IWICBitmapDecoder *iface, IStream *p
|
|||
WICDecodeOptions cacheOptions)
|
||||
{
|
||||
HRESULT hr;
|
||||
BmpDecoder *This = (BmpDecoder*)iface;
|
||||
BmpDecoder *This = impl_from_IWICBitmapDecoder(iface);
|
||||
|
||||
EnterCriticalSection(&This->lock);
|
||||
hr = BmpDecoder_ReadHeaders(This, pIStream);
|
||||
|
@ -1112,13 +1117,13 @@ static HRESULT WINAPI BmpDecoder_GetFrameCount(IWICBitmapDecoder *iface,
|
|||
static HRESULT WINAPI BmpDecoder_GetFrame(IWICBitmapDecoder *iface,
|
||||
UINT index, IWICBitmapFrameDecode **ppIBitmapFrame)
|
||||
{
|
||||
BmpDecoder *This = (BmpDecoder*)iface;
|
||||
BmpDecoder *This = impl_from_IWICBitmapDecoder(iface);
|
||||
|
||||
if (index != 0) return E_INVALIDARG;
|
||||
|
||||
if (!This->stream) return WINCODEC_ERR_WRONGSTATE;
|
||||
|
||||
*ppIBitmapFrame = (IWICBitmapFrameDecode*)&This->lpFrameVtbl;
|
||||
*ppIBitmapFrame = &This->IWICBitmapFrameDecode_iface;
|
||||
IWICBitmapDecoder_AddRef(iface);
|
||||
|
||||
return S_OK;
|
||||
|
@ -1148,8 +1153,8 @@ static HRESULT BmpDecoder_Create(int packed, int icoframe, BmpDecoder **ppDecode
|
|||
This = HeapAlloc(GetProcessHeap(), 0, sizeof(BmpDecoder));
|
||||
if (!This) return E_OUTOFMEMORY;
|
||||
|
||||
This->lpVtbl = &BmpDecoder_Vtbl;
|
||||
This->lpFrameVtbl = &BmpDecoder_FrameVtbl;
|
||||
This->IWICBitmapDecoder_iface.lpVtbl = &BmpDecoder_Vtbl;
|
||||
This->IWICBitmapFrameDecode_iface.lpVtbl = &BmpDecoder_FrameVtbl;
|
||||
This->ref = 1;
|
||||
This->initialized = FALSE;
|
||||
This->stream = NULL;
|
||||
|
@ -1178,8 +1183,8 @@ static HRESULT BmpDecoder_Construct(int packed, int icoframe, IUnknown *pUnkOute
|
|||
ret = BmpDecoder_Create(packed, icoframe, &This);
|
||||
if (FAILED(ret)) return ret;
|
||||
|
||||
ret = IUnknown_QueryInterface((IUnknown*)This, iid, ppv);
|
||||
IUnknown_Release((IUnknown*)This);
|
||||
ret = IWICBitmapDecoder_QueryInterface(&This->IWICBitmapDecoder_iface, iid, ppv);
|
||||
IWICBitmapDecoder_Release(&This->IWICBitmapDecoder_iface);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
@ -1201,7 +1206,7 @@ HRESULT IcoDibDecoder_CreateInstance(BmpDecoder **ppDecoder)
|
|||
|
||||
void BmpDecoder_GetWICDecoder(BmpDecoder *This, IWICBitmapDecoder **ppDecoder)
|
||||
{
|
||||
*ppDecoder = (IWICBitmapDecoder*)This;
|
||||
*ppDecoder = &This->IWICBitmapDecoder_iface;
|
||||
}
|
||||
|
||||
/* Return the offset where the mask of an icon might be, or 0 for failure. */
|
||||
|
@ -1213,7 +1218,7 @@ void BmpDecoder_FindIconMask(BmpDecoder *This, ULONG *mask_offset, int *topdown)
|
|||
{
|
||||
/* RGB or BITFIELDS data */
|
||||
ULONG width, height, bytesperrow, datasize;
|
||||
IWICBitmapFrameDecode_GetSize((IWICBitmapFrameDecode*)&This->lpFrameVtbl, &width, &height);
|
||||
IWICBitmapFrameDecode_GetSize(&This->IWICBitmapFrameDecode_iface, &width, &height);
|
||||
bytesperrow = (((width * This->bitsperpixel)+31)/32)*4;
|
||||
datasize = bytesperrow * height;
|
||||
*mask_offset = This->image_offset + datasize;
|
||||
|
|
Loading…
Reference in New Issue