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