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