ReactOS  0.4.13-dev-79-gcd489d8
sw_pixelformat.c File Reference
#include <windows.h>
#include <wingdi.h>
#include <GL/gl.h>
#include <stdio.h>
#include "wine/test.h"
Include dependency graph for sw_pixelformat.c:

Go to the source code of this file.

Classes

struct  test_color
 

Macros

#define FLAGS_TO_STR(__x__)
 
#define TEST_FIELD(__x__)   ok(pfd.__x__ == colors->__x__, "Wrong " #__x__ " for format %i, expected %u, got %u\n", pf, colors->__x__, pfd.__x__)
 
#define TEST_FIELD(__x__, __y__)   ok(pfd.__x__ == __y__, "Wrong " #__x__ " for format %i, expected " #__y__ ", got %u\n", pf, (UINT)pfd.__x__)
 

Functions

static charstr_dbg_pfd_flags (DWORD flags)
 
static void test_format (HDC hdc, int num_pf, int pf, const struct test_color *colors, BYTE depth, BOOL is_window, BOOL is_double_buffered)
 
static void test_screen_colors (const struct test_color **colors)
 
static HBITMAP create_dib_section (WORD bpp, void **dstBuffer)
 
static void test_bitmap_colors (HDC hdc, const struct test_color **colors)
 
static void test_bitmap_formats (const struct test_color **colors)
 
 START_TEST (sw_pixelformat)
 

Variables

static const struct test_color test_colors_32 []
 
static const struct test_color test_colors_24 []
 
static const struct test_color test_colors_16 []
 
static const struct test_color test_colors_16_565 []
 
static const struct test_color test_colors_8 []
 
static const struct test_color test_colors_4 []
 
static const struct test_colortest_colors_32bpp [] = {test_colors_32, test_colors_24, test_colors_16, test_colors_8, test_colors_4, NULL}
 
static const struct test_colortest_colors_24bpp [] = {test_colors_24, test_colors_32, test_colors_16, test_colors_8, test_colors_4, NULL}
 
static const struct test_colortest_colors_16bpp [] = {test_colors_16_565, test_colors_24, test_colors_32, test_colors_8, test_colors_4, NULL}
 
static const struct test_colortest_colors_8bpp [] = {test_colors_8, test_colors_24, test_colors_32, test_colors_16, test_colors_4, NULL}
 
static const BYTE test_depths [] = { 32, 16 }
 

Macro Definition Documentation

◆ FLAGS_TO_STR

#define FLAGS_TO_STR (   __x__)
Value:
do { \
if (flags & __x__) \
{ \
if (!first) strcat(p, " | "); \
strcat(p, #__x__); \
first = FALSE; \
flags &= ~((DWORD)__x__); \
} \
} while(0)
char * strcat(char *DstString, const char *SrcString)
Definition: utclib.c:568
const GLint * first
Definition: glext.h:5794
#define DWORD
Definition: nt_native.h:44
GLbitfield flags
Definition: glext.h:7161
GLfloat GLfloat p
Definition: glext.h:8902

◆ TEST_FIELD [1/2]

#define TEST_FIELD (   __x__)    ok(pfd.__x__ == colors->__x__, "Wrong " #__x__ " for format %i, expected %u, got %u\n", pf, colors->__x__, pfd.__x__)

◆ TEST_FIELD [2/2]

#define TEST_FIELD (   __x__,
  __y__ 
)    ok(pfd.__x__ == __y__, "Wrong " #__x__ " for format %i, expected " #__y__ ", got %u\n", pf, (UINT)pfd.__x__)

Function Documentation

◆ create_dib_section()

static HBITMAP create_dib_section ( WORD  bpp,
void **  dstBuffer 
)
static

Definition at line 266 of file sw_pixelformat.c.

267 {
268  BITMAPINFO bi;
269 
270  memset(&bi, 0, sizeof(BITMAPINFO));
271  bi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
272  bi.bmiHeader.biWidth = 4;
273  bi.bmiHeader.biHeight = -4;
274  bi.bmiHeader.biPlanes = 1;
275  bi.bmiHeader.biBitCount = bpp;
277 
278  return CreateDIBSection(0, &bi, DIB_RGB_COLORS, dstBuffer, NULL, 0);
279 }
BITMAPINFOHEADER bmiHeader
Definition: wingdi.h:1454
struct tagBITMAPINFOHEADER BITMAPINFOHEADER
DWORD biCompression
Definition: amvideo.idl:35
smooth NULL
Definition: ftsmooth.c:416
HBITMAP WINAPI CreateDIBSection(HDC hDC, CONST BITMAPINFO *BitmapInfo, UINT Usage, VOID **Bits, HANDLE hSection, DWORD dwOffset)
Definition: bitmap.c:197
DWORD bpp
Definition: surface.c:181
#define DIB_RGB_COLORS
Definition: wingdi.h:366
#define memset(x, y, z)
Definition: compat.h:39
#define BI_RGB
Definition: precomp.h:35

Referenced by test_bitmap_formats().

◆ START_TEST()

START_TEST ( sw_pixelformat  )

Definition at line 364 of file sw_pixelformat.c.

365 {
367  INT ret;
368  DWORD orig_bpp;
369  static const WORD bit_depths[] = {8, 16, 24, 32};
371  INT i;
372 
374  ok (ret != 0, "EnumDisplaySettings failed.\n");
375  orig_bpp = devMode.dmBitsPerPel;
376 
377  for (i = 0; i < ARRAY_SIZE(bit_depths); i++)
378  {
379  devMode.dmBitsPerPel = bit_depths[i];
382  {
383  trace("Testing %ubpp\n", bit_depths[i]);
384  test_screen_colors(colors[i]);
385  test_bitmap_formats(colors[i]);
386  }
387  else
388  {
389  skip("Unable to switch to %ubpp\n", bit_depths[i]);
390  }
391  }
392 
393  devMode.dmBitsPerPel = orig_bpp;
395 }
#define trace(...)
Definition: kmt_test.h:217
static const struct test_color * test_colors_8bpp[]
static HGLOBAL devMode
Definition: print.c:52
int32_t INT
Definition: typedefs.h:56
#define ENUM_CURRENT_SETTINGS
Definition: winuser.h:179
LONG WINAPI ChangeDisplaySettingsExW(LPCWSTR lpszDeviceName, LPDEVMODEW lpDevMode, HWND hwnd, DWORD dwflags, LPVOID lParam)
Definition: display.c:585
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
#define ok(value,...)
smooth NULL
Definition: ftsmooth.c:416
static const struct test_color * test_colors_24bpp[]
static const struct test_color * test_colors_16bpp[]
BOOL WINAPI EnumDisplaySettingsW(LPCWSTR lpszDeviceName, DWORD iModeNum, LPDEVMODEW lpDevMode)
Definition: display.c:408
#define DISP_CHANGE_SUCCESSFUL
Definition: winuser.h:190
unsigned short WORD
Definition: ntddk_ex.h:93
unsigned long DWORD
Definition: ntddk_ex.h:95
static void test_screen_colors(const struct test_color **colors)
static void test_bitmap_formats(const struct test_color **colors)
int ret
#define ARRAY_SIZE(a)
Definition: main.h:24
#define skip(...)
static const struct test_color * test_colors_32bpp[]

◆ str_dbg_pfd_flags()

static char* str_dbg_pfd_flags ( DWORD  flags)
static

Definition at line 15 of file sw_pixelformat.c.

16 {
17  static char buffer[1000];
18  static char *p = buffer;
19  char* ret;
20 
21  BOOL first = TRUE;
22 
23  if (p > &buffer[800])
24  p = buffer;
25 
26  *p = 0;
27 
28 #define FLAGS_TO_STR(__x__) \
29  do { \
30  if (flags & __x__) \
31  { \
32  if (!first) strcat(p, " | "); \
33  strcat(p, #__x__); \
34  first = FALSE; \
35  flags &= ~((DWORD)__x__); \
36  } \
37  } while(0)
38 
53 #undef FLAGS_TO_STR
54 
55  if (flags)
56  {
57  char tmp[16];
58  sprintf(tmp, " | 0x%08x", (UINT)flags);
59  strcat(p, tmp);
60  }
61 
62  ret = p;
63 
64  p += strlen(p) + 1;
65 
66  return ret;
67 }
#define TRUE
Definition: types.h:120
#define PFD_NEED_SYSTEM_PALETTE
Definition: wingdi.h:308
char * strcat(char *DstString, const char *SrcString)
Definition: utclib.c:568
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
const GLint * first
Definition: glext.h:5794
#define PFD_DRAW_TO_BITMAP
Definition: wingdi.h:303
#define PFD_NEED_PALETTE
Definition: wingdi.h:307
#define PFD_GENERIC_ACCELERATED
Definition: wingdi.h:312
GLuint buffer
Definition: glext.h:5915
#define PFD_DOUBLEBUFFER
Definition: wingdi.h:300
#define sprintf(buf, format,...)
Definition: sprintf.c:55
#define FLAGS_TO_STR(__x__)
unsigned int BOOL
Definition: ntddk_ex.h:94
#define PFD_SWAP_LAYER_BUFFERS
Definition: wingdi.h:311
#define PFD_SUPPORT_GDI
Definition: wingdi.h:304
GLbitfield flags
Definition: glext.h:7161
int ret
#define PFD_SWAP_EXCHANGE
Definition: wingdi.h:309
#define PFD_GENERIC_FORMAT
Definition: wingdi.h:306
#define PFD_STEREO
Definition: wingdi.h:301
unsigned int UINT
Definition: ndis.h:50
#define PFD_SWAP_COPY
Definition: wingdi.h:310
#define PFD_SUPPORT_OPENGL
Definition: wingdi.h:305
GLfloat GLfloat p
Definition: glext.h:8902
#define PFD_DRAW_TO_WINDOW
Definition: wingdi.h:302
#define PFD_SUPPORT_COMPOSITION
Definition: wingdi.h:313

Referenced by test_format().

◆ test_bitmap_colors()

static void test_bitmap_colors ( HDC  hdc,
const struct test_color **  colors 
)
static

Definition at line 281 of file sw_pixelformat.c.

282 {
283  INT num_pf, pf, ret;
285  INT i, j;
286 
287  num_pf = DescribePixelFormat(hdc, 0, 0, NULL);
288  ok(num_pf > 0, "DescribePixelFormat failed.\n");
289 
290  for (pf = 1; pf <= num_pf; pf++)
291  {
292  ret = DescribePixelFormat(hdc, pf, sizeof(pfd), &pfd);
293  ok(ret == num_pf, "Number of pixel formats changed!\n");
294 
296  break;
297  }
298 
299  ok(pf < num_pf, "No generic pixel format!\n");
300 
301  /* First the formats compatible with the DC */
302  for (i = 0; i < 3; i++)
303  {
304  /* Single buffered first */
305  for (j = 0; j < ARRAY_SIZE(test_depths); j++)
306  {
307  test_format(hdc, num_pf, pf++, &colors[0][i], test_depths[j], TRUE, FALSE);
308  }
309 
310  /* Then double buffered */
311  for (j = 0; j < ARRAY_SIZE(test_depths); j++)
312  {
313  test_format(hdc, num_pf, pf++, &colors[0][i], test_depths[j], TRUE, TRUE);
314  }
315  }
316 
317  colors++;
318 
319  /* Then the rest */
320  while (*colors)
321  {
322  for (i = 0; i < 3; i++)
323  {
324  for (j = 0; j < ARRAY_SIZE(test_depths); j++)
325  {
326  test_format(hdc, num_pf, pf++, &colors[0][i], test_depths[j], FALSE, FALSE);
327  }
328  }
329  colors++;
330  }
331 
332  /* We must have tested all generic formats. */
333  ok(pf - 1 == num_pf, "We didn't test all generic formats : tested %u, total %u.\n", pf, num_pf);
334 }
#define TRUE
Definition: types.h:120
static const BYTE test_depths[]
int32_t INT
Definition: typedefs.h:56
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
int WINAPI DescribePixelFormat(_In_ HDC hdc, _In_ int iPixelFormat, _In_ UINT nBytes, _Out_writes_bytes_opt_(nBytes) LPPIXELFORMATDESCRIPTOR ppfd)
#define ok(value,...)
smooth NULL
Definition: ftsmooth.c:416
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 GLint GLint j
Definition: glfuncs.h:250
static void test_format(HDC hdc, int num_pf, int pf, const struct test_color *colors, BYTE depth, BOOL is_window, BOOL is_double_buffered)
static PIXELFORMATDESCRIPTOR pfd
Definition: ssstars.c:67
int ret
HDC hdc
Definition: main.c:9
#define PFD_GENERIC_FORMAT
Definition: wingdi.h:306
#define ARRAY_SIZE(a)
Definition: main.h:24

Referenced by test_bitmap_formats().

◆ test_bitmap_formats()

static void test_bitmap_formats ( const struct test_color **  colors)
static

Definition at line 336 of file sw_pixelformat.c.

337 {
338  HBITMAP oldBmp, dib;
339  HDC hdc;
340  static const INT bpps [] = {4, 8, 16, 24, 32};
341  INT i;
342  void* dib_buffer;
343 
345  ok (hdc != NULL, "Failed creating a memory DC.\n");
346 
347  for (i = 0; i < ARRAY_SIZE(bpps); i++)
348  {
349  dib = create_dib_section(bpps[i], &dib_buffer);
350  ok(dib != NULL, "Failed to create DIB for %u bpp\n", bpps[i]);
351 
352  oldBmp = SelectObject(hdc, dib);
353  ok (oldBmp != NULL, "Failed to select the DIB\n");
354 
355  trace("testing DIB %ubpp\n", bpps[i]);
356  /* For mem DC, this is always the depth of the screen which is taken into account */
357  test_bitmap_colors(hdc, colors);
358 
359  SelectObject(hdc, oldBmp);
360  DeleteObject(dib);
361  }
362 }
#define trace(...)
Definition: kmt_test.h:217
static HDC
Definition: imagelist.c:92
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1497
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
HDC WINAPI CreateCompatibleDC(_In_opt_ HDC hdc)
int32_t INT
Definition: typedefs.h:56
static void test_bitmap_colors(HDC hdc, const struct test_color **colors)
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
#define ok(value,...)
smooth NULL
Definition: ftsmooth.c:416
HDC hdc
Definition: main.c:9
#define ARRAY_SIZE(a)
Definition: main.h:24
static const BYTE dib[]
Definition: ole2.c:201
static HBITMAP create_dib_section(WORD bpp, void **dstBuffer)
static HBITMAP
Definition: button.c:44

Referenced by START_TEST().

◆ test_format()

static void test_format ( HDC  hdc,
int  num_pf,
int  pf,
const struct test_color colors,
BYTE  depth,
BOOL  is_window,
BOOL  is_double_buffered 
)
static

Definition at line 130 of file sw_pixelformat.c.

131 {
133  int ret;
134 
135  ret = DescribePixelFormat(hdc, pf, sizeof(pfd), &pfd);
136  ok(ret == num_pf, "Number of pixel formats changed!\n");
137 
138  ok(pfd.nSize == sizeof(pfd), "Wrong nSize for format %i, expected %u, got %u\n", pf, (WORD)sizeof(pfd), pfd.nSize);
139  ok(pfd.nVersion == 1, "Wrong nVersion for format %i, expected 1, got %u\n", pf, pfd.nVersion);
140  if (is_window)
141  {
143 
144  if ((pfd.cColorBits <= 8) && (pfd.iPixelType == PFD_TYPE_RGBA))
146 
147  if (is_double_buffered)
148  {
150  }
151  else
152  {
154  }
156  "Wrong dwFlags for format %i, expected %s (0x%08x), got %s(0x%08x)\n",
158  }
159  else
160  {
162  "Wrong dwFlags for format %i, expected PFD_DRAW_TO_BITMAP | PFD_SUPPORT_GDI | PFD_SUPPORT_OPENGL | PFD_GENERIC_FORMAT, got %s\n",
164  }
165 
166 #define TEST_FIELD(__x__) ok(pfd.__x__ == colors->__x__, "Wrong " #__x__ " for format %i, expected %u, got %u\n", pf, colors->__x__, pfd.__x__)
182 #undef TEST_FIELD
183  ok(pfd.cDepthBits == depth, "Wrong cDepthBit for format %i, expected %u, got %u\n", pf, depth, pfd.cDepthBits);
184 
185  /* the rest is constant */
186 #define TEST_FIELD(__x__, __y__) ok(pfd.__x__ == __y__, "Wrong " #__x__ " for format %i, expected " #__y__ ", got %u\n", pf, (UINT)pfd.__x__)
187  TEST_FIELD(cStencilBits, 8);
188  TEST_FIELD(cAuxBuffers, 0);
189  TEST_FIELD(iLayerType, 0);
190  TEST_FIELD(bReserved, 0);
191  TEST_FIELD(dwLayerMask, 0);
192  TEST_FIELD(dwVisibleMask, 0);
193  TEST_FIELD(dwDamageMask, 0);
194 #undef TEST_FIELD
195 }
#define PFD_DRAW_TO_BITMAP
Definition: wingdi.h:303
#define PFD_NEED_PALETTE
Definition: wingdi.h:307
BYTE cGreenShift
BYTE cAccumBlueBits
#define TEST_FIELD(__x__)
#define PFD_DOUBLEBUFFER
Definition: wingdi.h:300
BYTE cAccumGreenBits
int WINAPI DescribePixelFormat(_In_ HDC hdc, _In_ int iPixelFormat, _In_ UINT nBytes, _Out_writes_bytes_opt_(nBytes) LPPIXELFORMATDESCRIPTOR ppfd)
#define ok(value,...)
BYTE cAlphaShift
#define PFD_SUPPORT_GDI
Definition: wingdi.h:304
unsigned short WORD
Definition: ntddk_ex.h:93
unsigned long DWORD
Definition: ntddk_ex.h:95
GLbitfield flags
Definition: glext.h:7161
#define PFD_TYPE_RGBA
Definition: wingdi.h:295
static PIXELFORMATDESCRIPTOR pfd
Definition: ssstars.c:67
GLint GLint GLsizei GLsizei GLsizei depth
Definition: gl.h:1546
int ret
HDC hdc
Definition: main.c:9
#define PFD_GENERIC_FORMAT
Definition: wingdi.h:306
unsigned int UINT
Definition: ndis.h:50
BYTE cAccumAlphaBits
#define PFD_SWAP_COPY
Definition: wingdi.h:310
#define PFD_SUPPORT_OPENGL
Definition: wingdi.h:305
#define PFD_DRAW_TO_WINDOW
Definition: wingdi.h:302
#define PFD_SUPPORT_COMPOSITION
Definition: wingdi.h:313
BYTE cAccumRedBits
static char * str_dbg_pfd_flags(DWORD flags)

Referenced by test_bitmap_colors(), and test_screen_colors().

◆ test_screen_colors()

static void test_screen_colors ( const struct test_color **  colors)
static

Definition at line 197 of file sw_pixelformat.c.

198 {
199  int pf, num_pf, ret;
200  int i, j;
201  HDC hdc;
202  HWND hwnd;
204 
205  hwnd = CreateWindowA("static", "Title", WS_OVERLAPPEDWINDOW, 10, 10, 200, 200, NULL, NULL,
206  NULL, NULL);
207  if (!hwnd)
208  {
209  ok(hwnd != NULL, "Failed to create a window.\n");
210  return;
211  }
212 
213  hdc = GetDC( hwnd );
214  num_pf = DescribePixelFormat(hdc, 0, 0, NULL);
215  ok(num_pf > 0, "DescribePixelFormat failed.\n");
216 
217  for (pf = 1; pf <= num_pf; pf++)
218  {
219  ret = DescribePixelFormat(hdc, pf, sizeof(pfd), &pfd);
220  ok(ret == num_pf, "Number of pixel formats changed!\n");
221 
223  break;
224  }
225 
226  ok(pf < num_pf, "No generic pixel format!\n");
227 
228  /* First the formats compatible with the DC */
229  for (i = 0; i < 3; i++)
230  {
231  /* Single buffered first */
232  for (j = 0; j < ARRAY_SIZE(test_depths); j++)
233  {
234  test_format(hdc, num_pf, pf++, &colors[0][i], test_depths[j], TRUE, FALSE);
235  }
236 
237  /* Then double buffered */
238  for (j = 0; j < ARRAY_SIZE(test_depths); j++)
239  {
240  test_format(hdc, num_pf, pf++, &colors[0][i], test_depths[j], TRUE, TRUE);
241  }
242  }
243 
244  colors++;
245 
246  /* Then the rest */
247  while (*colors)
248  {
249  for (i = 0; i < 3; i++)
250  {
251  for (j = 0; j < ARRAY_SIZE(test_depths); j++)
252  {
253  test_format(hdc, num_pf, pf++, &colors[0][i], test_depths[j], FALSE, FALSE);
254  }
255  }
256  colors++;
257  }
258 
259  /* We must have tested all generic formats. */
260  ok(pf - 1 == num_pf, "We didn't test all generic formats : tested %u, total %u.\n", pf, num_pf);
261 
262  ReleaseDC( hwnd, hdc );
263  DestroyWindow( hwnd );
264 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
#define TRUE
Definition: types.h:120
HDC WINAPI GetDC(_In_opt_ HWND)
static HDC
Definition: imagelist.c:92
static const BYTE test_depths[]
BOOL WINAPI DestroyWindow(_In_ HWND)
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
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
int WINAPI DescribePixelFormat(_In_ HDC hdc, _In_ int iPixelFormat, _In_ UINT nBytes, _Out_writes_bytes_opt_(nBytes) LPPIXELFORMATDESCRIPTOR ppfd)
#define ok(value,...)
#define CreateWindowA(a, b, c, d, e, f, g, h, i, j, k)
Definition: winuser.h:4184
smooth NULL
Definition: ftsmooth.c:416
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 GLint GLint j
Definition: glfuncs.h:250
static void test_format(HDC hdc, int num_pf, int pf, const struct test_color *colors, BYTE depth, BOOL is_window, BOOL is_double_buffered)
static PIXELFORMATDESCRIPTOR pfd
Definition: ssstars.c:67
int ret
HDC hdc
Definition: main.c:9
#define PFD_GENERIC_FORMAT
Definition: wingdi.h:306
#define ARRAY_SIZE(a)
Definition: main.h:24
#define WS_OVERLAPPEDWINDOW
Definition: pedump.c:637

Referenced by START_TEST().

Variable Documentation

◆ test_colors_16

const struct test_color test_colors_16[]
static
Initial value:
=
{
{PFD_TYPE_RGBA, 16, 5, 10, 5, 5, 5, 0, 0, 0, 32, 11, 11, 10, 0},
{PFD_TYPE_RGBA, 16, 5, 10, 5, 5, 5, 0, 8, 0, 32, 8, 8, 8, 8},
{PFD_TYPE_COLORINDEX, 16, 5, 10, 5, 5, 5, 0, 0, 0, 0, 0, 0, 0, 0},
}
#define PFD_TYPE_COLORINDEX
Definition: wingdi.h:296
#define PFD_TYPE_RGBA
Definition: wingdi.h:295

Definition at line 95 of file sw_pixelformat.c.

◆ test_colors_16_565

const struct test_color test_colors_16_565[]
static
Initial value:
=
{
{PFD_TYPE_RGBA, 16, 5, 11, 6, 5, 5, 0, 0, 0, 32, 11, 11, 10, 0},
{PFD_TYPE_RGBA, 16, 5, 11, 6, 5, 5, 0, 8, 0, 32, 8, 8, 8, 8},
{PFD_TYPE_COLORINDEX, 16, 5, 11, 6, 5, 5, 0, 0, 0, 0, 0, 0, 0, 0},
}
#define PFD_TYPE_COLORINDEX
Definition: wingdi.h:296
#define PFD_TYPE_RGBA
Definition: wingdi.h:295

Definition at line 102 of file sw_pixelformat.c.

◆ test_colors_16bpp

Definition at line 125 of file sw_pixelformat.c.

Referenced by START_TEST().

◆ test_colors_24

const struct test_color test_colors_24[]
static
Initial value:
=
{
{PFD_TYPE_RGBA, 24, 8, 16, 8, 8, 8, 0, 0, 0, 64, 16, 16, 16, 0},
{PFD_TYPE_RGBA, 24, 8, 16, 8, 8, 8, 0, 8, 0, 64, 16, 16, 16, 16},
{PFD_TYPE_COLORINDEX, 24, 8, 16, 8, 8, 8, 0, 0, 0, 0, 0, 0, 0, 0},
}
#define PFD_TYPE_COLORINDEX
Definition: wingdi.h:296
#define PFD_TYPE_RGBA
Definition: wingdi.h:295

Definition at line 88 of file sw_pixelformat.c.

◆ test_colors_24bpp

Definition at line 124 of file sw_pixelformat.c.

Referenced by START_TEST().

◆ test_colors_32

const struct test_color test_colors_32[]
static
Initial value:
=
{
{PFD_TYPE_RGBA, 32, 8, 16, 8, 8, 8, 0, 0, 0, 64, 16, 16, 16, 0},
{PFD_TYPE_RGBA, 32, 8, 16, 8, 8, 8, 0, 8, 0, 64, 16, 16, 16, 16},
{PFD_TYPE_COLORINDEX, 32, 8, 16, 8, 8, 8, 0, 0, 0, 0, 0, 0, 0, 0},
}
#define PFD_TYPE_COLORINDEX
Definition: wingdi.h:296
#define PFD_TYPE_RGBA
Definition: wingdi.h:295

Definition at line 81 of file sw_pixelformat.c.

◆ test_colors_32bpp

Definition at line 123 of file sw_pixelformat.c.

Referenced by START_TEST().

◆ test_colors_4

const struct test_color test_colors_4[]
static
Initial value:
=
{
{PFD_TYPE_RGBA, 4, 1, 0, 1, 1, 1, 2, 0, 0, 16, 5, 6, 5, 0},
{PFD_TYPE_RGBA, 4, 1, 0, 1, 1, 1, 2, 8, 0, 16, 4, 4, 4, 4},
{PFD_TYPE_COLORINDEX, 4, 1, 0, 1, 1, 1, 2, 0, 0, 0, 0, 0, 0, 0},
}
#define PFD_TYPE_COLORINDEX
Definition: wingdi.h:296
#define PFD_TYPE_RGBA
Definition: wingdi.h:295

Definition at line 116 of file sw_pixelformat.c.

◆ test_colors_8

const struct test_color test_colors_8[]
static
Initial value:
=
{
{PFD_TYPE_RGBA, 8, 3, 0, 3, 3, 2, 6, 0, 0, 32, 11, 11, 10, 0},
{PFD_TYPE_RGBA, 8, 3, 0, 3, 3, 2, 6, 8, 0, 32, 8, 8, 8, 8},
{PFD_TYPE_COLORINDEX, 8, 3, 0, 3, 3, 2, 6, 0, 0, 0, 0, 0, 0, 0},
}
#define PFD_TYPE_COLORINDEX
Definition: wingdi.h:296
#define PFD_TYPE_RGBA
Definition: wingdi.h:295

Definition at line 109 of file sw_pixelformat.c.

◆ test_colors_8bpp

Definition at line 126 of file sw_pixelformat.c.

Referenced by START_TEST().

◆ test_depths

const BYTE test_depths[] = { 32, 16 }
static

Definition at line 128 of file sw_pixelformat.c.

Referenced by test_bitmap_colors(), and test_screen_colors().