UINT count;
WICColor *colors;
WICBitmapPaletteType type;
+ CRITICAL_SECTION lock; /* must be held when count, colors, or type is accessed */
} PaletteImpl;
static HRESULT WINAPI PaletteImpl_QueryInterface(IWICPalette *iface, REFIID iid,
if (ref == 0)
{
+ This->lock.DebugInfo->Spare[0] = 0;
+ DeleteCriticalSection(&This->lock);
HeapFree(GetProcessHeap(), 0, This->colors);
HeapFree(GetProcessHeap(), 0, This);
}
memcpy(new_colors, pColors, sizeof(WICColor) * colorCount);
}
+ EnterCriticalSection(&This->lock);
HeapFree(GetProcessHeap(), 0, This->colors);
This->colors = new_colors;
This->count = colorCount;
This->type = WICBitmapPaletteTypeCustom;
+ LeaveCriticalSection(&This->lock);
return S_OK;
}
if (!pePaletteType) return E_INVALIDARG;
+ EnterCriticalSection(&This->lock);
*pePaletteType = This->type;
+ LeaveCriticalSection(&This->lock);
return S_OK;
}
if (!pcCount) return E_INVALIDARG;
+ EnterCriticalSection(&This->lock);
*pcCount = This->count;
+ LeaveCriticalSection(&This->lock);
return S_OK;
}
if (!pColors || !pcActualColors) return E_INVALIDARG;
+ EnterCriticalSection(&This->lock);
+
if (This->count < colorCount) colorCount = This->count;
memcpy(pColors, This->colors, sizeof(WICColor) * colorCount);
*pcActualColors = colorCount;
+ LeaveCriticalSection(&This->lock);
+
return S_OK;
}
if (!pfIsBlackWhite) return E_INVALIDARG;
+ EnterCriticalSection(&This->lock);
if (This->type == WICBitmapPaletteTypeFixedBW)
*pfIsBlackWhite = TRUE;
else
*pfIsBlackWhite = FALSE;
+ LeaveCriticalSection(&This->lock);
return S_OK;
}
if (!pfIsGrayscale) return E_INVALIDARG;
+ EnterCriticalSection(&This->lock);
switch(This->type)
{
case WICBitmapPaletteTypeFixedBW:
default:
*pfIsGrayscale = FALSE;
}
+ LeaveCriticalSection(&This->lock);
return S_OK;
}
*pfHasAlpha = FALSE;
+ EnterCriticalSection(&This->lock);
for (i=0; i<This->count; i++)
if ((This->colors[i]&0xff000000) != 0xff000000)
{
*pfHasAlpha = TRUE;
break;
}
+ LeaveCriticalSection(&This->lock);
return S_OK;
}
This->count = 0;
This->colors = NULL;
This->type = WICBitmapPaletteTypeCustom;
+ InitializeCriticalSection(&This->lock);
+ This->lock.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": PaletteImpl.lock");
*palette = (IWICPalette*)This;