[HAL]
[reactos.git] / reactos / dll / directx / ddraw / rosdraw.h
1 #pragma once
2
3 /********* Includes *********/
4 #include <windows.h>
5 #include <stdio.h>
6 #include <ddraw.h>
7 #include <ddrawi.h>
8 #include <d3dhal.h>
9 #include <ddrawgdi.h>
10 #include <pseh/pseh.h>
11
12 #include <pseh/pseh2.h>
13
14 #include "Ddraw/ddraw.h"
15 #include "Surface/surface.h"
16 #include "Clipper/clipper.h"
17
18 #include "resource.h"
19
20 /* DirectDraw startup code only internal use */
21 extern DDRAWI_DIRECTDRAW_GBL ddgbl;
22 extern DDRAWI_DDRAWSURFACE_GBL ddSurfGbl;
23 extern WCHAR classname[128];
24 extern WNDCLASSW wnd_class;
25 extern CRITICAL_SECTION ddcs;
26 extern IDirectDraw7Vtbl DirectDraw7_Vtable;
27 extern IDirectDraw4Vtbl DirectDraw4_Vtable;
28 extern IDirectDraw2Vtbl DirectDraw2_Vtable;
29 extern IDirectDrawVtbl DirectDraw_Vtable;
30
31
32 extern IDirectDrawSurface7Vtbl DirectDrawSurface7_Vtable;
33 extern IDirectDrawSurface4Vtbl DirectDrawSurface4_Vtable;
34 extern IDirectDrawSurface3Vtbl DirectDrawSurface3_Vtable;
35 extern IDirectDrawSurface2Vtbl DirectDrawSurface2_Vtable;
36 extern IDirectDrawSurfaceVtbl DirectDrawSurface_Vtable;
37 extern IDirectDrawPaletteVtbl DirectDrawPalette_Vtable;
38 extern IDirectDrawClipperVtbl DirectDrawClipper_Vtable;
39 extern IDirectDrawColorControlVtbl DirectDrawColorControl_Vtable;
40 extern IDirectDrawGammaControlVtbl DirectDrawGammaControl_Vtable;
41 extern IDirectDrawKernelVtbl DirectDrawKernel_Vtable;
42 extern IDirectDrawSurfaceKernelVtbl DirectDrawSurfaceKernel_Vtable;
43
44 extern IDirect3DVtbl IDirect3D_Vtbl;
45 extern IDirect3D2Vtbl IDirect3D2_Vtbl;
46 extern IDirect3D3Vtbl IDirect3D3_Vtbl;
47 extern IDirect3D7Vtbl IDirect3D7_Vtbl;
48
49 /* Start up direct hal or hel
50 * iface = a pointer to the com object
51 * pGUID = guid hardware acclations or software acclation this can be NULL
52 * reenable = FALSE if we whant create a new directdraw com
53 * = TRUE if we really whant rebuild the whole com interface (not in use)
54 */
55
56 HRESULT WINAPI
57 StartDirectDraw(
58 LPDIRECTDRAW iface,
59 LPGUID pGUID,
60 BOOL reenable);
61
62 /* iface = a pointer to the com object
63 * reenable = FALSE / TRUE rebuld dx hal interface, this is need if we doing a mode change
64 */
65
66 HRESULT WINAPI
67 StartDirectDrawHal(
68 LPDIRECTDRAW iface,
69 BOOL reenable);
70
71 /* iface = a pointer to the com object
72 * reenable = FALSE / TRUE rebuld dx hel interface, this is need if we doing a mode change
73 */
74
75 HRESULT WINAPI
76 StartDirectDrawHel(
77 LPDIRECTDRAW iface,
78 BOOL reenable);
79
80 HRESULT WINAPI
81 Create_DirectDraw (
82 LPGUID pGUID,
83 LPDIRECTDRAW* pIface,
84 REFIID id,
85 BOOL ex);
86
87 HRESULT WINAPI
88 ReCreateDirectDraw(LPDIRECTDRAW iface);
89 HRESULT
90 Internal_CreateSurface(
91 LPDDRAWI_DIRECTDRAW_INT pDDraw,
92 LPDDSURFACEDESC2 pDDSD,
93 LPDDRAWI_DDRAWSURFACE_INT *ppSurf,
94 IUnknown *pUnkOuter);
95
96 /* convert DDSURFACEDESC to DDSURFACEDESC2 */
97 void CopyDDSurfDescToDDSurfDesc2(LPDDSURFACEDESC2 dst_pDesc, LPDDSURFACEDESC src_pDesc);
98
99 /* DirectDraw Cleanup code only internal use */
100 VOID Cleanup(LPDDRAWI_DIRECTDRAW_INT iface);
101
102 /* own macro to alloc memmory */
103
104 /*
105 #define DxHeapMemAlloc(m) HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, m)
106 #define DxHeapMemFree(p) HeapFree(GetProcessHeap(), 0, p); \
107 p = NULL;
108 */
109 #define DxHeapMemAlloc(p, m) { \
110 p = malloc(m); \
111 if (p != NULL) \
112 { \
113 ZeroMemory(p,m); \
114 } \
115 }
116 #define DxHeapMemFree(p) { \
117 free(p); \
118 p = NULL; \
119 }
120
121 /******** Main Object ********/
122
123 /* Public interface */
124 VOID WINAPI AcquireDDThreadLock();
125 VOID WINAPI ReleaseDDThreadLock();
126
127 ULONG WINAPI DirectDrawClipper_AddRef (LPDIRECTDRAWCLIPPER iface);
128 HRESULT WINAPI DirectDrawClipper_Initialize( LPDIRECTDRAWCLIPPER iface, LPDIRECTDRAW lpDD, DWORD dwFlags);
129
130 typedef struct DDRAWI_DDCOLORCONTROL_INT
131 {
132 LPVOID lpVtbl;
133 LPVOID lpLcl;
134 LPVOID lpLink;
135 DWORD dwIntRefCnt;
136 } DDRAWI_DDCOLORCONTROL_INT, *LPDDRAWI_DDCOLORCONTROL_INT;
137
138 typedef struct _DDRAWI_DDGAMMACONTROL_INT
139 {
140 LPVOID lpVtbl;
141 LPVOID lpLcl;
142 LPVOID lpLink;
143 DWORD dwIntRefCnt;
144 } DDRAWI_DDGAMMACONTROL_INT, *LPDDRAWI_DDGAMMACONTROL_INT;
145
146 typedef struct _DDRAWI_DDKERNEL_INT
147 {
148 LPVOID lpVtbl;
149 LPVOID lpLcl;
150 LPVOID lpLink;
151 DWORD dwIntRefCnt;
152 } DDRAWI_KERNEL_INT, *LPDDRAWI_KERNEL_INT;
153
154 typedef struct _DDRAWI_DDKERNELSURFACE_INT
155 {
156 LPVOID lpVtbl;
157 LPVOID lpLcl;
158 LPVOID lpLink;
159 DWORD dwIntRefCnt;
160 } _DDRAWI_DDKERNELSURFACE_INT, *LPDDRAWI_DDKERNELSURFACE_INT;
161
162 /* now to real info that are for private use and are our own */
163
164
165
166
167
168
169
170
171 /********* Prototypes **********/
172 VOID Hal_DirectDraw_Release (LPDIRECTDRAW7);
173
174 /* Setting for HEL should be move to ros special reg key ? */
175
176 /* setup how much graphic memory should hel be limit, set it now to 64MB */
177 #define HEL_GRAPHIC_MEMORY_MAX 67108864
178
179 /*********** Macros ***********/
180
181 /*
182 use this macro to close
183 down the debuger text complete
184 no debuging at all, it will
185 crash ms debuger in VS
186 */
187
188 //#define DX_WINDBG_trace()
189 //#define DX_STUB
190 //#define DX_STUB_DD_OK return DD_OK;
191 //#define DX_STUB_str(x)
192 //#define DX_WINDBG_trace_res
193
194
195 /*
196 Use this macro if you want deboug in visual studio or
197 if you have a program to look at the _INT struct from
198 ReactOS ddraw.dll or ms ddraw.dll, so you can see what
199 value ms are being setup.
200
201 This macro will create allot warings and can not be help when you compile
202 */
203
204
205 //#define DX_WINDBG_trace()
206 //#define DX_STUB
207 //#define DX_STUB_DD_OK return DD_OK;
208 //#define DX_STUB_str(x) printf("%s",x);
209 //#define DX_WINDBG_trace_res
210
211 /*
212 use this if want doing a trace from a program
213 like a game and ReactOS ddraw.dll in windows
214 so you can figout what going wrong and what
215 api are being call or if it hel or is it hal
216
217 This marco does not create warings when you compile
218 */
219
220 #define DX_STUB \
221 { \
222 static BOOL firstcall = TRUE; \
223 if (firstcall) \
224 { \
225 char buffer[1024]; \
226 sprintf ( buffer, "Function %s is not implemented yet (%s:%d)\n", __FUNCTION__,__FILE__,__LINE__ ); \
227 OutputDebugStringA(buffer); \
228 firstcall = FALSE; \
229 } \
230 } \
231 return DDERR_UNSUPPORTED;
232
233
234
235 #define DX_STUB_DD_OK \
236 { \
237 static BOOL firstcall = TRUE; \
238 if (firstcall) \
239 { \
240 char buffer[1024]; \
241 sprintf ( buffer, "Function %s is not implemented yet (%s:%d)\n", __FUNCTION__,__FILE__,__LINE__ ); \
242 OutputDebugStringA(buffer); \
243 firstcall = FALSE; \
244 } \
245 } \
246 return DD_OK;
247
248
249 #if 1
250 #define DX_STUB_str(x) \
251 { \
252 char buffer[1024]; \
253 sprintf ( buffer, "Function %s %s (%s:%d)\n", __FUNCTION__,x,__FILE__,__LINE__ ); \
254 OutputDebugStringA(buffer); \
255 }
256
257
258 #define DX_WINDBG_trace() \
259 static BOOL firstcallx = TRUE; \
260 if (firstcallx) \
261 { \
262 char buffer[1024]; \
263 sprintf ( buffer, "Enter Function %s (%s:%d)\n", __FUNCTION__,__FILE__,__LINE__ ); \
264 OutputDebugStringA(buffer); \
265 firstcallx = TRUE; \
266 }
267
268
269 #define DX_WINDBG_trace_res(width,height,bpp, freq) \
270 static BOOL firstcallxx = TRUE; \
271 if (firstcallxx) \
272 { \
273 char buffer[1024]; \
274 sprintf ( buffer, "Setmode have been req width=%ld, height=%ld bpp=%ld freq = %ld\n",width,height,bpp, freq); \
275 OutputDebugStringA(buffer); \
276 firstcallxx = TRUE; \
277 }
278 #else
279 #define DX_WINDBG_trace() //
280 #define DX_WINDBG_trace_res(width,height,bpp, freq) \\
281
282 #define DX_STUB_str(x) //
283
284 #endif