Commit 53af9f2b authored by Michael Stefaniuc's avatar Michael Stefaniuc Committed by Alexandre Julliard

windowscodecs: Use ifaces instead of vtbl pointers in PngEncoder.

parent 1b11ffaa
...@@ -803,8 +803,8 @@ static const struct png_pixelformat formats[] = { ...@@ -803,8 +803,8 @@ static const struct png_pixelformat formats[] = {
}; };
typedef struct PngEncoder { typedef struct PngEncoder {
const IWICBitmapEncoderVtbl *lpVtbl; IWICBitmapEncoder IWICBitmapEncoder_iface;
const IWICBitmapFrameEncodeVtbl *lpFrameVtbl; IWICBitmapFrameEncode IWICBitmapFrameEncode_iface;
LONG ref; LONG ref;
IStream *stream; IStream *stream;
png_structp png_ptr; png_structp png_ptr;
...@@ -821,15 +821,20 @@ typedef struct PngEncoder { ...@@ -821,15 +821,20 @@ typedef struct PngEncoder {
CRITICAL_SECTION lock; CRITICAL_SECTION lock;
} PngEncoder; } PngEncoder;
static inline PngEncoder *encoder_from_frame(IWICBitmapFrameEncode *iface) static inline PngEncoder *impl_from_IWICBitmapEncoder(IWICBitmapEncoder *iface)
{ {
return CONTAINING_RECORD(iface, PngEncoder, lpFrameVtbl); return CONTAINING_RECORD(iface, PngEncoder, IWICBitmapEncoder_iface);
}
static inline PngEncoder *impl_from_IWICBitmapFrameEncode(IWICBitmapFrameEncode *iface)
{
return CONTAINING_RECORD(iface, PngEncoder, IWICBitmapFrameEncode_iface);
} }
static HRESULT WINAPI PngFrameEncode_QueryInterface(IWICBitmapFrameEncode *iface, REFIID iid, static HRESULT WINAPI PngFrameEncode_QueryInterface(IWICBitmapFrameEncode *iface, REFIID iid,
void **ppv) void **ppv)
{ {
PngEncoder *This = encoder_from_frame(iface); PngEncoder *This = impl_from_IWICBitmapFrameEncode(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;
...@@ -837,7 +842,7 @@ static HRESULT WINAPI PngFrameEncode_QueryInterface(IWICBitmapFrameEncode *iface ...@@ -837,7 +842,7 @@ static HRESULT WINAPI PngFrameEncode_QueryInterface(IWICBitmapFrameEncode *iface
if (IsEqualIID(&IID_IUnknown, iid) || if (IsEqualIID(&IID_IUnknown, iid) ||
IsEqualIID(&IID_IWICBitmapFrameEncode, iid)) IsEqualIID(&IID_IWICBitmapFrameEncode, iid))
{ {
*ppv = &This->lpFrameVtbl; *ppv = &This->IWICBitmapFrameEncode_iface;
} }
else else
{ {
...@@ -851,20 +856,20 @@ static HRESULT WINAPI PngFrameEncode_QueryInterface(IWICBitmapFrameEncode *iface ...@@ -851,20 +856,20 @@ static HRESULT WINAPI PngFrameEncode_QueryInterface(IWICBitmapFrameEncode *iface
static ULONG WINAPI PngFrameEncode_AddRef(IWICBitmapFrameEncode *iface) static ULONG WINAPI PngFrameEncode_AddRef(IWICBitmapFrameEncode *iface)
{ {
PngEncoder *This = encoder_from_frame(iface); PngEncoder *This = impl_from_IWICBitmapFrameEncode(iface);
return IUnknown_AddRef((IUnknown*)This); return IUnknown_AddRef((IUnknown*)This);
} }
static ULONG WINAPI PngFrameEncode_Release(IWICBitmapFrameEncode *iface) static ULONG WINAPI PngFrameEncode_Release(IWICBitmapFrameEncode *iface)
{ {
PngEncoder *This = encoder_from_frame(iface); PngEncoder *This = impl_from_IWICBitmapFrameEncode(iface);
return IUnknown_Release((IUnknown*)This); return IUnknown_Release((IUnknown*)This);
} }
static HRESULT WINAPI PngFrameEncode_Initialize(IWICBitmapFrameEncode *iface, static HRESULT WINAPI PngFrameEncode_Initialize(IWICBitmapFrameEncode *iface,
IPropertyBag2 *pIEncoderOptions) IPropertyBag2 *pIEncoderOptions)
{ {
PngEncoder *This = encoder_from_frame(iface); PngEncoder *This = impl_from_IWICBitmapFrameEncode(iface);
TRACE("(%p,%p)\n", iface, pIEncoderOptions); TRACE("(%p,%p)\n", iface, pIEncoderOptions);
EnterCriticalSection(&This->lock); EnterCriticalSection(&This->lock);
...@@ -885,7 +890,7 @@ static HRESULT WINAPI PngFrameEncode_Initialize(IWICBitmapFrameEncode *iface, ...@@ -885,7 +890,7 @@ static HRESULT WINAPI PngFrameEncode_Initialize(IWICBitmapFrameEncode *iface,
static HRESULT WINAPI PngFrameEncode_SetSize(IWICBitmapFrameEncode *iface, static HRESULT WINAPI PngFrameEncode_SetSize(IWICBitmapFrameEncode *iface,
UINT uiWidth, UINT uiHeight) UINT uiWidth, UINT uiHeight)
{ {
PngEncoder *This = encoder_from_frame(iface); PngEncoder *This = impl_from_IWICBitmapFrameEncode(iface);
TRACE("(%p,%u,%u)\n", iface, uiWidth, uiHeight); TRACE("(%p,%u,%u)\n", iface, uiWidth, uiHeight);
EnterCriticalSection(&This->lock); EnterCriticalSection(&This->lock);
...@@ -907,7 +912,7 @@ static HRESULT WINAPI PngFrameEncode_SetSize(IWICBitmapFrameEncode *iface, ...@@ -907,7 +912,7 @@ static HRESULT WINAPI PngFrameEncode_SetSize(IWICBitmapFrameEncode *iface,
static HRESULT WINAPI PngFrameEncode_SetResolution(IWICBitmapFrameEncode *iface, static HRESULT WINAPI PngFrameEncode_SetResolution(IWICBitmapFrameEncode *iface,
double dpiX, double dpiY) double dpiX, double dpiY)
{ {
PngEncoder *This = encoder_from_frame(iface); PngEncoder *This = impl_from_IWICBitmapFrameEncode(iface);
TRACE("(%p,%0.2f,%0.2f)\n", iface, dpiX, dpiY); TRACE("(%p,%0.2f,%0.2f)\n", iface, dpiX, dpiY);
EnterCriticalSection(&This->lock); EnterCriticalSection(&This->lock);
...@@ -929,7 +934,7 @@ static HRESULT WINAPI PngFrameEncode_SetResolution(IWICBitmapFrameEncode *iface, ...@@ -929,7 +934,7 @@ static HRESULT WINAPI PngFrameEncode_SetResolution(IWICBitmapFrameEncode *iface,
static HRESULT WINAPI PngFrameEncode_SetPixelFormat(IWICBitmapFrameEncode *iface, static HRESULT WINAPI PngFrameEncode_SetPixelFormat(IWICBitmapFrameEncode *iface,
WICPixelFormatGUID *pPixelFormat) WICPixelFormatGUID *pPixelFormat)
{ {
PngEncoder *This = encoder_from_frame(iface); PngEncoder *This = impl_from_IWICBitmapFrameEncode(iface);
int i; int i;
TRACE("(%p,%s)\n", iface, debugstr_guid(pPixelFormat)); TRACE("(%p,%s)\n", iface, debugstr_guid(pPixelFormat));
...@@ -981,7 +986,7 @@ static HRESULT WINAPI PngFrameEncode_SetThumbnail(IWICBitmapFrameEncode *iface, ...@@ -981,7 +986,7 @@ static HRESULT WINAPI PngFrameEncode_SetThumbnail(IWICBitmapFrameEncode *iface,
static HRESULT WINAPI PngFrameEncode_WritePixels(IWICBitmapFrameEncode *iface, static HRESULT WINAPI PngFrameEncode_WritePixels(IWICBitmapFrameEncode *iface,
UINT lineCount, UINT cbStride, UINT cbBufferSize, BYTE *pbPixels) UINT lineCount, UINT cbStride, UINT cbBufferSize, BYTE *pbPixels)
{ {
PngEncoder *This = encoder_from_frame(iface); PngEncoder *This = impl_from_IWICBitmapFrameEncode(iface);
png_byte **row_pointers=NULL; png_byte **row_pointers=NULL;
UINT i; UINT i;
jmp_buf jmpbuf; jmp_buf jmpbuf;
...@@ -1056,7 +1061,7 @@ static HRESULT WINAPI PngFrameEncode_WritePixels(IWICBitmapFrameEncode *iface, ...@@ -1056,7 +1061,7 @@ static HRESULT WINAPI PngFrameEncode_WritePixels(IWICBitmapFrameEncode *iface,
static HRESULT WINAPI PngFrameEncode_WriteSource(IWICBitmapFrameEncode *iface, static HRESULT WINAPI PngFrameEncode_WriteSource(IWICBitmapFrameEncode *iface,
IWICBitmapSource *pIBitmapSource, WICRect *prc) IWICBitmapSource *pIBitmapSource, WICRect *prc)
{ {
PngEncoder *This = encoder_from_frame(iface); PngEncoder *This = impl_from_IWICBitmapFrameEncode(iface);
HRESULT hr; HRESULT hr;
WICRect rc; WICRect rc;
WICPixelFormatGUID guid; WICPixelFormatGUID guid;
...@@ -1128,7 +1133,7 @@ static HRESULT WINAPI PngFrameEncode_WriteSource(IWICBitmapFrameEncode *iface, ...@@ -1128,7 +1133,7 @@ static HRESULT WINAPI PngFrameEncode_WriteSource(IWICBitmapFrameEncode *iface,
static HRESULT WINAPI PngFrameEncode_Commit(IWICBitmapFrameEncode *iface) static HRESULT WINAPI PngFrameEncode_Commit(IWICBitmapFrameEncode *iface)
{ {
PngEncoder *This = encoder_from_frame(iface); PngEncoder *This = impl_from_IWICBitmapFrameEncode(iface);
jmp_buf jmpbuf; jmp_buf jmpbuf;
TRACE("(%p)\n", iface); TRACE("(%p)\n", iface);
...@@ -1184,7 +1189,7 @@ static const IWICBitmapFrameEncodeVtbl PngEncoder_FrameVtbl = { ...@@ -1184,7 +1189,7 @@ static const IWICBitmapFrameEncodeVtbl PngEncoder_FrameVtbl = {
static HRESULT WINAPI PngEncoder_QueryInterface(IWICBitmapEncoder *iface, REFIID iid, static HRESULT WINAPI PngEncoder_QueryInterface(IWICBitmapEncoder *iface, REFIID iid,
void **ppv) void **ppv)
{ {
PngEncoder *This = (PngEncoder*)iface; PngEncoder *This = impl_from_IWICBitmapEncoder(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;
...@@ -1206,7 +1211,7 @@ static HRESULT WINAPI PngEncoder_QueryInterface(IWICBitmapEncoder *iface, REFIID ...@@ -1206,7 +1211,7 @@ static HRESULT WINAPI PngEncoder_QueryInterface(IWICBitmapEncoder *iface, REFIID
static ULONG WINAPI PngEncoder_AddRef(IWICBitmapEncoder *iface) static ULONG WINAPI PngEncoder_AddRef(IWICBitmapEncoder *iface)
{ {
PngEncoder *This = (PngEncoder*)iface; PngEncoder *This = impl_from_IWICBitmapEncoder(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);
...@@ -1216,7 +1221,7 @@ static ULONG WINAPI PngEncoder_AddRef(IWICBitmapEncoder *iface) ...@@ -1216,7 +1221,7 @@ static ULONG WINAPI PngEncoder_AddRef(IWICBitmapEncoder *iface)
static ULONG WINAPI PngEncoder_Release(IWICBitmapEncoder *iface) static ULONG WINAPI PngEncoder_Release(IWICBitmapEncoder *iface)
{ {
PngEncoder *This = (PngEncoder*)iface; PngEncoder *This = impl_from_IWICBitmapEncoder(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);
...@@ -1255,7 +1260,7 @@ static void user_flush(png_structp png_ptr) ...@@ -1255,7 +1260,7 @@ static void user_flush(png_structp png_ptr)
static HRESULT WINAPI PngEncoder_Initialize(IWICBitmapEncoder *iface, static HRESULT WINAPI PngEncoder_Initialize(IWICBitmapEncoder *iface,
IStream *pIStream, WICBitmapEncoderCacheOption cacheOption) IStream *pIStream, WICBitmapEncoderCacheOption cacheOption)
{ {
PngEncoder *This = (PngEncoder*)iface; PngEncoder *This = impl_from_IWICBitmapEncoder(iface);
jmp_buf jmpbuf; jmp_buf jmpbuf;
TRACE("(%p,%p,%u)\n", iface, pIStream, cacheOption); TRACE("(%p,%p,%u)\n", iface, pIStream, cacheOption);
...@@ -1350,7 +1355,7 @@ static HRESULT WINAPI PngEncoder_SetPreview(IWICBitmapEncoder *iface, IWICBitmap ...@@ -1350,7 +1355,7 @@ static HRESULT WINAPI PngEncoder_SetPreview(IWICBitmapEncoder *iface, IWICBitmap
static HRESULT WINAPI PngEncoder_CreateNewFrame(IWICBitmapEncoder *iface, static HRESULT WINAPI PngEncoder_CreateNewFrame(IWICBitmapEncoder *iface,
IWICBitmapFrameEncode **ppIFrameEncode, IPropertyBag2 **ppIEncoderOptions) IWICBitmapFrameEncode **ppIFrameEncode, IPropertyBag2 **ppIEncoderOptions)
{ {
PngEncoder *This = (PngEncoder*)iface; PngEncoder *This = impl_from_IWICBitmapEncoder(iface);
HRESULT hr; HRESULT hr;
TRACE("(%p,%p,%p)\n", iface, ppIFrameEncode, ppIEncoderOptions); TRACE("(%p,%p,%p)\n", iface, ppIFrameEncode, ppIEncoderOptions);
...@@ -1380,14 +1385,14 @@ static HRESULT WINAPI PngEncoder_CreateNewFrame(IWICBitmapEncoder *iface, ...@@ -1380,14 +1385,14 @@ static HRESULT WINAPI PngEncoder_CreateNewFrame(IWICBitmapEncoder *iface,
LeaveCriticalSection(&This->lock); LeaveCriticalSection(&This->lock);
IWICBitmapEncoder_AddRef(iface); IWICBitmapEncoder_AddRef(iface);
*ppIFrameEncode = (IWICBitmapFrameEncode*)&This->lpFrameVtbl; *ppIFrameEncode = &This->IWICBitmapFrameEncode_iface;
return S_OK; return S_OK;
} }
static HRESULT WINAPI PngEncoder_Commit(IWICBitmapEncoder *iface) static HRESULT WINAPI PngEncoder_Commit(IWICBitmapEncoder *iface)
{ {
PngEncoder *This = (PngEncoder*)iface; PngEncoder *This = impl_from_IWICBitmapEncoder(iface);
TRACE("(%p)\n", iface); TRACE("(%p)\n", iface);
EnterCriticalSection(&This->lock); EnterCriticalSection(&This->lock);
...@@ -1448,8 +1453,8 @@ HRESULT PngEncoder_CreateInstance(IUnknown *pUnkOuter, REFIID iid, void** ppv) ...@@ -1448,8 +1453,8 @@ HRESULT PngEncoder_CreateInstance(IUnknown *pUnkOuter, REFIID iid, void** ppv)
This = HeapAlloc(GetProcessHeap(), 0, sizeof(PngEncoder)); This = HeapAlloc(GetProcessHeap(), 0, sizeof(PngEncoder));
if (!This) return E_OUTOFMEMORY; if (!This) return E_OUTOFMEMORY;
This->lpVtbl = &PngEncoder_Vtbl; This->IWICBitmapEncoder_iface.lpVtbl = &PngEncoder_Vtbl;
This->lpFrameVtbl = &PngEncoder_FrameVtbl; This->IWICBitmapFrameEncode_iface.lpVtbl = &PngEncoder_FrameVtbl;
This->ref = 1; This->ref = 1;
This->png_ptr = NULL; This->png_ptr = NULL;
This->info_ptr = NULL; This->info_ptr = NULL;
......
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