48b0e921400eab0126fb2f9c81cced45b314f6c7
[reactos.git] / reactos / subsystems / win32 / win32k / include / dc.h
1 #pragma once
2
3 typedef struct _DC *PDC;
4
5 #include "engobjects.h"
6 #include "brush.h"
7 #include "bitmaps.h"
8 #include "pdevobj.h"
9 #include "palette.h"
10
11 /* Constants ******************************************************************/
12
13 /* Get/SetBounds/Rect support. */
14 #define DCB_WINDOWMGR 0x8000 /* Queries the Windows bounding rectangle instead of the application's */
15
16 /* flFontState */
17 #define DC_DIRTYFONT_XFORM 1
18 #define DC_DIRTYFONT_LFONT 2
19 #define DC_UFI_MAPPING 4
20
21 /* fl */
22 #define DC_FL_PAL_BACK 1
23
24 /* Type definitions ***********************************************************/
25
26 typedef struct _ROS_DC_INFO
27 {
28 HRGN hClipRgn; /* Clip region (may be 0) */
29 HRGN hVisRgn; /* Visible region (must never be 0) */
30 HRGN hGCClipRgn; /* GC clip region (ClipRgn AND VisRgn) */
31
32 BYTE bitsPerPixel;
33
34 CLIPOBJ *CombinedClip; /* Use XCLIPOBJ in DC. */
35
36 UNICODE_STRING DriverName;
37
38 } ROS_DC_INFO;
39
40 typedef struct _DCLEVEL
41 {
42 HPALETTE hpal;
43 struct _PALETTE * ppal;
44 PVOID pColorSpace; /* COLORSPACE* */
45 LONG lIcmMode;
46 LONG lSaveDepth;
47 DWORD unk1_00000000;
48 HGDIOBJ hdcSave;
49 POINTL ptlBrushOrigin;
50 PBRUSH pbrFill;
51 PBRUSH pbrLine;
52 PVOID plfnt; /* LFONTOBJ* (TEXTOBJ*) */
53 HGDIOBJ hPath; /* HPATH */
54 FLONG flPath;
55 LINEATTRS laPath; /* 0x20 bytes */
56 PVOID prgnClip; /* PROSRGNDATA */
57 PVOID prgnMeta;
58 COLORADJUSTMENT ca;
59 FLONG flFontState;
60 UNIVERSAL_FONT_ID ufi;
61 UNIVERSAL_FONT_ID ufiLoc[4]; /* Local List. */
62 UNIVERSAL_FONT_ID *pUFI;
63 ULONG uNumUFIs;
64 BOOL ufiSet;
65 FLONG fl;
66 FLONG flBrush;
67 MATRIX mxWorldToDevice;
68 MATRIX mxDeviceToWorld;
69 MATRIX mxWorldToPage;
70 FLOATOBJ efM11PtoD;
71 FLOATOBJ efM22PtoD;
72 FLOATOBJ efDxPtoD;
73 FLOATOBJ efDyPtoD;
74 FLOATOBJ efM11_TWIPS;
75 FLOATOBJ efM22_TWIPS;
76 FLOATOBJ efPr11;
77 FLOATOBJ efPr22;
78 PSURFACE pSurface;
79 SIZE sizl;
80 } DCLEVEL, *PDCLEVEL;
81
82 /* The DC object structure */
83 typedef struct _DC
84 {
85 /* Header for all gdi objects in the handle table.
86 Do not (re)move this. */
87 BASEOBJECT BaseObject;
88
89 DHPDEV dhpdev; /* <- PDEVOBJ.hPDev DHPDEV for device. */
90 INT dctype;
91 INT fs;
92 PPDEVOBJ ppdev;
93 PVOID hsem; /* PERESOURCE aka HSEMAPHORE */
94 FLONG flGraphicsCaps;
95 FLONG flGraphicsCaps2;
96 PDC_ATTR pdcattr;
97 DCLEVEL dclevel;
98 DC_ATTR dcattr;
99 HDC hdcNext;
100 HDC hdcPrev;
101 RECTL erclClip;
102 POINTL ptlDCOrig;
103 RECTL erclWindow;
104 RECTL erclBounds;
105 RECTL erclBoundsApp;
106 PVOID prgnAPI; /* PROSRGNDATA */
107 PVOID prgnVis;
108 PVOID prgnRao;
109 POINTL ptlFillOrigin;
110 EBRUSHOBJ eboFill;
111 EBRUSHOBJ eboLine;
112 EBRUSHOBJ eboText;
113 EBRUSHOBJ eboBackground;
114 HFONT hlfntCur;
115 FLONG flSimulationFlags;
116 LONG lEscapement;
117 PVOID prfnt; /* RFONT* */
118 XCLIPOBJ co; /* CLIPOBJ */
119 PVOID pPFFList; /* PPFF* */
120 PVOID pClrxFormLnk;
121 INT ipfdDevMax;
122 ULONG ulCopyCount;
123 PVOID pSurfInfo;
124 POINTL ptlDoBanding;
125
126 /* Reactos specific members */
127 ROS_DC_INFO rosdc;
128 } DC;
129
130 /* Internal functions *********************************************************/
131
132 #define DC_LockDc(hDC) \
133 ((PDC) GDIOBJ_LockObj ((HGDIOBJ) hDC, GDI_OBJECT_TYPE_DC))
134 #define DC_UnlockDc(pDC) \
135 GDIOBJ_UnlockObjByPtr ((POBJ)pDC)
136
137 extern PDC defaultDCstate;
138
139 NTSTATUS FASTCALL InitDcImpl(VOID);
140 PPDEVOBJ FASTCALL IntEnumHDev(VOID);
141 HDC FASTCALL DC_AllocDC(PUNICODE_STRING Driver);
142 VOID FASTCALL DC_InitDC(HDC DCToInit);
143 HDC FASTCALL DC_FindOpenDC(PUNICODE_STRING Driver);
144 VOID FASTCALL DC_AllocateDcAttr(HDC);
145 VOID FASTCALL DC_FreeDcAttr(HDC);
146 BOOL INTERNAL_CALL DC_Cleanup(PVOID ObjectBody);
147 BOOL FASTCALL DC_SetOwnership(HDC DC, PEPROCESS Owner);
148 VOID FASTCALL DC_LockDisplay(HDC);
149 VOID FASTCALL DC_UnlockDisplay(HDC);
150 BOOL FASTCALL IntGdiDeleteDC(HDC, BOOL);
151
152 VOID FASTCALL DC_UpdateXforms(PDC dc);
153 BOOL FASTCALL DC_InvertXform(const XFORM *xformSrc, XFORM *xformDest);
154 VOID FASTCALL DC_vUpdateViewportExt(PDC pdc);
155 VOID FASTCALL DC_vCopyState(PDC pdcSrc, PDC pdcDst, BOOL to);
156 VOID FASTCALL DC_vUpdateFillBrush(PDC pdc);
157 VOID FASTCALL DC_vUpdateLineBrush(PDC pdc);
158 VOID FASTCALL DC_vUpdateTextBrush(PDC pdc);
159 VOID FASTCALL DC_vUpdateBackgroundBrush(PDC pdc);
160
161 BOOL FASTCALL DCU_SyncDcAttrtoUser(PDC);
162 BOOL FASTCALL DCU_SynchDcAttrtoUser(HDC);
163 VOID FASTCALL DCU_SetDcUndeletable(HDC);
164
165 COLORREF FASTCALL IntGdiSetBkColor (HDC hDC, COLORREF Color);
166 INT FASTCALL IntGdiSetBkMode(HDC hDC, INT backgroundMode);
167 COLORREF APIENTRY IntGdiGetBkColor(HDC hDC);
168 INT APIENTRY IntGdiGetBkMode(HDC hDC);
169 COLORREF FASTCALL IntGdiSetTextColor(HDC hDC, COLORREF color);
170 UINT FASTCALL IntGdiSetTextAlign(HDC hDC, UINT Mode);
171 UINT APIENTRY IntGdiGetTextAlign(HDC hDC);
172 COLORREF APIENTRY IntGdiGetTextColor(HDC hDC);
173 INT APIENTRY IntGdiSetStretchBltMode(HDC hDC, INT stretchBltMode);
174 VOID FASTCALL IntGdiReferencePdev(PPDEVOBJ pPDev);
175 VOID FASTCALL IntGdiUnreferencePdev(PPDEVOBJ pPDev, DWORD CleanUpType);
176 HDC FASTCALL IntGdiCreateDisplayDC(HDEV hDev, ULONG DcType, BOOL EmptyDC);
177 BOOL FASTCALL IntGdiCleanDC(HDC hDC);
178 VOID FASTCALL IntvGetDeviceCaps(PPDEVOBJ, PDEVCAPS);
179 INT FASTCALL IntGdiGetDeviceCaps(PDC,INT);
180 BOOL FASTCALL MakeInfoDC(PDC,BOOL);
181 BOOL FASTCALL IntSetDefaultRegion(PDC);
182
183 extern PPDEVOBJ pPrimarySurface;
184
185 VOID
186 FORCEINLINE
187 DC_vSelectSurface(PDC pdc, PSURFACE psurfNew)
188 {
189 PSURFACE psurfOld = pdc->dclevel.pSurface;
190 if (psurfOld)
191 SURFACE_ShareUnlockSurface(psurfOld);
192 if (psurfNew)
193 GDIOBJ_IncrementShareCount((POBJ)psurfNew);
194 pdc->dclevel.pSurface = psurfNew;
195 }
196
197 VOID
198 FORCEINLINE
199 DC_vSelectFillBrush(PDC pdc, PBRUSH pbrFill)
200 {
201 PBRUSH pbrFillOld = pdc->dclevel.pbrFill;
202 if (pbrFillOld)
203 BRUSH_ShareUnlockBrush(pbrFillOld);
204 if (pbrFill)
205 GDIOBJ_IncrementShareCount((POBJ)pbrFill);
206 pdc->dclevel.pbrFill = pbrFill;
207 }
208
209 VOID
210 FORCEINLINE
211 DC_vSelectLineBrush(PDC pdc, PBRUSH pbrLine)
212 {
213 PBRUSH pbrLineOld = pdc->dclevel.pbrLine;
214 if (pbrLineOld)
215 BRUSH_ShareUnlockBrush(pbrLineOld);
216 if (pbrLine)
217 GDIOBJ_IncrementShareCount((POBJ)pbrLine);
218 pdc->dclevel.pbrLine = pbrLine;
219 }
220
221 VOID
222 FORCEINLINE
223 DC_vSelectPalette(PDC pdc, PPALETTE ppal)
224 {
225 PPALETTE ppalOld = pdc->dclevel.ppal;
226 if (ppalOld)
227 PALETTE_ShareUnlockPalette(ppalOld);
228 if (ppal)
229 GDIOBJ_IncrementShareCount((POBJ)ppal);
230 pdc->dclevel.ppal = ppal;
231 }
232
233 BOOL FASTCALL IntPrepareDriverIfNeeded(VOID);
234 extern PDEVOBJ PrimarySurface;