Fix DD_Cleanup that will make Contry Strike not crashing when it does not found right...
[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 if (!pDirectDraw)
25 return FALSE;
26
27 pDirectDraw->DrvDisableDirectDraw(pDirectDraw->Global.dhpdev);
28
29 GDIOBJ_UnlockObjByPtr(pDirectDraw);
30 return TRUE;
31 }
32
33 HANDLE STDCALL NtGdiDdCreateDirectDrawObject(
34 HDC hdc
35 )
36 {
37 DD_CALLBACKS callbacks;
38 DD_SURFACECALLBACKS surface_callbacks;
39 DD_PALETTECALLBACKS palette_callbacks;
40
41 RtlZeroMemory(&callbacks, sizeof(DD_CALLBACKS));
42 callbacks.dwSize = sizeof(DD_CALLBACKS);
43 RtlZeroMemory(&surface_callbacks, sizeof(DD_SURFACECALLBACKS));
44 surface_callbacks.dwSize = sizeof(DD_SURFACECALLBACKS);
45 RtlZeroMemory(&palette_callbacks, sizeof(DD_PALETTECALLBACKS));
46 palette_callbacks.dwSize = sizeof(DD_PALETTECALLBACKS);
47
48
49 DC *pDC = DC_LockDc(hdc);
50 if (!pDC)
51 return NULL;
52
53 if (!pDC->DriverFunctions.EnableDirectDraw)
54 {
55 // Driver doesn't support DirectDraw
56 DC_UnlockDc(pDC);
57 return NULL;
58 }
59
60 BOOL success = pDC->DriverFunctions.EnableDirectDraw(
61 pDC->PDev, &callbacks, &surface_callbacks, &palette_callbacks);
62
63 if (!success)
64 {
65 // DirectDraw creation failed
66 DC_UnlockDc(pDC);
67 return NULL;
68 }
69
70 HANDLE hDirectDraw = GDIOBJ_AllocObj(GDI_OBJECT_TYPE_DIRECTDRAW);
71 if (!hDirectDraw)
72 {
73 /* No more memmory */
74 DC_UnlockDc(pDC);
75 return NULL;
76 }
77
78 PDD_DIRECTDRAW pDirectDraw = GDIOBJ_LockObj(hDirectDraw, GDI_OBJECT_TYPE_DIRECTDRAW);
79 if (!pDirectDraw)
80 {
81 /* invalid handle */
82 DC_UnlockDc(pDC);
83 return NULL;
84 }
85
86
87 pDirectDraw->Global.dhpdev = pDC->PDev;
88 pDirectDraw->Local.lpGbl = &pDirectDraw->Global;
89
90 pDirectDraw->DrvGetDirectDrawInfo = pDC->DriverFunctions.GetDirectDrawInfo;
91 pDirectDraw->DrvDisableDirectDraw = pDC->DriverFunctions.DisableDirectDraw;
92
93 /* DD_CALLBACKS setup */
94 RtlMoveMemory(&pDirectDraw->DD, &callbacks, sizeof(DD_CALLBACKS));
95
96 /* DD_SURFACECALLBACKS setup*/
97 RtlMoveMemory(&pDirectDraw->Surf, &surface_callbacks, sizeof(DD_SURFACECALLBACKS));
98
99 /* DD_PALETTECALLBACKS setup*/
100 RtlMoveMemory(&pDirectDraw->Pal, &surface_callbacks, sizeof(DD_PALETTECALLBACKS));
101
102 GDIOBJ_UnlockObjByPtr(pDirectDraw);
103 DC_UnlockDc(pDC);
104
105 return hDirectDraw;
106 }
107
108 BOOL STDCALL NtGdiDdDeleteDirectDrawObject(
109 HANDLE hDirectDrawLocal
110 )
111 {
112 return GDIOBJ_FreeObj(hDirectDrawLocal, GDI_OBJECT_TYPE_DIRECTDRAW);
113 }
114
115 BOOL STDCALL NtGdiDdQueryDirectDrawObject(
116 HANDLE hDirectDrawLocal,
117 DD_HALINFO *pHalInfo,
118 DWORD *pCallBackFlags,
119 PD3DNTHAL_CALLBACKS puD3dCallbacks,
120 PD3DNTHAL_GLOBALDRIVERDATA puD3dDriverData,
121 PDD_D3DBUFCALLBACKS puD3dBufferCallbacks,
122 LPDDSURFACEDESC puD3dTextureFormats,
123 DWORD *puNumHeaps,
124 VIDEOMEMORY *puvmList,
125 DWORD *puNumFourCC,
126 DWORD *puFourCC
127 )
128 {
129 PDD_DIRECTDRAW pDirectDraw = GDIOBJ_LockObj(hDirectDrawLocal, GDI_OBJECT_TYPE_DIRECTDRAW);
130 if (!pDirectDraw)
131 return FALSE;
132
133 BOOL success = pDirectDraw->DrvGetDirectDrawInfo(
134 pDirectDraw->Global.dhpdev,
135 pHalInfo,
136 puNumHeaps,
137 puvmList,
138 puNumFourCC,
139 puFourCC);
140
141 if (!success)
142 {
143 GDIOBJ_UnlockObjByPtr(pDirectDraw);
144 return FALSE;
145 }
146
147 if (pHalInfo)
148 {
149 RtlMoveMemory(&pDirectDraw->Hal, pHalInfo, sizeof(DD_HALINFO));
150
151 if (pHalInfo->lpD3DHALCallbacks)
152 {
153 RtlMoveMemory(puD3dCallbacks, pHalInfo->lpD3DHALCallbacks, sizeof(D3DNTHAL_CALLBACKS));
154 }
155
156 if (pHalInfo->lpD3DGlobalDriverData)
157 {
158 RtlMoveMemory(puD3dDriverData, pHalInfo->lpD3DGlobalDriverData, sizeof(D3DNTHAL_GLOBALDRIVERDATA));
159 }
160 if (pHalInfo->lpD3DBufCallbacks)
161 {
162 RtlMoveMemory(puD3dBufferCallbacks, pHalInfo->lpD3DBufCallbacks, sizeof(DD_D3DBUFCALLBACKS));
163 }
164
165 }
166
167 GDIOBJ_UnlockObjByPtr(pDirectDraw);
168
169 return TRUE;
170 }
171
172
173 DWORD STDCALL NtGdiDdGetDriverInfo(
174 HANDLE hDirectDrawLocal,
175 PDD_GETDRIVERINFODATA puGetDriverInfoData)
176
177 {
178 DWORD ddRVal;
179
180 PDD_DIRECTDRAW pDirectDraw = GDIOBJ_LockObj(hDirectDrawLocal, GDI_OBJECT_TYPE_DIRECTDRAW);
181 if (pDirectDraw == NULL)
182 return DDHAL_DRIVER_NOTHANDLED;
183
184 if (!(pDirectDraw->Hal.dwFlags & DDHALINFO_GETDRIVERINFOSET))
185 ddRVal = DDHAL_DRIVER_NOTHANDLED;
186 else
187 ddRVal = pDirectDraw->Hal.GetDriverInfo(puGetDriverInfoData);
188
189 GDIOBJ_UnlockObjByPtr(pDirectDraw);
190
191 return ddRVal;
192 }
193
194 /************************************************************************/
195 /* DD CALLBACKS */
196 /* FIXME NtGdiDdCreateSurface we do not call to ddCreateSurface */
197 /************************************************************************/
198
199 DWORD STDCALL NtGdiDdCreateSurface(
200 HANDLE hDirectDrawLocal,
201 HANDLE *hSurface,
202 DDSURFACEDESC *puSurfaceDescription,
203 DD_SURFACE_GLOBAL *puSurfaceGlobalData,
204 DD_SURFACE_LOCAL *puSurfaceLocalData,
205 DD_SURFACE_MORE *puSurfaceMoreData,
206 PDD_CREATESURFACEDATA puCreateSurfaceData,
207 HANDLE *puhSurface
208 )
209 {
210 DWORD ddRVal = DDHAL_DRIVER_NOTHANDLED;
211
212
213 PDD_DIRECTDRAW pDirectDraw = GDIOBJ_LockObj(hDirectDrawLocal, GDI_OBJECT_TYPE_DIRECTDRAW);
214 if (pDirectDraw == NULL)
215 return DDHAL_DRIVER_NOTHANDLED;
216
217 if (!(pDirectDraw->DD.dwFlags & DDHAL_CB32_CANCREATESURFACE))
218 ddRVal = DDHAL_DRIVER_NOTHANDLED;
219 else
220 {
221 ddRVal = pDirectDraw->DD.CreateSurface(puCreateSurfaceData);
222 }
223
224 GDIOBJ_UnlockObjByPtr(pDirectDraw);
225 return ddRVal;
226 }
227
228 DWORD STDCALL NtGdiDdWaitForVerticalBlank(
229 HANDLE hDirectDrawLocal,
230 PDD_WAITFORVERTICALBLANKDATA puWaitForVerticalBlankData
231 )
232 {
233 DWORD ddRVal;
234 PDD_DIRECTDRAW pDirectDraw = GDIOBJ_LockObj(hDirectDrawLocal, GDI_OBJECT_TYPE_DIRECTDRAW);
235 if (pDirectDraw == NULL)
236 return DDHAL_DRIVER_NOTHANDLED;
237
238 if (!(pDirectDraw->DD.dwFlags & DDHAL_CB32_WAITFORVERTICALBLANK))
239 ddRVal = DDHAL_DRIVER_NOTHANDLED;
240 else
241 ddRVal = pDirectDraw->DD.WaitForVerticalBlank(puWaitForVerticalBlankData);
242
243 GDIOBJ_UnlockObjByPtr(pDirectDraw);
244 return ddRVal;
245 }
246
247 DWORD STDCALL NtGdiDdCanCreateSurface(
248 HANDLE hDirectDrawLocal,
249 PDD_CANCREATESURFACEDATA puCanCreateSurfaceData
250 )
251 {
252 DWORD ddRVal;
253
254 PDD_DIRECTDRAW pDirectDraw = GDIOBJ_LockObj(hDirectDrawLocal, GDI_OBJECT_TYPE_DIRECTDRAW);
255 if (pDirectDraw == NULL)
256 return DDHAL_DRIVER_NOTHANDLED;
257
258 if (!(pDirectDraw->DD.dwFlags & DDHAL_CB32_CANCREATESURFACE))
259 ddRVal = DDHAL_DRIVER_NOTHANDLED;
260 else
261 ddRVal = pDirectDraw->DD.CanCreateSurface(puCanCreateSurfaceData);
262
263 GDIOBJ_UnlockObjByPtr(pDirectDraw);
264 return ddRVal;
265 }
266
267 DWORD STDCALL NtGdiDdGetScanLine(
268 HANDLE hDirectDrawLocal,
269 PDD_GETSCANLINEDATA puGetScanLineData
270 )
271 {
272 DWORD ddRVal;
273
274 PDD_DIRECTDRAW pDirectDraw = GDIOBJ_LockObj(hDirectDrawLocal, GDI_OBJECT_TYPE_DIRECTDRAW);
275 if (pDirectDraw == NULL)
276 return DDHAL_DRIVER_NOTHANDLED;
277
278 if (!(pDirectDraw->DD.dwFlags & DDHAL_CB32_GETSCANLINE))
279 ddRVal = DDHAL_DRIVER_NOTHANDLED;
280 else
281 ddRVal = pDirectDraw->DD.GetScanLine(puGetScanLineData);
282
283 GDIOBJ_UnlockObjByPtr(pDirectDraw);
284 return ddRVal;
285 }
286
287
288
289 /************************************************************************/
290 /* Surface CALLBACKS */
291 /* FIXME */
292 /* NtGdiDdDestroySurface */
293 /************************************************************************/
294
295 DWORD STDCALL NtGdiDdDestroySurface(
296 HANDLE hSurface,
297 BOOL bRealDestroy
298 )
299 {
300 DWORD ddRVal = DDHAL_DRIVER_NOTHANDLED;
301
302 PDD_DIRECTDRAW pDirectDraw = GDIOBJ_LockObj(hSurface, GDI_OBJECT_TYPE_DIRECTDRAW);
303 if (pDirectDraw == NULL)
304 return DDHAL_DRIVER_NOTHANDLED;
305
306 if (!(pDirectDraw->Surf.dwFlags & DDHAL_SURFCB32_DESTROYSURFACE))
307 ddRVal = DDHAL_DRIVER_NOTHANDLED;
308 else
309 {
310 DD_DESTROYSURFACEDATA DestroySurf;
311
312 /* FIXME
313 * bRealDestroy
314 * are we doing right ??
315 */
316 DestroySurf.lpDD = &pDirectDraw->Global;
317
318 DestroySurf.lpDDSurface = hSurface; // ?
319 DestroySurf.DestroySurface = pDirectDraw->Surf.DestroySurface;
320
321 ddRVal = pDirectDraw->Surf.DestroySurface(&DestroySurf);
322 }
323
324 GDIOBJ_UnlockObjByPtr(pDirectDraw);
325 return ddRVal;
326 }
327
328 DWORD STDCALL NtGdiDdFlip(
329 HANDLE hSurfaceCurrent,
330 HANDLE hSurfaceTarget,
331 HANDLE hSurfaceCurrentLeft,
332 HANDLE hSurfaceTargetLeft,
333 PDD_FLIPDATA puFlipData
334 )
335 {
336 DWORD ddRVal;
337
338 PDD_DIRECTDRAW pDirectDraw = GDIOBJ_LockObj(hSurfaceTarget, GDI_OBJECT_TYPE_DIRECTDRAW);
339 if (pDirectDraw == NULL)
340 return DDHAL_DRIVER_NOTHANDLED;
341
342 if (!(pDirectDraw->Surf.dwFlags & DDHAL_SURFCB32_FLIP))
343 ddRVal = DDHAL_DRIVER_NOTHANDLED;
344 else
345 ddRVal = pDirectDraw->Surf.Flip(puFlipData);
346
347 GDIOBJ_UnlockObjByPtr(pDirectDraw);
348 return ddRVal;
349 }
350
351 DWORD STDCALL NtGdiDdLock(
352 HANDLE hSurface,
353 PDD_LOCKDATA puLockData,
354 HDC hdcClip
355 )
356 {
357 DWORD ddRVal;
358
359 PDD_DIRECTDRAW pDirectDraw = GDIOBJ_LockObj(hSurface, GDI_OBJECT_TYPE_DIRECTDRAW);
360 if (pDirectDraw == NULL)
361 return DDHAL_DRIVER_NOTHANDLED;
362
363 if (!(pDirectDraw->Surf.dwFlags & DDHAL_SURFCB32_LOCK))
364 ddRVal = DDHAL_DRIVER_NOTHANDLED;
365 else
366 ddRVal = pDirectDraw->Surf.Lock(puLockData);
367
368 GDIOBJ_UnlockObjByPtr(pDirectDraw);
369 return ddRVal;
370 }
371
372 DWORD STDCALL NtGdiDdUnlock(
373 HANDLE hSurface,
374 PDD_UNLOCKDATA puUnlockData
375 )
376 {
377 DWORD ddRVal;
378
379 PDD_DIRECTDRAW pDirectDraw = GDIOBJ_LockObj(hSurface, GDI_OBJECT_TYPE_DIRECTDRAW);
380 if (pDirectDraw == NULL)
381 return DDHAL_DRIVER_NOTHANDLED;
382
383 if (!(pDirectDraw->Surf.dwFlags & DDHAL_SURFCB32_UNLOCK))
384 ddRVal = DDHAL_DRIVER_NOTHANDLED;
385 else
386 ddRVal = pDirectDraw->Surf.Unlock(puUnlockData);
387
388 GDIOBJ_UnlockObjByPtr(pDirectDraw);
389 return ddRVal;
390 }
391
392 DWORD STDCALL NtGdiDdBlt(
393 HANDLE hSurfaceDest,
394 HANDLE hSurfaceSrc,
395 PDD_BLTDATA puBltData
396 )
397 {
398 DWORD ddRVal;
399
400 PDD_DIRECTDRAW pDirectDraw = GDIOBJ_LockObj(hSurfaceDest, GDI_OBJECT_TYPE_DIRECTDRAW);
401 if (pDirectDraw == NULL)
402 return DDHAL_DRIVER_NOTHANDLED;
403
404 if (!(pDirectDraw->Surf.dwFlags & DDHAL_SURFCB32_BLT))
405 ddRVal = DDHAL_DRIVER_NOTHANDLED;
406 else
407 ddRVal = pDirectDraw->Surf.Blt(puBltData);
408
409 GDIOBJ_UnlockObjByPtr(pDirectDraw);
410 return ddRVal;
411 }
412
413 DWORD STDCALL NtGdiDdSetColorKey(
414 HANDLE hSurface,
415 PDD_SETCOLORKEYDATA puSetColorKeyData
416 )
417 {
418 DWORD ddRVal;
419
420 PDD_DIRECTDRAW pDirectDraw = GDIOBJ_LockObj(hSurface, GDI_OBJECT_TYPE_DIRECTDRAW);
421 if (pDirectDraw == NULL)
422 return DDHAL_DRIVER_NOTHANDLED;
423
424 if (!(pDirectDraw->Surf.dwFlags & DDHAL_SURFCB32_SETCOLORKEY))
425 ddRVal = DDHAL_DRIVER_NOTHANDLED;
426 else
427 ddRVal = pDirectDraw->Surf.SetColorKey(puSetColorKeyData);
428
429 GDIOBJ_UnlockObjByPtr(pDirectDraw);
430 return ddRVal;
431 }
432
433
434 DWORD STDCALL NtGdiDdAddAttachedSurface(
435 HANDLE hSurface,
436 HANDLE hSurfaceAttached,
437 PDD_ADDATTACHEDSURFACEDATA puAddAttachedSurfaceData
438 )
439 {
440 DWORD ddRVal;
441
442 PDD_DIRECTDRAW pDirectDraw = GDIOBJ_LockObj(hSurfaceAttached, GDI_OBJECT_TYPE_DIRECTDRAW);
443 if (pDirectDraw == NULL)
444 return DDHAL_DRIVER_NOTHANDLED;
445
446 if (!(pDirectDraw->Surf.dwFlags & DDHAL_SURFCB32_ADDATTACHEDSURFACE))
447 ddRVal = DDHAL_DRIVER_NOTHANDLED;
448 else
449 ddRVal = pDirectDraw->Surf.AddAttachedSurface(puAddAttachedSurfaceData);
450
451 GDIOBJ_UnlockObjByPtr(pDirectDraw);
452 return ddRVal;
453 }
454
455 DWORD STDCALL NtGdiDdGetBltStatus(
456 HANDLE hSurface,
457 PDD_GETBLTSTATUSDATA puGetBltStatusData
458 )
459 {
460 DWORD ddRVal;
461
462 PDD_DIRECTDRAW pDirectDraw = GDIOBJ_LockObj(hSurface, GDI_OBJECT_TYPE_DIRECTDRAW);
463 if (pDirectDraw == NULL)
464 return DDHAL_DRIVER_NOTHANDLED;
465
466 if (!(pDirectDraw->Surf.dwFlags & DDHAL_SURFCB32_GETBLTSTATUS))
467 ddRVal = DDHAL_DRIVER_NOTHANDLED;
468 else
469 ddRVal = pDirectDraw->Surf.GetBltStatus(puGetBltStatusData);
470
471 GDIOBJ_UnlockObjByPtr(pDirectDraw);
472 return ddRVal;
473 }
474
475 DWORD STDCALL NtGdiDdGetFlipStatus(
476 HANDLE hSurface,
477 PDD_GETFLIPSTATUSDATA puGetFlipStatusData
478 )
479 {
480 DWORD ddRVal;
481
482 PDD_DIRECTDRAW pDirectDraw = GDIOBJ_LockObj(hSurface, GDI_OBJECT_TYPE_DIRECTDRAW);
483 if (pDirectDraw == NULL)
484 return DDHAL_DRIVER_NOTHANDLED;
485
486 if (!(pDirectDraw->Surf.dwFlags & DDHAL_SURFCB32_GETFLIPSTATUS))
487 ddRVal = DDHAL_DRIVER_NOTHANDLED;
488 else
489 ddRVal = pDirectDraw->Surf.GetFlipStatus(puGetFlipStatusData);
490
491 GDIOBJ_UnlockObjByPtr(pDirectDraw);
492 return ddRVal;
493 }
494
495 DWORD STDCALL NtGdiDdUpdateOverlay(
496 HANDLE hSurfaceDestination,
497 HANDLE hSurfaceSource,
498 PDD_UPDATEOVERLAYDATA puUpdateOverlayData
499 )
500 {
501 DWORD ddRVal;
502
503 PDD_DIRECTDRAW pDirectDraw = GDIOBJ_LockObj(hSurfaceDestination, GDI_OBJECT_TYPE_DIRECTDRAW);
504 if (pDirectDraw == NULL)
505 return DDHAL_DRIVER_NOTHANDLED;
506
507 if (!(pDirectDraw->Surf.dwFlags & DDHAL_SURFCB32_UPDATEOVERLAY))
508 ddRVal = DDHAL_DRIVER_NOTHANDLED;
509 else
510 ddRVal = pDirectDraw->Surf.UpdateOverlay(puUpdateOverlayData);
511
512 GDIOBJ_UnlockObjByPtr(pDirectDraw);
513 return ddRVal;
514 }
515
516 DWORD STDCALL NtGdiDdSetOverlayPosition(
517 HANDLE hSurfaceSource,
518 HANDLE hSurfaceDestination,
519 PDD_SETOVERLAYPOSITIONDATA puSetOverlayPositionData
520 )
521 {
522 DWORD ddRVal;
523
524 PDD_DIRECTDRAW pDirectDraw = GDIOBJ_LockObj(hSurfaceDestination, GDI_OBJECT_TYPE_DIRECTDRAW);
525 if (pDirectDraw == NULL)
526 return DDHAL_DRIVER_NOTHANDLED;
527
528 if (!(pDirectDraw->Surf.dwFlags & DDHAL_SURFCB32_SETOVERLAYPOSITION))
529 ddRVal = DDHAL_DRIVER_NOTHANDLED;
530 else
531 ddRVal = pDirectDraw->Surf.SetOverlayPosition(puSetOverlayPositionData);
532
533 GDIOBJ_UnlockObjByPtr(pDirectDraw);
534 return ddRVal;
535 }
536
537
538 /************************************************************************/
539 /* SURFACE OBJECT */
540 /************************************************************************/
541
542 BOOL INTERNAL_CALL
543 DDSURF_Cleanup(PVOID pDDSurf)
544 {
545 /* FIXME: implement
546 * PDD_SURFACE pDDSurf = PVOID pDDSurf
547 */
548 return TRUE;
549 }
550
551 HANDLE STDCALL NtGdiDdCreateSurfaceObject(
552 HANDLE hDirectDrawLocal,
553 HANDLE hSurface,
554 PDD_SURFACE_LOCAL puSurfaceLocal,
555 PDD_SURFACE_MORE puSurfaceMore,
556 PDD_SURFACE_GLOBAL puSurfaceGlobal,
557 BOOL bComplete
558 )
559 {
560 PDD_DIRECTDRAW pDirectDraw = GDIOBJ_LockObj(hDirectDrawLocal, GDI_OBJECT_TYPE_DIRECTDRAW);
561 if (!pDirectDraw)
562 return NULL;
563
564 if (!hSurface)
565 hSurface = GDIOBJ_AllocObj(GDI_OBJECT_TYPE_DD_SURFACE);
566
567 PDD_SURFACE pSurface = GDIOBJ_LockObj(hSurface, GDI_OBJECT_TYPE_DD_SURFACE);
568 /* FIXME - Handle pSurface == NULL!!!! */
569
570 RtlMoveMemory(&pSurface->Local, puSurfaceLocal, sizeof(DD_SURFACE_LOCAL));
571 RtlMoveMemory(&pSurface->More, puSurfaceMore, sizeof(DD_SURFACE_MORE));
572 RtlMoveMemory(&pSurface->Global, puSurfaceGlobal, sizeof(DD_SURFACE_GLOBAL));
573 pSurface->Local.lpGbl = &pSurface->Global;
574 pSurface->Local.lpSurfMore = &pSurface->More;
575 pSurface->Local.lpAttachList = NULL;
576 pSurface->Local.lpAttachListFrom = NULL;
577 pSurface->More.lpVideoPort = NULL;
578 // FIXME: figure out how to use this
579 pSurface->bComplete = bComplete;
580
581 GDIOBJ_UnlockObjByPtr(pSurface);
582 GDIOBJ_UnlockObjByPtr(pDirectDraw);
583
584 return hSurface;
585 }
586
587 BOOL STDCALL NtGdiDdDeleteSurfaceObject(
588 HANDLE hSurface
589 )
590 {
591 return GDIOBJ_FreeObj(hSurface, GDI_OBJECT_TYPE_DD_SURFACE);
592 }
593
594
595
596 /************************************************************************/
597 /* DIRECT DRAW SURFACR END */
598 /************************************************************************/
599
600
601 /*
602 BOOL STDCALL NtGdiDdAttachSurface(
603 HANDLE hSurfaceFrom,
604 HANDLE hSurfaceTo
605 )
606 {
607 PDD_SURFACE pSurfaceFrom = GDIOBJ_LockObj(hSurfaceFrom, GDI_OBJECT_TYPE_DD_SURFACE);
608 if (!pSurfaceFrom)
609 return FALSE;
610 PDD_SURFACE pSurfaceTo = GDIOBJ_LockObj(hSurfaceTo, GDI_OBJECT_TYPE_DD_SURFACE);
611 if (!pSurfaceTo)
612 {
613 GDIOBJ_UnlockObjByPtr(pSurfaceFrom);
614 return FALSE;
615 }
616
617 if (pSurfaceFrom->Local.lpAttachListFrom)
618 {
619 pSurfaceFrom->Local.lpAttachListFrom = pSurfaceFrom->AttachListFrom;
620 }
621
622 GDIOBJ_UnlockObjByPtr(pSurfaceFrom);
623 GDIOBJ_UnlockObjByPtr(pSurfaceTo);
624 return TRUE;
625 }
626 */
627
628 DWORD STDCALL NtGdiDdGetAvailDriverMemory(
629 HANDLE hDirectDrawLocal,
630 PDD_GETAVAILDRIVERMEMORYDATA puGetAvailDriverMemoryData
631 )
632 {
633 DWORD ddRVal = DDHAL_DRIVER_NOTHANDLED;
634
635 PDD_DIRECTDRAW pDirectDraw = GDIOBJ_LockObj(hDirectDrawLocal, GDI_OBJECT_TYPE_DIRECTDRAW);
636
637 // ddRVal = pDirectDraw->DdGetAvailDriverMemory(puGetAvailDriverMemoryData);
638
639 GDIOBJ_UnlockObjByPtr(pDirectDraw);
640
641 return ddRVal;
642 }
643
644
645
646
647 DWORD STDCALL NtGdiDdSetExclusiveMode(
648 HANDLE hDirectDraw,
649 PDD_SETEXCLUSIVEMODEDATA puSetExclusiveModeData
650 )
651 {
652 DWORD ddRVal;
653
654 PDD_DIRECTDRAW pDirectDraw = GDIOBJ_LockObj(hDirectDraw, GDI_OBJECT_TYPE_DIRECTDRAW);
655
656 ddRVal = pDirectDraw->DdSetExclusiveMode(puSetExclusiveModeData);
657
658 GDIOBJ_UnlockObjByPtr(pDirectDraw);
659
660 return ddRVal;
661 }
662
663
664
665
666 /* EOF */