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