[DXG] Initial implementation of DxDdLock and better stub for DxDdUnlock
authorSebastian Gasiorek <sebastian.gasiorek@reactos.org>
Sat, 24 Jun 2017 13:53:22 +0000 (13:53 +0000)
committerSebastian Gasiorek <sebastian.gasiorek@reactos.org>
Sat, 24 Jun 2017 13:53:22 +0000 (13:53 +0000)
svn path=/trunk/; revision=75182

reactos/sdk/include/reactos/drivers/directx/directxint.h
reactos/win32ss/reactx/dxg/CMakeLists.txt
reactos/win32ss/reactx/dxg/ddsurf.c [new file with mode: 0644]
reactos/win32ss/reactx/dxg/dxg_driver.h
reactos/win32ss/reactx/dxg/dxg_int.h

index ca163a6..904d791 100644 (file)
@@ -24,8 +24,8 @@ typedef struct _EDD_DIRECTDRAW_LOCAL
 /* 0x2C */    FLONG fl;
 /* 0x30 */    struct _EDD_DIRECTDRAW_LOCAL *peDirectDrawLocal_prev;  // verified to match Windows XP,
                                                                      // points to the old DDLocal when new handle is created.
-/* 0x34 */    ULONG unk_034;
-/* 0x38 */    ULONG unk_038;
+/* 0x34 */    FLATPTR fpProcess2;                                    // surface memory address returned by graphic driver
+/* 0x38 */    ULONG isMemoryMapped;                                  // surface memory mapped?
 /* 0x3C */    HANDLE UniqueProcess;
 /* 0x40 */    PEPROCESS Process;
 /* 0x44 */    VOID *unk_044;
index 8b6d568..f89951f 100644 (file)
@@ -7,6 +7,7 @@ list(APPEND SOURCE
     d3d.c
     dd.c
     ddraw.c
+    ddsurf.c
     eng.c
     historic.c
     dxg_int.h)
diff --git a/reactos/win32ss/reactx/dxg/ddsurf.c b/reactos/win32ss/reactx/dxg/ddsurf.c
new file mode 100644 (file)
index 0000000..cde3d8a
--- /dev/null
@@ -0,0 +1,100 @@
+/*
+ * COPYRIGHT:        See COPYING in the top level directory
+ * PROJECT:          ReactOS kernel
+ * PURPOSE:          Native driver for dxg implementation
+ * FILE:             win32ss/reactx/dxg/ddsurf.c
+ * PROGRAMER:        Sebastian Gasiorek (sebastian.gasiorek@reactos.org)
+ */
+
+/*++
+* @name DxDdLock
+* @implemented
+*
+* The function DxDdLock locks the surface and calls
+* MapMemory driver function to assign surface memory.
+* Surface memory is returned in mapMemoryData.fpProcess variable
+*
+* @param HANDLE hSurface
+* Handle to DirectDraw surface
+*
+* @param PDD_LOCKDATA puLockData
+* Structure with lock details
+*
+* @param HDC hdcClip
+* Reserved
+*
+* @return
+* Returns DDHAL_DRIVER_HANDLED or DDHAL_DRIVER_NOTHANDLED. 
+*
+* @remarks.
+* Missing lock data and error handling.
+*--*/
+DWORD
+NTAPI
+DxDdLock(HANDLE hSurface,
+         PDD_LOCKDATA puLockData,
+         HDC hdcClip)
+{
+    PEDD_SURFACE pSurface;
+    PEDD_DIRECTDRAW_LOCAL peDdL;
+    PEDD_DIRECTDRAW_GLOBAL peDdGl;
+    DD_MAPMEMORYDATA mapMemoryData;
+
+    pSurface = (PEDD_SURFACE)DdHmgLock(hSurface, ObjType_DDSURFACE_TYPE, TRUE);
+    peDdL = pSurface->peDirectDrawLocal;
+    peDdGl = peDdL->peDirectDrawGlobal2;
+
+    // Map memory if it's not already mapped and driver function is provided
+    if (!peDdL->isMemoryMapped && (peDdGl->ddCallbacks.dwFlags & DDHAL_CB32_MAPMEMORY))
+    {
+        mapMemoryData.bMap = 1;
+        mapMemoryData.hProcess = (HANDLE)-1;
+        mapMemoryData.fpProcess = 0;
+        mapMemoryData.lpDD = (PDD_DIRECTDRAW_GLOBAL)peDdGl;
+
+        peDdGl->ddCallbacks.MapMemory(&mapMemoryData);
+
+        if (!mapMemoryData.ddRVal)
+        {
+            peDdL->isMemoryMapped = 1;
+            peDdL->fpProcess2 = mapMemoryData.fpProcess;
+        }
+    }
+
+    if (pSurface)
+    {
+        InterlockedExchangeAdd((LONG*)&pSurface->pobj.cExclusiveLock, 0xFFFFFFFF);
+    }
+
+    puLockData->ddRVal = DD_OK;
+
+    return DDHAL_DRIVER_HANDLED;
+}
+
+/*++
+* @name DxDdUnlock
+* @unimplemented
+*
+* The function DxDdUnlock releases the lock from specified surface
+*
+* @param HANDLE hSurface
+* Handle to DirectDraw surface
+*
+* @param PDD_UNLOCKDATA puUnlockData
+* Structure with lock details
+*
+* @return
+* Returns DDHAL_DRIVER_HANDLED or DDHAL_DRIVER_NOTHANDLED. 
+*
+* @remarks.
+* Stub
+*--*/
+DWORD
+NTAPI
+DxDdUnlock(HANDLE hSurface,
+           PDD_UNLOCKDATA puUnlockData)
+{
+    puUnlockData->ddRVal = DD_OK;
+
+    return DDHAL_DRIVER_HANDLED;
+}
index a112757..73a998e 100644 (file)
@@ -343,15 +343,6 @@ DxDdGetScanLine(
     return 0;
 }
 
-DWORD
-NTAPI
-DxDdLock(
-    PVOID p1)
-{
-    TRACE();
-    return 0;
-}
-
 DWORD
 NTAPI
 DxDdLockD3D(
@@ -464,15 +455,6 @@ DxDdUnattachSurface(
     return 0;
 }
 
-DWORD
-NTAPI
-DxDdUnlock(
-    PVOID p1)
-{
-    TRACE();
-    return 0;
-}
-
 DWORD
 NTAPI
 DxDdUnlockD3D(
index 4915589..0d90081 100644 (file)
@@ -202,6 +202,8 @@ BOOL NTAPI DxDdQueryDirectDrawObject(HANDLE DdHandle, DD_HALINFO* pDdHalInfo, DW
 DWORD NTAPI DxDdReenableDirectDrawObject(HANDLE DdHandle, PVOID p2);
 DWORD NTAPI DxDdCanCreateSurface(HANDLE DdHandle, PDD_CANCREATESURFACEDATA SurfaceData);
 DWORD NTAPI DxDdCanCreateD3DBuffer(HANDLE DdHandle, PDD_CANCREATESURFACEDATA SurfaceData);
+DWORD NTAPI DxDdLock(HANDLE hSurface, PDD_LOCKDATA puLockData, HDC hdcClip);
+DWORD NTAPI DxDdUnlock(HANDLE hSurface, PDD_UNLOCKDATA puUnlockData);
 
 
 /* Internal functions */