[DXG] Implement DdAllocateObject, DdFreeObject, DdGetFreeHandle, DdHmgAlloc, DdHmgFre...
[reactos.git] / reactos / win32ss / reactx / dxg / dxg_int.h
1 #ifndef _DXG_PCH_
2 #define _DXG_PCH_
3
4 #include <ntifs.h>
5
6 /* Win32 Headers */
7 #define WINBASEAPI
8 #define STARTF_USESIZE 2
9 #define STARTF_USEPOSITION 4
10 #define INTERNAL_CALL NTAPI
11 #define NT_BUILD_ENVIRONMENT
12
13 #define DDHMG_HANDLE_LIMIT 0x200000
14 #define DDHMG_HTOI(DdHandle) ((DWORD)DdHandle & (DDHMG_HANDLE_LIMIT-1))
15
16
17 #include <windef.h>
18 #include <winerror.h>
19 #include <wingdi.h>
20 #include <winddi.h>
21 #include <ddkernel.h>
22 #include <ddrawi.h>
23
24 /* DXG treats this as opaque */
25 typedef PVOID PDC;
26 typedef PVOID PW32THREAD;
27
28 typedef struct _DD_BASEOBJECT
29 {
30 HGDIOBJ hHmgr;
31 ULONG ulShareCount;
32 USHORT cExclusiveLock;
33 USHORT BaseFlags;
34 PW32THREAD Tid;
35 } DD_BASEOBJECT, *PDD_BASEOBJECT;
36
37 #include <drivers/directx/directxint.h>
38 #include <drivers/directx/dxg.h>
39 #include <drivers/directx/dxeng.h>
40
41 #include "tags.h"
42
43 #define ObjType_DDSURFACE_TYPE 2
44 #define ObjType_DDVIDEOPORT_TYPE 4
45 #define ObjType_DDMOTIONCOMP_TYPE 5
46
47 typedef struct _DD_ENTRY
48 {
49 union
50 {
51 PDD_BASEOBJECT pobj;
52 ULONG NextFree;
53 };
54 HANDLE Pid;
55 USHORT FullUnique;
56 UCHAR Objt;
57 } DD_ENTRY, *PDD_ENTRY;
58
59 typedef struct _EDD_SURFACE_LOCAL
60 {
61 DD_BASEOBJECT Object;
62 DD_SURFACE_LOCAL Surfacelcl;
63 } EDD_SURFACE_LOCAL, *PEDD_SURFACE_LOCAL;
64
65 /* exported functions */
66 NTSTATUS NTAPI DriverEntry(IN PVOID Context1, IN PVOID Context2);
67 NTSTATUS NTAPI GsDriverEntry(IN PVOID Context1, IN PVOID Context2);
68 NTSTATUS APIENTRY DxDdCleanupDxGraphics(VOID);
69 BOOL NTAPI DxDdEnableDirectDraw(PVOID arg1, BOOL arg2);
70
71 /* Global pointers */
72 extern ULONG gcSizeDdHmgr;
73 extern PDD_ENTRY gpentDdHmgr;
74 extern ULONG gcMaxDdHmgr;
75 extern PDD_ENTRY gpentDdHmgrLast;
76 extern ULONG ghFreeDdHmgr;
77 extern HSEMAPHORE ghsemHmgr;
78 extern LONG gcDummyPageRefCnt;
79 extern HSEMAPHORE ghsemDummyPage;
80 extern VOID *gpDummyPage;
81 extern PEPROCESS gpepSession;
82 extern PLARGE_INTEGER gpLockShortDelay;
83
84 /* Driver list export functions */
85 DWORD NTAPI DxDxgGenericThunk(ULONG_PTR ulIndex, ULONG_PTR ulHandle, SIZE_T *pdwSizeOfPtr1, PVOID pvPtr1, SIZE_T *pdwSizeOfPtr2, PVOID pvPtr2);
86 DWORD NTAPI DxDdIoctl(ULONG ulIoctl, PVOID pBuffer, ULONG ulBufferSize);
87 PDD_SURFACE_LOCAL NTAPI DxDdLockDirectDrawSurface(HANDLE hDdSurface);
88 BOOL NTAPI DxDdUnlockDirectDrawSurface(PDD_SURFACE_LOCAL pSurface);
89
90 /* Internal functions */
91 BOOL FASTCALL VerifyObjectOwner(PDD_ENTRY pEntry);
92 BOOL FASTCALL DdHmgCreate(VOID);
93 BOOL FASTCALL DdHmgDestroy(VOID);
94 PVOID FASTCALL DdHmgLock(HANDLE DdHandle, UCHAR ObjectType, BOOLEAN LockOwned);
95
96 /* define stuff */
97 #define drvDxEngLockDC gpEngFuncs[DXENG_INDEX_DxEngLockDC]
98 #define drvDxEngGetDCState gpEngFuncs[DXENG_INDEX_DxEngGetDCState]
99 #define drvDxEngGetHdevData gpEngFuncs[DXENG_INDEX_DxEngGetHdevData]
100 #define drvDxEngUnlockDC gpEngFuncs[DXENG_INDEX_DxEngUnlockDC]
101 #define drvDxEngUnlockHdev gpEngFuncs[DXENG_INDEX_DxEngUnlockHdev]
102 #define drvDxEngLockHdev gpEngFuncs[DXENG_INDEX_DxEngLockHdev]
103
104 #endif /* _DXG_PCH_ */