1 /*
2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS kernel
4 * PURPOSE: Native DirectDraw implementation
5 * FILE: win32ss/reactx/ntddraw/ddsurf.c
6 * PROGRAMER: Magnus Olsen (greatlord@reactos.org)
7 * REVISION HISTORY:
8 * 19/7-2006 Magnus Olsen
9 */
10
11 #include <win32k.h>
12
13 // #define NDEBUG
14 #include <debug.h>
15
16 /************************************************************************/
17 /* NtGdiDdDestroySurface */
18 /************************************************************************/
19 DWORD
20 APIENTRY
NtGdiDdDestroySurface(HANDLE hSurface,BOOL bRealDestroy)21 NtGdiDdDestroySurface(HANDLE hSurface, BOOL bRealDestroy)
22 {
23 PGD_DXDDDESTROYSURFACE pfnDdDestroySurface = (PGD_DXDDDESTROYSURFACE)gpDxFuncs[DXG_INDEX_DxDdDestroySurface].pfn;
24
25 if (pfnDdDestroySurface == NULL)
26 {
27 DPRINT1("Warning: no pfnDdDestroySurface\n");
28 return DDHAL_DRIVER_NOTHANDLED;
29 }
30
31 DPRINT("Calling dxg.sys pfnDdDestroySurface\n");
32 return pfnDdDestroySurface(hSurface, bRealDestroy);
33 }
34
35 /************************************************************************/
36 /* NtGdiDdFlip */
37 /************************************************************************/
38 DWORD
39 APIENTRY
NtGdiDdFlip(HANDLE hSurfaceCurrent,HANDLE hSurfaceTarget,HANDLE hSurfaceCurrentLeft,HANDLE hSurfaceTargetLeft,PDD_FLIPDATA puFlipData)40 NtGdiDdFlip(HANDLE hSurfaceCurrent,
41 HANDLE hSurfaceTarget,
42 HANDLE hSurfaceCurrentLeft,
43 HANDLE hSurfaceTargetLeft,
44 PDD_FLIPDATA puFlipData)
45 {
46 PGD_DXDDFLIP pfnDdDdFlip = (PGD_DXDDFLIP)gpDxFuncs[DXG_INDEX_DxDdFlip].pfn;
47
48 if (pfnDdDdFlip == NULL)
49 {
50 DPRINT1("Warning: no pfnDdDdFlip\n");
51 return DDHAL_DRIVER_NOTHANDLED;
52 }
53
54 DPRINT("Calling dxg.sys pfnDdDdFlip\n");
55 return pfnDdDdFlip(hSurfaceCurrent, hSurfaceTarget, hSurfaceCurrentLeft, hSurfaceTargetLeft, puFlipData);
56 }
57
58 /************************************************************************/
59 /* NtGdiDdUnlock */
60 /************************************************************************/
61 DWORD
62 APIENTRY
NtGdiDdLock(HANDLE hSurface,PDD_LOCKDATA puLockData,HDC hdcClip)63 NtGdiDdLock(HANDLE hSurface,
64 PDD_LOCKDATA puLockData,
65 HDC hdcClip)
66 {
67 PGD_DXDDLOCK pfnDdLock = (PGD_DXDDLOCK)gpDxFuncs[DXG_INDEX_DxDdLock].pfn;
68
69 if (pfnDdLock == NULL)
70 {
71 DPRINT1("Warning: no pfnDdLock\n");
72 return DDHAL_DRIVER_NOTHANDLED;
73 }
74
75 DPRINT("Calling dxg.sys pfnDdLock\n");
76 return pfnDdLock(hSurface, puLockData, hdcClip);
77 }
78
79 /************************************************************************/
80 /* NtGdiDdunlock */
81 /************************************************************************/
82 DWORD
83 APIENTRY
NtGdiDdUnlock(HANDLE hSurface,PDD_UNLOCKDATA puUnlockData)84 NtGdiDdUnlock(HANDLE hSurface,
85 PDD_UNLOCKDATA puUnlockData)
86 {
87 PGD_DXDDUNLOCK pfnDdUnlock = (PGD_DXDDUNLOCK)gpDxFuncs[DXG_INDEX_DxDdUnlock].pfn;
88
89 if (pfnDdUnlock == NULL)
90 {
91 DPRINT1("Warning: no pfnDdUnlock\n");
92 return DDHAL_DRIVER_NOTHANDLED;
93 }
94
95 DPRINT("Calling dxg.sys pfnDdUnlock\n");
96 return pfnDdUnlock(hSurface, puUnlockData);
97 }
98
99 /************************************************************************/
100 /* NtGdiDdBlt */
101 /************************************************************************/
102 DWORD
103 APIENTRY
NtGdiDdBlt(HANDLE hSurfaceDest,HANDLE hSurfaceSrc,PDD_BLTDATA puBltData)104 NtGdiDdBlt(HANDLE hSurfaceDest,
105 HANDLE hSurfaceSrc,
106 PDD_BLTDATA puBltData)
107 {
108 PGD_DDBLT pfnDdBlt = (PGD_DDBLT)gpDxFuncs[DXG_INDEX_DxDdBlt].pfn;
109
110 if (pfnDdBlt == NULL)
111 {
112 DPRINT1("Warning: no pfnDdBlt\n");
113 return DDHAL_DRIVER_NOTHANDLED;
114 }
115
116 DPRINT("Calling dxg.sys pfnDdBlt\n");
117 return pfnDdBlt(hSurfaceDest,hSurfaceSrc,puBltData);
118 }
119
120 /************************************************************************/
121 /* NtGdiDdSetColorKey */
122 /************************************************************************/
123 DWORD
124 APIENTRY
NtGdiDdSetColorKey(HANDLE hSurface,PDD_SETCOLORKEYDATA puSetColorKeyData)125 NtGdiDdSetColorKey(HANDLE hSurface,
126 PDD_SETCOLORKEYDATA puSetColorKeyData)
127 {
128 PGD_DXDDSETCOLORKEY pfnDdSetColorKey = (PGD_DXDDSETCOLORKEY)gpDxFuncs[DXG_INDEX_DxDdSetColorKey].pfn;
129
130 if (pfnDdSetColorKey == NULL)
131 {
132 DPRINT1("Warning: no pfnDdSetColorKey\n");
133 return DDHAL_DRIVER_NOTHANDLED;
134 }
135
136 DPRINT("Calling dxg.sys pfnDdSetColorKey\n");
137 return pfnDdSetColorKey(hSurface,puSetColorKeyData);
138 }
139
140 /************************************************************************/
141 /* NtGdiDdAddAttachedSurface */
142 /************************************************************************/
143 DWORD
144 APIENTRY
NtGdiDdAddAttachedSurface(HANDLE hSurface,HANDLE hSurfaceAttached,PDD_ADDATTACHEDSURFACEDATA puAddAttachedSurfaceData)145 NtGdiDdAddAttachedSurface(HANDLE hSurface,
146 HANDLE hSurfaceAttached,
147 PDD_ADDATTACHEDSURFACEDATA puAddAttachedSurfaceData)
148 {
149 PGD_DDADDATTACHEDSURFACE pfnDdAddAttachedSurface = (PGD_DDADDATTACHEDSURFACE)gpDxFuncs[DXG_INDEX_DxDdAddAttachedSurface].pfn;
150
151 if (pfnDdAddAttachedSurface == NULL)
152 {
153 DPRINT1("Warning: no pfnDdAddAttachedSurface\n");
154 return DDHAL_DRIVER_NOTHANDLED;
155 }
156
157 DPRINT("Calling dxg.sys pfnDdAddAttachedSurface\n");
158 return pfnDdAddAttachedSurface(hSurface,hSurfaceAttached,puAddAttachedSurfaceData);
159 }
160
161 /************************************************************************/
162 /* NtGdiDdGetBltStatus */
163 /************************************************************************/
164 DWORD
165 APIENTRY
NtGdiDdGetBltStatus(HANDLE hSurface,PDD_GETBLTSTATUSDATA puGetBltStatusData)166 NtGdiDdGetBltStatus(HANDLE hSurface,
167 PDD_GETBLTSTATUSDATA puGetBltStatusData)
168 {
169 PGD_DXDDGETBLTSTATUS pfnDdGetBltStatus = (PGD_DXDDGETBLTSTATUS)gpDxFuncs[DXG_INDEX_DxDdGetBltStatus].pfn;
170
171 if (pfnDdGetBltStatus == NULL)
172 {
173 DPRINT1("Warning: no pfnDdGetBltStatus\n");
174 return DDHAL_DRIVER_NOTHANDLED;
175 }
176
177 DPRINT("Calling dxg.sys pfnDdGetBltStatus\n");
178 return pfnDdGetBltStatus(hSurface,puGetBltStatusData);
179 }
180
181 /************************************************************************/
182 /* NtGdiDdGetFlipStatus */
183 /************************************************************************/
184 DWORD
185 APIENTRY
NtGdiDdGetFlipStatus(HANDLE hSurface,PDD_GETFLIPSTATUSDATA puGetFlipStatusData)186 NtGdiDdGetFlipStatus(HANDLE hSurface,
187 PDD_GETFLIPSTATUSDATA puGetFlipStatusData)
188 {
189 PGD_DXDDGETFLIPSTATUS pfnDdGetFlipStatus = (PGD_DXDDGETFLIPSTATUS)gpDxFuncs[DXG_INDEX_DxDdGetFlipStatus].pfn;
190
191 if (pfnDdGetFlipStatus == NULL)
192 {
193 DPRINT1("Warning: no pfnDdGetFlipStatus\n");
194 return DDHAL_DRIVER_NOTHANDLED;
195 }
196
197 DPRINT("Calling dxg.sys pfnDdGetFlipStatus\n");
198 return pfnDdGetFlipStatus(hSurface,puGetFlipStatusData);
199 }
200
201 /************************************************************************/
202 /* NtGdiDdUpdateOverlay */
203 /************************************************************************/
204 DWORD
205 APIENTRY
NtGdiDdUpdateOverlay(HANDLE hSurfaceDestination,HANDLE hSurfaceSource,PDD_UPDATEOVERLAYDATA puUpdateOverlayData)206 NtGdiDdUpdateOverlay(HANDLE hSurfaceDestination,
207 HANDLE hSurfaceSource,
208 PDD_UPDATEOVERLAYDATA puUpdateOverlayData)
209 {
210 PGD_DXDDUPDATEOVERLAY pfnDdUpdateOverlay = (PGD_DXDDUPDATEOVERLAY)gpDxFuncs[DXG_INDEX_DxDdUpdateOverlay].pfn;
211
212 if (pfnDdUpdateOverlay == NULL)
213 {
214 DPRINT1("Warning: no pfnDdUpdateOverlay\n");
215 return DDHAL_DRIVER_NOTHANDLED;
216 }
217
218 DPRINT("Calling dxg.sys pfnDdUpdateOverlay\n");
219 return pfnDdUpdateOverlay(hSurfaceDestination,hSurfaceSource,puUpdateOverlayData);
220 }
221
222 /************************************************************************/
223 /* NtGdiDdSetOverlayPosition */
224 /************************************************************************/
225 DWORD
226 APIENTRY
NtGdiDdSetOverlayPosition(HANDLE hSurfaceSource,HANDLE hSurfaceDestination,PDD_SETOVERLAYPOSITIONDATA puSetOverlayPositionData)227 NtGdiDdSetOverlayPosition(HANDLE hSurfaceSource,
228 HANDLE hSurfaceDestination,
229 PDD_SETOVERLAYPOSITIONDATA puSetOverlayPositionData)
230 {
231 PGD_DXDDSETOVERLAYPOSITION pfnDdSetOverlayPosition = (PGD_DXDDSETOVERLAYPOSITION)gpDxFuncs[DXG_INDEX_DxDdSetOverlayPosition].pfn;
232
233 if (pfnDdSetOverlayPosition == NULL)
234 {
235 DPRINT1("Warning: no pfnDdSetOverlayPosition\n");
236 return DDHAL_DRIVER_NOTHANDLED;
237 }
238
239 DPRINT("Calling dxg.sys pfnDdSetOverlayPosition\n");
240 return pfnDdSetOverlayPosition(hSurfaceSource,hSurfaceDestination,puSetOverlayPositionData);
241 }
242
243 /************************************************************************/
244 /* This is not part of the ddsurface interface but it */
245 /* deals with the surface */
246 /************************************************************************/
247
248
249 /************************************************************************/
250 /* NtGdiDdAlphaBlt */
251 /************************************************************************/
252 DWORD
253 APIENTRY
NtGdiDdAlphaBlt(HANDLE hSurfaceDest,HANDLE hSurfaceSrc,PDD_BLTDATA puBltData)254 NtGdiDdAlphaBlt(HANDLE hSurfaceDest,
255 HANDLE hSurfaceSrc,
256 PDD_BLTDATA puBltData)
257 {
258 PGD_DDALPHABLT pfnDdAlphaBlt = (PGD_DDALPHABLT)gpDxFuncs[DXG_INDEX_DxDdAlphaBlt].pfn;
259
260 if (pfnDdAlphaBlt == NULL)
261 {
262 DPRINT1("Warning: no pfnDdAlphaBlt\n");
263 return DDHAL_DRIVER_NOTHANDLED;
264 }
265
266 DPRINT("Calling dxg.sys pfnDdAlphaBlt\n");
267 return pfnDdAlphaBlt(hSurfaceDest,hSurfaceSrc,puBltData);
268 }
269
270 /************************************************************************/
271 /* NtGdiDdAttachSurface */
272 /************************************************************************/
273 BOOL
274 APIENTRY
NtGdiDdAttachSurface(HANDLE hSurfaceFrom,HANDLE hSurfaceTo)275 NtGdiDdAttachSurface(HANDLE hSurfaceFrom,
276 HANDLE hSurfaceTo
277 )
278 {
279 PGD_DDATTACHSURFACE pfnDdAttachSurface = (PGD_DDATTACHSURFACE)gpDxFuncs[DXG_INDEX_DxDdAttachSurface].pfn;
280
281 if (pfnDdAttachSurface == NULL)
282 {
283 DPRINT1("Warning: no pfnDdAttachSurface\n");
284 return DDHAL_DRIVER_NOTHANDLED;
285 }
286
287 DPRINT("Calling dxg.sys pfnDdAttachSurface\n");
288 return pfnDdAttachSurface(hSurfaceFrom,hSurfaceTo);
289 }
290
291 /************************************************************************/
292 /* NtGdiDdUnattachSurface */
293 /************************************************************************/
294 /* Note: MSDN protypes is VOID APIENTRY NtGdiDdUnattachSurface(HANDLE hSurface, HANDLE hSurfaceAttached)
295 But it say it return either DDHAL_DRIVER_NOTHANDLED or DDHAL_DRIVER_HANDLED
296 so I guess it is a typo in MSDN for this prototype for the info contradicts itself.
297 */
298 NTSTATUS
299 APIENTRY
NtGdiDdUnattachSurface(HANDLE hSurface,HANDLE hSurfaceAttached)300 NtGdiDdUnattachSurface(HANDLE hSurface,
301 HANDLE hSurfaceAttached)
302 {
303 PGD_DXDDUNATTACHSURFACE pfnDdUnattachSurface = (PGD_DXDDUNATTACHSURFACE)gpDxFuncs[DXG_INDEX_DxDdUnattachSurface].pfn;
304 if (pfnDdUnattachSurface == NULL)
305 {
306 DPRINT1("Warning: no pfnDdUnattachSurface\n");
307 //return DDHAL_DRIVER_NOTHANDLED;
308 return STATUS_NOT_IMPLEMENTED;
309 }
310
311 DPRINT("Calling dxg.sys pfnDdUnattachSurface\n");
312 return pfnDdUnattachSurface(hSurface,hSurfaceAttached);
313 }
314