[GDI32] Fix 64 bit issues
[reactos.git] / win32ss / include / ntgdihdl.h
1 /*
2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS Win32 Graphical Subsystem (WIN32K)
4 * FILE: win32ss/include/ntgdihdl.h
5 * PURPOSE: Win32 Shared GDI Handle/Object Types
6 * PROGRAMMER: Alex Ionescu (alex@relsoft.net)
7 */
8
9 /* INCLUDES ******************************************************************/
10
11 #ifndef _NTGDIHDL_
12 #define _NTGDIHDL_
13
14 #include <winddi.h>
15
16 /* DEFINES *******************************************************************/
17
18 /* GDI handle table can hold 0x10000 handles */
19 #define GDI_HANDLE_COUNT 0x10000
20 #define GDI_CFONT_MAX 16
21
22 /* Handle Masks and shifts */
23 #define GDI_HANDLE_INDEX_MASK (GDI_HANDLE_COUNT - 1)
24 #define GDI_HANDLE_TYPE_MASK 0x007f0000
25 #define GDI_HANDLE_BASETYPE_MASK 0x001f0000
26 #define GDI_HANDLE_EXTYPE_MASK 0x00600000
27 #define GDI_HANDLE_STOCK_MASK 0x00800000
28 #define GDI_HANDLE_REUSE_MASK 0xff000000
29 #define GDI_HANDLE_UPPER_MASK (GDI_HANDLE_TYPE_MASK|GDI_HANDLE_STOCK_MASK|GDI_HANDLE_REUSE_MASK)
30 #define GDI_HANDLE_REUSECNT_SHIFT 24
31 #define GDI_HANDLE_BASETYPE_SHIFT 16
32
33 #define GDI_ENTRY_STOCK_MASK 0x00000080
34 #define GDI_ENTRY_BASETYPE_MASK 0x001f0000
35 #define GDI_ENTRY_UPPER_SHIFT 16
36
37 /* GDI Entry Flags */
38 #define GDI_ENTRY_UNDELETABLE 1 /* Mark Object as nonremovable */
39 #define GDI_ENTRY_DELETING 2 /* Used when deleting Font Objects */
40 #define GDI_ENTRY_VALIDATE_VIS 4 /* Validating Visible region data */
41 #define GDI_ENTRY_ALLOCATE_LAL 0x80 /* Object Allocated with Look aside List */
42
43 /*! \defgroup GDI object types
44 *
45 * GDI object types
46 *
47 */
48 /*@{*/
49 #define GDI_OBJECT_TYPE_DC 0x00010000
50 #define GDI_OBJECT_TYPE_DD_SURFACE 0x00030000 /* Should be moved away from gdi objects */
51 #define GDI_OBJECT_TYPE_REGION 0x00040000
52 #define GDI_OBJECT_TYPE_BITMAP 0x00050000
53 #define GDI_OBJECT_TYPE_CLIOBJ 0x00060000
54 #define GDI_OBJECT_TYPE_PATH 0x00070000
55 #define GDI_OBJECT_TYPE_PALETTE 0x00080000
56 #define GDI_OBJECT_TYPE_COLORSPACE 0x00090000
57 #define GDI_OBJECT_TYPE_FONT 0x000a0000
58
59 #define GDI_OBJECT_TYPE_BRUSH 0x00100000
60 #define GDI_OBJECT_TYPE_DD_VIDEOPORT 0x00120000 /* Should be moved away from gdi objects */
61 #define GDI_OBJECT_TYPE_DD_MOTIONCOMP 0x00140000 /* Should be moved away from gdi objects */
62 #define GDI_OBJECT_TYPE_ENUMFONT 0x00160000
63 #define GDI_OBJECT_TYPE_DRIVEROBJ 0x001C0000
64
65 /* Confrim on XP value is taken from NtGdiCreateDirectDrawObject */
66 #define GDI_OBJECT_TYPE_DIRECTDRAW 0x00200000
67
68 /* Following object types are derived types from the above base types
69 use 0x001f0000 as mask to get the base type */
70 #define GDI_OBJECT_TYPE_EMF 0x00210000
71
72 #define GDI_OBJECT_TYPE_METAFILE 0x00260000
73 #define GDI_OBJECT_TYPE_ENHMETAFILE 0x00460000
74 #define GDI_OBJECT_TYPE_PEN 0x00300000
75 #define GDI_OBJECT_TYPE_EXTPEN 0x00500000
76 #define GDI_OBJECT_TYPE_METADC 0x00660000
77 /*#define GDI_OBJECT_TYPE_DD_PALETTE 0x00630000 unused at the moment, other value required */
78 /*#define GDI_OBJECT_TYPE_DD_CLIPPER 0x00640000 unused at the moment, other value required */
79
80 /* Following object types made up for ROS */
81 #define GDI_OBJECT_TYPE_DONTCARE 0x007f0000
82 /** Not really an object type. Forces GDI_FreeObj to be silent. */
83 #define GDI_OBJECT_TYPE_SILENT 0x80000000
84 /*@}*/
85
86 /* Handle macros */
87 #define GDI_HANDLE_CREATE(i, t) \
88 ((HANDLE)(((i) & GDI_HANDLE_INDEX_MASK) | ((t) & GDI_HANDLE_TYPE_MASK)))
89
90 #define GDI_HANDLE_GET_INDEX(h) \
91 (((ULONG_PTR)(h)) & GDI_HANDLE_INDEX_MASK)
92
93 #define GDI_HANDLE_GET_TYPE(h) \
94 (((ULONG_PTR)(h)) & GDI_HANDLE_TYPE_MASK)
95
96 #define GDI_HANDLE_IS_TYPE(h, t) \
97 ((t) == (((ULONG_PTR)(h)) & GDI_HANDLE_TYPE_MASK))
98
99 #define GDI_HANDLE_IS_STOCKOBJ(h) \
100 (0 != (((ULONG_PTR)(h)) & GDI_HANDLE_STOCK_MASK))
101
102 #define GDI_HANDLE_SET_STOCKOBJ(h) \
103 ((h) = (HANDLE)(((ULONG_PTR)(h)) | GDI_HANDLE_STOCK_MASK))
104
105 #define GDI_HANDLE_GET_UPPER(h) \
106 (((ULONG_PTR)(h)) & GDI_HANDLE_UPPER_MASK)
107
108 #define GDI_HANDLE_GET_REUSECNT(h) \
109 (((ULONG_PTR)(h)) >> GDI_HANDLE_REUSECNT_SHIFT)
110
111 #define GDI_OBJECT_GET_TYPE_INDEX(t) \
112 ((t & GDI_HANDLE_BASETYPE_MASK) >> GDI_HANDLE_BASETYPE_SHIFT)
113
114 /* Gdi Object Handle Managment Pid lock masking sets. */
115 /* Ref: used with DxEngSetDCOwner */
116 #define GDI_OBJ_HMGR_PUBLIC 0 /* Public owner, Open access? */
117 #define GDI_OBJ_HMGR_POWNED 0x80000002 /* Set to current owner. */
118 #define GDI_OBJ_HMGR_NONE 0x80000012 /* No owner, Open access? */
119 #define GDI_OBJ_HMGR_RESTRICTED 0x80000022 /* Restricted? */
120
121
122 /* DC OBJ Types */
123 #define DC_TYPE_DIRECT 0 /* normal device context */
124 #define DC_TYPE_MEMORY 1 /* memory device context */
125 #define DC_TYPE_INFO 2 /* information context */
126
127 /* DC OBJ Flags */
128 #define DC_FLAG_DISPLAY 0x0001
129 #define DC_FLAG_DIRECT 0x0002
130 #define DC_FLAG_CANCELLED 0x0004
131 #define DC_FLAG_PERMANENT 0x0008
132 #define DC_FLAG_DIRTY_RAO 0x0010
133 #define DC_FLAG_ACCUM_WMGR 0x0020
134 #define DC_FLAG_ACCUM_APP 0x0040
135 #define DC_FLAG_RESET 0x0080
136 #define DC_FLAG_SYNCHRONIZEACCESS 0x0100
137 #define DC_FLAG_EPSPRINTINGESCAPE 0x0200
138 #define DC_FLAG_TEMPINFODC 0x0400
139 #define DC_FLAG_FULLSCREEN 0x0800
140 #define DC_FLAG_IN_CLONEPDEV 0x1000
141 #define DC_FLAG_REDIRECTION 0x2000
142 #define DC_FLAG_SHAREACCESS 0x4000
143
144 /* DC_ATTR Dirty Flags */
145 #define DIRTY_FILL 0x00000001
146 #define DIRTY_LINE 0x00000002
147 #define DIRTY_TEXT 0x00000004
148 #define DIRTY_BACKGROUND 0x00000008
149 #define DIRTY_CHARSET 0x00000010
150 #define SLOW_WIDTHS 0x00000020
151 #define DC_CACHED_TM_VALID 0x00000040
152 #define DISPLAY_DC 0x00000080
153 #define DIRTY_PTLCURRENT 0x00000100
154 #define DIRTY_PTFXCURRENT 0x00000200
155 #define DIRTY_STYLESTATE 0x00000400
156 #define DC_PLAYMETAFILE 0x00000800
157 #define DC_BRUSH_DIRTY 0x00001000
158 #define DC_PEN_DIRTY 0x00002000
159 #define DC_DIBSECTION 0x00004000
160 #define DC_LAST_CLIPRGN_VALID 0x00008000
161 #define DC_PRIMARY_DISPLAY 0x00010000
162 #define DC_ICM_NOT_CALIBRATED 0x00020000
163 #define DC_ICM_BRUSH_DIRTY 0x00040000
164 #define DC_ICM_PEN_DIRTY 0x00080000
165 #define DC_ICM_NOT_SET 0x00100000
166 #define DC_MODE_DIRTY 0x00200000
167 #define DC_FONTTEXT_DIRTY 0x00400000
168
169 /* DC_ATTR LCD Flags */
170 #define LDC_LDC 0x00000001 /* (init) local DC other than a normal DC */
171 #define LDC_EMFLDC 0x00000002 /* Enhance Meta File local DC */
172 #define LDC_SAPCALLBACK 0x00000020
173 #define LDC_INIT_DOCUMENT 0x00000040
174 #define LDC_INIT_PAGE 0x00000080
175 #define LDC_STARTPAGE 0x00000100
176 #define LDC_PLAY_MFDC 0x00000800
177 #define LDC_CLOCKWISE 0x00002000
178 #define LDC_KILL_DOCUMENT 0x00010000
179 #define LDC_META_PRINT 0x00020000
180 #define LDC_INFODC 0x01000000 /* If CreateIC was passed. */
181 #define LDC_DEVCAPS 0x02000000
182 #define LDC_ATENDPAGE 0x10000000
183
184 /* DC_ATTR Xform Flags */
185 #define METAFILE_TO_WORLD_IDENTITY 0x00000001
186 #define WORLD_TO_PAGE_IDENTITY 0x00000002
187 #define DEVICE_TO_PAGE_INVALID 0x00000008
188 #define DEVICE_TO_WORLD_INVALID 0x00000010
189 #define WORLD_TRANSFORM_SET 0x00000020
190 #define POSITIVE_Y_IS_UP 0x00000040
191 #define INVALIDATE_ATTRIBUTES 0x00000080
192 #define PTOD_EFM11_NEGATIVE 0x00000100
193 #define PTOD_EFM22_NEGATIVE 0x00000200
194 #define ISO_OR_ANISO_MAP_MODE 0x00000400
195 #define PAGE_TO_DEVICE_IDENTITY 0x00000800
196 #define PAGE_TO_DEVICE_SCALE_IDENTITY 0x00001000
197 #define PAGE_XLATE_CHANGED 0x00002000
198 #define PAGE_EXTENTS_CHANGED 0x00004000
199 #define WORLD_XFORM_CHANGED 0x00008000
200
201 /* BRUSH/RGN_ATTR Flags */
202 #define ATTR_CACHED 0x00000001
203 #define ATTR_TO_BE_DELETED 0x00000002
204 #define ATTR_NEW_COLOR 0x00000004
205 #define ATTR_CANT_SELECT 0x00000008
206 #define ATTR_RGN_VALID 0x00000010
207 #define ATTR_RGN_DIRTY 0x00000020
208
209
210 /* TYPES *********************************************************************/
211
212 typedef struct _GDI_TABLE_ENTRY
213 {
214 PVOID KernelData; /* Points to the kernel mode structure */
215 DWORD ProcessId; /* process id that created the object, 0 for stock objects */
216 union{ /* temp union structure. */
217 LONG Type; /* the first 16 bit is the object type including the stock obj flag, the last 16 bits is just the object type */
218 struct{
219 USHORT FullUnique; /* unique */
220 UCHAR ObjectType; /* objt */
221 UCHAR Flags; /* Flags */
222 };};
223 PVOID UserData; /* pUser Points to the user mode structure, usually NULL though */
224 } GDI_TABLE_ENTRY, *PGDI_TABLE_ENTRY;
225
226 typedef struct _ENTRY
227 {
228 union _EINFO
229 {
230 struct _BASEOBJECT *pobj;
231 HGDIOBJ hFree;
232 } einfo;
233
234 union _OBJECTOWNER
235 {
236 struct _OBJECTOWNER_S
237 {
238 unsigned Lock:1;
239 unsigned Pid_Shifted:31;
240 } Share;
241 ULONG ulObj;
242 } ObjectOwner;
243
244 USHORT FullUnique;
245 UCHAR Objt;
246 UCHAR Flags;
247 PVOID pUser;
248 } ENTRY, *PENTRY;
249
250 /*
251 * User space only structure!
252 */
253 typedef struct __GDI_SHARED_HANDLE_TABLE /* Must match win32k/include/gdiobj.h */
254 {
255 GDI_TABLE_ENTRY Entries[GDI_HANDLE_COUNT]; /* Handle table. */
256 DEVCAPS DevCaps; /* Shared device capabilities. */
257 FLONG flDeviceUniq; /* Device settings uniqueness. */
258 PVOID pvLangPack; /* Lanuage Pack. */
259 CFONT cfPublic[GDI_CFONT_MAX]; /* Public Fonts. */
260 DWORD dwCFCount;
261 } GDI_SHARED_HANDLE_TABLE, *PGDI_SHARED_HANDLE_TABLE;
262
263 typedef struct _RGN_ATTR
264 {
265 ULONG AttrFlags;
266 ULONG iComplexity; /* Clipping region's complexity. NULL, SIMPLE & COMPLEXREGION */
267 RECTL Rect;
268 } RGN_ATTR,*PRGN_ATTR;
269
270 /* Local DC structure (_DC_ATTR) PVOID pvLDC; */
271 typedef struct _LDC
272 {
273 HDC hDC;
274 ULONG Flags;
275 INT iType;
276 PVOID pvEmfDC; /* Pointer to ENHMETAFILE structure */
277 LPWSTR pwszPort;
278 ABORTPROC pAbortProc; /* AbortProc for Printing */
279 DWORD CallBackTick;
280 HANDLE hPrinter; /* Local or Remote Printer driver */
281 PVOID pUMPDev;
282 PUMDHPDEV pUMdhpdev;
283 DEVCAPS DevCaps;
284 HBRUSH BrushColor;
285 HPEN PenColor;
286 } LDC, *PLDC;
287
288 typedef struct _DC_ATTR
289 {
290 PVOID pvLDC;
291 ULONG ulDirty_;
292 HANDLE hbrush;
293 HANDLE hpen;
294 COLORREF crBackgroundClr;
295 ULONG ulBackgroundClr;
296 COLORREF crForegroundClr;
297 ULONG ulForegroundClr;
298 COLORREF crBrushClr;
299 ULONG ulBrushClr;
300 COLORREF crPenClr;
301 ULONG ulPenClr;
302 DWORD iCS_CP;
303 INT iGraphicsMode;
304 BYTE jROP2;
305 BYTE jBkMode;
306 BYTE jFillMode;
307 BYTE jStretchBltMode;
308 POINTL ptlCurrent;
309 POINTL ptfxCurrent;
310 LONG lBkMode;
311 LONG lFillMode;
312 LONG lStretchBltMode;
313 FLONG flFontMapper;
314 LONG lIcmMode;
315 HANDLE hcmXform;
316 HCOLORSPACE hColorSpace;
317 FLONG flIcmFlags;
318 INT IcmBrushColor;
319 INT IcmPenColor;
320 PVOID pvLIcm;
321 FLONG flTextAlign;
322 LONG lTextAlign;
323 LONG lTextExtra;
324 LONG lRelAbs;
325 LONG lBreakExtra;
326 LONG cBreak;
327 HANDLE hlfntNew;
328 MATRIX mxWorldToDevice;
329 MATRIX mxDeviceToWorld;
330 MATRIX mxWorldToPage;
331 FLOATOBJ efM11PtoD;
332 FLOATOBJ efM22PtoD;
333 FLOATOBJ efDxPtoD;
334 FLOATOBJ efDyPtoD;
335 INT iMapMode;
336 DWORD dwLayout;
337 LONG lWindowOrgx;
338 POINTL ptlWindowOrg;
339 SIZEL szlWindowExt;
340 POINTL ptlViewportOrg;
341 SIZEL szlViewportExt;
342 FLONG flXform;
343 SIZEL szlVirtualDevicePixel;
344 SIZEL szlVirtualDeviceMm;
345 SIZEL szlVirtualDeviceSize;
346 POINTL ptlBrushOrigin;
347 RGN_ATTR VisRectRegion;
348 } DC_ATTR, *PDC_ATTR;
349
350 typedef struct _BRUSH_ATTR /* Used with pen too. */
351 {
352 FLONG AttrFlags;
353 COLORREF lbColor;
354 } BRUSH_ATTR, *PBRUSH_ATTR;
355
356 typedef struct _FONT_ATTR
357 {
358 BOOL bSlowWidths;
359 PCFONT pCharWidthData;
360 } FONT_ATTR, *PFONT_ATTR;
361
362
363 #endif