[KERNEL32][CONSRV]
[reactos.git] / win32ss / reactx / ntddraw / eng.c
1 /*
2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS kernel
4 * PURPOSE: Native DirectDraw implementation
5 * FILE: subsystems/win32/win32k/ntddraw/eng.c
6 * PROGRAMER: Magnus olsen (magnus@greatlord.com)
7 * REVISION HISTORY:
8 * 19/1-2006 Magnus Olsen
9 */
10
11
12 #include <win32k.h>
13 #include <debug.h>
14
15 /************************************************************************/
16 /* HeapVidMemAllocAligned */
17 /************************************************************************/
18 FLATPTR
19 APIENTRY
20 HeapVidMemAllocAligned(LPVIDMEM lpVidMem,
21 DWORD dwWidth,
22 DWORD dwHeight,
23 LPSURFACEALIGNMENT lpAlignment,
24 LPLONG lpNewPitch)
25 {
26 PGD_HEAPVIDMEMALLOCALIGNED pfnHeapVidMemAllocAligned = (PGD_HEAPVIDMEMALLOCALIGNED)gpDxFuncs[DXG_INDEX_DxDdHeapVidMemAllocAligned].pfn;
27
28 if (pfnHeapVidMemAllocAligned == NULL)
29 {
30 DPRINT1("Warning: no pfnHeapVidMemAllocAligned\n");
31 return 0;
32 }
33
34 DPRINT1("Calling dxg.sys pfnHeapVidMemAllocAligned\n");
35 return pfnHeapVidMemAllocAligned(lpVidMem, dwWidth, dwHeight, lpAlignment, lpNewPitch);
36 }
37
38 /************************************************************************/
39 /* VidMemFree */
40 /************************************************************************/
41 VOID
42 APIENTRY
43 VidMemFree(LPVMEMHEAP pvmh,
44 FLATPTR ptr)
45 {
46 PGD_VIDMEMFREE pfnVidMemFree = (PGD_VIDMEMFREE)gpDxFuncs[DXG_INDEX_DxDdHeapVidMemFree].pfn;
47
48 if (pfnVidMemFree == NULL)
49 {
50 DPRINT1("Warning: no pfnVidMemFree\n");
51 }
52 else
53 {
54 DPRINT1("Calling dxg.sys pfnVidMemFree\n");
55 pfnVidMemFree(pvmh, ptr);
56 }
57 }
58
59 /************************************************************************/
60 /* EngAllocPrivateUserMem */
61 /************************************************************************/
62 PVOID
63 APIENTRY
64 EngAllocPrivateUserMem(PDD_SURFACE_LOCAL psl,
65 SIZE_T cj,
66 ULONG tag)
67 {
68 PGD_ENGALLOCPRIVATEUSERMEM pfnEngAllocPrivateUserMem = (PGD_ENGALLOCPRIVATEUSERMEM)gpDxFuncs[DXG_INDEX_DxDdAllocPrivateUserMem].pfn;
69
70 if (pfnEngAllocPrivateUserMem == NULL)
71 {
72 DPRINT1("Warning: no pfnEngAllocPrivateUserMem\n");
73 return DDHAL_DRIVER_NOTHANDLED;
74 }
75
76 DPRINT1("Calling dxg.sys pfnEngAllocPrivateUserMem\n");
77 return pfnEngAllocPrivateUserMem(psl, cj, tag);
78 }
79
80 /************************************************************************/
81 /* EngFreePrivateUserMem */
82 /************************************************************************/
83 VOID
84 APIENTRY
85 EngFreePrivateUserMem(PDD_SURFACE_LOCAL psl,
86 PVOID pv)
87 {
88 PGD_ENGFREEPRIVATEUSERMEM pfnEngFreePrivateUserMem = (PGD_ENGFREEPRIVATEUSERMEM)gpDxFuncs[DXG_INDEX_DxDdFreePrivateUserMem].pfn;
89
90 if (pfnEngFreePrivateUserMem == NULL)
91 {
92 DPRINT1("Warning: no pfnEngFreePrivateUserMem\n");
93 }
94 else
95 {
96 DPRINT1("Calling dxg.sys pfnEngFreePrivateUserMem\n");
97 pfnEngFreePrivateUserMem(psl, pv);
98 }
99 }
100
101 /*++
102 * @name EngDxIoctl
103 * @implemented
104 *
105 * The function EngDxIoctl is the ioctl call to different DirectX functions
106 * in the driver dxg.sys
107 *
108 * @param ULONG ulIoctl
109 * The ioctl code that we want call to
110 *
111 * @param PVOID pBuffer
112 * Our in or out buffer with data to the ioctl code we are using
113 *
114 * @param ULONG ulBufferSize
115 * The buffer size in bytes
116 *
117 * @return
118 * Always returns DDERR_UNSUPPORTED
119 *
120 * @remarks.
121 * dxg.sys EngDxIoctl call is redirected to dxg.sys
122 * This function is no longer used in Windows NT 2000/XP/2003
123 *
124 *--*/
125 DWORD
126 APIENTRY
127 EngDxIoctl(ULONG ulIoctl,
128 PVOID pBuffer,
129 ULONG ulBufferSize)
130 {
131 PGD_ENGDXIOCTL pfnEngDxIoctl = (PGD_ENGDXIOCTL)gpDxFuncs[DXG_INDEX_DxDdIoctl].pfn;
132 DWORD retVal = DDERR_UNSUPPORTED;
133
134 DPRINT1("Calling dxg.sys pfnEngDxIoctl\n");
135
136 if (pfnEngDxIoctl != NULL)
137 {
138 retVal = pfnEngDxIoctl(ulIoctl, pBuffer, ulBufferSize);
139 }
140
141 return retVal;
142 }
143
144 /*++
145 * @name EngLockDirectDrawSurface
146 * @implemented
147 *
148 * The function EngUnlockDirectDrawSurface locks the DirectX surface.
149
150 * @param HANDLE hSurface
151 * The handle of a surface
152 *
153 * @return
154 * This return a vaild or NULL pointer to a PDD_SURFACE_LOCAL object
155 *
156 * @remarks.
157 * None
158 *
159 *--*/
160 PDD_SURFACE_LOCAL
161 APIENTRY
162 EngLockDirectDrawSurface(HANDLE hSurface)
163 {
164 PGD_ENGLOCKDIRECTDRAWSURFACE pfnEngLockDirectDrawSurface = (PGD_ENGLOCKDIRECTDRAWSURFACE)gpDxFuncs[DXG_INDEX_DxDdLockDirectDrawSurface].pfn;
165 PDD_SURFACE_LOCAL retVal = NULL;
166
167 DPRINT1("Calling dxg.sys pfnEngLockDirectDrawSurface\n");
168
169 if (pfnEngLockDirectDrawSurface != NULL)
170 {
171 retVal = pfnEngLockDirectDrawSurface(hSurface);
172 }
173
174 return retVal;
175 }
176
177
178 /*++
179 * @name EngUnlockDirectDrawSurface
180 * @implemented
181 *
182 * The function EngUnlockDirectDrawSurface unlocks the DirectX surface
183
184 * @param PDD_SURFACE_LOCAL pSurface
185 * The Surface we want to unlock
186 *
187 * @return
188 * This return TRUE for success, FALSE for failure
189 *
190 * @remarks.
191 * None
192 *
193 *--*/
194 BOOL
195 APIENTRY
196 EngUnlockDirectDrawSurface(PDD_SURFACE_LOCAL pSurface)
197 {
198 PGD_ENGUNLOCKDIRECTDRAWSURFACE pfnEngUnlockDirectDrawSurface = (PGD_ENGUNLOCKDIRECTDRAWSURFACE)gpDxFuncs[DXG_INDEX_DxDdUnlockDirectDrawSurface].pfn;
199 BOOL retVal = FALSE;
200
201 DPRINT1("Calling dxg.sys pfnEngUnlockDirectDrawSurface\n");
202
203 if (pfnEngUnlockDirectDrawSurface != NULL)
204 {
205 retVal = pfnEngUnlockDirectDrawSurface(pSurface);
206 }
207
208 return retVal;
209 }
210