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