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 HRGN hClipRgn; /* Clip region (may be 0) */ 52 HRGN hGCClipRgn; /* GC clip region (ClipRgn AND VisRgn) */ 53 54 CLIPOBJ *CombinedClip; 55 } ROS_DC_INFO; 56 57 typedef struct _DCLEVEL 58 { 59 HPALETTE hpal; 60 struct _PALETTE * ppal; 61 PVOID pColorSpace; /* COLORSPACE* */ 62 LONG lIcmMode; 63 LONG lSaveDepth; 64 DWORD unk1_00000000; 65 HGDIOBJ hdcSave; 66 POINTL ptlBrushOrigin; 67 PBRUSH pbrFill; 68 PBRUSH pbrLine; 69 _Notnull_ struct _LFONT * plfnt; /* LFONT* (TEXTOBJ*) */ 70 HGDIOBJ hPath; /* HPATH */ 71 FLONG flPath; 72 LINEATTRS laPath; /* 0x20 bytes */ 73 PREGION prgnClip; 74 PREGION prgnMeta; 75 COLORADJUSTMENT ca; 76 FLONG flFontState; 77 UNIVERSAL_FONT_ID ufi; 78 UNIVERSAL_FONT_ID ufiLoc[4]; /* Local List. */ 79 UNIVERSAL_FONT_ID *pUFI; 80 ULONG uNumUFIs; 81 BOOL ufiSet; 82 FLONG fl; 83 FLONG flBrush; 84 MATRIX mxWorldToDevice; 85 MATRIX mxDeviceToWorld; 86 MATRIX mxWorldToPage; 87 FLOATOBJ efM11PtoD; 88 FLOATOBJ efM22PtoD; 89 FLOATOBJ efDxPtoD; 90 FLOATOBJ efDyPtoD; 91 FLOATOBJ efM11_TWIPS; 92 FLOATOBJ efM22_TWIPS; 93 FLOATOBJ efPr11; 94 FLOATOBJ efPr22; 95 PSURFACE pSurface; 96 SIZE sizl; 97 } DCLEVEL, *PDCLEVEL; 98 99 /* The DC object structure */ 100 typedef struct _DC 101 { 102 /* Header for all gdi objects in the handle table. 103 Do not (re)move this. */ 104 BASEOBJECT BaseObject; 105 106 DHPDEV dhpdev; /* <- PDEVOBJ.hPDev DHPDEV for device. */ 107 INT dctype; 108 INT fs; 109 PPDEVOBJ ppdev; 110 PVOID hsem; /* PERESOURCE aka HSEMAPHORE */ 111 FLONG flGraphicsCaps; 112 FLONG flGraphicsCaps2; 113 _Notnull_ PDC_ATTR pdcattr; 114 DCLEVEL dclevel; 115 DC_ATTR dcattr; 116 HDC hdcNext; 117 HDC hdcPrev; 118 RECTL erclClip; 119 POINTL ptlDCOrig; 120 RECTL erclWindow; 121 RECTL erclBounds; 122 RECTL erclBoundsApp; 123 PREGION prgnAPI; 124 PREGION prgnVis; /* Visible region (must never be 0) */ 125 PREGION prgnRao; 126 POINTL ptlFillOrigin; 127 EBRUSHOBJ eboFill; 128 EBRUSHOBJ eboLine; 129 EBRUSHOBJ eboText; 130 EBRUSHOBJ eboBackground; 131 HFONT hlfntCur; 132 FLONG flSimulationFlags; 133 LONG lEscapement; 134 PVOID prfnt; /* RFONT* */ 135 XCLIPOBJ co; /* CLIPOBJ */ 136 PVOID pPFFList; /* PPFF* */ 137 PVOID pClrxFormLnk; 138 INT ipfdDevMax; 139 ULONG ulCopyCount; 140 PVOID pSurfInfo; 141 POINTL ptlDoBanding; 142 143 /* Reactos specific members */ 144 ROS_DC_INFO rosdc; 145 } DC; 146 147 extern PDC defaultDCstate; 148 149 /* Internal functions *********************************************************/ 150 151 /* dcobjs.c */ 152 153 VOID FASTCALL DC_vUpdateFillBrush(PDC pdc); 154 VOID FASTCALL DC_vUpdateLineBrush(PDC pdc); 155 VOID FASTCALL DC_vUpdateTextBrush(PDC pdc); 156 VOID FASTCALL DC_vUpdateBackgroundBrush(PDC pdc); 157 158 HFONT 159 NTAPI 160 DC_hSelectFont( 161 _In_ PDC pdc, 162 _In_ HFONT hlfntNew); 163 164 HPALETTE 165 NTAPI 166 GdiSelectPalette( 167 _In_ HDC hDC, 168 _In_ HPALETTE hpal, 169 _In_ BOOL ForceBackground); 170 171 /* dcutil.c */ 172 173 COLORREF 174 FASTCALL 175 IntGdiSetBkColor( 176 _In_ HDC hDC, 177 _In_ COLORREF Color); 178 179 INT FASTCALL IntGdiSetBkMode(HDC hDC, INT backgroundMode); 180 COLORREF FASTCALL IntGdiSetTextColor(HDC hDC, COLORREF color); 181 UINT FASTCALL IntGdiSetTextAlign(HDC hDC, UINT Mode); 182 VOID FASTCALL DCU_SetDcUndeletable(HDC); 183 BOOL FASTCALL IntSetDefaultRegion(PDC); 184 ULONG TranslateCOLORREF(PDC pdc, COLORREF crColor); 185 int FASTCALL GreSetStretchBltMode(HDC hdc, int iStretchMode); 186 int FASTCALL GreGetBkMode(HDC); 187 int FASTCALL GreGetMapMode(HDC); 188 COLORREF FASTCALL GreGetTextColor(HDC); 189 COLORREF FASTCALL IntSetDCBrushColor(HDC,COLORREF); 190 COLORREF FASTCALL IntSetDCPenColor(HDC,COLORREF); 191 192 193 INIT_FUNCTION NTSTATUS NTAPI InitDcImpl(VOID); 194 PPDEVOBJ FASTCALL IntEnumHDev(VOID); 195 PDC NTAPI DC_AllocDcWithHandle(VOID); 196 BOOL NTAPI DC_bAllocDcAttr(PDC pdc); 197 BOOL NTAPI DC_Cleanup(PVOID ObjectBody); 198 BOOL FASTCALL IntGdiDeleteDC(HDC, BOOL); 199 200 BOOL FASTCALL DC_InvertXform(const XFORM *xformSrc, XFORM *xformDest); 201 VOID FASTCALL DC_vUpdateViewportExt(PDC pdc); 202 VOID FASTCALL DC_vCopyState(PDC pdcSrc, PDC pdcDst, BOOL to); 203 VOID FASTCALL DC_vFinishBlit(PDC pdc1, PDC pdc2); 204 VOID FASTCALL DC_vPrepareDCsForBlit(PDC pdc1, RECT rc1, PDC pdc2, RECT rc2); 205 206 VOID NTAPI DC_vRestoreDC(IN PDC pdc, INT iSaveLevel); 207 208 VOID NTAPI DC_vFreeDcAttr(PDC pdc); 209 VOID NTAPI DC_vInitDc(PDC pdc, DCTYPE dctype, PPDEVOBJ ppdev); 210 211 VOID FASTCALL IntGdiReferencePdev(PPDEVOBJ pPDev); 212 VOID FASTCALL IntGdiUnreferencePdev(PPDEVOBJ pPDev, DWORD CleanUpType); 213 HDC FASTCALL IntGdiCreateDisplayDC(HDEV hDev, ULONG DcType, BOOL EmptyDC); 214 BOOL FASTCALL IntGdiCleanDC(HDC hDC); 215 VOID FASTCALL IntvGetDeviceCaps(PPDEVOBJ, PDEVCAPS); 216 217 BOOL NTAPI GreSetDCOwner(HDC hdc, ULONG ulOwner); 218 219 VOID 220 NTAPI 221 DC_vSetBrushOrigin(PDC pdc, LONG x, LONG y); 222 223 FORCEINLINE 224 PDC 225 DC_LockDc(HDC hdc) 226 { 227 PDC pdc; 228 229 pdc = GDIOBJ_LockObject(hdc, GDIObjType_DC_TYPE); 230 if (pdc) 231 { 232 ASSERT(GDI_HANDLE_GET_TYPE(pdc->BaseObject.hHmgr) == GDILoObjType_LO_DC_TYPE); 233 ASSERT(pdc->dclevel.plfnt != NULL); 234 ASSERT(GDI_HANDLE_GET_TYPE(((POBJ)pdc->dclevel.plfnt)->hHmgr) == GDILoObjType_LO_FONT_TYPE); 235 } 236 237 return pdc; 238 } 239 240 FORCEINLINE 241 VOID 242 DC_UnlockDc(PDC pdc) 243 { 244 ASSERT(pdc->dclevel.plfnt != NULL); 245 ASSERT(GDI_HANDLE_GET_TYPE(((POBJ)pdc->dclevel.plfnt)->hHmgr) == GDILoObjType_LO_FONT_TYPE); 246 247 GDIOBJ_vUnlockObject(&pdc->BaseObject); 248 } 249 250 VOID 251 FORCEINLINE 252 DC_vSelectSurface(PDC pdc, PSURFACE psurfNew) 253 { 254 PSURFACE psurfOld = pdc->dclevel.pSurface; 255 if (psurfOld) 256 { 257 psurfOld->hdc = NULL; 258 SURFACE_ShareUnlockSurface(psurfOld); 259 } 260 if (psurfNew) 261 GDIOBJ_vReferenceObjectByPointer((POBJ)psurfNew); 262 pdc->dclevel.pSurface = psurfNew; 263 } 264 265 VOID 266 FORCEINLINE 267 DC_vSelectFillBrush(PDC pdc, PBRUSH pbrFill) 268 { 269 PBRUSH pbrFillOld = pdc->dclevel.pbrFill; 270 if (pbrFillOld) 271 BRUSH_ShareUnlockBrush(pbrFillOld); 272 if (pbrFill) 273 GDIOBJ_vReferenceObjectByPointer((POBJ)pbrFill); 274 pdc->dclevel.pbrFill = pbrFill; 275 } 276 277 VOID 278 FORCEINLINE 279 DC_vSelectLineBrush(PDC pdc, PBRUSH pbrLine) 280 { 281 PBRUSH pbrLineOld = pdc->dclevel.pbrLine; 282 if (pbrLineOld) 283 BRUSH_ShareUnlockBrush(pbrLineOld); 284 if (pbrLine) 285 GDIOBJ_vReferenceObjectByPointer((POBJ)pbrLine); 286 pdc->dclevel.pbrLine = pbrLine; 287 } 288 289 VOID 290 FORCEINLINE 291 DC_vSelectPalette(PDC pdc, PPALETTE ppal) 292 { 293 PPALETTE ppalOld = pdc->dclevel.ppal; 294 if (ppalOld) 295 PALETTE_ShareUnlockPalette(ppalOld); 296 if (ppal) 297 GDIOBJ_vReferenceObjectByPointer((POBJ)ppal); 298 pdc->dclevel.ppal = ppal; 299 } 300 301 extern _Notnull_ PBRUSH pbrDefaultBrush; 302 extern _Notnull_ PSURFACE psurfDefaultBitmap; 303 304 #endif /* not __WIN32K_DC_H */ 305