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