wordpad: Apply changes on dropdown selection for comboboxes on toolbar.
[wine/multimedia.git] / dlls / ddraw / utils.c
blob2c08328595f7f908bcb481b7f4168de39e88435e
1 /*
2 * DirectDraw helper functions
4 * Copyright (c) 1997-2000 Marcus Meissner
5 * Copyright (c) 1998 Lionel Ulmer
6 * Copyright (c) 2000 TransGaming Technologies Inc.
7 * Copyright (c) 2006 Stefan Dösinger
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License as published by the Free Software Foundation; either
12 * version 2.1 of the License, or (at your option) any later version.
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with this library; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
24 #include "config.h"
26 #define NONAMELESSUNION
28 #include "ddraw_private.h"
29 #include "wine/debug.h"
31 WINE_DEFAULT_DEBUG_CHANNEL(ddraw);
34 /*****************************************************************************
35 * PixelFormat_WineD3DtoDD
37 * Converts an WINED3DFORMAT value into a DDPIXELFORMAT structure
39 * Params:
40 * DDPixelFormat: Address of the structure to write the pixel format to
41 * WineD3DFormat: Source format
43 *****************************************************************************/
44 void
45 PixelFormat_WineD3DtoDD(DDPIXELFORMAT *DDPixelFormat,
46 WINED3DFORMAT WineD3DFormat)
48 DWORD Size = DDPixelFormat->dwSize;
49 TRACE("Converting WINED3DFORMAT %d to DDRAW\n", WineD3DFormat);
51 if(Size==0) return;
53 memset(DDPixelFormat, 0x00, Size);
54 DDPixelFormat->dwSize = Size;
55 switch(WineD3DFormat)
57 case WINED3DFMT_R8G8B8:
58 DDPixelFormat->dwFlags = DDPF_RGB;
59 DDPixelFormat->dwFourCC = 0;
60 DDPixelFormat->u1.dwRGBBitCount = 24;
61 DDPixelFormat->u2.dwRBitMask = 0x00ff0000;
62 DDPixelFormat->u3.dwGBitMask = 0x0000ff00;
63 DDPixelFormat->u4.dwBBitMask = 0x000000ff;
64 DDPixelFormat->u5.dwRGBAlphaBitMask = 0x0;
65 break;
67 case WINED3DFMT_A8R8G8B8:
68 DDPixelFormat->dwFlags = DDPF_RGB | DDPF_ALPHAPIXELS;
69 DDPixelFormat->dwFourCC = 0;
70 DDPixelFormat->u1.dwRGBBitCount = 32;
71 DDPixelFormat->u2.dwRBitMask = 0x00ff0000;
72 DDPixelFormat->u3.dwGBitMask = 0x0000ff00;
73 DDPixelFormat->u4.dwBBitMask = 0x000000ff;
74 DDPixelFormat->u5.dwRGBAlphaBitMask = 0xff000000;
75 break;
77 case WINED3DFMT_X8R8G8B8:
78 DDPixelFormat->dwFlags = DDPF_RGB;
79 DDPixelFormat->dwFourCC = 0;
80 DDPixelFormat->u1.dwRGBBitCount = 32;
81 DDPixelFormat->u2.dwRBitMask = 0x00ff0000;
82 DDPixelFormat->u3.dwGBitMask = 0x0000ff00;
83 DDPixelFormat->u4.dwBBitMask = 0x000000ff;
84 DDPixelFormat->u5.dwRGBAlphaBitMask = 0x0;
85 break;
87 case WINED3DFMT_X8B8G8R8:
88 DDPixelFormat->dwFlags = DDPF_RGB;
89 DDPixelFormat->dwFourCC = 0;
90 DDPixelFormat->u1.dwRGBBitCount = 32;
91 DDPixelFormat->u2.dwRBitMask = 0x000000ff;
92 DDPixelFormat->u3.dwGBitMask = 0x0000ff00;
93 DDPixelFormat->u4.dwBBitMask = 0x00ff0000;
94 DDPixelFormat->u5.dwRGBAlphaBitMask = 0x0;
95 break;
97 case WINED3DFMT_R5G6B5:
98 DDPixelFormat->dwFlags = DDPF_RGB;
99 DDPixelFormat->dwFourCC = 0;
100 DDPixelFormat->u1.dwRGBBitCount = 16;
101 DDPixelFormat->u2.dwRBitMask = 0xF800;
102 DDPixelFormat->u3.dwGBitMask = 0x07E0;
103 DDPixelFormat->u4.dwBBitMask = 0x001F;
104 DDPixelFormat->u5.dwRGBAlphaBitMask = 0x0;
105 break;
107 case WINED3DFMT_X1R5G5B5:
108 DDPixelFormat->dwFlags = DDPF_RGB;
109 DDPixelFormat->dwFourCC = 0;
110 DDPixelFormat->u1.dwRGBBitCount = 16;
111 DDPixelFormat->u2.dwRBitMask = 0x7C00;
112 DDPixelFormat->u3.dwGBitMask = 0x03E0;
113 DDPixelFormat->u4.dwBBitMask = 0x001F;
114 DDPixelFormat->u5.dwRGBAlphaBitMask = 0x0;
115 break;
117 case WINED3DFMT_A1R5G5B5:
118 DDPixelFormat->dwFlags = DDPF_RGB | DDPF_ALPHAPIXELS;
119 DDPixelFormat->dwFourCC = 0;
120 DDPixelFormat->u1.dwRGBBitCount = 16;
121 DDPixelFormat->u2.dwRBitMask = 0x7C00;
122 DDPixelFormat->u3.dwGBitMask = 0x03E0;
123 DDPixelFormat->u4.dwBBitMask = 0x001F;
124 DDPixelFormat->u5.dwRGBAlphaBitMask = 0x8000;
125 break;
127 case WINED3DFMT_A4R4G4B4:
128 DDPixelFormat->dwFlags = DDPF_RGB | DDPF_ALPHAPIXELS;
129 DDPixelFormat->dwFourCC = 0;
130 DDPixelFormat->u1.dwRGBBitCount = 16;
131 DDPixelFormat->u2.dwRBitMask = 0x0F00;
132 DDPixelFormat->u3.dwGBitMask = 0x00F0;
133 DDPixelFormat->u4.dwBBitMask = 0x000F;
134 DDPixelFormat->u5.dwRGBAlphaBitMask = 0xF000;
135 break;
137 case WINED3DFMT_R3G3B2:
138 DDPixelFormat->dwFlags = DDPF_RGB;
139 DDPixelFormat->dwFourCC = 0;
140 DDPixelFormat->u1.dwRGBBitCount = 8;
141 DDPixelFormat->u2.dwRBitMask = 0xE0;
142 DDPixelFormat->u3.dwGBitMask = 0x1C;
143 DDPixelFormat->u4.dwBBitMask = 0x03;
144 DDPixelFormat->u5.dwLuminanceAlphaBitMask = 0x0;
145 break;
147 case WINED3DFMT_P8:
148 DDPixelFormat->dwFlags = DDPF_PALETTEINDEXED8 | DDPF_RGB;
149 DDPixelFormat->dwFourCC = 0;
150 DDPixelFormat->u1.dwRGBBitCount = 8;
151 DDPixelFormat->u2.dwRBitMask = 0x00;
152 DDPixelFormat->u3.dwGBitMask = 0x00;
153 DDPixelFormat->u4.dwBBitMask = 0x00;
154 break;
156 case WINED3DFMT_A8:
157 DDPixelFormat->dwFlags = DDPF_ALPHA;
158 DDPixelFormat->dwFourCC = 0;
159 DDPixelFormat->u1.dwAlphaBitDepth = 8;
160 DDPixelFormat->u2.dwRBitMask = 0x0;
161 DDPixelFormat->u3.dwZBitMask = 0x0;
162 DDPixelFormat->u4.dwStencilBitMask = 0x0;
163 DDPixelFormat->u5.dwLuminanceAlphaBitMask = 0x0;
164 break;
166 case WINED3DFMT_A8R3G3B2:
167 DDPixelFormat->dwFlags = DDPF_RGB | DDPF_ALPHAPIXELS;
168 DDPixelFormat->dwFourCC = 0;
169 DDPixelFormat->u1.dwRGBBitCount = 16;
170 DDPixelFormat->u2.dwRBitMask = 0x00E0;
171 DDPixelFormat->u3.dwGBitMask = 0x001C;
172 DDPixelFormat->u4.dwBBitMask = 0x0003;
173 DDPixelFormat->u5.dwRGBAlphaBitMask = 0xF000;
174 break;
176 case WINED3DFMT_X4R4G4B4:
177 DDPixelFormat->dwFlags = DDPF_RGB;
178 DDPixelFormat->dwFourCC = 0;
179 DDPixelFormat->u1.dwRGBBitCount = 16;
180 DDPixelFormat->u2.dwRBitMask = 0x0F00;
181 DDPixelFormat->u3.dwGBitMask = 0x00F0;
182 DDPixelFormat->u4.dwBBitMask = 0x000F;
183 DDPixelFormat->u5.dwRGBAlphaBitMask = 0x0;
184 return;
186 /* How are Z buffer bit depth and Stencil buffer bit depth related?
188 case WINED3DFMT_D16:
189 DDPixelFormat->dwFlags = DDPF_ZBUFFER;
190 DDPixelFormat->dwFourCC = 0;
191 DDPixelFormat->u1.dwZBufferBitDepth = 16;
192 DDPixelFormat->u2.dwStencilBitDepth = 0;
193 DDPixelFormat->u3.dwZBitMask = 0x0000FFFF;
194 DDPixelFormat->u4.dwStencilBitMask = 0x0;
195 DDPixelFormat->u5.dwRGBZBitMask = 0x00000000;
196 break;
198 case WINED3DFMT_D32:
199 DDPixelFormat->dwFlags = DDPF_ZBUFFER;
200 DDPixelFormat->dwFourCC = 0;
201 DDPixelFormat->u1.dwZBufferBitDepth = 32;
202 DDPixelFormat->u2.dwStencilBitDepth = 0;
203 DDPixelFormat->u3.dwZBitMask = 0xFFFFFFFF;
204 DDPixelFormat->u4.dwStencilBitMask = 0x0;
205 DDPixelFormat->u5.dwRGBZBitMask = 0x00000000;
206 break;
208 case WINED3DFMT_D24X4S4:
209 DDPixelFormat->dwFlags = DDPF_ZBUFFER | DDPF_STENCILBUFFER;
210 DDPixelFormat->dwFourCC = 0;
211 /* Should I set dwZBufferBitDepth to 32 here? */
212 DDPixelFormat->u1.dwZBufferBitDepth = 32;
213 DDPixelFormat->u2.dwStencilBitDepth = 4;
214 DDPixelFormat->u3.dwZBitMask = 0x00FFFFFF;
215 DDPixelFormat->u4.dwStencilBitMask = 0x0F000000;
216 DDPixelFormat->u5.dwRGBAlphaBitMask = 0x0;
217 break;
219 case WINED3DFMT_D24S8:
220 DDPixelFormat->dwFlags = DDPF_ZBUFFER | DDPF_STENCILBUFFER;
221 DDPixelFormat->dwFourCC = 0;
222 /* Should I set dwZBufferBitDepth to 32 here? */
223 DDPixelFormat->u1.dwZBufferBitDepth = 32;
224 DDPixelFormat->u2.dwStencilBitDepth = 8;
225 DDPixelFormat->u3.dwZBitMask = 0x00FFFFFFFF;
226 DDPixelFormat->u4.dwStencilBitMask = 0xFF000000;
227 DDPixelFormat->u5.dwRGBAlphaBitMask = 0x0;
228 break;
230 case WINED3DFMT_D24X8:
231 DDPixelFormat->dwFlags = DDPF_ZBUFFER;
232 DDPixelFormat->dwFourCC = 0;
233 DDPixelFormat->u1.dwZBufferBitDepth = 32;
234 DDPixelFormat->u2.dwStencilBitDepth = 0;
235 DDPixelFormat->u3.dwZBitMask = 0x00FFFFFFFF;
236 DDPixelFormat->u4.dwStencilBitMask = 0x00000000;
237 DDPixelFormat->u5.dwRGBAlphaBitMask = 0x0;
239 break;
240 case WINED3DFMT_D15S1:
241 DDPixelFormat->dwFlags = DDPF_ZBUFFER | DDPF_STENCILBUFFER;
242 DDPixelFormat->dwFourCC = 0;
243 DDPixelFormat->u1.dwZBufferBitDepth = 16;
244 DDPixelFormat->u2.dwStencilBitDepth = 1;
245 DDPixelFormat->u3.dwZBitMask = 0x7fff;
246 DDPixelFormat->u4.dwStencilBitMask = 0x8000;
247 DDPixelFormat->u5.dwRGBAlphaBitMask = 0x0;
248 break;
250 case WINED3DFMT_UYVY:
251 case WINED3DFMT_YUY2:
252 case WINED3DFMT_YV12:
253 case WINED3DFMT_DXT1:
254 case WINED3DFMT_DXT2:
255 case WINED3DFMT_DXT3:
256 case WINED3DFMT_DXT4:
257 case WINED3DFMT_DXT5:
258 case WINED3DFMT_MULTI2_ARGB8:
259 case WINED3DFMT_G8R8_G8B8:
260 case WINED3DFMT_R8G8_B8G8:
261 DDPixelFormat->dwFlags = DDPF_FOURCC;
262 DDPixelFormat->dwFourCC = WineD3DFormat;
263 break;
265 /* Luminance */
266 case WINED3DFMT_L8:
267 DDPixelFormat->dwFlags = DDPF_LUMINANCE;
268 DDPixelFormat->dwFourCC = 0;
269 DDPixelFormat->u1.dwLuminanceBitCount = 8;
270 DDPixelFormat->u2.dwLuminanceBitMask = 0xff;
271 DDPixelFormat->u3.dwBumpDvBitMask = 0x0;
272 DDPixelFormat->u4.dwBumpLuminanceBitMask = 0x0;
273 DDPixelFormat->u5.dwLuminanceAlphaBitMask = 0x0;
274 break;
276 case WINED3DFMT_A4L4:
277 DDPixelFormat->dwFlags = DDPF_ALPHAPIXELS | DDPF_LUMINANCE;
278 DDPixelFormat->dwFourCC = 0;
279 DDPixelFormat->u1.dwLuminanceBitCount = 4;
280 DDPixelFormat->u2.dwLuminanceBitMask = 0x0f;
281 DDPixelFormat->u3.dwBumpDvBitMask = 0x0;
282 DDPixelFormat->u4.dwBumpLuminanceBitMask = 0x0;
283 DDPixelFormat->u5.dwLuminanceAlphaBitMask = 0xf0;
284 break;
286 case WINED3DFMT_A8L8:
287 DDPixelFormat->dwFlags = DDPF_ALPHAPIXELS | DDPF_LUMINANCE;
288 DDPixelFormat->dwFourCC = 0;
289 DDPixelFormat->u1.dwLuminanceBitCount = 16;
290 DDPixelFormat->u2.dwLuminanceBitMask = 0x00ff;
291 DDPixelFormat->u3.dwBumpDvBitMask = 0x0;
292 DDPixelFormat->u4.dwBumpLuminanceBitMask = 0x0;
293 DDPixelFormat->u5.dwLuminanceAlphaBitMask = 0xff00;
294 break;
296 /* Bump mapping */
297 case WINED3DFMT_V8U8:
298 DDPixelFormat->dwFlags = DDPF_BUMPDUDV;
299 DDPixelFormat->dwFourCC = 0;
300 DDPixelFormat->u1.dwBumpBitCount = 16;
301 DDPixelFormat->u2.dwBumpDuBitMask = 0x000000ff;
302 DDPixelFormat->u3.dwBumpDvBitMask = 0x0000ff00;
303 DDPixelFormat->u4.dwBumpLuminanceBitMask = 0x00000000;
304 DDPixelFormat->u5.dwLuminanceAlphaBitMask = 0x00000000;
305 break;
307 case WINED3DFMT_L6V5U5:
308 DDPixelFormat->dwFlags = DDPF_BUMPDUDV;
309 DDPixelFormat->dwFourCC = 0;
310 DDPixelFormat->u1.dwBumpBitCount = 16;
311 DDPixelFormat->u2.dwBumpDuBitMask = 0x0000001f;
312 DDPixelFormat->u3.dwBumpDvBitMask = 0x000003e0;
313 DDPixelFormat->u4.dwBumpLuminanceBitMask = 0x0000fc00;
314 DDPixelFormat->u5.dwLuminanceAlphaBitMask = 0x00000000;
315 break;
317 default:
318 ERR("Can't translate this Pixelformat %d\n", WineD3DFormat);
321 if(TRACE_ON(ddraw)) {
322 TRACE("Returning: ");
323 DDRAW_dump_pixelformat(DDPixelFormat);
326 /*****************************************************************************
327 * PixelFormat_DD2WineD3D
329 * Reads a DDPIXELFORMAT structure and returns the equal WINED3DFORMAT
331 * Params:
332 * DDPixelFormat: The source format
334 * Returns:
335 * The WINED3DFORMAT equal to the DDraw format
336 * WINED3DFMT_UNKNOWN if a matching format wasn't found
337 *****************************************************************************/
338 WINED3DFORMAT
339 PixelFormat_DD2WineD3D(const DDPIXELFORMAT *DDPixelFormat)
341 TRACE("Convert a DirectDraw Pixelformat to a WineD3D Pixelformat\n");
342 if(TRACE_ON(ddraw))
344 DDRAW_dump_pixelformat(DDPixelFormat);
347 if(DDPixelFormat->dwFlags & DDPF_PALETTEINDEXED8)
349 return WINED3DFMT_P8;
351 else if(DDPixelFormat->dwFlags & (DDPF_PALETTEINDEXED1 | DDPF_PALETTEINDEXED2 | DDPF_PALETTEINDEXED4) )
353 FIXME("DDPF_PALETTEINDEXED1 to DDPF_PALETTEINDEXED4 are not supported by WineD3D (yet). Returning WINED3DFMT_P8\n");
354 return WINED3DFMT_P8;
356 else if(DDPixelFormat->dwFlags & DDPF_RGB)
358 switch(DDPixelFormat->u1.dwRGBBitCount)
360 case 8:
361 /* This is the only format that can match here */
362 return WINED3DFMT_R3G3B2;
364 case 16:
365 /* Read the Color masks */
366 if( (DDPixelFormat->u2.dwRBitMask == 0xF800) &&
367 (DDPixelFormat->u3.dwGBitMask == 0x07E0) &&
368 (DDPixelFormat->u4.dwBBitMask == 0x001F) )
370 return WINED3DFMT_R5G6B5;
373 if( (DDPixelFormat->u2.dwRBitMask == 0x7C00) &&
374 (DDPixelFormat->u3.dwGBitMask == 0x03E0) &&
375 (DDPixelFormat->u4.dwBBitMask == 0x001F) )
377 if( (DDPixelFormat->dwFlags & DDPF_ALPHAPIXELS) &&
378 (DDPixelFormat->u5.dwRGBAlphaBitMask == 0x8000))
379 return WINED3DFMT_A1R5G5B5;
380 else
381 return WINED3DFMT_X1R5G5B5;
384 if( (DDPixelFormat->u2.dwRBitMask == 0x0F00) &&
385 (DDPixelFormat->u3.dwGBitMask == 0x00F0) &&
386 (DDPixelFormat->u4.dwBBitMask == 0x000F) )
388 if( (DDPixelFormat->dwFlags & DDPF_ALPHAPIXELS) &&
389 (DDPixelFormat->u5.dwRGBAlphaBitMask == 0xF000))
390 return WINED3DFMT_A4R4G4B4;
391 else
392 return WINED3DFMT_X4R4G4B4;
395 if( (DDPixelFormat->dwFlags & DDPF_ALPHAPIXELS) &&
396 (DDPixelFormat->u5.dwRGBAlphaBitMask == 0xFF00) &&
397 (DDPixelFormat->u2.dwRBitMask == 0x00E0) &&
398 (DDPixelFormat->u3.dwGBitMask == 0x001C) &&
399 (DDPixelFormat->u4.dwBBitMask == 0x0003) )
401 return WINED3DFMT_A8R3G3B2;
403 ERR("16 bit RGB Pixel format does not match\n");
404 return WINED3DFMT_UNKNOWN;
406 case 24:
407 return WINED3DFMT_R8G8B8;
409 case 32:
410 /* Read the Color masks */
411 if( (DDPixelFormat->u2.dwRBitMask == 0x00FF0000) &&
412 (DDPixelFormat->u3.dwGBitMask == 0x0000FF00) &&
413 (DDPixelFormat->u4.dwBBitMask == 0x000000FF) )
415 if( (DDPixelFormat->dwFlags & DDPF_ALPHAPIXELS) &&
416 (DDPixelFormat->u5.dwRGBAlphaBitMask == 0xFF000000))
417 return WINED3DFMT_A8R8G8B8;
418 else
419 return WINED3DFMT_X8R8G8B8;
422 ERR("32 bit RGB pixel format does not match\n");
424 default:
425 ERR("Invalid dwRGBBitCount in Pixelformat structure\n");
426 return WINED3DFMT_UNKNOWN;
429 else if( (DDPixelFormat->dwFlags & DDPF_ALPHA) )
431 /* Alpha only Pixelformat */
432 switch(DDPixelFormat->u1.dwAlphaBitDepth)
434 case 1:
435 case 2:
436 case 4:
437 ERR("Unsupported Alpha-Only bit depth 0x%x\n", DDPixelFormat->u1.dwAlphaBitDepth);
438 case 8:
439 return WINED3DFMT_A8;
441 default:
442 ERR("Invalid AlphaBitDepth in Alpha-Only Pixelformat\n");
443 return WINED3DFMT_UNKNOWN;
446 else if(DDPixelFormat->dwFlags & DDPF_LUMINANCE)
448 /* Luminance-only or luminance-alpha */
449 if(DDPixelFormat->dwFlags & DDPF_ALPHAPIXELS)
451 /* Luminance with Alpha */
452 switch(DDPixelFormat->u1.dwLuminanceBitCount)
454 case 4:
455 if(DDPixelFormat->u1.dwAlphaBitDepth == 4)
456 return WINED3DFMT_A4L4;
457 ERR("Unknown Alpha / Luminance bit depth combination\n");
458 return WINED3DFMT_UNKNOWN;
460 case 6:
461 ERR("A luminance Pixelformat shouldn't have 6 luminance bits. Returning D3DFMT_L6V5U5 for now!!\n");
462 return WINED3DFMT_L6V5U5;
464 case 8:
465 if(DDPixelFormat->u1.dwAlphaBitDepth == 8)
466 return WINED3DFMT_A8L8;
467 ERR("Unknown Alpha / Lumincase bit depth combination\n");
468 return WINED3DFMT_UNKNOWN;
471 else
473 /* Luminance-only */
474 switch(DDPixelFormat->u1.dwLuminanceBitCount)
476 case 6:
477 ERR("A luminance Pixelformat shouldn't have 6 luminance bits. Returning D3DFMT_L6V5U5 for now!!\n");
478 return WINED3DFMT_L6V5U5;
480 case 8:
481 return WINED3DFMT_L8;
483 default:
484 ERR("Unknown luminance-only bit depth 0x%x\n", DDPixelFormat->u1.dwLuminanceBitCount);
485 return WINED3DFMT_UNKNOWN;
489 else if(DDPixelFormat->dwFlags & DDPF_ZBUFFER)
491 /* Z buffer */
492 if(DDPixelFormat->dwFlags & DDPF_STENCILBUFFER)
494 switch(DDPixelFormat->u1.dwZBufferBitDepth)
496 case 8:
497 FIXME("8 Bits Z+Stencil buffer pixelformat is not supported. Returning WINED3DFMT_UNKNOWN\n");
498 return WINED3DFMT_UNKNOWN;
500 case 15:
501 FIXME("15 bit depth buffer not handled yet, assuming 16 bit\n");
502 case 16:
503 if(DDPixelFormat->u2.dwStencilBitDepth == 1)
504 return WINED3DFMT_D15S1;
506 FIXME("Don't know how to handle a 16 bit Z buffer with %d bit stencil buffer pixelformat\n", DDPixelFormat->u2.dwStencilBitDepth);
507 return WINED3DFMT_UNKNOWN;
509 case 24:
510 FIXME("Don't know how to handle a 24 bit depth buffer with stencil bits\n");
511 return WINED3DFMT_D24S8;
513 case 32:
514 if(DDPixelFormat->u2.dwStencilBitDepth == 8)
515 return WINED3DFMT_D24S8;
516 else
517 return WINED3DFMT_D24X4S4;
519 default:
520 ERR("Unknown Z buffer depth %d\n", DDPixelFormat->u1.dwZBufferBitDepth);
521 return WINED3DFMT_UNKNOWN;
524 else
526 switch(DDPixelFormat->u1.dwZBufferBitDepth)
528 case 8:
529 ERR("8 Bit Z buffers are not supported. Trying a 16 Bit one\n");
530 return WINED3DFMT_D16;
532 case 16:
533 return WINED3DFMT_D16;
535 case 24:
536 FIXME("24 Bit depth buffer, treating like a 32 bit one\n");
537 case 32:
538 if(DDPixelFormat->u3.dwZBitMask == 0x00FFFFFF) {
539 return WINED3DFMT_D24X8;
540 } else if(DDPixelFormat->u3.dwZBitMask == 0xFFFFFFFF) {
541 return WINED3DFMT_D32;
543 FIXME("Unhandled 32 bit depth buffer bitmasks, returning WINED3DFMT_D24X8\n");
544 return WINED3DFMT_D24X8; /* That's most likely to make games happy */
546 default:
547 ERR("Unsupported Z buffer depth %d\n", DDPixelFormat->u1.dwZBufferBitDepth);
548 return WINED3DFMT_UNKNOWN;
552 else if(DDPixelFormat->dwFlags & DDPF_FOURCC)
554 if(DDPixelFormat->dwFourCC == MAKEFOURCC('U', 'Y', 'V', 'Y'))
556 return WINED3DFMT_UYVY;
558 if(DDPixelFormat->dwFourCC == MAKEFOURCC('Y', 'U', 'Y', '2'))
560 return WINED3DFMT_YUY2;
562 if(DDPixelFormat->dwFourCC == MAKEFOURCC('Y', 'V', '1', '2'))
564 return WINED3DFMT_YV12;
566 if(DDPixelFormat->dwFourCC == MAKEFOURCC('D', 'X', 'T', '1'))
568 return WINED3DFMT_DXT1;
570 if(DDPixelFormat->dwFourCC == MAKEFOURCC('D', 'X', 'T', '2'))
572 return WINED3DFMT_DXT2;
574 if(DDPixelFormat->dwFourCC == MAKEFOURCC('D', 'X', 'T', '3'))
576 return WINED3DFMT_DXT3;
578 if(DDPixelFormat->dwFourCC == MAKEFOURCC('D', 'X', 'T', '4'))
580 return WINED3DFMT_DXT4;
582 if(DDPixelFormat->dwFourCC == MAKEFOURCC('D', 'X', 'T', '5'))
584 return WINED3DFMT_DXT5;
586 if(DDPixelFormat->dwFourCC == MAKEFOURCC('G', 'R', 'G', 'B'))
588 return WINED3DFMT_G8R8_G8B8;
590 if(DDPixelFormat->dwFourCC == MAKEFOURCC('R', 'G', 'B', 'G'))
592 return WINED3DFMT_R8G8_B8G8;
594 return WINED3DFMT_UNKNOWN; /* Abuse this as an error value */
596 else if(DDPixelFormat->dwFlags & DDPF_BUMPDUDV)
598 if( (DDPixelFormat->u1.dwBumpBitCount == 16 ) &&
599 (DDPixelFormat->u2.dwBumpDuBitMask == 0x000000ff) &&
600 (DDPixelFormat->u3.dwBumpDvBitMask == 0x0000ff00) &&
601 (DDPixelFormat->u4.dwBumpLuminanceBitMask == 0x00000000) )
603 return WINED3DFMT_V8U8;
605 else if ( (DDPixelFormat->u1.dwBumpBitCount == 16 ) &&
606 (DDPixelFormat->u2.dwBumpDuBitMask == 0x0000001f) &&
607 (DDPixelFormat->u3.dwBumpDvBitMask == 0x000003e0) &&
608 (DDPixelFormat->u4.dwBumpLuminanceBitMask == 0x0000fc00) )
610 return WINED3DFMT_L6V5U5;
614 ERR("Unknown Pixelformat!\n");
615 return WINED3DFMT_UNKNOWN;
618 /*****************************************************************************
619 * Various dumping functions.
621 * They write the contents of a specific function to a TRACE.
623 *****************************************************************************/
624 static void
625 DDRAW_dump_DWORD(const void *in)
627 TRACE("%d\n", *((const DWORD *) in));
629 static void
630 DDRAW_dump_PTR(const void *in)
632 TRACE("%p\n", *((const void * const*) in));
634 static void
635 DDRAW_dump_DDCOLORKEY(const DDCOLORKEY *ddck)
637 TRACE("Low : %d - High : %d\n", ddck->dwColorSpaceLowValue, ddck->dwColorSpaceHighValue);
640 static void DDRAW_dump_flags_nolf(DWORD flags, const flag_info* names,
641 size_t num_names)
643 unsigned int i;
645 for (i=0; i < num_names; i++)
646 if ((flags & names[i].val) || /* standard flag value */
647 ((!flags) && (!names[i].val))) /* zero value only */
648 TRACE("%s ", names[i].name);
651 static void DDRAW_dump_flags(DWORD flags, const flag_info* names, size_t num_names)
653 DDRAW_dump_flags_nolf(flags, names, num_names);
654 TRACE("\n");
657 void DDRAW_dump_DDSCAPS2(const DDSCAPS2 *in)
659 static const flag_info flags[] = {
660 FE(DDSCAPS_RESERVED1),
661 FE(DDSCAPS_ALPHA),
662 FE(DDSCAPS_BACKBUFFER),
663 FE(DDSCAPS_COMPLEX),
664 FE(DDSCAPS_FLIP),
665 FE(DDSCAPS_FRONTBUFFER),
666 FE(DDSCAPS_OFFSCREENPLAIN),
667 FE(DDSCAPS_OVERLAY),
668 FE(DDSCAPS_PALETTE),
669 FE(DDSCAPS_PRIMARYSURFACE),
670 FE(DDSCAPS_PRIMARYSURFACELEFT),
671 FE(DDSCAPS_SYSTEMMEMORY),
672 FE(DDSCAPS_TEXTURE),
673 FE(DDSCAPS_3DDEVICE),
674 FE(DDSCAPS_VIDEOMEMORY),
675 FE(DDSCAPS_VISIBLE),
676 FE(DDSCAPS_WRITEONLY),
677 FE(DDSCAPS_ZBUFFER),
678 FE(DDSCAPS_OWNDC),
679 FE(DDSCAPS_LIVEVIDEO),
680 FE(DDSCAPS_HWCODEC),
681 FE(DDSCAPS_MODEX),
682 FE(DDSCAPS_MIPMAP),
683 FE(DDSCAPS_RESERVED2),
684 FE(DDSCAPS_ALLOCONLOAD),
685 FE(DDSCAPS_VIDEOPORT),
686 FE(DDSCAPS_LOCALVIDMEM),
687 FE(DDSCAPS_NONLOCALVIDMEM),
688 FE(DDSCAPS_STANDARDVGAMODE),
689 FE(DDSCAPS_OPTIMIZED)
691 static const flag_info flags2[] = {
692 FE(DDSCAPS2_HARDWAREDEINTERLACE),
693 FE(DDSCAPS2_HINTDYNAMIC),
694 FE(DDSCAPS2_HINTSTATIC),
695 FE(DDSCAPS2_TEXTUREMANAGE),
696 FE(DDSCAPS2_RESERVED1),
697 FE(DDSCAPS2_RESERVED2),
698 FE(DDSCAPS2_OPAQUE),
699 FE(DDSCAPS2_HINTANTIALIASING),
700 FE(DDSCAPS2_CUBEMAP),
701 FE(DDSCAPS2_CUBEMAP_POSITIVEX),
702 FE(DDSCAPS2_CUBEMAP_NEGATIVEX),
703 FE(DDSCAPS2_CUBEMAP_POSITIVEY),
704 FE(DDSCAPS2_CUBEMAP_NEGATIVEY),
705 FE(DDSCAPS2_CUBEMAP_POSITIVEZ),
706 FE(DDSCAPS2_CUBEMAP_NEGATIVEZ),
707 FE(DDSCAPS2_MIPMAPSUBLEVEL),
708 FE(DDSCAPS2_D3DTEXTUREMANAGE),
709 FE(DDSCAPS2_DONOTPERSIST),
710 FE(DDSCAPS2_STEREOSURFACELEFT)
713 DDRAW_dump_flags_nolf(in->dwCaps, flags, sizeof(flags)/sizeof(flags[0]));
714 DDRAW_dump_flags(in->dwCaps2, flags2, sizeof(flags2)/sizeof(flags2[0]));
717 void
718 DDRAW_dump_DDSCAPS(const DDSCAPS *in)
720 DDSCAPS2 in_bis;
722 in_bis.dwCaps = in->dwCaps;
723 in_bis.dwCaps2 = 0;
724 in_bis.dwCaps3 = 0;
725 in_bis.dwCaps4 = 0;
727 DDRAW_dump_DDSCAPS2(&in_bis);
730 static void
731 DDRAW_dump_pixelformat_flag(DWORD flagmask)
733 static const flag_info flags[] =
735 FE(DDPF_ALPHAPIXELS),
736 FE(DDPF_ALPHA),
737 FE(DDPF_FOURCC),
738 FE(DDPF_PALETTEINDEXED4),
739 FE(DDPF_PALETTEINDEXEDTO8),
740 FE(DDPF_PALETTEINDEXED8),
741 FE(DDPF_RGB),
742 FE(DDPF_COMPRESSED),
743 FE(DDPF_RGBTOYUV),
744 FE(DDPF_YUV),
745 FE(DDPF_ZBUFFER),
746 FE(DDPF_PALETTEINDEXED1),
747 FE(DDPF_PALETTEINDEXED2),
748 FE(DDPF_ZPIXELS)
751 DDRAW_dump_flags_nolf(flagmask, flags, sizeof(flags)/sizeof(flags[0]));
754 static void
755 DDRAW_dump_members(DWORD flags,
756 const void* data,
757 const member_info* mems,
758 size_t num_mems)
760 unsigned int i;
762 for (i=0; i < num_mems; i++)
764 if (mems[i].val & flags)
766 TRACE(" - %s : ", mems[i].name);
767 mems[i].func((const char *)data + mems[i].offset);
772 void
773 DDRAW_dump_pixelformat(const DDPIXELFORMAT *pf)
775 TRACE("( ");
776 DDRAW_dump_pixelformat_flag(pf->dwFlags);
777 if (pf->dwFlags & DDPF_FOURCC)
779 TRACE(", dwFourCC code '%c%c%c%c' (0x%08x) - %d bits per pixel",
780 (unsigned char)( pf->dwFourCC &0xff),
781 (unsigned char)((pf->dwFourCC>> 8)&0xff),
782 (unsigned char)((pf->dwFourCC>>16)&0xff),
783 (unsigned char)((pf->dwFourCC>>24)&0xff),
784 pf->dwFourCC,
785 pf->u1.dwYUVBitCount
788 if (pf->dwFlags & DDPF_RGB)
790 const char *cmd;
791 TRACE(", RGB bits: %d, ", pf->u1.dwRGBBitCount);
792 switch (pf->u1.dwRGBBitCount)
794 case 4: cmd = "%1lx"; break;
795 case 8: cmd = "%02lx"; break;
796 case 16: cmd = "%04lx"; break;
797 case 24: cmd = "%06lx"; break;
798 case 32: cmd = "%08lx"; break;
799 default: ERR("Unexpected bit depth !\n"); cmd = "%d"; break;
801 TRACE(" R "); TRACE(cmd, pf->u2.dwRBitMask);
802 TRACE(" G "); TRACE(cmd, pf->u3.dwGBitMask);
803 TRACE(" B "); TRACE(cmd, pf->u4.dwBBitMask);
804 if (pf->dwFlags & DDPF_ALPHAPIXELS)
806 TRACE(" A "); TRACE(cmd, pf->u5.dwRGBAlphaBitMask);
808 if (pf->dwFlags & DDPF_ZPIXELS)
810 TRACE(" Z "); TRACE(cmd, pf->u5.dwRGBZBitMask);
813 if (pf->dwFlags & DDPF_ZBUFFER)
815 TRACE(", Z bits : %d", pf->u1.dwZBufferBitDepth);
817 if (pf->dwFlags & DDPF_ALPHA)
819 TRACE(", Alpha bits : %d", pf->u1.dwAlphaBitDepth);
821 if (pf->dwFlags & DDPF_BUMPDUDV)
823 const char *cmd = "%08lx";
824 TRACE(", Bump bits: %d, ", pf->u1.dwBumpBitCount);
825 TRACE(" U "); TRACE(cmd, pf->u2.dwBumpDuBitMask);
826 TRACE(" V "); TRACE(cmd, pf->u3.dwBumpDvBitMask);
827 TRACE(" L "); TRACE(cmd, pf->u4.dwBumpLuminanceBitMask);
829 TRACE(")\n");
832 void DDRAW_dump_surface_desc(const DDSURFACEDESC2 *lpddsd)
834 #define STRUCT DDSURFACEDESC2
835 static const member_info members[] =
837 ME(DDSD_HEIGHT, DDRAW_dump_DWORD, dwHeight),
838 ME(DDSD_WIDTH, DDRAW_dump_DWORD, dwWidth),
839 ME(DDSD_PITCH, DDRAW_dump_DWORD, u1 /* lPitch */),
840 ME(DDSD_LINEARSIZE, DDRAW_dump_DWORD, u1 /* dwLinearSize */),
841 ME(DDSD_BACKBUFFERCOUNT, DDRAW_dump_DWORD, dwBackBufferCount),
842 ME(DDSD_MIPMAPCOUNT, DDRAW_dump_DWORD, u2 /* dwMipMapCount */),
843 ME(DDSD_ZBUFFERBITDEPTH, DDRAW_dump_DWORD, u2 /* dwZBufferBitDepth */), /* This is for 'old-style' D3D */
844 ME(DDSD_REFRESHRATE, DDRAW_dump_DWORD, u2 /* dwRefreshRate */),
845 ME(DDSD_ALPHABITDEPTH, DDRAW_dump_DWORD, dwAlphaBitDepth),
846 ME(DDSD_LPSURFACE, DDRAW_dump_PTR, lpSurface),
847 ME(DDSD_CKDESTOVERLAY, DDRAW_dump_DDCOLORKEY, u3 /* ddckCKDestOverlay */),
848 ME(DDSD_CKDESTBLT, DDRAW_dump_DDCOLORKEY, ddckCKDestBlt),
849 ME(DDSD_CKSRCOVERLAY, DDRAW_dump_DDCOLORKEY, ddckCKSrcOverlay),
850 ME(DDSD_CKSRCBLT, DDRAW_dump_DDCOLORKEY, ddckCKSrcBlt),
851 ME(DDSD_PIXELFORMAT, DDRAW_dump_pixelformat, u4 /* ddpfPixelFormat */)
853 static const member_info members_caps[] =
855 ME(DDSD_CAPS, DDRAW_dump_DDSCAPS, ddsCaps)
857 static const member_info members_caps2[] =
859 ME(DDSD_CAPS, DDRAW_dump_DDSCAPS2, ddsCaps)
861 #undef STRUCT
863 if (NULL == lpddsd)
865 TRACE("(null)\n");
867 else
869 if (lpddsd->dwSize >= sizeof(DDSURFACEDESC2))
871 DDRAW_dump_members(lpddsd->dwFlags, lpddsd, members_caps2, 1);
873 else
875 DDRAW_dump_members(lpddsd->dwFlags, lpddsd, members_caps, 1);
877 DDRAW_dump_members(lpddsd->dwFlags, lpddsd, members,
878 sizeof(members)/sizeof(members[0]));
882 void
883 dump_D3DMATRIX(const D3DMATRIX *mat)
885 TRACE(" %f %f %f %f\n", mat->_11, mat->_12, mat->_13, mat->_14);
886 TRACE(" %f %f %f %f\n", mat->_21, mat->_22, mat->_23, mat->_24);
887 TRACE(" %f %f %f %f\n", mat->_31, mat->_32, mat->_33, mat->_34);
888 TRACE(" %f %f %f %f\n", mat->_41, mat->_42, mat->_43, mat->_44);
891 DWORD
892 get_flexible_vertex_size(DWORD d3dvtVertexType)
894 DWORD size = 0;
895 int i;
897 if (d3dvtVertexType & D3DFVF_NORMAL) size += 3 * sizeof(D3DVALUE);
898 if (d3dvtVertexType & D3DFVF_DIFFUSE) size += sizeof(DWORD);
899 if (d3dvtVertexType & D3DFVF_SPECULAR) size += sizeof(DWORD);
900 if (d3dvtVertexType & D3DFVF_RESERVED1) size += sizeof(DWORD);
901 switch (d3dvtVertexType & D3DFVF_POSITION_MASK)
903 case D3DFVF_XYZ: size += 3 * sizeof(D3DVALUE); break;
904 case D3DFVF_XYZRHW: size += 4 * sizeof(D3DVALUE); break;
905 case D3DFVF_XYZB1: size += 4 * sizeof(D3DVALUE); break;
906 case D3DFVF_XYZB2: size += 5 * sizeof(D3DVALUE); break;
907 case D3DFVF_XYZB3: size += 6 * sizeof(D3DVALUE); break;
908 case D3DFVF_XYZB4: size += 7 * sizeof(D3DVALUE); break;
909 case D3DFVF_XYZB5: size += 8 * sizeof(D3DVALUE); break;
910 default: ERR("Unexpected position mask\n");
912 for (i = 0; i < GET_TEXCOUNT_FROM_FVF(d3dvtVertexType); i++)
914 size += GET_TEXCOORD_SIZE_FROM_FVF(d3dvtVertexType, i) * sizeof(D3DVALUE);
917 return size;
920 void DDRAW_Convert_DDSCAPS_1_To_2(const DDSCAPS* pIn, DDSCAPS2* pOut)
922 /* 2 adds three additional caps fields to the end. Both versions
923 * are unversioned. */
924 pOut->dwCaps = pIn->dwCaps;
925 pOut->dwCaps2 = 0;
926 pOut->dwCaps3 = 0;
927 pOut->dwCaps4 = 0;
930 void DDRAW_Convert_DDDEVICEIDENTIFIER_2_To_1(const DDDEVICEIDENTIFIER2* pIn, DDDEVICEIDENTIFIER* pOut)
932 /* 2 adds a dwWHQLLevel field to the end. Both structures are
933 * unversioned. */
934 memcpy(pOut, pIn, sizeof(*pOut));
937 void DDRAW_dump_cooperativelevel(DWORD cooplevel)
939 static const flag_info flags[] =
941 FE(DDSCL_FULLSCREEN),
942 FE(DDSCL_ALLOWREBOOT),
943 FE(DDSCL_NOWINDOWCHANGES),
944 FE(DDSCL_NORMAL),
945 FE(DDSCL_ALLOWMODEX),
946 FE(DDSCL_EXCLUSIVE),
947 FE(DDSCL_SETFOCUSWINDOW),
948 FE(DDSCL_SETDEVICEWINDOW),
949 FE(DDSCL_CREATEDEVICEWINDOW)
952 if (TRACE_ON(ddraw))
954 TRACE(" - ");
955 DDRAW_dump_flags(cooplevel, flags, sizeof(flags)/sizeof(flags[0]));
959 void DDRAW_dump_DDCAPS(const DDCAPS *lpcaps)
961 static const flag_info flags1[] =
963 FE(DDCAPS_3D),
964 FE(DDCAPS_ALIGNBOUNDARYDEST),
965 FE(DDCAPS_ALIGNSIZEDEST),
966 FE(DDCAPS_ALIGNBOUNDARYSRC),
967 FE(DDCAPS_ALIGNSIZESRC),
968 FE(DDCAPS_ALIGNSTRIDE),
969 FE(DDCAPS_BLT),
970 FE(DDCAPS_BLTQUEUE),
971 FE(DDCAPS_BLTFOURCC),
972 FE(DDCAPS_BLTSTRETCH),
973 FE(DDCAPS_GDI),
974 FE(DDCAPS_OVERLAY),
975 FE(DDCAPS_OVERLAYCANTCLIP),
976 FE(DDCAPS_OVERLAYFOURCC),
977 FE(DDCAPS_OVERLAYSTRETCH),
978 FE(DDCAPS_PALETTE),
979 FE(DDCAPS_PALETTEVSYNC),
980 FE(DDCAPS_READSCANLINE),
981 FE(DDCAPS_STEREOVIEW),
982 FE(DDCAPS_VBI),
983 FE(DDCAPS_ZBLTS),
984 FE(DDCAPS_ZOVERLAYS),
985 FE(DDCAPS_COLORKEY),
986 FE(DDCAPS_ALPHA),
987 FE(DDCAPS_COLORKEYHWASSIST),
988 FE(DDCAPS_NOHARDWARE),
989 FE(DDCAPS_BLTCOLORFILL),
990 FE(DDCAPS_BANKSWITCHED),
991 FE(DDCAPS_BLTDEPTHFILL),
992 FE(DDCAPS_CANCLIP),
993 FE(DDCAPS_CANCLIPSTRETCHED),
994 FE(DDCAPS_CANBLTSYSMEM)
996 static const flag_info flags2[] =
998 FE(DDCAPS2_CERTIFIED),
999 FE(DDCAPS2_NO2DDURING3DSCENE),
1000 FE(DDCAPS2_VIDEOPORT),
1001 FE(DDCAPS2_AUTOFLIPOVERLAY),
1002 FE(DDCAPS2_CANBOBINTERLEAVED),
1003 FE(DDCAPS2_CANBOBNONINTERLEAVED),
1004 FE(DDCAPS2_COLORCONTROLOVERLAY),
1005 FE(DDCAPS2_COLORCONTROLPRIMARY),
1006 FE(DDCAPS2_CANDROPZ16BIT),
1007 FE(DDCAPS2_NONLOCALVIDMEM),
1008 FE(DDCAPS2_NONLOCALVIDMEMCAPS),
1009 FE(DDCAPS2_NOPAGELOCKREQUIRED),
1010 FE(DDCAPS2_WIDESURFACES),
1011 FE(DDCAPS2_CANFLIPODDEVEN),
1012 FE(DDCAPS2_CANBOBHARDWARE),
1013 FE(DDCAPS2_COPYFOURCC),
1014 FE(DDCAPS2_PRIMARYGAMMA),
1015 FE(DDCAPS2_CANRENDERWINDOWED),
1016 FE(DDCAPS2_CANCALIBRATEGAMMA),
1017 FE(DDCAPS2_FLIPINTERVAL),
1018 FE(DDCAPS2_FLIPNOVSYNC),
1019 FE(DDCAPS2_CANMANAGETEXTURE),
1020 FE(DDCAPS2_TEXMANINNONLOCALVIDMEM),
1021 FE(DDCAPS2_STEREO),
1022 FE(DDCAPS2_SYSTONONLOCAL_AS_SYSTOLOCAL)
1024 static const flag_info flags3[] =
1026 FE(DDCKEYCAPS_DESTBLT),
1027 FE(DDCKEYCAPS_DESTBLTCLRSPACE),
1028 FE(DDCKEYCAPS_DESTBLTCLRSPACEYUV),
1029 FE(DDCKEYCAPS_DESTBLTYUV),
1030 FE(DDCKEYCAPS_DESTOVERLAY),
1031 FE(DDCKEYCAPS_DESTOVERLAYCLRSPACE),
1032 FE(DDCKEYCAPS_DESTOVERLAYCLRSPACEYUV),
1033 FE(DDCKEYCAPS_DESTOVERLAYONEACTIVE),
1034 FE(DDCKEYCAPS_DESTOVERLAYYUV),
1035 FE(DDCKEYCAPS_SRCBLT),
1036 FE(DDCKEYCAPS_SRCBLTCLRSPACE),
1037 FE(DDCKEYCAPS_SRCBLTCLRSPACEYUV),
1038 FE(DDCKEYCAPS_SRCBLTYUV),
1039 FE(DDCKEYCAPS_SRCOVERLAY),
1040 FE(DDCKEYCAPS_SRCOVERLAYCLRSPACE),
1041 FE(DDCKEYCAPS_SRCOVERLAYCLRSPACEYUV),
1042 FE(DDCKEYCAPS_SRCOVERLAYONEACTIVE),
1043 FE(DDCKEYCAPS_SRCOVERLAYYUV),
1044 FE(DDCKEYCAPS_NOCOSTOVERLAY)
1046 static const flag_info flags4[] =
1048 FE(DDFXCAPS_BLTALPHA),
1049 FE(DDFXCAPS_OVERLAYALPHA),
1050 FE(DDFXCAPS_BLTARITHSTRETCHYN),
1051 FE(DDFXCAPS_BLTARITHSTRETCHY),
1052 FE(DDFXCAPS_BLTMIRRORLEFTRIGHT),
1053 FE(DDFXCAPS_BLTMIRRORUPDOWN),
1054 FE(DDFXCAPS_BLTROTATION),
1055 FE(DDFXCAPS_BLTROTATION90),
1056 FE(DDFXCAPS_BLTSHRINKX),
1057 FE(DDFXCAPS_BLTSHRINKXN),
1058 FE(DDFXCAPS_BLTSHRINKY),
1059 FE(DDFXCAPS_BLTSHRINKYN),
1060 FE(DDFXCAPS_BLTSTRETCHX),
1061 FE(DDFXCAPS_BLTSTRETCHXN),
1062 FE(DDFXCAPS_BLTSTRETCHY),
1063 FE(DDFXCAPS_BLTSTRETCHYN),
1064 FE(DDFXCAPS_OVERLAYARITHSTRETCHY),
1065 FE(DDFXCAPS_OVERLAYARITHSTRETCHYN),
1066 FE(DDFXCAPS_OVERLAYSHRINKX),
1067 FE(DDFXCAPS_OVERLAYSHRINKXN),
1068 FE(DDFXCAPS_OVERLAYSHRINKY),
1069 FE(DDFXCAPS_OVERLAYSHRINKYN),
1070 FE(DDFXCAPS_OVERLAYSTRETCHX),
1071 FE(DDFXCAPS_OVERLAYSTRETCHXN),
1072 FE(DDFXCAPS_OVERLAYSTRETCHY),
1073 FE(DDFXCAPS_OVERLAYSTRETCHYN),
1074 FE(DDFXCAPS_OVERLAYMIRRORLEFTRIGHT),
1075 FE(DDFXCAPS_OVERLAYMIRRORUPDOWN)
1077 static const flag_info flags5[] =
1079 FE(DDFXALPHACAPS_BLTALPHAEDGEBLEND),
1080 FE(DDFXALPHACAPS_BLTALPHAPIXELS),
1081 FE(DDFXALPHACAPS_BLTALPHAPIXELSNEG),
1082 FE(DDFXALPHACAPS_BLTALPHASURFACES),
1083 FE(DDFXALPHACAPS_BLTALPHASURFACESNEG),
1084 FE(DDFXALPHACAPS_OVERLAYALPHAEDGEBLEND),
1085 FE(DDFXALPHACAPS_OVERLAYALPHAPIXELS),
1086 FE(DDFXALPHACAPS_OVERLAYALPHAPIXELSNEG),
1087 FE(DDFXALPHACAPS_OVERLAYALPHASURFACES),
1088 FE(DDFXALPHACAPS_OVERLAYALPHASURFACESNEG)
1090 static const flag_info flags6[] =
1092 FE(DDPCAPS_4BIT),
1093 FE(DDPCAPS_8BITENTRIES),
1094 FE(DDPCAPS_8BIT),
1095 FE(DDPCAPS_INITIALIZE),
1096 FE(DDPCAPS_PRIMARYSURFACE),
1097 FE(DDPCAPS_PRIMARYSURFACELEFT),
1098 FE(DDPCAPS_ALLOW256),
1099 FE(DDPCAPS_VSYNC),
1100 FE(DDPCAPS_1BIT),
1101 FE(DDPCAPS_2BIT),
1102 FE(DDPCAPS_ALPHA),
1104 static const flag_info flags7[] =
1106 FE(DDSVCAPS_RESERVED1),
1107 FE(DDSVCAPS_RESERVED2),
1108 FE(DDSVCAPS_RESERVED3),
1109 FE(DDSVCAPS_RESERVED4),
1110 FE(DDSVCAPS_STEREOSEQUENTIAL),
1113 TRACE(" - dwSize : %d\n", lpcaps->dwSize);
1114 TRACE(" - dwCaps : "); DDRAW_dump_flags(lpcaps->dwCaps, flags1, sizeof(flags1)/sizeof(flags1[0]));
1115 TRACE(" - dwCaps2 : "); DDRAW_dump_flags(lpcaps->dwCaps2, flags2, sizeof(flags2)/sizeof(flags2[0]));
1116 TRACE(" - dwCKeyCaps : "); DDRAW_dump_flags(lpcaps->dwCKeyCaps, flags3, sizeof(flags3)/sizeof(flags3[0]));
1117 TRACE(" - dwFXCaps : "); DDRAW_dump_flags(lpcaps->dwFXCaps, flags4, sizeof(flags4)/sizeof(flags4[0]));
1118 TRACE(" - dwFXAlphaCaps : "); DDRAW_dump_flags(lpcaps->dwFXAlphaCaps, flags5, sizeof(flags5)/sizeof(flags5[0]));
1119 TRACE(" - dwPalCaps : "); DDRAW_dump_flags(lpcaps->dwPalCaps, flags6, sizeof(flags6)/sizeof(flags6[0]));
1120 TRACE(" - dwSVCaps : "); DDRAW_dump_flags(lpcaps->dwSVCaps, flags7, sizeof(flags7)/sizeof(flags7[0]));
1121 TRACE("...\n");
1122 TRACE(" - dwNumFourCCCodes : %d\n", lpcaps->dwNumFourCCCodes);
1123 TRACE(" - dwCurrVisibleOverlays : %d\n", lpcaps->dwCurrVisibleOverlays);
1124 TRACE(" - dwMinOverlayStretch : %d\n", lpcaps->dwMinOverlayStretch);
1125 TRACE(" - dwMaxOverlayStretch : %d\n", lpcaps->dwMaxOverlayStretch);
1126 TRACE("...\n");
1127 TRACE(" - ddsCaps : "); DDRAW_dump_DDSCAPS2(&lpcaps->ddsCaps);
1130 /*****************************************************************************
1131 * multiply_matrix
1133 * Multiplies 2 4x4 matrices src1 and src2, and stores the result in dest.
1135 * Params:
1136 * dest: Pointer to the destination matrix
1137 * src1: Pointer to the first source matrix
1138 * src2: Pointer to the second source matrix
1140 *****************************************************************************/
1141 void
1142 multiply_matrix(D3DMATRIX *dest,
1143 const D3DMATRIX *src1,
1144 const D3DMATRIX *src2)
1146 D3DMATRIX temp;
1148 /* Now do the multiplication 'by hand'.
1149 I know that all this could be optimised, but this will be done later :-) */
1150 temp._11 = (src1->_11 * src2->_11) + (src1->_21 * src2->_12) + (src1->_31 * src2->_13) + (src1->_41 * src2->_14);
1151 temp._21 = (src1->_11 * src2->_21) + (src1->_21 * src2->_22) + (src1->_31 * src2->_23) + (src1->_41 * src2->_24);
1152 temp._31 = (src1->_11 * src2->_31) + (src1->_21 * src2->_32) + (src1->_31 * src2->_33) + (src1->_41 * src2->_34);
1153 temp._41 = (src1->_11 * src2->_41) + (src1->_21 * src2->_42) + (src1->_31 * src2->_43) + (src1->_41 * src2->_44);
1155 temp._12 = (src1->_12 * src2->_11) + (src1->_22 * src2->_12) + (src1->_32 * src2->_13) + (src1->_42 * src2->_14);
1156 temp._22 = (src1->_12 * src2->_21) + (src1->_22 * src2->_22) + (src1->_32 * src2->_23) + (src1->_42 * src2->_24);
1157 temp._32 = (src1->_12 * src2->_31) + (src1->_22 * src2->_32) + (src1->_32 * src2->_33) + (src1->_42 * src2->_34);
1158 temp._42 = (src1->_12 * src2->_41) + (src1->_22 * src2->_42) + (src1->_32 * src2->_43) + (src1->_42 * src2->_44);
1160 temp._13 = (src1->_13 * src2->_11) + (src1->_23 * src2->_12) + (src1->_33 * src2->_13) + (src1->_43 * src2->_14);
1161 temp._23 = (src1->_13 * src2->_21) + (src1->_23 * src2->_22) + (src1->_33 * src2->_23) + (src1->_43 * src2->_24);
1162 temp._33 = (src1->_13 * src2->_31) + (src1->_23 * src2->_32) + (src1->_33 * src2->_33) + (src1->_43 * src2->_34);
1163 temp._43 = (src1->_13 * src2->_41) + (src1->_23 * src2->_42) + (src1->_33 * src2->_43) + (src1->_43 * src2->_44);
1165 temp._14 = (src1->_14 * src2->_11) + (src1->_24 * src2->_12) + (src1->_34 * src2->_13) + (src1->_44 * src2->_14);
1166 temp._24 = (src1->_14 * src2->_21) + (src1->_24 * src2->_22) + (src1->_34 * src2->_23) + (src1->_44 * src2->_24);
1167 temp._34 = (src1->_14 * src2->_31) + (src1->_24 * src2->_32) + (src1->_34 * src2->_33) + (src1->_44 * src2->_34);
1168 temp._44 = (src1->_14 * src2->_41) + (src1->_24 * src2->_42) + (src1->_34 * src2->_43) + (src1->_44 * src2->_44);
1170 /* And copy the new matrix in the good storage.. */
1171 memcpy(dest, &temp, 16 * sizeof(D3DVALUE));
1175 HRESULT
1176 hr_ddraw_from_wined3d(HRESULT hr)
1178 switch(hr)
1180 case WINED3DERR_INVALIDCALL: return DDERR_INVALIDPARAMS;
1181 default: return hr;