3 * COPYRIGHT: See COPYING in the top level directory
5 * FILE: lib/ddraw/hal/ddraw.c
6 * PURPOSE: DirectDraw HAL Implementation
7 * PROGRAMMER: Magnus Olsen, Maarten Bosma
14 HRESULT
Hal_DirectDraw_Initialize (LPDIRECTDRAW7 iface
)
16 IDirectDrawImpl
* This
= (IDirectDrawImpl
*)iface
;
19 /* point to it self */
20 This
->DirectDrawGlobal
.lp16DD
= &This
->DirectDrawGlobal
;
23 if(!DdCreateDirectDrawObject (&This
->DirectDrawGlobal
, This
->hdc
))
24 return DDERR_INVALIDPARAMS
;
27 /* alloc all the space */
28 This
->DirectDrawGlobal
.lpDDCBtmp
= (LPDDHAL_CALLBACKS
)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(DDHAL_CALLBACKS
));
29 This
->DirectDrawGlobal
.lpD3DHALCallbacks
= (ULONG_PTR
)HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY
, sizeof(D3DHAL_CALLBACKS
));
30 This
->DirectDrawGlobal
.lpD3DGlobalDriverData
= (ULONG_PTR
)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(D3DHAL_GLOBALDRIVERDATA
));
33 /* Fill in some info */
34 This
->HalInfo
.lpD3DGlobalDriverData
= This
->DirectDrawGlobal
.lpD3DGlobalDriverData
;
35 This
->HalInfo
.lpD3DHALCallbacks
= This
->DirectDrawGlobal
.lpD3DHALCallbacks
;
36 This
->HalInfo
.lpDDCallbacks
= &This
->DirectDrawGlobal
.lpDDCBtmp
->HALDD
;
37 This
->HalInfo
.lpDDExeBufCallbacks
= &This
->DirectDrawGlobal
.lpDDCBtmp
->HALDDExeBuf
;
38 This
->HalInfo
.lpDDPaletteCallbacks
= &This
->DirectDrawGlobal
.lpDDCBtmp
->HALDDPalette
;
39 This
->HalInfo
.lpDDSurfaceCallbacks
= &This
->DirectDrawGlobal
.lpDDCBtmp
->HALDDSurface
;
41 /* FIXME The insate is not right we need the info that the three NULL return */
43 /* query all kinds of infos from the driver */
44 if(!DdQueryDirectDrawObject (
45 &This
->DirectDrawGlobal
,
47 This
->HalInfo
.lpDDCallbacks
,
48 This
->HalInfo
.lpDDSurfaceCallbacks
,
49 This
->HalInfo
.lpDDPaletteCallbacks
,
50 (LPD3DHAL_CALLBACKS
)This
->DirectDrawGlobal
.lpD3DHALCallbacks
,
51 (LPD3DHAL_GLOBALDRIVERDATA
)This
->DirectDrawGlobal
.lpD3DGlobalDriverData
,
52 This
->HalInfo
.lpDDExeBufCallbacks
,
57 OutputDebugString(L
"First DdQueryDirectDrawObject failed");
61 /* FIXME The insate is not right we need the info that the three NULL return and use it here*/
63 /* Fixme shall we selected the pixel type before we call the DdQueryDirectDrawObject second time
64 and fill in more info ?? */
66 This
->HalInfo
.vmiData
.pvmList
= HeapAlloc(GetProcessHeap(), 0, sizeof(VIDMEM
) * This
->HalInfo
.vmiData
.dwNumHeaps
);
67 This
->DirectDrawGlobal
.lpdwFourCC
= HeapAlloc(GetProcessHeap(), 0, sizeof(DWORD
) * This
->HalInfo
.ddCaps
.dwNumFourCCCodes
);
68 This
->DirectDrawGlobal
.lpZPixelFormats
= HeapAlloc(GetProcessHeap(), 0, sizeof(DDPIXELFORMAT
) * This
->DirectDrawGlobal
.dwNumZPixelFormats
);
69 ((LPD3DHAL_GLOBALDRIVERDATA
)This
->DirectDrawGlobal
.lpD3DGlobalDriverData
)->lpTextureFormats
= HeapAlloc(GetProcessHeap(), 0, sizeof(DDSURFACEDESC
) * ((LPD3DHAL_GLOBALDRIVERDATA
)This
->DirectDrawGlobal
.lpD3DGlobalDriverData
)->dwNumTextureFormats
);
71 if(!DdQueryDirectDrawObject (
72 &This
->DirectDrawGlobal
,
74 This
->HalInfo
.lpDDCallbacks
,
75 This
->HalInfo
.lpDDSurfaceCallbacks
,
76 This
->HalInfo
.lpDDPaletteCallbacks
,
77 (LPD3DHAL_CALLBACKS
)This
->DirectDrawGlobal
.lpD3DHALCallbacks
,
78 (LPD3DHAL_GLOBALDRIVERDATA
)This
->DirectDrawGlobal
.lpD3DGlobalDriverData
,
79 This
->HalInfo
.lpDDExeBufCallbacks
,
80 ((LPD3DHAL_GLOBALDRIVERDATA
)This
->DirectDrawGlobal
.lpD3DGlobalDriverData
)->lpTextureFormats
,
81 This
->DirectDrawGlobal
.lpdwFourCC
,
82 This
->HalInfo
.vmiData
.pvmList
85 OutputDebugString(L
"Second DdQueryDirectDrawObject failed");
89 /* Copy HalInfo to DirectDrawGlobal (Not complete)*/
91 RtlCopyMemory(&This
->DirectDrawGlobal
.vmiData
,&This
->HalInfo
.vmiData
,sizeof(VIDMEMINFO
));
92 RtlCopyMemory(&This
->DirectDrawGlobal
.ddCaps
,&This
->HalInfo
.ddCaps
,sizeof(DDCORECAPS
));
93 This
->DirectDrawGlobal
.dwMonitorFrequency
= This
->HalInfo
.dwMonitorFrequency
;
95 /* have not check where it should go into yet
96 This->HalInfo.GetDriverInfo datatype LPDDHAL_GETDRIVERINFO
99 This
->DirectDrawGlobal
.dwModeIndex
= This
->HalInfo
.dwModeIndex
;
101 /* have not check where it should go into yet
102 This->HalInfo.lpdwFourCC datatype LPDWORD
105 This
->DirectDrawGlobal
.dwNumModes
= This
->HalInfo
.dwNumModes
;
106 This
->DirectDrawGlobal
.lpModeInfo
= This
->HalInfo
.lpModeInfo
;
108 /* have not check where it should go into yet
109 This->HalInfo.dwFlags data type DWORD
112 /* Unsure which of these two for lpPDevice
113 This->DirectDrawGlobal.dwPDevice = This->HalInfo.lpPDevice;
114 This->lpDriverHandle = This->HalInfo.lpPDevice;
117 This
->DirectDrawGlobal
.hInstance
= This
->HalInfo
.hInstance
;
119 /* have not check where it should go into yet
120 This->lpD3DGlobalDriverData datatype ULONG_PTR
121 This->lpD3DHALCallbacks datatype ULONG_PTR
123 RtlCopyMemory(&This
->DirectDrawGlobal
.lpDDCBtmp
->HALDDExeBuf
,&This
->HalInfo
.lpDDExeBufCallbacks
,sizeof(DDHAL_DDEXEBUFCALLBACKS
));
127 /************************************************************************/
128 /* Set up the rest of the callbacks all callbacks we get back from */
129 /* gdi32.dll is user mode */
130 /************************************************************************/
132 /* Todo add a check see if HalInfo.GetDriverInfo is supported or not */
134 /* Do not trust msdn what it say about dwContext it is not in use for
135 windows nt, it is in use for all os, and it always pont to
136 DirectDrawGlobal.hDD */
138 DDHAL_GETDRIVERINFODATA DriverInfo
;
139 memset(&DriverInfo
,0, sizeof(DDHAL_GETDRIVERINFODATA
));
140 DriverInfo
.dwSize
= sizeof(DDHAL_GETDRIVERINFODATA
);
141 DriverInfo
.dwContext
= This
->DirectDrawGlobal
.hDD
;
144 /* Get ColorControlCallbacks */
145 DriverInfo
.guidInfo
= GUID_ColorControlCallbacks
;
146 DriverInfo
.lpvData
= &This
->DirectDrawGlobal
.lpDDCBtmp
->HALDDColorControl
;
147 DriverInfo
.dwExpectedSize
= sizeof(DDHAL_DDCOLORCONTROLCALLBACKS
);
148 This
->HalInfo
.GetDriverInfo( &DriverInfo
);
151 /* Get the GUID_D3DCallbacks callback */
153 /* Problem with include files
154 DDHAL_DDMISCELLANEOUSCALLBACKS misc;
155 DriverInfo.guidInfo = GUID_D3DCallbacks;
156 DriverInfo.lpvData = &misc;
157 DriverInfo.dwExpectedSize = sizeof(DDHAL_DDMISCELLANEOUSCALLBACKS);
158 This->HalInfo.GetDriverInfo( &DriverInfo);*/
160 /* Get the D3DCallbacks2 */
161 This
->DirectDrawGlobal
.lpD3DHALCallbacks2
= (ULONG_PTR
)HeapAlloc(GetProcessHeap(), 0, sizeof(D3DHAL_CALLBACKS2
));
162 DriverInfo
.guidInfo
= GUID_D3DCallbacks2
;
163 DriverInfo
.lpvData
= (PVOID
)This
->DirectDrawGlobal
.lpD3DHALCallbacks2
;
164 DriverInfo
.dwExpectedSize
= sizeof(D3DHAL_CALLBACKS2
);
165 This
->HalInfo
.GetDriverInfo( &DriverInfo
);
168 /* Get the D3DCallbacks3 */
169 This
->DirectDrawGlobal
.lpD3DHALCallbacks
= (ULONG_PTR
)HeapAlloc(GetProcessHeap(), 0, sizeof(D3DHAL_CALLBACKS3
));
170 DriverInfo
.guidInfo
= GUID_D3DCallbacks3
;
171 DriverInfo
.lpvData
= (PVOID
)This
->DirectDrawGlobal
.lpD3DHALCallbacks
;
172 DriverInfo
.dwExpectedSize
= sizeof(D3DHAL_CALLBACKS3
);
173 This
->HalInfo
.GetDriverInfo( &DriverInfo
);
176 /* Get the misc callback */
177 /* Problem with include files
178 DriverInfo.guidInfo = GUID_D3DCaps;
179 DriverInfo.lpvData = &misc;
180 DriverInfo.dwExpectedSize = sizeof(DDHAL_DDMISCELLANEOUSCALLBACKS);
181 This->HalInfo.GetDriverInfo( &DriverInfo);
184 /* Get the D3DExtendedCaps */
186 This
->DirectDrawGlobal
.lpD3DExtendedCaps
= (ULONG_PTR
)HeapAlloc(GetProcessHeap(), 0, sizeof(D3DHAL_D3DEXTENDEDCAPS
));
187 DriverInfo
.guidInfo
= GUID_D3DExtendedCaps
;
188 DriverInfo
.lpvData
= (PVOID
) This
->DirectDrawGlobal
.lpD3DExtendedCaps
;
189 DriverInfo
.dwExpectedSize
= sizeof(D3DHAL_D3DEXTENDEDCAPS
);
190 This
->HalInfo
.GetDriverInfo( &DriverInfo
);
193 /* Get the D3DParseUnknownCommandCallback */
195 DriverInfo.guidInfo = GUID_D3DParseUnknownCommandCallback;
196 DriverInfo.lpvData = &misc;
197 DriverInfo.dwExpectedSize = sizeof(DDHAL_DDMISCELLANEOUSCALLBACKS);
198 This->HalInfo.GetDriverInfo( &DriverInfo);
201 /* Get the GetHeapAlignment */
203 DriverInfo.guidInfo = GUID_GetHeapAlignment;
204 DriverInfo.lpvData = &misc;
205 DriverInfo.dwExpectedSize = sizeof(DDHAL_DDMISCELLANEOUSCALLBACKS);
206 This->HalInfo.GetDriverInfo( &DriverInfo);
209 /* Get the KernelCallbacks */
210 DriverInfo
.guidInfo
= GUID_KernelCallbacks
;
211 DriverInfo
.lpvData
= &This
->DirectDrawGlobal
.lpDDCBtmp
->HALDDKernel
;
212 DriverInfo
.dwExpectedSize
= sizeof(DDHAL_DDKERNELCALLBACKS
);
213 This
->HalInfo
.GetDriverInfo( &DriverInfo
);
216 /* Get the KernelCaps */
217 This
->DirectDrawGlobal
.lpDDKernelCaps
= (LPDDKERNELCAPS
)HeapAlloc(GetProcessHeap(), 0, sizeof(DDHAL_DDKERNELCALLBACKS
));
218 DriverInfo
.guidInfo
= GUID_KernelCaps
;
219 DriverInfo
.lpvData
= (PVOID
) This
->DirectDrawGlobal
.lpDDKernelCaps
;
220 DriverInfo
.dwExpectedSize
= sizeof(DDHAL_DDKERNELCALLBACKS
);
221 This
->HalInfo
.GetDriverInfo( &DriverInfo
);
224 /* Get the MiscellaneousCallbacks */
225 DriverInfo
.guidInfo
= GUID_MiscellaneousCallbacks
;
226 DriverInfo
.lpvData
= &This
->DirectDrawGlobal
.lpDDCBtmp
->HALDDMiscellaneous
;
227 DriverInfo
.dwExpectedSize
= sizeof(DDHAL_DDMISCELLANEOUSCALLBACKS
);
228 This
->HalInfo
.GetDriverInfo( &DriverInfo
);
231 /* Get the Miscellaneous2Callbacks */
233 DriverInfo.guidInfo = GUID_Miscellaneous2Callbacks;
234 DriverInfo.lpvData = &misc;
235 DriverInfo.dwExpectedSize = sizeof(DDHAL_DDMISCELLANEOUSCALLBACKS);
236 This->HalInfo.GetDriverInfo( &DriverInfo);
239 /* Get the MotionCompCallbacks */
240 DriverInfo
.guidInfo
= GUID_MotionCompCallbacks
;
241 DriverInfo
.lpvData
= &This
->DirectDrawGlobal
.lpDDCBtmp
->HALDDMotionComp
;
242 DriverInfo
.dwExpectedSize
= sizeof(DDHAL_DDMOTIONCOMPCALLBACKS
);
243 This
->HalInfo
.GetDriverInfo( &DriverInfo
);
246 /* Get the NonLocalVidMemCaps */
248 DriverInfo.guidInfo = GUID_NonLocalVidMemCaps;
249 DriverInfo.lpvData = &misc;
250 DriverInfo.dwExpectedSize = sizeof(DDHAL_DDMISCELLANEOUSCALLBACKS);
251 This->HalInfo.GetDriverInfo( &DriverInfo);
254 /* Get the NTCallbacks */
256 DriverInfo.guidInfo = GUID_NTCallbacks;
257 DriverInfo.lpvData = &misc;
258 DriverInfo.dwExpectedSize = sizeof(DDHAL_DDMISCELLANEOUSCALLBACKS);
259 This->HalInfo.GetDriverInfo( &DriverInfo);
262 /* Get the NTPrivateDriverCaps */
264 DriverInfo.guidInfo = GUID_NTPrivateDriverCaps;
265 DriverInfo.lpvData = &misc;
266 DriverInfo.dwExpectedSize = sizeof(DDHAL_DDMISCELLANEOUSCALLBACKS);
267 This->HalInfo.GetDriverInfo( &DriverInfo);
270 /* Get the UpdateNonLocalHeap */
272 DriverInfo.guidInfo = GUID_UpdateNonLocalHeap;
273 DriverInfo.lpvData = &misc;
274 DriverInfo.dwExpectedSize = sizeof(DDHAL_DDMISCELLANEOUSCALLBACKS);
275 This->HalInfo.GetDriverInfo( &DriverInfo);
278 /* Get the VideoPortCallbacks */
279 /* Problem with include files
280 DriverInfo.guidInfo = GUID_VideoPortCallbacks;
281 DriverInfo.lpvData = &This->DirectDrawGlobal.lpDDCBtmp->HALDDVideoPort;
282 DriverInfo.dwExpectedSize = sizeof(HALDDVideoPort);
283 This->HalInfo.GetDriverInfo( &DriverInfo);
287 /* Get the VideoPortCaps */
289 DriverInfo.guidInfo = GUID_VideoPortCaps;
290 DriverInfo.lpvData = &misc;
291 DriverInfo.dwExpectedSize = sizeof(DDHAL_DDMISCELLANEOUSCALLBACKS);
292 This->HalInfo.GetDriverInfo( &DriverInfo);
295 /* Get the ZPixelFormats */
297 DriverInfo.guidInfo = GUID_ZPixelFormats;
298 DriverInfo.lpvData = &misc;
299 DriverInfo.dwExpectedSize = sizeof(DDHAL_DDMISCELLANEOUSCALLBACKS);
300 This->HalInfo.GetDriverInfo( &DriverInfo);
304 /* FIXME add setup for one call ot get memmory */
307 /* now all insate of HAL is done and we hopply do not have forget anything*/
312 HRESULT
Hal_DirectDraw_SetCooperativeLevel (LPDIRECTDRAW7 iface
)
318 VOID
Hal_DirectDraw_Release (LPDIRECTDRAW7 iface
)
320 IDirectDrawImpl
* This
= (IDirectDrawImpl
*)iface
;
322 DdDeleteDirectDrawObject (&This
->DirectDrawGlobal
);
324 if(This
->HalInfo
.vmiData
.pvmList
)
325 HeapFree(GetProcessHeap(), 0, This
->HalInfo
.vmiData
.pvmList
);
326 if(This
->DirectDrawGlobal
.lpdwFourCC
)
327 HeapFree(GetProcessHeap(), 0, This
->DirectDrawGlobal
.lpdwFourCC
);
328 if(This
->DirectDrawGlobal
.lpZPixelFormats
)
329 HeapFree(GetProcessHeap(), 0, This
->DirectDrawGlobal
.lpZPixelFormats
);
330 if(((LPD3DHAL_GLOBALDRIVERDATA
)This
->DirectDrawGlobal
.lpD3DGlobalDriverData
)->lpTextureFormats
)
331 HeapFree(GetProcessHeap(), 0, ((LPD3DHAL_GLOBALDRIVERDATA
)This
->DirectDrawGlobal
.lpD3DGlobalDriverData
)->lpTextureFormats
);
333 if(This
->DirectDrawGlobal
.lpDDCBtmp
)
334 HeapFree(GetProcessHeap(), 0, This
->DirectDrawGlobal
.lpDDCBtmp
);
335 if(This
->DirectDrawGlobal
.lpD3DHALCallbacks
)
336 HeapFree(GetProcessHeap(), 0, (PVOID
)This
->DirectDrawGlobal
.lpD3DHALCallbacks
);
337 if(This
->DirectDrawGlobal
.lpD3DGlobalDriverData
)
338 HeapFree(GetProcessHeap(), 0, (PVOID
)This
->DirectDrawGlobal
.lpD3DGlobalDriverData
);