1 /* 2 * COPYRIGHT: See COPYING in the top level directory 3 * PROJECT: ReactOS kernel 4 * PURPOSE: Native driver for dxg implementation 5 * FILE: win32ss/reactx/dxg/ddsurf.c 6 * PROGRAMER: Sebastian Gasiorek (sebastian.gasiorek@reactos.org) 7 */ 8 9 #include <dxg_int.h> 10 11 /*++ 12 * @name DxDdLock 13 * @implemented 14 * 15 * The function DxDdLock locks the surface and calls 16 * MapMemory driver function to assign surface memory. 17 * Surface memory is returned in mapMemoryData.fpProcess variable 18 * 19 * @param HANDLE hSurface 20 * Handle to DirectDraw surface 21 * 22 * @param PDD_LOCKDATA puLockData 23 * Structure with lock details 24 * 25 * @param HDC hdcClip 26 * Reserved 27 * 28 * @return 29 * Returns DDHAL_DRIVER_HANDLED or DDHAL_DRIVER_NOTHANDLED. 30 * 31 * @remarks. 32 * Missing lock data and error handling. 33 *--*/ 34 DWORD 35 NTAPI DxDdLock(HANDLE hSurface,PDD_LOCKDATA puLockData,HDC hdcClip)36DxDdLock(HANDLE hSurface, 37 PDD_LOCKDATA puLockData, 38 HDC hdcClip) 39 { 40 PEDD_SURFACE pSurface; 41 PEDD_DIRECTDRAW_LOCAL peDdL; 42 PEDD_DIRECTDRAW_GLOBAL peDdGl; 43 DD_MAPMEMORYDATA mapMemoryData; 44 45 pSurface = (PEDD_SURFACE)DdHmgLock(hSurface, ObjType_DDSURFACE_TYPE, TRUE); 46 peDdL = pSurface->peDirectDrawLocal; 47 peDdGl = peDdL->peDirectDrawGlobal2; 48 49 // Map memory if it's not already mapped and driver function is provided 50 if (!peDdL->isMemoryMapped && (peDdGl->ddCallbacks.dwFlags & DDHAL_CB32_MAPMEMORY)) 51 { 52 mapMemoryData.bMap = 1; 53 mapMemoryData.hProcess = (HANDLE)-1; 54 mapMemoryData.fpProcess = 0; 55 mapMemoryData.lpDD = (PDD_DIRECTDRAW_GLOBAL)peDdGl; 56 57 peDdGl->ddCallbacks.MapMemory(&mapMemoryData); 58 59 if (!mapMemoryData.ddRVal) 60 { 61 peDdL->isMemoryMapped = 1; 62 peDdL->fpProcess2 = mapMemoryData.fpProcess; 63 } 64 } 65 66 if (pSurface) 67 { 68 InterlockedExchangeAdd((LONG*)&pSurface->pobj.cExclusiveLock, 0xFFFFFFFF); 69 } 70 71 puLockData->ddRVal = DD_OK; 72 73 return DDHAL_DRIVER_HANDLED; 74 } 75 76 /*++ 77 * @name DxDdUnlock 78 * @unimplemented 79 * 80 * The function DxDdUnlock releases the lock from specified surface 81 * 82 * @param HANDLE hSurface 83 * Handle to DirectDraw surface 84 * 85 * @param PDD_UNLOCKDATA puUnlockData 86 * Structure with lock details 87 * 88 * @return 89 * Returns DDHAL_DRIVER_HANDLED or DDHAL_DRIVER_NOTHANDLED. 90 * 91 * @remarks. 92 * Stub 93 *--*/ 94 DWORD 95 NTAPI DxDdUnlock(HANDLE hSurface,PDD_UNLOCKDATA puUnlockData)96DxDdUnlock(HANDLE hSurface, 97 PDD_UNLOCKDATA puUnlockData) 98 { 99 puUnlockData->ddRVal = DD_OK; 100 101 return DDHAL_DRIVER_HANDLED; 102 } 103