Load done event now created by the server.
[wine/multimedia.git] / dlls / ddraw / helper.c
blob366af360347ad22594d1d6ee90f881c2f0efd4f5
2 /* DirectDraw Base Functions
4 * Copyright 1997-1999 Marcus Meissner
5 * Copyright 1998 Lionel Ulmer (most of Direct3D stuff)
6 */
8 #include "config.h"
10 #include <unistd.h>
11 #include <assert.h>
12 #include <fcntl.h>
13 #include <string.h>
14 #include <stdlib.h>
15 #include <stdio.h>
17 #include "winerror.h"
18 #include "gdi.h"
19 #include "heap.h"
20 #include "dc.h"
21 #include "win.h"
22 #include "wine/exception.h"
23 #include "ddraw.h"
24 #include "d3d.h"
25 #include "debugtools.h"
26 #include "spy.h"
27 #include "message.h"
28 #include "options.h"
29 #include "monitor.h"
31 DEFAULT_DEBUG_CHANNEL(ddraw);
33 /******************************************************************************
34 * debug output functions
36 void _dump_DDBLTFX(DWORD flagmask) {
37 int i;
38 const struct {
39 DWORD mask;
40 char *name;
41 } flags[] = {
42 #define FE(x) { x, #x},
43 FE(DDBLTFX_ARITHSTRETCHY)
44 FE(DDBLTFX_MIRRORLEFTRIGHT)
45 FE(DDBLTFX_MIRRORUPDOWN)
46 FE(DDBLTFX_NOTEARING)
47 FE(DDBLTFX_ROTATE180)
48 FE(DDBLTFX_ROTATE270)
49 FE(DDBLTFX_ROTATE90)
50 FE(DDBLTFX_ZBUFFERRANGE)
51 FE(DDBLTFX_ZBUFFERBASEDEST)
52 #undef FE
54 for (i=0;i<sizeof(flags)/sizeof(flags[0]);i++)
55 if (flags[i].mask & flagmask)
56 DPRINTF("%s ",flags[i].name);
57 DPRINTF("\n");
60 void _dump_DDBLTFAST(DWORD flagmask) {
61 int i;
62 const struct {
63 DWORD mask;
64 char *name;
65 } flags[] = {
66 #define FE(x) { x, #x},
67 FE(DDBLTFAST_NOCOLORKEY)
68 FE(DDBLTFAST_SRCCOLORKEY)
69 FE(DDBLTFAST_DESTCOLORKEY)
70 FE(DDBLTFAST_WAIT)
71 #undef FE
73 for (i=0;i<sizeof(flags)/sizeof(flags[0]);i++)
74 if (flags[i].mask & flagmask)
75 DPRINTF("%s ",flags[i].name);
76 DPRINTF("\n");
79 void _dump_DDBLT(DWORD flagmask) {
80 int i;
81 const struct {
82 DWORD mask;
83 char *name;
84 } flags[] = {
85 #define FE(x) { x, #x},
86 FE(DDBLT_ALPHADEST)
87 FE(DDBLT_ALPHADESTCONSTOVERRIDE)
88 FE(DDBLT_ALPHADESTNEG)
89 FE(DDBLT_ALPHADESTSURFACEOVERRIDE)
90 FE(DDBLT_ALPHAEDGEBLEND)
91 FE(DDBLT_ALPHASRC)
92 FE(DDBLT_ALPHASRCCONSTOVERRIDE)
93 FE(DDBLT_ALPHASRCNEG)
94 FE(DDBLT_ALPHASRCSURFACEOVERRIDE)
95 FE(DDBLT_ASYNC)
96 FE(DDBLT_COLORFILL)
97 FE(DDBLT_DDFX)
98 FE(DDBLT_DDROPS)
99 FE(DDBLT_KEYDEST)
100 FE(DDBLT_KEYDESTOVERRIDE)
101 FE(DDBLT_KEYSRC)
102 FE(DDBLT_KEYSRCOVERRIDE)
103 FE(DDBLT_ROP)
104 FE(DDBLT_ROTATIONANGLE)
105 FE(DDBLT_ZBUFFER)
106 FE(DDBLT_ZBUFFERDESTCONSTOVERRIDE)
107 FE(DDBLT_ZBUFFERDESTOVERRIDE)
108 FE(DDBLT_ZBUFFERSRCCONSTOVERRIDE)
109 FE(DDBLT_ZBUFFERSRCOVERRIDE)
110 FE(DDBLT_WAIT)
111 FE(DDBLT_DEPTHFILL)
112 #undef FE
114 for (i=0;i<sizeof(flags)/sizeof(flags[0]);i++)
115 if (flags[i].mask & flagmask)
116 DPRINTF("%s ",flags[i].name);
117 DPRINTF("\n");
120 void _dump_DDSCAPS(void *in) {
121 int i;
122 const struct {
123 DWORD mask;
124 char *name;
125 } flags[] = {
126 #define FE(x) { x, #x},
127 FE(DDSCAPS_RESERVED1)
128 FE(DDSCAPS_ALPHA)
129 FE(DDSCAPS_BACKBUFFER)
130 FE(DDSCAPS_COMPLEX)
131 FE(DDSCAPS_FLIP)
132 FE(DDSCAPS_FRONTBUFFER)
133 FE(DDSCAPS_OFFSCREENPLAIN)
134 FE(DDSCAPS_OVERLAY)
135 FE(DDSCAPS_PALETTE)
136 FE(DDSCAPS_PRIMARYSURFACE)
137 FE(DDSCAPS_PRIMARYSURFACELEFT)
138 FE(DDSCAPS_SYSTEMMEMORY)
139 FE(DDSCAPS_TEXTURE)
140 FE(DDSCAPS_3DDEVICE)
141 FE(DDSCAPS_VIDEOMEMORY)
142 FE(DDSCAPS_VISIBLE)
143 FE(DDSCAPS_WRITEONLY)
144 FE(DDSCAPS_ZBUFFER)
145 FE(DDSCAPS_OWNDC)
146 FE(DDSCAPS_LIVEVIDEO)
147 FE(DDSCAPS_HWCODEC)
148 FE(DDSCAPS_MODEX)
149 FE(DDSCAPS_MIPMAP)
150 FE(DDSCAPS_RESERVED2)
151 FE(DDSCAPS_ALLOCONLOAD)
152 FE(DDSCAPS_VIDEOPORT)
153 FE(DDSCAPS_LOCALVIDMEM)
154 FE(DDSCAPS_NONLOCALVIDMEM)
155 FE(DDSCAPS_STANDARDVGAMODE)
156 FE(DDSCAPS_OPTIMIZED)
157 #undef FE
159 DWORD flagmask = *((DWORD *) in);
160 for (i=0;i<sizeof(flags)/sizeof(flags[0]);i++)
161 if (flags[i].mask & flagmask)
162 DPRINTF("%s ",flags[i].name);
165 void _dump_pixelformat_flag(DWORD flagmask) {
166 int i;
167 const struct {
168 DWORD mask;
169 char *name;
170 } flags[] = {
171 #define FE(x) { x, #x},
172 FE(DDPF_ALPHAPIXELS)
173 FE(DDPF_ALPHA)
174 FE(DDPF_FOURCC)
175 FE(DDPF_PALETTEINDEXED4)
176 FE(DDPF_PALETTEINDEXEDTO8)
177 FE(DDPF_PALETTEINDEXED8)
178 FE(DDPF_RGB)
179 FE(DDPF_COMPRESSED)
180 FE(DDPF_RGBTOYUV)
181 FE(DDPF_YUV)
182 FE(DDPF_ZBUFFER)
183 FE(DDPF_PALETTEINDEXED1)
184 FE(DDPF_PALETTEINDEXED2)
185 FE(DDPF_ZPIXELS)
186 #undef FE
188 for (i=0;i<sizeof(flags)/sizeof(flags[0]);i++)
189 if (flags[i].mask & flagmask)
190 DPRINTF("%s ",flags[i].name);
193 void _dump_paletteformat(DWORD dwFlags) {
194 int i;
195 const struct {
196 DWORD mask;
197 char *name;
198 } flags[] = {
199 #define FE(x) { x, #x},
200 FE(DDPCAPS_4BIT)
201 FE(DDPCAPS_8BITENTRIES)
202 FE(DDPCAPS_8BIT)
203 FE(DDPCAPS_INITIALIZE)
204 FE(DDPCAPS_PRIMARYSURFACE)
205 FE(DDPCAPS_PRIMARYSURFACELEFT)
206 FE(DDPCAPS_ALLOW256)
207 FE(DDPCAPS_VSYNC)
208 FE(DDPCAPS_1BIT)
209 FE(DDPCAPS_2BIT)
210 FE(DDPCAPS_ALPHA)
211 #undef FE
213 for (i=0;i<sizeof(flags)/sizeof(flags[0]);i++)
214 if (flags[i].mask & dwFlags)
215 DPRINTF("%s ",flags[i].name);
216 DPRINTF("\n");
219 void _dump_pixelformat(void *in) {
220 LPDDPIXELFORMAT pf = (LPDDPIXELFORMAT) in;
222 DPRINTF("( ");
223 _dump_pixelformat_flag(pf->dwFlags);
224 if (pf->dwFlags & DDPF_FOURCC)
225 DPRINTF(", dwFourCC : %ld", pf->dwFourCC);
226 if (pf->dwFlags & DDPF_RGB) {
227 char *cmd;
228 DPRINTF(", RGB bits: %ld, ", pf->u.dwRGBBitCount);
229 switch (pf->u.dwRGBBitCount) {
230 case 4: cmd = "%1lx"; break;
231 case 8: cmd = "%02lx"; break;
232 case 16: cmd = "%04lx"; break;
233 case 24: cmd = "%06lx"; break;
234 case 32: cmd = "%08lx"; break;
235 default: ERR("Unexpected bit depth !\n"); cmd = "%d"; break;
237 DPRINTF(" R "); DPRINTF(cmd, pf->u1.dwRBitMask);
238 DPRINTF(" G "); DPRINTF(cmd, pf->u2.dwGBitMask);
239 DPRINTF(" B "); DPRINTF(cmd, pf->u3.dwBBitMask);
240 if (pf->dwFlags & DDPF_ALPHAPIXELS)
241 DPRINTF(" A "); DPRINTF(cmd, pf->u4.dwRGBAlphaBitMask);
242 if (pf->dwFlags & DDPF_ZPIXELS)
243 DPRINTF(" Z "); DPRINTF(cmd, pf->u4.dwRGBZBitMask);
245 if (pf->dwFlags & DDPF_ZBUFFER)
246 DPRINTF(", Z bits : %ld", pf->u.dwZBufferBitDepth);
247 if (pf->dwFlags & DDPF_ALPHA)
248 DPRINTF(", Alpha bits : %ld", pf->u.dwAlphaBitDepth);
249 DPRINTF(")");
252 void _dump_colorkeyflag(DWORD ck) {
253 int i;
254 const struct {
255 DWORD mask;
256 char *name;
257 } flags[] = {
258 #define FE(x) { x, #x},
259 FE(DDCKEY_COLORSPACE)
260 FE(DDCKEY_DESTBLT)
261 FE(DDCKEY_DESTOVERLAY)
262 FE(DDCKEY_SRCBLT)
263 FE(DDCKEY_SRCOVERLAY)
264 #undef FE
266 for (i=0;i<sizeof(flags)/sizeof(flags[0]);i++)
267 if (flags[i].mask & ck)
268 DPRINTF("%s ",flags[i].name);
271 static void _dump_DWORD(void *in) {
272 DPRINTF("%ld", *((DWORD *) in));
274 static void _dump_PTR(void *in) {
275 DPRINTF("%p", *((void **) in));
277 void _dump_DDCOLORKEY(void *in) {
278 DDCOLORKEY *ddck = (DDCOLORKEY *) in;
280 DPRINTF(" Low : %ld - High : %ld", ddck->dwColorSpaceLowValue, ddck->dwColorSpaceHighValue);
283 void _dump_surface_desc(DDSURFACEDESC *lpddsd) {
284 int i;
285 struct {
286 DWORD mask;
287 char *name;
288 void (*func)(void *);
289 void *elt;
290 } flags[16], *fe = flags;
291 #define FE(x,f,e) do { fe->mask = x; fe->name = #x; fe->func = f; fe->elt = (void *) &(lpddsd->e); fe++; } while(0)
292 FE(DDSD_CAPS, _dump_DDSCAPS, ddsCaps);
293 FE(DDSD_HEIGHT, _dump_DWORD, dwHeight);
294 FE(DDSD_WIDTH, _dump_DWORD, dwWidth);
295 FE(DDSD_PITCH, _dump_DWORD, lPitch);
296 FE(DDSD_BACKBUFFERCOUNT, _dump_DWORD, dwBackBufferCount);
297 FE(DDSD_ZBUFFERBITDEPTH, _dump_DWORD, u.dwZBufferBitDepth);
298 FE(DDSD_ALPHABITDEPTH, _dump_DWORD, dwAlphaBitDepth);
299 FE(DDSD_PIXELFORMAT, _dump_pixelformat, ddpfPixelFormat);
300 FE(DDSD_CKDESTOVERLAY, _dump_DDCOLORKEY, ddckCKDestOverlay);
301 FE(DDSD_CKDESTBLT, _dump_DDCOLORKEY, ddckCKDestBlt);
302 FE(DDSD_CKSRCOVERLAY, _dump_DDCOLORKEY, ddckCKSrcOverlay);
303 FE(DDSD_CKSRCBLT, _dump_DDCOLORKEY, ddckCKSrcBlt);
304 FE(DDSD_MIPMAPCOUNT, _dump_DWORD, u.dwMipMapCount);
305 FE(DDSD_REFRESHRATE, _dump_DWORD, u.dwRefreshRate);
306 FE(DDSD_LINEARSIZE, _dump_DWORD, u1.dwLinearSize);
307 FE(DDSD_LPSURFACE, _dump_PTR, u1.lpSurface);
308 #undef FE
310 for (i=0;i<sizeof(flags)/sizeof(flags[0]);i++)
311 if (flags[i].mask & lpddsd->dwFlags) {
312 DPRINTF(" - %s : ",flags[i].name);
313 flags[i].func(flags[i].elt);
314 DPRINTF("\n");
317 void _dump_cooperativelevel(DWORD cooplevel) {
318 int i;
319 const struct {
320 int mask;
321 char *name;
322 } flags[] = {
323 #define FE(x) { x, #x},
324 FE(DDSCL_FULLSCREEN)
325 FE(DDSCL_ALLOWREBOOT)
326 FE(DDSCL_NOWINDOWCHANGES)
327 FE(DDSCL_NORMAL)
328 FE(DDSCL_ALLOWMODEX)
329 FE(DDSCL_EXCLUSIVE)
330 FE(DDSCL_SETFOCUSWINDOW)
331 FE(DDSCL_SETDEVICEWINDOW)
332 FE(DDSCL_CREATEDEVICEWINDOW)
333 #undef FE
336 if (TRACE_ON(ddraw)) {
337 DPRINTF(" - ");
338 for (i=0;i<sizeof(flags)/sizeof(flags[0]);i++)
339 if (flags[i].mask & cooplevel)
340 DPRINTF("%s ",flags[i].name);
341 DPRINTF("\n");