Commit the stuff. Lots of changes. I'll write a proper list of changes when it's...
[reactos.git] / subsystems / win32 / win32k / include / dc.h
1 #ifndef __WIN32K_DC_H
2 #define __WIN32K_DC_H
3
4 typedef struct _DC *PDC;
5
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 #define DC_DISPLAY 1
25 #define DC_DIRECT 2
26 #define DC_CANCELED 4
27 #define DC_PERMANANT 0x08
28 #define DC_DIRTY_RAO 0x10
29 #define DC_ACCUM_WMGR 0x20
30 #define DC_ACCUM_APP 0x40
31 #define DC_RESET 0x80
32 #define DC_SYNCHRONIZEACCESS 0x100
33 #define DC_EPSPRINTINGESCAPE 0x200
34 #define DC_TEMPINFODC 0x400
35 #define DC_FULLSCREEN 0x800
36 #define DC_IN_CLONEPDEV 0x1000
37 #define DC_REDIRECTION 0x2000
38 #define DC_SHAREACCESS 0x4000
39
40 typedef enum
41 {
42 DCTYPE_DIRECT = 0,
43 DCTYPE_MEMORY = 1,
44 DCTYPE_INFO = 2,
45 } DCTYPE;
46
47
48 /* Type definitions ***********************************************************/
49
50 typedef struct _ROS_DC_INFO
51 {
52 HRGN hClipRgn; /* Clip region (may be 0) */
53 HRGN hVisRgn; /* Visible region (must never be 0) */
54 HRGN hGCClipRgn; /* GC clip region (ClipRgn AND VisRgn) */
55
56 BYTE bitsPerPixel;
57
58 CLIPOBJ *CombinedClip;
59
60 UNICODE_STRING DriverName;
61
62 } ROS_DC_INFO;
63
64 /* EXtended CLip and Window Region Object */
65 typedef struct _XCLIPOBJ
66 {
67 WNDOBJ eClipWnd;
68 PVOID pClipRgn; /* prgnRao_ or (prgnVis_ if (prgnRao_ == z)) */
69 DWORD Unknown1[16];
70 DWORD nComplexity; /* count/mode based on # of rect in regions scan. */
71 PVOID pUnknown; /* UnK pointer to a large drawing structure. */
72 /* We will use it for CombinedClip ptr. */
73 } XCLIPOBJ, *PXCLIPOBJ;
74
75 typedef struct _DCLEVEL
76 {
77 HPALETTE hpal;
78 struct _PALETTE * ppal;
79 PVOID pColorSpace; /* COLORSPACE* */
80 LONG lIcmMode;
81 LONG lSaveDepth;
82 DWORD unk1_00000000;
83 HGDIOBJ hdcSave;
84 POINTL ptlBrushOrigin;
85 PBRUSH pbrFill;
86 PBRUSH pbrLine;
87 PVOID plfnt; /* LFONTOBJ* (TEXTOBJ*) */
88 HGDIOBJ hPath; /* HPATH */
89 FLONG flPath;
90 LINEATTRS laPath; /* 0x20 bytes */
91 PVOID prgnClip; /* PROSRGNDATA */
92 PVOID prgnMeta;
93 COLORADJUSTMENT ca;
94 FLONG flFontState;
95 UNIVERSAL_FONT_ID ufi;
96 UNIVERSAL_FONT_ID ufiLoc[4]; /* Local List. */
97 UNIVERSAL_FONT_ID *pUFI;
98 ULONG uNumUFIs;
99 BOOL ufiSet;
100 FLONG fl;
101 FLONG flBrush;
102 MATRIX mxWorldToDevice;
103 MATRIX mxDeviceToWorld;
104 MATRIX mxWorldToPage;
105 FLOATOBJ efM11PtoD;
106 FLOATOBJ efM22PtoD;
107 FLOATOBJ efDxPtoD;
108 FLOATOBJ efDyPtoD;
109 FLOATOBJ efM11_TWIPS;
110 FLOATOBJ efM22_TWIPS;
111 FLOATOBJ efPr11;
112 FLOATOBJ efPr22;
113 PSURFACE pSurface;
114 SIZE sizl;
115 } DCLEVEL, *PDCLEVEL;
116
117 /* The DC object structure */
118 typedef struct _DC
119 {
120 /* Header for all gdi objects in the handle table.
121 Do not (re)move this. */
122 BASEOBJECT BaseObject;
123
124 DHPDEV dhpdev; /* <- PDEVOBJ.hPDev DHPDEV for device. */
125 INT dctype;
126 INT fs;
127 PPDEVOBJ ppdev;
128 PVOID hsem; /* PERESOURCE aka HSEMAPHORE */
129 FLONG flGraphicsCaps;
130 FLONG flGraphicsCaps2;
131 PDC_ATTR pdcattr;
132 DCLEVEL dclevel;
133 DC_ATTR dcattr;
134 HDC hdcNext;
135 HDC hdcPrev;
136 RECTL erclClip;
137 POINTL ptlDCOrig;
138 RECTL erclWindow;
139 RECTL erclBounds;
140 RECTL erclBoundsApp;
141 PVOID prgnAPI; /* PROSRGNDATA */
142 PVOID prgnVis;
143 PVOID prgnRao;
144 POINTL ptlFillOrigin;
145 EBRUSHOBJ eboFill;
146 EBRUSHOBJ eboLine;
147 EBRUSHOBJ eboText;
148 EBRUSHOBJ eboBackground;
149 HFONT hlfntCur;
150 FLONG flSimulationFlags;
151 LONG lEscapement;
152 PVOID prfnt; /* RFONT* */
153 XCLIPOBJ co; /* CLIPOBJ */
154 PVOID pPFFList; /* PPFF* */
155 PVOID pClrxFormLnk;
156 INT ipfdDevMax;
157 ULONG ulCopyCount;
158 PVOID pSurfInfo;
159 POINTL ptlDoBanding;
160
161 /* Reactos specific members */
162 ROS_DC_INFO rosdc;
163 } DC;
164
165 /* Internal functions *********************************************************/
166
167 #if 0
168 #define DC_LockDc(hDC) \
169 ((PDC) GDIOBJ_LockObj ((HGDIOBJ) hDC, GDI_OBJECT_TYPE_DC))
170 #define DC_UnlockDc(pDC) \
171 GDIOBJ_UnlockObjByPtr ((POBJ)pDC)
172 #endif
173
174 VOID NTAPI EngAcquireSemaphoreShared(IN HSEMAPHORE hsem);
175
176 PDC
177 FORCEINLINE
178 DC_LockDc(HDC hdc)
179 {
180 PDC pdc;
181 pdc = GDIOBJ_LockObj(hdc, GDI_OBJECT_TYPE_DC);
182 // EngAcquireSemaphoreShared(pdc->ppdev->hsemDevLock);
183 return pdc;
184 }
185
186 void
187 FORCEINLINE
188 DC_UnlockDc(PDC pdc)
189 {
190 // EngReleaseSemaphore(pdc->ppdev->hsemDevLock);
191 GDIOBJ_UnlockObjByPtr(&pdc->BaseObject);
192 }
193
194
195 extern PDC defaultDCstate;
196
197 NTSTATUS FASTCALL InitDcImpl(VOID);
198 PPDEVOBJ FASTCALL IntEnumHDev(VOID);
199 PDC NTAPI DC_AllocDcWithHandle();
200 VOID FASTCALL DC_InitDC(HDC DCToInit);
201 VOID FASTCALL DC_AllocateDcAttr(HDC);
202 VOID FASTCALL DC_FreeDcAttr(HDC);
203 BOOL INTERNAL_CALL DC_Cleanup(PVOID ObjectBody);
204 BOOL FASTCALL DC_SetOwnership(HDC hDC, PEPROCESS Owner);
205 VOID FASTCALL DC_LockDisplay(HDC);
206 VOID FASTCALL DC_UnlockDisplay(HDC);
207 BOOL FASTCALL IntGdiDeleteDC(HDC, BOOL);
208
209 VOID FASTCALL DC_UpdateXforms(PDC dc);
210 BOOL FASTCALL DC_InvertXform(const XFORM *xformSrc, XFORM *xformDest);
211 VOID FASTCALL DC_vUpdateViewportExt(PDC pdc);
212 VOID FASTCALL DC_vCopyState(PDC pdcSrc, PDC pdcDst);
213 VOID FASTCALL DC_vUpdateFillBrush(PDC pdc);
214 VOID FASTCALL DC_vUpdateLineBrush(PDC pdc);
215 VOID FASTCALL DC_vUpdateTextBrush(PDC pdc);
216 VOID FASTCALL DC_vUpdateBackgroundBrush(PDC pdc);
217
218 VOID NTAPI DC_vRestoreDC(IN PDC pdc, INT iSaveLevel);
219
220 BOOL FASTCALL DCU_SyncDcAttrtoUser(PDC);
221 BOOL FASTCALL DCU_SynchDcAttrtoUser(HDC);
222 VOID FASTCALL DCU_SetDcUndeletable(HDC);
223 VOID NTAPI DC_vFreeDcAttr(PDC pdc);
224 VOID NTAPI DC_vInitDc(PDC pdc, DCTYPE dctype, PPDEVOBJ ppdev);
225
226 COLORREF FASTCALL IntGdiSetBkColor (HDC hDC, COLORREF Color);
227 INT FASTCALL IntGdiSetBkMode(HDC hDC, INT backgroundMode);
228 COLORREF APIENTRY IntGdiGetBkColor(HDC hDC);
229 INT APIENTRY IntGdiGetBkMode(HDC hDC);
230 COLORREF FASTCALL IntGdiSetTextColor(HDC hDC, COLORREF color);
231 UINT FASTCALL IntGdiSetTextAlign(HDC hDC, UINT Mode);
232 UINT APIENTRY IntGdiGetTextAlign(HDC hDC);
233 COLORREF APIENTRY IntGdiGetTextColor(HDC hDC);
234 INT APIENTRY IntGdiSetStretchBltMode(HDC hDC, INT stretchBltMode);
235 VOID FASTCALL IntGdiReferencePdev(PPDEVOBJ pPDev);
236 VOID FASTCALL IntGdiUnreferencePdev(PPDEVOBJ pPDev, DWORD CleanUpType);
237 HDC FASTCALL IntGdiCreateDisplayDC(HDEV hDev, ULONG DcType, BOOL EmptyDC);
238 BOOL FASTCALL IntGdiCleanDC(HDC hDC);
239 VOID FASTCALL IntvGetDeviceCaps(PPDEVOBJ, PDEVCAPS);
240
241 VOID
242 FORCEINLINE
243 DC_vSelectSurface(PDC pdc, PSURFACE psurfNew)
244 {
245 PSURFACE psurfOld = pdc->dclevel.pSurface;
246 if (psurfOld)
247 SURFACE_ShareUnlockSurface(psurfOld);
248 if (psurfNew)
249 GDIOBJ_IncrementShareCount((POBJ)psurfNew);
250 pdc->dclevel.pSurface = psurfNew;
251 }
252
253 VOID
254 FORCEINLINE
255 DC_vSelectFillBrush(PDC pdc, PBRUSH pbrFill)
256 {
257 PBRUSH pbrFillOld = pdc->dclevel.pbrFill;
258 if (pbrFillOld)
259 BRUSH_ShareUnlockBrush(pbrFillOld);
260 if (pbrFill)
261 GDIOBJ_IncrementShareCount((POBJ)pbrFill);
262 pdc->dclevel.pbrFill = pbrFill;
263 }
264
265 VOID
266 FORCEINLINE
267 DC_vSelectLineBrush(PDC pdc, PBRUSH pbrLine)
268 {
269 PBRUSH pbrLineOld = pdc->dclevel.pbrLine;
270 if (pbrLineOld)
271 BRUSH_ShareUnlockBrush(pbrLineOld);
272 if (pbrLine)
273 GDIOBJ_IncrementShareCount((POBJ)pbrLine);
274 pdc->dclevel.pbrLine = pbrLine;
275 }
276
277 VOID
278 FORCEINLINE
279 DC_vSelectPalette(PDC pdc, PPALETTE ppal)
280 {
281 PPALETTE ppalOld = pdc->dclevel.ppal;
282 if (ppalOld)
283 PALETTE_ShareUnlockPalette(ppalOld);
284 if (ppal)
285 GDIOBJ_IncrementShareCount((POBJ)ppal);
286 pdc->dclevel.ppal = ppal;
287 }
288
289 #endif /* not __WIN32K_DC_H */