Author: sgasiorek
Date: Tue Mar 14 23:05:49 2017
New Revision: 74171
URL:
http://svn.reactos.org/svn/reactos?rev=74171&view=rev
Log:
[DXG] Implement DxDdCreateDirectDrawObject and update DdHmgAlloc CORE-4490
Modified:
trunk/reactos/sdk/include/reactos/drivers/directx/directxint.h
trunk/reactos/win32ss/reactx/dxg/ddhmg.c
trunk/reactos/win32ss/reactx/dxg/dxg_driver.h
trunk/reactos/win32ss/reactx/dxg/dxg_int.h
trunk/reactos/win32ss/reactx/dxg/eng.c
trunk/reactos/win32ss/reactx/ntddraw/ddraw.c
Modified: trunk/reactos/sdk/include/reactos/drivers/directx/directxint.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/sdk/include/reactos/driver…
==============================================================================
--- trunk/reactos/sdk/include/reactos/drivers/directx/directxint.h [iso-8859-1]
(original)
+++ trunk/reactos/sdk/include/reactos/drivers/directx/directxint.h [iso-8859-1] Tue Mar 14
23:05:49 2017
@@ -24,10 +24,10 @@
/* 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 */ PEPROCESS Process;
+/* 0x34 */ ULONG unk_034;
/* 0x38 */ ULONG unk_038;
/* 0x3C */ HANDLE UniqueProcess;
-/* 0x40 */ VOID *unk_040;
+/* 0x40 */ PEPROCESS Process;
/* 0x44 */ VOID *unk_044;
/* 0x48 */ ULONG unk_048;
/* 0x4C */ ULONG unk_04C;
Modified: trunk/reactos/win32ss/reactx/dxg/ddhmg.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/reactx/dxg/ddhmg.c…
==============================================================================
--- trunk/reactos/win32ss/reactx/dxg/ddhmg.c [iso-8859-1] (original)
+++ trunk/reactos/win32ss/reactx/dxg/ddhmg.c [iso-8859-1] Tue Mar 14 23:05:49 2017
@@ -323,12 +323,12 @@
* Size of memory to be allocated
* @param CHAR objType
* Object type
-* @param UINT objFlags
-* Object flags
+* @param UINT objLock
+* Object lock flag
*
* @return
-* Handle if object is not locked by objFlags
-* Object if lock is set in objFlags
+* Handle if object is not locked by objLock
+* Object if lock is set in objLock
* 0 if it fails.
*
* @remarks.
@@ -336,7 +336,7 @@
*--*/
HANDLE
FASTCALL
-DdHmgAlloc(ULONG objSize, CHAR objType, UINT objFlags)
+DdHmgAlloc(ULONG objSize, CHAR objType, BOOLEAN objLock)
{
PVOID pObject = NULL;
HANDLE DdHandle = NULL;
@@ -363,16 +363,17 @@
pEntry->Pid = (HANDLE)(((ULONG)PsGetCurrentProcessId() & 0xFFFFFFFC) |
((ULONG)(pEntry->Pid) & 1));
- if (objFlags & 1)
+ if (objLock)
+ {
+ InterlockedIncrement((VOID*)&pEntry->pobj->cExclusiveLock);
pEntry->pobj->Tid = KeGetCurrentThread();
-
- pEntry->pobj->cExclusiveLock = objFlags & 1;
+ }
pEntry->pobj->hHmgr = DdHandle;
EngReleaseSemaphore(ghsemHmgr);
/* Return handle if object not locked */
- if (!(objFlags & 1))
+ if (!objLock)
return DdHandle;
return (HANDLE)pEntry;
Modified: trunk/reactos/win32ss/reactx/dxg/dxg_driver.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/reactx/dxg/dxg_dri…
==============================================================================
--- trunk/reactos/win32ss/reactx/dxg/dxg_driver.h [iso-8859-1] (original)
+++ trunk/reactos/win32ss/reactx/dxg/dxg_driver.h [iso-8859-1] Tue Mar 14 23:05:49 2017
@@ -144,15 +144,6 @@
DxDdColorControl(
PVOID p1,
PVOID p2)
-{
- TRACE();
- return 0;
-}
-
-DWORD
-NTAPI
-DxDdCreateDirectDrawObject(
- PVOID p1)
{
TRACE();
return 0;
Modified: trunk/reactos/win32ss/reactx/dxg/dxg_int.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/reactx/dxg/dxg_int…
==============================================================================
--- trunk/reactos/win32ss/reactx/dxg/dxg_int.h [iso-8859-1] (original)
+++ trunk/reactos/win32ss/reactx/dxg/dxg_int.h [iso-8859-1] Tue Mar 14 23:05:49 2017
@@ -22,6 +22,7 @@
#include <initguid.h>
#include <ddrawi.h>
#include <ntgdityp.h>
+#include <psfuncs.h>
DEFINE_GUID(GUID_NTCallbacks, 0x6fe9ecde, 0xdf89, 0x11d1, 0x9d, 0xb0, 0x00,
0x60, 0x08, 0x27, 0x71, 0xba);
DEFINE_GUID(GUID_DDMoreCaps, 0x880baf30, 0xb030, 0x11d0, 0x8e, 0xa7, 0x00,
0x60, 0x97, 0x97, 0xea, 0x5b);
@@ -52,8 +53,9 @@
#define CapOver_DisableOGL 0x8
#define CapOver_DisableEscapes 0x10
-
+#define ObjType_DDLOCAL_TYPE 1
#define ObjType_DDSURFACE_TYPE 2
+#define ObjType_DDCONTEXT_TYPE 3
#define ObjType_DDVIDEOPORT_TYPE 4
#define ObjType_DDMOTIONCOMP_TYPE 5
@@ -171,7 +173,8 @@
NTSTATUS NTAPI DriverEntry(IN PVOID Context1, IN PVOID Context2);
NTSTATUS NTAPI GsDriverEntry(IN PVOID Context1, IN PVOID Context2);
NTSTATUS APIENTRY DxDdCleanupDxGraphics(VOID);
-BOOL NTAPI DxDdEnableDirectDraw(PVOID arg1, BOOL arg2);
+BOOL NTAPI DxDdEnableDirectDraw(HANDLE hDev, BOOL arg2);
+DWORD NTAPI DxDdCreateDirectDrawObject(HDC hDC);
/* Global pointers */
extern ULONG gcSizeDdHmgr;
@@ -198,6 +201,7 @@
BOOL FASTCALL DdHmgCreate(VOID);
BOOL FASTCALL DdHmgDestroy(VOID);
PVOID FASTCALL DdHmgLock(HANDLE DdHandle, UCHAR ObjectType, BOOLEAN LockOwned);
+HANDLE FASTCALL DdHmgAlloc(ULONG objSize, CHAR objType, BOOLEAN objLock);
#endif /* _DXG_PCH_ */
Modified: trunk/reactos/win32ss/reactx/dxg/eng.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/reactx/dxg/eng.c?r…
==============================================================================
--- trunk/reactos/win32ss/reactx/dxg/eng.c [iso-8859-1] (original)
+++ trunk/reactos/win32ss/reactx/dxg/eng.c [iso-8859-1] Tue Mar 14 23:05:49 2017
@@ -68,6 +68,40 @@
}
+PVOID
+FASTCALL
+intDdCreateDirectDrawLocal(HDEV hDev)
+{
+ PEDD_DIRECTDRAW_GLOBAL peDdGl = NULL;
+ PEDD_DIRECTDRAW_LOCAL peDdL = NULL;
+ PDD_ENTRY AllocRet;
+
+ peDdGl = (PEDD_DIRECTDRAW_GLOBAL)gpEngFuncs.DxEngGetHdevData(hDev,
DxEGShDevData_eddg);
+
+ AllocRet = DdHmgAlloc(sizeof(EDD_DIRECTDRAW_LOCAL), ObjType_DDLOCAL_TYPE, TRUE);
+ if (!AllocRet)
+ return NULL;
+
+ peDdL = (PEDD_DIRECTDRAW_LOCAL)AllocRet;
+
+ /* initialize DIRECTDRAW_LOCAL */
+ peDdL->peDirectDrawLocal_prev = peDdGl->peDirectDrawLocalList;
+ peDdL->UniqueProcess = PsGetCurrentThreadProcessId();
+ peDdL->Process = PsGetCurrentProcess();
+
+ // link DirectDrawGlobal and DirectDrawLocal
+ peDdGl->peDirectDrawLocalList = peDdL;
+ peDdL->peDirectDrawGlobal = peDdGl;
+ peDdL->peDirectDrawGlobal2 = peDdGl;
+
+ gpEngFuncs.DxEngReferenceHdev(hDev);
+
+ InterlockedExchangeAdd((LONG*)&peDdL->pobj.cExclusiveLock, 0xFFFFFFFF);
+
+ return peDdL->pobj.hHmgr;
+}
+
+
PDD_SURFACE_LOCAL
NTAPI
DxDdLockDirectDrawSurface(HANDLE hDdSurface)
@@ -266,3 +300,56 @@
return FALSE;
}
+
+/*++
+* @name DxDdCreateDirectDrawObject
+* @implemented
+*
+* Function creates new DirectDraw object
+*
+* @param HDC hDC
+* Device context handle
+*
+* @return
+* Newly created DirectDraw object handle.
+*
+* @remarks.
+* Missing all AGP stuff
+*--*/
+DWORD
+NTAPI
+DxDdCreateDirectDrawObject(
+ HDC hDC)
+{
+ PDC pDC = NULL;
+ HDEV hDev = NULL;
+ DWORD retVal = 0;
+
+ pDC = gpEngFuncs.DxEngLockDC(hDC);
+ if (!pDC)
+ return 0;
+
+ // get driver hDev from DC
+ hDev = (HDEV)gpEngFuncs.DxEngGetDCState(hDC, 3);
+ if (!hDev) {
+ gpEngFuncs.DxEngUnlockDC(pDC);
+ return 0;
+ }
+
+ // is this primary display?
+ if (!gpEngFuncs.DxEngGetHdevData(hDev, DxEGShDevData_display))
+ {
+ gpEngFuncs.DxEngUnlockDC(pDC);
+ return 0;
+ }
+
+ gpEngFuncs.DxEngLockHdev(hDev);
+
+ // create object only for 8BPP and more
+ if (gpEngFuncs.DxEngGetHdevData(hDev, DxEGShDevData_DitherFmt) >= BMF_8BPP)
+ retVal = (DWORD)intDdCreateDirectDrawLocal(hDev);
+
+ gpEngFuncs.DxEngUnlockHdev(hDev);
+ gpEngFuncs.DxEngUnlockDC(pDC);
+ return retVal;
+}
Modified: trunk/reactos/win32ss/reactx/ntddraw/ddraw.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/reactx/ntddraw/ddr…
==============================================================================
--- trunk/reactos/win32ss/reactx/ntddraw/ddraw.c [iso-8859-1] (original)
+++ trunk/reactos/win32ss/reactx/ntddraw/ddraw.c [iso-8859-1] Tue Mar 14 23:05:49 2017
@@ -912,10 +912,10 @@
DPRINT1("0x%08lx PEDD_DIRECTDRAW_LOCAL->fl :
0x%08lx\n",FIELD_OFFSET(EDD_DIRECTDRAW_LOCAL, fl), pEddlcl->fl);
DPRINT1("0x%08lx PEDD_DIRECTDRAW_LOCAL->peDirectDrawLocal_prev :
0x%p\n",FIELD_OFFSET(EDD_DIRECTDRAW_LOCAL, peDirectDrawLocal_prev),
pEddlcl->peDirectDrawLocal_prev);
- DPRINT1("0x%08lx PEDD_DIRECTDRAW_LOCAL->Process :
0x%p\n",FIELD_OFFSET(EDD_DIRECTDRAW_LOCAL, Process), pEddlcl->Process);
+ DPRINT1("0x%08lx PEDD_DIRECTDRAW_LOCAL->unk_034 :
0x%08lx\n",FIELD_OFFSET(EDD_DIRECTDRAW_LOCAL, unk_034), pEddlcl->unk_034);
DPRINT1("0x%08lx PEDD_DIRECTDRAW_LOCAL->unk_038 :
0x%08lx\n",FIELD_OFFSET(EDD_DIRECTDRAW_LOCAL, unk_038), pEddlcl->unk_038);
DPRINT1("0x%08lx PEDD_DIRECTDRAW_LOCAL->UniqueProcess :
0x%p\n",FIELD_OFFSET(EDD_DIRECTDRAW_LOCAL, UniqueProcess),
pEddlcl->UniqueProcess);
- DPRINT1("0x%08lx PEDD_DIRECTDRAW_LOCAL->unk_040 :
0x%p\n",FIELD_OFFSET(EDD_DIRECTDRAW_LOCAL, unk_040), pEddlcl->unk_040);
+ DPRINT1("0x%08lx PEDD_DIRECTDRAW_LOCAL->Process :
0x%p\n",FIELD_OFFSET(EDD_DIRECTDRAW_LOCAL, Process), pEddlcl->Process);
DPRINT1("0x%08lx PEDD_DIRECTDRAW_LOCAL->unk_044 :
0x%p\n",FIELD_OFFSET(EDD_DIRECTDRAW_LOCAL, unk_044), pEddlcl->unk_044);
DPRINT1("0x%08lx PEDD_DIRECTDRAW_LOCAL->unk_048 :
0x%08lx\n",FIELD_OFFSET(EDD_DIRECTDRAW_LOCAL, unk_048), pEddlcl->unk_048);
DPRINT1("0x%08lx PEDD_DIRECTDRAW_LOCAL->unk_04C :
0x%08lx\n",FIELD_OFFSET(EDD_DIRECTDRAW_LOCAL, unk_04C), pEddlcl->unk_04C);