Added reference counting and deferred deletion for GDI objects.
[reactos.git] / reactos / include / win32k / gdiobj.h
1 /*
2 * GDI object common header definition
3 *
4 * (RJJ) taken from WINE
5 */
6
7 #ifndef __WIN32K_GDIOBJ_H
8 #define __WIN32K_GDIOBJ_H
9
10 #include <ddk/ntddk.h>
11
12 /* GDI objects magic numbers */
13 #define GO_PEN_MAGIC 0x4f47
14 #define GO_BRUSH_MAGIC 0x4f48
15 #define GO_FONT_MAGIC 0x4f49
16 #define GO_PALETTE_MAGIC 0x4f4a
17 #define GO_BITMAP_MAGIC 0x4f4b
18 #define GO_REGION_MAGIC 0x4f4c
19 #define GO_DC_MAGIC 0x4f4d
20 #define GO_DISABLED_DC_MAGIC 0x4f4e
21 #define GO_META_DC_MAGIC 0x4f4f
22 #define GO_METAFILE_MAGIC 0x4f50
23 #define GO_METAFILE_DC_MAGIC 0x4f51
24 #define GO_ENHMETAFILE_MAGIC 0x4f52
25 #define GO_ENHMETAFILE_DC_MAGIC 0x4f53
26 #define GO_MAGIC_DONTCARE 0xffff
27
28 /* (RJJ) swiped stock handles from wine */
29 /* First handle possible for stock objects (must be >= GDI_HEAP_SIZE) */
30 #define FIRST_STOCK_HANDLE 0xffffff00
31
32 /* Stock objects handles */
33 #define NB_STOCK_OBJECTS (DEFAULT_GUI_FONT + 1)
34 #define STOCK_WHITE_BRUSH ((HBRUSH)(FIRST_STOCK_HANDLE+WHITE_BRUSH))
35 #define STOCK_LTGRAY_BRUSH ((HBRUSH)(FIRST_STOCK_HANDLE+LTGRAY_BRUSH))
36 #define STOCK_GRAY_BRUSH ((HBRUSH)(FIRST_STOCK_HANDLE+GRAY_BRUSH))
37 #define STOCK_DKGRAY_BRUSH ((HBRUSH)(FIRST_STOCK_HANDLE+DKGRAY_BRUSH))
38 #define STOCK_BLACK_BRUSH ((HBRUSH)(FIRST_STOCK_HANDLE+BLACK_BRUSH))
39 #define STOCK_NULL_BRUSH ((HBRUSH)(FIRST_STOCK_HANDLE+NULL_BRUSH))
40 #define STOCK_HOLLOW_BRUSH ((HBRUSH)(FIRST_STOCK_HANDLE+HOLLOW_BRUSH))
41 #define STOCK_WHITE_PEN ((HPEN)(FIRST_STOCK_HANDLE+WHITE_PEN))
42 #define STOCK_BLACK_PEN ((HPEN)(FIRST_STOCK_HANDLE+BLACK_PEN))
43 #define STOCK_NULL_PEN ((HPEN)(FIRST_STOCK_HANDLE+NULL_PEN))
44 #define STOCK_OEM_FIXED_FONT ((HFONT)(FIRST_STOCK_HANDLE+OEM_FIXED_FONT))
45 #define STOCK_ANSI_FIXED_FONT ((HFONT)(FIRST_STOCK_HANDLE+ANSI_FIXED_FONT))
46 #define STOCK_ANSI_VAR_FONT ((HFONT)(FIRST_STOCK_HANDLE+ANSI_VAR_FONT))
47 #define STOCK_SYSTEM_FONT ((HFONT)(FIRST_STOCK_HANDLE+SYSTEM_FONT))
48 #define STOCK_DEVICE_DEFAULT_FONT ((HFONT)(FIRST_STOCK_HANDLE+DEVICE_DEFAULT_FONT))
49 #define STOCK_DEFAULT_PALETTE ((HPALETTE)(FIRST_STOCK_HANDLE+DEFAULT_PALETTE))
50 #define STOCK_SYSTEM_FIXED_FONT ((HFONT)(FIRST_STOCK_HANDLE+SYSTEM_FIXED_FONT))
51 #define STOCK_DEFAULT_GUI_FONT ((HFONT)(FIRST_STOCK_HANDLE+DEFAULT_GUI_FONT))
52 #define FIRST_STOCK_FONT STOCK_OEM_FIXED_FONT
53 #define LAST_STOCK_FONT STOCK_DEFAULT_GUI_FONT
54 #define LAST_STOCK_HANDLE ((DWORD)STOCK_DEFAULT_GUI_FONT)
55
56 typedef struct _GDIOBJHDR
57 {
58 WORD wTableIndex;
59 DWORD dwCount; //reference count.
60 } GDIOBJHDR, *PGDIOBJHDR;
61
62 typedef PVOID PGDIOBJ;
63
64 typedef struct _GDI_HANDLE_ENTRY
65 {
66 WORD wMagic;
67 HANDLE hProcessId;
68 PGDIOBJ pObject;
69 } GDI_HANDLE_ENTRY, *PGDI_HANDLE_ENTRY;
70
71 typedef struct _GDI_HANDLE_TABLE
72 {
73 WORD wTableSize;
74 GDI_HANDLE_ENTRY Handles [1];
75 } GDI_HANDLE_TABLE, *PGDI_HANDLE_TABLE;
76
77 HGDIOBJ GDIOBJ_AllocObj(WORD Size, WORD Magic);
78 BOOL GDIOBJ_FreeObj (HGDIOBJ Obj, WORD Magic);
79 PGDIOBJ GDIOBJ_LockObj (HGDIOBJ Obj, WORD Magic);
80 BOOL GDIOBJ_UnlockObj (HGDIOBJ Obj, WORD Magic);
81 WORD GDIOBJ_GetHandleMagic (HGDIOBJ ObjectHandle);
82 VOID STDCALL W32kDumpGdiObjects( INT Process );
83
84 #endif
85