Adding more debug string on dx api that are being calling
[reactos.git] / reactos / subsys / win32k / ntddraw / ddraw.c
1 /*
2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS kernel
4 * PURPOSE: Native DirectDraw implementation
5 * FILE: subsys/win32k/ntddraw/ddraw.c
6 * PROGRAMER: Peter Bajusz (hyp-x@stormregion.com)
7 * REVISION HISTORY:
8 * 25-10-2003 PB Created
9 */
10
11 #include <w32k.h>
12
13 #define NDEBUG
14 #include <debug.h>
15
16 /************************************************************************/
17 /* DIRECT DRAW OBJECT */
18 /************************************************************************/
19
20 BOOL INTERNAL_CALL
21 DD_Cleanup(PVOID ObjectBody)
22 {
23 PDD_DIRECTDRAW pDirectDraw = GDIOBJ_LockObj(ObjectBody, GDI_OBJECT_TYPE_DIRECTDRAW);
24 DPRINT1("DD_Cleanup\n");
25
26 if (!pDirectDraw)
27 return FALSE;
28
29 pDirectDraw->DrvDisableDirectDraw(pDirectDraw->Global.dhpdev);
30
31 GDIOBJ_UnlockObjByPtr(pDirectDraw);
32 return TRUE;
33 }
34
35 HANDLE STDCALL NtGdiDdCreateDirectDrawObject(
36 HDC hdc
37 )
38 {
39 DD_CALLBACKS callbacks;
40 DD_SURFACECALLBACKS surface_callbacks;
41 DD_PALETTECALLBACKS palette_callbacks;
42 DPRINT1("NtGdiDdCreateDirectDrawObject\n");
43
44 RtlZeroMemory(&callbacks, sizeof(DD_CALLBACKS));
45 callbacks.dwSize = sizeof(DD_CALLBACKS);
46 RtlZeroMemory(&surface_callbacks, sizeof(DD_SURFACECALLBACKS));
47 surface_callbacks.dwSize = sizeof(DD_SURFACECALLBACKS);
48 RtlZeroMemory(&palette_callbacks, sizeof(DD_PALETTECALLBACKS));
49 palette_callbacks.dwSize = sizeof(DD_PALETTECALLBACKS);
50
51 /* FIXME hdc can be zero for d3d9 */
52 /* we need create it, if in that case */
53 if (hdc == NULL)
54 {
55 return NULL;
56 }
57
58 DC *pDC = DC_LockDc(hdc);
59 if (!pDC)
60 return NULL;
61
62 if (!pDC->DriverFunctions.EnableDirectDraw)
63 {
64 // Driver doesn't support DirectDraw
65 DC_UnlockDc(pDC);
66 return NULL;
67 }
68
69 BOOL success = pDC->DriverFunctions.EnableDirectDraw(
70 pDC->PDev, &callbacks, &surface_callbacks, &palette_callbacks);
71
72 if (!success)
73 {
74 DPRINT1("DirectDraw creation failed\n");
75 // DirectDraw creation failed
76 DC_UnlockDc(pDC);
77 return NULL;
78 }
79
80 HANDLE hDirectDraw = GDIOBJ_AllocObj(GDI_OBJECT_TYPE_DIRECTDRAW);
81 if (!hDirectDraw)
82 {
83 /* No more memmory */
84 DPRINT1("No more memmory\n");
85 DC_UnlockDc(pDC);
86 return NULL;
87 }
88
89 PDD_DIRECTDRAW pDirectDraw = GDIOBJ_LockObj(hDirectDraw, GDI_OBJECT_TYPE_DIRECTDRAW);
90 if (!pDirectDraw)
91 {
92 /* invalid handle */
93 DPRINT1("invalid handle\n");
94 DC_UnlockDc(pDC);
95 return NULL;
96 }
97
98
99 pDirectDraw->Global.dhpdev = pDC->PDev;
100 pDirectDraw->Local.lpGbl = &pDirectDraw->Global;
101
102 pDirectDraw->DrvGetDirectDrawInfo = pDC->DriverFunctions.GetDirectDrawInfo;
103 pDirectDraw->DrvDisableDirectDraw = pDC->DriverFunctions.DisableDirectDraw;
104
105 /* DD_CALLBACKS setup */
106 RtlMoveMemory(&pDirectDraw->DD, &callbacks, sizeof(DD_CALLBACKS));
107
108 /* DD_SURFACECALLBACKS setup*/
109 RtlMoveMemory(&pDirectDraw->Surf, &surface_callbacks, sizeof(DD_SURFACECALLBACKS));
110
111 /* DD_PALETTECALLBACKS setup*/
112 RtlMoveMemory(&pDirectDraw->Pal, &surface_callbacks, sizeof(DD_PALETTECALLBACKS));
113
114 GDIOBJ_UnlockObjByPtr(pDirectDraw);
115 DC_UnlockDc(pDC);
116
117 return hDirectDraw;
118 }
119
120 BOOL STDCALL NtGdiDdDeleteDirectDrawObject(
121 HANDLE hDirectDrawLocal
122 )
123 {
124 DPRINT1("NtGdiDdDeleteDirectDrawObject\n");
125 return GDIOBJ_FreeObj(hDirectDrawLocal, GDI_OBJECT_TYPE_DIRECTDRAW);
126 }
127
128 BOOL STDCALL NtGdiDdQueryDirectDrawObject(
129 HANDLE hDirectDrawLocal,
130 DD_HALINFO *pHalInfo,
131 DWORD *pCallBackFlags,
132 LPD3DNTHAL_CALLBACKS puD3dCallbacks,
133 LPD3DNTHAL_GLOBALDRIVERDATA puD3dDriverData,
134 PDD_D3DBUFCALLBACKS puD3dBufferCallbacks,
135 LPDDSURFACEDESC puD3dTextureFormats,
136 DWORD *puNumHeaps,
137 VIDEOMEMORY *puvmList,
138 DWORD *puNumFourCC,
139 DWORD *puFourCC
140 )
141 {
142 PDD_DIRECTDRAW pDirectDraw = GDIOBJ_LockObj(hDirectDrawLocal, GDI_OBJECT_TYPE_DIRECTDRAW);
143 DPRINT1("NtGdiDdQueryDirectDrawObject\n");
144
145 if (!pDirectDraw)
146 {
147 /* Fail to Lock DirectDraw handle */
148 DPRINT1(" Fail to Lock DirectDraw handle \n");
149 return FALSE;
150 }
151
152 BOOL success = pDirectDraw->DrvGetDirectDrawInfo(
153 pDirectDraw->Global.dhpdev,
154 pHalInfo,
155 puNumHeaps,
156 puvmList,
157 puNumFourCC,
158 puFourCC);
159
160 if (!success)
161 {
162 DPRINT1(" Fail to get DirectDraw driver info \n");
163 GDIOBJ_UnlockObjByPtr(pDirectDraw);
164 return FALSE;
165 }
166
167 if (pHalInfo)
168 {
169 DPRINT1("Found DirectDraw CallBack for 2D Hal\n");
170 RtlMoveMemory(&pDirectDraw->Hal, pHalInfo, sizeof(DD_HALINFO));
171
172 if (pHalInfo->lpD3DHALCallbacks)
173 {
174 DPRINT1("Found DirectDraw CallBack for 3D Hal\n");
175 RtlMoveMemory(puD3dCallbacks, pHalInfo->lpD3DHALCallbacks, sizeof(D3DNTHAL_CALLBACKS));
176 }
177
178 if (pHalInfo->lpD3DGlobalDriverData)
179 {
180 DPRINT1("Found DirectDraw CallBack for 3D Hal Private \n");
181 RtlMoveMemory(puD3dDriverData, pHalInfo->lpD3DGlobalDriverData, sizeof(D3DNTHAL_GLOBALDRIVERDATA));
182 }
183 if (pHalInfo->lpD3DBufCallbacks)
184 {
185 DPRINT1("Found DirectDraw CallBack for 3D Hal Bufffer \n");
186 RtlMoveMemory(puD3dBufferCallbacks, pHalInfo->lpD3DBufCallbacks, sizeof(DD_D3DBUFCALLBACKS));
187 }
188
189 }
190 else
191 {
192 DPRINT1("No DirectDraw Hal info have been found, it did not fail, it did gather some other info \n");
193 }
194
195 GDIOBJ_UnlockObjByPtr(pDirectDraw);
196
197 return TRUE;
198 }
199
200
201 DWORD STDCALL NtGdiDdGetDriverInfo(
202 HANDLE hDirectDrawLocal,
203 PDD_GETDRIVERINFODATA puGetDriverInfoData)
204
205 {
206 DWORD ddRVal;
207
208 PDD_DIRECTDRAW pDirectDraw = GDIOBJ_LockObj(hDirectDrawLocal, GDI_OBJECT_TYPE_DIRECTDRAW);
209 DPRINT1("NtGdiDdGetDriverInfo\n");
210
211 if (pDirectDraw == NULL)
212 {
213 DPRINT1("NtGdiDdGetDriverInfo DDHAL_DRIVER_NOTHANDLED\n");
214 return DDHAL_DRIVER_NOTHANDLED;
215 }
216
217 if (!(pDirectDraw->Hal.dwFlags & DDHALINFO_GETDRIVERINFOSET))
218 {
219 DPRINT1("NtGdiDdGetDriverInfo DDHAL_DRIVER_NOTHANDLED\n");
220 ddRVal = DDHAL_DRIVER_NOTHANDLED;
221 }
222 else
223 ddRVal = pDirectDraw->Hal.GetDriverInfo(puGetDriverInfoData);
224
225 GDIOBJ_UnlockObjByPtr(pDirectDraw);
226
227 return ddRVal;
228 }
229
230 /************************************************************************/
231 /* DD CALLBACKS */
232 /* FIXME NtGdiDdCreateSurface we do not call to ddCreateSurface */
233 /************************************************************************/
234
235 DWORD STDCALL NtGdiDdCreateSurface(
236 HANDLE hDirectDrawLocal,
237 HANDLE *hSurface,
238 DDSURFACEDESC *puSurfaceDescription,
239 DD_SURFACE_GLOBAL *puSurfaceGlobalData,
240 DD_SURFACE_LOCAL *puSurfaceLocalData,
241 DD_SURFACE_MORE *puSurfaceMoreData,
242 PDD_CREATESURFACEDATA puCreateSurfaceData,
243 HANDLE *puhSurface
244 )
245 {
246 DWORD ddRVal = DDHAL_DRIVER_NOTHANDLED;
247 PDD_DIRECTDRAW_GLOBAL lgpl;
248 DPRINT1("NtGdiDdCreateSurface\n");
249
250 PDD_DIRECTDRAW pDirectDraw = GDIOBJ_LockObj(hDirectDrawLocal, GDI_OBJECT_TYPE_DIRECTDRAW);
251 if (pDirectDraw == NULL)
252 return DDHAL_DRIVER_NOTHANDLED;
253
254 /* backup the orignal PDev and info */
255 lgpl = puCreateSurfaceData->lpDD;
256
257 /* use our cache version instead */
258 puCreateSurfaceData->lpDD = &pDirectDraw->Global;
259
260 /* make the call */
261 if (!(pDirectDraw->DD.dwFlags & DDHAL_CB32_CANCREATESURFACE))
262 ddRVal = DDHAL_DRIVER_NOTHANDLED;
263 else
264 {
265 ddRVal = pDirectDraw->DD.CreateSurface(puCreateSurfaceData);
266 }
267
268 /* But back the orignal PDev */
269 puCreateSurfaceData->lpDD = lgpl;
270
271 GDIOBJ_UnlockObjByPtr(pDirectDraw);
272 return ddRVal;
273 }
274
275 DWORD STDCALL NtGdiDdWaitForVerticalBlank(
276 HANDLE hDirectDrawLocal,
277 PDD_WAITFORVERTICALBLANKDATA puWaitForVerticalBlankData
278 )
279 {
280 DWORD ddRVal;
281 PDD_DIRECTDRAW_GLOBAL lgpl;
282 DPRINT1("NtGdiDdWaitForVerticalBlank\n");
283
284
285 PDD_DIRECTDRAW pDirectDraw = GDIOBJ_LockObj(hDirectDrawLocal, GDI_OBJECT_TYPE_DIRECTDRAW);
286 if (pDirectDraw == NULL)
287 return DDHAL_DRIVER_NOTHANDLED;
288
289 /* backup the orignal PDev and info */
290 lgpl = puWaitForVerticalBlankData->lpDD;
291
292 /* use our cache version instead */
293 puWaitForVerticalBlankData->lpDD = &pDirectDraw->Global;
294
295 /* make the call */
296 if (!(pDirectDraw->DD.dwFlags & DDHAL_CB32_WAITFORVERTICALBLANK))
297 ddRVal = DDHAL_DRIVER_NOTHANDLED;
298 else
299 ddRVal = pDirectDraw->DD.WaitForVerticalBlank(puWaitForVerticalBlankData);
300
301 /* But back the orignal PDev */
302 puWaitForVerticalBlankData->lpDD = lgpl;
303
304 GDIOBJ_UnlockObjByPtr(pDirectDraw);
305 return ddRVal;
306 }
307
308 DWORD STDCALL NtGdiDdCanCreateSurface(
309 HANDLE hDirectDrawLocal,
310 PDD_CANCREATESURFACEDATA puCanCreateSurfaceData
311 )
312 {
313 DWORD ddRVal;
314 PDD_DIRECTDRAW_GLOBAL lgpl;
315
316 PDD_DIRECTDRAW pDirectDraw = GDIOBJ_LockObj(hDirectDrawLocal, GDI_OBJECT_TYPE_DIRECTDRAW);
317 DPRINT1("NtGdiDdCanCreateSurface\n");
318 if (pDirectDraw == NULL)
319 return DDHAL_DRIVER_NOTHANDLED;
320
321 /* backup the orignal PDev and info */
322 lgpl = puCanCreateSurfaceData->lpDD;
323
324 /* use our cache version instead */
325 puCanCreateSurfaceData->lpDD = &pDirectDraw->Global;
326
327 /* make the call */
328 if (!(pDirectDraw->DD.dwFlags & DDHAL_CB32_CANCREATESURFACE))
329 ddRVal = DDHAL_DRIVER_NOTHANDLED;
330 else
331 ddRVal = pDirectDraw->DD.CanCreateSurface(puCanCreateSurfaceData);
332
333 /* But back the orignal PDev */
334 puCanCreateSurfaceData->lpDD = lgpl;
335
336 GDIOBJ_UnlockObjByPtr(pDirectDraw);
337 return ddRVal;
338 }
339
340 DWORD STDCALL NtGdiDdGetScanLine(
341 HANDLE hDirectDrawLocal,
342 PDD_GETSCANLINEDATA puGetScanLineData
343 )
344 {
345 DWORD ddRVal;
346 PDD_DIRECTDRAW_GLOBAL lgpl;
347
348 PDD_DIRECTDRAW pDirectDraw = GDIOBJ_LockObj(hDirectDrawLocal, GDI_OBJECT_TYPE_DIRECTDRAW);
349 DPRINT1("NtGdiDdGetScanLine\n");
350 if (pDirectDraw == NULL)
351 return DDHAL_DRIVER_NOTHANDLED;
352
353 /* backup the orignal PDev and info */
354 lgpl = puGetScanLineData->lpDD;
355
356 /* use our cache version instead */
357 puGetScanLineData->lpDD = &pDirectDraw->Global;
358
359 /* make the call */
360 if (!(pDirectDraw->DD.dwFlags & DDHAL_CB32_GETSCANLINE))
361 ddRVal = DDHAL_DRIVER_NOTHANDLED;
362 else
363 ddRVal = pDirectDraw->DD.GetScanLine(puGetScanLineData);
364
365 /* But back the orignal PDev */
366 puGetScanLineData->lpDD = lgpl;
367
368 GDIOBJ_UnlockObjByPtr(pDirectDraw);
369 return ddRVal;
370 }
371
372
373
374 /************************************************************************/
375 /* Surface CALLBACKS */
376 /* FIXME */
377 /* NtGdiDdDestroySurface */
378 /************************************************************************/
379
380 DWORD STDCALL NtGdiDdDestroySurface(
381 HANDLE hSurface,
382 BOOL bRealDestroy
383 )
384 {
385 DWORD ddRVal = DDHAL_DRIVER_NOTHANDLED;
386
387 PDD_DIRECTDRAW pDirectDraw = GDIOBJ_LockObj(hSurface, GDI_OBJECT_TYPE_DIRECTDRAW);
388 DPRINT1("NtGdiDdDestroySurface\n");
389 if (pDirectDraw == NULL)
390 return DDHAL_DRIVER_NOTHANDLED;
391
392 if (!(pDirectDraw->Surf.dwFlags & DDHAL_SURFCB32_DESTROYSURFACE))
393 ddRVal = DDHAL_DRIVER_NOTHANDLED;
394 else
395 {
396 DD_DESTROYSURFACEDATA DestroySurf;
397
398 /* FIXME
399 * bRealDestroy
400 * are we doing right ??
401 */
402 DestroySurf.lpDD = &pDirectDraw->Global;
403
404 DestroySurf.lpDDSurface = hSurface; // ?
405 DestroySurf.DestroySurface = pDirectDraw->Surf.DestroySurface;
406
407 ddRVal = pDirectDraw->Surf.DestroySurface(&DestroySurf);
408 }
409
410
411 GDIOBJ_UnlockObjByPtr(pDirectDraw);
412 return ddRVal;
413 }
414
415 DWORD STDCALL NtGdiDdFlip(
416 HANDLE hSurfaceCurrent,
417 HANDLE hSurfaceTarget,
418 HANDLE hSurfaceCurrentLeft,
419 HANDLE hSurfaceTargetLeft,
420 PDD_FLIPDATA puFlipData
421 )
422 {
423 DWORD ddRVal;
424 PDD_DIRECTDRAW_GLOBAL lgpl;
425
426 PDD_DIRECTDRAW pDirectDraw = GDIOBJ_LockObj(hSurfaceTarget, GDI_OBJECT_TYPE_DIRECTDRAW);
427 DPRINT1("NtGdiDdFlip\n");
428
429 if (pDirectDraw == NULL)
430 return DDHAL_DRIVER_NOTHANDLED;
431
432 /* backup the orignal PDev and info */
433 lgpl = puFlipData->lpDD;
434
435 /* use our cache version instead */
436 puFlipData->lpDD = &pDirectDraw->Global;
437
438 /* make the call */
439 if (!(pDirectDraw->Surf.dwFlags & DDHAL_SURFCB32_FLIP))
440 ddRVal = DDHAL_DRIVER_NOTHANDLED;
441 else
442 ddRVal = pDirectDraw->Surf.Flip(puFlipData);
443
444 /* But back the orignal PDev */
445 puFlipData->lpDD = lgpl;
446
447 GDIOBJ_UnlockObjByPtr(pDirectDraw);
448 return ddRVal;
449 }
450
451 DWORD STDCALL NtGdiDdLock(
452 HANDLE hSurface,
453 PDD_LOCKDATA puLockData,
454 HDC hdcClip
455 )
456 {
457 DWORD ddRVal;
458 PDD_DIRECTDRAW_GLOBAL lgpl;
459
460 PDD_DIRECTDRAW pDirectDraw = GDIOBJ_LockObj(hSurface, GDI_OBJECT_TYPE_DIRECTDRAW);
461 DPRINT1("NtGdiDdLock\n");
462 if (pDirectDraw == NULL)
463 return DDHAL_DRIVER_NOTHANDLED;
464
465 /* backup the orignal PDev and info */
466 lgpl = puLockData->lpDD;
467
468 /* use our cache version instead */
469 puLockData->lpDD = &pDirectDraw->Global;
470
471 /* make the call */
472 if (!(pDirectDraw->Surf.dwFlags & DDHAL_SURFCB32_LOCK))
473 ddRVal = DDHAL_DRIVER_NOTHANDLED;
474 else
475 ddRVal = pDirectDraw->Surf.Lock(puLockData);
476
477 /* But back the orignal PDev */
478 puLockData->lpDD = lgpl;
479
480 GDIOBJ_UnlockObjByPtr(pDirectDraw);
481 return ddRVal;
482 }
483
484 DWORD STDCALL NtGdiDdUnlock(
485 HANDLE hSurface,
486 PDD_UNLOCKDATA puUnlockData
487 )
488 {
489 DWORD ddRVal;
490 PDD_DIRECTDRAW_GLOBAL lgpl;
491
492 PDD_DIRECTDRAW pDirectDraw = GDIOBJ_LockObj(hSurface, GDI_OBJECT_TYPE_DIRECTDRAW);
493 DPRINT1("NtGdiDdUnlock\n");
494 if (pDirectDraw == NULL)
495 return DDHAL_DRIVER_NOTHANDLED;
496
497 /* backup the orignal PDev and info */
498 lgpl = puUnlockData->lpDD;
499
500 /* use our cache version instead */
501 puUnlockData->lpDD = &pDirectDraw->Global;
502
503 /* make the call */
504 if (!(pDirectDraw->Surf.dwFlags & DDHAL_SURFCB32_UNLOCK))
505 ddRVal = DDHAL_DRIVER_NOTHANDLED;
506 else
507 ddRVal = pDirectDraw->Surf.Unlock(puUnlockData);
508
509 /* But back the orignal PDev */
510 puUnlockData->lpDD = lgpl;
511
512 GDIOBJ_UnlockObjByPtr(pDirectDraw);
513 return ddRVal;
514 }
515
516 DWORD STDCALL NtGdiDdBlt(
517 HANDLE hSurfaceDest,
518 HANDLE hSurfaceSrc,
519 PDD_BLTDATA puBltData
520 )
521 {
522 DWORD ddRVal;
523 PDD_DIRECTDRAW_GLOBAL lgpl;
524
525 PDD_DIRECTDRAW pDirectDraw = GDIOBJ_LockObj(hSurfaceDest, GDI_OBJECT_TYPE_DIRECTDRAW);
526 DPRINT1("NtGdiDdBlt\n");
527 if (pDirectDraw == NULL)
528 return DDHAL_DRIVER_NOTHANDLED;
529
530 /* backup the orignal PDev and info */
531 lgpl = puBltData->lpDD;
532
533 /* use our cache version instead */
534 puBltData->lpDD = &pDirectDraw->Global;
535
536 /* make the call */
537 if (!(pDirectDraw->Surf.dwFlags & DDHAL_SURFCB32_BLT))
538 ddRVal = DDHAL_DRIVER_NOTHANDLED;
539 else
540 ddRVal = pDirectDraw->Surf.Blt(puBltData);
541
542 /* But back the orignal PDev */
543 puBltData->lpDD = lgpl;
544
545 GDIOBJ_UnlockObjByPtr(pDirectDraw);
546 return ddRVal;
547 }
548
549 DWORD STDCALL NtGdiDdSetColorKey(
550 HANDLE hSurface,
551 PDD_SETCOLORKEYDATA puSetColorKeyData
552 )
553 {
554 DWORD ddRVal;
555 PDD_DIRECTDRAW_GLOBAL lgpl;
556
557 PDD_DIRECTDRAW pDirectDraw = GDIOBJ_LockObj(hSurface, GDI_OBJECT_TYPE_DIRECTDRAW);
558 DPRINT1("NtGdiDdSetColorKey\n");
559 if (pDirectDraw == NULL)
560 return DDHAL_DRIVER_NOTHANDLED;
561
562 /* backup the orignal PDev and info */
563 lgpl = puSetColorKeyData->lpDD;
564
565 /* use our cache version instead */
566 puSetColorKeyData->lpDD = &pDirectDraw->Global;
567
568 /* make the call */
569 if (!(pDirectDraw->Surf.dwFlags & DDHAL_SURFCB32_SETCOLORKEY))
570 ddRVal = DDHAL_DRIVER_NOTHANDLED;
571 else
572 ddRVal = pDirectDraw->Surf.SetColorKey(puSetColorKeyData);
573
574 /* But back the orignal PDev */
575 puSetColorKeyData->lpDD = lgpl;
576
577 GDIOBJ_UnlockObjByPtr(pDirectDraw);
578 return ddRVal;
579 }
580
581
582 DWORD STDCALL NtGdiDdAddAttachedSurface(
583 HANDLE hSurface,
584 HANDLE hSurfaceAttached,
585 PDD_ADDATTACHEDSURFACEDATA puAddAttachedSurfaceData
586 )
587 {
588 DWORD ddRVal;
589 PDD_DIRECTDRAW_GLOBAL lgpl;
590
591 PDD_DIRECTDRAW pDirectDraw = GDIOBJ_LockObj(hSurfaceAttached, GDI_OBJECT_TYPE_DIRECTDRAW);
592 DPRINT1("NtGdiDdAddAttachedSurface\n");
593 if (pDirectDraw == NULL)
594 return DDHAL_DRIVER_NOTHANDLED;
595
596 /* backup the orignal PDev and info */
597 lgpl = puAddAttachedSurfaceData->lpDD;
598
599 /* use our cache version instead */
600 puAddAttachedSurfaceData->lpDD = &pDirectDraw->Global;
601
602 /* make the call */
603 if (!(pDirectDraw->Surf.dwFlags & DDHAL_SURFCB32_ADDATTACHEDSURFACE))
604 ddRVal = DDHAL_DRIVER_NOTHANDLED;
605 else
606 ddRVal = pDirectDraw->Surf.AddAttachedSurface(puAddAttachedSurfaceData);
607
608 /* But back the orignal PDev */
609 puAddAttachedSurfaceData->lpDD = lgpl;
610
611 GDIOBJ_UnlockObjByPtr(pDirectDraw);
612 return ddRVal;
613 }
614
615 DWORD STDCALL NtGdiDdGetBltStatus(
616 HANDLE hSurface,
617 PDD_GETBLTSTATUSDATA puGetBltStatusData
618 )
619 {
620 DWORD ddRVal;
621 PDD_DIRECTDRAW_GLOBAL lgpl;
622
623 PDD_DIRECTDRAW pDirectDraw = GDIOBJ_LockObj(hSurface, GDI_OBJECT_TYPE_DIRECTDRAW);
624 DPRINT1("NtGdiDdGetBltStatus\n");
625 if (pDirectDraw == NULL)
626 return DDHAL_DRIVER_NOTHANDLED;
627
628 /* backup the orignal PDev and info */
629 lgpl = puGetBltStatusData->lpDD;
630
631 /* use our cache version instead */
632 puGetBltStatusData->lpDD = &pDirectDraw->Global;
633
634 /* make the call */
635 if (!(pDirectDraw->Surf.dwFlags & DDHAL_SURFCB32_GETBLTSTATUS))
636 ddRVal = DDHAL_DRIVER_NOTHANDLED;
637 else
638 ddRVal = pDirectDraw->Surf.GetBltStatus(puGetBltStatusData);
639
640 /* But back the orignal PDev */
641 puGetBltStatusData->lpDD = lgpl;
642
643 GDIOBJ_UnlockObjByPtr(pDirectDraw);
644 return ddRVal;
645 }
646
647 DWORD STDCALL NtGdiDdGetFlipStatus(
648 HANDLE hSurface,
649 PDD_GETFLIPSTATUSDATA puGetFlipStatusData
650 )
651 {
652 DWORD ddRVal;
653 PDD_DIRECTDRAW_GLOBAL lgpl;
654
655 PDD_DIRECTDRAW pDirectDraw = GDIOBJ_LockObj(hSurface, GDI_OBJECT_TYPE_DIRECTDRAW);
656 DPRINT1("NtGdiDdGetFlipStatus\n");
657 if (pDirectDraw == NULL)
658 return DDHAL_DRIVER_NOTHANDLED;
659
660 /* backup the orignal PDev and info */
661 lgpl = puGetFlipStatusData->lpDD;
662
663 /* use our cache version instead */
664 puGetFlipStatusData->lpDD = &pDirectDraw->Global;
665
666 /* make the call */
667 if (!(pDirectDraw->Surf.dwFlags & DDHAL_SURFCB32_GETFLIPSTATUS))
668 ddRVal = DDHAL_DRIVER_NOTHANDLED;
669 else
670 ddRVal = pDirectDraw->Surf.GetFlipStatus(puGetFlipStatusData);
671
672 /* But back the orignal PDev */
673 puGetFlipStatusData->lpDD = lgpl;
674
675 GDIOBJ_UnlockObjByPtr(pDirectDraw);
676 return ddRVal;
677 }
678
679 DWORD STDCALL NtGdiDdUpdateOverlay(
680 HANDLE hSurfaceDestination,
681 HANDLE hSurfaceSource,
682 PDD_UPDATEOVERLAYDATA puUpdateOverlayData
683 )
684 {
685 DWORD ddRVal;
686 PDD_DIRECTDRAW_GLOBAL lgpl;
687
688 PDD_DIRECTDRAW pDirectDraw = GDIOBJ_LockObj(hSurfaceDestination, GDI_OBJECT_TYPE_DIRECTDRAW);
689 DPRINT1("NtGdiDdUpdateOverlay\n");
690 if (pDirectDraw == NULL)
691 return DDHAL_DRIVER_NOTHANDLED;
692
693 /* backup the orignal PDev and info */
694 lgpl = puUpdateOverlayData->lpDD;
695
696 /* use our cache version instead */
697 puUpdateOverlayData->lpDD = &pDirectDraw->Global;
698
699 /* make the call */
700 if (!(pDirectDraw->Surf.dwFlags & DDHAL_SURFCB32_UPDATEOVERLAY))
701 ddRVal = DDHAL_DRIVER_NOTHANDLED;
702 else
703 ddRVal = pDirectDraw->Surf.UpdateOverlay(puUpdateOverlayData);
704
705 /* But back the orignal PDev */
706 puUpdateOverlayData->lpDD = lgpl;
707
708 GDIOBJ_UnlockObjByPtr(pDirectDraw);
709 return ddRVal;
710 }
711
712 DWORD STDCALL NtGdiDdSetOverlayPosition(
713 HANDLE hSurfaceSource,
714 HANDLE hSurfaceDestination,
715 PDD_SETOVERLAYPOSITIONDATA puSetOverlayPositionData
716 )
717 {
718 DWORD ddRVal;
719 PDD_DIRECTDRAW_GLOBAL lgpl;
720
721 PDD_DIRECTDRAW pDirectDraw = GDIOBJ_LockObj(hSurfaceDestination, GDI_OBJECT_TYPE_DIRECTDRAW);
722 DPRINT1("NtGdiDdSetOverlayPosition\n");
723 if (pDirectDraw == NULL)
724 return DDHAL_DRIVER_NOTHANDLED;
725
726 /* backup the orignal PDev and info */
727 lgpl = puSetOverlayPositionData->lpDD;
728
729 /* use our cache version instead */
730 puSetOverlayPositionData->lpDD = &pDirectDraw->Global;
731
732 /* make the call */
733 if (!(pDirectDraw->Surf.dwFlags & DDHAL_SURFCB32_SETOVERLAYPOSITION))
734 ddRVal = DDHAL_DRIVER_NOTHANDLED;
735 else
736 ddRVal = pDirectDraw->Surf.SetOverlayPosition(puSetOverlayPositionData);
737
738 /* But back the orignal PDev */
739 puSetOverlayPositionData->lpDD = lgpl;
740
741 GDIOBJ_UnlockObjByPtr(pDirectDraw);
742 return ddRVal;
743 }
744
745
746 /************************************************************************/
747 /* SURFACE OBJECT */
748 /************************************************************************/
749
750 BOOL INTERNAL_CALL
751 DDSURF_Cleanup(PVOID pDDSurf)
752 {
753 /* FIXME: implement
754 * PDD_SURFACE pDDSurf = PVOID pDDSurf
755 */
756 DPRINT1("DDSURF_Cleanup\n");
757 return TRUE;
758 }
759
760 HANDLE STDCALL NtGdiDdCreateSurfaceObject(
761 HANDLE hDirectDrawLocal,
762 HANDLE hSurface,
763 PDD_SURFACE_LOCAL puSurfaceLocal,
764 PDD_SURFACE_MORE puSurfaceMore,
765 PDD_SURFACE_GLOBAL puSurfaceGlobal,
766 BOOL bComplete
767 )
768 {
769 PDD_DIRECTDRAW pDirectDraw = GDIOBJ_LockObj(hDirectDrawLocal, GDI_OBJECT_TYPE_DIRECTDRAW);
770 DPRINT1("NtGdiDdCreateSurfaceObject\n");
771 if (!pDirectDraw)
772 return NULL;
773
774 if (!hSurface)
775 hSurface = GDIOBJ_AllocObj(GDI_OBJECT_TYPE_DD_SURFACE);
776
777 PDD_SURFACE pSurface = GDIOBJ_LockObj(hSurface, GDI_OBJECT_TYPE_DD_SURFACE);
778 /* FIXME - Handle pSurface == NULL!!!! */
779
780 RtlMoveMemory(&pSurface->Local, puSurfaceLocal, sizeof(DD_SURFACE_LOCAL));
781 RtlMoveMemory(&pSurface->More, puSurfaceMore, sizeof(DD_SURFACE_MORE));
782 RtlMoveMemory(&pSurface->Global, puSurfaceGlobal, sizeof(DD_SURFACE_GLOBAL));
783 pSurface->Local.lpGbl = &pSurface->Global;
784 pSurface->Local.lpSurfMore = &pSurface->More;
785 pSurface->Local.lpAttachList = NULL;
786 pSurface->Local.lpAttachListFrom = NULL;
787 pSurface->More.lpVideoPort = NULL;
788 // FIXME: figure out how to use this
789 pSurface->bComplete = bComplete;
790
791 GDIOBJ_UnlockObjByPtr(pSurface);
792 GDIOBJ_UnlockObjByPtr(pDirectDraw);
793
794 return hSurface;
795 }
796
797 BOOL STDCALL NtGdiDdDeleteSurfaceObject(
798 HANDLE hSurface
799 )
800 {
801 DPRINT1("NtGdiDdDeleteSurfaceObject\n");
802 return GDIOBJ_FreeObj(hSurface, GDI_OBJECT_TYPE_DD_SURFACE);
803 }
804
805
806
807 /************************************************************************/
808 /* DIRECT DRAW SURFACR END */
809 /************************************************************************/
810
811
812 /*
813 BOOL STDCALL NtGdiDdAttachSurface(
814 HANDLE hSurfaceFrom,
815 HANDLE hSurfaceTo
816 )
817 {
818 PDD_SURFACE pSurfaceFrom = GDIOBJ_LockObj(hSurfaceFrom, GDI_OBJECT_TYPE_DD_SURFACE);
819 if (!pSurfaceFrom)
820 return FALSE;
821 PDD_SURFACE pSurfaceTo = GDIOBJ_LockObj(hSurfaceTo, GDI_OBJECT_TYPE_DD_SURFACE);
822 if (!pSurfaceTo)
823 {
824 GDIOBJ_UnlockObjByPtr(pSurfaceFrom);
825 return FALSE;
826 }
827
828 if (pSurfaceFrom->Local.lpAttachListFrom)
829 {
830 pSurfaceFrom->Local.lpAttachListFrom = pSurfaceFrom->AttachListFrom;
831 }
832
833 GDIOBJ_UnlockObjByPtr(pSurfaceFrom);
834 GDIOBJ_UnlockObjByPtr(pSurfaceTo);
835 return TRUE;
836 }
837 */
838
839 DWORD STDCALL NtGdiDdGetAvailDriverMemory(
840 HANDLE hDirectDrawLocal,
841 PDD_GETAVAILDRIVERMEMORYDATA puGetAvailDriverMemoryData
842 )
843 {
844 DWORD ddRVal = DDHAL_DRIVER_NOTHANDLED;
845 PDD_DIRECTDRAW_GLOBAL lgpl;
846
847 PDD_DIRECTDRAW pDirectDraw = GDIOBJ_LockObj(hDirectDrawLocal, GDI_OBJECT_TYPE_DIRECTDRAW);
848 DPRINT1("NtGdiDdGetAvailDriverMemory\n");
849
850 /* backup the orignal PDev and info */
851 lgpl = puGetAvailDriverMemoryData->lpDD;
852
853 /* use our cache version instead */
854 puGetAvailDriverMemoryData->lpDD = &pDirectDraw->Global;
855
856 /* make the call */
857 // ddRVal = pDirectDraw->DdGetAvailDriverMemory(puGetAvailDriverMemoryData);
858
859 GDIOBJ_UnlockObjByPtr(pDirectDraw);
860
861
862 /* But back the orignal PDev */
863 puGetAvailDriverMemoryData->lpDD = lgpl;
864
865 return ddRVal;
866 }
867
868
869
870
871 DWORD STDCALL NtGdiDdSetExclusiveMode(
872 HANDLE hDirectDraw,
873 PDD_SETEXCLUSIVEMODEDATA puSetExclusiveModeData
874 )
875 {
876 DWORD ddRVal;
877 PDD_DIRECTDRAW_GLOBAL lgpl;
878
879 PDD_DIRECTDRAW pDirectDraw = GDIOBJ_LockObj(hDirectDraw, GDI_OBJECT_TYPE_DIRECTDRAW);
880 DPRINT1("NtGdiDdSetExclusiveMode\n");
881
882 /* backup the orignal PDev and info */
883 lgpl = puSetExclusiveModeData->lpDD;
884
885 /* use our cache version instead */
886 puSetExclusiveModeData->lpDD = &pDirectDraw->Global;
887
888 /* make the call */
889 ddRVal = pDirectDraw->DdSetExclusiveMode(puSetExclusiveModeData);
890
891 GDIOBJ_UnlockObjByPtr(pDirectDraw);
892
893 /* But back the orignal PDev */
894 puSetExclusiveModeData->lpDD = lgpl;
895
896 return ddRVal;
897 }
898
899
900
901
902 /* EOF */