2 * Copyright 2010 Vincent Povirk for CodeWeavers
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
30 #include "wincodecs_private.h"
32 #include "wine/debug.h"
34 WINE_DEFAULT_DEBUG_CHANNEL(wincodecs
);
36 typedef struct FlipRotator
{
37 const IWICBitmapFlipRotatorVtbl
*lpVtbl
;
39 IWICBitmapSource
*source
;
43 CRITICAL_SECTION lock
; /* must be held when initialized */
46 static HRESULT WINAPI
FlipRotator_QueryInterface(IWICBitmapFlipRotator
*iface
, REFIID iid
,
49 FlipRotator
*This
= (FlipRotator
*)iface
;
50 TRACE("(%p,%s,%p)\n", iface
, debugstr_guid(iid
), ppv
);
52 if (!ppv
) return E_INVALIDARG
;
54 if (IsEqualIID(&IID_IUnknown
, iid
) ||
55 IsEqualIID(&IID_IWICBitmapSource
, iid
) ||
56 IsEqualIID(&IID_IWICBitmapFlipRotator
, iid
))
66 IUnknown_AddRef((IUnknown
*)*ppv
);
70 static ULONG WINAPI
FlipRotator_AddRef(IWICBitmapFlipRotator
*iface
)
72 FlipRotator
*This
= (FlipRotator
*)iface
;
73 ULONG ref
= InterlockedIncrement(&This
->ref
);
75 TRACE("(%p) refcount=%u\n", iface
, ref
);
80 static ULONG WINAPI
FlipRotator_Release(IWICBitmapFlipRotator
*iface
)
82 FlipRotator
*This
= (FlipRotator
*)iface
;
83 ULONG ref
= InterlockedDecrement(&This
->ref
);
85 TRACE("(%p) refcount=%u\n", iface
, ref
);
89 This
->lock
.DebugInfo
->Spare
[0] = 0;
90 DeleteCriticalSection(&This
->lock
);
91 if (This
->source
) IWICBitmapSource_Release(This
->source
);
92 HeapFree(GetProcessHeap(), 0, This
);
98 static HRESULT WINAPI
FlipRotator_GetSize(IWICBitmapFlipRotator
*iface
,
99 UINT
*puiWidth
, UINT
*puiHeight
)
101 FIXME("(%p,%p,%p): stub\n", iface
, puiWidth
, puiHeight
);
106 static HRESULT WINAPI
FlipRotator_GetPixelFormat(IWICBitmapFlipRotator
*iface
,
107 WICPixelFormatGUID
*pPixelFormat
)
109 FIXME("(%p,%p): stub\n", iface
, pPixelFormat
);
114 static HRESULT WINAPI
FlipRotator_GetResolution(IWICBitmapFlipRotator
*iface
,
115 double *pDpiX
, double *pDpiY
)
117 FIXME("(%p,%p,%p): stub\n", iface
, pDpiX
, pDpiY
);
122 static HRESULT WINAPI
FlipRotator_CopyPalette(IWICBitmapFlipRotator
*iface
,
123 IWICPalette
*pIPalette
)
125 FIXME("(%p,%p): stub\n", iface
, pIPalette
);
129 static HRESULT WINAPI
FlipRotator_CopyPixels(IWICBitmapFlipRotator
*iface
,
130 const WICRect
*prc
, UINT cbStride
, UINT cbBufferSize
, BYTE
*pbBuffer
)
132 FIXME("(%p,%p,%u,%u,%p): stub\n", iface
, prc
, cbStride
, cbBufferSize
, pbBuffer
);
137 static HRESULT WINAPI
FlipRotator_Initialize(IWICBitmapFlipRotator
*iface
,
138 IWICBitmapSource
*pISource
, WICBitmapTransformOptions options
)
140 FlipRotator
*This
= (FlipRotator
*)iface
;
143 TRACE("(%p,%p,%u)\n", iface
, pISource
, options
);
145 EnterCriticalSection(&This
->lock
);
149 hr
= WINCODEC_ERR_WRONGSTATE
;
153 if (options
&WICBitmapTransformRotate90
)
156 This
->flip_x
= !This
->flip_x
;
159 if (options
&WICBitmapTransformRotate180
)
161 This
->flip_x
= !This
->flip_x
;
162 This
->flip_y
= !This
->flip_y
;
165 if (options
&WICBitmapTransformFlipHorizontal
)
166 This
->flip_x
= !This
->flip_x
;
168 if (options
&WICBitmapTransformFlipVertical
)
169 This
->flip_y
= !This
->flip_y
;
171 IWICBitmapSource_AddRef(pISource
);
172 This
->source
= pISource
;
175 LeaveCriticalSection(&This
->lock
);
180 static const IWICBitmapFlipRotatorVtbl FlipRotator_Vtbl
= {
181 FlipRotator_QueryInterface
,
185 FlipRotator_GetPixelFormat
,
186 FlipRotator_GetResolution
,
187 FlipRotator_CopyPalette
,
188 FlipRotator_CopyPixels
,
189 FlipRotator_Initialize
192 HRESULT
FlipRotator_Create(IWICBitmapFlipRotator
**fliprotator
)
196 This
= HeapAlloc(GetProcessHeap(), 0, sizeof(FlipRotator
));
197 if (!This
) return E_OUTOFMEMORY
;
199 This
->lpVtbl
= &FlipRotator_Vtbl
;
205 InitializeCriticalSection(&This
->lock
);
206 This
->lock
.DebugInfo
->Spare
[0] = (DWORD_PTR
)(__FILE__
": FlipRotator.lock");
208 *fliprotator
= (IWICBitmapFlipRotator
*)This
;