xref: /reactos/win32ss/reactx/dxg/dxg_int.h (revision 1734f297)
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_PTR)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 <initguid.h>
23 #include <ddrawi.h>
24 #include <ntgdityp.h>
25 #include <psfuncs.h>
26 
27 DEFINE_GUID(GUID_NTCallbacks,             0x6fe9ecde, 0xdf89, 0x11d1, 0x9d, 0xb0, 0x00, 0x60, 0x08, 0x27, 0x71, 0xba);
28 DEFINE_GUID(GUID_DDMoreCaps,              0x880baf30, 0xb030, 0x11d0, 0x8e, 0xa7, 0x00, 0x60, 0x97, 0x97, 0xea, 0x5b);
29 DEFINE_GUID(GUID_NTPrivateDriverCaps,     0xfad16a23, 0x7b66, 0x11d2, 0x83, 0xd7, 0x00, 0xc0, 0x4f, 0x7c, 0xe5, 0x8c);
30 
31 /* DXG treats this as opaque */
32 typedef PVOID PDC;
33 typedef PVOID PW32THREAD;
34 
35 typedef struct _DD_BASEOBJECT
36 {
37   HGDIOBJ     hHmgr;
38   ULONG       ulShareCount;
39   USHORT      cExclusiveLock;
40   USHORT      BaseFlags;
41   PW32THREAD  Tid;
42 } DD_BASEOBJECT, *PDD_BASEOBJECT;
43 
44 #include <drivers/directx/directxint.h>
45 #include <drivers/directx/dxg.h>
46 #include <drivers/directx/dxeng.h>
47 
48 #include "tags.h"
49 
50 #define CapOver_DisableAccel      0x1
51 #define CapOver_DisableD3DDDAccel 0x2
52 #define CapOver_DisableD3DAccel   0x4
53 #define CapOver_DisableOGL        0x8
54 #define CapOver_DisableEscapes    0x10
55 
56 #define ObjType_DDLOCAL_TYPE      1
57 #define ObjType_DDSURFACE_TYPE    2
58 #define ObjType_DDCONTEXT_TYPE    3
59 #define ObjType_DDVIDEOPORT_TYPE  4
60 #define ObjType_DDMOTIONCOMP_TYPE 5
61 
62 typedef struct _DD_ENTRY
63 {
64     union
65     {
66         PDD_BASEOBJECT pobj;
67         ULONG NextFree;
68     };
69     HANDLE Pid;
70     USHORT FullUnique;
71     UCHAR Objt;
72 } DD_ENTRY, *PDD_ENTRY;
73 
74 typedef struct _EDD_SURFACE_LOCAL
75 {
76      DD_BASEOBJECT Object;
77      DD_SURFACE_LOCAL Surfacelcl;
78 } EDD_SURFACE_LOCAL, *PEDD_SURFACE_LOCAL;
79 
80 
81 typedef BOOLEAN   (APIENTRY* PFN_DxEngNUIsTermSrv)(VOID);
82 typedef DWORD     (APIENTRY* PFN_DxEngScreenAccessCheck)(VOID);
83 typedef BOOLEAN   (APIENTRY* PFN_DxEngRedrawDesktop)(VOID);
84 typedef ULONG     (APIENTRY* PFN_DxEngDispUniq)(VOID);
85 typedef BOOLEAN   (APIENTRY* PFN_DxEngIncDispUniq)(VOID);
86 typedef ULONG     (APIENTRY* PFN_DxEngVisRgnUniq)(VOID);
87 typedef BOOLEAN   (APIENTRY* PFN_DxEngLockShareSem)(VOID);
88 typedef BOOLEAN   (APIENTRY* PFN_DxEngUnlockShareSem)(VOID);
89 typedef HDEV*     (APIENTRY* PFN_DxEngEnumerateHdev)(HDEV*);
90 typedef BOOLEAN   (APIENTRY* PFN_DxEngLockHdev)(HDEV);
91 typedef BOOLEAN   (APIENTRY* PFN_DxEngUnlockHdev)(HDEV);
92 typedef BOOLEAN   (APIENTRY* PFN_DxEngIsHdevLockedByCurrentThread)(HDEV);
93 typedef BOOLEAN   (APIENTRY* PFN_DxEngReferenceHdev)(HDEV);
94 typedef BOOLEAN   (APIENTRY* PFN_DxEngUnreferenceHdev)(HDEV);
95 typedef BOOL      (APIENTRY* PFN_DxEngGetDeviceGammaRamp)(HDEV, PGAMMARAMP);
96 typedef BOOLEAN   (APIENTRY* PFN_DxEngSetDeviceGammaRamp)(HDEV, PGAMMARAMP, BOOL);
97 typedef DWORD     (APIENTRY* PFN_DxEngSpTearDownSprites)(DWORD, DWORD, DWORD);
98 typedef DWORD     (APIENTRY* PFN_DxEngSpUnTearDownSprites)(DWORD, DWORD, DWORD);
99 typedef DWORD     (APIENTRY* PFN_DxEngSpSpritesVisible)(DWORD);
100 typedef DWORD_PTR (APIENTRY* PFN_DxEngGetHdevData)(HDEV, DXEGSHDEVDATA);
101 typedef BOOLEAN   (APIENTRY* PFN_DxEngSetHdevData)(HDEV, DXEGSHDEVDATA, DWORD_PTR);
102 typedef HDC       (APIENTRY* PFN_DxEngCreateMemoryDC)(HDEV);
103 typedef HDC       (APIENTRY* PFN_DxEngGetDesktopDC)(ULONG, BOOL, BOOL);
104 typedef BOOLEAN   (APIENTRY* PFN_DxEngDeleteDC)(HDC, BOOL);
105 typedef BOOLEAN   (APIENTRY* PFN_DxEngCleanDC)(HDC hdc);
106 typedef BOOL      (APIENTRY* PFN_DxEngSetDCOwner)(HGDIOBJ, DWORD);
107 typedef PDC       (APIENTRY* PFN_DxEngLockDC)(HDC);
108 typedef BOOLEAN   (APIENTRY* PFN_DxEngUnlockDC)(PDC);
109 typedef BOOLEAN   (APIENTRY* PFN_DxEngSetDCState)(HDC, DWORD, DWORD);
110 typedef DWORD_PTR (APIENTRY* PFN_DxEngGetDCState)(HDC, DWORD);
111 typedef DWORD     (APIENTRY* PFN_DxEngSelectBitmap)(DWORD, DWORD);
112 typedef DWORD     (APIENTRY* PFN_DxEngSetBitmapOwner)(DWORD, DWORD);
113 typedef DWORD     (APIENTRY* PFN_DxEngDeleteSurface)(DWORD);
114 typedef DWORD     (APIENTRY* PFN_DxEngGetSurfaceData)(DWORD, DWORD);
115 typedef DWORD     (APIENTRY* PFN_DxEngAltLockSurface)(DWORD);
116 typedef DWORD     (APIENTRY* PFN_DxEngUploadPaletteEntryToSurface)(DWORD, DWORD, DWORD, DWORD);
117 typedef DWORD     (APIENTRY* PFN_DxEngMarkSurfaceAsDirectDraw)(DWORD, DWORD);
118 typedef DWORD     (APIENTRY* PFN_DxEngSelectPaletteToSurface)(DWORD, DWORD);
119 typedef DWORD     (APIENTRY* PFN_DxEngSyncPaletteTableWithDevice)(DWORD, DWORD);
120 typedef DWORD     (APIENTRY* PFN_DxEngSetPaletteState)(DWORD, DWORD, DWORD);
121 typedef DWORD     (APIENTRY* PFN_DxEngGetRedirectionBitmap)(DWORD);
122 typedef DWORD     (APIENTRY* PFN_DxEngLoadImage)(DWORD, DWORD);
123 
124 
125 typedef struct _DXENG_FUNCTIONS
126 {
127     PVOID                                   Reserved;
128     PFN_DxEngNUIsTermSrv                    DxEngNUIsTermSrv;
129     PFN_DxEngScreenAccessCheck              DxEngScreenAccessCheck;
130     PFN_DxEngRedrawDesktop                  DxEngRedrawDesktop;
131     PFN_DxEngDispUniq                       DxEngDispUniq;
132     PFN_DxEngIncDispUniq                    DxEngIncDispUniq;
133     PFN_DxEngVisRgnUniq                     DxEngVisRgnUniq;
134     PFN_DxEngLockShareSem                   DxEngLockShareSem;
135     PFN_DxEngUnlockShareSem                 DxEngUnlockShareSem;
136     PFN_DxEngEnumerateHdev                  DxEngEnumerateHdev;
137     PFN_DxEngLockHdev                       DxEngLockHdev;
138     PFN_DxEngUnlockHdev                     DxEngUnlockHdev;
139     PFN_DxEngIsHdevLockedByCurrentThread    DxEngIsHdevLockedByCurrentThread;
140     PFN_DxEngReferenceHdev                  DxEngReferenceHdev;
141     PFN_DxEngUnreferenceHdev                DxEngUnreferenceHdev;
142     PFN_DxEngGetDeviceGammaRamp             DxEngGetDeviceGammaRamp;
143     PFN_DxEngSetDeviceGammaRamp             DxEngSetDeviceGammaRamp;
144     PFN_DxEngSpTearDownSprites              DxEngSpTearDownSprites;
145     PFN_DxEngSpUnTearDownSprites            DxEngSpUnTearDownSprites;
146     PFN_DxEngSpSpritesVisible               DxEngSpSpritesVisible;
147     PFN_DxEngGetHdevData                    DxEngGetHdevData;
148     PFN_DxEngSetHdevData                    DxEngSetHdevData;
149     PFN_DxEngCreateMemoryDC                 DxEngCreateMemoryDC;
150     PFN_DxEngGetDesktopDC                   DxEngGetDesktopDC;
151     PFN_DxEngDeleteDC                       DxEngDeleteDC;
152     PFN_DxEngCleanDC                        DxEngCleanDC;
153     PFN_DxEngSetDCOwner                     DxEngSetDCOwner;
154     PFN_DxEngLockDC                         DxEngLockDC;
155     PFN_DxEngUnlockDC                       DxEngUnlockDC;
156     PFN_DxEngSetDCState                     DxEngSetDCState;
157     PFN_DxEngGetDCState                     DxEngGetDCState;
158     PFN_DxEngSelectBitmap                   DxEngSelectBitmap;
159     PFN_DxEngSetBitmapOwner                 DxEngSetBitmapOwner;
160     PFN_DxEngDeleteSurface                  DxEngDeleteSurface;
161     PFN_DxEngGetSurfaceData                 DxEngGetSurfaceData;
162     PFN_DxEngAltLockSurface                 DxEngAltLockSurface;
163     PFN_DxEngUploadPaletteEntryToSurface    DxEngUploadPaletteEntryToSurface;
164     PFN_DxEngMarkSurfaceAsDirectDraw        DxEngMarkSurfaceAsDirectDraw;
165     PFN_DxEngSelectPaletteToSurface         DxEngSelectPaletteToSurface;
166     PFN_DxEngSyncPaletteTableWithDevice     DxEngSyncPaletteTableWithDevice;
167     PFN_DxEngSetPaletteState                DxEngSetPaletteState;
168     PFN_DxEngGetRedirectionBitmap           DxEngGetRedirectionBitmap;
169     PFN_DxEngLoadImage                      DxEngLoadImage;
170 } DXENG_FUNCTIONS, *PDXENG_FUNCTIONS;
171 
172 /* exported functions */
173 NTSTATUS NTAPI DriverEntry(IN PVOID Context1, IN PVOID Context2);
174 NTSTATUS NTAPI GsDriverEntry(IN PVOID Context1, IN PVOID Context2);
175 NTSTATUS APIENTRY DxDdCleanupDxGraphics(VOID);
176 BOOL NTAPI DxDdEnableDirectDraw(HANDLE hDev, BOOL arg2);
177 DWORD NTAPI DxDdCreateDirectDrawObject(HDC hDC);
178 
179 /* Global pointers */
180 extern ULONG gcSizeDdHmgr;
181 extern PDD_ENTRY gpentDdHmgr;
182 extern ULONG gcMaxDdHmgr;
183 extern PDD_ENTRY gpentDdHmgrLast;
184 extern ULONG ghFreeDdHmgr;
185 extern HSEMAPHORE ghsemHmgr;
186 extern LONG gcDummyPageRefCnt;
187 extern HSEMAPHORE ghsemDummyPage;
188 extern VOID *gpDummyPage;
189 extern PEPROCESS gpepSession;
190 extern PLARGE_INTEGER gpLockShortDelay;
191 extern DXENG_FUNCTIONS gpEngFuncs;
192 
193 /* Driver list export functions */
194 DWORD NTAPI DxDxgGenericThunk(ULONG_PTR ulIndex, ULONG_PTR ulHandle, SIZE_T *pdwSizeOfPtr1, PVOID pvPtr1, SIZE_T *pdwSizeOfPtr2, PVOID pvPtr2);
195 DWORD NTAPI DxDdIoctl(ULONG ulIoctl, PVOID pBuffer, ULONG ulBufferSize);
196 PDD_SURFACE_LOCAL NTAPI DxDdLockDirectDrawSurface(HANDLE hDdSurface);
197 BOOL NTAPI DxDdUnlockDirectDrawSurface(PDD_SURFACE_LOCAL pSurface);
198 DWORD NTAPI DxDdGetDriverInfo(HANDLE DdHandle, PDD_GETDRIVERINFODATA drvInfoData);
199 BOOL NTAPI DxDdQueryDirectDrawObject(HANDLE DdHandle, DD_HALINFO* pDdHalInfo, DWORD* pCallBackFlags, LPD3DNTHAL_CALLBACKS pd3dNtHalCallbacks,
200                                      LPD3DNTHAL_GLOBALDRIVERDATA pd3dNtGlobalDriverData, PDD_D3DBUFCALLBACKS pd3dBufCallbacks, LPDDSURFACEDESC pTextureFormats,
201                                      DWORD* p8, VIDEOMEMORY* p9, DWORD* pdwNumFourCC, DWORD* pdwFourCC);
202 DWORD NTAPI DxDdReenableDirectDrawObject(HANDLE DdHandle, PVOID p2);
203 DWORD NTAPI DxDdCanCreateSurface(HANDLE DdHandle, PDD_CANCREATESURFACEDATA SurfaceData);
204 DWORD NTAPI DxDdCanCreateD3DBuffer(HANDLE DdHandle, PDD_CANCREATESURFACEDATA SurfaceData);
205 DWORD NTAPI DxDdCreateD3DBuffer(HANDLE hDirectDrawLocal, PEDD_SURFACE pDdSurfList, DDSURFACEDESC2 *a3, DD_SURFACE_GLOBAL *pDdSurfGlob, DD_SURFACE_LOCAL *pDdSurfLoc,
206                                 DD_SURFACE_MORE *pDdSurfMore, DD_CREATESURFACEDATA *pDdCreateSurfaceData, PVOID Address);
207 DWORD NTAPI DxDdLock(HANDLE hSurface, PDD_LOCKDATA puLockData, HDC hdcClip);
208 DWORD NTAPI DxDdUnlock(HANDLE hSurface, PDD_UNLOCKDATA puUnlockData);
209 HANDLE NTAPI DxDdCreateSurfaceObject(HANDLE hDirectDrawLocal, HANDLE hSurface, PDD_SURFACE_LOCAL puSurfaceLocal, PDD_SURFACE_MORE puSurfaceMore, PDD_SURFACE_GLOBAL puSurfaceGlobal, BOOL bComplete);
210 
211 
212 /* Internal functions */
213 BOOL FASTCALL VerifyObjectOwner(PDD_ENTRY pEntry);
214 BOOL FASTCALL DdHmgCreate(VOID);
215 BOOL FASTCALL DdHmgDestroy(VOID);
216 PVOID FASTCALL DdHmgLock(HANDLE DdHandle, UCHAR ObjectType, BOOLEAN LockOwned);
217 HANDLE FASTCALL DdHmgAlloc(ULONG objSize, CHAR objType, BOOLEAN objLock);
218 PEDD_SURFACE NTAPI intDdCreateNewSurfaceObject(PEDD_DIRECTDRAW_LOCAL peDdL, HANDLE hDirectDrawLocal,
219                                                PDD_SURFACE_GLOBAL pDdSurfGlob, PDD_SURFACE_LOCAL pDdSurfLoc, PDD_SURFACE_MORE pDdSurfMore);
220 
221 #endif /* _DXG_PCH_ */
222