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