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)
8 * 25-10-2003 PB Created
15 GDIDEVICE
IntGetPrimarySurface(VOID
);
17 /* swtich this off to get rid of all dx debug msg */
20 #define DdHandleTable GdiHandleTable
25 /************************************************************************/
26 /* DIRECT DRAW OBJECT */
27 /************************************************************************/
30 DD_Cleanup(PVOID ObjectBody
)
32 PDD_DIRECTDRAW pDirectDraw
= (PDD_DIRECTDRAW
) ObjectBody
;
34 DPRINT1("DD_Cleanup\n");
41 if (pDirectDraw
->Global
.dhpdev
== NULL
)
46 if (pDirectDraw
->DrvDisableDirectDraw
== NULL
)
51 //if (pDirectDraw->pvmList != NULL)
53 // ExFreePool(pDirectDraw->pvmList);
56 //if (pDirectDraw->pdwFourCC != NULL)
58 // ExFreePool(pDirectDraw->pdwFourCC);
61 pDirectDraw
->DrvDisableDirectDraw(pDirectDraw
->Global
.dhpdev
);
65 /* code for enable and reanble the drv */
67 intEnableDriver(PDD_DIRECTDRAW pDirectDraw
)
72 /*clean up some of the cache entry */
73 RtlZeroMemory(&pDirectDraw
->DD
, sizeof(DD_CALLBACKS
));
74 RtlZeroMemory(&pDirectDraw
->Surf
, sizeof(DD_SURFACECALLBACKS
));
75 RtlZeroMemory(&pDirectDraw
->Pal
, sizeof(DD_PALETTECALLBACKS
));
76 RtlZeroMemory(&pDirectDraw
->Hal
, sizeof(DD_HALINFO
));
77 RtlZeroMemory(&HalInfo
, sizeof(DD_HALINFO
));
78 pDirectDraw
->dwNumHeaps
=0;
79 pDirectDraw
->dwNumFourCC
= 0;
80 pDirectDraw
->pdwFourCC
= NULL
;
81 pDirectDraw
->pvmList
= NULL
;
83 /* Get DirectDraw infomations form the driver
84 * DDK say pvmList, pdwFourCC is always NULL in frist call here
85 * but we get back how many pvmList it whant we should alloc, same
88 success
= pDirectDraw
->DrvGetDirectDrawInfo( pDirectDraw
->Global
.dhpdev
,
90 &pDirectDraw
->dwNumHeaps
,
92 &pDirectDraw
->dwNumFourCC
,
96 DPRINT1("DrvGetDirectDrawInfo frist call fail\n");
97 GDIOBJ_UnlockObjByPtr(DdHandleTable
, pDirectDraw
);
101 /* The driver are not respnose to alloc the memory for pvmList
102 * but it is win32k responsible todo, Windows 9x it is gdi32.dll
104 if (pDirectDraw
->dwNumHeaps
!= 0)
106 pDirectDraw
->pvmList
= (PVIDEOMEMORY
) ExAllocatePoolWithTag(PagedPool
, pDirectDraw
->dwNumHeaps
* sizeof(VIDEOMEMORY
), TAG_DXPVMLIST
);
107 if (pDirectDraw
->pvmList
== NULL
)
113 /* The driver are not respnose to alloc the memory for pdwFourCC
114 * but it is win32k responsible todo, Windows 9x it is gdi32.dll
117 if (pDirectDraw
->dwNumFourCC
!= 0)
119 pDirectDraw
->pdwFourCC
= (LPDWORD
) ExAllocatePoolWithTag(PagedPool
, pDirectDraw
->dwNumFourCC
* sizeof(DWORD
), TAG_DXFOURCC
);
121 if (pDirectDraw
->pdwFourCC
== NULL
)
127 success
= pDirectDraw
->DrvGetDirectDrawInfo( pDirectDraw
->Global
.dhpdev
,
129 &pDirectDraw
->dwNumHeaps
,
130 pDirectDraw
->pvmList
,
131 &pDirectDraw
->dwNumFourCC
,
132 pDirectDraw
->pdwFourCC
);
135 DPRINT1("DrvGetDirectDrawInfo second call fail\n");
136 GDIOBJ_UnlockObjByPtr(DdHandleTable
, pDirectDraw
);
141 /* We need now convert the DD_HALINFO we got, it can be NT4 driver we
142 * loading ReactOS supporting NT4 and higher to be loading.so we make
143 * the HALInfo compatible here so we can easy pass it to gdi32.dll
144 * without converting it later
147 if ((HalInfo
.dwSize
!= sizeof(DD_HALINFO
)) &&
148 (HalInfo
.dwSize
!= sizeof(DD_HALINFO_V4
)))
150 DPRINT1(" Fail not vaild driver DD_HALINFO struct found\n");
151 GDIOBJ_UnlockObjByPtr(DdHandleTable
, pDirectDraw
);
155 if (HalInfo
.dwSize
!= sizeof(DD_HALINFO
))
157 if (HalInfo
.dwSize
== sizeof(DD_HALINFO_V4
))
160 DPRINT1("Got DD_HALINFO_V4 sturct we convert it to DD_HALINFO \n");
161 HalInfo
.dwSize
= sizeof(DD_HALINFO
);
162 HalInfo
.lpD3DGlobalDriverData
= NULL
;
163 HalInfo
.lpD3DHALCallbacks
= NULL
;
164 HalInfo
.lpD3DBufCallbacks
= NULL
;
168 /* Unknown version found */
169 DPRINT1(" Fail : did not get DD_HALINFO size \n");
171 GDIOBJ_UnlockObjByPtr(DdHandleTable
, pDirectDraw
);
175 /* Copy it to user mode pointer the data */
176 RtlCopyMemory(&pDirectDraw
->Hal
, &HalInfo
, sizeof(DD_HALINFO
));
179 success
= pDirectDraw
->EnableDirectDraw( pDirectDraw
->Global
.dhpdev
,
186 DPRINT1("EnableDirectDraw call fail\n");
187 GDIOBJ_UnlockObjByPtr(DdHandleTable
, pDirectDraw
);
196 NtGdiDdCreateDirectDrawObject(HDC hdc
)
200 PDD_DIRECTDRAW pDirectDraw
;
202 DPRINT1("NtGdiDdCreateDirectDrawObject\n");
204 /* Create a hdc if we do not have one */
210 /* Look the hdc to gain the internal struct */
211 pDC
= DC_LockDc(hdc
);
217 /* test see if drv got a dx interface or not */
218 if (( pDC
->DriverFunctions
.GetDirectDrawInfo
== NULL
) ||
219 ( pDC
->DriverFunctions
.DisableDirectDraw
== NULL
) ||
220 ( pDC
->DriverFunctions
.EnableDirectDraw
== NULL
))
226 /* alloc and lock the stucrt */
227 hDirectDraw
= GDIOBJ_AllocObj(DdHandleTable
, GDI_OBJECT_TYPE_DIRECTDRAW
);
230 /* No more memmory */
235 pDirectDraw
= GDIOBJ_LockObj(DdHandleTable
, hDirectDraw
, GDI_OBJECT_TYPE_DIRECTDRAW
);
243 /* setup the internal stuff */
244 pDirectDraw
->Global
.dhpdev
= pDC
->PDev
;
245 pDirectDraw
->Local
.lpGbl
= &pDirectDraw
->Global
;
247 pDirectDraw
->DrvGetDirectDrawInfo
= pDC
->DriverFunctions
.GetDirectDrawInfo
;
248 pDirectDraw
->DrvDisableDirectDraw
= pDC
->DriverFunctions
.DisableDirectDraw
;
249 pDirectDraw
->EnableDirectDraw
= pDC
->DriverFunctions
.EnableDirectDraw
;
251 if (intEnableDriver(pDirectDraw
) == FALSE
)
253 /* FIXME delete the pDirectDraw and the handle */
254 GDIOBJ_UnlockObjByPtr(DdHandleTable
, pDirectDraw
);
259 GDIOBJ_UnlockObjByPtr(DdHandleTable
, pDirectDraw
);
261 DPRINT1("DirectDraw return handler 0x%x\n",hDirectDraw
);
267 NtGdiDdDeleteDirectDrawObject( HANDLE hDirectDrawLocal
)
269 DPRINT1("NtGdiDdDeleteDirectDrawObject\n");
270 return GDIOBJ_FreeObj(DdHandleTable
, hDirectDrawLocal
, GDI_OBJECT_TYPE_DIRECTDRAW
);
275 NtGdiDdQueryDirectDrawObject(
276 HANDLE hDirectDrawLocal
,
277 DD_HALINFO
*pHalInfo
,
278 DWORD
*pCallBackFlags
,
279 LPD3DNTHAL_CALLBACKS puD3dCallbacks
,
280 LPD3DNTHAL_GLOBALDRIVERDATA puD3dDriverData
,
281 PDD_D3DBUFCALLBACKS puD3dBufferCallbacks
,
282 LPDDSURFACEDESC puD3dTextureFormats
,
284 VIDEOMEMORY
*puvmList
,
289 PDD_DIRECTDRAW pDirectDraw
;
290 NTSTATUS Status
= FALSE
;
292 DPRINT1("NtGdiDdQueryDirectDrawObject\n");
293 if (hDirectDrawLocal
== NULL
)
298 pDirectDraw
= GDIOBJ_LockObj(DdHandleTable
, hDirectDrawLocal
,
299 GDI_OBJECT_TYPE_DIRECTDRAW
);
308 ProbeForWrite(pHalInfo
, sizeof(DD_HALINFO
), 1);
309 RtlCopyMemory(pHalInfo
,&pDirectDraw
->Hal
, sizeof(DD_HALINFO
));
311 ProbeForWrite(pCallBackFlags
, sizeof(DWORD
)*3, 1);
312 pCallBackFlags
[0]=pDirectDraw
->DD
.dwFlags
;
313 pCallBackFlags
[1]=pDirectDraw
->Surf
.dwFlags
;
314 pCallBackFlags
[2]=pDirectDraw
->Pal
.dwFlags
;
316 if (pDirectDraw
->Hal
.lpD3DHALCallbacks
!= NULL
)
318 DPRINT1("Found DirectDraw CallBack for 3D Hal\n");
320 ProbeForWrite(puD3dCallbacks
, sizeof(D3DNTHAL_CALLBACKS
), 1);
321 RtlCopyMemory( puD3dCallbacks
, pDirectDraw
->Hal
.lpD3DHALCallbacks
,
322 sizeof( D3DNTHAL_CALLBACKS
) );
325 if (pDirectDraw
->Hal
.lpD3DGlobalDriverData
!= NULL
)
327 DPRINT1("Found DirectDraw Global DriverData \n");
329 ProbeForWrite(puD3dDriverData
, sizeof(D3DNTHAL_GLOBALDRIVERDATA
), 1);
330 RtlCopyMemory( puD3dDriverData
, pDirectDraw
->Hal
.lpD3DGlobalDriverData
,
331 sizeof(D3DNTHAL_GLOBALDRIVERDATA
));
334 if (pDirectDraw
->Hal
.lpD3DBufCallbacks
!= NULL
)
336 DPRINT1("Found DirectDraw CallBack for 3D Hal Bufffer \n");
337 ProbeForWrite(puD3dBufferCallbacks
, sizeof(DD_D3DBUFCALLBACKS
), 1);
338 RtlCopyMemory( puD3dBufferCallbacks
, pDirectDraw
->Hal
.lpD3DBufCallbacks
,
339 sizeof(DD_D3DBUFCALLBACKS
));
342 /* FIXME LPDDSURFACEDESC puD3dTextureFormats */
344 ProbeForWrite(puNumHeaps
, sizeof(DWORD
), 1);
345 *puNumHeaps
= pDirectDraw
->dwNumHeaps
;
347 if (pDirectDraw
->pvmList
!= NULL
)
349 ProbeForWrite(puvmList
, sizeof(VIDEOMEMORY
) * pDirectDraw
->dwNumHeaps
, 1);
350 RtlCopyMemory( puvmList
,
351 pDirectDraw
->pvmList
,
352 sizeof(VIDEOMEMORY
) * pDirectDraw
->dwNumHeaps
);
355 ProbeForWrite(puNumFourCC
, sizeof(DWORD
), 1);
356 *puNumFourCC
= pDirectDraw
->dwNumFourCC
;
358 if (pDirectDraw
->pdwFourCC
!= NULL
)
360 ProbeForWrite(puFourCC
, sizeof(DWORD
) * pDirectDraw
->dwNumFourCC
, 1);
361 RtlCopyMemory( puFourCC
,
362 pDirectDraw
->pdwFourCC
,
363 sizeof(DWORD
) * pDirectDraw
->dwNumFourCC
);
368 Status
= _SEH_GetExceptionCode();
372 GDIOBJ_UnlockObjByPtr(DdHandleTable
, pDirectDraw
);
374 if(!NT_SUCCESS(Status
))
376 SetLastNtError(Status
);
384 DWORD STDCALL
NtGdiDdGetDriverInfo(
385 HANDLE hDirectDrawLocal
,
386 PDD_GETDRIVERINFODATA puGetDriverInfoData
)
390 PDD_DIRECTDRAW pDirectDraw
= GDIOBJ_LockObj(DdHandleTable
, hDirectDrawLocal
,
391 GDI_OBJECT_TYPE_DIRECTDRAW
);
393 DPRINT1("NtGdiDdGetDriverInfo\n");
395 if (pDirectDraw
== NULL
)
397 return DDHAL_DRIVER_NOTHANDLED
;
400 /* it exsist two version of NtGdiDdGetDriverInfo we need check for both flags */
401 if (!(pDirectDraw
->Hal
.dwFlags
& DDHALINFO_GETDRIVERINFOSET
))
404 if (!(pDirectDraw
->Hal
.dwFlags
& DDHALINFO_GETDRIVERINFO2
))
407 /* Now we are doing the call to drv DrvGetDriverInfo */
410 DPRINT1("NtGdiDdGetDriverInfo DDHAL_DRIVER_NOTHANDLED");
411 ddRVal
= DDHAL_DRIVER_NOTHANDLED
;
415 ddRVal
= pDirectDraw
->Hal
.GetDriverInfo(puGetDriverInfoData
);
418 GDIOBJ_UnlockObjByPtr(DdHandleTable
, pDirectDraw
);
426 DWORD STDCALL
NtGdiDdUnlock(
428 PDD_UNLOCKDATA puUnlockData
432 PDD_DIRECTDRAW_GLOBAL lgpl
;
434 PDD_DIRECTDRAW pDirectDraw
= GDIOBJ_LockObj(DdHandleTable
, hSurface
, GDI_OBJECT_TYPE_DIRECTDRAW
);
436 DPRINT1("NtGdiDdUnlock\n");
438 if (pDirectDraw
== NULL
)
439 return DDHAL_DRIVER_NOTHANDLED
;
441 /* backup the orignal PDev and info */
442 lgpl
= puUnlockData
->lpDD
;
444 /* use our cache version instead */
445 puUnlockData
->lpDD
= &pDirectDraw
->Global
;
448 if (!(pDirectDraw
->Surf
.dwFlags
& DDHAL_SURFCB32_UNLOCK
))
449 ddRVal
= DDHAL_DRIVER_NOTHANDLED
;
451 ddRVal
= pDirectDraw
->Surf
.Unlock(puUnlockData
);
453 /* But back the orignal PDev */
454 puUnlockData
->lpDD
= lgpl
;
456 GDIOBJ_UnlockObjByPtr(DdHandleTable
, pDirectDraw
);
460 DWORD STDCALL
NtGdiDdBlt(
463 PDD_BLTDATA puBltData
467 PDD_DIRECTDRAW_GLOBAL lgpl
;
469 PDD_DIRECTDRAW pDirectDraw
= GDIOBJ_LockObj(DdHandleTable
, hSurfaceDest
, GDI_OBJECT_TYPE_DIRECTDRAW
);
471 DPRINT1("NtGdiDdBlt\n");
473 if (pDirectDraw
== NULL
)
474 return DDHAL_DRIVER_NOTHANDLED
;
476 /* backup the orignal PDev and info */
477 lgpl
= puBltData
->lpDD
;
479 /* use our cache version instead */
480 puBltData
->lpDD
= &pDirectDraw
->Global
;
483 if (!(pDirectDraw
->Surf
.dwFlags
& DDHAL_SURFCB32_BLT
))
484 ddRVal
= DDHAL_DRIVER_NOTHANDLED
;
486 ddRVal
= pDirectDraw
->Surf
.Blt(puBltData
);
488 /* But back the orignal PDev */
489 puBltData
->lpDD
= lgpl
;
491 GDIOBJ_UnlockObjByPtr(DdHandleTable
, pDirectDraw
);
495 DWORD STDCALL
NtGdiDdSetColorKey(
497 PDD_SETCOLORKEYDATA puSetColorKeyData
501 PDD_DIRECTDRAW_GLOBAL lgpl
;
503 PDD_DIRECTDRAW pDirectDraw
= GDIOBJ_LockObj(DdHandleTable
, hSurface
, GDI_OBJECT_TYPE_DIRECTDRAW
);
505 DPRINT1("NtGdiDdSetColorKey\n");
507 if (pDirectDraw
== NULL
)
508 return DDHAL_DRIVER_NOTHANDLED
;
510 /* backup the orignal PDev and info */
511 lgpl
= puSetColorKeyData
->lpDD
;
513 /* use our cache version instead */
514 puSetColorKeyData
->lpDD
= &pDirectDraw
->Global
;
517 if (!(pDirectDraw
->Surf
.dwFlags
& DDHAL_SURFCB32_SETCOLORKEY
))
518 ddRVal
= DDHAL_DRIVER_NOTHANDLED
;
520 ddRVal
= pDirectDraw
->Surf
.SetColorKey(puSetColorKeyData
);
522 /* But back the orignal PDev */
523 puSetColorKeyData
->lpDD
= lgpl
;
525 GDIOBJ_UnlockObjByPtr(DdHandleTable
, pDirectDraw
);
530 DWORD STDCALL
NtGdiDdAddAttachedSurface(
532 HANDLE hSurfaceAttached
,
533 PDD_ADDATTACHEDSURFACEDATA puAddAttachedSurfaceData
537 PDD_DIRECTDRAW_GLOBAL lgpl
;
539 PDD_DIRECTDRAW pDirectDraw
= GDIOBJ_LockObj(DdHandleTable
, hSurfaceAttached
, GDI_OBJECT_TYPE_DIRECTDRAW
);
541 DPRINT1("NtGdiDdAddAttachedSurface\n");
543 if (pDirectDraw
== NULL
)
544 return DDHAL_DRIVER_NOTHANDLED
;
546 /* backup the orignal PDev and info */
547 lgpl
= puAddAttachedSurfaceData
->lpDD
;
549 /* use our cache version instead */
550 puAddAttachedSurfaceData
->lpDD
= &pDirectDraw
->Global
;
553 if (!(pDirectDraw
->Surf
.dwFlags
& DDHAL_SURFCB32_ADDATTACHEDSURFACE
))
554 ddRVal
= DDHAL_DRIVER_NOTHANDLED
;
556 ddRVal
= pDirectDraw
->Surf
.AddAttachedSurface(puAddAttachedSurfaceData
);
558 /* But back the orignal PDev */
559 puAddAttachedSurfaceData
->lpDD
= lgpl
;
561 GDIOBJ_UnlockObjByPtr(DdHandleTable
, pDirectDraw
);
565 DWORD STDCALL
NtGdiDdGetBltStatus(
567 PDD_GETBLTSTATUSDATA puGetBltStatusData
571 PDD_DIRECTDRAW_GLOBAL lgpl
;
573 PDD_DIRECTDRAW pDirectDraw
= GDIOBJ_LockObj(DdHandleTable
, hSurface
, GDI_OBJECT_TYPE_DIRECTDRAW
);
575 DPRINT1("NtGdiDdGetBltStatus\n");
577 if (pDirectDraw
== NULL
)
578 return DDHAL_DRIVER_NOTHANDLED
;
580 /* backup the orignal PDev and info */
581 lgpl
= puGetBltStatusData
->lpDD
;
583 /* use our cache version instead */
584 puGetBltStatusData
->lpDD
= &pDirectDraw
->Global
;
587 if (!(pDirectDraw
->Surf
.dwFlags
& DDHAL_SURFCB32_GETBLTSTATUS
))
588 ddRVal
= DDHAL_DRIVER_NOTHANDLED
;
590 ddRVal
= pDirectDraw
->Surf
.GetBltStatus(puGetBltStatusData
);
592 /* But back the orignal PDev */
593 puGetBltStatusData
->lpDD
= lgpl
;
595 GDIOBJ_UnlockObjByPtr(DdHandleTable
, pDirectDraw
);
599 DWORD STDCALL
NtGdiDdGetFlipStatus(
601 PDD_GETFLIPSTATUSDATA puGetFlipStatusData
605 PDD_DIRECTDRAW_GLOBAL lgpl
;
607 PDD_DIRECTDRAW pDirectDraw
= GDIOBJ_LockObj(DdHandleTable
, hSurface
, GDI_OBJECT_TYPE_DIRECTDRAW
);
609 DPRINT1("NtGdiDdGetFlipStatus\n");
611 if (pDirectDraw
== NULL
)
612 return DDHAL_DRIVER_NOTHANDLED
;
614 /* backup the orignal PDev and info */
615 lgpl
= puGetFlipStatusData
->lpDD
;
617 /* use our cache version instead */
618 puGetFlipStatusData
->lpDD
= &pDirectDraw
->Global
;
621 if (!(pDirectDraw
->Surf
.dwFlags
& DDHAL_SURFCB32_GETFLIPSTATUS
))
622 ddRVal
= DDHAL_DRIVER_NOTHANDLED
;
624 ddRVal
= pDirectDraw
->Surf
.GetFlipStatus(puGetFlipStatusData
);
626 /* But back the orignal PDev */
627 puGetFlipStatusData
->lpDD
= lgpl
;
629 GDIOBJ_UnlockObjByPtr(DdHandleTable
, pDirectDraw
);
633 DWORD STDCALL
NtGdiDdUpdateOverlay(
634 HANDLE hSurfaceDestination
,
635 HANDLE hSurfaceSource
,
636 PDD_UPDATEOVERLAYDATA puUpdateOverlayData
640 PDD_DIRECTDRAW_GLOBAL lgpl
;
642 PDD_DIRECTDRAW pDirectDraw
= GDIOBJ_LockObj(DdHandleTable
, hSurfaceDestination
, GDI_OBJECT_TYPE_DIRECTDRAW
);
644 DPRINT1("NtGdiDdUpdateOverlay\n");
646 if (pDirectDraw
== NULL
)
647 return DDHAL_DRIVER_NOTHANDLED
;
649 /* backup the orignal PDev and info */
650 lgpl
= puUpdateOverlayData
->lpDD
;
652 /* use our cache version instead */
653 puUpdateOverlayData
->lpDD
= &pDirectDraw
->Global
;
656 if (!(pDirectDraw
->Surf
.dwFlags
& DDHAL_SURFCB32_UPDATEOVERLAY
))
657 ddRVal
= DDHAL_DRIVER_NOTHANDLED
;
659 ddRVal
= pDirectDraw
->Surf
.UpdateOverlay(puUpdateOverlayData
);
661 /* But back the orignal PDev */
662 puUpdateOverlayData
->lpDD
= lgpl
;
664 GDIOBJ_UnlockObjByPtr(DdHandleTable
, pDirectDraw
);
668 DWORD STDCALL
NtGdiDdSetOverlayPosition(
669 HANDLE hSurfaceSource
,
670 HANDLE hSurfaceDestination
,
671 PDD_SETOVERLAYPOSITIONDATA puSetOverlayPositionData
675 PDD_DIRECTDRAW_GLOBAL lgpl
;
677 PDD_DIRECTDRAW pDirectDraw
= GDIOBJ_LockObj(DdHandleTable
, hSurfaceDestination
, GDI_OBJECT_TYPE_DIRECTDRAW
);
679 DPRINT1("NtGdiDdSetOverlayPosition\n");
681 if (pDirectDraw
== NULL
)
682 return DDHAL_DRIVER_NOTHANDLED
;
684 /* backup the orignal PDev and info */
685 lgpl
= puSetOverlayPositionData
->lpDD
;
687 /* use our cache version instead */
688 puSetOverlayPositionData
->lpDD
= &pDirectDraw
->Global
;
691 if (!(pDirectDraw
->Surf
.dwFlags
& DDHAL_SURFCB32_SETOVERLAYPOSITION
))
692 ddRVal
= DDHAL_DRIVER_NOTHANDLED
;
694 ddRVal
= pDirectDraw
->Surf
.SetOverlayPosition(puSetOverlayPositionData
);
696 /* But back the orignal PDev */
697 puSetOverlayPositionData
->lpDD
= lgpl
;
699 GDIOBJ_UnlockObjByPtr(DdHandleTable
, pDirectDraw
);
704 /************************************************************************/
706 /************************************************************************/
709 DDSURF_Cleanup(PVOID pDDSurf
)
712 * PDD_SURFACE pDDSurf = PVOID pDDSurf
715 DPRINT1("DDSURF_Cleanup\n");
720 HANDLE STDCALL
NtGdiDdCreateSurfaceObject(
721 HANDLE hDirectDrawLocal
,
723 PDD_SURFACE_LOCAL puSurfaceLocal
,
724 PDD_SURFACE_MORE puSurfaceMore
,
725 PDD_SURFACE_GLOBAL puSurfaceGlobal
,
729 PDD_DIRECTDRAW pDirectDraw
= GDIOBJ_LockObj(DdHandleTable
, hDirectDrawLocal
, GDI_OBJECT_TYPE_DIRECTDRAW
);
730 PDD_SURFACE pSurface
;
732 DPRINT1("NtGdiDdCreateSurfaceObject\n");
738 hSurface
= GDIOBJ_AllocObj(DdHandleTable
, GDI_OBJECT_TYPE_DD_SURFACE
);
740 pSurface
= GDIOBJ_LockObj(DdHandleTable
, hSurface
, GDI_OBJECT_TYPE_DD_SURFACE
);
744 GDIOBJ_UnlockObjByPtr(DdHandleTable
, pDirectDraw
);
748 pSurface
->hDirectDrawLocal
= hDirectDrawLocal
;
750 RtlMoveMemory(&pSurface
->Local
, puSurfaceLocal
, sizeof(DD_SURFACE_LOCAL
));
751 RtlMoveMemory(&pSurface
->More
, puSurfaceMore
, sizeof(DD_SURFACE_MORE
));
752 RtlMoveMemory(&pSurface
->Global
, puSurfaceGlobal
, sizeof(DD_SURFACE_GLOBAL
));
753 pSurface
->Local
.lpGbl
= &pSurface
->Global
;
754 pSurface
->Local
.lpSurfMore
= &pSurface
->More
;
755 pSurface
->Local
.lpAttachList
= NULL
;
756 pSurface
->Local
.lpAttachListFrom
= NULL
;
757 pSurface
->More
.lpVideoPort
= NULL
;
758 // FIXME: figure out how to use this
759 pSurface
->bComplete
= bComplete
;
761 GDIOBJ_UnlockObjByPtr(DdHandleTable
, pSurface
);
762 GDIOBJ_UnlockObjByPtr(DdHandleTable
, pDirectDraw
);
767 BOOL STDCALL
NtGdiDdDeleteSurfaceObject(
772 DPRINT1("NtGdiDdDeleteSurfaceObject\n");
774 /* FIXME add right GDI_OBJECT_TYPE_ for everthing for now
775 we are using same type */
776 /* return GDIOBJ_FreeObj(hSurface, GDI_OBJECT_TYPE_DD_SURFACE); */
777 return GDIOBJ_FreeObj(DdHandleTable
, hSurface
, GDI_OBJECT_TYPE_DD_SURFACE
);
783 /************************************************************************/
784 /* DIRECT DRAW SURFACR END */
785 /************************************************************************/
789 BOOL STDCALL NtGdiDdAttachSurface(
794 PDD_SURFACE pSurfaceFrom = GDIOBJ_LockObj(hSurfaceFrom, GDI_OBJECT_TYPE_DD_SURFACE);
797 PDD_SURFACE pSurfaceTo = GDIOBJ_LockObj(hSurfaceTo, GDI_OBJECT_TYPE_DD_SURFACE);
800 GDIOBJ_UnlockObjByPtr(pSurfaceFrom);
804 if (pSurfaceFrom->Local.lpAttachListFrom)
806 pSurfaceFrom->Local.lpAttachListFrom = pSurfaceFrom->AttachListFrom;
809 GDIOBJ_UnlockObjByPtr(pSurfaceFrom);
810 GDIOBJ_UnlockObjByPtr(pSurfaceTo);
815 DWORD STDCALL
NtGdiDdGetAvailDriverMemory(
816 HANDLE hDirectDrawLocal
,
817 PDD_GETAVAILDRIVERMEMORYDATA puGetAvailDriverMemoryData
820 DWORD ddRVal
= DDHAL_DRIVER_NOTHANDLED
;
821 PDD_DIRECTDRAW_GLOBAL lgpl
;
823 PDD_DIRECTDRAW pDirectDraw
= GDIOBJ_LockObj(DdHandleTable
, hDirectDrawLocal
, GDI_OBJECT_TYPE_DIRECTDRAW
);
825 DPRINT1("NtGdiDdGetAvailDriverMemory\n");
828 /* backup the orignal PDev and info */
829 lgpl
= puGetAvailDriverMemoryData
->lpDD
;
831 /* use our cache version instead */
832 puGetAvailDriverMemoryData
->lpDD
= &pDirectDraw
->Global
;
835 // ddRVal = pDirectDraw->DdGetAvailDriverMemory(puGetAvailDriverMemoryData);
837 GDIOBJ_UnlockObjByPtr(DdHandleTable
, pDirectDraw
);
840 /* But back the orignal PDev */
841 puGetAvailDriverMemoryData
->lpDD
= lgpl
;
849 DWORD STDCALL
NtGdiDdSetExclusiveMode(
851 PDD_SETEXCLUSIVEMODEDATA puSetExclusiveModeData
855 PDD_DIRECTDRAW_GLOBAL lgpl
;
857 PDD_DIRECTDRAW pDirectDraw
= GDIOBJ_LockObj(DdHandleTable
, hDirectDraw
, GDI_OBJECT_TYPE_DIRECTDRAW
);
860 DPRINT1("NtGdiDdSetExclusiveMode\n");
863 /* backup the orignal PDev and info */
864 lgpl
= puSetExclusiveModeData
->lpDD
;
866 /* use our cache version instead */
867 puSetExclusiveModeData
->lpDD
= &pDirectDraw
->Global
;
870 ddRVal
= pDirectDraw
->DdSetExclusiveMode(puSetExclusiveModeData
);
872 GDIOBJ_UnlockObjByPtr(DdHandleTable
, pDirectDraw
);
874 /* But back the orignal PDev */
875 puSetExclusiveModeData
->lpDD
= lgpl
;