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