ReactOS  0.4.13-dev-249-gcba1a2f
palette.c File Reference
#include "config.h"
#include "wine/port.h"
#include "ddraw_private.h"
Include dependency graph for palette.c:

Go to the source code of this file.

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (ddraw)
 
static HRESULT WINAPI ddraw_palette_QueryInterface (IDirectDrawPalette *iface, REFIID refiid, void **obj)
 
static ULONG WINAPI ddraw_palette_AddRef (IDirectDrawPalette *iface)
 
static ULONG WINAPI ddraw_palette_Release (IDirectDrawPalette *iface)
 
static HRESULT WINAPI ddraw_palette_Initialize (IDirectDrawPalette *iface, IDirectDraw *ddraw, DWORD flags, PALETTEENTRY *entries)
 
static HRESULT WINAPI ddraw_palette_GetCaps (IDirectDrawPalette *iface, DWORD *caps)
 
static HRESULT WINAPI ddraw_palette_SetEntries (IDirectDrawPalette *iface, DWORD flags, DWORD start, DWORD count, PALETTEENTRY *entries)
 
static HRESULT WINAPI ddraw_palette_GetEntries (IDirectDrawPalette *iface, DWORD flags, DWORD start, DWORD count, PALETTEENTRY *entries)
 
struct ddraw_paletteunsafe_impl_from_IDirectDrawPalette (IDirectDrawPalette *iface)
 
static unsigned int palette_size (DWORD flags)
 
HRESULT ddraw_palette_init (struct ddraw_palette *palette, struct ddraw *ddraw, DWORD flags, PALETTEENTRY *entries)
 

Variables

static const struct IDirectDrawPaletteVtbl ddraw_palette_vtbl
 

Function Documentation

◆ ddraw_palette_AddRef()

static ULONG WINAPI ddraw_palette_AddRef ( IDirectDrawPalette *  iface)
static

Definition at line 67 of file palette.c.

68 {
71 
72  TRACE("%p increasing refcount to %u.\n", This, ref);
73 
74  return ref;
75 }
Definition: send.c:47
GLenum GLint ref
Definition: glext.h:6028
#define TRACE(s)
Definition: solgame.cpp:4
#define InterlockedIncrement
Definition: armddk.h:53
static struct ddraw_palette * impl_from_IDirectDrawPalette(IDirectDrawPalette *iface)
unsigned int ULONG
Definition: retypes.h:1

◆ ddraw_palette_GetCaps()

static HRESULT WINAPI ddraw_palette_GetCaps ( IDirectDrawPalette *  iface,
DWORD caps 
)
static

Definition at line 133 of file palette.c.

134 {
136 
137  TRACE("iface %p, caps %p.\n", iface, caps);
138 
140  *caps = palette->flags;
142 
143  return D3D_OK;
144 }
void WINAPI wined3d_mutex_lock(void)
Definition: wined3d_main.c:360
#define TRACE(s)
Definition: solgame.cpp:4
static HPALETTE palette
Definition: clipboard.c:1345
#define D3D_OK
Definition: d3d.h:106
static struct ddraw_palette * impl_from_IDirectDrawPalette(IDirectDrawPalette *iface)
void WINAPI wined3d_mutex_unlock(void)
Definition: wined3d_main.c:365

◆ ddraw_palette_GetEntries()

static HRESULT WINAPI ddraw_palette_GetEntries ( IDirectDrawPalette *  iface,
DWORD  flags,
DWORD  start,
DWORD  count,
PALETTEENTRY entries 
)
static

Definition at line 202 of file palette.c.

204 {
206  HRESULT hr;
207 
208  TRACE("iface %p, flags %#x, start %u, count %u, entries %p.\n",
209  iface, flags, start, count, entries);
210 
211  if (!entries)
212  return DDERR_INVALIDPARAMS;
213 
215  hr = wined3d_palette_get_entries(palette->wined3d_palette, flags, start, count, entries);
217 
218  return hr;
219 }
HRESULT CDECL wined3d_palette_get_entries(const struct wined3d_palette *palette, DWORD flags, DWORD start, DWORD count, PALETTEENTRY *entries)
Definition: palette.c:53
HRESULT hr
Definition: shlfolder.c:183
GLuint GLuint GLsizei count
Definition: gl.h:1545
void WINAPI wined3d_mutex_lock(void)
Definition: wined3d_main.c:360
#define TRACE(s)
Definition: solgame.cpp:4
LONG HRESULT
Definition: typedefs.h:77
GLbitfield flags
Definition: glext.h:7161
static HPALETTE palette
Definition: clipboard.c:1345
GLuint start
Definition: gl.h:1545
static struct ddraw_palette * impl_from_IDirectDrawPalette(IDirectDrawPalette *iface)
void WINAPI wined3d_mutex_unlock(void)
Definition: wined3d_main.c:365
#define DDERR_INVALIDPARAMS
Definition: ddraw.h:79

◆ ddraw_palette_init()

HRESULT ddraw_palette_init ( struct ddraw_palette palette,
struct ddraw ddraw,
DWORD  flags,
PALETTEENTRY entries 
)

Definition at line 258 of file palette.c.

260 {
261  unsigned int entry_count;
262  DWORD wined3d_flags = 0;
263  HRESULT hr;
264 
265  if ((entry_count = palette_size(flags)) == ~0u)
266  {
267  WARN("Invalid flags %#x.\n", flags);
268  return DDERR_INVALIDPARAMS;
269  }
270 
272  wined3d_flags |= WINED3D_PALETTE_8BIT_ENTRIES;
273  if (flags & DDPCAPS_ALLOW256)
274  wined3d_flags |= WINED3D_PALETTE_ALLOW_256;
275  if (flags & DDPCAPS_ALPHA)
276  wined3d_flags |= WINED3D_PALETTE_ALPHA;
277 
278  palette->IDirectDrawPalette_iface.lpVtbl = &ddraw_palette_vtbl;
279  palette->ref = 1;
280  palette->flags = flags;
281 
283  wined3d_flags, entry_count, entries, &palette->wined3d_palette)))
284  {
285  WARN("Failed to create wined3d palette, hr %#x.\n", hr);
286  return hr;
287  }
288 
289  palette->ddraw = ddraw;
290  palette->ifaceToRelease = (IUnknown *)&ddraw->IDirectDraw7_iface;
291  IUnknown_AddRef(palette->ifaceToRelease);
292 
293  return DD_OK;
294 }
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble * u
Definition: glfuncs.h:240
#define WINED3D_PALETTE_ALPHA
Definition: wined3d.h:1556
#define WINED3D_PALETTE_8BIT_ENTRIES
Definition: wined3d.h:1554
HRESULT hr
Definition: shlfolder.c:183
#define WARN(fmt,...)
Definition: debug.h:111
#define DDPCAPS_8BITENTRIES
Definition: ddraw.h:454
#define DDPCAPS_ALLOW256
Definition: ddraw.h:458
#define DD_OK
Definition: ddraw.h:186
LONG HRESULT
Definition: typedefs.h:77
unsigned long DWORD
Definition: ntddk_ex.h:95
GLbitfield flags
Definition: glext.h:7161
static unsigned int palette_size(DWORD flags)
Definition: palette.c:241
static const struct IDirectDrawPaletteVtbl ddraw_palette_vtbl
Definition: palette.c:221
static HPALETTE palette
Definition: clipboard.c:1345
#define DDPCAPS_ALPHA
Definition: ddraw.h:462
HRESULT CDECL wined3d_palette_create(struct wined3d_device *device, DWORD flags, unsigned int entry_count, const PALETTEENTRY *entries, struct wined3d_palette **palette)
Definition: palette.c:162
struct wined3d_device * wined3d_device
Definition: ddraw_private.h:94
struct ddraw * ddraw
IDirectDraw7 IDirectDraw7_iface
Definition: ddraw_private.h:80
#define WINED3D_PALETTE_ALLOW_256
Definition: wined3d.h:1555
#define DDERR_INVALIDPARAMS
Definition: ddraw.h:79

Referenced by ddraw7_CreatePalette().

◆ ddraw_palette_Initialize()

static HRESULT WINAPI ddraw_palette_Initialize ( IDirectDrawPalette *  iface,
IDirectDraw *  ddraw,
DWORD  flags,
PALETTEENTRY entries 
)
static

Definition at line 124 of file palette.c.

126 {
127  TRACE("iface %p, ddraw %p, flags %#x, entries %p.\n",
128  iface, ddraw, flags, entries);
129 
131 }
#define DDERR_ALREADYINITIALIZED
Definition: ddraw.h:67
#define TRACE(s)
Definition: solgame.cpp:4
GLbitfield flags
Definition: glext.h:7161

◆ ddraw_palette_QueryInterface()

static HRESULT WINAPI ddraw_palette_QueryInterface ( IDirectDrawPalette *  iface,
REFIID  refiid,
void **  obj 
)
static

Definition at line 40 of file palette.c.

41 {
42  TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(refiid), obj);
43 
44  if (IsEqualGUID(refiid, &IID_IUnknown)
45  || IsEqualGUID(refiid, &IID_IDirectDrawPalette))
46  {
47  *obj = iface;
48  IDirectDrawPalette_AddRef(iface);
49  return S_OK;
50  }
51  else
52  {
53  *obj = NULL;
54  return E_NOINTERFACE;
55  }
56 }
#define E_NOINTERFACE
Definition: winerror.h:2364
smooth NULL
Definition: ftsmooth.c:416
#define debugstr_guid
Definition: kernel32.h:35
#define TRACE(s)
Definition: solgame.cpp:4
const GUID IID_IUnknown
#define S_OK
Definition: intsafe.h:59
BOOL WINAPI IsEqualGUID(REFGUID rguid1, REFGUID rguid2)
Definition: compobj.c:4021

◆ ddraw_palette_Release()

static ULONG WINAPI ddraw_palette_Release ( IDirectDrawPalette *  iface)
static

Definition at line 86 of file palette.c.

87 {
90 
91  TRACE("%p decreasing refcount to %u.\n", palette, ref);
92 
93  if (ref == 0)
94  {
96  wined3d_palette_decref(palette->wined3d_palette);
97  if ((palette->flags & DDPCAPS_PRIMARYSURFACE) && palette->ddraw->primary)
98  palette->ddraw->primary->palette = NULL;
99  if (palette->ifaceToRelease)
100  IUnknown_Release(palette->ifaceToRelease);
102 
104  }
105 
106  return ref;
107 }
void WINAPI wined3d_mutex_lock(void)
Definition: wined3d_main.c:360
ULONG CDECL wined3d_palette_decref(struct wined3d_palette *palette)
Definition: palette.c:41
#define DDPCAPS_PRIMARYSURFACE
Definition: ddraw.h:456
Definition: send.c:47
GLenum GLint ref
Definition: glext.h:6028
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
#define InterlockedDecrement
Definition: armddk.h:52
static HPALETTE palette
Definition: clipboard.c:1345
static struct ddraw_palette * impl_from_IDirectDrawPalette(IDirectDrawPalette *iface)
unsigned int ULONG
Definition: retypes.h:1
void WINAPI wined3d_mutex_unlock(void)
Definition: wined3d_main.c:365
static BOOL heap_free(void *mem)
Definition: appwiz.h:75

◆ ddraw_palette_SetEntries()

static HRESULT WINAPI ddraw_palette_SetEntries ( IDirectDrawPalette *  iface,
DWORD  flags,
DWORD  start,
DWORD  count,
PALETTEENTRY entries 
)
static

Definition at line 163 of file palette.c.

165 {
167  HRESULT hr;
168 
169  TRACE("iface %p, flags %#x, start %u, count %u, entries %p.\n",
170  iface, flags, start, count, entries);
171 
172  if (!entries)
173  return DDERR_INVALIDPARAMS;
174 
176  hr = wined3d_palette_set_entries(palette->wined3d_palette, flags, start, count, entries);
177 
178  if (SUCCEEDED(hr) && palette->flags & DDPCAPS_PRIMARYSURFACE)
179  ddraw_surface_update_frontbuffer(palette->ddraw->primary, NULL, FALSE, 0);
180 
182 
183  return hr;
184 }
HRESULT hr
Definition: shlfolder.c:183
GLuint GLuint GLsizei count
Definition: gl.h:1545
void WINAPI wined3d_mutex_lock(void)
Definition: wined3d_main.c:360
#define DDPCAPS_PRIMARYSURFACE
Definition: ddraw.h:456
HRESULT ddraw_surface_update_frontbuffer(struct ddraw_surface *surface, const RECT *rect, BOOL read, unsigned int swap_interval) DECLSPEC_HIDDEN
Definition: surface.c:43
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
HRESULT CDECL wined3d_palette_set_entries(struct wined3d_palette *palette, DWORD flags, DWORD start, DWORD count, const PALETTEENTRY *entries)
Definition: palette.c:100
LONG HRESULT
Definition: typedefs.h:77
GLbitfield flags
Definition: glext.h:7161
static HPALETTE palette
Definition: clipboard.c:1345
GLuint start
Definition: gl.h:1545
static struct ddraw_palette * impl_from_IDirectDrawPalette(IDirectDrawPalette *iface)
void WINAPI wined3d_mutex_unlock(void)
Definition: wined3d_main.c:365
#define DDERR_INVALIDPARAMS
Definition: ddraw.h:79
#define SUCCEEDED(hr)
Definition: intsafe.h:57

◆ palette_size()

static unsigned int palette_size ( DWORD  flags)
static

Definition at line 241 of file palette.c.

242 {
244  {
245  case DDPCAPS_1BIT:
246  return 2;
247  case DDPCAPS_2BIT:
248  return 4;
249  case DDPCAPS_4BIT:
250  return 16;
251  case DDPCAPS_8BIT:
252  return 256;
253  default:
254  return ~0u;
255  }
256 }
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble * u
Definition: glfuncs.h:240
#define DDPCAPS_4BIT
Definition: ddraw.h:453
#define DDPCAPS_2BIT
Definition: ddraw.h:461
#define DDPCAPS_8BIT
Definition: ddraw.h:455
GLbitfield flags
Definition: glext.h:7161
#define DDPCAPS_1BIT
Definition: ddraw.h:460

Referenced by BmpDecoder_ReadHeaders(), d3dx9_skin_info_ConvertToIndexedBlendedMesh(), ddraw_palette_init(), DECLARE_INTERFACE_(), metafile_deserialize_image(), NtGdiDdDDICreateDCFromMemory(), and test_multiframegif().

◆ unsafe_impl_from_IDirectDrawPalette()

struct ddraw_palette* unsafe_impl_from_IDirectDrawPalette ( IDirectDrawPalette *  iface)

Definition at line 234 of file palette.c.

235 {
236  if (!iface) return NULL;
237  assert(iface->lpVtbl == &ddraw_palette_vtbl);
239 }
#define assert(x)
Definition: debug.h:53
smooth NULL
Definition: ftsmooth.c:416
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
static const struct IDirectDrawPaletteVtbl ddraw_palette_vtbl
Definition: palette.c:221
IDirectDrawPalette IDirectDrawPalette_iface

Referenced by ddraw_surface_set_palette().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( ddraw  )

Variable Documentation

◆ ddraw_palette_vtbl

const struct IDirectDrawPaletteVtbl ddraw_palette_vtbl
static
Initial value:
=
{
}
static ULONG WINAPI ddraw_palette_AddRef(IDirectDrawPalette *iface)
Definition: palette.c:67
static HRESULT WINAPI ddraw_palette_GetCaps(IDirectDrawPalette *iface, DWORD *caps)
Definition: palette.c:133
static HRESULT WINAPI ddraw_palette_SetEntries(IDirectDrawPalette *iface, DWORD flags, DWORD start, DWORD count, PALETTEENTRY *entries)
Definition: palette.c:163
static HRESULT WINAPI ddraw_palette_Initialize(IDirectDrawPalette *iface, IDirectDraw *ddraw, DWORD flags, PALETTEENTRY *entries)
Definition: palette.c:124
static HRESULT WINAPI ddraw_palette_GetEntries(IDirectDrawPalette *iface, DWORD flags, DWORD start, DWORD count, PALETTEENTRY *entries)
Definition: palette.c:202
static ULONG WINAPI ddraw_palette_Release(IDirectDrawPalette *iface)
Definition: palette.c:86
static HRESULT WINAPI ddraw_palette_QueryInterface(IDirectDrawPalette *iface, REFIID refiid, void **obj)
Definition: palette.c:40

Definition at line 221 of file palette.c.

Referenced by ddraw_palette_init(), and unsafe_impl_from_IDirectDrawPalette().