From dbdf1ef8b64fc9705665b5e141c42e627764d6aa Mon Sep 17 00:00:00 2001 From: Vincent Povirk Date: Tue, 27 Apr 2010 11:40:25 -0500 Subject: [PATCH] windowscodecs: Implement IWICBitmapFlipRotator_Initialize. --- dlls/windowscodecs/fliprotate.c | 48 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 46 insertions(+), 2 deletions(-) diff --git a/dlls/windowscodecs/fliprotate.c b/dlls/windowscodecs/fliprotate.c index 19a00ded259..6db7fea4a6a 100644 --- a/dlls/windowscodecs/fliprotate.c +++ b/dlls/windowscodecs/fliprotate.c @@ -36,6 +36,10 @@ WINE_DEFAULT_DEBUG_CHANNEL(wincodecs); typedef struct FlipRotator { const IWICBitmapFlipRotatorVtbl *lpVtbl; LONG ref; + IWICBitmapSource *source; + int flip_x; + int flip_y; + int swap_xy; CRITICAL_SECTION lock; /* must be held when initialized */ } FlipRotator; @@ -84,6 +88,7 @@ static ULONG WINAPI FlipRotator_Release(IWICBitmapFlipRotator *iface) { This->lock.DebugInfo->Spare[0] = 0; DeleteCriticalSection(&This->lock); + if (This->source) IWICBitmapSource_Release(This->source); HeapFree(GetProcessHeap(), 0, This); } @@ -132,9 +137,44 @@ static HRESULT WINAPI FlipRotator_CopyPixels(IWICBitmapFlipRotator *iface, static HRESULT WINAPI FlipRotator_Initialize(IWICBitmapFlipRotator *iface, IWICBitmapSource *pISource, WICBitmapTransformOptions options) { - FIXME("(%p,%p,%u): stub\n", iface, pISource, options); + FlipRotator *This = (FlipRotator*)iface; + HRESULT hr=S_OK; - return E_NOTIMPL; + TRACE("(%p,%p,%u)\n", iface, pISource, options); + + EnterCriticalSection(&This->lock); + + if (This->source) + { + hr = WINCODEC_ERR_WRONGSTATE; + goto end; + } + + if (options&WICBitmapTransformRotate90) + { + This->swap_xy = 1; + This->flip_x = !This->flip_x; + } + + if (options&WICBitmapTransformRotate180) + { + This->flip_x = !This->flip_x; + This->flip_y = !This->flip_y; + } + + if (options&WICBitmapTransformFlipHorizontal) + This->flip_x = !This->flip_x; + + if (options&WICBitmapTransformFlipVertical) + This->flip_y = !This->flip_y; + + IWICBitmapSource_AddRef(pISource); + This->source = pISource; + +end: + LeaveCriticalSection(&This->lock); + + return hr; } static const IWICBitmapFlipRotatorVtbl FlipRotator_Vtbl = { @@ -158,6 +198,10 @@ HRESULT FlipRotator_Create(IWICBitmapFlipRotator **fliprotator) This->lpVtbl = &FlipRotator_Vtbl; This->ref = 1; + This->source = NULL; + This->flip_x = 0; + This->flip_y = 0; + This->swap_xy = 0; InitializeCriticalSection(&This->lock); This->lock.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": FlipRotator.lock"); -- 2.11.4.GIT