ReactOS 0.4.17-dev-966-gf06eace
palette.c File Reference
#include "wined3d_private.h"
Include dependency graph for palette.c:

Go to the source code of this file.

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (d3d)
 
ULONG CDECL wined3d_palette_incref (struct wined3d_palette *palette)
 
static void wined3d_palette_destroy_object (void *object)
 
ULONG CDECL wined3d_palette_decref (struct wined3d_palette *palette)
 
HRESULT CDECL wined3d_palette_get_entries (const struct wined3d_palette *palette, uint32_t flags, unsigned int start, unsigned int count, PALETTEENTRY *entries)
 
void CDECL wined3d_palette_apply_to_dc (const struct wined3d_palette *palette, HDC dc)
 
HRESULT CDECL wined3d_palette_set_entries (struct wined3d_palette *palette, uint32_t flags, unsigned int start, unsigned int count, const PALETTEENTRY *entries)
 
static HRESULT wined3d_palette_init (struct wined3d_palette *palette, struct wined3d_device *device, uint32_t flags, unsigned int entry_count, const PALETTEENTRY *entries)
 
HRESULT CDECL wined3d_palette_create (struct wined3d_device *device, uint32_t flags, unsigned int entry_count, const PALETTEENTRY *entries, struct wined3d_palette **palette)
 

Function Documentation

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( d3d  )

◆ wined3d_palette_apply_to_dc()

void CDECL wined3d_palette_apply_to_dc ( const struct wined3d_palette *  palette,
HDC  dc 
)

Definition at line 91 of file palette.c.

92{
93 if (SetDIBColorTable(dc, 0, 256, palette->colors) != 256)
94 ERR("Failed to set DIB color table.\n");
95}
#define ERR(fmt,...)
Definition: precomp.h:57
HDC dc
Definition: cylfrac.c:34
static HPALETTE palette
Definition: clipboard.c:1457
UINT WINAPI SetDIBColorTable(_In_ HDC hdc, _In_ UINT iStart, _In_ UINT cEntries, _In_reads_(cEntries) const RGBQUAD *prgbq)

Referenced by ddraw_surface7_GetDC(), ddraw_surface_update_frontbuffer(), and swapchain_gdi_frontbuffer_updated().

◆ wined3d_palette_create()

HRESULT CDECL wined3d_palette_create ( struct wined3d_device *  device,
uint32_t  flags,
unsigned int  entry_count,
const PALETTEENTRY *  entries,
struct wined3d_palette **  palette 
)

Definition at line 161 of file palette.c.

163{
164 struct wined3d_palette *object;
165 HRESULT hr;
166
167 TRACE("device %p, flags %#x, entry_count %u, entries %p, palette %p.\n",
168 device, flags, entry_count, entries, palette);
169
170 if (!(object = calloc(1, sizeof(*object))))
171 return E_OUTOFMEMORY;
172
173 if (FAILED(hr = wined3d_palette_init(object, device, flags, entry_count, entries)))
174 {
175 WARN("Failed to initialize palette, hr %#lx.\n", hr);
176 free(object);
177 return hr;
178 }
179
180 TRACE("Created palette %p.\n", object);
181 *palette = object;
182
183 return WINED3D_OK;
184}
#define WARN(fmt,...)
Definition: precomp.h:61
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define free
Definition: debug_ros.c:5
HRESULT hr
Definition: delayimp.cpp:582
static HRESULT wined3d_palette_init(struct wined3d_palette *palette, struct wined3d_device *device, uint32_t flags, unsigned int entry_count, const PALETTEENTRY *entries)
Definition: palette.c:142
GLbitfield flags
Definition: glext.h:7161
#define FAILED(hr)
Definition: intsafe.h:51
#define calloc
Definition: rosglue.h:14
#define TRACE(s)
Definition: solgame.cpp:4
Definition: devices.h:37
#define WINED3D_OK
Definition: wined3d.h:33

Referenced by ddraw_palette_init().

◆ wined3d_palette_decref()

ULONG CDECL wined3d_palette_decref ( struct wined3d_palette *  palette)

Definition at line 42 of file palette.c.

43{
44 unsigned int refcount = InterlockedDecrement(&palette->ref);
45
46 TRACE("%p decreasing refcount to %u.\n", palette, refcount);
47
48 if (!refcount)
49 {
53 }
54
55 return refcount;
56}
#define InterlockedDecrement
Definition: armddk.h:52
void wined3d_cs_destroy_object(struct wined3d_cs *cs, void(*callback)(void *object), void *object)
Definition: cs.c:2299
static void wined3d_palette_destroy_object(void *object)
Definition: palette.c:35
void WINAPI wined3d_mutex_unlock(void)
Definition: wined3d_main.c:544
void WINAPI wined3d_mutex_lock(void)
Definition: wined3d_main.c:539

Referenced by ddraw_palette_Release().

◆ wined3d_palette_destroy_object()

static void wined3d_palette_destroy_object ( void *  object)
static

Definition at line 35 of file palette.c.

36{
37 TRACE("object %p.\n", object);
38
39 free(object);
40}

Referenced by wined3d_palette_decref().

◆ wined3d_palette_get_entries()

HRESULT CDECL wined3d_palette_get_entries ( const struct wined3d_palette *  palette,
uint32_t  flags,
unsigned int  start,
unsigned int  count,
PALETTEENTRY *  entries 
)

Definition at line 58 of file palette.c.

60{
61 unsigned int i;
62 TRACE("palette %p, flags %#x, start %u, count %u, entries %p.\n",
63 palette, flags, start, count, entries);
64
65 if (flags)
66 return WINED3DERR_INVALIDCALL; /* unchecked */
69
71 {
72 BYTE *entry = (BYTE *)entries;
73
74 for (i = start; i < count + start; ++i)
75 *entry++ = palette->colors[i].rgbRed;
76 }
77 else
78 {
79 for (i = 0; i < count; ++i)
80 {
81 entries[i].peRed = palette->colors[i + start].rgbRed;
82 entries[i].peGreen = palette->colors[i + start].rgbGreen;
83 entries[i].peBlue = palette->colors[i + start].rgbBlue;
84 entries[i].peFlags = palette->colors[i + start].rgbReserved;
85 }
86 }
87
88 return WINED3D_OK;
89}
GLuint start
Definition: gl.h:1545
GLuint GLuint GLsizei count
Definition: gl.h:1545
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 const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
uint32_t entry
Definition: isohybrid.c:63
#define WINED3D_PALETTE_8BIT_ENTRIES
Definition: wined3d.h:1559
static bool wined3d_bound_range(unsigned int start, unsigned int count, unsigned int limit)
Definition: wined3d.h:2995
#define WINED3DERR_INVALIDCALL
Definition: wined3d.h:44
unsigned char BYTE
Definition: xxhash.c:193

Referenced by ddraw_palette_GetEntries(), and wined3d_colour_from_ddraw_colour().

◆ wined3d_palette_incref()

ULONG CDECL wined3d_palette_incref ( struct wined3d_palette *  palette)

Definition at line 26 of file palette.c.

27{
28 unsigned int refcount = InterlockedIncrement(&palette->ref);
29
30 TRACE("%p increasing refcount to %u.\n", palette, refcount);
31
32 return refcount;
33}
#define InterlockedIncrement
Definition: armddk.h:53

◆ wined3d_palette_init()

static HRESULT wined3d_palette_init ( struct wined3d_palette *  palette,
struct wined3d_device *  device,
uint32_t  flags,
unsigned int  entry_count,
const PALETTEENTRY *  entries 
)
static

Definition at line 142 of file palette.c.

144{
145 HRESULT hr;
146
147 palette->ref = 1;
148 palette->device = device;
149 palette->flags = flags;
150 palette->size = entry_count;
151
152 if (FAILED(hr = wined3d_palette_set_entries(palette, 0, 0, entry_count, entries)))
153 {
154 WARN("Failed to set palette entries, hr %#lx.\n", hr);
155 return hr;
156 }
157
158 return WINED3D_OK;
159}
HRESULT CDECL wined3d_palette_set_entries(struct wined3d_palette *palette, uint32_t flags, unsigned int start, unsigned int count, const PALETTEENTRY *entries)
Definition: palette.c:97

Referenced by wined3d_palette_create().

◆ wined3d_palette_set_entries()

HRESULT CDECL wined3d_palette_set_entries ( struct wined3d_palette *  palette,
uint32_t  flags,
unsigned int  start,
unsigned int  count,
const PALETTEENTRY *  entries 
)

Definition at line 97 of file palette.c.

99{
100 unsigned int i;
101
102 TRACE("palette %p, flags %#x, start %u, count %u, entries %p.\n",
103 palette, flags, start, count, entries);
104 TRACE("Palette flags: %#x.\n", palette->flags);
105
107
109 {
110 const BYTE *entry = (const BYTE *)entries;
111
112 for (i = start; i < count + start; ++i)
113 palette->colors[i].rgbRed = *entry++;
114 }
115 else
116 {
117 for (i = 0; i < count; ++i)
118 {
119 palette->colors[i + start].rgbRed = entries[i].peRed;
120 palette->colors[i + start].rgbGreen = entries[i].peGreen;
121 palette->colors[i + start].rgbBlue = entries[i].peBlue;
122 palette->colors[i + start].rgbReserved = entries[i].peFlags;
123 }
124
125 /* When WINEDDCAPS_ALLOW256 isn't set we need to override entry 0 with black and 255 with white */
126 if (!(palette->flags & WINED3D_PALETTE_ALLOW_256))
127 {
128 TRACE("WINED3D_PALETTE_ALLOW_256 not set, overriding palette entry 0 with black and 255 with white.\n");
129 palette->colors[0].rgbRed = 0;
130 palette->colors[0].rgbGreen = 0;
131 palette->colors[0].rgbBlue = 0;
132
133 palette->colors[255].rgbRed = 255;
134 palette->colors[255].rgbGreen = 255;
135 palette->colors[255].rgbBlue = 255;
136 }
137 }
138
139 return WINED3D_OK;
140}
#define WINED3D_PALETTE_ALLOW_256
Definition: wined3d.h:1560
static void wined3d_cs_finish(struct wined3d_cs *cs, enum wined3d_cs_queue_id queue_id)
@ WINED3D_CS_QUEUE_DEFAULT

Referenced by ddraw_palette_SetEntries(), and wined3d_palette_init().