Module: wine Branch: master Commit: a16df86db360d2704d156a1aca881679308e43ac URL: http://source.winehq.org/git/wine.git/?a=commit;h=a16df86db360d2704d156a1aca...
Author: Vincent Povirk vincent@codeweavers.com Date: Mon Jan 10 15:36:14 2011 -0600
windowscodecs: Avoid an iface -> impl conversion from a non-method.
---
dlls/windowscodecs/bmpdecode.c | 49 ++++++++++++++++++++----------- dlls/windowscodecs/icoformat.c | 6 ++- dlls/windowscodecs/wincodecs_private.h | 7 +++- 3 files changed, 40 insertions(+), 22 deletions(-)
diff --git a/dlls/windowscodecs/bmpdecode.c b/dlls/windowscodecs/bmpdecode.c index 04e300d..bd0ace1 100644 --- a/dlls/windowscodecs/bmpdecode.c +++ b/dlls/windowscodecs/bmpdecode.c @@ -59,10 +59,9 @@ typedef struct { DWORD bc2AppData; } BITMAPCOREHEADER2;
-struct BmpDecoder; -typedef HRESULT (*ReadDataFunc)(struct BmpDecoder* This); +typedef HRESULT (*ReadDataFunc)(BmpDecoder* This);
-typedef struct BmpDecoder { +struct BmpDecoder { const IWICBitmapDecoderVtbl *lpVtbl; const IWICBitmapFrameDecodeVtbl *lpFrameVtbl; LONG ref; @@ -80,7 +79,7 @@ typedef struct BmpDecoder { CRITICAL_SECTION lock; /* must be held when initialized/imagedata is set or stream is accessed */ int packed; /* If TRUE, don't look for a file header and assume a packed DIB. */ int icoframe; /* If TRUE, this is a frame of a .ico file. */ -} BmpDecoder; +};
static inline BmpDecoder *impl_from_frame(IWICBitmapFrameDecode *iface) { @@ -1142,16 +1141,9 @@ static const IWICBitmapDecoderVtbl BmpDecoder_Vtbl = { BmpDecoder_GetFrame };
-static HRESULT BmpDecoder_Construct(int packed, int icoframe, IUnknown *pUnkOuter, REFIID iid, void** ppv) +static HRESULT BmpDecoder_Create(int packed, int icoframe, BmpDecoder **ppDecoder) { BmpDecoder *This; - HRESULT ret; - - TRACE("(%p,%s,%p)\n", pUnkOuter, debugstr_guid(iid), ppv); - - *ppv = NULL; - - if (pUnkOuter) return CLASS_E_NOAGGREGATION;
This = HeapAlloc(GetProcessHeap(), 0, sizeof(BmpDecoder)); if (!This) return E_OUTOFMEMORY; @@ -1167,6 +1159,25 @@ static HRESULT BmpDecoder_Construct(int packed, int icoframe, IUnknown *pUnkOute This->packed = packed; This->icoframe = icoframe;
+ *ppDecoder = This; + + return S_OK; +} + +static HRESULT BmpDecoder_Construct(int packed, int icoframe, IUnknown *pUnkOuter, REFIID iid, void** ppv) +{ + BmpDecoder *This; + HRESULT ret; + + TRACE("(%p,%s,%p)\n", pUnkOuter, debugstr_guid(iid), ppv); + + *ppv = NULL; + + if (pUnkOuter) return CLASS_E_NOAGGREGATION; + + ret = BmpDecoder_Create(packed, icoframe, &This); + if (FAILED(ret)) return ret; + ret = IUnknown_QueryInterface((IUnknown*)This, iid, ppv); IUnknown_Release((IUnknown*)This);
@@ -1183,17 +1194,19 @@ HRESULT DibDecoder_CreateInstance(IUnknown *pUnkOuter, REFIID iid, void** ppv) return BmpDecoder_Construct(TRUE, FALSE, pUnkOuter, iid, ppv); }
-HRESULT IcoDibDecoder_CreateInstance(IUnknown *pUnkOuter, REFIID iid, void** ppv) +HRESULT IcoDibDecoder_CreateInstance(BmpDecoder **ppDecoder) { - return BmpDecoder_Construct(TRUE, TRUE, pUnkOuter, iid, ppv); + return BmpDecoder_Create(TRUE, TRUE, ppDecoder); }
-/* Return the offset where the mask of an icon might be, or 0 for failure. */ -void BmpDecoder_FindIconMask(IWICBitmapDecoder *decoder, ULONG *mask_offset, int *topdown) +void BmpDecoder_GetWICDecoder(BmpDecoder *This, IWICBitmapDecoder **ppDecoder) { - BmpDecoder *This = (BmpDecoder*)decoder; + *ppDecoder = (IWICBitmapDecoder*)This; +}
- assert(This->lpVtbl == &BmpDecoder_Vtbl); +/* Return the offset where the mask of an icon might be, or 0 for failure. */ +void BmpDecoder_FindIconMask(BmpDecoder *This, ULONG *mask_offset, int *topdown) +{ assert(This->stream != NULL);
if (This->read_data_func == BmpFrameDecode_ReadUncompressed) diff --git a/dlls/windowscodecs/icoformat.c b/dlls/windowscodecs/icoformat.c index 1e939d7..de6ebe6 100644 --- a/dlls/windowscodecs/icoformat.c +++ b/dlls/windowscodecs/icoformat.c @@ -220,6 +220,7 @@ static inline void pixel_set_trans(DWORD* pixel, BOOL transparent) static HRESULT ReadIcoDib(IStream *stream, IcoFrameDecode *result) { HRESULT hr; + BmpDecoder *bmp_decoder; IWICBitmapDecoder *decoder; IWICBitmapFrameDecode *framedecode; WICPixelFormatGUID pixelformat; @@ -227,9 +228,10 @@ static HRESULT ReadIcoDib(IStream *stream, IcoFrameDecode *result) int has_alpha=FALSE; /* if TRUE, alpha data might be in the image data */ WICRect rc;
- hr = IcoDibDecoder_CreateInstance(NULL, &IID_IWICBitmapDecoder, (void**)&decoder); + hr = IcoDibDecoder_CreateInstance(&bmp_decoder); if (SUCCEEDED(hr)) { + BmpDecoder_GetWICDecoder(bmp_decoder, &decoder); hr = IWICBitmapDecoder_Initialize(decoder, stream, WICDecodeMetadataCacheOnLoad);
if (SUCCEEDED(hr)) @@ -317,7 +319,7 @@ static HRESULT ReadIcoDib(IStream *stream, IcoFrameDecode *result) LARGE_INTEGER seek; int topdown;
- BmpDecoder_FindIconMask(decoder, &offset, &topdown); + BmpDecoder_FindIconMask(bmp_decoder, &offset, &topdown);
if (offset) { diff --git a/dlls/windowscodecs/wincodecs_private.h b/dlls/windowscodecs/wincodecs_private.h index 3c416b0..fc2d17c 100644 --- a/dlls/windowscodecs/wincodecs_private.h +++ b/dlls/windowscodecs/wincodecs_private.h @@ -40,7 +40,6 @@ extern HRESULT JpegDecoder_CreateInstance(IUnknown *pUnkOuter, REFIID iid, void* extern HRESULT TiffDecoder_CreateInstance(IUnknown *pUnkOuter, REFIID iid, void** ppv); extern HRESULT IcnsEncoder_CreateInstance(IUnknown *pUnkOuter, REFIID iid, void** ppv);
-extern HRESULT IcoDibDecoder_CreateInstance(IUnknown *pUnkOuter, REFIID iid, void** ppv); extern HRESULT TgaDecoder_CreateInstance(IUnknown *pUnkOuter, REFIID iid, void** ppv);
extern HRESULT FlipRotator_Create(IWICBitmapFlipRotator **fliprotator); @@ -58,6 +57,10 @@ extern HRESULT CreatePropertyBag2(IPropertyBag2 **ppPropertyBag2); extern HRESULT CreateComponentInfo(REFCLSID clsid, IWICComponentInfo **ppIInfo); extern HRESULT CreateComponentEnumerator(DWORD componentTypes, DWORD options, IEnumUnknown **ppIEnumUnknown);
-void BmpDecoder_FindIconMask(IWICBitmapDecoder *decoder, ULONG *mask_offset, int *topdown); +typedef struct BmpDecoder BmpDecoder; + +extern HRESULT IcoDibDecoder_CreateInstance(BmpDecoder **ppDecoder); +extern void BmpDecoder_GetWICDecoder(BmpDecoder *This, IWICBitmapDecoder **ppDecoder); +extern void BmpDecoder_FindIconMask(BmpDecoder *This, ULONG *mask_offset, int *topdown);
#endif /* WINCODECS_PRIVATE_H */