2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS GDI32
4 * PURPOSE: GDI DirectX inteface
5 * FILE: lib/gdi32/misc/gdientry.c
6 * PROGRAMERS: Alex Ionescu (alex@relsoft.net)
7 * Magnus Olsen (magnus@greatlord.com)
10 /* INCLUDES ******************************************************************/
20 /* DATA **********************************************************************/
25 #define GetDdHandle(Handle) ((HANDLE)Handle ? (HANDLE)Handle : ghDirectDraw)
29 /* CALLBACKS *****************************************************************/
34 * DdAddAttachedSurface
38 DdAddAttachedSurface(LPDDHAL_ADDATTACHEDSURFACEDATA Attach
)
41 return NtGdiDdAddAttachedSurface((HANDLE
)Attach
->lpDDSurface
->hDDSurface
,
42 (HANDLE
)Attach
->lpSurfAttached
->hDDSurface
,
43 (PDD_ADDATTACHEDSURFACEDATA
)Attach
);
53 DdBlt(LPDDHAL_BLTDATA Blt
)
57 /* Use the right surface */
58 if (Blt
->lpDDSrcSurface
)
60 Surface
= (HANDLE
)Blt
->lpDDSrcSurface
->hDDSurface
;
64 return NtGdiDdBlt((HANDLE
)Blt
->lpDDDestSurface
->hDDSurface
, Surface
, (PDD_BLTDATA
)Blt
);
74 DdDestroySurface(LPDDHAL_DESTROYSURFACEDATA pDestroySurface
)
76 DWORD Return
= DDHAL_DRIVER_NOTHANDLED
;
79 if (pDestroySurface
->lpDDSurface
->hDDSurface
)
81 /* Check if we shoudl really destroy it */
82 RealDestroy
= !(pDestroySurface
->lpDDSurface
->dwFlags
& DDRAWISURF_DRIVERMANAGED
) ||
83 !(pDestroySurface
->lpDDSurface
->dwFlags
& DDRAWISURF_INVALID
);
86 Return
= NtGdiDdDestroySurface((HANDLE
)pDestroySurface
->lpDDSurface
->hDDSurface
, RealDestroy
);
99 DdFlip(LPDDHAL_FLIPDATA Flip
)
102 * See http://msdn2.microsoft.com/en-us/library/ms794213.aspx and
103 * http://msdn2.microsoft.com/en-us/library/ms792675.aspx
106 HANDLE hSurfaceCurrentLeft
= NULL
;
107 HANDLE hSurfaceTargetLeft
= NULL
;
109 /* Auto flip off or on */
110 if (Flip
->dwFlags
& DDFLIP_STEREO
)
112 if ( (Flip
->lpSurfTargLeft
) &&
113 (Flip
->lpSurfCurrLeft
))
116 hSurfaceTargetLeft
= (HANDLE
) Flip
->lpSurfTargLeft
->hDDSurface
;
117 hSurfaceCurrentLeft
= (HANDLE
) Flip
->lpSurfCurrLeft
->hDDSurface
;
122 return NtGdiDdFlip( (HANDLE
) Flip
->lpSurfCurr
->hDDSurface
,
123 (HANDLE
) Flip
->lpSurfTarg
->hDDSurface
,
126 (PDD_FLIPDATA
) Flip
);
136 DdLock(LPDDHAL_LOCKDATA Lock
)
140 return NtGdiDdLock((HANDLE
)Lock
->lpDDSurface
->hDDSurface
,
142 (HANDLE
)Lock
->lpDDSurface
->hDC
);
152 DdUnlock(LPDDHAL_UNLOCKDATA Unlock
)
155 return NtGdiDdUnlock((HANDLE
)Unlock
->lpDDSurface
->hDDSurface
,
156 (PDD_UNLOCKDATA
)Unlock
);
166 DdGetBltStatus(LPDDHAL_GETBLTSTATUSDATA GetBltStatus
)
169 return NtGdiDdGetBltStatus((HANDLE
)GetBltStatus
->lpDDSurface
->hDDSurface
,
170 (PDD_GETBLTSTATUSDATA
)GetBltStatus
);
180 DdGetFlipStatus(LPDDHAL_GETFLIPSTATUSDATA GetFlipStatus
)
183 return NtGdiDdGetFlipStatus((HANDLE
)GetFlipStatus
->lpDDSurface
->hDDSurface
,
184 (PDD_GETFLIPSTATUSDATA
)GetFlipStatus
);
194 DdUpdateOverlay(LPDDHAL_UPDATEOVERLAYDATA UpdateOverlay
)
197 /* We have to handle this manually here */
198 if (UpdateOverlay
->dwFlags
& DDOVER_KEYDEST
)
200 /* Use the override */
201 UpdateOverlay
->dwFlags
&= ~DDOVER_KEYDEST
;
202 UpdateOverlay
->dwFlags
|= DDOVER_KEYDESTOVERRIDE
;
204 /* Set the overlay */
205 UpdateOverlay
->overlayFX
.dckDestColorkey
=
206 UpdateOverlay
->lpDDDestSurface
->ddckCKDestOverlay
;
208 if (UpdateOverlay
->dwFlags
& DDOVER_KEYSRC
)
210 /* Use the override */
211 UpdateOverlay
->dwFlags
&= ~DDOVER_KEYSRC
;
212 UpdateOverlay
->dwFlags
|= DDOVER_KEYSRCOVERRIDE
;
214 /* Set the overlay */
215 UpdateOverlay
->overlayFX
.dckSrcColorkey
=
216 UpdateOverlay
->lpDDSrcSurface
->ddckCKSrcOverlay
;
220 return NtGdiDdUpdateOverlay((HANDLE
)UpdateOverlay
->lpDDDestSurface
->hDDSurface
,
221 (HANDLE
)UpdateOverlay
->lpDDSrcSurface
->hDDSurface
,
222 (PDD_UPDATEOVERLAYDATA
)UpdateOverlay
);
228 * DdSetOverlayPosition
232 DdSetOverlayPosition(LPDDHAL_SETOVERLAYPOSITIONDATA SetOverlayPosition
)
235 return NtGdiDdSetOverlayPosition( (HANDLE
)SetOverlayPosition
->lpDDSrcSurface
->hDDSurface
,
236 (HANDLE
)SetOverlayPosition
->lpDDDestSurface
->hDDSurface
,
237 (PDD_SETOVERLAYPOSITIONDATA
) SetOverlayPosition
);
243 * DdWaitForVerticalBlank
247 DdWaitForVerticalBlank(LPDDHAL_WAITFORVERTICALBLANKDATA WaitForVerticalBlank
)
250 return NtGdiDdWaitForVerticalBlank(GetDdHandle(
251 WaitForVerticalBlank
->lpDD
->hDD
),
252 (PDD_WAITFORVERTICALBLANKDATA
)
253 WaitForVerticalBlank
);
263 DdCanCreateSurface(LPDDHAL_CANCREATESURFACEDATA CanCreateSurface
)
266 * Note : This functions are basic same, in win32k
267 * NtGdiDdCanCreateD3DBuffer and NtGdiDdCanCreateSurface are mergs
268 * toghter in win32k at end and retrurn same data, it is still sepreated
269 * at user mode but in kmode it is not.
273 return NtGdiDdCanCreateSurface(GetDdHandle(CanCreateSurface
->lpDD
->hDD
),
274 (PDD_CANCREATESURFACEDATA
)CanCreateSurface
);
284 DdCreateSurface(LPDDHAL_CREATESURFACEDATA pCreateSurface
)
286 DWORD Return
= DDHAL_DRIVER_NOTHANDLED
;
287 ULONG SurfaceCount
= pCreateSurface
->dwSCnt
;
288 DD_SURFACE_LOCAL DdSurfaceLocal
;
289 DD_SURFACE_MORE DdSurfaceMore
;
290 DD_SURFACE_GLOBAL DdSurfaceGlobal
;
292 HANDLE hPrevSurface
, hSurface
;
294 PDD_SURFACE_LOCAL pDdSurfaceLocal
= NULL
;
295 PDD_SURFACE_MORE pDdSurfaceMore
= NULL
;
296 PDD_SURFACE_GLOBAL pDdSurfaceGlobal
= NULL
;
298 PDD_SURFACE_LOCAL ptmpDdSurfaceLocal
= NULL
;
299 PDD_SURFACE_MORE ptmpDdSurfaceMore
= NULL
;
300 PDD_SURFACE_GLOBAL ptmpDdSurfaceGlobal
= NULL
;
301 PHANDLE phSurface
= NULL
, puhSurface
= NULL
;
303 LPDDSURFACEDESC pSurfaceDesc
= NULL
;
305 /* TODO : Speed optimze, most games/dx apps/program does not want 1 surface, they want lest 2
306 * so we need incress the stack so it can contain 2 surface instead of one, this will incress
307 * the speed of the apps when it trying alloc buffer. How to incress the surface stack space
308 * we need create a own struct for DD_SURFACE_LOCAL DdSurfaceLocal, DD_SURFACE_MORE DdSurfaceMore
309 * DD_SURFACE_GLOBAL DdSurfaceGlobal. HANDLE hPrevSurface, hSurface. like
310 * struct { DD_SURFACE_LOCAL DdSurfaceLocal1, DD_SURFACE_LOCAL DdSurfaceLocal2 }
311 * lest so it contain two surface. maybe 4. we need watch what is most common here before
312 * we create the size activate this IF when you start doing the optimze and please also
313 * take report from user which value they got here
318 sprintf ( buffer
, "Function %s : Optimze max to %d Surface ? (%s:%d)\n", __FUNCTION__
, (int)SurfaceCount
,__FILE__
,__LINE__
);
319 OutputDebugStringA(buffer
);
323 /* Check how many surfaces there are */
324 if (SurfaceCount
!= 1)
326 /* We got more that one surface so we need alloc memory for them */
327 pDdSurfaceLocal
= (PDD_SURFACE_LOCAL
) HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, (sizeof(DD_SURFACE_LOCAL
) * SurfaceCount
));
328 pDdSurfaceMore
= (PDD_SURFACE_MORE
) HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, (sizeof(DD_SURFACE_MORE
) * SurfaceCount
));
329 pDdSurfaceGlobal
= (PDD_SURFACE_GLOBAL
) HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, (sizeof(DD_SURFACE_GLOBAL
) * SurfaceCount
));
330 phSurface
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, (sizeof(HANDLE
) * SurfaceCount
));
331 puhSurface
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, (sizeof(HANDLE
) * SurfaceCount
));
333 /* check if we sueese alloc all memory we need */
334 if ((pDdSurfaceLocal
== NULL
) || (pDdSurfaceMore
== NULL
) || (pDdSurfaceGlobal
== NULL
) || (phSurface
== NULL
) || (puhSurface
== NULL
))
336 pCreateSurface
->ddRVal
= DDERR_OUTOFMEMORY
;
338 if ( pDdSurfaceLocal
!= NULL
)
340 HeapFree(GetProcessHeap(), 0, pDdSurfaceLocal
);
343 if ( pDdSurfaceMore
!= NULL
)
345 HeapFree(GetProcessHeap(), 0, pDdSurfaceMore
);
348 if ( phSurface
!= NULL
)
350 HeapFree(GetProcessHeap(), 0, phSurface
);
353 if ( puhSurface
!= NULL
)
355 HeapFree(GetProcessHeap(), 0, puhSurface
);
358 return DDHAL_DRIVER_HANDLED
;
363 /* We'll use what we have on the stack */
364 pDdSurfaceLocal
= &DdSurfaceLocal
;
365 pDdSurfaceMore
= &DdSurfaceMore
;
366 pDdSurfaceGlobal
= &DdSurfaceGlobal
;
367 phSurface
= &hPrevSurface
;
368 puhSurface
= &hSurface
;
370 /* Clear the structures */
371 RtlZeroMemory(&DdSurfaceLocal
, sizeof(DdSurfaceLocal
));
372 RtlZeroMemory(&DdSurfaceGlobal
, sizeof(DdSurfaceGlobal
));
373 RtlZeroMemory(&DdSurfaceMore
, sizeof(DdSurfaceMore
));
376 /* check if we got a surface or not */
379 /* Loop for each surface */
380 ptmpDdSurfaceGlobal
= pDdSurfaceGlobal
;
381 ptmpDdSurfaceLocal
= pDdSurfaceLocal
;
382 ptmpDdSurfaceMore
= pDdSurfaceMore
;
383 pSurfaceDesc
= pCreateSurface
->lpDDSurfaceDesc
;
385 for (i
= 0; i
< SurfaceCount
; i
++)
387 LPDDRAWI_DDRAWSURFACE_LCL lcl
= pCreateSurface
->lplpSList
[i
];
388 LPDDRAWI_DDRAWSURFACE_GBL gpl
= pCreateSurface
->lplpSList
[i
]->lpGbl
;
390 phSurface
[i
] = (HANDLE
)lcl
->hDDSurface
;
391 ptmpDdSurfaceLocal
->ddsCaps
.dwCaps
= lcl
->ddsCaps
.dwCaps
;
393 ptmpDdSurfaceLocal
->dwFlags
= (ptmpDdSurfaceLocal
->dwFlags
&
394 (0xB0000000 | DDRAWISURF_INMASTERSPRITELIST
|
395 DDRAWISURF_HELCB
| DDRAWISURF_FRONTBUFFER
|
396 DDRAWISURF_BACKBUFFER
| DDRAWISURF_INVALID
|
397 DDRAWISURF_DCIBUSY
| DDRAWISURF_DCILOCK
)) |
398 (lcl
->dwFlags
& DDRAWISURF_DRIVERMANAGED
);
400 ptmpDdSurfaceGlobal
->wWidth
= gpl
->wWidth
;
401 ptmpDdSurfaceGlobal
->wHeight
= gpl
->wHeight
;
402 ptmpDdSurfaceGlobal
->lPitch
= gpl
->lPitch
;
403 ptmpDdSurfaceGlobal
->fpVidMem
= gpl
->fpVidMem
;
404 ptmpDdSurfaceGlobal
->dwBlockSizeX
= gpl
->dwBlockSizeX
;
405 ptmpDdSurfaceGlobal
->dwBlockSizeY
= gpl
->dwBlockSizeY
;
407 if (lcl
->dwFlags
& DDRAWISURF_HASPIXELFORMAT
)
409 RtlCopyMemory( &ptmpDdSurfaceGlobal
->ddpfSurface
,
411 sizeof(DDPIXELFORMAT
));
413 ptmpDdSurfaceGlobal
->ddpfSurface
.dwSize
= sizeof(DDPIXELFORMAT
);
417 RtlCopyMemory( &ptmpDdSurfaceGlobal
->ddpfSurface
,
418 &gpl
->lpDD
->vmiData
.ddpfDisplay
,
419 sizeof(DDPIXELFORMAT
));
422 /* Note if lcl->lpSurfMore is NULL zero out
423 * ptmpDdSurfaceMore->ddsCapsEx.dwCaps2,
424 * dwCaps3, dwCaps4, ptmpDdSurfaceMore->dwSurfaceHandle
428 ptmpDdSurfaceMore
->ddsCapsEx
.dwCaps2
= lcl
->lpSurfMore
->ddsCapsEx
.dwCaps2
;
429 ptmpDdSurfaceMore
->ddsCapsEx
.dwCaps3
= lcl
->lpSurfMore
->ddsCapsEx
.dwCaps3
;
430 ptmpDdSurfaceMore
->ddsCapsEx
.dwCaps4
= lcl
->lpSurfMore
->ddsCapsEx
.dwCaps4
;
431 ptmpDdSurfaceMore
->dwSurfaceHandle
= lcl
->lpSurfMore
->dwSurfaceHandle
;
435 /* count to next SurfaceCount */
436 ptmpDdSurfaceGlobal
= (PDD_SURFACE_GLOBAL
) (((PBYTE
) ((ULONG_PTR
) ptmpDdSurfaceGlobal
)) + sizeof(DD_SURFACE_GLOBAL
));
437 ptmpDdSurfaceLocal
= (PDD_SURFACE_LOCAL
) (((PBYTE
) ((ULONG_PTR
) ptmpDdSurfaceLocal
)) + sizeof(DD_SURFACE_LOCAL
));
438 ptmpDdSurfaceMore
= (PDD_SURFACE_MORE
) (((PBYTE
) ((ULONG_PTR
) ptmpDdSurfaceMore
)) + sizeof(DD_SURFACE_MORE
));
442 /* Call win32k now */
443 pCreateSurface
->ddRVal
= DDERR_GENERIC
;
445 Return
= NtGdiDdCreateSurface(GetDdHandle(pCreateSurface
->lpDD
->hDD
),
451 (PDD_CREATESURFACEDATA
)pCreateSurface
,
454 if (SurfaceCount
== 0)
456 pCreateSurface
->ddRVal
= DDERR_GENERIC
;
460 ptmpDdSurfaceMore
= pDdSurfaceMore
;
461 ptmpDdSurfaceGlobal
= pDdSurfaceGlobal
;
462 ptmpDdSurfaceLocal
= pDdSurfaceLocal
;
464 for (i
=0;i
<SurfaceCount
;i
++)
466 LPDDRAWI_DDRAWSURFACE_LCL lcl
= pCreateSurface
->lplpSList
[i
];
467 LPDDRAWI_DDRAWSURFACE_GBL gpl
= pCreateSurface
->lplpSList
[i
]->lpGbl
;
469 gpl
->lPitch
= ptmpDdSurfaceGlobal
->lPitch
;
470 gpl
->fpVidMem
= ptmpDdSurfaceGlobal
->fpVidMem
;
471 gpl
->dwBlockSizeX
= ptmpDdSurfaceGlobal
->dwBlockSizeX
;
472 gpl
->dwBlockSizeY
= ptmpDdSurfaceGlobal
->dwBlockSizeY
;
474 if (lcl
->dwFlags
& DDRAWISURF_HASPIXELFORMAT
)
476 RtlCopyMemory( &gpl
->ddpfSurface
, &ptmpDdSurfaceGlobal
->ddpfSurface
, sizeof(DDPIXELFORMAT
));
479 if (pCreateSurface
->ddRVal
!= DD_OK
)
484 NtGdiDdDeleteSurfaceObject( (HANDLE
)lcl
->hDDSurface
);
491 lcl
->hDDSurface
= (ULONG_PTR
) puhSurface
[i
];
494 lcl
->ddsCaps
.dwCaps
= ptmpDdSurfaceLocal
->ddsCaps
.dwCaps
;
497 lcl
->lpSurfMore
->ddsCapsEx
.dwCaps2
= ptmpDdSurfaceMore
->ddsCapsEx
.dwCaps2
;
498 lcl
->lpSurfMore
->ddsCapsEx
.dwCaps3
= ptmpDdSurfaceMore
->ddsCapsEx
.dwCaps3
;
499 lcl
->lpSurfMore
->ddsCapsEx
.dwCaps4
= ptmpDdSurfaceMore
->ddsCapsEx
.dwCaps4
;
502 /* count to next SurfaceCount */
503 ptmpDdSurfaceGlobal
= (PDD_SURFACE_GLOBAL
) (((PBYTE
) ((ULONG_PTR
) ptmpDdSurfaceGlobal
)) + sizeof(DD_SURFACE_GLOBAL
));
504 ptmpDdSurfaceLocal
= (PDD_SURFACE_LOCAL
) (((PBYTE
) ((ULONG_PTR
) ptmpDdSurfaceLocal
)) + sizeof(DD_SURFACE_LOCAL
));
505 ptmpDdSurfaceMore
= (PDD_SURFACE_MORE
) (((PBYTE
) ((ULONG_PTR
) ptmpDdSurfaceMore
)) + sizeof(DD_SURFACE_MORE
));
509 /* Check if we have to free all our local allocations */
510 if (SurfaceCount
> 1)
512 if ( pDdSurfaceLocal
!= NULL
)
514 HeapFree(GetProcessHeap(), 0, pDdSurfaceLocal
);
517 if ( pDdSurfaceMore
!= NULL
)
519 HeapFree(GetProcessHeap(), 0, pDdSurfaceMore
);
522 if ( phSurface
!= NULL
)
524 HeapFree(GetProcessHeap(), 0, phSurface
);
527 if ( puhSurface
!= NULL
)
529 HeapFree(GetProcessHeap(), 0, puhSurface
);
544 DdSetColorKey(LPDDHAL_SETCOLORKEYDATA pSetColorKey
)
547 return NtGdiDdSetColorKey((HANDLE
)pSetColorKey
->lpDDSurface
->hDDSurface
,
548 (PDD_SETCOLORKEYDATA
)pSetColorKey
);
558 DdGetScanLine(LPDDHAL_GETSCANLINEDATA pGetScanLine
)
561 return NtGdiDdGetScanLine(GetDdHandle(pGetScanLine
->lpDD
->hDD
),
562 (PDD_GETSCANLINEDATA
)pGetScanLine
);
573 DvpCreateVideoPort(LPDDHAL_CREATEVPORTDATA pDvdCreatePort
)
575 pDvdCreatePort
->lpVideoPort
->hDDVideoPort
=
576 NtGdiDvpCreateVideoPort(GetDdHandle(pDvdCreatePort
->lpDD
->lpGbl
->hDD
),
577 (PDD_CREATEVPORTDATA
) pDvdCreatePort
);
589 DvpDestroyVideoPort(LPDDHAL_DESTROYVPORTDATA pDvdDestoryPort
)
591 return NtGdiDvpDestroyVideoPort(pDvdDestoryPort
->lpVideoPort
->hDDVideoPort
, (PDD_DESTROYVPORTDATA
)pDvdDestoryPort
);
601 DvpFlipVideoPort(LPDDHAL_FLIPVPORTDATA pDvdPortFlip
)
603 return NtGdiDvpFlipVideoPort(pDvdPortFlip
->lpVideoPort
->hDDVideoPort
,
604 (HANDLE
)pDvdPortFlip
->lpSurfCurr
->hDDSurface
,
605 (HANDLE
)pDvdPortFlip
->lpSurfTarg
->hDDSurface
,
606 (PDD_FLIPVPORTDATA
) pDvdPortFlip
);
612 * DvpGetVideoPortBandwidth
616 DvpGetVideoPortBandwidth(LPDDHAL_GETVPORTBANDWIDTHDATA pDvdPortBandWidth
)
618 return NtGdiDvpGetVideoPortBandwidth(pDvdPortBandWidth
->lpVideoPort
->hDDVideoPort
, (PDD_GETVPORTBANDWIDTHDATA
)pDvdPortBandWidth
);
628 DvpColorControl(LPDDHAL_VPORTCOLORDATA pDvdPortColorControl
)
630 return NtGdiDvpColorControl(pDvdPortColorControl
->lpVideoPort
->hDDVideoPort
, (PDD_VPORTCOLORDATA
) pDvdPortColorControl
);
636 * DvpGetVideoSignalStatus
640 DvpGetVideoSignalStatus(LPDDHAL_GETVPORTSIGNALDATA pDvdPortVideoSignalStatus
)
642 return NtGdiDvpGetVideoSignalStatus(pDvdPortVideoSignalStatus
->lpVideoPort
->hDDVideoPort
, (PDD_GETVPORTSIGNALDATA
) pDvdPortVideoSignalStatus
);
648 * DvpGetVideoPortFlipStatus
652 DvpGetVideoPortFlipStatus(LPDDHAL_GETVPORTFLIPSTATUSDATA pDvdPortVideoPortFlipStatus
)
654 return NtGdiDvpGetVideoPortFlipStatus(GetDdHandle(pDvdPortVideoPortFlipStatus
->lpDD
->lpGbl
->hDD
), (PDD_GETVPORTFLIPSTATUSDATA
) pDvdPortVideoPortFlipStatus
);
661 * DvpCanCreateVideoPort
665 DvpCanCreateVideoPort(LPDDHAL_CANCREATEVPORTDATA pDvdCanCreateVideoPort
)
667 return NtGdiDvpCanCreateVideoPort(GetDdHandle(pDvdCanCreateVideoPort
->lpDD
->lpGbl
->hDD
), (PDD_CANCREATEVPORTDATA
) pDvdCanCreateVideoPort
);
672 * DvpWaitForVideoPortSync
676 DvpWaitForVideoPortSync(LPDDHAL_WAITFORVPORTSYNCDATA pDvdWaitForVideoPortSync
)
678 return NtGdiDvpWaitForVideoPortSync(pDvdWaitForVideoPortSync
->lpVideoPort
->hDDVideoPort
, (PDD_WAITFORVPORTSYNCDATA
) pDvdWaitForVideoPortSync
);
688 DvpUpdateVideoPort(LPDDHAL_UPDATEVPORTDATA pDvdUpdateVideoPort
)
691 * Windows XP limit to max 10 handles of videoport surface and Vbi
692 * ReactOS doing same to keep compatible, if it is more that 10
693 * videoport surface or vbi the stack will be curpted in windows xp
694 * ReactOS safe guard againts that
698 HANDLE phSurfaceVideo
[10];
699 HANDLE phSurfaceVbi
[10];
701 if (pDvdUpdateVideoPort
->dwFlags
!= DDRAWI_VPORTSTOP
)
704 DWORD dwNumVBIAutoflip
;
706 /* Take copy of lplpDDSurface for the handle value will be modify in dxg */
707 dwNumAutoflip
= pDvdUpdateVideoPort
->dwNumAutoflip
;
708 if ((dwNumAutoflip
== 0) &&
709 (pDvdUpdateVideoPort
->lplpDDSurface
== 0))
714 if (dwNumAutoflip
!= 0)
716 if (dwNumAutoflip
>10)
720 memcpy(phSurfaceVideo
,pDvdUpdateVideoPort
->lplpDDSurface
,dwNumAutoflip
*sizeof(HANDLE
));
723 /* Take copy of lplpDDVBISurface for the handle value will be modify in dxg */
724 dwNumVBIAutoflip
= pDvdUpdateVideoPort
->dwNumVBIAutoflip
;
725 if ( (dwNumVBIAutoflip
== 0) &&
726 (pDvdUpdateVideoPort
->lplpDDVBISurface
== 0) )
731 if (dwNumVBIAutoflip
!= 0)
733 if (dwNumVBIAutoflip
>10)
735 dwNumVBIAutoflip
= 10;
737 memcpy(phSurfaceVbi
,pDvdUpdateVideoPort
->lplpDDVBISurface
,dwNumVBIAutoflip
*sizeof(HANDLE
));
742 return NtGdiDvpUpdateVideoPort(pDvdUpdateVideoPort
->lpVideoPort
->hDDVideoPort
,phSurfaceVideo
,phSurfaceVbi
, (PDD_UPDATEVPORTDATA
)pDvdUpdateVideoPort
);
748 * DvpWaitForVideoPortSync
752 DvpGetVideoPortField(LPDDHAL_FLIPVPORTDATA pDvdGetVideoPortField
)
754 return NtGdiDvpGetVideoPortField(pDvdGetVideoPortField
->lpVideoPort
->hDDVideoPort
, (PDD_GETVPORTFIELDDATA
)pDvdGetVideoPortField
);
760 * DvpWaitForVideoPortSync
764 DvpGetVideoPortInputFormats(LPDDHAL_GETVPORTINPUTFORMATDATA pDvdGetVideoPortInputFormat
)
766 return NtGdiDvpGetVideoPortInputFormats(pDvdGetVideoPortInputFormat
->lpVideoPort
->hDDVideoPort
, (PDD_GETVPORTINPUTFORMATDATA
) pDvdGetVideoPortInputFormat
);
772 * DvpGetVideoPortLine
776 DvpGetVideoPortLine(LPDDHAL_GETVPORTLINEDATA pDvdGetVideoPortLine
)
778 return NtGdiDvpGetVideoPortLine(pDvdGetVideoPortLine
->lpVideoPort
->hDDVideoPort
, (PDD_GETVPORTLINEDATA
)pDvdGetVideoPortLine
);
784 * DvpGetVideoPortOutputFormats
788 DvpGetVideoPortOutputFormats(LPDDHAL_GETVPORTLINEDATA pDvdGetVideoPortOutputFormat
)
790 return NtGdiDvpGetVideoPortLine(pDvdGetVideoPortOutputFormat
->lpVideoPort
->hDDVideoPort
, (PDD_GETVPORTLINEDATA
)pDvdGetVideoPortOutputFormat
);
796 * DvpGetVideoPortConnectInfo
800 DvpGetVideoPortConnectInfo(LPDDHAL_GETVPORTCONNECTDATA pDvdGetVideoPortInfo
)
802 return NtGdiDvpGetVideoPortConnectInfo( GetDdHandle( pDvdGetVideoPortInfo
->lpDD
->lpGbl
->hDD
) , (PDD_GETVPORTCONNECTDATA
) pDvdGetVideoPortInfo
);
808 * DdGetAvailDriverMemory
812 DdGetAvailDriverMemory(LPDDHAL_GETAVAILDRIVERMEMORYDATA pDdGetAvailDriverMemory
)
814 return NtGdiDdGetAvailDriverMemory(GetDdHandle( pDdGetAvailDriverMemory
->lpDD
->hDD
), (PDD_GETAVAILDRIVERMEMORYDATA
) pDdGetAvailDriverMemory
);
824 DdAlphaBlt(LPDDHAL_BLTDATA pDdAlphaBlt
)
826 HANDLE hDDSrcSurface
= 0;
828 if (pDdAlphaBlt
->lpDDSrcSurface
!= 0)
830 hDDSrcSurface
= (HANDLE
) pDdAlphaBlt
->lpDDSrcSurface
->hDDSurface
;
833 return NtGdiDdAlphaBlt((HANDLE
)pDdAlphaBlt
->lpDDDestSurface
->hDDSurface
, hDDSrcSurface
, (PDD_BLTDATA
)&pDdAlphaBlt
);
843 DdCreateSurfaceEx(LPDDHAL_CREATESURFACEEXDATA pDdCreateSurfaceEx
)
845 pDdCreateSurfaceEx
->ddRVal
= NtGdiDdCreateSurfaceEx( GetDdHandle(pDdCreateSurfaceEx
->lpDDLcl
->lpGbl
->hDD
),
846 (HANDLE
)pDdCreateSurfaceEx
->lpDDSLcl
->hDDSurface
,
847 pDdCreateSurfaceEx
->lpDDSLcl
->lpSurfMore
->dwSurfaceHandle
);
858 DdColorControl(LPDDHAL_COLORCONTROLDATA pDdColorControl
)
860 return NtGdiDdColorControl( (HANDLE
) pDdColorControl
->lpDDSurface
->hDDSurface
, (PDD_COLORCONTROLDATA
) &pDdColorControl
);
870 DdSetExclusiveMode(LPDDHAL_SETEXCLUSIVEMODEDATA pDdSetExclusiveMode
)
872 return NtGdiDdSetExclusiveMode( GetDdHandle(pDdSetExclusiveMode
->lpDD
->hDD
), (PDD_SETEXCLUSIVEMODEDATA
) &pDdSetExclusiveMode
);
882 DdFlipToGDISurface(LPDDHAL_FLIPTOGDISURFACEDATA pDdFlipToGDISurface
)
884 return NtGdiDdFlipToGDISurface( GetDdHandle(pDdFlipToGDISurface
->lpDD
->hDD
), (PDD_FLIPTOGDISURFACEDATA
) &pDdFlipToGDISurface
);
890 DdGetDriverInfo(LPDDHAL_GETDRIVERINFODATA pData
)
892 DDHAL_GETDRIVERINFODATA pDrvInfoData
;
893 DWORD retValue
= DDHAL_DRIVER_NOTHANDLED
;
896 /* FIXME add SEH around this functions */
898 RtlZeroMemory(&pDrvInfoData
, sizeof (DDHAL_GETDRIVERINFODATA
));
899 RtlCopyMemory(&pDrvInfoData
.guidInfo
, &pData
->guidInfo
, sizeof(GUID
));
901 hDD
= GetDdHandle(pData
->dwContext
);
903 pDrvInfoData
.dwSize
= sizeof (DDHAL_GETDRIVERINFODATA
);
904 pDrvInfoData
.ddRVal
= DDERR_GENERIC
;
905 pDrvInfoData
.dwContext
= (ULONG_PTR
)hDD
;
908 /* Videoport Callbacks check and setup for DirectX/ ReactX */
909 if (IsEqualGUID(&pData
->guidInfo
, &GUID_VideoPortCallbacks
))
911 DDHAL_DDVIDEOPORTCALLBACKS pDvdPort
;
912 DDHAL_DDVIDEOPORTCALLBACKS
* pUserDvdPort
= (DDHAL_DDVIDEOPORTCALLBACKS
*)pData
->lpvData
;
914 /* Clear internal out buffer and set it up*/
915 RtlZeroMemory(&pDvdPort
, DDVIDEOPORTCALLBACKSSIZE
);
916 pDvdPort
.dwSize
= DDVIDEOPORTCALLBACKSSIZE
;
918 /* set up internal buffer */
919 pDrvInfoData
.lpvData
= (PVOID
)&pDvdPort
;
920 pDrvInfoData
.dwExpectedSize
= DDVIDEOPORTCALLBACKSSIZE
;
923 retValue
= NtGdiDdGetDriverInfo(hDD
, (PDD_GETDRIVERINFODATA
)&pDrvInfoData
);
925 /* Setup user out buffer and convert kmode callbacks to user mode */
926 pUserDvdPort
->dwSize
= DDVIDEOPORTCALLBACKSSIZE
;
927 pUserDvdPort
->dwFlags
= pDrvInfoData
.dwFlags
= 0;
929 pUserDvdPort
->dwFlags
= (pDrvInfoData
.dwFlags
& ~(DDHAL_VPORT32_CREATEVIDEOPORT
| DDHAL_VPORT32_FLIP
|
930 DDHAL_VPORT32_DESTROY
| DDHAL_VPORT32_UPDATE
| DDHAL_VPORT32_WAITFORSYNC
)) |
931 (DDHAL_VPORT32_CREATEVIDEOPORT
| DDHAL_VPORT32_FLIP
|
932 DDHAL_VPORT32_DESTROY
| DDHAL_VPORT32_UPDATE
);
934 pData
->dwActualSize
= DDVIDEOPORTCALLBACKSSIZE
;
935 pUserDvdPort
->CreateVideoPort
= (LPDDHALVPORTCB_CREATEVIDEOPORT
) DvpCreateVideoPort
;
936 pUserDvdPort
->FlipVideoPort
= (LPDDHALVPORTCB_FLIP
) DvpFlipVideoPort
;
937 pUserDvdPort
->DestroyVideoPort
= (LPDDHALVPORTCB_DESTROYVPORT
) DvpDestroyVideoPort
;
938 pUserDvdPort
->UpdateVideoPort
= (LPDDHALVPORTCB_UPDATE
) DvpUpdateVideoPort
;
940 if (pDvdPort
.CanCreateVideoPort
)
942 pUserDvdPort
->CanCreateVideoPort
= (LPDDHALVPORTCB_CANCREATEVIDEOPORT
) DvpCanCreateVideoPort
;
945 if (pDvdPort
.GetVideoPortBandwidth
)
947 pUserDvdPort
->GetVideoPortBandwidth
= (LPDDHALVPORTCB_GETBANDWIDTH
) DvpGetVideoPortBandwidth
;
950 if (pDvdPort
.GetVideoPortInputFormats
)
952 pUserDvdPort
->GetVideoPortInputFormats
= (LPDDHALVPORTCB_GETINPUTFORMATS
) DvpGetVideoPortInputFormats
;
955 if (pDvdPort
.GetVideoPortOutputFormats
)
957 pUserDvdPort
->GetVideoPortOutputFormats
= (LPDDHALVPORTCB_GETOUTPUTFORMATS
) DvpGetVideoPortOutputFormats
;
960 if (pDvdPort
.GetVideoPortField
)
962 pUserDvdPort
->GetVideoPortField
= (LPDDHALVPORTCB_GETFIELD
) DvpGetVideoPortField
;
965 if (pDvdPort
.GetVideoPortLine
)
967 pUserDvdPort
->GetVideoPortLine
= (LPDDHALVPORTCB_GETLINE
) DvpGetVideoPortLine
;
970 if (pDvdPort
.GetVideoPortConnectInfo
)
972 pUserDvdPort
->GetVideoPortConnectInfo
= (LPDDHALVPORTCB_GETVPORTCONNECT
) DvpGetVideoPortConnectInfo
;
975 if (pDvdPort
.GetVideoPortFlipStatus
)
977 pUserDvdPort
->GetVideoPortFlipStatus
= (LPDDHALVPORTCB_GETFLIPSTATUS
) DvpGetVideoPortFlipStatus
;
980 if (pDvdPort
.WaitForVideoPortSync
)
982 pUserDvdPort
->WaitForVideoPortSync
= (LPDDHALVPORTCB_WAITFORSYNC
) DvpWaitForVideoPortSync
;
985 if (pDvdPort
.GetVideoSignalStatus
)
987 pUserDvdPort
->GetVideoSignalStatus
= (LPDDHALVPORTCB_GETSIGNALSTATUS
) DvpGetVideoSignalStatus
;
990 if (pDvdPort
.ColorControl
)
992 pUserDvdPort
->ColorControl
= (LPDDHALVPORTCB_COLORCONTROL
) DvpColorControl
;
995 /* Windows XP never repot back the true return value,
996 * it only report back if we have a driver or not
997 * ReactOS keep this behoir to be compatible with
1000 pData
->ddRVal
= retValue
;
1003 /* Color Control Callbacks check and setup for DirectX/ ReactX */
1004 if (IsEqualGUID(&pData
->guidInfo
, &GUID_ColorControlCallbacks
))
1006 DDHAL_DDCOLORCONTROLCALLBACKS pColorControl
;
1007 DDHAL_DDCOLORCONTROLCALLBACKS
* pUserColorControl
= (DDHAL_DDCOLORCONTROLCALLBACKS
*)pData
->lpvData
;
1009 /* Clear internal out buffer and set it up*/
1010 RtlZeroMemory(&pColorControl
, DDCOLORCONTROLCALLBACKSSIZE
);
1011 pColorControl
.dwSize
= DDCOLORCONTROLCALLBACKSSIZE
;
1013 /* set up internal buffer */
1014 pDrvInfoData
.lpvData
= (PVOID
)&pColorControl
;
1015 pDrvInfoData
.dwExpectedSize
= DDCOLORCONTROLCALLBACKSSIZE
;
1018 retValue
= NtGdiDdGetDriverInfo(hDD
, (PDD_GETDRIVERINFODATA
)&pDrvInfoData
);
1020 pData
->dwActualSize
= DDCOLORCONTROLCALLBACKSSIZE
;
1021 pData
->dwFlags
= pDrvInfoData
.dwFlags
;
1023 pUserColorControl
->dwSize
= DDCOLORCONTROLCALLBACKSSIZE
;
1024 pUserColorControl
->dwFlags
= pUserColorControl
->dwFlags
;
1026 if (pColorControl
.ColorControl
!= NULL
)
1028 pUserColorControl
->ColorControl
= (LPDDHALCOLORCB_COLORCONTROL
) DdColorControl
;
1031 /* Windows XP never repot back the true return value,
1032 * it only report back if we have a driver or not
1033 * ReactOS keep this behoir to be compatible with
1036 pData
->ddRVal
= retValue
;
1039 /* Misc Callbacks check and setup for DirectX/ ReactX */
1040 else if (IsEqualGUID(&pData
->guidInfo
, &GUID_MiscellaneousCallbacks
))
1042 DDHAL_DDMISCELLANEOUSCALLBACKS pMisc
;
1043 DDHAL_DDMISCELLANEOUSCALLBACKS
* pUserMisc
= (DDHAL_DDMISCELLANEOUSCALLBACKS
*)pData
->lpvData
;
1045 /* Clear internal out buffer and set it up*/
1046 RtlZeroMemory(&pMisc
, DDMISCELLANEOUSCALLBACKSSIZE
);
1047 pMisc
.dwSize
= DDMISCELLANEOUSCALLBACKSSIZE
;
1049 /* set up internal buffer */
1050 pDrvInfoData
.lpvData
= (PVOID
)&pMisc
;
1051 pDrvInfoData
.dwExpectedSize
= DDMISCELLANEOUSCALLBACKSSIZE
;
1054 retValue
= NtGdiDdGetDriverInfo(hDD
, (PDD_GETDRIVERINFODATA
)&pDrvInfoData
);
1056 pData
->dwActualSize
= DDMISCELLANEOUSCALLBACKSSIZE
;
1058 /* Only one callbacks are supported */
1059 pUserMisc
->dwFlags
= pMisc
.dwFlags
& DDHAL_MISCCB32_GETAVAILDRIVERMEMORY
;
1060 pUserMisc
->GetAvailDriverMemory
= (LPDDHAL_GETAVAILDRIVERMEMORY
) DdGetAvailDriverMemory
;
1062 /* This callbacks are only for win9x and theirfor it is not longer use in NT or ReactOS
1063 * pUserMisc->UpdateNonLocalHeap;
1064 * pUserMisc->GetHeapAlignment;
1065 * pUserMisc->GetSysmemBltStatus; */
1067 /* Windows XP never repot back the true return value,
1068 * it only report back if we have a driver or not
1069 * ReactOS keep this behoir to be compatible with
1072 pData
->ddRVal
= retValue
;
1075 /* Misc 2 Callbacks check and setup for DirectX/ ReactX */
1076 else if (IsEqualGUID(&pData
->guidInfo
, &GUID_Miscellaneous2Callbacks
))
1078 DDHAL_DDMISCELLANEOUS2CALLBACKS pMisc
;
1079 DDHAL_DDMISCELLANEOUS2CALLBACKS
* pUserMisc
= (DDHAL_DDMISCELLANEOUS2CALLBACKS
*)pData
->lpvData
;
1081 /* Clear internal out buffer and set it up*/
1082 RtlZeroMemory(&pMisc
, DDMISCELLANEOUS2CALLBACKSSIZE
);
1083 pMisc
.dwSize
= DDMISCELLANEOUS2CALLBACKSSIZE
;
1085 /* set up internal buffer */
1086 pDrvInfoData
.lpvData
= (PVOID
)&pMisc
;
1087 pDrvInfoData
.dwExpectedSize
= DDMISCELLANEOUS2CALLBACKSSIZE
;
1090 retValue
= NtGdiDdGetDriverInfo(hDD
, (PDD_GETDRIVERINFODATA
)&pDrvInfoData
);
1092 pData
->dwActualSize
= DDMISCELLANEOUS2CALLBACKSSIZE
;
1094 pUserMisc
->dwFlags
= pMisc
.dwFlags
;
1096 /* This functions are not documneted in MSDN for this struct, here is directx/reactx alpha blend */
1097 if ( pMisc
.Reserved
)
1099 pUserMisc
->Reserved
= (LPVOID
) DdAlphaBlt
;
1102 if ( pMisc
.CreateSurfaceEx
)
1104 pUserMisc
->CreateSurfaceEx
= (LPDDHAL_CREATESURFACEEX
) DdCreateSurfaceEx
;
1107 if ( pMisc
.GetDriverState
)
1109 pUserMisc
->GetDriverState
= (LPDDHAL_GETDRIVERSTATE
) NtGdiDdGetDriverState
;
1112 /* NOTE : pUserMisc->DestroyDDLocal is outdated and are not beign tuch */
1114 /* Windows XP never repot back the true return value,
1115 * it only report back if we have a driver or not
1116 * ReactOS keep this behoir to be compatible with
1119 pData
->ddRVal
= retValue
;
1122 /* NT Callbacks check and setup for DirectX/ ReactX */
1123 else if (IsEqualGUID(&pData
->guidInfo
, &GUID_NTCallbacks
))
1125 /* MS does not have DHAL_* version of this callbacks
1126 * so we are force using PDD_* callbacks here
1128 DD_NTCALLBACKS pNtKernel
;
1129 PDD_NTCALLBACKS pUserNtKernel
= (PDD_NTCALLBACKS
)pData
->lpvData
;
1131 /* Clear internal out buffer and set it up*/
1132 RtlZeroMemory(&pNtKernel
, sizeof(DD_NTCALLBACKS
));
1133 pNtKernel
.dwSize
= sizeof(DD_NTCALLBACKS
);
1135 /* set up internal buffer */
1136 pDrvInfoData
.lpvData
= (PVOID
)&pNtKernel
;
1137 pDrvInfoData
.dwExpectedSize
= sizeof(DD_NTCALLBACKS
) ;
1140 retValue
= NtGdiDdGetDriverInfo(hDD
, (PDD_GETDRIVERINFODATA
)&pDrvInfoData
);
1142 pData
->dwActualSize
= sizeof(DD_NTCALLBACKS
);
1144 pUserNtKernel
->dwSize
= sizeof(DD_NTCALLBACKS
);
1145 pUserNtKernel
->dwFlags
= pNtKernel
.dwFlags
;
1146 pUserNtKernel
->FreeDriverMemory
= 0;
1148 if (pNtKernel
.SetExclusiveMode
)
1150 pUserNtKernel
->SetExclusiveMode
= (PDD_SETEXCLUSIVEMODE
) DdSetExclusiveMode
;
1153 if (pNtKernel
.FlipToGDISurface
)
1155 pUserNtKernel
->FlipToGDISurface
= (PDD_FLIPTOGDISURFACE
) DdFlipToGDISurface
;
1158 /* Windows XP never repot back the true return value,
1159 * it only report back if we have a driver or not
1160 * ReactOS keep this behoir to be compatible with
1163 pData
->ddRVal
= retValue
;
1166 /* D3D Callbacks version 2 check and setup for DirectX/ ReactX */
1167 else if (IsEqualGUID(&pData
->guidInfo
, &GUID_D3DCallbacks2
))
1169 // FIXME GUID_D3DCallbacks2
1172 /* D3D Callbacks version 3 check and setup for DirectX/ ReactX */
1173 else if (IsEqualGUID(&pData
->guidInfo
, &GUID_D3DCallbacks3
))
1175 // FIXME GUID_D3DCallbacks3
1178 /* D3DParseUnknownCommand Callbacks check and setup for DirectX/ ReactX */
1179 else if (IsEqualGUID(&pData
->guidInfo
, &GUID_D3DParseUnknownCommandCallback
))
1181 // FIXME GUID_D3DParseUnknownCommandCallback
1184 /* MotionComp Callbacks check and setup for DirectX/ ReactX */
1185 else if (IsEqualGUID(&pData
->guidInfo
, &GUID_MotionCompCallbacks
))
1187 // FIXME GUID_MotionCompCallbacks
1190 /* FIXME VPE2 Callbacks check and setup for DirectX/ ReactX */
1191 //else if (IsEqualGUID(&pData->guidInfo, &GUID_VPE2Callbacks))
1193 // FIXME GUID_VPE2Callbacks
1197 /* set up internal buffer */
1198 pDrvInfoData
.dwExpectedSize
= pData
->dwExpectedSize
;
1199 pDrvInfoData
.lpvData
= pData
->lpvData
;
1201 /* We do not cover all callbacks for user mode, they are only cover by kmode */
1202 retValue
= NtGdiDdGetDriverInfo(hDD
, (PDD_GETDRIVERINFODATA
)&pDrvInfoData
);
1204 /* Setup return data */
1205 pData
->dwActualSize
= pDrvInfoData
.dwActualSize
;
1206 pData
->lpvData
= pDrvInfoData
.lpvData
;
1207 /* Windows XP never repot back the true return value,
1208 * it only report back if we have a driver or not
1209 * ReactOS keep this behoir to be compatible with
1212 pData
->ddRVal
= retValue
;
1226 D3dContextCreate(LPD3DHAL_CONTEXTCREATEDATA pdcci
)
1228 HANDLE hSurfZ
= NULL
;
1230 if (pdcci
->lpDDSZLcl
)
1232 hSurfZ
= (HANDLE
)pdcci
->lpDDSZLcl
->hDDSurface
;
1235 return NtGdiD3dContextCreate(GetDdHandle(pdcci
->lpDDLcl
->hDD
),
1236 (HANDLE
)pdcci
->lpDDSLcl
->hDDSurface
,
1238 (D3DNTHAL_CONTEXTCREATEI
*)pdcci
);
1244 * DdCanCreateD3DBuffer
1248 DdCanCreateD3DBuffer(LPDDHAL_CANCREATESURFACEDATA CanCreateD3DBuffer
)
1251 * Note : This functions are basic same, in win32k
1252 * NtGdiDdCanCreateD3DBuffer and NtGdiDdCanCreateSurface are mergs
1253 * toghter in win32k at end and retrurn same data, it is still sepreated
1254 * at user mode but in kmode it is not.
1258 return NtGdiDdCanCreateD3DBuffer(GetDdHandle(CanCreateD3DBuffer
->lpDD
->hDD
),
1259 (PDD_CANCREATESURFACEDATA
)CanCreateD3DBuffer
);
1270 DdCreateD3DBuffer(LPDDHAL_CREATESURFACEDATA pCreateSurface
)
1272 HANDLE puhSurface
= 0;
1273 DDRAWI_DDRAWSURFACE_GBL
*pSurfGBL
;
1274 DDRAWI_DDRAWSURFACE_LCL
*pSurfLcl
;
1275 DD_SURFACE_GLOBAL puSurfaceGlobalData
;
1276 DD_SURFACE_MORE puSurfaceMoreData
;
1277 DD_SURFACE_LOCAL puSurfaceLocalData
;
1280 /* Zero all local memory pointer */
1281 RtlZeroMemory(&puSurfaceGlobalData
, sizeof(DD_SURFACE_GLOBAL
) );
1282 RtlZeroMemory(&puSurfaceMoreData
, sizeof(DD_SURFACE_MORE
) ) ;
1283 RtlZeroMemory(&puSurfaceLocalData
, sizeof(DD_SURFACE_LOCAL
) );
1285 pCreateSurface
->dwSCnt
= 1;
1286 pSurfLcl
= pCreateSurface
->lplpSList
[0];
1287 pSurfGBL
= pSurfLcl
->lpGbl
;
1289 /* Convert DDRAWI_DDRAWSURFACE_GBL to DD_SURFACE_GLOBAL */
1290 puSurfaceGlobalData
.wWidth
= pSurfGBL
->wWidth
;
1291 puSurfaceGlobalData
.wHeight
= pSurfGBL
->wHeight
;
1292 puSurfaceGlobalData
.dwLinearSize
= pSurfGBL
->dwLinearSize
;
1293 puSurfaceGlobalData
.fpVidMem
= pSurfGBL
->fpVidMem
;
1294 puSurfaceGlobalData
.dwBlockSizeX
= pSurfGBL
->dwBlockSizeX
;
1295 puSurfaceGlobalData
.dwBlockSizeY
= pSurfGBL
->dwBlockSizeY
;
1297 /* Convert DDRAWI_DDRAWSURFACE_MORE to DD_SURFACE_MORE */
1298 puSurfaceMoreData
.dwSurfaceHandle
= pSurfLcl
->lpSurfMore
->dwSurfaceHandle
;
1299 puSurfaceMoreData
.ddsCapsEx
.dwCaps2
= pSurfLcl
->lpSurfMore
->ddsCapsEx
.dwCaps2
;
1300 puSurfaceMoreData
.ddsCapsEx
.dwCaps3
= pSurfLcl
->lpSurfMore
->ddsCapsEx
.dwCaps3
;
1301 puSurfaceMoreData
.ddsCapsEx
.dwCaps4
= pSurfLcl
->lpSurfMore
->ddsCapsEx
.dwCaps4
;
1303 /* Convert DDRAWI_DDRAWSURFACE_LCL to DD_SURFACE_LOCAL */
1304 puSurfaceLocalData
.dwFlags
= pSurfLcl
->dwFlags
;
1305 puSurfaceLocalData
.ddsCaps
.dwCaps
= pSurfLcl
->ddsCaps
.dwCaps
;
1308 retValue
= NtGdiDdCreateD3DBuffer( GetDdHandle(pCreateSurface
->lpDD
->hDD
),
1309 (HANDLE
*)&pSurfLcl
->hDDSurface
,
1310 pCreateSurface
->lpDDSurfaceDesc
,
1311 &puSurfaceGlobalData
,
1312 &puSurfaceLocalData
,
1314 (DD_CREATESURFACEDATA
*) pCreateSurface
,
1317 /* Setup surface handle if we got one back */
1318 if ( puhSurface
!= NULL
)
1320 pCreateSurface
->lplpSList
[0]->hDDSurface
= (ULONG_PTR
)puhSurface
;
1323 /* Convert DD_SURFACE_GLOBAL to DDRAWI_DDRAWSURFACE_GBL */
1324 pSurfGBL
->dwLinearSize
= puSurfaceGlobalData
.dwLinearSize
;
1325 pSurfGBL
->fpVidMem
= puSurfaceGlobalData
.fpVidMem
;
1326 pSurfGBL
->dwBlockSizeX
= puSurfaceGlobalData
.dwBlockSizeX
;
1327 pSurfGBL
->dwBlockSizeY
= puSurfaceGlobalData
.dwBlockSizeY
;
1335 * DdDestroyD3DBuffer
1339 DdDestroyD3DBuffer(LPDDHAL_DESTROYSURFACEDATA pDestroySurface
)
1342 if ( pDestroySurface
->lpDDSurface
->hDDSurface
)
1345 retValue
= NtGdiDdDestroyD3DBuffer((HANDLE
)pDestroySurface
->lpDDSurface
->hDDSurface
);
1358 DdLockD3D(LPDDHAL_LOCKDATA Lock
)
1362 return NtGdiDdLockD3D((HANDLE
)Lock
->lpDDSurface
->hDDSurface
, (PDD_LOCKDATA
)Lock
);
1372 DdUnlockD3D(LPDDHAL_UNLOCKDATA Unlock
)
1375 return NtGdiDdUnlock((HANDLE
)Unlock
->lpDDSurface
->hDDSurface
,
1376 (PDD_UNLOCKDATA
)Unlock
);
1380 /* PRIVATE FUNCTIONS *********************************************************/
1384 bDDCreateSurface(LPDDRAWI_DDRAWSURFACE_LCL pSurface
,
1387 DD_SURFACE_LOCAL SurfaceLocal
;
1388 DD_SURFACE_GLOBAL SurfaceGlobal
;
1389 DD_SURFACE_MORE SurfaceMore
;
1392 RtlZeroMemory(&SurfaceLocal
, sizeof(DD_SURFACE_LOCAL
));
1393 RtlZeroMemory(&SurfaceGlobal
, sizeof(DD_SURFACE_GLOBAL
));
1394 RtlZeroMemory(&SurfaceMore
, sizeof(DD_SURFACE_MORE
));
1396 /* Set up SurfaceLocal struct */
1397 SurfaceLocal
.ddsCaps
.dwCaps
= pSurface
->ddsCaps
.dwCaps
;
1398 SurfaceLocal
.dwFlags
= pSurface
->dwFlags
;
1400 /* Set up SurfaceMore struct */
1401 RtlMoveMemory(&SurfaceMore
.ddsCapsEx
,
1402 &pSurface
->ddckCKDestBlt
,
1404 SurfaceMore
.dwSurfaceHandle
= (DWORD
)pSurface
->dbnOverlayNode
.object_int
->lpVtbl
;
1406 /* Set up SurfaceGlobal struct */
1407 SurfaceGlobal
.fpVidMem
= pSurface
->lpGbl
->fpVidMem
;
1408 SurfaceGlobal
.dwLinearSize
= pSurface
->lpGbl
->dwLinearSize
;
1409 SurfaceGlobal
.wHeight
= pSurface
->lpGbl
->wHeight
;
1410 SurfaceGlobal
.wWidth
= pSurface
->lpGbl
->wWidth
;
1412 /* Check if we have a pixel format */
1413 if (pSurface
->dwFlags
& DDSD_PIXELFORMAT
)
1415 /* Use global one */
1416 SurfaceGlobal
.ddpfSurface
= pSurface
->lpGbl
->lpDD
->vmiData
.ddpfDisplay
;
1417 SurfaceGlobal
.ddpfSurface
.dwSize
= sizeof(DDPIXELFORMAT
);
1422 SurfaceGlobal
.ddpfSurface
= pSurface
->lpGbl
->lpDD
->vmiData
.ddpfDisplay
;
1425 /* Create the object */
1426 pSurface
->hDDSurface
= (DWORD
)NtGdiDdCreateSurfaceObject(GetDdHandle(pSurface
->lpGbl
->lpDD
->hDD
),
1427 (HANDLE
)pSurface
->hDDSurface
,
1434 if (pSurface
->hDDSurface
) return TRUE
;
1438 /* PUBLIC FUNCTIONS **********************************************************/
1447 DdCreateDirectDrawObject(LPDDRAWI_DIRECTDRAW_GBL pDirectDrawGlobal
,
1450 BOOL Return
= FALSE
;
1452 /* Check if the global hDC (hdc == 0) is being used */
1455 /* We'll only allow this if the global object doesn't exist yet */
1459 if ((hdc
= CreateDCW(L
"Display", NULL
, NULL
, NULL
)))
1461 /* Create the DDraw Object */
1462 ghDirectDraw
= NtGdiDdCreateDirectDrawObject(hdc
);
1469 /* If we created the object, or had one ...*/
1472 /* Increase count and set success */
1477 /* Zero the handle */
1478 pDirectDrawGlobal
->hDD
= 0;
1482 /* Using the per-process object, so create it */
1483 pDirectDrawGlobal
->hDD
= (ULONG_PTR
)NtGdiDdCreateDirectDrawObject(hdc
);
1485 /* Set the return value */
1486 Return
= pDirectDrawGlobal
->hDD
? TRUE
: FALSE
;
1489 /* Return to caller */
1500 DdQueryDirectDrawObject(LPDDRAWI_DIRECTDRAW_GBL pDirectDrawGlobal
,
1501 LPDDHALINFO pHalInfo
,
1502 LPDDHAL_DDCALLBACKS pDDCallbacks
,
1503 LPDDHAL_DDSURFACECALLBACKS pDDSurfaceCallbacks
,
1504 LPDDHAL_DDPALETTECALLBACKS pDDPaletteCallbacks
,
1505 LPD3DHAL_CALLBACKS pD3dCallbacks
,
1506 LPD3DHAL_GLOBALDRIVERDATA pD3dDriverData
,
1507 LPDDHAL_DDEXEBUFCALLBACKS pD3dBufferCallbacks
,
1508 LPDDSURFACEDESC pD3dTextureFormats
,
1512 PVIDEOMEMORY VidMemList
= NULL
;
1514 D3DNTHAL_CALLBACKS D3dCallbacks
;
1515 D3DNTHAL_GLOBALDRIVERDATA D3dDriverData
;
1516 DD_D3DBUFCALLBACKS D3dBufferCallbacks
;
1517 DWORD CallbackFlags
[3];
1518 DWORD dwNumHeaps
=0, FourCCs
=0;
1522 /* Clear the structures */
1523 RtlZeroMemory(&HalInfo
, sizeof(DD_HALINFO
));
1524 RtlZeroMemory(&D3dCallbacks
, sizeof(D3DNTHAL_CALLBACKS
));
1525 RtlZeroMemory(&D3dDriverData
, sizeof(D3DNTHAL_GLOBALDRIVERDATA
));
1526 RtlZeroMemory(&D3dBufferCallbacks
, sizeof(DD_D3DBUFCALLBACKS
));
1527 RtlZeroMemory(CallbackFlags
, sizeof(DWORD
)*3);
1529 /* Note : XP always alloc 24*sizeof(VIDEOMEMORY) of pvmlist so we change it to it */
1530 if ( (pvmList
!= NULL
) &&
1531 (pHalInfo
->vmiData
.dwNumHeaps
!= 0) )
1533 VidMemList
= (PVIDEOMEMORY
) HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, (sizeof(VIDEOMEMORY
) * 24 ) * pHalInfo
->vmiData
.dwNumHeaps
);
1538 if (!NtGdiDdQueryDirectDrawObject(GetDdHandle(pDirectDrawGlobal
->hDD
),
1543 &D3dBufferCallbacks
,
1550 /* We failed, free the memory and return */
1555 /* Clear the incoming pointer */
1556 RtlZeroMemory(pHalInfo
, sizeof(DDHALINFO
));
1558 /* Convert all the data */
1559 pHalInfo
->dwSize
= sizeof(DDHALINFO
);
1560 pHalInfo
->lpDDCallbacks
= pDDCallbacks
;
1561 pHalInfo
->lpDDSurfaceCallbacks
= pDDSurfaceCallbacks
;
1562 pHalInfo
->lpDDPaletteCallbacks
= pDDPaletteCallbacks
;
1564 /* Check for NT5+ D3D Data */
1565 if ( (D3dCallbacks
.dwSize
!= 0) &&
1566 (D3dDriverData
.dwSize
!= 0) )
1568 /* Write these down */
1569 pHalInfo
->lpD3DGlobalDriverData
= (ULONG_PTR
)pD3dDriverData
;
1570 pHalInfo
->lpD3DHALCallbacks
= (ULONG_PTR
)pD3dCallbacks
;
1572 /* Check for Buffer Callbacks */
1573 if (D3dBufferCallbacks
.dwSize
)
1575 /* Write this one too */
1576 pHalInfo
->lpDDExeBufCallbacks
= pD3dBufferCallbacks
;
1580 /* Continue converting the rest */
1581 pHalInfo
->vmiData
.dwFlags
= HalInfo
.vmiData
.dwFlags
;
1582 pHalInfo
->vmiData
.dwDisplayWidth
= HalInfo
.vmiData
.dwDisplayWidth
;
1583 pHalInfo
->vmiData
.dwDisplayHeight
= HalInfo
.vmiData
.dwDisplayHeight
;
1584 pHalInfo
->vmiData
.lDisplayPitch
= HalInfo
.vmiData
.lDisplayPitch
;
1585 pHalInfo
->vmiData
.fpPrimary
= 0;
1587 RtlCopyMemory( &pHalInfo
->vmiData
.ddpfDisplay
,
1588 &HalInfo
.vmiData
.ddpfDisplay
,
1589 sizeof(DDPIXELFORMAT
));
1591 pHalInfo
->vmiData
.dwOffscreenAlign
= HalInfo
.vmiData
.dwOffscreenAlign
;
1592 pHalInfo
->vmiData
.dwOverlayAlign
= HalInfo
.vmiData
.dwOverlayAlign
;
1593 pHalInfo
->vmiData
.dwTextureAlign
= HalInfo
.vmiData
.dwTextureAlign
;
1594 pHalInfo
->vmiData
.dwZBufferAlign
= HalInfo
.vmiData
.dwZBufferAlign
;
1595 pHalInfo
->vmiData
.dwAlphaAlign
= HalInfo
.vmiData
.dwAlphaAlign
;
1597 pHalInfo
->vmiData
.dwNumHeaps
= dwNumHeaps
;
1598 pHalInfo
->vmiData
.pvmList
= pvmList
;
1600 RtlCopyMemory( &pHalInfo
->ddCaps
,
1602 sizeof(DDCORECAPS
));
1604 pHalInfo
->ddCaps
.dwNumFourCCCodes
= FourCCs
;
1605 pHalInfo
->lpdwFourCC
= pdwFourCC
;
1607 /* always force rope 0x1000 for hal it mean only source copy is supported */
1608 pHalInfo
->ddCaps
.dwRops
[6] = 0x1000;
1610 /* Set the HAL flags what ReactX got from the driver
1611 * Windows XP force setting DDHALINFO_GETDRIVERINFOSET if the driver does not set it
1612 * and ReactX doing same to keep compatible with drivers, but the driver are
1613 * force support DdGetDriverInfo acoriding MSDN but it seam some driver do not set
1614 * this flag even it is being supported. that is mean. It is small hack to keep
1615 * bad driver working, that trust this is always being setting by it self at end
1617 pHalInfo
->dwFlags
= (HalInfo
.dwFlags
& ~DDHALINFO_GETDRIVERINFOSET
) | DDHALINFO_GETDRIVERINFOSET
;
1618 pHalInfo
->GetDriverInfo
= (LPDDHAL_GETDRIVERINFO
) DdGetDriverInfo
;
1620 /* Now check if we got any DD callbacks */
1623 /* Zero the structure */
1624 RtlZeroMemory(pDDCallbacks
, sizeof(DDHAL_DDCALLBACKS
));
1625 pDDCallbacks
->dwSize
= sizeof(DDHAL_DDCALLBACKS
);
1627 /* Set the flags for this structure
1628 * Windows XP force setting DDHAL_CB32_CREATESURFACE if the driver does not set it
1629 * and ReactX doing same to keep compatible with drivers, but the driver are
1630 * force support pDDCallbacks acoriding MSDN but it seam some driver do not set
1631 * this flag even it is being supported. that is mean. It is small hack to keep
1632 * bad driver working, that trust this is always being setting by it self at end
1634 Flags
= (CallbackFlags
[0] & ~DDHAL_CB32_CREATESURFACE
) | DDHAL_CB32_CREATESURFACE
;
1635 pDDCallbacks
->dwFlags
= Flags
;
1637 /* Write the always-on functions */
1638 pDDCallbacks
->CreateSurface
= DdCreateSurface
;
1640 /* Now write the pointers, if applicable */
1641 if (Flags
& DDHAL_CB32_WAITFORVERTICALBLANK
)
1643 pDDCallbacks
->WaitForVerticalBlank
= DdWaitForVerticalBlank
;
1645 if (Flags
& DDHAL_CB32_CANCREATESURFACE
)
1647 pDDCallbacks
->CanCreateSurface
= DdCanCreateSurface
;
1649 if (Flags
& DDHAL_CB32_GETSCANLINE
)
1651 pDDCallbacks
->GetScanLine
= DdGetScanLine
;
1655 /* Check for DD Surface Callbacks */
1656 if (pDDSurfaceCallbacks
)
1658 /* Zero the structures */
1659 RtlZeroMemory(pDDSurfaceCallbacks
, sizeof(DDHAL_DDSURFACECALLBACKS
));
1660 pDDSurfaceCallbacks
->dwSize
= sizeof(DDHAL_DDSURFACECALLBACKS
);
1662 /* Set the flags for this structure
1663 * Windows XP force setting DDHAL_SURFCB32_LOCK, DDHAL_SURFCB32_UNLOCK,
1664 * DDHAL_SURFCB32_SETCOLORKEY, DDHAL_SURFCB32_DESTROYSURFACE if the driver
1665 * does not set it and ReactX doing same to keep compatible with drivers,
1666 * but the driver are force support pDDSurfaceCallbacks acoriding MSDN but it seam
1667 * some driver do not set this flag even it is being supported. that is mean.
1668 * It is small hack to keep bad driver working, that trust this is always being
1669 * setting by it self at end
1672 Flags
= (CallbackFlags
[1] & ~(DDHAL_SURFCB32_LOCK
| DDHAL_SURFCB32_UNLOCK
|
1673 DDHAL_SURFCB32_SETCOLORKEY
| DDHAL_SURFCB32_DESTROYSURFACE
)) |
1674 (DDHAL_SURFCB32_LOCK
| DDHAL_SURFCB32_UNLOCK
|
1675 DDHAL_SURFCB32_SETCOLORKEY
| DDHAL_SURFCB32_DESTROYSURFACE
);
1677 pDDSurfaceCallbacks
->dwFlags
= Flags
;
1679 /* Write the always-on functions */
1680 pDDSurfaceCallbacks
->Lock
= DdLock
;
1681 pDDSurfaceCallbacks
->Unlock
= DdUnlock
;
1682 pDDSurfaceCallbacks
->SetColorKey
= DdSetColorKey
;
1683 pDDSurfaceCallbacks
->DestroySurface
= DdDestroySurface
;
1685 /* Write the optional ones */
1686 if (Flags
& DDHAL_SURFCB32_FLIP
)
1688 pDDSurfaceCallbacks
->Flip
= DdFlip
;
1690 if (Flags
& DDHAL_SURFCB32_BLT
)
1692 pDDSurfaceCallbacks
->Blt
= DdBlt
;
1694 if (Flags
& DDHAL_SURFCB32_GETBLTSTATUS
)
1696 pDDSurfaceCallbacks
->GetBltStatus
= DdGetBltStatus
;
1698 if (Flags
& DDHAL_SURFCB32_GETFLIPSTATUS
)
1700 pDDSurfaceCallbacks
->GetFlipStatus
= DdGetFlipStatus
;
1702 if (Flags
& DDHAL_SURFCB32_UPDATEOVERLAY
)
1704 pDDSurfaceCallbacks
->UpdateOverlay
= DdUpdateOverlay
;
1706 if (Flags
& DDHAL_SURFCB32_SETOVERLAYPOSITION
)
1708 pDDSurfaceCallbacks
->SetOverlayPosition
= DdSetOverlayPosition
;
1710 if (Flags
& DDHAL_SURFCB32_ADDATTACHEDSURFACE
)
1712 pDDSurfaceCallbacks
->AddAttachedSurface
= DdAddAttachedSurface
;
1716 /* Check for DD Palette Callbacks, This interface are dead for user mode,
1717 * only what it can support are being report back.
1719 if (pDDPaletteCallbacks
)
1721 /* Zero the struct */
1722 RtlZeroMemory(pDDPaletteCallbacks
, sizeof(DDHAL_DDPALETTECALLBACKS
));
1724 /* Write the header */
1725 pDDPaletteCallbacks
->dwSize
= sizeof(DDHAL_DDPALETTECALLBACKS
);
1726 pDDPaletteCallbacks
->dwFlags
= CallbackFlags
[2];
1731 /* Zero the struct */
1732 RtlZeroMemory(pD3dCallbacks
, sizeof(DDHAL_DDEXEBUFCALLBACKS
));
1734 /* Check if we have one */
1735 if (D3dCallbacks
.dwSize
)
1737 /* Write the header */
1738 pD3dCallbacks
->dwSize
= sizeof(DDHAL_DDEXEBUFCALLBACKS
);
1740 /* Now check for each callback */
1741 if (D3dCallbacks
.ContextCreate
)
1743 pD3dCallbacks
->ContextCreate
= (LPD3DHAL_CONTEXTCREATECB
) D3dContextCreate
;
1745 if (D3dCallbacks
.ContextDestroy
)
1747 pD3dCallbacks
->ContextDestroy
= (LPD3DHAL_CONTEXTDESTROYCB
) NtGdiD3dContextDestroy
;
1749 if (D3dCallbacks
.ContextDestroyAll
)
1751 pD3dCallbacks
->ContextDestroyAll
= (LPD3DHAL_CONTEXTDESTROYALLCB
) NtGdiD3dContextDestroyAll
;
1756 /* Check for D3D Driver Data */
1759 /* Copy the struct */
1760 RtlMoveMemory(pD3dDriverData
, &D3dDriverData
, sizeof(D3DHAL_GLOBALDRIVERDATA
));
1762 /* Write the pointer to the texture formats */
1763 pD3dDriverData
->lpTextureFormats
= pD3dTextureFormats
;
1766 /* Check for D3D Buffer Callbacks */
1767 if (pD3dBufferCallbacks
)
1769 /* Zero the struct */
1770 RtlZeroMemory(pD3dBufferCallbacks
, sizeof(DDHAL_DDEXEBUFCALLBACKS
));
1772 if ( D3dBufferCallbacks
.dwSize
)
1774 pD3dBufferCallbacks
->dwSize
= D3dBufferCallbacks
.dwSize
;
1776 pD3dBufferCallbacks
->dwFlags
= D3dBufferCallbacks
.dwFlags
;
1777 if ( D3dBufferCallbacks
.CanCreateD3DBuffer
)
1779 pD3dBufferCallbacks
->CanCreateExecuteBuffer
= (LPDDHALEXEBUFCB_CANCREATEEXEBUF
)DdCanCreateD3DBuffer
;
1782 if ( D3dBufferCallbacks
.CanCreateD3DBuffer
)
1784 pD3dBufferCallbacks
->CreateExecuteBuffer
= (LPDDHALEXEBUFCB_CREATEEXEBUF
) DdCreateD3DBuffer
;
1787 if ( D3dBufferCallbacks
.DestroyD3DBuffer
)
1789 pD3dBufferCallbacks
->DestroyExecuteBuffer
= (LPDDHALEXEBUFCB_DESTROYEXEBUF
) DdDestroyD3DBuffer
;
1792 if ( D3dBufferCallbacks
.LockD3DBuffer
)
1794 pD3dBufferCallbacks
->LockExecuteBuffer
= (LPDDHALEXEBUFCB_LOCKEXEBUF
) DdLockD3D
;
1797 if ( D3dBufferCallbacks
.UnlockD3DBuffer
)
1799 pD3dBufferCallbacks
->UnlockExecuteBuffer
= (LPDDHALEXEBUFCB_UNLOCKEXEBUF
) DdUnlockD3D
;
1805 /* FIXME VidMemList */
1810 HeapFree(GetProcessHeap(), 0, VidMemList
);
1823 DdDeleteDirectDrawObject(LPDDRAWI_DIRECTDRAW_GBL pDirectDrawGlobal
)
1825 BOOL Return
= FALSE
;
1827 /* If this is the global object */
1828 if(pDirectDrawGlobal
->hDD
)
1831 Return
= NtGdiDdDeleteDirectDrawObject((HANDLE
)pDirectDrawGlobal
->hDD
);
1834 pDirectDrawGlobal
->hDD
= 0;
1837 else if (ghDirectDraw
)
1839 /* Always success here */
1842 /* Make sure this is the last instance */
1843 if (!(--gcDirectDraw
))
1845 /* Delete the object */
1846 Return
= NtGdiDdDeleteDirectDrawObject(ghDirectDraw
);
1865 DdCreateSurfaceObject( LPDDRAWI_DDRAWSURFACE_LCL pSurfaceLocal
,
1866 BOOL bPrimarySurface
)
1868 return bDDCreateSurface(pSurfaceLocal
, TRUE
);
1879 DdDeleteSurfaceObject(LPDDRAWI_DDRAWSURFACE_LCL pSurfaceLocal
)
1881 BOOL Return
= FALSE
;
1883 /* Make sure there is one */
1884 if (pSurfaceLocal
->hDDSurface
)
1887 Return
= NtGdiDdDeleteSurfaceObject((HANDLE
)pSurfaceLocal
->hDDSurface
);
1888 pSurfaceLocal
->hDDSurface
= 0;
1901 DdResetVisrgn(LPDDRAWI_DDRAWSURFACE_LCL pSurfaceLocal
,
1904 /* Call win32k directly */
1905 return NtGdiDdResetVisrgn((HANDLE
) pSurfaceLocal
->hDDSurface
, hWnd
);
1915 DdGetDC(LPDDRAWI_DDRAWSURFACE_LCL pSurfaceLocal
,
1916 LPPALETTEENTRY pColorTable
)
1918 /* Call win32k directly */
1919 return NtGdiDdGetDC(pColorTable
, (HANDLE
) pSurfaceLocal
->hDDSurface
);
1929 DdReleaseDC(LPDDRAWI_DDRAWSURFACE_LCL pSurfaceLocal
)
1931 /* Call win32k directly */
1932 return NtGdiDdReleaseDC((HANDLE
) pSurfaceLocal
->hDDSurface
);
1941 DdCreateDIBSection(HDC hdc
,
1942 CONST BITMAPINFO
*pbmi
,
1948 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
1959 DdReenableDirectDrawObject(LPDDRAWI_DIRECTDRAW_GBL pDirectDrawGlobal
,
1962 /* Call win32k directly */
1963 return NtGdiDdReenableDirectDrawObject(GetDdHandle(pDirectDrawGlobal
->hDD
),
1975 DdAttachSurface( LPDDRAWI_DDRAWSURFACE_LCL pSurfaceFrom
,
1976 LPDDRAWI_DDRAWSURFACE_LCL pSurfaceTo
)
1978 /* Create Surface if it does not exits one */
1979 if (!pSurfaceFrom
->hDDSurface
)
1981 if (!bDDCreateSurface(pSurfaceFrom
, FALSE
))
1987 /* Create Surface if it does not exits one */
1988 if (!pSurfaceTo
->hDDSurface
)
1990 if (!bDDCreateSurface(pSurfaceTo
, FALSE
))
1997 return NtGdiDdAttachSurface((HANDLE
)pSurfaceFrom
->hDDSurface
,
1998 (HANDLE
)pSurfaceTo
->hDDSurface
);
2008 DdUnattachSurface(LPDDRAWI_DDRAWSURFACE_LCL pSurface
,
2009 LPDDRAWI_DDRAWSURFACE_LCL pSurfaceAttached
)
2012 NtGdiDdUnattachSurface((HANDLE
)pSurface
->hDDSurface
,
2013 (HANDLE
)pSurfaceAttached
->hDDSurface
);
2023 DdQueryDisplaySettingsUniqueness()
2025 return GdiSharedHandleTable
->flDeviceUniq
;
2035 DdGetDxHandle(LPDDRAWI_DIRECTDRAW_LCL pDDraw
,
2036 LPDDRAWI_DDRAWSURFACE_LCL pSurface
,
2040 HANDLE hSurface
= (HANDLE
)pSurface
->hDDSurface
;
2042 /* Check if we already have a surface */
2045 /* We don't have one, use the DirectDraw Object handle instead */
2047 hDD
= GetDdHandle(pDDraw
->lpGbl
->hDD
);
2051 return (HANDLE
)NtGdiDdGetDxHandle(hDD
, hSurface
, bRelease
);
2061 DdSetGammaRamp(LPDDRAWI_DIRECTDRAW_LCL pDDraw
,
2065 /* Call win32k directly */
2066 return NtGdiDdSetGammaRamp(GetDdHandle(pDDraw
->lpGbl
->hDD
),