1 #ifndef __WIN32K_DC_H
2 #define __WIN32K_DC_H
3
4 /* Constants ******************************************************************/
5
6 /* flFontState */
7 enum _FONT_STATE
8 {
9 DC_DIRTYFONT_XFORM = 1,
10 DC_DIRTYFONT_LFONT = 2,
11 DC_UFI_MAPPING = 4
12 };
13
14 /* fl */
15 #define DC_FL_PAL_BACK 1
16
17 typedef enum _DCFLAGS
18 {
19 DC_DISPLAY = 0x0001,
20 DC_DIRECT = 0x0002,
21 DC_CANCELED = 0x0004,
22 DC_PERMANANT = 0x0008,
23 DC_DIRTY_RAO = 0x0010,
24 DC_ACCUM_WMGR = 0x0020,
25 DC_ACCUM_APP = 0x0040,
26 DC_RESET = 0x0080,
27 DC_SYNCHRONIZEACCESS = 0x0100,
28 DC_EPSPRINTINGESCAPE = 0x0200,
29 DC_TEMPINFODC = 0x0400,
30 DC_FULLSCREEN = 0x0800,
31 DC_IN_CLONEPDEV = 0x1000,
32 DC_REDIRECTION = 0x2000,
33 DC_SHAREACCESS = 0x4000,
34 #if DBG
35 DC_PREPARED = 0x8000
36 #endif
37 } DCFLAGS;
38
39 typedef enum _DCTYPE
40 {
41 DCTYPE_DIRECT = 0, /* Normal device context */
42 DCTYPE_MEMORY = 1, /* Memory device context */
43 DCTYPE_INFO = 2, /* Information context */
44 } DCTYPE;
45
46
47 /* Type definitions ***********************************************************/
48
49 typedef struct _DCLEVEL
50 {
51 HPALETTE hpal;
52 struct _PALETTE * ppal;
53 PVOID pColorSpace; /* COLORSPACE* */
54 LONG lIcmMode;
55 LONG lSaveDepth;
56 DWORD unk1_00000000;
57 HGDIOBJ hdcSave;
58 POINTL ptlBrushOrigin;
59 PBRUSH pbrFill;
60 PBRUSH pbrLine;
61 _Notnull_ struct _LFONT * plfnt; /* LFONT* (TEXTOBJ*) */
62 HGDIOBJ hPath; /* HPATH */
63 FLONG flPath;
64 LINEATTRS laPath; /* 0x20 bytes */
65 PREGION prgnClip;
66 PREGION prgnMeta;
67 COLORADJUSTMENT ca;
68 FLONG flFontState;
69 UNIVERSAL_FONT_ID ufi;
70 UNIVERSAL_FONT_ID ufiLoc[4]; /* Local List. */
71 UNIVERSAL_FONT_ID *pUFI;
72 ULONG uNumUFIs;
73 BOOL ufiSet;
74 FLONG fl;
75 FLONG flBrush;
76 MATRIX mxWorldToDevice;
77 MATRIX mxDeviceToWorld;
78 MATRIX mxWorldToPage;
79 FLOATOBJ efM11PtoD;
80 FLOATOBJ efM22PtoD;
81 FLOATOBJ efDxPtoD;
82 FLOATOBJ efDyPtoD;
83 FLOATOBJ efM11_TWIPS;
84 FLOATOBJ efM22_TWIPS;
85 FLOATOBJ efPr11;
86 FLOATOBJ efPr22;
87 PSURFACE pSurface;
88 SIZE sizl;
89 } DCLEVEL, *PDCLEVEL;
90
91 /*
92 * The DC object structure.
93 * See also: https://reactos.org/wiki/Techwiki:Win32k/DC
94 */
95 typedef struct _DC
96 {
97 /* Header for all gdi objects in the handle table.
98 Do not (re)move this. */
99 BASEOBJECT BaseObject;
100
101 DHPDEV dhpdev; /* <- PDEVOBJ.hPDev DHPDEV for device. */
102 DCTYPE dctype;
103 INT fs;
104 PPDEVOBJ ppdev;
105 PVOID hsem; /* PERESOURCE aka HSEMAPHORE */
106 FLONG flGraphicsCaps;
107 FLONG flGraphicsCaps2;
108 _Notnull_ PDC_ATTR pdcattr;
109 DCLEVEL dclevel;
110 DC_ATTR dcattr;
111 HDC hdcNext;
112 HDC hdcPrev;
113 RECTL erclClip;
114 POINTL ptlDCOrig;
115 RECTL erclWindow;
116 RECTL erclBounds;
117 RECTL erclBoundsApp;
118 PREGION prgnAPI;
119 _Notnull_ PREGION prgnVis; /* Visible region (must never be 0) */
120 PREGION prgnRao;
121 POINTL ptlFillOrigin;
122 EBRUSHOBJ eboFill;
123 EBRUSHOBJ eboLine;
124 EBRUSHOBJ eboText;
125 EBRUSHOBJ eboBackground;
126 HFONT hlfntCur;
127 FLONG flSimulationFlags;
128 LONG lEscapement;
129 PVOID prfnt; /* RFONT* */
130 XCLIPOBJ co; /* CLIPOBJ */
131 PVOID pPFFList; /* PPFF* */
132 PVOID pClrxFormLnk;
133 INT ipfdDevMax;
134 ULONG ulCopyCount;
135 PVOID pSurfInfo;
136 POINTL ptlDoBanding;
137 } DC;
138 // typedef struct _DC *PDC;
139
140 extern PDC defaultDCstate;
141
142 /* Internal functions *********************************************************/
143
144 /* dcobjs.c */
145
146 VOID FASTCALL DC_vUpdateFillBrush(PDC pdc);
147 VOID FASTCALL DC_vUpdateLineBrush(PDC pdc);
148 VOID FASTCALL DC_vUpdateTextBrush(PDC pdc);
149 VOID FASTCALL DC_vUpdateBackgroundBrush(PDC pdc);
150
151 HFONT
152 NTAPI
153 DC_hSelectFont(
154 _In_ PDC pdc,
155 _In_ HFONT hlfntNew);
156
157 HPALETTE
158 NTAPI
159 GdiSelectPalette(
160 _In_ HDC hDC,
161 _In_ HPALETTE hpal,
162 _In_ BOOL ForceBackground);
163
164 /* dcutil.c */
165
166 COLORREF
167 FASTCALL
168 IntGdiSetBkColor(
169 _In_ HDC hDC,
170 _In_ COLORREF Color);
171
172 INT FASTCALL IntGdiSetBkMode(HDC hDC, INT backgroundMode);
173 COLORREF FASTCALL IntGdiSetTextColor(HDC hDC, COLORREF color);
174 UINT FASTCALL IntGdiSetTextAlign(HDC hDC, UINT Mode);
175 VOID FASTCALL DCU_SetDcUndeletable(HDC);
176 BOOL FASTCALL IntSetDefaultRegion(PDC);
177 ULONG TranslateCOLORREF(PDC pdc, COLORREF crColor);
178 int FASTCALL GreSetStretchBltMode(HDC hdc, int iStretchMode);
179 int FASTCALL GreGetBkMode(HDC);
180 int FASTCALL GreGetMapMode(HDC);
181 COLORREF FASTCALL GreGetTextColor(HDC);
182 COLORREF FASTCALL GreGetBkColor(HDC);
183 COLORREF FASTCALL IntSetDCBrushColor(HDC,COLORREF);
184 COLORREF FASTCALL IntSetDCPenColor(HDC,COLORREF);
185 int FASTCALL GreGetGraphicsMode(HDC);
186 BOOL FASTCALL GreSetBrushOrg(HDC,INT,INT,LPPOINT);
187
188 CODE_SEG("INIT") NTSTATUS NTAPI InitDcImpl(VOID);
189 PPDEVOBJ FASTCALL IntEnumHDev(VOID);
190 PDC NTAPI DC_AllocDcWithHandle(GDILOOBJTYPE eDcObjType);
191 BOOL NTAPI DC_bAllocDcAttr(PDC pdc);
192 VOID NTAPI DC_vCleanup(PVOID ObjectBody);
193 BOOL FASTCALL IntGdiDeleteDC(HDC, BOOL);
194
195 BOOL FASTCALL DC_InvertXform(const XFORM *xformSrc, XFORM *xformDest);
196 VOID FASTCALL DC_vUpdateViewportExt(PDC pdc);
197 VOID FASTCALL DC_vCopyState(PDC pdcSrc, PDC pdcDst, BOOL To);
198 VOID FASTCALL DC_vFinishBlit(PDC pdc1, PDC pdc2);
199 VOID FASTCALL DC_vPrepareDCsForBlit(PDC pdcDest, const RECT* rcDest, PDC pdcSrc, const RECT* rcSrc);
200
201 VOID NTAPI DC_vRestoreDC(IN PDC pdc, INT iSaveLevel);
202
203 VOID NTAPI DC_vFreeDcAttr(PDC pdc);
204 VOID NTAPI DC_vInitDc(PDC pdc, DCTYPE dctype, PPDEVOBJ ppdev);
205
206 HDC FASTCALL IntGdiCreateDisplayDC(HDEV hDev, ULONG DcType, BOOL EmptyDC);
207 BOOL FASTCALL IntGdiCleanDC(HDC hDC);
208 VOID FASTCALL IntvGetDeviceCaps(PPDEVOBJ, PDEVCAPS);
209 VOID FASTCALL IntUpdateBoundsRect(PDC,PRECTL);
210
211 BOOL NTAPI GreSetDCOwner(HDC hdc, ULONG ulOwner);
212 HDC APIENTRY GreCreateCompatibleDC(HDC hdc, BOOL bAltDc);
213
214 VOID
215 NTAPI
216 DC_vSetBrushOrigin(PDC pdc, LONG x, LONG y);
217
218 FORCEINLINE
219 PDC
DC_LockDc(HDC hdc)220 DC_LockDc(HDC hdc)
221 {
222 PDC pdc;
223
224 pdc = (PDC)GDIOBJ_LockObject(hdc, GDIObjType_DC_TYPE);
225 if (pdc)
226 {
227 ASSERT((GDI_HANDLE_GET_TYPE(pdc->BaseObject.hHmgr) == GDILoObjType_LO_DC_TYPE) ||
228 (GDI_HANDLE_GET_TYPE(pdc->BaseObject.hHmgr) == GDILoObjType_LO_ALTDC_TYPE));
229 ASSERT(pdc->dclevel.plfnt != NULL);
230 ASSERT(GDI_HANDLE_GET_TYPE(((POBJ)pdc->dclevel.plfnt)->hHmgr) == GDILoObjType_LO_FONT_TYPE);
231 }
232
233 return pdc;
234 }
235
236 FORCEINLINE
237 VOID
DC_UnlockDc(PDC pdc)238 DC_UnlockDc(PDC pdc)
239 {
240 ASSERT(pdc->dclevel.plfnt != NULL);
241 ASSERT(GDI_HANDLE_GET_TYPE(((POBJ)pdc->dclevel.plfnt)->hHmgr) == GDILoObjType_LO_FONT_TYPE);
242
243 GDIOBJ_vUnlockObject(&pdc->BaseObject);
244 }
245
246 FORCEINLINE
247 VOID
DC_vSelectSurface(PDC pdc,PSURFACE psurfNew)248 DC_vSelectSurface(PDC pdc, PSURFACE psurfNew)
249 {
250 PSURFACE psurfOld = pdc->dclevel.pSurface;
251 if (psurfOld)
252 {
253 psurfOld->hdc = NULL;
254 SURFACE_ShareUnlockSurface(psurfOld);
255 }
256 if (psurfNew)
257 GDIOBJ_vReferenceObjectByPointer((POBJ)psurfNew);
258 pdc->dclevel.pSurface = psurfNew;
259 }
260
261 FORCEINLINE
262 VOID
DC_vSelectFillBrush(PDC pdc,PBRUSH pbrFill)263 DC_vSelectFillBrush(PDC pdc, PBRUSH pbrFill)
264 {
265 PBRUSH pbrFillOld = pdc->dclevel.pbrFill;
266 if (pbrFillOld)
267 BRUSH_ShareUnlockBrush(pbrFillOld);
268 if (pbrFill)
269 GDIOBJ_vReferenceObjectByPointer((POBJ)pbrFill);
270 pdc->dclevel.pbrFill = pbrFill;
271 }
272
273 FORCEINLINE
274 VOID
DC_vSelectLineBrush(PDC pdc,PBRUSH pbrLine)275 DC_vSelectLineBrush(PDC pdc, PBRUSH pbrLine)
276 {
277 PBRUSH pbrLineOld = pdc->dclevel.pbrLine;
278 if (pbrLineOld)
279 BRUSH_ShareUnlockBrush(pbrLineOld);
280 if (pbrLine)
281 GDIOBJ_vReferenceObjectByPointer((POBJ)pbrLine);
282 pdc->dclevel.pbrLine = pbrLine;
283 }
284
285 FORCEINLINE
286 VOID
DC_vSelectPalette(PDC pdc,PPALETTE ppal)287 DC_vSelectPalette(PDC pdc, PPALETTE ppal)
288 {
289 PPALETTE ppalOld = pdc->dclevel.ppal;
290 if (ppalOld)
291 PALETTE_ShareUnlockPalette(ppalOld);
292 if (ppal)
293 GDIOBJ_vReferenceObjectByPointer((POBJ)ppal);
294 pdc->dclevel.ppal = ppal;
295 }
296
297 extern _Notnull_ PBRUSH pbrDefaultBrush;
298 extern _Notnull_ PSURFACE psurfDefaultBitmap;
299
300 #define ASSERT_DC_PREPARED(pdc) NT_ASSERT((pdc)->fs & DC_PREPARED)
301
302 #endif /* not __WIN32K_DC_H */
303