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