/***************************************************************************** * IDirectDrawPaletteImpl::AddRef * * Increases the refcount. * * Returns: * The new refcount * *****************************************************************************/ static ULONG WINAPI ddraw_palette_AddRef(IDirectDrawPalette *iface) { struct ddraw_palette *This = impl_from_IDirectDrawPalette(iface); ULONG ref = InterlockedIncrement(&This->ref); TRACE("%p increasing refcount to %u.\n", This, ref); return ref; }
static HRESULT WINAPI ddraw_palette_GetCaps(IDirectDrawPalette *iface, DWORD *caps) { struct ddraw_palette *palette = impl_from_IDirectDrawPalette(iface); TRACE("iface %p, caps %p.\n", iface, caps); wined3d_mutex_lock(); *caps = palette->flags; wined3d_mutex_unlock(); return D3D_OK; }
/***************************************************************************** * IDirectDrawPalette::GetCaps * * Returns the palette description * * Params: * Caps: Address to store the caps at * * Returns: * D3D_OK on success * DDERR_INVALIDPARAMS if Caps is NULL * For more details, see IWineD3DPalette::GetCaps * *****************************************************************************/ static HRESULT WINAPI IDirectDrawPaletteImpl_GetCaps(IDirectDrawPalette *iface, DWORD *Caps) { IDirectDrawPaletteImpl *This = impl_from_IDirectDrawPalette(iface); TRACE("iface %p, caps %p.\n", iface, Caps); EnterCriticalSection(&ddraw_cs); *Caps = wined3d_palette_get_flags(This->wineD3DPalette); LeaveCriticalSection(&ddraw_cs); return D3D_OK; }
/***************************************************************************** * IDirectDrawPalette::GetEntries * * Returns the entries stored in this interface. * * Params: * Flags: Flags :) * Start: First entry to return * Count: The number of entries to return * PalEnt: PALETTEENTRY structure to write the entries to * * Returns: * D3D_OK on success * DDERR_INVALIDPARAMS if PalEnt is NULL * For details, see IWineD3DDevice::SetEntries * *****************************************************************************/ static HRESULT WINAPI ddraw_palette_GetEntries(IDirectDrawPalette *iface, DWORD flags, DWORD start, DWORD count, PALETTEENTRY *entries) { struct ddraw_palette *palette = impl_from_IDirectDrawPalette(iface); HRESULT hr; TRACE("iface %p, flags %#x, start %u, count %u, entries %p.\n", iface, flags, start, count, entries); if (!entries) return DDERR_INVALIDPARAMS; wined3d_mutex_lock(); hr = wined3d_palette_get_entries(palette->wined3d_palette, flags, start, count, entries); wined3d_mutex_unlock(); return hr; }
/***************************************************************************** * IDirectDrawPalette::GetEntries * * Returns the entries stored in this interface. * * Params: * Flags: Flags :) * Start: First entry to return * Count: The number of entries to return * PalEnt: PALETTEENTRY structure to write the entries to * * Returns: * D3D_OK on success * DDERR_INVALIDPARAMS if PalEnt is NULL * For details, see IWineD3DDevice::SetEntries * *****************************************************************************/ static HRESULT WINAPI IDirectDrawPaletteImpl_GetEntries(IDirectDrawPalette *iface, DWORD Flags, DWORD Start, DWORD Count, PALETTEENTRY *PalEnt) { IDirectDrawPaletteImpl *This = impl_from_IDirectDrawPalette(iface); HRESULT hr; TRACE("iface %p, flags %#x, start %u, count %u, entries %p.\n", iface, Flags, Start, Count, PalEnt); if(!PalEnt) return DDERR_INVALIDPARAMS; EnterCriticalSection(&ddraw_cs); hr = wined3d_palette_get_entries(This->wineD3DPalette, Flags, Start, Count, PalEnt); LeaveCriticalSection(&ddraw_cs); return hr; }
/***************************************************************************** * IDirectDrawPaletteImpl::Release * * Reduces the refcount. If the refcount falls to 0, the object is destroyed * * Returns: * The new refcount * *****************************************************************************/ static ULONG WINAPI ddraw_palette_Release(IDirectDrawPalette *iface) { struct ddraw_palette *palette = impl_from_IDirectDrawPalette(iface); ULONG ref = InterlockedDecrement(&palette->ref); TRACE("%p decreasing refcount to %u.\n", palette, ref); if (ref == 0) { wined3d_mutex_lock(); wined3d_palette_decref(palette->wined3d_palette); if ((palette->flags & DDPCAPS_PRIMARYSURFACE) && palette->ddraw->primary) palette->ddraw->primary->palette = NULL; if (palette->ifaceToRelease) IUnknown_Release(palette->ifaceToRelease); wined3d_mutex_unlock(); HeapFree(GetProcessHeap(), 0, palette); } return ref; }
/***************************************************************************** * IDirectDrawPalette::SetEntries * * Sets the palette entries from a PALETTEENTRY structure. WineD3D takes * care for updating the surface. * * Params: * Flags: Flags, as usual * Start: First palette entry to set * Count: Number of entries to set * PalEnt: Source entries * * Returns: * D3D_OK on success * DDERR_INVALIDPARAMS if PalEnt is NULL * For details, see IWineD3DDevice::SetEntries * *****************************************************************************/ static HRESULT WINAPI ddraw_palette_SetEntries(IDirectDrawPalette *iface, DWORD flags, DWORD start, DWORD count, PALETTEENTRY *entries) { struct ddraw_palette *palette = impl_from_IDirectDrawPalette(iface); HRESULT hr; TRACE("iface %p, flags %#x, start %u, count %u, entries %p.\n", iface, flags, start, count, entries); if (!entries) return DDERR_INVALIDPARAMS; wined3d_mutex_lock(); hr = wined3d_palette_set_entries(palette->wined3d_palette, flags, start, count, entries); if (SUCCEEDED(hr) && palette->flags & DDPCAPS_PRIMARYSURFACE) ddraw_surface_update_frontbuffer(palette->ddraw->primary, NULL, FALSE); wined3d_mutex_unlock(); return hr; }
/***************************************************************************** * IDirectDrawPaletteImpl::Release * * Reduces the refcount. If the refcount falls to 0, the object is destroyed * * Returns: * The new refcount * *****************************************************************************/ static ULONG WINAPI IDirectDrawPaletteImpl_Release(IDirectDrawPalette *iface) { IDirectDrawPaletteImpl *This = impl_from_IDirectDrawPalette(iface); ULONG ref = InterlockedDecrement(&This->ref); TRACE("%p decreasing refcount to %u.\n", This, ref); if (ref == 0) { EnterCriticalSection(&ddraw_cs); wined3d_palette_decref(This->wineD3DPalette); if(This->ifaceToRelease) { IUnknown_Release(This->ifaceToRelease); } LeaveCriticalSection(&ddraw_cs); HeapFree(GetProcessHeap(), 0, This); } return ref; }