one more redisg adding a member that tells whih destions it is. it work pretty well.
[reactos.git] / reactos / dll / directx / ddraw / rosdraw.h
1 #ifndef __DDRAW_PRIVATE
2 #define __DDRAW_PRIVATE
3
4 /********* Includes *********/
5
6 #include <windows.h>
7 #include <stdio.h>
8 #include <ddraw.h>
9 #include <ddrawi.h>
10 #include <d3dhal.h>
11 #include <ddrawgdi.h>
12
13
14 /* this sturct are not longer in DDK
15 I did recrate it by looking diffent betwin DD_xx struct and _DDHAL strucrt
16 only diffent I found was the global pointer have been change from LPDDRAWI_DDRAWSURFACE_GBL
17 to DD_DIRECTDRAW_GLOBAL
18 */
19
20 typedef struct _DDHAL_MAPMEMORYDATA
21 {
22 LPDDRAWI_DDRAWSURFACE_GBL lpDD;
23 BOOL bMap;
24 HANDLE hProcess;
25 FLATPTR fpProcess;
26 HRESULT ddRVal;
27 } DDHAL_MAPMEMORYDATA;
28
29 /* own macro to alloc memmory */
30 #define DxHeapMemAlloc(m) HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, m)
31 #define DxHeapMemFree(p) HeapFree(GetProcessHeap(), 0, p);
32 /******** Main Object ********/
33
34 typedef struct
35 {
36 /* Setup the Vtbl COM table */
37 IDirectDraw7Vtbl* lpVtbl;
38 IDirectDraw4Vtbl* lpVtbl_v4;
39 IDirectDraw2Vtbl* lpVtbl_v2;
40 IDirectDrawVtbl* lpVtbl_v1;
41
42 /* The main struct that contain all info from the HAL and HEL */
43 HDC hdc;
44 DDRAWI_DIRECTDRAW_GBL mDDrawGlobal;
45 DDRAWI_DIRECTDRAW_LCL mDDrawLocal;
46 DDHALINFO mHALInfo;
47
48 DDHAL_CALLBACKS mCallbacks;
49 DDHAL_DDEXEBUFCALLBACKS mD3dBufferCallbacks;
50 D3DHAL_CALLBACKS mD3dCallbacks;
51 D3DHAL_GLOBALDRIVERDATA mD3dDriverData;
52
53 UINT mcModeInfos;
54 DDHALMODEINFO *mpModeInfos;
55
56 UINT mcvmList;
57 VIDMEM *mpvmList;
58
59 UINT mcFourCC;
60 DWORD *mpFourCC;
61
62 UINT mcTextures;
63 DDSURFACEDESC *mpTextures;
64
65
66
67
68 /* ExclusiveOwner */
69
70 DWORD cooperative_level;
71
72
73 BOOL InitializeDraw;
74
75 /* HEL stuff */
76 DWORD HELMemoryAvilable;
77
78 /* internal counter */
79 ULONG ref;
80
81 /* Callbacks info */
82 DDHAL_CREATESURFACEDATA mDdCreateSurface;
83 DDHAL_CANCREATESURFACEDATA mDdCanCreateSurface;
84
85 /* Primarey surface we must reach it from every where */
86 DDRAWI_DDRAWSURFACE_GBL mPrimaryGlobal;
87 DDRAWI_DDRAWSURFACE_MORE mPrimaryMore;
88 DDRAWI_DDRAWSURFACE_LCL mPrimaryLocal;
89 DDRAWI_DDRAWSURFACE_LCL *mpPrimaryLocals[1];
90 DDRAWI_DDRAWCLIPPER_LCL mPrimaryClipperLocal;
91 DDRAWI_DDRAWCLIPPER_GBL mPrimaryClipperGlobal;
92
93 DDSURFACEDESC mddsdPrimary;
94
95 } IDirectDrawImpl;
96
97 /******** Surface Object ********/
98 typedef struct
99 {
100
101 DDRAWI_DDRAWSURFACE_LCL *mpInUseSurfaceLocals[1];
102
103 DDRAWI_DDRAWSURFACE_GBL mSurfGlobal;
104 DDRAWI_DDRAWSURFACE_MORE mSurfMore;
105 DDRAWI_DDRAWSURFACE_LCL mSurfLocal;
106 DDRAWI_DDRAWSURFACE_LCL *mpSurfLocals[1];
107 DDRAWI_DDRAWCLIPPER_LCL mSurfClipperLocal;
108 DDRAWI_DDRAWCLIPPER_GBL mSurfClipperGlobal;
109
110 DDRAWI_DDRAWSURFACE_GBL mOverlayGlobal;
111 DDRAWI_DDRAWSURFACE_LCL mOverlayLocal[6];
112 DDRAWI_DDRAWSURFACE_LCL *mpOverlayLocals[6];
113 DDRAWI_DDRAWSURFACE_MORE mOverlayMore[6];
114
115 DDSURFACEDESC mddsdOverlay;
116
117 } DxSurf;
118
119 typedef struct
120 {
121 IDirectDrawSurface7Vtbl* lpVtbl;
122 IDirectDrawSurface3Vtbl* lpVtbl_v3;
123
124 IDirectDrawImpl* Owner;
125
126 DDRAWI_DDRAWSURFACE_GBL Global;
127 DDRAWI_DDRAWSURFACE_MORE More;
128 DDRAWI_DDRAWSURFACE_LCL Local;
129 DDRAWI_DDRAWSURFACE_LCL *pLocal[2];
130 DDSURFACEDESC ddsd;
131
132 DxSurf *Surf;
133
134 } IDirectDrawSurfaceImpl;
135
136
137
138
139
140 /******** Clipper Object ********/
141
142 typedef struct
143 {
144 IDirectDrawClipperVtbl* lpVtbl;
145 LONG ref;
146
147 IDirectDrawImpl* owner;
148
149 } IDirectDrawClipperImpl;
150
151 /******** Palette Object ********/
152
153 typedef struct
154 {
155 IDirectDrawPaletteVtbl* lpVtbl;
156 LONG ref;
157
158 IDirectDrawImpl* owner;
159
160 } IDirectDrawPaletteImpl;
161
162 /*********** VTables ************/
163
164 extern IDirectDraw7Vtbl DirectDraw7_Vtable;
165 extern IDirectDrawVtbl DDRAW_IDirectDraw_VTable;
166 extern IDirectDraw2Vtbl DDRAW_IDirectDraw2_VTable;
167 extern IDirectDraw4Vtbl DDRAW_IDirectDraw4_VTable;
168
169 extern IDirectDrawSurface7Vtbl DirectDrawSurface7_Vtable;
170 extern IDirectDrawSurface3Vtbl DDRAW_IDDS3_Thunk_VTable;
171
172 extern IDirectDrawPaletteVtbl DirectDrawPalette_Vtable;
173 extern IDirectDrawClipperVtbl DirectDrawClipper_Vtable;
174 extern IDirectDrawColorControlVtbl DirectDrawColorControl_Vtable;
175 extern IDirectDrawGammaControlVtbl DirectDrawGammaControl_Vtable;
176
177 /********* Prototypes **********/
178
179 HRESULT WINAPI Main_DirectDraw_GetAvailableVidMem(LPDIRECTDRAW7 iface, LPDDSCAPS2 ddscaps, LPDWORD total, LPDWORD free);
180
181 HRESULT Hal_DirectDraw_Initialize (LPDIRECTDRAW7 );
182 HRESULT Hal_DirectDraw_SetCooperativeLevel (LPDIRECTDRAW7 );
183 VOID Hal_DirectDraw_Release (LPDIRECTDRAW7 );
184 HRESULT Hal_DirectDraw_GetAvailableVidMem(LPDIRECTDRAW7, LPDDSCAPS2, LPDWORD, LPDWORD );
185 HRESULT Hal_DirectDraw_WaitForVerticalBlank(LPDIRECTDRAW7, DWORD, HANDLE );
186 HRESULT Hal_DirectDraw_GetScanLine(LPDIRECTDRAW7 , LPDWORD );
187 HRESULT Hal_DirectDraw_FlipToGDISurface(LPDIRECTDRAW7 );
188 HRESULT Hal_DirectDraw_SetDisplayMode (LPDIRECTDRAW7, DWORD, DWORD, DWORD, DWORD, DWORD );
189 HRESULT Hal_DDrawSurface_Blt(LPDIRECTDRAWSURFACE7, LPRECT, LPDIRECTDRAWSURFACE7, LPRECT, DWORD, LPDDBLTFX );
190 HRESULT Hal_DDrawSurface_Lock(LPDIRECTDRAWSURFACE7 iface, LPRECT prect, LPDDSURFACEDESC2 pDDSD, DWORD flags, HANDLE event);
191 HRESULT Hal_DDrawSurface_Flip(LPDIRECTDRAWSURFACE7 iface, LPDIRECTDRAWSURFACE7 override, DWORD dwFlags);
192 HRESULT Hal_DDrawSurface_SetColorKey (LPDIRECTDRAWSURFACE7 iface, DWORD dwFlags, LPDDCOLORKEY pCKey);
193 HRESULT Hal_DDrawSurface_Unlock(LPDIRECTDRAWSURFACE7 iface, LPRECT pRect);
194 HRESULT Hal_DDrawSurface_GetBltStatus(LPDIRECTDRAWSURFACE7 iface, DWORD dwFlags);
195 HRESULT Hal_DDrawSurface_UpdateOverlayDisplay (LPDIRECTDRAWSURFACE7 iface, DWORD dwFlags);
196
197 HRESULT Hel_DirectDraw_Initialize (LPDIRECTDRAW7 );
198 HRESULT Hel_DirectDraw_SetCooperativeLevel (LPDIRECTDRAW7 );
199 VOID Hel_DirectDraw_Release (LPDIRECTDRAW7 );
200 HRESULT Hel_DirectDraw_GetAvailableVidMem(LPDIRECTDRAW7 , LPDDSCAPS2 ddsaps, LPDWORD , LPDWORD );
201 HRESULT Hel_DirectDraw_WaitForVerticalBlank(LPDIRECTDRAW7, DWORD, HANDLE );
202 HRESULT Hel_DirectDraw_GetScanLine(LPDIRECTDRAW7 , LPDWORD );
203 HRESULT Hel_DirectDraw_FlipToGDISurface(LPDIRECTDRAW7 );
204 HRESULT Hel_DirectDraw_SetDisplayMode (LPDIRECTDRAW7 , DWORD , DWORD ,DWORD , DWORD , DWORD );
205 HRESULT Hel_DDrawSurface_Blt(LPDIRECTDRAWSURFACE7, LPRECT, LPDIRECTDRAWSURFACE7, LPRECT, DWORD, LPDDBLTFX );
206 HRESULT Hel_DDrawSurface_Lock(LPDIRECTDRAWSURFACE7 iface, LPRECT prect, LPDDSURFACEDESC2 pDDSD, DWORD flags, HANDLE event);
207 HRESULT Hel_DDrawSurface_SetColorKey (LPDIRECTDRAWSURFACE7 iface, DWORD dwFlags, LPDDCOLORKEY pCKey);
208 HRESULT Hel_DDrawSurface_Unlock(LPDIRECTDRAWSURFACE7 iface, LPRECT pRect);
209 HRESULT Hel_DDrawSurface_GetBltStatus(LPDIRECTDRAWSURFACE7 iface, DWORD dwFlags);
210 HRESULT Hel_DDrawSurface_Flip(LPDIRECTDRAWSURFACE7 iface, LPDIRECTDRAWSURFACE7 override, DWORD dwFlags);
211 HRESULT Hel_DDrawSurface_UpdateOverlayDisplay (LPDIRECTDRAWSURFACE7 iface, DWORD dwFlags);
212
213 /* HEL CALLBACK */
214 DWORD CALLBACK HelDdCanCreateSurface(LPDDHAL_CANCREATESURFACEDATA pccsd);
215 DWORD CALLBACK HelDdCreateSurface(LPDDHAL_CREATESURFACEDATA lpCreateSurface);
216
217
218 /* Setting for HEL should be move to ros special reg key ? */
219
220 /* setup how much graphic memory should hel be limit, set it now to 64MB */
221 #define HEL_GRAPHIC_MEMORY_MAX 67108864
222
223 /*********** Macros ***********/
224
225 #define DX_STUB \
226 static BOOL firstcall = TRUE; \
227 if (firstcall) \
228 { \
229 char buffer[1024]; \
230 sprintf ( buffer, "Function %s is not implemented yet (%s:%d)\n", __FUNCTION__,__FILE__,__LINE__ ); \
231 OutputDebugStringA(buffer); \
232 firstcall = FALSE; \
233 } \
234 return DDERR_UNSUPPORTED;
235
236 #define DX_STUB_str(x) \
237 static BOOL firstcall = TRUE; \
238 if (firstcall) \
239 { \
240 char buffer[1024]; \
241 sprintf ( buffer, "Function %s %s (%s:%d)\n", __FUNCTION__,x,__FILE__,__LINE__ ); \
242 OutputDebugStringA(buffer); \
243 firstcall = FALSE; \
244 }
245
246 //#define DX_WINDBG_trace()
247
248
249 #define DX_WINDBG_trace() \
250 static BOOL firstcallx = TRUE; \
251 if (firstcallx) \
252 { \
253 char buffer[1024]; \
254 sprintf ( buffer, "Enter Function %s (%s:%d)\n", __FUNCTION__,__FILE__,__LINE__ ); \
255 OutputDebugStringA(buffer); \
256 firstcallx = TRUE; \
257 }
258
259
260 #define DX_WINDBG_trace_res(width,height,bpp) \
261 static BOOL firstcallxx = TRUE; \
262 if (firstcallxx) \
263 { \
264 char buffer[1024]; \
265 sprintf ( buffer, "Setmode have been req width=%d, height=%d bpp=%d\n",width,height,bpp); \
266 OutputDebugStringA(buffer); \
267 firstcallxx = FALSE; \
268 }
269
270 #endif /* __DDRAW_PRIVATE */