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 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 _Must_inspect_result_ 63 _Ret_opt_bytecount_(cjMemSize) 64 __drv_allocatesMem(PrivateUserMem) 65 ENGAPI 66 PVOID 67 APIENTRY 68 EngAllocPrivateUserMem( 69 _In_ PDD_SURFACE_LOCAL psl, 70 _In_ SIZE_T cjMemSize, 71 _In_ ULONG ulTag) 72 { 73 PGD_ENGALLOCPRIVATEUSERMEM pfnEngAllocPrivateUserMem = (PGD_ENGALLOCPRIVATEUSERMEM)gpDxFuncs[DXG_INDEX_DxDdAllocPrivateUserMem].pfn; 74 75 if (pfnEngAllocPrivateUserMem == NULL) 76 { 77 DPRINT1("Warning: no pfnEngAllocPrivateUserMem\n"); 78 return DDHAL_DRIVER_NOTHANDLED; 79 } 80 81 DPRINT1("Calling dxg.sys pfnEngAllocPrivateUserMem\n"); 82 return pfnEngAllocPrivateUserMem(psl, cjMemSize, ulTag); 83 } 84 85 /************************************************************************/ 86 /* EngFreePrivateUserMem */ 87 /************************************************************************/ 88 VOID 89 APIENTRY 90 EngFreePrivateUserMem(PDD_SURFACE_LOCAL psl, 91 PVOID pv) 92 { 93 PGD_ENGFREEPRIVATEUSERMEM pfnEngFreePrivateUserMem = (PGD_ENGFREEPRIVATEUSERMEM)gpDxFuncs[DXG_INDEX_DxDdFreePrivateUserMem].pfn; 94 95 if (pfnEngFreePrivateUserMem == NULL) 96 { 97 DPRINT1("Warning: no pfnEngFreePrivateUserMem\n"); 98 } 99 else 100 { 101 DPRINT1("Calling dxg.sys pfnEngFreePrivateUserMem\n"); 102 pfnEngFreePrivateUserMem(psl, pv); 103 } 104 } 105 106 /*++ 107 * @name EngDxIoctl 108 * @implemented 109 * 110 * The function EngDxIoctl is the ioctl call to different DirectX functions 111 * in the driver dxg.sys 112 * 113 * @param ULONG ulIoctl 114 * The ioctl code that we want call to 115 * 116 * @param PVOID pBuffer 117 * Our in or out buffer with data to the ioctl code we are using 118 * 119 * @param ULONG ulBufferSize 120 * The buffer size in bytes 121 * 122 * @return 123 * Always returns DDERR_UNSUPPORTED 124 * 125 * @remarks. 126 * dxg.sys EngDxIoctl call is redirected to dxg.sys 127 * This function is no longer used in Windows NT 2000/XP/2003 128 * 129 *--*/ 130 HRESULT 131 APIENTRY 132 EngDxIoctl(ULONG ulIoctl, 133 PVOID pBuffer, 134 ULONG ulBufferSize) 135 { 136 PGD_ENGDXIOCTL pfnEngDxIoctl = (PGD_ENGDXIOCTL)gpDxFuncs[DXG_INDEX_DxDdIoctl].pfn; 137 DWORD retVal = DDERR_UNSUPPORTED; 138 139 DPRINT1("Calling dxg.sys pfnEngDxIoctl\n"); 140 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 167 EngLockDirectDrawSurface(HANDLE hSurface) 168 { 169 PGD_ENGLOCKDIRECTDRAWSURFACE pfnEngLockDirectDrawSurface = (PGD_ENGLOCKDIRECTDRAWSURFACE)gpDxFuncs[DXG_INDEX_DxDdLockDirectDrawSurface].pfn; 170 PDD_SURFACE_LOCAL retVal = NULL; 171 172 DPRINT1("Calling dxg.sys pfnEngLockDirectDrawSurface\n"); 173 174 if (pfnEngLockDirectDrawSurface != NULL) 175 { 176 retVal = pfnEngLockDirectDrawSurface(hSurface); 177 } 178 179 return retVal; 180 } 181 182 183 /*++ 184 * @name EngUnlockDirectDrawSurface 185 * @implemented 186 * 187 * The function EngUnlockDirectDrawSurface unlocks the DirectX surface 188 189 * @param PDD_SURFACE_LOCAL pSurface 190 * The Surface we want to unlock 191 * 192 * @return 193 * This return TRUE for success, FALSE for failure 194 * 195 * @remarks. 196 * None 197 * 198 *--*/ 199 BOOL 200 APIENTRY 201 EngUnlockDirectDrawSurface(PDD_SURFACE_LOCAL pSurface) 202 { 203 PGD_ENGUNLOCKDIRECTDRAWSURFACE pfnEngUnlockDirectDrawSurface = (PGD_ENGUNLOCKDIRECTDRAWSURFACE)gpDxFuncs[DXG_INDEX_DxDdUnlockDirectDrawSurface].pfn; 204 BOOL retVal = FALSE; 205 206 DPRINT1("Calling dxg.sys pfnEngUnlockDirectDrawSurface\n"); 207 208 if (pfnEngUnlockDirectDrawSurface != NULL) 209 { 210 retVal = pfnEngUnlockDirectDrawSurface(pSurface); 211 } 212 213 return retVal; 214 } 215 216