Commit 34fc8902 authored by Michael Stefaniuc's avatar Michael Stefaniuc Committed by Alexandre Julliard

windowscodecs: Standardize the COM usage in tiffformat.c.

parent 8d8dd3de
...@@ -194,7 +194,7 @@ static TIFF* tiff_open_stream(IStream *stream, const char *mode) ...@@ -194,7 +194,7 @@ static TIFF* tiff_open_stream(IStream *stream, const char *mode)
} }
typedef struct { typedef struct {
const IWICBitmapDecoderVtbl *lpVtbl; IWICBitmapDecoder IWICBitmapDecoder_iface;
LONG ref; LONG ref;
IStream *stream; IStream *stream;
CRITICAL_SECTION lock; /* Must be held when tiff is used or initiailzed is set */ CRITICAL_SECTION lock; /* Must be held when tiff is used or initiailzed is set */
...@@ -218,7 +218,7 @@ typedef struct { ...@@ -218,7 +218,7 @@ typedef struct {
} tiff_decode_info; } tiff_decode_info;
typedef struct { typedef struct {
const IWICBitmapFrameDecodeVtbl *lpVtbl; IWICBitmapFrameDecode IWICBitmapFrameDecode_iface;
LONG ref; LONG ref;
TiffDecoder *parent; TiffDecoder *parent;
UINT index; UINT index;
...@@ -229,6 +229,16 @@ typedef struct { ...@@ -229,6 +229,16 @@ typedef struct {
static const IWICBitmapFrameDecodeVtbl TiffFrameDecode_Vtbl; static const IWICBitmapFrameDecodeVtbl TiffFrameDecode_Vtbl;
static inline TiffDecoder *impl_from_IWICBitmapDecoder(IWICBitmapDecoder *iface)
{
return CONTAINING_RECORD(iface, TiffDecoder, IWICBitmapDecoder_iface);
}
static inline TiffFrameDecode *impl_from_IWICBitmapFrameDecode(IWICBitmapFrameDecode *iface)
{
return CONTAINING_RECORD(iface, TiffFrameDecode, IWICBitmapFrameDecode_iface);
}
static HRESULT tiff_get_decode_info(TIFF *tiff, tiff_decode_info *decode_info) static HRESULT tiff_get_decode_info(TIFF *tiff, tiff_decode_info *decode_info)
{ {
uint16 photometric, bps, samples, planar; uint16 photometric, bps, samples, planar;
...@@ -423,7 +433,7 @@ static HRESULT tiff_get_decode_info(TIFF *tiff, tiff_decode_info *decode_info) ...@@ -423,7 +433,7 @@ static HRESULT tiff_get_decode_info(TIFF *tiff, tiff_decode_info *decode_info)
static HRESULT WINAPI TiffDecoder_QueryInterface(IWICBitmapDecoder *iface, REFIID iid, static HRESULT WINAPI TiffDecoder_QueryInterface(IWICBitmapDecoder *iface, REFIID iid,
void **ppv) void **ppv)
{ {
TiffDecoder *This = (TiffDecoder*)iface; TiffDecoder *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;
...@@ -444,7 +454,7 @@ static HRESULT WINAPI TiffDecoder_QueryInterface(IWICBitmapDecoder *iface, REFII ...@@ -444,7 +454,7 @@ static HRESULT WINAPI TiffDecoder_QueryInterface(IWICBitmapDecoder *iface, REFII
static ULONG WINAPI TiffDecoder_AddRef(IWICBitmapDecoder *iface) static ULONG WINAPI TiffDecoder_AddRef(IWICBitmapDecoder *iface)
{ {
TiffDecoder *This = (TiffDecoder*)iface; TiffDecoder *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);
...@@ -454,7 +464,7 @@ static ULONG WINAPI TiffDecoder_AddRef(IWICBitmapDecoder *iface) ...@@ -454,7 +464,7 @@ static ULONG WINAPI TiffDecoder_AddRef(IWICBitmapDecoder *iface)
static ULONG WINAPI TiffDecoder_Release(IWICBitmapDecoder *iface) static ULONG WINAPI TiffDecoder_Release(IWICBitmapDecoder *iface)
{ {
TiffDecoder *This = (TiffDecoder*)iface; TiffDecoder *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);
...@@ -481,7 +491,7 @@ static HRESULT WINAPI TiffDecoder_QueryCapability(IWICBitmapDecoder *iface, IStr ...@@ -481,7 +491,7 @@ static HRESULT WINAPI TiffDecoder_QueryCapability(IWICBitmapDecoder *iface, IStr
static HRESULT WINAPI TiffDecoder_Initialize(IWICBitmapDecoder *iface, IStream *pIStream, static HRESULT WINAPI TiffDecoder_Initialize(IWICBitmapDecoder *iface, IStream *pIStream,
WICDecodeOptions cacheOptions) WICDecodeOptions cacheOptions)
{ {
TiffDecoder *This = (TiffDecoder*)iface; TiffDecoder *This = impl_from_IWICBitmapDecoder(iface);
TIFF *tiff; TIFF *tiff;
HRESULT hr=S_OK; HRESULT hr=S_OK;
...@@ -565,7 +575,7 @@ static HRESULT WINAPI TiffDecoder_GetThumbnail(IWICBitmapDecoder *iface, ...@@ -565,7 +575,7 @@ static HRESULT WINAPI TiffDecoder_GetThumbnail(IWICBitmapDecoder *iface,
static HRESULT WINAPI TiffDecoder_GetFrameCount(IWICBitmapDecoder *iface, static HRESULT WINAPI TiffDecoder_GetFrameCount(IWICBitmapDecoder *iface,
UINT *pCount) UINT *pCount)
{ {
TiffDecoder *This = (TiffDecoder*)iface; TiffDecoder *This = impl_from_IWICBitmapDecoder(iface);
if (!This->tiff) if (!This->tiff)
{ {
...@@ -586,7 +596,7 @@ static HRESULT WINAPI TiffDecoder_GetFrameCount(IWICBitmapDecoder *iface, ...@@ -586,7 +596,7 @@ static HRESULT WINAPI TiffDecoder_GetFrameCount(IWICBitmapDecoder *iface,
static HRESULT WINAPI TiffDecoder_GetFrame(IWICBitmapDecoder *iface, static HRESULT WINAPI TiffDecoder_GetFrame(IWICBitmapDecoder *iface,
UINT index, IWICBitmapFrameDecode **ppIBitmapFrame) UINT index, IWICBitmapFrameDecode **ppIBitmapFrame)
{ {
TiffDecoder *This = (TiffDecoder*)iface; TiffDecoder *This = impl_from_IWICBitmapDecoder(iface);
TiffFrameDecode *result; TiffFrameDecode *result;
int res; int res;
tiff_decode_info decode_info; tiff_decode_info decode_info;
...@@ -609,7 +619,7 @@ static HRESULT WINAPI TiffDecoder_GetFrame(IWICBitmapDecoder *iface, ...@@ -609,7 +619,7 @@ static HRESULT WINAPI TiffDecoder_GetFrame(IWICBitmapDecoder *iface,
if (result) if (result)
{ {
result->lpVtbl = &TiffFrameDecode_Vtbl; result->IWICBitmapFrameDecode_iface.lpVtbl = &TiffFrameDecode_Vtbl;
result->ref = 1; result->ref = 1;
result->parent = This; result->parent = This;
result->index = index; result->index = index;
...@@ -653,7 +663,7 @@ static const IWICBitmapDecoderVtbl TiffDecoder_Vtbl = { ...@@ -653,7 +663,7 @@ static const IWICBitmapDecoderVtbl TiffDecoder_Vtbl = {
static HRESULT WINAPI TiffFrameDecode_QueryInterface(IWICBitmapFrameDecode *iface, REFIID iid, static HRESULT WINAPI TiffFrameDecode_QueryInterface(IWICBitmapFrameDecode *iface, REFIID iid,
void **ppv) void **ppv)
{ {
TiffFrameDecode *This = (TiffFrameDecode*)iface; TiffFrameDecode *This = impl_from_IWICBitmapFrameDecode(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;
...@@ -676,7 +686,7 @@ static HRESULT WINAPI TiffFrameDecode_QueryInterface(IWICBitmapFrameDecode *ifac ...@@ -676,7 +686,7 @@ static HRESULT WINAPI TiffFrameDecode_QueryInterface(IWICBitmapFrameDecode *ifac
static ULONG WINAPI TiffFrameDecode_AddRef(IWICBitmapFrameDecode *iface) static ULONG WINAPI TiffFrameDecode_AddRef(IWICBitmapFrameDecode *iface)
{ {
TiffFrameDecode *This = (TiffFrameDecode*)iface; TiffFrameDecode *This = impl_from_IWICBitmapFrameDecode(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);
...@@ -686,7 +696,7 @@ static ULONG WINAPI TiffFrameDecode_AddRef(IWICBitmapFrameDecode *iface) ...@@ -686,7 +696,7 @@ static ULONG WINAPI TiffFrameDecode_AddRef(IWICBitmapFrameDecode *iface)
static ULONG WINAPI TiffFrameDecode_Release(IWICBitmapFrameDecode *iface) static ULONG WINAPI TiffFrameDecode_Release(IWICBitmapFrameDecode *iface)
{ {
TiffFrameDecode *This = (TiffFrameDecode*)iface; TiffFrameDecode *This = impl_from_IWICBitmapFrameDecode(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);
...@@ -703,7 +713,7 @@ static ULONG WINAPI TiffFrameDecode_Release(IWICBitmapFrameDecode *iface) ...@@ -703,7 +713,7 @@ static ULONG WINAPI TiffFrameDecode_Release(IWICBitmapFrameDecode *iface)
static HRESULT WINAPI TiffFrameDecode_GetSize(IWICBitmapFrameDecode *iface, static HRESULT WINAPI TiffFrameDecode_GetSize(IWICBitmapFrameDecode *iface,
UINT *puiWidth, UINT *puiHeight) UINT *puiWidth, UINT *puiHeight)
{ {
TiffFrameDecode *This = (TiffFrameDecode*)iface; TiffFrameDecode *This = impl_from_IWICBitmapFrameDecode(iface);
*puiWidth = This->decode_info.width; *puiWidth = This->decode_info.width;
*puiHeight = This->decode_info.height; *puiHeight = This->decode_info.height;
...@@ -716,7 +726,7 @@ static HRESULT WINAPI TiffFrameDecode_GetSize(IWICBitmapFrameDecode *iface, ...@@ -716,7 +726,7 @@ static HRESULT WINAPI TiffFrameDecode_GetSize(IWICBitmapFrameDecode *iface,
static HRESULT WINAPI TiffFrameDecode_GetPixelFormat(IWICBitmapFrameDecode *iface, static HRESULT WINAPI TiffFrameDecode_GetPixelFormat(IWICBitmapFrameDecode *iface,
WICPixelFormatGUID *pPixelFormat) WICPixelFormatGUID *pPixelFormat)
{ {
TiffFrameDecode *This = (TiffFrameDecode*)iface; TiffFrameDecode *This = impl_from_IWICBitmapFrameDecode(iface);
memcpy(pPixelFormat, This->decode_info.format, sizeof(GUID)); memcpy(pPixelFormat, This->decode_info.format, sizeof(GUID));
...@@ -735,7 +745,7 @@ static HRESULT WINAPI TiffFrameDecode_GetResolution(IWICBitmapFrameDecode *iface ...@@ -735,7 +745,7 @@ static HRESULT WINAPI TiffFrameDecode_GetResolution(IWICBitmapFrameDecode *iface
static HRESULT WINAPI TiffFrameDecode_CopyPalette(IWICBitmapFrameDecode *iface, static HRESULT WINAPI TiffFrameDecode_CopyPalette(IWICBitmapFrameDecode *iface,
IWICPalette *pIPalette) IWICPalette *pIPalette)
{ {
TiffFrameDecode *This = (TiffFrameDecode*)iface; TiffFrameDecode *This = impl_from_IWICBitmapFrameDecode(iface);
uint16 *red, *green, *blue; uint16 *red, *green, *blue;
WICColor colors[256]; WICColor colors[256];
int color_count, ret, i; int color_count, ret, i;
...@@ -862,7 +872,7 @@ static HRESULT TiffFrameDecode_ReadTile(TiffFrameDecode *This, UINT tile_x, UINT ...@@ -862,7 +872,7 @@ static HRESULT TiffFrameDecode_ReadTile(TiffFrameDecode *This, UINT tile_x, UINT
static HRESULT WINAPI TiffFrameDecode_CopyPixels(IWICBitmapFrameDecode *iface, static HRESULT WINAPI TiffFrameDecode_CopyPixels(IWICBitmapFrameDecode *iface,
const WICRect *prc, UINT cbStride, UINT cbBufferSize, BYTE *pbBuffer) const WICRect *prc, UINT cbStride, UINT cbBufferSize, BYTE *pbBuffer)
{ {
TiffFrameDecode *This = (TiffFrameDecode*)iface; TiffFrameDecode *This = impl_from_IWICBitmapFrameDecode(iface);
UINT min_tile_x, max_tile_x, min_tile_y, max_tile_y; UINT min_tile_x, max_tile_x, min_tile_y, max_tile_y;
UINT tile_x, tile_y; UINT tile_x, tile_y;
WICRect rc; WICRect rc;
...@@ -1015,7 +1025,7 @@ HRESULT TiffDecoder_CreateInstance(IUnknown *pUnkOuter, REFIID iid, void** ppv) ...@@ -1015,7 +1025,7 @@ HRESULT TiffDecoder_CreateInstance(IUnknown *pUnkOuter, REFIID iid, void** ppv)
This = HeapAlloc(GetProcessHeap(), 0, sizeof(TiffDecoder)); This = HeapAlloc(GetProcessHeap(), 0, sizeof(TiffDecoder));
if (!This) return E_OUTOFMEMORY; if (!This) return E_OUTOFMEMORY;
This->lpVtbl = &TiffDecoder_Vtbl; This->IWICBitmapDecoder_iface.lpVtbl = &TiffDecoder_Vtbl;
This->ref = 1; This->ref = 1;
This->stream = NULL; This->stream = NULL;
InitializeCriticalSection(&This->lock); InitializeCriticalSection(&This->lock);
......
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