ReactOS 0.4.16-dev-2293-g4d8327b
ddraw.c
Go to the documentation of this file.
1/*
2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS kernel
4 * PURPOSE: Native driver for dxg implementation
5 * FILE: win32ss/reactx/dxg/eng.c
6 * PROGRAMER: Magnus olsen (magnus@greatlord.com)
7 * Sebastian Gasiorek (sebastian.gasiorek@reactos.org)
8 * REVISION HISTORY:
9 * 30/12-2007 Magnus Olsen
10 */
11
12#include <dxg_int.h>
13
14/*++
15* @name intDdGetDriverInfo
16* @implemented
17*
18* The function intDdGetDriverInfo is used internally in dxg.sys
19* It retrieves driver information structures
20*
21* @param PEDD_DIRECTDRAW_GLOBAL peDdGl
22* DirectDraw global structure
23*
24* @param GUID guid
25* GUID of InfoData to read
26*
27* @param PVOID callbackStruct
28* Callback structure pointer
29*
30* @param ULONG callbackSize
31* Size of allocated callback structure
32*
33* @param ULONG *returnSize
34* Desired structure size returned by driver
35*
36* @return
37* Returns true on successful execution, false when error.
38*
39* @remarks.
40* Only used internally in dxg.sys
41*--*/
42BOOL intDdGetDriverInfo(PEDD_DIRECTDRAW_GLOBAL peDdGl, GUID guid, PVOID callbackStruct, ULONG callbackSize, ULONG *returnSize)
43{
44 DD_GETDRIVERINFODATA ddGetDriverInfoData;
45
47 {
48 memset(&ddGetDriverInfoData, 0, sizeof(DD_GETDRIVERINFODATA));
49 ddGetDriverInfoData.dwSize = sizeof(DD_GETDRIVERINFODATA);
50 ddGetDriverInfoData.dhpdev = peDdGl->dhpdev;
51 memcpy(&ddGetDriverInfoData.guidInfo, &guid, sizeof(GUID));
52 ddGetDriverInfoData.dwExpectedSize = callbackSize;
53 ddGetDriverInfoData.lpvData = callbackStruct;
54 ddGetDriverInfoData.ddRVal = DDERR_CURRENTLYNOTAVAIL;
55 if (peDdGl->ddHalInfo.GetDriverInfo(&ddGetDriverInfoData) && !ddGetDriverInfoData.ddRVal)
56 {
57 if (returnSize)
58 *returnSize = ddGetDriverInfoData.dwActualSize;
59 return TRUE;
60 }
61
62 }
63
64 /* cleanup on error */
65 memset(callbackStruct, 0, callbackSize);
66 if (returnSize)
67 *returnSize = 0;
68 return FALSE;
69}
70
71/*++
72* @name intDdGetAllDriverInfo
73* @implemented
74*
75* The function intDdGetAllDriverInfo is used internally in dxg.sys
76* It retrieves all possible driver information structures
77*
78* @param PEDD_DIRECTDRAW_GLOBAL peDdGl
79* Pointer to destination DirectDrawGlobal structure
80*
81* @remarks.
82* Only used internally in dxg.sys
83* Missing some callbacks (VideoPort, DxApi, AGP)
84*--*/
86{
88 {
89 intDdGetDriverInfo(peDdGl, GUID_KernelCaps, &peDdGl->ddKernelCaps, sizeof(peDdGl->ddKernelCaps), 0);
90 intDdGetDriverInfo(peDdGl, GUID_KernelCallbacks, &peDdGl->ddKernelCallbacks, sizeof(peDdGl->ddKernelCallbacks), 0);
91
92 if (intDdGetDriverInfo(peDdGl, GUID_D3DCallbacks3, &peDdGl->d3dNtHalCallbacks3, sizeof(peDdGl->d3dNtHalCallbacks3), 0))
94
95 if (intDdGetDriverInfo(peDdGl, GUID_ColorControlCallbacks, &peDdGl->ddColorControlCallbacks, sizeof(peDdGl->ddColorControlCallbacks), 0))
97
98 if (intDdGetDriverInfo(peDdGl, GUID_MiscellaneousCallbacks, &peDdGl->ddMiscellanousCallbacks, sizeof(peDdGl->ddMiscellanousCallbacks), 0))
100
101 if (intDdGetDriverInfo(peDdGl, GUID_Miscellaneous2Callbacks, &peDdGl->ddMiscellanous2Callbacks, sizeof(peDdGl->ddMiscellanous2Callbacks), 0))
103
104 if (intDdGetDriverInfo(peDdGl, GUID_NTCallbacks, &peDdGl->ddNtCallbacks, sizeof(peDdGl->ddNtCallbacks), 0) )
106
107 if (intDdGetDriverInfo(peDdGl, GUID_DDMoreCaps, &peDdGl->ddMoreCaps, sizeof(peDdGl->ddMoreCaps), 0) )
109
110 if (intDdGetDriverInfo(peDdGl, GUID_NTPrivateDriverCaps, &peDdGl->ddNtPrivateDriverCaps, sizeof(peDdGl->ddNtPrivateDriverCaps), 0) )
112
113 if (intDdGetDriverInfo(peDdGl, GUID_MotionCompCallbacks, &peDdGl->ddMotionCompCallbacks, sizeof(peDdGl->ddMotionCompCallbacks), 0) )
115 }
116}
117
118/*++
119* @name intDdEnableDriver
120* @implemented
121*
122* The function intDdEnableDriver is used internally in dxg.sys
123* Fills in all EDD_DIRECTDRAW_GLOBAL structures and enables DirectDraw acceleration when possible
124*
125* @param PEDD_DIRECTDRAW_GLOBAL peDdGl
126* Pointer to destination DirectDrawGlobal structure
127*
128* @remarks.
129* Only used internally in dxg.sys
130*--*/
132{
133 PDRIVER_FUNCTIONS DriverFunctions;
134 LPD3DNTHAL_GLOBALDRIVERDATA GlobalDriverData;
135 LPD3DNTHAL_CALLBACKS HalCallbacks;
136 PDD_D3DBUFCALLBACKS D3DBufCallbacks;
137
138
141
142 // check if driver has DirectDraw functions
143 if ((!DriverFunctions->GetDirectDrawInfo)||(!DriverFunctions->EnableDirectDraw)||(!DriverFunctions->DisableDirectDraw))
144 peDdGl->dhpdev = 0;
145
146
147 // reset acceleration flag
148 peDdGl->fl = peDdGl->fl & 0xFFFFFFFE;
149
150 // ask for structure sizes
151 if ((peDdGl->dhpdev)&&(DriverFunctions->GetDirectDrawInfo(peDdGl->dhpdev, &peDdGl->ddHalInfo, &peDdGl->dwNumHeaps, NULL, &peDdGl->dwNumFourCC, NULL)))
152 {
153 // allocate memory for DX data
154 if (peDdGl->dwNumHeaps)
156 if (peDdGl->dwNumFourCC)
158
159 // get data from driver
160 if (!DriverFunctions->GetDirectDrawInfo(peDdGl->dhpdev, &peDdGl->ddHalInfo, &peDdGl->dwNumHeaps, peDdGl->pvmList, &peDdGl->dwNumFourCC, peDdGl->pdwFourCC))
161 {
162 // failed - cleanup and exit
163 if (peDdGl->pvmList)
164 EngFreeMem(peDdGl->pvmList);
165 if (peDdGl->pdwFourCC)
166 EngFreeMem(peDdGl->pdwFourCC);
168 return;
169 }
170
171 // check if we can enable DirectDraw acceleration
172 if ((peDdGl->ddHalInfo.vmiData.pvPrimary) &&
173 (DriverFunctions->EnableDirectDraw(peDdGl->dhpdev, &peDdGl->ddCallbacks, &peDdGl->ddSurfaceCallbacks, &peDdGl->ddPaletteCallbacks))&&
175 (peDdGl->ddHalInfo.dwSize == sizeof(DD_HALINFO)))
176 {
177 GlobalDriverData = peDdGl->ddHalInfo.lpD3DGlobalDriverData;
178 HalCallbacks = peDdGl->ddHalInfo.lpD3DHALCallbacks;
179 D3DBufCallbacks = peDdGl->ddHalInfo.lpD3DHALCallbacks;
180
181 if (GlobalDriverData && GlobalDriverData->dwSize == sizeof(D3DNTHAL_GLOBALDRIVERDATA))
182 memcpy(&peDdGl->d3dNtGlobalDriverData, GlobalDriverData, sizeof(D3DNTHAL_GLOBALDRIVERDATA));
183
184 if (HalCallbacks && HalCallbacks->dwSize == sizeof(D3DNTHAL_CALLBACKS))
185 memcpy(&peDdGl->d3dNtHalCallbacks, HalCallbacks, sizeof(D3DNTHAL_CALLBACKS));
186
187 if (D3DBufCallbacks && D3DBufCallbacks->dwSize == sizeof(DD_D3DBUFCALLBACKS))
188 memcpy(&peDdGl->d3dBufCallbacks, D3DBufCallbacks, sizeof(DD_D3DBUFCALLBACKS));
189
190 intDdGetAllDriverInfo(peDdGl);
191
192 /*
193 * Initialize video memory heaps for surface allocation.
194 * This is done specifically for vmware, nothing else is likely to use it yet.
195 * But it's done well enough that native ddraw.dll seems happy.
196 */
197 if (peDdGl->pvmList && peDdGl->dwNumHeaps > 0)
198 {
199 VIDEOMEMORY *VidMemEntry;
200 LPVMEMHEAP HeapStruct;
201 DWORD HeapIndex;
202 DWORD DisplayPitch = peDdGl->ddHalInfo.vmiData.lDisplayPitch;
203
204 for (HeapIndex = 0, VidMemEntry = peDdGl->pvmList;
205 HeapIndex < peDdGl->dwNumHeaps;
206 HeapIndex++, VidMemEntry++)
207 {
208 if (VidMemEntry->dwFlags & (VIDMEM_ISHEAP | VIDMEM_HEAPDISABLED))
209 continue;
210
211 HeapStruct = (LPVMEMHEAP)EngAllocMem(FL_ZERO_MEMORY, sizeof(*HeapStruct), TAG_GDDV);
212 if (!HeapStruct)
213 {
214 VidMemEntry->dwFlags |= VIDMEM_HEAPDISABLED;
215 continue;
216 }
217
218 if (VidMemEntry->dwFlags & VIDMEM_ISLINEAR)
219 {
220 HeapStruct->dwFlags = VMEMHEAP_LINEAR;
221 HeapStruct->dwTotalSize = VidMemEntry->fpEnd - VidMemEntry->fpStart + 1;
222 }
223 else
224 {
225 HeapStruct->dwFlags = VMEMHEAP_RECTANGULAR;
226 HeapStruct->stride = DisplayPitch ? DisplayPitch : VidMemEntry->dwWidth;
227 HeapStruct->dwTotalSize = HeapStruct->stride * VidMemEntry->dwHeight;
228 }
229
230 VidMemEntry->lpHeap = HeapStruct;
231 VidMemEntry->dwFlags |= VIDMEM_ISHEAP;
232 }
233 }
234
235 // enable DirectDraw acceleration
236 peDdGl->fl |= 1;
237 }
238 else
239 {
240 // failed - cleanup and exit
241 if (peDdGl->pvmList)
242 EngFreeMem(peDdGl->pvmList);
243 if (peDdGl->pdwFourCC)
244 EngFreeMem(peDdGl->pdwFourCC);
245 }
246 }
247
249}
250
251PVOID
254{
257 PDD_ENTRY AllocRet;
258
260
262 if (!AllocRet)
263 return NULL;
264
265 peDdL = (PEDD_DIRECTDRAW_LOCAL)AllocRet->pobj;
266
267 /* initialize DIRECTDRAW_LOCAL */
270 peDdL->Process = PsGetCurrentProcess();
271
272 // link DirectDrawGlobal and DirectDrawLocal
273 peDdGl->peDirectDrawLocalList = peDdL;
274 peDdL->peDirectDrawGlobal = peDdGl;
275 peDdL->peDirectDrawGlobal2 = peDdGl;
276
278
280
281 return peDdL->pobj.hHmgr;
282}
283
284/*++
285* @name DxDdCreateDirectDrawObject
286* @implemented
287*
288* Function creates new DirectDraw object
289*
290* @param HDC hDC
291* Device context handle
292*
293* @return
294* Newly created DirectDraw object handle.
295*
296* @remarks.
297* Missing all AGP stuff
298*--*/
299DWORD
300NTAPI
302 HDC hDC)
303{
304 PDC pDC = NULL;
305 HDEV hDev = NULL;
306 DWORD_PTR retVal = 0;
307
309 if (!pDC)
310 return 0;
311
312 // get driver hDev from DC
313 hDev = (HDEV)gpEngFuncs.DxEngGetDCState(hDC, 3);
314 if (!hDev) {
316 return 0;
317 }
318
319 // is this primary display?
321 {
323 return 0;
324 }
325
327
328 // create object only for 8BPP and more
331
334 return retVal;
335}
336
337
338/*++
339* @name DxDdGetDriverInfo
340* @implemented
341*
342* Function queries the driver for DirectDraw and Direct3D functionality
343*
344* @param HANDLE DdHandle
345* Handle to DirectDraw object
346*
347* @param PDD_GETDRIVERINFODATA drvInfoData
348* Pointer to in/out driver info data structure
349*--*/
350DWORD
351NTAPI
353{
356 PVOID pInfo = NULL;
357 DWORD dwInfoSize = 0;
358 BYTE callbackStruct[1024];
359 DWORD RetVal = FALSE;
360
362 if (!peDdL)
363 return RetVal;
364
365 peDdGl = peDdL->peDirectDrawGlobal2;
366
367 // check VideoPort related callbacks
369 {
370 if (InlineIsEqualGUID(&drvInfoData->guidInfo, &GUID_VideoPortCallbacks))
371 {
372 dwInfoSize = sizeof(DD_VIDEOPORTCALLBACKS);
373 pInfo = (VOID*)&peDdGl->ddVideoPortCallback;
374 }
375 if (InlineIsEqualGUID(&drvInfoData->guidInfo, &GUID_VideoPortCaps))
376 {
377 pInfo = (VOID*)peDdGl->lpDDVideoPortCaps;
378 dwInfoSize = 72 * peDdGl->ddHalInfo.ddCaps.dwMaxVideoPorts;
379 }
380 if (InlineIsEqualGUID(&drvInfoData->guidInfo, &GUID_D3DCallbacks3))
381 {
382 dwInfoSize = sizeof(D3DNTHAL_CALLBACKS3);
383 pInfo = (VOID*)&peDdGl->d3dNtHalCallbacks3;
384 }
385 }
386
387 // check ColorControl related callbacks
389 {
390 if (InlineIsEqualGUID(&drvInfoData->guidInfo, &GUID_ColorControlCallbacks))
391 {
392 dwInfoSize = sizeof(DD_COLORCONTROLCALLBACKS);
393 pInfo = (VOID*)&peDdGl->ddColorControlCallbacks;
394 }
395 if (InlineIsEqualGUID(&drvInfoData->guidInfo, &GUID_NTCallbacks))
396 {
397 dwInfoSize = sizeof(DD_NTCALLBACKS);
398 pInfo = (VOID*)&peDdGl->ddNtCallbacks;
399 }
400 }
401
402 // check Miscellaneous callbacks
404 {
405 if (InlineIsEqualGUID(&drvInfoData->guidInfo, &GUID_MiscellaneousCallbacks))
406 {
407 dwInfoSize = sizeof(DD_MISCELLANEOUSCALLBACKS);
408 pInfo = (VOID*)&peDdGl->ddMiscellanousCallbacks;
409 }
410 if (InlineIsEqualGUID(&drvInfoData->guidInfo, &GUID_DDMoreCaps))
411 {
412 dwInfoSize = sizeof(DD_MORECAPS);
413 pInfo = &peDdGl->ddMoreCaps;
414 }
415 }
416
418 InlineIsEqualGUID(&drvInfoData->guidInfo, &GUID_Miscellaneous2Callbacks))
419 {
420 dwInfoSize = sizeof(DD_MISCELLANEOUS2CALLBACKS);
421 pInfo = (VOID*)&peDdGl->ddMiscellanous2Callbacks;
422 }
423
425 InlineIsEqualGUID(&drvInfoData->guidInfo, &GUID_MotionCompCallbacks))
426 {
427 dwInfoSize = sizeof(DD_MOTIONCOMPCALLBACKS);
428 pInfo = (VOID*)&peDdGl->ddMotionCompCallbacks;
429 }
430
431 if (InlineIsEqualGUID(&drvInfoData->guidInfo, &GUID_KernelCaps) )
432 {
433 dwInfoSize = sizeof(DD_KERNELCALLBACKS);
434 pInfo = &peDdGl->ddKernelCaps;
435 }
436
437 if (InlineIsEqualGUID(&drvInfoData->guidInfo, &GUID_DDMoreSurfaceCaps))
438 {
439 dwInfoSize = sizeof(DDMORESURFACECAPS);
440 pInfo = &peDdGl->ddMoreSurfaceCaps;
441 }
442
443 if (dwInfoSize && pInfo)
444 {
446 intDdGetDriverInfo(peDdGl, drvInfoData->guidInfo, &callbackStruct, dwInfoSize, &dwInfoSize);
448 memcpy(drvInfoData->lpvData, callbackStruct, dwInfoSize);
449 }
450
452
453 return TRUE;
454}
455
456/*++
457* @name DxDdQueryDirectDrawObject
458* @implemented
459*
460* Function queries the DirectDraw object for its functionality
461*
462* @return
463* TRUE on success.
464*--*/
465BOOL
466NTAPI
468 HANDLE DdHandle,
469 DD_HALINFO* pDdHalInfo,
470 DWORD* pCallBackFlags,
471 LPD3DNTHAL_CALLBACKS pd3dNtHalCallbacks,
472 LPD3DNTHAL_GLOBALDRIVERDATA pd3dNtGlobalDriverData,
473 PDD_D3DBUFCALLBACKS pd3dBufCallbacks,
474 LPDDSURFACEDESC pTextureFormats,
475 DWORD* p8,
476 VIDEOMEMORY* p9,
477 DWORD* pdwNumFourCC,
479{
482 BOOL RetVal = FALSE;
483
484 if (!DdHandle)
485 return RetVal;
486
487 if (!pDdHalInfo)
488 return RetVal;
489
491 return RetVal;
492
494 if (peDdL)
495 {
496 peDdGl = peDdL->peDirectDrawGlobal2;
498
499 memcpy(pDdHalInfo, &peDdGl->ddHalInfo, sizeof(DD_HALINFO));
500
501 if (pCallBackFlags)
502 {
503 *(DWORD*)pCallBackFlags = peDdGl->ddCallbacks.dwFlags;
504 *(DWORD*)((ULONG_PTR)pCallBackFlags + 4) = peDdGl->ddSurfaceCallbacks.dwFlags;
505 *(DWORD*)((ULONG_PTR)pCallBackFlags + 8) = peDdGl->ddPaletteCallbacks.dwFlags;
506 }
507
508 if (pd3dNtHalCallbacks)
509 memcpy(pd3dNtHalCallbacks, &peDdGl->d3dNtHalCallbacks, sizeof(peDdGl->d3dNtHalCallbacks));
510
511 if (pd3dNtGlobalDriverData)
512 memcpy(pd3dNtGlobalDriverData, &peDdGl->d3dNtGlobalDriverData, sizeof(peDdGl->d3dNtGlobalDriverData));
513
514 if (pd3dBufCallbacks)
515 memcpy(pd3dBufCallbacks, &peDdGl->d3dBufCallbacks, sizeof(peDdGl->d3dBufCallbacks));
516
517 if (pTextureFormats)
519
520 if (pdwNumFourCC)
521 *pdwNumFourCC = peDdGl->dwNumFourCC;
522
523 if (pdwFourCC)
524 memcpy(pdwFourCC, &peDdGl->pdwFourCC, 4 * peDdGl->dwNumFourCC);
525
526 RetVal = TRUE;
527
529
531 }
532
533 return RetVal;
534}
535
536/*++
537* @name DxDdEnableDirectDraw
538* @implemented
539*
540* Function enables DirectDraw
541*
542* @param PEDD_DIRECTDRAW_GLOBAL peDdGl
543* Pointer to destination DirectDrawGlobal structure
544*--*/
545BOOL
546NTAPI
548{
550
552 {
554 peDdGl->hDev = hDev;
555 peDdGl->bSuspended = FALSE;
557 intDdEnableDriver(peDdGl);
558 return TRUE;
559 }
560
561 return FALSE;
562}
563
564/*++
565* @name DxDdReenableDirectDrawObject
566* @implemented
567*
568* Function re-enables DirectDraw object after mode switch
569*
570* @param HANDLE DdHandle
571* DirectDraw object handle
572*
573* @param PVOID p2
574* ???
575*
576* @return
577* TRUE on success.
578*
579* @remarks
580* Missing all AGP stuff and second parameter handling
581*--*/
582DWORD
583NTAPI
585 HANDLE DdHandle,
586 PVOID p2)
587{
590 HDC hDC;
591 DWORD RetVal = FALSE;
592
594
595 if (!peDdL)
596 return RetVal;
597
598 peDdGl = peDdL->peDirectDrawGlobal2;
599
601
604
605 if (peDdGl->fl & 1 &&
606 gpEngFuncs.DxEngGetDCState(hDC, 2) != 1 &&
611 {
612 // reset acceleration and suspend flags
613 peDdGl->fl &= 0xFFFFFFFD;
614 peDdGl->bSuspended = 0;
616
617 RetVal = TRUE;
618 // FIXME AGP Stuff
619 }
620
623
625
626 return RetVal;
627}
628
630NTAPI
632{
634
635 // first check if we can assign it from current ddHandle
636 if (hDirectDrawLocal)
637 {
639 // check if surface is locked and belongs to correct DirectDrawLocal
640 if ((pSurface)&&((pSurface->peDirectDrawLocal != peDdL)||(!pSurface->hSecure)))
641 {
643 return NULL;
644 }
645 }
646
647 // if surface not found from ddHandle or ddHandle not provided
648 if (!pSurface)
649 {
650 // create new surface object
652 if (pSurface)
653 {
654 pSurface->ddsSurfaceLocal.lpGbl = &pSurface->ddsSurfaceGlobal;
655 pSurface->ddsSurfaceLocal.lpSurfMore = &pSurface->ddsSurfaceMore;
656 pSurface->ddsSurfaceInt.lpLcl = &pSurface->ddsSurfaceLocal;
657 pSurface->peDirectDrawLocal = peDdL;
658 pSurface->peDirectDrawGlobalNext = peDdL->peDirectDrawGlobal2;
659 pSurface->ldev = gpEngFuncs.DxEngGetHdevData(pSurface->peDirectDrawGlobalNext->hDev, DxEGShDevData_ldev);
660 pSurface->gdev = gpEngFuncs.DxEngGetHdevData(pSurface->peDirectDrawGlobalNext->hDev, DxEGShDevData_GDev);
661 pSurface->hSecure = (VOID*)1;
662 }
663 }
664
665 if (pSurface)
666 {
667 pSurface->ddsSurfaceGlobal.fpVidMem = pDdSurfGlob->fpVidMem;
668 pSurface->ddsSurfaceGlobal.lPitch = pDdSurfGlob->lPitch;
669 pSurface->ddsSurfaceGlobal.wWidth = pDdSurfGlob->wWidth;
670 pSurface->ddsSurfaceGlobal.wHeight = pDdSurfGlob->wHeight;
671 pSurface->wWidth = pDdSurfGlob->wWidth;
672 pSurface->wHeight = pDdSurfGlob->wHeight;
673 memcpy(&pSurface->ddsSurfaceGlobal.ddpfSurface, &pDdSurfGlob->ddpfSurface, sizeof(pSurface->ddsSurfaceGlobal.ddpfSurface));
674 pSurface->ddsSurfaceLocal.ddsCaps.dwCaps = pDdSurfLoc->ddsCaps.dwCaps;
675 pSurface->ddsSurfaceMore.ddsCapsEx.dwCaps2 = pDdSurfMore->ddsCapsEx.dwCaps2;
676 pSurface->ddsSurfaceMore.ddsCapsEx.dwCaps3 = pDdSurfMore->ddsCapsEx.dwCaps3;
677 pSurface->ddsSurfaceMore.ddsCapsEx.dwCaps4 = pDdSurfMore->ddsCapsEx.dwCaps4;
678 pSurface->ddsSurfaceMore.dwSurfaceHandle = pDdSurfMore->dwSurfaceHandle;
679 pSurface->hSecure = (VOID*)1;
680
681 peDdL->peSurface_DdList = pSurface;
682 peDdL->hSurface = (ULONG_PTR)pSurface->pobj.hHmgr;
683 }
684
685 return pSurface;
686}
687
688HANDLE
689NTAPI
691 HANDLE hSurface,
692 PDD_SURFACE_LOCAL puSurfaceLocal,
693 PDD_SURFACE_MORE puSurfaceMore,
694 PDD_SURFACE_GLOBAL puSurfaceGlobal,
695 BOOL bComplete)
696{
697 HANDLE RetVal = FALSE;
699 PEDD_SURFACE pDdSurface = NULL;
700
701 peDdL = (PEDD_DIRECTDRAW_LOCAL)DdHmgLock(hDirectDrawLocal, ObjType_DDLOCAL_TYPE, FALSE);
702
703 if (!peDdL)
704 return RetVal;
705
706 pDdSurface = intDdCreateNewSurfaceObject(peDdL, hSurface, puSurfaceGlobal, puSurfaceLocal, puSurfaceMore);
707 if (!pDdSurface)
708 {
710 return RetVal;
711 }
712
713 RetVal = pDdSurface->pobj.hHmgr;
714
717
718 return RetVal;
719}
static HDC hDC
Definition: 3dtext.c:33
#define InterlockedDecrement
Definition: armddk.h:52
struct _D3DNTHAL_CALLBACKS3 D3DNTHAL_CALLBACKS3
HANDLE FASTCALL DdHmgAlloc(ULONG objSize, CHAR objType, BOOLEAN objLock)
Definition: ddhmg.c:340
PVOID FASTCALL DdHmgLock(HANDLE DdHandle, UCHAR ObjectType, BOOLEAN LockOwned)
Definition: ddhmg.c:147
#define VIDMEM_HEAPDISABLED
Definition: ddrawi.h:213
#define VIDMEM_ISHEAP
Definition: ddrawi.h:210
#define VIDMEM_ISLINEAR
Definition: ddrawi.h:208
#define DDHALINFO_GETDRIVERINFOSET
Definition: ddrawi.h:667
struct _DDMORESURFACECAPS DDMORESURFACECAPS
struct _DD_MORECAPS DD_MORECAPS
struct _DD_COLORCONTROLCALLBACKS DD_COLORCONTROLCALLBACKS
struct _DD_MISCELLANEOUS2CALLBACKS DD_MISCELLANEOUS2CALLBACKS
struct _DD_NTCALLBACKS DD_NTCALLBACKS
#define EDDDGBL_MISCCALLBACKS
Definition: directxint.h:107
#define EDDDGBL_MISC2CALLBACKS
Definition: directxint.h:111
#define EDDDGBL_PRIVATEDRIVERCAPS
Definition: directxint.h:115
#define EDDDGBL_DDMORECAPS
Definition: directxint.h:112
#define EDDDGBL_MOTIONCOMPCALLBACKS
Definition: directxint.h:110
struct _EDD_DIRECTDRAW_GLOBAL * PEDD_DIRECTDRAW_GLOBAL
struct _EDD_DIRECTDRAW_LOCAL * PEDD_DIRECTDRAW_LOCAL
#define EDDDGBL_COLORCONTROLCALLBACKS
Definition: directxint.h:109
struct _EDD_SURFACE * PEDD_SURFACE
#define EDDDGBL_NTCALLBACKS
Definition: directxint.h:114
#define EDDDGBL_D3DCALLBACKS3
Definition: directxint.h:113
#define EDDDGBL_VIDEOPORTCALLBACKS
Definition: directxint.h:108
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
GUID guid
Definition: version.c:147
#define VMEMHEAP_RECTANGULAR
Definition: dmemmgr.h:47
#define VMEMHEAP_LINEAR
Definition: dmemmgr.h:46
struct _VMEMHEAP * LPVMEMHEAP
#define ULONG_PTR
Definition: config.h:101
@ DxEGShDevData_OpenRefs
Definition: dxeng.h:66
@ DxEGShDevData_DrvFuncs
Definition: dxeng.h:57
@ DxEGShDevData_DitherFmt
Definition: dxeng.h:54
@ DxEGShDevData_dd_flags
Definition: dxeng.h:61
@ DxEGShDevData_eddg
Definition: dxeng.h:59
@ DxEGShDevData_display
Definition: dxeng.h:64
@ DxEGShDevData_ldev
Definition: dxeng.h:68
@ DxEGShDevData_disable
Definition: dxeng.h:62
@ DxEGShDevData_dd_locks
Definition: dxeng.h:60
@ DxEGShDevData_dhpdev
Definition: dxeng.h:58
@ DxEGShDevData_GDev
Definition: dxeng.h:69
#define CapOver_DisableD3DAccel
Definition: dxg_int.h:47
DXENG_FUNCTIONS gpEngFuncs
Definition: main.c:20
#define ObjType_DDLOCAL_TYPE
Definition: dxg_int.h:51
#define ObjType_DDSURFACE_TYPE
Definition: dxg_int.h:52
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
GLuint GLuint GLuint GLuint GLuint GLuint GLuint arg2
Definition: glext.h:9514
if(dx< 0)
Definition: linetemp.h:194
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
struct _DD_GETDRIVERINFODATA DD_GETDRIVERINFODATA
struct _DD_MISCELLANEOUSCALLBACKS DD_MISCELLANEOUSCALLBACKS
static HDC
Definition: imagelist.c:88
#define FASTCALL
Definition: nt_native.h:50
struct _DRIVER_FUNCTIONS * PDRIVER_FUNCTIONS
HANDLE NTAPI PsGetCurrentThreadProcessId(VOID)
Definition: thread.c:755
#define EngFreeMem
Definition: polytest.cpp:56
#define FL_ZERO_MEMORY
Definition: polytest.cpp:58
void * EngAllocMem(int zero, unsigned long size, int tag=0)
Definition: polytest.cpp:70
#define InlineIsEqualGUID(rguid1, rguid2)
Definition: guiddef.h:142
#define DDERR_CURRENTLYNOTAVAIL
Definition: ddraw.h:72
#define memset(x, y, z)
Definition: compat.h:39
Definition: polytest.cpp:41
DWORD dwFlags
Definition: ddrawint.h:499
LPDDSURFACEDESC lpTextureFormats
Definition: d3dnthal.h:132
DWORD dwMaxVideoPorts
Definition: ddrawint.h:1110
DWORD dwCaps4
Definition: ddraw.h:1065
DWORD dwCaps3
Definition: ddraw.h:1062
DWORD dwCaps2
Definition: ddraw.h:1061
DWORD dwCaps
Definition: ddraw.h:729
USHORT cExclusiveLock
Definition: dxg_int.h:34
HGDIOBJ hHmgr
Definition: dxg_int.h:32
Definition: dxg_int.h:58
PDD_BASEOBJECT pobj
Definition: dxg_int.h:61
DWORD dwExpectedSize
Definition: main.c:55
HRESULT ddRVal
Definition: main.c:58
DWORD dwActualSize
Definition: main.c:57
DWORD dwSize
Definition: ddrawint.h:1124
PVOID lpD3DHALCallbacks
Definition: ddrawint.h:1130
PVOID lpD3DGlobalDriverData
Definition: ddrawint.h:1129
DWORD dwFlags
Definition: ddrawint.h:1128
PDD_GETDRIVERINFO GetDriverInfo
Definition: ddrawint.h:1127
DDNTCORECAPS ddCaps
Definition: ddrawint.h:1126
VIDEOMEMORYINFO vmiData
Definition: ddrawint.h:1125
DDPIXELFORMAT ddpfSurface
Definition: ddrawint.h:156
FLATPTR fpVidMem
Definition: ddrawint.h:146
DDSCAPS ddsCaps
Definition: ddrawint.h:174
DDSCAPSEX ddsCapsEx
Definition: ddrawint.h:165
DWORD dwSurfaceHandle
Definition: ddrawint.h:166
PFN_DrvEnableDirectDraw EnableDirectDraw
Definition: ntgdityp.h:629
PFN_DrvDisableDirectDraw DisableDirectDraw
Definition: ntgdityp.h:630
PFN_DrvGetDirectDrawInfo GetDirectDrawInfo
Definition: ntgdityp.h:628
PFN_DxEngGetHdevData DxEngGetHdevData
Definition: dxg_int.h:142
PFN_DxEngLockDC DxEngLockDC
Definition: dxg_int.h:149
PFN_DxEngUnlockShareSem DxEngUnlockShareSem
Definition: dxg_int.h:130
PFN_DxEngUnlockHdev DxEngUnlockHdev
Definition: dxg_int.h:133
PFN_DxEngGetDesktopDC DxEngGetDesktopDC
Definition: dxg_int.h:145
PFN_DxEngGetDCState DxEngGetDCState
Definition: dxg_int.h:152
PFN_DxEngScreenAccessCheck DxEngScreenAccessCheck
Definition: dxg_int.h:124
PFN_DxEngReferenceHdev DxEngReferenceHdev
Definition: dxg_int.h:135
PFN_DxEngLockShareSem DxEngLockShareSem
Definition: dxg_int.h:129
PFN_DxEngUnlockDC DxEngUnlockDC
Definition: dxg_int.h:150
PFN_DxEngLockHdev DxEngLockHdev
Definition: dxg_int.h:132
DD_NTPRIVATEDRIVERCAPS ddNtPrivateDriverCaps
Definition: directxint.h:159
DD_MORECAPS ddMoreCaps
Definition: directxint.h:158
D3DNTHAL_GLOBALDRIVERDATA d3dNtGlobalDriverData
Definition: directxint.h:163
DD_MISCELLANEOUSCALLBACKS ddMiscellanousCallbacks
Definition: directxint.h:168
DD_MOTIONCOMPCALLBACKS ddMotionCompCallbacks
Definition: directxint.h:174
VIDEOMEMORY * pvmList
Definition: directxint.h:150
DD_KERNELCALLBACKS ddKernelCallbacks
Definition: directxint.h:172
DD_NTCALLBACKS ddNtCallbacks
Definition: directxint.h:170
DD_VIDEOPORTCALLBACKS ddVideoPortCallback
Definition: directxint.h:167
DD_D3DBUFCALLBACKS d3dBufCallbacks
Definition: directxint.h:165
DDKERNELCAPS ddKernelCaps
Definition: directxint.h:157
DD_MISCELLANEOUS2CALLBACKS ddMiscellanous2Callbacks
Definition: directxint.h:169
DDMORESURFACECAPS ddMoreSurfaceCaps
Definition: directxint.h:175
DD_PALETTECALLBACKS ddPaletteCallbacks
Definition: directxint.h:162
EDD_DIRECTDRAW_LOCAL * peDirectDrawLocalList
Definition: directxint.h:176
DD_CALLBACKS ddCallbacks
Definition: directxint.h:160
DD_COLORCONTROLCALLBACKS ddColorControlCallbacks
Definition: directxint.h:171
D3DNTHAL_CALLBACKS3 d3dNtHalCallbacks3
Definition: directxint.h:173
D3DNTHAL_CALLBACKS d3dNtHalCallbacks
Definition: directxint.h:164
DD_SURFACECALLBACKS ddSurfaceCallbacks
Definition: directxint.h:161
LPDDVIDEOPORTCAPS lpDDVideoPortCaps
Definition: directxint.h:123
struct _EDD_DIRECTDRAW_GLOBAL * peDirectDrawGlobal2
Definition: directxint.h:22
struct _EDD_SURFACE * peSurface_DdList
Definition: directxint.h:19
DD_BASEOBJECT pobj
Definition: directxint.h:16
struct _EDD_DIRECTDRAW_GLOBAL * peDirectDrawGlobal
Definition: directxint.h:17
struct _EDD_DIRECTDRAW_LOCAL * peDirectDrawLocal_prev
Definition: directxint.h:25
DD_BASEOBJECT pobj
Definition: directxint.h:46
LONG lDisplayPitch
Definition: ddrawint.h:115
struct _VMEMHEAP * lpHeap
Definition: ddrawint.h:105
DWORD dwWidth
Definition: ddrawint.h:100
DWORD dwFlags
Definition: ddrawint.h:96
FLATPTR fpEnd
Definition: ddrawint.h:99
FLATPTR fpStart
Definition: ddrawint.h:97
DWORD dwHeight
Definition: ddrawint.h:106
DWORD dwTotalSize
Definition: dmemmgr.h:119
DWORD dwFlags
Definition: dmemmgr.h:115
DWORD stride
Definition: dmemmgr.h:116
uint32_t DWORD_PTR
Definition: typedefs.h:65
#define NTAPI
Definition: typedefs.h:36
void * PVOID
Definition: typedefs.h:50
uint32_t ULONG_PTR
Definition: typedefs.h:65
uint32_t ULONG
Definition: typedefs.h:59
HANDLE NTAPI DxDdCreateSurfaceObject(HANDLE hDirectDrawLocal, HANDLE hSurface, PDD_SURFACE_LOCAL puSurfaceLocal, PDD_SURFACE_MORE puSurfaceMore, PDD_SURFACE_GLOBAL puSurfaceGlobal, BOOL bComplete)
Definition: ddraw.c:690
BOOL NTAPI DxDdEnableDirectDraw(HANDLE hDev, BOOL arg2)
Definition: ddraw.c:547
DWORD NTAPI DxDdReenableDirectDrawObject(HANDLE DdHandle, PVOID p2)
Definition: ddraw.c:584
DWORD NTAPI DxDdCreateDirectDrawObject(HDC hDC)
Definition: ddraw.c:301
VOID intDdGetAllDriverInfo(PEDD_DIRECTDRAW_GLOBAL peDdGl)
Definition: ddraw.c:85
PEDD_SURFACE NTAPI intDdCreateNewSurfaceObject(PEDD_DIRECTDRAW_LOCAL peDdL, HANDLE hDirectDrawLocal, PDD_SURFACE_GLOBAL pDdSurfGlob, PDD_SURFACE_LOCAL pDdSurfLoc, PDD_SURFACE_MORE pDdSurfMore)
Definition: ddraw.c:631
BOOL intDdGetDriverInfo(PEDD_DIRECTDRAW_GLOBAL peDdGl, GUID guid, PVOID callbackStruct, ULONG callbackSize, ULONG *returnSize)
Definition: ddraw.c:42
BOOL NTAPI DxDdQueryDirectDrawObject(HANDLE DdHandle, DD_HALINFO *pDdHalInfo, DWORD *pCallBackFlags, LPD3DNTHAL_CALLBACKS pd3dNtHalCallbacks, LPD3DNTHAL_GLOBALDRIVERDATA pd3dNtGlobalDriverData, PDD_D3DBUFCALLBACKS pd3dBufCallbacks, LPDDSURFACEDESC pTextureFormats, DWORD *p8, VIDEOMEMORY *p9, DWORD *pdwNumFourCC, DWORD *pdwFourCC)
Definition: ddraw.c:467
PVOID FASTCALL intDdCreateDirectDrawLocal(HDEV hDev)
Definition: ddraw.c:253
DWORD NTAPI DxDdGetDriverInfo(HANDLE DdHandle, PDD_GETDRIVERINFODATA drvInfoData)
Definition: ddraw.c:352
VOID intDdEnableDriver(PEDD_DIRECTDRAW_GLOBAL peDdGl)
Definition: ddraw.c:131
#define TAG_GDDV
Definition: tags.h:3
#define TAG_GDDF
Definition: tags.h:4
#define BMF_8BPP
Definition: winddi.h:357
_In_ DD_SURFACE_LOCAL * pSurface
Definition: winddi.h:3481
_Out_ DD_HALINFO _Out_ DWORD _Out_ VIDEOMEMORY _Out_ DWORD _Out_ DWORD * pdwFourCC
Definition: winddi.h:4230
#define PsGetCurrentProcess
Definition: psfuncs.h:17
unsigned char BYTE
Definition: xxhash.c:193