ReactOS  0.4.13-dev-257-gfabbd7c
ddsurf.c
Go to the documentation of this file.
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
36 DxDdLock(HANDLE hSurface,
37  PDD_LOCKDATA puLockData,
38  HDC hdcClip)
39 {
43  DD_MAPMEMORYDATA mapMemoryData;
44 
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
96 DxDdUnlock(HANDLE hSurface,
97  PDD_UNLOCKDATA puUnlockData)
98 {
99  puUnlockData->ddRVal = DD_OK;
100 
101  return DDHAL_DRIVER_HANDLED;
102 }
#define TRUE
Definition: types.h:120
#define DDHAL_CB32_MAPMEMORY
Definition: ddrawint.h:519
struct _DD_DIRECTDRAW_GLOBAL * PDD_DIRECTDRAW_GLOBAL
static HDC
Definition: imagelist.c:92
#define ObjType_DDSURFACE_TYPE
Definition: dxg_int.h:57
PDD_DIRECTDRAW_GLOBAL lpDD
Definition: ddrawint.h:483
HRESULT ddRVal
Definition: ddrawint.h:487
#define DDHAL_DRIVER_HANDLED
Definition: ddrawi.h:321
#define DD_OK
Definition: ddraw.h:186
NTSTATUS(* NTAPI)(IN PFILE_FULL_EA_INFORMATION EaBuffer, IN ULONG EaLength, OUT PULONG ErrorOffset)
Definition: IoEaTest.cpp:117
DWORD NTAPI DxDdLock(HANDLE hSurface, PDD_LOCKDATA puLockData, HDC hdcClip)
Definition: ddsurf.c:36
long LONG
Definition: pedump.c:60
#define InterlockedExchangeAdd
Definition: interlocked.h:181
_In_ DD_SURFACE_LOCAL * pSurface
Definition: winddi.h:3481
PVOID FASTCALL DdHmgLock(HANDLE DdHandle, UCHAR ObjectType, BOOLEAN LockOwned)
Definition: ddhmg.c:147
PVOID HANDLE
Definition: typedefs.h:71
unsigned long DWORD
Definition: ntddk_ex.h:95
DWORD NTAPI DxDdUnlock(HANDLE hSurface, PDD_UNLOCKDATA puUnlockData)
Definition: ddsurf.c:96
struct _EDD_DIRECTDRAW_GLOBAL * peDirectDrawGlobal2
Definition: directxint.h:22
DD_CALLBACKS ddCallbacks
Definition: directxint.h:160
FLATPTR fpProcess
Definition: ddrawint.h:486
DWORD dwFlags
Definition: ddrawint.h:499
HRESULT ddRVal
Definition: ddrawint.h:248
HRESULT ddRVal
Definition: ddrawint.h:258
struct _EDD_SURFACE * PEDD_SURFACE
PDD_MAPMEMORY MapMemory
Definition: ddrawint.h:508