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 DDHAL_GETDRIVERINFODATA DriverInfo
;
135 memset(&DriverInfo
,0, sizeof(DDHAL_GETDRIVERINFODATA
));
136 DriverInfo
.dwSize
= sizeof(DDHAL_GETDRIVERINFODATA
);
138 /* Get ColorControlCallbacks */
139 DriverInfo
.guidInfo
= GUID_ColorControlCallbacks
;
140 DriverInfo
.lpvData
= &This
->DirectDrawGlobal
.lpDDCBtmp
->HALDDColorControl
;
141 DriverInfo
.dwExpectedSize
= sizeof(DDHAL_DDCOLORCONTROLCALLBACKS
);
142 This
->HalInfo
.GetDriverInfo( &DriverInfo
);
145 /* Get the GUID_D3DCallbacks callback */
147 /* Problem with include files
148 DDHAL_DDMISCELLANEOUSCALLBACKS misc;
149 DriverInfo.guidInfo = GUID_D3DCallbacks;
150 DriverInfo.lpvData = &misc;
151 DriverInfo.dwExpectedSize = sizeof(DDHAL_DDMISCELLANEOUSCALLBACKS);
152 This->HalInfo.GetDriverInfo( &DriverInfo);*/
154 /* Get the D3DCallbacks2 */
155 /* do we need alloc memmory for This->DirectDrawGlobal.lpD3DHALCallbacks2 */
156 DriverInfo
.guidInfo
= GUID_D3DCallbacks2
;
157 DriverInfo
.lpvData
= &This
->DirectDrawGlobal
.lpD3DHALCallbacks2
;
158 DriverInfo
.dwExpectedSize
= sizeof(D3DHAL_CALLBACKS2
);
159 This
->HalInfo
.GetDriverInfo( &DriverInfo
);
162 /* Get the D3DCallbacks3 */
164 DriverInfo.guidInfo = GUID_D3DCallbacks3;
165 DriverInfo.lpvData = &misc;
166 DriverInfo.dwExpectedSize = sizeof(DDHAL_DDMISCELLANEOUSCALLBACKS);
167 This->HalInfo.GetDriverInfo( &DriverInfo);
170 /* Get the misc callback */
171 /* Problem with include files
172 DriverInfo.guidInfo = GUID_D3DCaps;
173 DriverInfo.lpvData = &misc;
174 DriverInfo.dwExpectedSize = sizeof(DDHAL_DDMISCELLANEOUSCALLBACKS);
175 This->HalInfo.GetDriverInfo( &DriverInfo);
178 /* Get the D3DExtendedCaps */
180 DriverInfo.guidInfo = GUID_D3DExtendedCaps;
181 DriverInfo.lpvData = &misc;
182 DriverInfo.dwExpectedSize = sizeof(DDHAL_DDMISCELLANEOUSCALLBACKS);
183 This->HalInfo.GetDriverInfo( &DriverInfo);
186 /* Get the D3DParseUnknownCommandCallback */
188 DriverInfo.guidInfo = GUID_D3DParseUnknownCommandCallback;
189 DriverInfo.lpvData = &misc;
190 DriverInfo.dwExpectedSize = sizeof(DDHAL_DDMISCELLANEOUSCALLBACKS);
191 This->HalInfo.GetDriverInfo( &DriverInfo);
194 /* Get the GetHeapAlignment */
196 DriverInfo.guidInfo = GUID_GetHeapAlignment;
197 DriverInfo.lpvData = &misc;
198 DriverInfo.dwExpectedSize = sizeof(DDHAL_DDMISCELLANEOUSCALLBACKS);
199 This->HalInfo.GetDriverInfo( &DriverInfo);
202 /* Get the KernelCallbacks */
203 DriverInfo
.guidInfo
= GUID_KernelCallbacks
;
204 DriverInfo
.lpvData
= &This
->DirectDrawGlobal
.lpDDCBtmp
->HALDDKernel
;
205 DriverInfo
.dwExpectedSize
= sizeof(DDHAL_DDKERNELCALLBACKS
);
206 This
->HalInfo
.GetDriverInfo( &DriverInfo
);
209 /* Get the KernelCaps */
211 DriverInfo.guidInfo = GUID_KernelCaps;
212 DriverInfo.lpvData = &misc;
213 DriverInfo.dwExpectedSize = sizeof(DDHAL_DDMISCELLANEOUSCALLBACKS);
214 This->HalInfo.GetDriverInfo( &DriverInfo);
217 /* Get the MiscellaneousCallbacks */
218 DriverInfo
.guidInfo
= GUID_MiscellaneousCallbacks
;
219 DriverInfo
.lpvData
= &This
->DirectDrawGlobal
.lpDDCBtmp
->HALDDMiscellaneous
;
220 DriverInfo
.dwExpectedSize
= sizeof(DDHAL_DDMISCELLANEOUSCALLBACKS
);
221 This
->HalInfo
.GetDriverInfo( &DriverInfo
);
224 /* Get the Miscellaneous2Callbacks */
226 DriverInfo.guidInfo = GUID_Miscellaneous2Callbacks;
227 DriverInfo.lpvData = &misc;
228 DriverInfo.dwExpectedSize = sizeof(DDHAL_DDMISCELLANEOUSCALLBACKS);
229 This->HalInfo.GetDriverInfo( &DriverInfo);
232 /* Get the MotionCompCallbacks */
234 DriverInfo
.guidInfo
= GUID_MotionCompCallbacks
;
235 DriverInfo
.lpvData
= &This
->DirectDrawGlobal
.lpDDCBtmp
->HALDDMotionComp
;
236 DriverInfo
.dwExpectedSize
= sizeof(DDHAL_DDMOTIONCOMPCALLBACKS
);
237 This
->HalInfo
.GetDriverInfo( &DriverInfo
);
240 /* Get the NonLocalVidMemCaps */
242 DriverInfo.guidInfo = GUID_NonLocalVidMemCaps;
243 DriverInfo.lpvData = &misc;
244 DriverInfo.dwExpectedSize = sizeof(DDHAL_DDMISCELLANEOUSCALLBACKS);
245 This->HalInfo.GetDriverInfo( &DriverInfo);
248 /* Get the NTCallbacks */
250 DriverInfo.guidInfo = GUID_NTCallbacks;
251 DriverInfo.lpvData = &misc;
252 DriverInfo.dwExpectedSize = sizeof(DDHAL_DDMISCELLANEOUSCALLBACKS);
253 This->HalInfo.GetDriverInfo( &DriverInfo);
256 /* Get the NTPrivateDriverCaps */
258 DriverInfo.guidInfo = GUID_NTPrivateDriverCaps;
259 DriverInfo.lpvData = &misc;
260 DriverInfo.dwExpectedSize = sizeof(DDHAL_DDMISCELLANEOUSCALLBACKS);
261 This->HalInfo.GetDriverInfo( &DriverInfo);
264 /* Get the UpdateNonLocalHeap */
266 DriverInfo.guidInfo = GUID_UpdateNonLocalHeap;
267 DriverInfo.lpvData = &misc;
268 DriverInfo.dwExpectedSize = sizeof(DDHAL_DDMISCELLANEOUSCALLBACKS);
269 This->HalInfo.GetDriverInfo( &DriverInfo);
272 /* Get the VideoPortCallbacks */
273 /* Problem with include files
274 DriverInfo.guidInfo = GUID_VideoPortCallbacks;
275 DriverInfo.lpvData = &This->DirectDrawGlobal.lpDDCBtmp->HALDDVideoPort;
276 DriverInfo.dwExpectedSize = sizeof(HALDDVideoPort);
277 This->HalInfo.GetDriverInfo( &DriverInfo);
281 /* Get the VideoPortCaps */
283 DriverInfo.guidInfo = GUID_VideoPortCaps;
284 DriverInfo.lpvData = &misc;
285 DriverInfo.dwExpectedSize = sizeof(DDHAL_DDMISCELLANEOUSCALLBACKS);
286 This->HalInfo.GetDriverInfo( &DriverInfo);
289 /* Get the ZPixelFormats */
291 DriverInfo.guidInfo = GUID_ZPixelFormats;
292 DriverInfo.lpvData = &misc;
293 DriverInfo.dwExpectedSize = sizeof(DDHAL_DDMISCELLANEOUSCALLBACKS);
294 This->HalInfo.GetDriverInfo( &DriverInfo);
298 /* FIXME add setup for one call ot get memmory */
301 /* now all insate of HAL is done and we hopply do not have forget anything*/
306 HRESULT
Hal_DirectDraw_SetCooperativeLevel (LPDIRECTDRAW7 iface
)
312 VOID
Hal_DirectDraw_Release (LPDIRECTDRAW7 iface
)
314 IDirectDrawImpl
* This
= (IDirectDrawImpl
*)iface
;
316 DdDeleteDirectDrawObject (&This
->DirectDrawGlobal
);
318 if(This
->HalInfo
.vmiData
.pvmList
)
319 HeapFree(GetProcessHeap(), 0, This
->HalInfo
.vmiData
.pvmList
);
320 if(This
->DirectDrawGlobal
.lpdwFourCC
)
321 HeapFree(GetProcessHeap(), 0, This
->DirectDrawGlobal
.lpdwFourCC
);
322 if(This
->DirectDrawGlobal
.lpZPixelFormats
)
323 HeapFree(GetProcessHeap(), 0, This
->DirectDrawGlobal
.lpZPixelFormats
);
324 if(((LPD3DHAL_GLOBALDRIVERDATA
)This
->DirectDrawGlobal
.lpD3DGlobalDriverData
)->lpTextureFormats
)
325 HeapFree(GetProcessHeap(), 0, ((LPD3DHAL_GLOBALDRIVERDATA
)This
->DirectDrawGlobal
.lpD3DGlobalDriverData
)->lpTextureFormats
);
327 if(This
->DirectDrawGlobal
.lpDDCBtmp
)
328 HeapFree(GetProcessHeap(), 0, This
->DirectDrawGlobal
.lpDDCBtmp
);
329 if(This
->DirectDrawGlobal
.lpD3DHALCallbacks
)
330 HeapFree(GetProcessHeap(), 0, (PVOID
)This
->DirectDrawGlobal
.lpD3DHALCallbacks
);
331 if(This
->DirectDrawGlobal
.lpD3DGlobalDriverData
)
332 HeapFree(GetProcessHeap(), 0, (PVOID
)This
->DirectDrawGlobal
.lpD3DGlobalDriverData
);