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