[5/5] windowscodecs: Implement IWICBitmapScaler::Initialize.

Vincent Povirk madewokherd at gmail.com
Tue Jun 26 09:35:34 CDT 2012


-------------- next part --------------
From 3d5fd6134dfad24af58f4aed1637e7508773f6aa Mon Sep 17 00:00:00 2001
From: Vincent Povirk <vincent at codeweavers.com>
Date: Tue, 28 Feb 2012 16:20:03 -0600
Subject: [PATCH 05/14] windowscodecs: Implement IWICBitmapScaler::Initialize.

---
 dlls/windowscodecs/scaler.c |   38 ++++++++++++++++++++++++++++++++++++--
 1 file changed, 36 insertions(+), 2 deletions(-)

diff --git a/dlls/windowscodecs/scaler.c b/dlls/windowscodecs/scaler.c
index d3bd1b7..be21dcc 100644
--- a/dlls/windowscodecs/scaler.c
+++ b/dlls/windowscodecs/scaler.c
@@ -36,6 +36,10 @@ WINE_DEFAULT_DEBUG_CHANNEL(wincodecs);
 typedef struct BitmapScaler {
     IWICBitmapScaler IWICBitmapScaler_iface;
     LONG ref;
+    IWICBitmapSource *source;
+    UINT width, height;
+    WICBitmapInterpolationMode mode;
+    CRITICAL_SECTION lock; /* must be held when initialized */
 } BitmapScaler;
 
 static inline BitmapScaler *impl_from_IWICBitmapScaler(IWICBitmapScaler *iface)
@@ -86,6 +90,9 @@ static ULONG WINAPI BitmapScaler_Release(IWICBitmapScaler *iface)
 
     if (ref == 0)
     {
+        This->lock.DebugInfo->Spare[0] = 0;
+        DeleteCriticalSection(&This->lock);
+        if (This->source) IWICBitmapSource_Release(This->source);
         HeapFree(GetProcessHeap(), 0, This);
     }
 
@@ -136,9 +143,30 @@ static HRESULT WINAPI BitmapScaler_Initialize(IWICBitmapScaler *iface,
     IWICBitmapSource *pISource, UINT uiWidth, UINT uiHeight,
     WICBitmapInterpolationMode mode)
 {
-    FIXME("(%p,%p,%u,%u,%u): stub\n", iface, pISource, uiWidth, uiHeight, mode);
+    BitmapScaler *This = impl_from_IWICBitmapScaler(iface);
+    HRESULT hr=S_OK;
 
-    return E_NOTIMPL;
+    TRACE("(%p,%p,%u,%u,%u)\n", iface, pISource, uiWidth, uiHeight, mode);
+
+    EnterCriticalSection(&This->lock);
+
+    if (This->source)
+    {
+        hr = WINCODEC_ERR_WRONGSTATE;
+        goto end;
+    }
+
+    IWICBitmapSource_AddRef(pISource);
+    This->source = pISource;
+
+    This->width = uiWidth;
+    This->height = uiHeight;
+    This->mode = mode;
+
+end:
+    LeaveCriticalSection(&This->lock);
+
+    return hr;
 }
 
 static const IWICBitmapScalerVtbl BitmapScaler_Vtbl = {
@@ -162,6 +190,12 @@ HRESULT BitmapScaler_Create(IWICBitmapScaler **scaler)
 
     This->IWICBitmapScaler_iface.lpVtbl = &BitmapScaler_Vtbl;
     This->ref = 1;
+    This->source = NULL;
+    This->width = 0;
+    This->height = 0;
+    This->mode = 0;
+    InitializeCriticalSection(&This->lock);
+    This->lock.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": BitmapScaler.lock");
 
     *scaler = &This->IWICBitmapScaler_iface;
 
-- 
1.7.9.5


More information about the wine-patches mailing list