ReactOS  0.4.13-dev-52-g0efcfec
dclife.c File Reference
#include <win32k.h>
#include <debug.h>
Include dependency graph for dclife.c:

Go to the source code of this file.

Macros

#define NDEBUG
 
#define DIRTY_DEFAULT   DIRTY_CHARSET|DIRTY_BACKGROUND|DIRTY_TEXT|DIRTY_LINE|DIRTY_FILL
 
#define gmxWorldToDeviceDefault   gmxWorldToPageDefault
 
#define gmxDeviceToWorldDefault   gmxWorldToPageDefault
 

Functions

INIT_FUNCTION NTSTATUS NTAPI InitDcImpl (VOID)
 
PDC NTAPI DC_AllocDcWithHandle (GDILOOBJTYPE eDcObjType)
 
void DC_InitHack (PDC pdc)
 
VOID NTAPI DC_vInitDc (PDC pdc, DCTYPE dctype, PPDEVOBJ ppdev)
 
VOID NTAPI DC_vCleanup (PVOID ObjectBody)
 
VOID NTAPI DC_vSetOwner (PDC pdc, ULONG ulOwner)
 
BOOL NTAPI GreSetDCOwner (HDC hdc, ULONG ulOwner)
 
static void DC_vUpdateDC (PDC pdc)
 
VOID FASTCALL DC_vPrepareDCsForBlit (PDC pdcDest, const RECT *rcDest, PDC pdcSrc, const RECT *rcSrc)
 
VOID FASTCALL DC_vFinishBlit (PDC pdc1, PDC pdc2)
 
HDC NTAPI GreOpenDCW (PUNICODE_STRING pustrDevice, DEVMODEW *pdmInit, PUNICODE_STRING pustrLogAddr, ULONG iType, BOOL bDisplay, HANDLE hspool, VOID *pDriverInfo2, VOID *pUMdhpdev)
 
__kernel_entry HDC APIENTRY NtGdiOpenDCW (_In_opt_ PUNICODE_STRING pustrDevice, _In_ DEVMODEW *pdmInit, _In_ PUNICODE_STRING pustrLogAddr, _In_ ULONG iType, _In_ BOOL bDisplay, _In_opt_ HANDLE hspool, _At_((PUMDHPDEV *) pUMdhpdev, _Out_) PVOID pUMdhpdev)
 
HDC APIENTRY GreCreateCompatibleDC (HDC hdc, BOOL bAltDc)
 
HDC APIENTRY NtGdiCreateCompatibleDC (HDC hdc)
 
BOOL FASTCALL IntGdiDeleteDC (HDC hDC, BOOL Force)
 
BOOL APIENTRY NtGdiDeleteObjectApp (HANDLE hobj)
 
BOOL FASTCALL MakeInfoDC (PDC pdc, BOOL bSet)
 
BOOL APIENTRY NtGdiMakeInfoDC (IN HDC hdc, IN BOOL bSet)
 
HDC FASTCALL IntGdiCreateDC (PUNICODE_STRING Driver, PUNICODE_STRING pustrDevice, PVOID pUMdhpdev, CONST PDEVMODEW pdmInit, BOOL CreateAsIC)
 
HDC FASTCALL IntGdiCreateDisplayDC (HDEV hDev, ULONG DcType, BOOL EmptyDC)
 

Variables

PSURFACE psurfDefaultBitmap = NULL
 
PBRUSH pbrDefaultBrush = NULL
 
const MATRIX gmxWorldToDeviceDefault
 
const MATRIX gmxDeviceToWorldDefault
 
const MATRIX gmxWorldToPageDefault
 

Macro Definition Documentation

◆ DIRTY_DEFAULT

Definition at line 15 of file dclife.c.

◆ gmxDeviceToWorldDefault

#define gmxDeviceToWorldDefault   gmxWorldToPageDefault

Definition at line 46 of file dclife.c.

◆ gmxWorldToDeviceDefault

#define gmxWorldToDeviceDefault   gmxWorldToPageDefault

Definition at line 45 of file dclife.c.

◆ NDEBUG

#define NDEBUG

Definition at line 11 of file dclife.c.

Function Documentation

◆ DC_AllocDcWithHandle()

PDC NTAPI DC_AllocDcWithHandle ( GDILOOBJTYPE  eDcObjType)

Definition at line 69 of file dclife.c.

70 {
71  PDC pdc;
72 
73  NT_ASSERT((eDcObjType == GDILoObjType_LO_DC_TYPE) ||
74  (eDcObjType == GDILoObjType_LO_ALTDC_TYPE));
75 
76  /* Allocate the object */
78  sizeof(DC),
80  if (!pdc)
81  {
82  DPRINT1("Could not allocate a DC.\n");
83  return NULL;
84  }
85 
86  /* Set the actual DC type */
87  pdc->BaseObject.hHmgr = UlongToHandle(eDcObjType);
88 
89  pdc->pdcattr = &pdc->dcattr;
90 
91  /* Insert the object */
92  if (!GDIOBJ_hInsertObject(&pdc->BaseObject, GDI_OBJ_HMGR_POWNED))
93  {
94  DPRINT1("Could not insert DC into handle table.\n");
95  GDIOBJ_vFreeObject(&pdc->BaseObject);
96  return NULL;
97  }
98 
99  return pdc;
100 }
struct DC * PDC
smooth NULL
Definition: ftsmooth.c:416
Definition: polytest.cpp:40
#define UlongToHandle(ul)
Definition: basetsd.h:97
#define GDI_OBJ_HMGR_POWNED
Definition: ntgdihdl.h:117
#define DPRINT1
Definition: precomp.h:8
POBJ NTAPI GDIOBJ_AllocateObject(UCHAR objt, ULONG cjSize, FLONG fl)
Definition: gdiobj.c:557
VOID NTAPI GDIOBJ_vFreeObject(POBJ pobj)
Definition: gdiobj.c:591
#define NT_ASSERT
Definition: rtlfuncs.h:3312
HGDIOBJ NTAPI GDIOBJ_hInsertObject(POBJ pobj, ULONG ulOwner)
Definition: gdiobj.c:907

Referenced by GreCreateCompatibleDC(), GreOpenDCW(), and NtGdiSaveDC().

◆ DC_InitHack()

void DC_InitHack ( PDC  pdc)

Definition at line 104 of file dclife.c.

105 {
106  if (defaultDCstate == NULL)
107  {
110  RtlZeroMemory(defaultDCstate, sizeof(DC));
111  defaultDCstate->pdcattr = &defaultDCstate->dcattr;
113  }
114 
115  TextIntRealizeFont(pdc->pdcattr->hlfntNew,NULL);
116  pdc->pdcattr->iCS_CP = ftGdiGetTextCharsetInfo(pdc,NULL,0);
117 
118  /* This should never fail */
119  ASSERT(pdc->dclevel.ppal);
120 }
#define TAG_DC
Definition: tags.h:21
#define TRUE
Definition: types.h:120
NTSTATUS FASTCALL TextIntRealizeFont(HFONT FontHandle, PTEXTOBJ pTextObj)
Definition: freetype.c:4878
smooth NULL
Definition: ftsmooth.c:416
Definition: polytest.cpp:40
PDC defaultDCstate
Definition: device.c:14
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
VOID FASTCALL DC_vCopyState(PDC pdcSrc, PDC pdcDst, BOOL To)
Definition: dcstate.c:16
INT FASTCALL ftGdiGetTextCharsetInfo(PDC Dc, LPFONTSIGNATURE lpSig, DWORD dwFlags)
Definition: freetype.c:4047

Referenced by GreCreateCompatibleDC(), and GreOpenDCW().

◆ DC_vCleanup()

VOID NTAPI DC_vCleanup ( PVOID  ObjectBody)

Definition at line 349 of file dclife.c.

350 {
351  PDC pdc = (PDC)ObjectBody;
352 
353  /* Free DC_ATTR */
354  DC_vFreeDcAttr(pdc);
355 
356  /* Delete saved DCs */
357  DC_vRestoreDC(pdc, 1);
358 
359  /* Deselect dc objects */
360  DC_vSelectSurface(pdc, NULL);
363  DC_vSelectPalette(pdc, NULL);
364 
365  /* Cleanup the dc brushes */
366  EBRUSHOBJ_vCleanup(&pdc->eboFill);
367  EBRUSHOBJ_vCleanup(&pdc->eboLine);
368  EBRUSHOBJ_vCleanup(&pdc->eboText);
369  EBRUSHOBJ_vCleanup(&pdc->eboBackground);
370 
371  /* Release font */
372  if (pdc->dclevel.plfnt)
373  LFONT_ShareUnlockFont(pdc->dclevel.plfnt);
374 
375  /* Free regions */
376  if (pdc->dclevel.prgnClip)
377  REGION_Delete(pdc->dclevel.prgnClip);
378  if (pdc->dclevel.prgnMeta)
379  REGION_Delete(pdc->dclevel.prgnMeta);
380  if (pdc->prgnVis)
381  REGION_Delete(pdc->prgnVis);
382  if (pdc->prgnRao)
383  REGION_Delete(pdc->prgnRao);
384  if (pdc->prgnAPI)
385  REGION_Delete(pdc->prgnAPI);
386 
387  /* Free CLIPOBJ resources */
388  IntEngFreeClipResources(&pdc->co);
389 
390  if (pdc->dclevel.hPath)
391  {
392  DPRINT("DC_vCleanup Path\n");
393  PATH_Delete(pdc->dclevel.hPath);
394  pdc->dclevel.hPath = 0;
395  pdc->dclevel.flPath = 0;
396  }
397  if (pdc->dclevel.pSurface)
398  SURFACE_ShareUnlockSurface(pdc->dclevel.pSurface);
399 
400  if (pdc->ppdev)
401  PDEVOBJ_vRelease(pdc->ppdev);
402 }
struct DC * PDC
VOID NTAPI EBRUSHOBJ_vCleanup(EBRUSHOBJ *pebo)
Definition: engbrush.c:153
FORCEINLINE VOID DC_vSelectSurface(PDC pdc, PSURFACE psurfNew)
Definition: dc.h:247
#define SURFACE_ShareUnlockSurface(pBMObj)
Definition: surface.h:102
FORCEINLINE VOID DC_vSelectPalette(PDC pdc, PPALETTE ppal)
Definition: dc.h:286
#define LFONT_ShareUnlockFont(plfnt)
Definition: text.h:78
FORCEINLINE VOID DC_vSelectFillBrush(PDC pdc, PBRUSH pbrFill)
Definition: dc.h:262
VOID FASTCALL IntEngFreeClipResources(XCLIPOBJ *Clip)
Definition: clip.c:164
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
Definition: polytest.cpp:40
VOID FASTCALL REGION_Delete(PREGION pRgn)
Definition: region.c:2471
FORCEINLINE VOID DC_vSelectLineBrush(PDC pdc, PBRUSH pbrLine)
Definition: dc.h:274
BOOL FASTCALL PATH_Delete(HPATH hPath)
Definition: path.c:91
VOID NTAPI DC_vRestoreDC(IN PDC pdc, INT iSaveLevel)
Definition: dcstate.c:137
VOID NTAPI PDEVOBJ_vRelease(PPDEVOBJ ppdev)
Definition: pdevobj.c:93
VOID NTAPI DC_vFreeDcAttr(PDC pdc)
Definition: dcattr.c:59

◆ DC_vFinishBlit()

VOID FASTCALL DC_vFinishBlit ( PDC  pdc1,
PDC  pdc2 
)

Definition at line 606 of file dclife.c.

607 {
608  if (pdc1->dctype == DCTYPE_DIRECT)
609  {
610  MouseSafetyOnDrawEnd(pdc1->ppdev);
611  EngReleaseSemaphore(pdc1->ppdev->hsemDevLock);
612  }
613 #if DBG
614  pdc1->fs &= ~DC_PREPARED;
615 #endif
616 
617  if (pdc2)
618  {
619  if (pdc2->dctype == DCTYPE_DIRECT)
620  {
621  MouseSafetyOnDrawEnd(pdc2->ppdev);
622  EngReleaseSemaphore(pdc2->ppdev->hsemDevLock);
623  }
624 #if DBG
625  pdc2->fs &= ~DC_PREPARED;
626 #endif
627  }
628 }
VOID WINAPI EngReleaseSemaphore(IN HSEMAPHORE hsem)
Definition: eng.c:235
_Requires_lock_held_ ppdev BOOL NTAPI MouseSafetyOnDrawEnd(_Inout_ PPDEVOBJ ppdev)
Definition: mouse.c:99

Referenced by GreGradientFill(), GreStretchBltMask(), IntExtTextOutW(), IntGdiBitBltRgn(), IntGdiFillRgn(), IntGdiPolyline(), IntPatBlt(), IntRectangle(), IntRoundRect(), NtGdiAlphaBlend(), NtGdiAngleArc(), NtGdiArcInternal(), NtGdiEllipse(), NtGdiExtFloodFill(), NtGdiFillPath(), NtGdiGetPixel(), NtGdiLineTo(), NtGdiMaskBlt(), NtGdiPolyPolyDraw(), NtGdiSetDIBitsToDeviceInternal(), NtGdiStretchDIBitsInternal(), NtGdiStrokeAndFillPath(), NtGdiStrokePath(), NtGdiTransparentBlt(), and UserDrawIconEx().

◆ DC_vInitDc()

VOID NTAPI DC_vInitDc ( PDC  pdc,
DCTYPE  dctype,
PPDEVOBJ  ppdev 
)

Definition at line 124 of file dclife.c.

128 {
129  /* Setup some basic fields */
130  pdc->dctype = dctype;
131  pdc->ppdev = ppdev;
132  pdc->dhpdev = ppdev->dhpdev;
133  pdc->hsem = ppdev->hsemDevLock;
134  pdc->flGraphicsCaps = ppdev->devinfo.flGraphicsCaps;
135  pdc->flGraphicsCaps2 = ppdev->devinfo.flGraphicsCaps2;
136  pdc->fs = DC_DIRTY_RAO;
137 
138  /* Setup dc attribute */
139  pdc->pdcattr = &pdc->dcattr;
140  pdc->dcattr.pvLDC = NULL;
141  pdc->dcattr.ulDirty_ = DIRTY_DEFAULT;
142  if (ppdev == gppdevPrimary)
143  pdc->dcattr.ulDirty_ |= DC_PRIMARY_DISPLAY;
144 
145  /* Setup the DC size */
146  if (dctype == DCTYPE_MEMORY)
147  {
148  /* Memory DCs have a 1 x 1 bitmap by default */
149  pdc->dclevel.sizl.cx = 1;
150  pdc->dclevel.sizl.cy = 1;
151  }
152  else
153  {
154  /* Other DC's are as big as the related PDEV */
155  pdc->dclevel.sizl.cx = ppdev->gdiinfo.ulHorzRes;
156  pdc->dclevel.sizl.cy = ppdev->gdiinfo.ulVertRes;
157  }
158 
159  /* Setup Window rect based on DC size */
160  pdc->erclWindow.left = 0;
161  pdc->erclWindow.top = 0;
162  pdc->erclWindow.right = pdc->dclevel.sizl.cx;
163  pdc->erclWindow.bottom = pdc->dclevel.sizl.cy;
164 
165  if (dctype == DCTYPE_DIRECT)
166  {
167  /* Direct DCs get the surface from the PDEV */
168  pdc->dclevel.pSurface = PDEVOBJ_pSurface(ppdev);
169 
170  pdc->erclBounds.left = 0x7fffffff;
171  pdc->erclBounds.top = 0x7fffffff;
172  pdc->erclBounds.right = 0x80000000;
173  pdc->erclBounds.bottom = 0x80000000;
174  pdc->erclBoundsApp.left = 0xffffffff;
175  pdc->erclBoundsApp.top = 0xfffffffc;
176  pdc->erclBoundsApp.right = 0x00007ffc; // FIXME
177  pdc->erclBoundsApp.bottom = 0x00000333; // FIXME
178  pdc->erclClip = pdc->erclBounds;
179  pdc->co = gxcoTrivial;
180  }
181  else
182  {
183  /* Non-direct DCs don't have a surface by default */
184  pdc->dclevel.pSurface = NULL;
185 
186  pdc->erclBounds.left = 0;
187  pdc->erclBounds.top = 0;
188  pdc->erclBounds.right = 0;
189  pdc->erclBounds.bottom = 0;
190  pdc->erclBoundsApp = pdc->erclBounds;
191  pdc->erclClip = pdc->erclWindow;
192  pdc->co = gxcoTrivial;
193  }
194 
195  //pdc->dcattr.VisRectRegion:
196 
197  /* Setup coordinate transformation data */
198  pdc->dclevel.mxWorldToDevice = gmxWorldToDeviceDefault;
199  pdc->dclevel.mxDeviceToWorld = gmxDeviceToWorldDefault;
200  pdc->dclevel.mxWorldToPage = gmxWorldToPageDefault;
201  pdc->dclevel.efM11PtoD = gef16;
202  pdc->dclevel.efM22PtoD = gef16;
203  pdc->dclevel.efDxPtoD = gef0;
204  pdc->dclevel.efDyPtoD = gef0;
205  pdc->dclevel.efM11_TWIPS = gef0;
206  pdc->dclevel.efM22_TWIPS = gef0;
207  pdc->dclevel.efPr11 = gef0;
208  pdc->dclevel.efPr22 = gef0;
209  pdc->dcattr.mxWorldToDevice = pdc->dclevel.mxWorldToDevice;
210  pdc->dcattr.mxDeviceToWorld = pdc->dclevel.mxDeviceToWorld;
211  pdc->dcattr.mxWorldToPage = pdc->dclevel.mxWorldToPage;
212  pdc->dcattr.efM11PtoD = pdc->dclevel.efM11PtoD;
213  pdc->dcattr.efM22PtoD = pdc->dclevel.efM22PtoD;
214  pdc->dcattr.efDxPtoD = pdc->dclevel.efDxPtoD;
215  pdc->dcattr.efDyPtoD = pdc->dclevel.efDyPtoD;
216  pdc->dcattr.iMapMode = MM_TEXT;
217  pdc->dcattr.dwLayout = 0;
218  pdc->dcattr.flXform = PAGE_TO_DEVICE_SCALE_IDENTITY |
221 
222  /* Setup more coordinates */
223  pdc->ptlDCOrig.x = 0;
224  pdc->ptlDCOrig.y = 0;
225  pdc->dcattr.lWindowOrgx = 0;
226  pdc->dcattr.ptlWindowOrg.x = 0;
227  pdc->dcattr.ptlWindowOrg.y = 0;
228  pdc->dcattr.szlWindowExt.cx = 1;
229  pdc->dcattr.szlWindowExt.cy = 1;
230  pdc->dcattr.ptlViewportOrg.x = 0;
231  pdc->dcattr.ptlViewportOrg.y = 0;
232  pdc->dcattr.szlViewportExt.cx = 1;
233  pdc->dcattr.szlViewportExt.cy = 1;
234  pdc->dcattr.szlVirtualDevicePixel.cx = ppdev->gdiinfo.ulHorzRes;
235  pdc->dcattr.szlVirtualDevicePixel.cy = ppdev->gdiinfo.ulVertRes;
236  pdc->dcattr.szlVirtualDeviceMm.cx = ppdev->gdiinfo.ulHorzSize;
237  pdc->dcattr.szlVirtualDeviceMm.cy = ppdev->gdiinfo.ulVertSize;
238  pdc->dcattr.szlVirtualDeviceSize.cx = 0;
239  pdc->dcattr.szlVirtualDeviceSize.cy = 0;
240 
241  /* Setup regions */
242  pdc->prgnAPI = NULL;
243  pdc->prgnRao = NULL;
244  pdc->dclevel.prgnClip = NULL;
245  pdc->dclevel.prgnMeta = NULL;
246  /* Allocate a Vis region */
247  pdc->prgnVis = IntSysCreateRectpRgn(0, 0, pdc->dclevel.sizl.cx, pdc->dclevel.sizl.cy);
248  ASSERT(pdc->prgnVis);
249 
250  /* Initialize Clip object */
251  IntEngInitClipObj(&pdc->co);
252 
253  /* Setup palette */
254  pdc->dclevel.hpal = StockObjects[DEFAULT_PALETTE];
255  pdc->dclevel.ppal = PALETTE_ShareLockPalette(pdc->dclevel.hpal);
256 
257  /* Setup path */
258  pdc->dclevel.hPath = NULL;
259  pdc->dclevel.flPath = 0;
260 // pdc->dclevel.lapath:
261 
262  /* Setup colors */
263  pdc->dcattr.crBackgroundClr = RGB(0xff, 0xff, 0xff);
264  pdc->dcattr.ulBackgroundClr = RGB(0xff, 0xff, 0xff);
265  pdc->dcattr.crForegroundClr = RGB(0, 0, 0);
266  pdc->dcattr.ulForegroundClr = RGB(0, 0, 0);
267  pdc->dcattr.crBrushClr = RGB(0xff, 0xff, 0xff);
268  pdc->dcattr.ulBrushClr = RGB(0xff, 0xff, 0xff);
269  pdc->dcattr.crPenClr = RGB(0, 0, 0);
270  pdc->dcattr.ulPenClr = RGB(0, 0, 0);
271 
272  /* Select the default fill and line brush */
273  pdc->dcattr.hbrush = StockObjects[WHITE_BRUSH];
274  pdc->dcattr.hpen = StockObjects[BLACK_PEN];
275  pdc->dclevel.pbrFill = BRUSH_ShareLockBrush(pdc->pdcattr->hbrush);
276  pdc->dclevel.pbrLine = PEN_ShareLockPen(pdc->pdcattr->hpen);
277  pdc->dclevel.ptlBrushOrigin.x = 0;
278  pdc->dclevel.ptlBrushOrigin.y = 0;
279  pdc->dcattr.ptlBrushOrigin = pdc->dclevel.ptlBrushOrigin;
280 
281  /* Initialize EBRUSHOBJs */
282  EBRUSHOBJ_vInitFromDC(&pdc->eboFill, pdc->dclevel.pbrFill, pdc);
283  EBRUSHOBJ_vInitFromDC(&pdc->eboLine, pdc->dclevel.pbrLine, pdc);
284  EBRUSHOBJ_vInitFromDC(&pdc->eboText, pbrDefaultBrush, pdc);
285  EBRUSHOBJ_vInitFromDC(&pdc->eboBackground, pbrDefaultBrush, pdc);
286 
287  /* Setup fill data */
288  pdc->dcattr.jROP2 = R2_COPYPEN;
289  pdc->dcattr.jBkMode = 2;
290  pdc->dcattr.lBkMode = 2;
291  pdc->dcattr.jFillMode = ALTERNATE;
292  pdc->dcattr.lFillMode = 1;
293  pdc->dcattr.jStretchBltMode = 1;
294  pdc->dcattr.lStretchBltMode = 1;
295  pdc->ptlFillOrigin.x = 0;
296  pdc->ptlFillOrigin.y = 0;
297 
298  /* Setup drawing position */
299  pdc->dcattr.ptlCurrent.x = 0;
300  pdc->dcattr.ptlCurrent.y = 0;
301  pdc->dcattr.ptfxCurrent.x = 0;
302  pdc->dcattr.ptfxCurrent.y = 0;
303 
304  /* Setup ICM data */
305  pdc->dclevel.lIcmMode = 0;
306  pdc->dcattr.lIcmMode = 0;
307  pdc->dcattr.hcmXform = NULL;
308  pdc->dcattr.flIcmFlags = 0;
309  pdc->dcattr.IcmBrushColor = CLR_INVALID;
310  pdc->dcattr.IcmPenColor = CLR_INVALID;
311  pdc->dcattr.pvLIcm = NULL;
312  pdc->dcattr.hColorSpace = NULL; // FIXME: 0189001f
313  pdc->dclevel.pColorSpace = NULL; // FIXME
314  pdc->pClrxFormLnk = NULL;
315 // pdc->dclevel.ca =
316 
317  /* Setup font data */
318  pdc->hlfntCur = NULL; // FIXME: 2f0a0cf8
319  pdc->pPFFList = NULL;
320  pdc->flSimulationFlags = 0;
321  pdc->lEscapement = 0;
322  pdc->prfnt = NULL;
323  pdc->dcattr.flFontMapper = 0;
324  pdc->dcattr.flTextAlign = 0;
325  pdc->dcattr.lTextAlign = 0;
326  pdc->dcattr.lTextExtra = 0;
327  pdc->dcattr.lRelAbs = 1;
328  pdc->dcattr.lBreakExtra = 0;
329  pdc->dcattr.cBreak = 0;
330  pdc->dcattr.hlfntNew = StockObjects[SYSTEM_FONT];
331  pdc->dclevel.plfnt = LFONT_ShareLockFont(pdc->dcattr.hlfntNew);
332 
333  /* Other stuff */
334  pdc->hdcNext = NULL;
335  pdc->hdcPrev = NULL;
336  pdc->ipfdDevMax = 0;
337  pdc->ulCopyCount = -1;
338  pdc->ptlDoBanding.x = 0;
339  pdc->ptlDoBanding.y = 0;
340  pdc->dclevel.lSaveDepth = 1;
341  pdc->dclevel.hdcSave = NULL;
342  pdc->dcattr.iGraphicsMode = GM_COMPATIBLE;
343  pdc->dcattr.iCS_CP = 0;
344  pdc->pSurfInfo = NULL;
345 }
DHPDEV dhpdev
Definition: pdevobj.h:121
PBRUSH pbrDefaultBrush
Definition: dclife.c:18
VOID FASTCALL IntEngInitClipObj(XCLIPOBJ *Clip)
Definition: clip.c:158
XCLIPOBJ gxcoTrivial
Definition: bitblt.c:15
#define BRUSH_ShareLockBrush(hBrush)
Definition: brush.h:113
PSURFACE NTAPI PDEVOBJ_pSurface(PPDEVOBJ ppdev)
Definition: pdevobj.c:233
GDIINFO gdiinfo
Definition: pdevobj.h:124
PPDEVOBJ gppdevPrimary
Definition: pdevobj.c:13
#define PAGE_TO_DEVICE_IDENTITY
Definition: ntgdihdl.h:195
#define CLR_INVALID
Definition: wingdi.h:882
#define gmxDeviceToWorldDefault
Definition: dclife.c:46
#define WHITE_BRUSH
Definition: wingdi.h:901
#define R2_COPYPEN
Definition: wingdi.h:338
#define DC_PRIMARY_DISPLAY
Definition: ntgdihdl.h:161
ULONG ulVertSize
Definition: winddi.h:881
PREGION FASTCALL IntSysCreateRectpRgn(INT LeftRect, INT TopRect, INT RightRect, INT BottomRect)
Definition: region.c:2429
HGDIOBJ StockObjects[]
Definition: stockobj.c:100
#define ALTERNATE
Definition: constants.h:278
ULONG ulHorzRes
Definition: winddi.h:882
smooth NULL
Definition: ftsmooth.c:416
#define SYSTEM_FONT
Definition: wingdi.h:910
HSEMAPHORE hsemDevLock
Definition: pdevobj.h:91
#define PALETTE_ShareLockPalette(hpal)
Definition: palette.h:57
#define DEFAULT_PALETTE
Definition: wingdi.h:912
DEVINFO devinfo
Definition: pdevobj.h:123
#define RGB(r, g, b)
Definition: wingdi.h:2918
ULONG ulHorzSize
Definition: winddi.h:880
static const FLOATOBJ gef0
Definition: floatobj.h:115
#define GM_COMPATIBLE
Definition: wingdi.h:863
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define WORLD_TO_PAGE_IDENTITY
Definition: ntgdihdl.h:186
static const FLOATOBJ gef16
Definition: floatobj.h:117
#define PAGE_TO_DEVICE_SCALE_IDENTITY
Definition: ntgdihdl.h:196
VOID NTAPI EBRUSHOBJ_vInitFromDC(EBRUSHOBJ *pebo, PBRUSH pbrush, PDC pdc)
Definition: engbrush.c:112
#define BLACK_PEN
Definition: wingdi.h:902
FLONG flGraphicsCaps
Definition: winddi.h:390
#define DIRTY_DEFAULT
Definition: dclife.c:15
#define LFONT_ShareLockFont(hfont)
Definition: text.h:77
#define gmxWorldToDeviceDefault
Definition: dclife.c:45
#define MM_TEXT
Definition: wingdi.h:872
const MATRIX gmxWorldToPageDefault
Definition: dclife.c:36
ULONG ulVertRes
Definition: winddi.h:883
PBRUSH FASTCALL PEN_ShareLockPen(HPEN hobj)
Definition: pen.c:61
FLONG flGraphicsCaps2
Definition: winddi.h:399

Referenced by GreCreateCompatibleDC(), GreOpenDCW(), and NtGdiSaveDC().

◆ DC_vPrepareDCsForBlit()

VOID FASTCALL DC_vPrepareDCsForBlit ( PDC  pdcDest,
const RECT rcDest,
PDC  pdcSrc,
const RECT rcSrc 
)

Definition at line 497 of file dclife.c.

502 {
503  PDC pdcFirst, pdcSecond;
504  const RECT *prcFirst, *prcSecond;
505 
506  /* Update brushes */
507  if (pdcDest->pdcattr->ulDirty_ & (DIRTY_FILL | DC_BRUSH_DIRTY))
508  DC_vUpdateFillBrush(pdcDest);
509  if (pdcDest->pdcattr->ulDirty_ & (DIRTY_LINE | DC_PEN_DIRTY))
510  DC_vUpdateLineBrush(pdcDest);
511  if(pdcDest->pdcattr->ulDirty_ & DIRTY_TEXT)
512  DC_vUpdateTextBrush(pdcDest);
513 
514  /* Lock them in good order */
515  if (pdcSrc)
516  {
517  if((ULONG_PTR)pdcDest->ppdev->hsemDevLock >=
518  (ULONG_PTR)pdcSrc->ppdev->hsemDevLock)
519  {
520  pdcFirst = pdcDest;
521  prcFirst = rcDest;
522  pdcSecond = pdcSrc;
523  prcSecond = rcSrc;
524  }
525  else
526  {
527  pdcFirst = pdcSrc;
528  prcFirst = rcSrc;
529  pdcSecond = pdcDest;
530  prcSecond = rcDest;
531  }
532  }
533  else
534  {
535  pdcFirst = pdcDest;
536  prcFirst = rcDest;
537  pdcSecond = NULL;
538  prcSecond = NULL;
539  }
540 
541  if (pdcDest->fs & DC_FLAG_DIRTY_RAO)
542  CLIPPING_UpdateGCRegion(pdcDest);
543 
544  /* Lock and update first DC */
545  if (pdcFirst->dctype == DCTYPE_DIRECT)
546  {
547  EngAcquireSemaphore(pdcFirst->ppdev->hsemDevLock);
548 
549  /* Update surface if needed */
550  if (pdcFirst->ppdev->pSurface != pdcFirst->dclevel.pSurface)
551  {
552  DC_vUpdateDC(pdcFirst);
553  }
554  }
555 
556  if (pdcFirst->dctype == DCTYPE_DIRECT)
557  {
558  if (!prcFirst)
559  prcFirst = &pdcFirst->erclClip;
560 
561  MouseSafetyOnDrawStart(pdcFirst->ppdev,
562  prcFirst->left,
563  prcFirst->top,
564  prcFirst->right,
565  prcFirst->bottom) ;
566  }
567 
568 #if DBG
569  pdcFirst->fs |= DC_PREPARED;
570 #endif
571 
572  if (!pdcSecond)
573  return;
574 
575  /* Lock and update second DC */
576  if (pdcSecond->dctype == DCTYPE_DIRECT)
577  {
578  EngAcquireSemaphore(pdcSecond->ppdev->hsemDevLock);
579 
580  /* Update surface if needed */
581  if (pdcSecond->ppdev->pSurface != pdcSecond->dclevel.pSurface)
582  {
583  DC_vUpdateDC(pdcSecond);
584  }
585  }
586 
587  if (pdcSecond->dctype == DCTYPE_DIRECT)
588  {
589  if (!prcSecond)
590  prcSecond = &pdcSecond->erclClip;
591  MouseSafetyOnDrawStart(pdcSecond->ppdev,
592  prcSecond->left,
593  prcSecond->top,
594  prcSecond->right,
595  prcSecond->bottom) ;
596  }
597 
598 #if DBG
599  pdcSecond->fs |= DC_PREPARED;
600 #endif
601 }
VOID FASTCALL DC_vUpdateLineBrush(PDC pdc)
Definition: dcobjs.c:62
static void DC_vUpdateDC(PDC pdc)
Definition: dclife.c:467
#define DC_PEN_DIRTY
Definition: ntgdihdl.h:158
LONG top
Definition: windef.h:292
LONG left
Definition: windef.h:291
LONG right
Definition: windef.h:293
uint32_t ULONG_PTR
Definition: typedefs.h:63
_Requires_lock_held_ ppdev BOOL NTAPI MouseSafetyOnDrawStart(_Inout_ PPDEVOBJ ppdev, _In_ LONG HazardX1, _In_ LONG HazardY1, _In_ LONG HazardX2, _In_ LONG HazardY2)
Definition: mouse.c:41
ENGAPI VOID APIENTRY EngAcquireSemaphore(_Inout_ HSEMAPHORE hsem)
smooth NULL
Definition: ftsmooth.c:416
VOID FASTCALL DC_vUpdateTextBrush(PDC pdc)
Definition: dcobjs.c:108
Definition: polytest.cpp:40
#define DC_FLAG_DIRTY_RAO
Definition: ntgdihdl.h:132
VOID FASTCALL CLIPPING_UpdateGCRegion(PDC pDC)
Definition: cliprgn.c:544
#define DIRTY_TEXT
Definition: ntgdihdl.h:147
#define DIRTY_FILL
Definition: ntgdihdl.h:145
#define DC_BRUSH_DIRTY
Definition: ntgdihdl.h:157
LONG bottom
Definition: windef.h:294
#define DIRTY_LINE
Definition: ntgdihdl.h:146
VOID FASTCALL DC_vUpdateFillBrush(PDC pdc)
Definition: dcobjs.c:16

Referenced by GreGradientFill(), GreStretchBltMask(), IntExtTextOutW(), IntGdiBitBltRgn(), IntGdiFillRgn(), IntGdiPolyline(), IntPatBlt(), IntRectangle(), IntRoundRect(), NtGdiAlphaBlend(), NtGdiAngleArc(), NtGdiArcInternal(), NtGdiEllipse(), NtGdiExtFloodFill(), NtGdiFillPath(), NtGdiGetPixel(), NtGdiLineTo(), NtGdiMaskBlt(), NtGdiPolyPolyDraw(), NtGdiSetDIBitsToDeviceInternal(), NtGdiStretchDIBitsInternal(), NtGdiStrokeAndFillPath(), NtGdiStrokePath(), NtGdiTransparentBlt(), and UserDrawIconEx().

◆ DC_vSetOwner()

VOID NTAPI DC_vSetOwner ( PDC  pdc,
ULONG  ulOwner 
)

Definition at line 406 of file dclife.c.

407 {
408  /* Delete saved DCs */
409  DC_vRestoreDC(pdc, 1);
410 
411  if (pdc->dclevel.hPath)
412  {
413  GreSetObjectOwner(pdc->dclevel.hPath, ulOwner);
414  }
415 
416  /* Dereference current brush and pen */
417  BRUSH_ShareUnlockBrush(pdc->dclevel.pbrFill);
418  BRUSH_ShareUnlockBrush(pdc->dclevel.pbrLine);
419 
420  /* Select the default fill and line brush */
421  pdc->dcattr.hbrush = StockObjects[WHITE_BRUSH];
422  pdc->dcattr.hpen = StockObjects[BLACK_PEN];
423  pdc->dclevel.pbrFill = BRUSH_ShareLockBrush(pdc->pdcattr->hbrush);
424  pdc->dclevel.pbrLine = PEN_ShareLockPen(pdc->pdcattr->hpen);
425 
426  /* Mark them as dirty */
427  pdc->pdcattr->ulDirty_ |= DIRTY_FILL|DIRTY_LINE;
428 
429  /* Allocate or free DC attribute */
430  if (ulOwner == GDI_OBJ_HMGR_PUBLIC || ulOwner == GDI_OBJ_HMGR_NONE)
431  {
432  if (pdc->pdcattr != &pdc->dcattr)
433  DC_vFreeDcAttr(pdc);
434  }
435  else if (ulOwner == GDI_OBJ_HMGR_POWNED)
436  {
437  if (pdc->pdcattr == &pdc->dcattr)
438  DC_bAllocDcAttr(pdc);
439  }
440 
441  /* Set the DC's ownership */
442  GDIOBJ_vSetObjectOwner(&pdc->BaseObject, ulOwner);
443 }
#define BRUSH_ShareUnlockBrush(pBrush)
Definition: brush.h:114
BOOL NTAPI GreSetObjectOwner(HGDIOBJ hobj, ULONG ulOwner)
Definition: gdiobj.c:1250
#define BRUSH_ShareLockBrush(hBrush)
Definition: brush.h:113
#define WHITE_BRUSH
Definition: wingdi.h:901
HGDIOBJ StockObjects[]
Definition: stockobj.c:100
BOOL NTAPI DC_bAllocDcAttr(PDC pdc)
Definition: dcattr.c:31
#define DIRTY_FILL
Definition: ntgdihdl.h:145
#define GDI_OBJ_HMGR_POWNED
Definition: ntgdihdl.h:117
#define BLACK_PEN
Definition: wingdi.h:902
#define GDI_OBJ_HMGR_PUBLIC
Definition: ntgdihdl.h:116
#define GDI_OBJ_HMGR_NONE
Definition: ntgdihdl.h:118
#define DIRTY_LINE
Definition: ntgdihdl.h:146
VOID NTAPI GDIOBJ_vSetObjectOwner(POBJ pobj, ULONG ulNewOwner)
Definition: gdiobj.c:960
PBRUSH FASTCALL PEN_ShareLockPen(HPEN hobj)
Definition: pen.c:61
VOID NTAPI DC_vRestoreDC(IN PDC pdc, INT iSaveLevel)
Definition: dcstate.c:137
VOID NTAPI DC_vFreeDcAttr(PDC pdc)
Definition: dcattr.c:59

Referenced by GreSetDCOwner().

◆ DC_vUpdateDC()

static void DC_vUpdateDC ( PDC  pdc)
static

Definition at line 467 of file dclife.c.

468 {
469  // PREGION VisRgn ;
470  PPDEVOBJ ppdev = pdc->ppdev;
471 
472  pdc->dhpdev = ppdev->dhpdev;
473 
474  SURFACE_ShareUnlockSurface(pdc->dclevel.pSurface);
475  pdc->dclevel.pSurface = PDEVOBJ_pSurface(ppdev);
476 
477  PDEVOBJ_sizl(pdc->ppdev, &pdc->dclevel.sizl);
478 #if 0
479  VisRgn = IntSysCreateRectpRgn(0, 0, pdc->dclevel.sizl.cx, pdc->dclevel.sizl.cy);
480  ASSERT(VisRgn);
481  GdiSelectVisRgn(pdc->BaseObject.hHmgr, VisRgn);
482  REGION_Delete(VisRgn);
483 #endif
484 
485  pdc->flGraphicsCaps = ppdev->devinfo.flGraphicsCaps;
486  pdc->flGraphicsCaps2 = ppdev->devinfo.flGraphicsCaps2;
487 
488  /* Mark EBRUSHOBJs as dirty */
489  pdc->pdcattr->ulDirty_ |= DIRTY_DEFAULT ;
490 }
DHPDEV dhpdev
Definition: pdevobj.h:121
VOID FASTCALL GdiSelectVisRgn(HDC hdc, PREGION prgn)
Definition: cliprgn.c:42
#define SURFACE_ShareUnlockSurface(pBMObj)
Definition: surface.h:102
PSURFACE NTAPI PDEVOBJ_pSurface(PPDEVOBJ ppdev)
Definition: pdevobj.c:233
PREGION FASTCALL IntSysCreateRectpRgn(INT LeftRect, INT TopRect, INT RightRect, INT BottomRect)
Definition: region.c:2429
DEVINFO devinfo
Definition: pdevobj.h:123
PSIZEL FASTCALL PDEVOBJ_sizl(PPDEVOBJ ppdev, PSIZEL psizl)
Definition: pdevobj.c:973
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
FLONG flGraphicsCaps
Definition: winddi.h:390
#define DIRTY_DEFAULT
Definition: dclife.c:15
VOID FASTCALL REGION_Delete(PREGION pRgn)
Definition: region.c:2471
FLONG flGraphicsCaps2
Definition: winddi.h:399

Referenced by DC_vPrepareDCsForBlit().

◆ GreCreateCompatibleDC()

HDC APIENTRY GreCreateCompatibleDC ( HDC  hdc,
BOOL  bAltDc 
)

Definition at line 806 of file dclife.c.

807 {
808  GDILOOBJTYPE eDcObjType;
809  HDC hdcNew;
810  PPDEVOBJ ppdev;
811  PDC pdc, pdcNew;
812 
813  DPRINT("NtGdiCreateCompatibleDC(0x%p)\n", hdc);
814 
815  /* Did the caller provide a DC? */
816  if (hdc)
817  {
818  /* Yes, try to lock it */
819  pdc = DC_LockDc(hdc);
820  if (!pdc)
821  {
822  DPRINT1("Could not lock source DC %p\n", hdc);
823  return NULL;
824  }
825 
826  /* Get the pdev from the DC */
827  ppdev = pdc->ppdev;
829 
830  /* Unlock the source DC */
831  DC_UnlockDc(pdc);
832  }
833  else
834  {
835  /* No DC given, get default device */
836  ppdev = EngpGetPDEV(NULL);
837  }
838 
839  if (!ppdev)
840  {
841  DPRINT1("Didn't find a suitable PDEV\n");
842  return NULL;
843  }
844 
845  /* Allocate a new DC */
846  eDcObjType = bAltDc ? GDILoObjType_LO_ALTDC_TYPE : GDILoObjType_LO_DC_TYPE;
847  pdcNew = DC_AllocDcWithHandle(eDcObjType);
848  if (!pdcNew)
849  {
850  DPRINT1("Could not allocate a new DC\n");
851  PDEVOBJ_vRelease(ppdev);
852  return NULL;
853  }
854  hdcNew = pdcNew->BaseObject.hHmgr;
855 
856  /* Lock ppdev and initialize the new DC */
857  DC_vInitDc(pdcNew, bAltDc ? DCTYPE_INFO : DCTYPE_MEMORY, ppdev);
858  /* FIXME: HACK! */
859  DC_InitHack(pdcNew);
860 
861  /* Allocate a dc attribute */
862  DC_bAllocDcAttr(pdcNew);
863 
864  DC_UnlockDc(pdcNew);
865 
866  DPRINT("Leave NtGdiCreateCompatibleDC hdcNew = %p\n", hdcNew);
867 
868  return hdcNew;
869 }
LONG cPdevRefs
Definition: pdevobj.h:86
FORCEINLINE PDC DC_LockDc(HDC hdc)
Definition: dc.h:219
PDC NTAPI DC_AllocDcWithHandle(GDILOOBJTYPE eDcObjType)
Definition: dclife.c:69
static HDC
Definition: imagelist.c:92
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
BOOL NTAPI DC_bAllocDcAttr(PDC pdc)
Definition: dcattr.c:31
Definition: polytest.cpp:40
HDC hdc
Definition: main.c:9
Definition: dc.h:43
VOID NTAPI DC_vInitDc(PDC pdc, DCTYPE dctype, PPDEVOBJ ppdev)
Definition: dclife.c:124
#define InterlockedIncrement
Definition: armddk.h:53
FORCEINLINE VOID DC_UnlockDc(PDC pdc)
Definition: dc.h:237
#define DPRINT1
Definition: precomp.h:8
void DC_InitHack(PDC pdc)
Definition: dclife.c:104
enum GDILoObjType GDILOOBJTYPE
PPDEVOBJ NTAPI EngpGetPDEV(_In_opt_ PUNICODE_STRING pustrDeviceName)
Definition: pdevobj.c:591
VOID NTAPI PDEVOBJ_vRelease(PPDEVOBJ ppdev)
Definition: pdevobj.c:93

Referenced by NtGdiCreateCompatibleDC(), and NtGdiCreateMetafileDC().

◆ GreOpenDCW()

HDC NTAPI GreOpenDCW ( PUNICODE_STRING  pustrDevice,
DEVMODEW pdmInit,
PUNICODE_STRING  pustrLogAddr,
ULONG  iType,
BOOL  bDisplay,
HANDLE  hspool,
VOID pDriverInfo2,
VOID pUMdhpdev 
)

Definition at line 632 of file dclife.c.

641 {
642  PPDEVOBJ ppdev;
643  PDC pdc;
644  HDC hdc;
645 
646  DPRINT("GreOpenDCW(%S, iType=%lu)\n",
647  pustrDevice ? pustrDevice->Buffer : NULL, iType);
648 
649  /* Get a PDEVOBJ for the device */
650  ppdev = EngpGetPDEV(pustrDevice);
651  if (!ppdev)
652  {
653  DPRINT1("Didn't find a suitable PDEV\n");
654  return NULL;
655  }
656 
657  DPRINT("GreOpenDCW - ppdev = %p\n", ppdev);
658 
660  if (!pdc)
661  {
662  DPRINT1("Could not Allocate a DC\n");
663  PDEVOBJ_vRelease(ppdev);
664  return NULL;
665  }
666  hdc = pdc->BaseObject.hHmgr;
667 
668  /* Lock ppdev and initialize the new DC */
669  DC_vInitDc(pdc, iType, ppdev);
670  /* FIXME: HACK! */
671  DC_InitHack(pdc);
672 
673  DC_bAllocDcAttr(pdc);
674 
675  DC_UnlockDc(pdc);
676 
677  DPRINT("Returning hdc = %p\n", hdc);
678 
679  return hdc;
680 }
PDC NTAPI DC_AllocDcWithHandle(GDILOOBJTYPE eDcObjType)
Definition: dclife.c:69
_In_ ULONG iType
Definition: winddi.h:3748
static HDC
Definition: imagelist.c:92
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
BOOL NTAPI DC_bAllocDcAttr(PDC pdc)
Definition: dcattr.c:31
Definition: polytest.cpp:40
HDC hdc
Definition: main.c:9
VOID NTAPI DC_vInitDc(PDC pdc, DCTYPE dctype, PPDEVOBJ ppdev)
Definition: dclife.c:124
FORCEINLINE VOID DC_UnlockDc(PDC pdc)
Definition: dc.h:237
#define DPRINT1
Definition: precomp.h:8
void DC_InitHack(PDC pdc)
Definition: dclife.c:104
PPDEVOBJ NTAPI EngpGetPDEV(_In_opt_ PUNICODE_STRING pustrDeviceName)
Definition: pdevobj.c:591
VOID NTAPI PDEVOBJ_vRelease(PPDEVOBJ ppdev)
Definition: pdevobj.c:93

Referenced by IntGdiCreateDC(), and NtGdiOpenDCW().

◆ GreSetDCOwner()

BOOL NTAPI GreSetDCOwner ( HDC  hdc,
ULONG  ulOwner 
)

Definition at line 447 of file dclife.c.

448 {
449  PDC pdc;
450 
451  pdc = DC_LockDc(hdc);
452  if (!pdc)
453  {
454  DPRINT1("GreSetDCOwner: Could not lock DC\n");
455  return FALSE;
456  }
457 
458  /* Call the internal DC function */
459  DC_vSetOwner(pdc, ulOwner);
460 
461  DC_UnlockDc(pdc);
462  return TRUE;
463 }
#define TRUE
Definition: types.h:120
FORCEINLINE PDC DC_LockDc(HDC hdc)
Definition: dc.h:219
Definition: polytest.cpp:40
HDC hdc
Definition: main.c:9
FORCEINLINE VOID DC_UnlockDc(PDC pdc)
Definition: dc.h:237
VOID NTAPI DC_vSetOwner(PDC pdc, ULONG ulOwner)
Definition: dclife.c:406
#define DPRINT1
Definition: precomp.h:8

Referenced by co_IntInitializeDesktopGraphics(), DceAllocDCE(), DceFreeDCE(), DceFreeWindowDCE(), DceReleaseDC(), DxEngSetDCOwner(), IntEndDesktopGraphics(), and UserGetDCEx().

◆ InitDcImpl()

INIT_FUNCTION NTSTATUS NTAPI InitDcImpl ( VOID  )

Internal functions

Definition at line 53 of file dclife.c.

54 {
56  if (!psurfDefaultBitmap)
57  return STATUS_UNSUCCESSFUL;
58 
60  if (!pbrDefaultBrush)
61  return STATUS_UNSUCCESSFUL;
62 
63  return STATUS_SUCCESS;
64 }
PBRUSH pbrDefaultBrush
Definition: dclife.c:18
#define BRUSH_ShareLockBrush(hBrush)
Definition: brush.h:113
PSURFACE psurfDefaultBitmap
Definition: dclife.c:17
#define SURFACE_ShareLockSurface(hBMObj)
Definition: surface.h:91
HGDIOBJ StockObjects[]
Definition: stockobj.c:100
#define DEFAULT_BITMAP
Definition: ntgdityp.h:192
#define BLACK_BRUSH
Definition: wingdi.h:895
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
return STATUS_SUCCESS
Definition: btrfs.c:2725

Referenced by DriverEntry().

◆ IntGdiCreateDC()

HDC FASTCALL IntGdiCreateDC ( PUNICODE_STRING  Driver,
PUNICODE_STRING  pustrDevice,
PVOID  pUMdhpdev,
CONST PDEVMODEW  pdmInit,
BOOL  CreateAsIC 
)

Definition at line 1032 of file dclife.c.

1038 {
1039  HDC hdc;
1040 
1041  hdc = GreOpenDCW(pustrDevice,
1042  pdmInit,
1043  NULL,
1044  CreateAsIC ? DCTYPE_INFO :
1046  TRUE,
1047  NULL,
1048  NULL,
1049  pUMdhpdev);
1050 
1051  return hdc;
1052 }
#define TRUE
Definition: types.h:120
static HDC
Definition: imagelist.c:92
HDC NTAPI GreOpenDCW(PUNICODE_STRING pustrDevice, DEVMODEW *pdmInit, PUNICODE_STRING pustrLogAddr, ULONG iType, BOOL bDisplay, HANDLE hspool, VOID *pDriverInfo2, VOID *pUMdhpdev)
Definition: dclife.c:632
smooth NULL
Definition: ftsmooth.c:416
_In_ PCUNICODE_STRING _In_ PVOID Driver
Definition: cmfuncs.h:32
HDC hdc
Definition: main.c:9
Definition: dc.h:43
#define DC_TYPE_DIRECT
Definition: ntgdihdl.h:123

Referenced by co_IntInitializeDesktopGraphics(), DceCreateDisplayDC(), IntGdiCreateDisplayDC(), and UserLoadImage().

◆ IntGdiCreateDisplayDC()

HDC FASTCALL IntGdiCreateDisplayDC ( HDEV  hDev,
ULONG  DcType,
BOOL  EmptyDC 
)

Definition at line 1055 of file dclife.c.

1056 {
1057  HDC hDC;
1058  UNIMPLEMENTED;
1059  ASSERT(FALSE);
1060 
1061  if (DcType == DC_TYPE_MEMORY)
1062  hDC = NtGdiCreateCompatibleDC(NULL); // OH~ Yuck! I think I taste vomit in my mouth!
1063  else
1064  hDC = IntGdiCreateDC(NULL, NULL, NULL, NULL, (DcType == DC_TYPE_INFO));
1065 
1066  return hDC;
1067 }
HDC APIENTRY NtGdiCreateCompatibleDC(HDC hdc)
Definition: dclife.c:873
static HDC
Definition: imagelist.c:92
smooth NULL
Definition: ftsmooth.c:416
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define DC_TYPE_MEMORY
Definition: ntgdihdl.h:124
static HDC hDC
Definition: 3dtext.c:33
#define DC_TYPE_INFO
Definition: ntgdihdl.h:125
HDC FASTCALL IntGdiCreateDC(PUNICODE_STRING Driver, PUNICODE_STRING pustrDevice, PVOID pUMdhpdev, CONST PDEVMODEW pdmInit, BOOL CreateAsIC)
Definition: dclife.c:1032
#define UNIMPLEMENTED
Definition: debug.h:114

Referenced by DxEngCreateMemoryDC(), and UserGetDesktopDC().

◆ IntGdiDeleteDC()

BOOL FASTCALL IntGdiDeleteDC ( HDC  hDC,
BOOL  Force 
)

Definition at line 881 of file dclife.c.

882 {
883  PDC DCToDelete = DC_LockDc(hDC);
884 
885  if (DCToDelete == NULL)
886  {
888  return FALSE;
889  }
890 
891  if (!Force)
892  {
893  /* Windows permits NtGdiDeleteObjectApp to delete a permanent DC
894  * For some reason, it's still a valid handle, pointing to some kernel data.
895  * Not sure if this is a bug, a feature, some cache stuff... Who knows?
896  * See NtGdiDeleteObjectApp test for details */
897  if (DCToDelete->fs & DC_FLAG_PERMANENT)
898  {
899  DC_UnlockDc(DCToDelete);
900  if(UserReleaseDC(NULL, hDC, FALSE))
901  {
902  /* ReactOS feature: Call UserReleaseDC
903  * I don't think Windows does it.
904  * Still, complain, no one should ever call DeleteDC
905  * on a window DC */
906  DPRINT1("No, you naughty application!\n");
907  return TRUE;
908  }
909  else
910  {
911  /* This is not a window owned DC.
912  * Force its deletion */
913  return IntGdiDeleteDC(hDC, TRUE);
914  }
915  }
916  }
917 
918  DC_UnlockDc(DCToDelete);
919 
920  if (GreIsHandleValid(hDC))
921  {
922  if (!GreDeleteObject(hDC))
923  {
924  DPRINT1("DC_FreeDC failed\n");
925  return FALSE;
926  }
927  }
928  else
929  {
930  DPRINT1("Attempted to Delete 0x%p currently being destroyed!!!\n", hDC);
931  return FALSE;
932  }
933 
934  return TRUE;
935 }
BOOL NTAPI GreDeleteObject(HGDIOBJ hobj)
Definition: gdiobj.c:1153
#define TRUE
Definition: types.h:120
BOOL NTAPI GreIsHandleValid(HGDIOBJ hobj)
Definition: gdiobj.c:1141
FORCEINLINE PDC DC_LockDc(HDC hdc)
Definition: dc.h:219
#define ERROR_INVALID_HANDLE
Definition: compat.h:88
smooth NULL
Definition: ftsmooth.c:416
Definition: polytest.cpp:40
#define DC_FLAG_PERMANENT
Definition: ntgdihdl.h:131
static HDC hDC
Definition: 3dtext.c:33
FORCEINLINE VOID DC_UnlockDc(PDC pdc)
Definition: dc.h:237
INT FASTCALL UserReleaseDC(PWND Window, HDC hDc, BOOL EndPaint)
Definition: windc.c:917
#define DPRINT1
Definition: precomp.h:8
BOOL FASTCALL IntGdiDeleteDC(HDC hDC, BOOL Force)
Definition: dclife.c:881
ENGAPI VOID APIENTRY EngSetLastError(_In_ ULONG iError)
Definition: error.c:27
_Inout_ PVCB _In_ BOOLEAN Force
Definition: cdprocs.h:1425

Referenced by DceFreeDCE(), DxEngDeleteDC(), IntUpdateLayeredWindowI(), MENU_DrawBitmapItem(), MENU_DrawMenuItem(), NtGdiDeleteObjectApp(), and SnapWindow().

◆ MakeInfoDC()

BOOL FASTCALL MakeInfoDC ( PDC  pdc,
BOOL  bSet 
)

Definition at line 961 of file dclife.c.

962 {
964  SIZEL sizl;
965 
966  /* Can not be a display DC. */
967  if (pdc->fs & DC_FLAG_DISPLAY) return FALSE;
968  if (bSet)
969  {
970  if (pdc->fs & DC_FLAG_TEMPINFODC || pdc->dctype == DC_TYPE_DIRECT)
971  return FALSE;
972 
973  pSurface = pdc->dclevel.pSurface;
974  pdc->fs |= DC_FLAG_TEMPINFODC;
975  pdc->pSurfInfo = pSurface;
976  pdc->dctype = DC_TYPE_INFO;
977  pdc->dclevel.pSurface = NULL;
978 
979  PDEVOBJ_sizl(pdc->ppdev, &sizl);
980 
981  if ( sizl.cx == pdc->dclevel.sizl.cx &&
982  sizl.cy == pdc->dclevel.sizl.cy )
983  return TRUE;
984 
985  pdc->dclevel.sizl.cx = sizl.cx;
986  pdc->dclevel.sizl.cy = sizl.cy;
987  }
988  else
989  {
990  if (!(pdc->fs & DC_FLAG_TEMPINFODC) || pdc->dctype != DC_TYPE_INFO)
991  return FALSE;
992 
993  pSurface = pdc->pSurfInfo;
994  pdc->fs &= ~DC_FLAG_TEMPINFODC;
995  pdc->dclevel.pSurface = pSurface;
996  pdc->dctype = DC_TYPE_DIRECT;
997  pdc->pSurfInfo = NULL;
998 
999  if ( !pSurface ||
1000  (pSurface->SurfObj.sizlBitmap.cx == pdc->dclevel.sizl.cx &&
1001  pSurface->SurfObj.sizlBitmap.cy == pdc->dclevel.sizl.cy) )
1002  return TRUE;
1003 
1004  pdc->dclevel.sizl.cx = pSurface->SurfObj.sizlBitmap.cx;
1005  pdc->dclevel.sizl.cy = pSurface->SurfObj.sizlBitmap.cy;
1006  }
1007  return IntSetDefaultRegion(pdc);
1008 }
#define TRUE
Definition: types.h:120
_In_ SIZEL sizl
Definition: winddi.h:3467
#define DC_FLAG_DISPLAY
Definition: ntgdihdl.h:128
smooth NULL
Definition: ftsmooth.c:416
_In_ DD_SURFACE_LOCAL * pSurface
Definition: winddi.h:3481
PSIZEL FASTCALL PDEVOBJ_sizl(PPDEVOBJ ppdev, PSIZEL psizl)
Definition: pdevobj.c:973
BOOL FASTCALL IntSetDefaultRegion(PDC)
Definition: dcutil.c:350
#define DC_TYPE_INFO
Definition: ntgdihdl.h:125
#define DC_FLAG_TEMPINFODC
Definition: ntgdihdl.h:138
#define DC_TYPE_DIRECT
Definition: ntgdihdl.h:123

Referenced by NtGdiMakeInfoDC().

◆ NtGdiCreateCompatibleDC()

HDC APIENTRY NtGdiCreateCompatibleDC ( HDC  hdc)

Definition at line 873 of file dclife.c.

874 {
875  /* Call the internal function to create a normal memory DC */
877 }
HDC APIENTRY GreCreateCompatibleDC(HDC hdc, BOOL bAltDc)
Definition: dclife.c:806
HDC hdc
Definition: main.c:9

Referenced by IntGdiCreateDisplayDC().

◆ NtGdiDeleteObjectApp()

BOOL APIENTRY NtGdiDeleteObjectApp ( HANDLE  hobj)

Definition at line 939 of file dclife.c.

940 {
941  /* Complete all pending operations */
942  NtGdiFlushUserBatch(); // FIXME: We shouldn't need this
943 
944  if (GDI_HANDLE_IS_STOCKOBJ(hobj)) return TRUE;
945 
947  {
949  return FALSE;
950  }
951 
953  return GreDeleteObject(hobj);
954 
955  // FIXME: Everything should be callback based
956  return IntGdiDeleteDC(hobj, FALSE);
957 }
BOOL NTAPI GreDeleteObject(HGDIOBJ hobj)
Definition: gdiobj.c:1153
#define TRUE
Definition: types.h:120
#define ERROR_INVALID_HANDLE
Definition: compat.h:88
ULONG NTAPI GreGetObjectOwner(HGDIOBJ hobj)
Definition: gdiobj.c:1187
NTSTATUS APIENTRY NtGdiFlushUserBatch(VOID)
Definition: gdibatch.c:445
#define GDI_HANDLE_IS_STOCKOBJ(h)
Definition: gdi.h:37
#define GDI_HANDLE_GET_TYPE(h)
Definition: gdi.h:31
#define GDI_OBJECT_TYPE_DC
Definition: gdi.h:46
#define GDI_OBJ_HMGR_POWNED
Definition: ntgdihdl.h:117
BOOL FASTCALL IntGdiDeleteDC(HDC hDC, BOOL Force)
Definition: dclife.c:881
ENGAPI VOID APIENTRY EngSetLastError(_In_ ULONG iError)
Definition: error.c:27

◆ NtGdiMakeInfoDC()

BOOL APIENTRY NtGdiMakeInfoDC ( IN HDC  hdc,
IN BOOL  bSet 
)

Definition at line 1015 of file dclife.c.

1018 {
1019  BOOL Ret;
1020  PDC pdc = DC_LockDc(hdc);
1021  if (pdc)
1022  {
1023  Ret = MakeInfoDC(pdc, bSet);
1024  DC_UnlockDc(pdc);
1025  return Ret;
1026  }
1027  return FALSE;
1028 }
FORCEINLINE PDC DC_LockDc(HDC hdc)
Definition: dc.h:219
BOOL FASTCALL MakeInfoDC(PDC pdc, BOOL bSet)
Definition: dclife.c:961
unsigned int BOOL
Definition: ntddk_ex.h:94
Definition: polytest.cpp:40
HDC hdc
Definition: main.c:9
FORCEINLINE VOID DC_UnlockDc(PDC pdc)
Definition: dc.h:237

◆ NtGdiOpenDCW()

__kernel_entry HDC APIENTRY NtGdiOpenDCW ( _In_opt_ PUNICODE_STRING  pustrDevice,
_In_ DEVMODEW pdmInit,
_In_ PUNICODE_STRING  pustrLogAddr,
_In_ ULONG  iType,
_In_ BOOL  bDisplay,
_In_opt_ HANDLE  hspool,
_At_((PUMDHPDEV *) pUMdhpdev, _Out_) PVOID  pUMdhpdev 
)

Definition at line 685 of file dclife.c.

693 {
694  UNICODE_STRING ustrDevice;
695  WCHAR awcDevice[CCHDEVICENAME];
696  PVOID dhpdev;
697  HDC hdc;
698  WORD dmSize, dmDriverExtra;
699  DWORD Size;
700  DEVMODEW * _SEH2_VOLATILE pdmAllocated = NULL;
701 
702  /* Only if a devicename is given, we need any data */
703  if (pustrDevice)
704  {
705  /* Initialize destination string */
706  RtlInitEmptyUnicodeString(&ustrDevice, awcDevice, sizeof(awcDevice));
707 
708  _SEH2_TRY
709  {
710  /* Probe the UNICODE_STRING and the buffer */
711  ProbeForRead(pustrDevice, sizeof(UNICODE_STRING), 1);
712  ProbeForRead(pustrDevice->Buffer, pustrDevice->Length, 1);
713 
714  /* Copy the string */
715  RtlCopyUnicodeString(&ustrDevice, pustrDevice);
716 
717  /* Allocate and store pdmAllocated if pdmInit is not NULL */
718  if (pdmInit)
719  {
720  ProbeForRead(pdmInit, sizeof(DEVMODEW), 1);
721 
722  dmSize = pdmInit->dmSize;
723  dmDriverExtra = pdmInit->dmDriverExtra;
724  Size = dmSize + dmDriverExtra;
725  ProbeForRead(pdmInit, Size, 1);
726 
728  Size,
729  TAG_DC);
730  RtlCopyMemory(pdmAllocated, pdmInit, Size);
731  pdmAllocated->dmSize = dmSize;
732  pdmAllocated->dmDriverExtra = dmDriverExtra;
733  }
734 
735  if (pUMdhpdev)
736  {
737  ProbeForWrite(pUMdhpdev, sizeof(HANDLE), 1);
738  }
739  }
741  {
742  if (pdmAllocated)
743  {
744  ExFreePoolWithTag(pdmAllocated, TAG_DC);
745  }
747  _SEH2_YIELD(return NULL);
748  }
749  _SEH2_END
750  }
751  else
752  {
753  pdmInit = NULL;
754  pUMdhpdev = NULL;
755  }
756 
757  /* FIXME: HACK! */
758  if (pustrDevice)
759  {
760  UNICODE_STRING ustrDISPLAY = RTL_CONSTANT_STRING(L"DISPLAY");
761  if (RtlEqualUnicodeString(&ustrDevice, &ustrDISPLAY, TRUE))
762  {
763  pustrDevice = NULL;
764  }
765  }
766 
767  /* Call the internal function */
768  hdc = GreOpenDCW(pustrDevice ? &ustrDevice : NULL,
769  pdmAllocated,
770  NULL, // FIXME: pwszLogAddress
771  iType,
772  bDisplay,
773  hspool,
774  NULL, // FIXME: pDriverInfo2
775  pUMdhpdev ? &dhpdev : NULL);
776 
777  /* If we got a HDC and a UM dhpdev is requested,... */
778  if (hdc && pUMdhpdev)
779  {
780  /* Copy dhpdev to caller (FIXME: use dhpdev?) */
781  _SEH2_TRY
782  {
783  /* Pointer was already probed */
784  *(HANDLE*)pUMdhpdev = dhpdev;
785  }
787  {
788  /* Ignore error */
789  (void)0;
790  }
791  _SEH2_END
792  }
793 
794  /* Free the allocated */
795  if (pdmAllocated)
796  {
797  ExFreePoolWithTag(pdmAllocated, TAG_DC);
798  }
799 
800  return hdc;
801 }
#define TAG_DC
Definition: tags.h:21
#define TRUE
Definition: types.h:120
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:49
_In_ ULONG iType
Definition: winddi.h:3748
static HDC
Definition: imagelist.c:92
HDC NTAPI GreOpenDCW(PUNICODE_STRING pustrDevice, DEVMODEW *pdmInit, PUNICODE_STRING pustrLogAddr, ULONG iType, BOOL bDisplay, HANDLE hspool, VOID *pDriverInfo2, VOID *pUMdhpdev)
Definition: dclife.c:632
VOID NTAPI ProbeForWrite(IN PVOID Address, IN SIZE_T Length, IN ULONG Alignment)
Definition: exintrin.c:143
NTSYSAPI VOID NTAPI RtlCopyUnicodeString(PUNICODE_STRING DestinationString, PUNICODE_STRING SourceString)
_SEH2_TRY
Definition: create.c:4250
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
smooth NULL
Definition: ftsmooth.c:416
#define _SEH2_YIELD(STMT_)
Definition: pseh2_64.h:8
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned short WORD
Definition: ntddk_ex.h:93
unsigned long DWORD
Definition: ntddk_ex.h:95
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
VOID NTAPI ProbeForRead(IN CONST VOID *Address, IN SIZE_T Length, IN ULONG Alignment)
Definition: exintrin.c:102
static const WCHAR L[]
Definition: oid.c:1250
HDC hdc
Definition: main.c:9
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:359
VOID FASTCALL SetLastNtError(NTSTATUS Status)
Definition: error.c:36
_SEH2_END
Definition: create.c:4424
#define CCHDEVICENAME
Definition: ddrawi.h:63
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:6
#define POOL_RAISE_IF_ALLOCATION_FAILURE
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099
#define _SEH2_GetExceptionCode()
Definition: pseh2_64.h:12
NTSYSAPI BOOLEAN NTAPI RtlEqualUnicodeString(PUNICODE_STRING String1, PUNICODE_STRING String2, BOOLEAN CaseInSensitive)
#define RTL_CONSTANT_STRING(s)
Definition: tunneltest.c:14

Referenced by IntCreateDICW().

Variable Documentation

◆ gmxDeviceToWorldDefault

const MATRIX gmxDeviceToWorldDefault
Initial value:
=
{
0, 0, 0x53
}
#define FLOATOBJ_1_16
Definition: floatobj.h:113
#define FLOATOBJ_0
Definition: floatobj.h:110

Definition at line 28 of file dclife.c.

◆ gmxWorldToDeviceDefault

const MATRIX gmxWorldToDeviceDefault
Initial value:
=
{
0, 0, 0x4b
}
#define FLOATOBJ_16
Definition: floatobj.h:112
#define FLOATOBJ_0
Definition: floatobj.h:110

Definition at line 20 of file dclife.c.

◆ gmxWorldToPageDefault

const MATRIX gmxWorldToPageDefault
Initial value:
=
{
0, 0, 0x63
}
#define FLOATOBJ_1
Definition: floatobj.h:111
#define FLOATOBJ_0
Definition: floatobj.h:110

Definition at line 36 of file dclife.c.

Referenced by DC_vInitDc().

◆ pbrDefaultBrush

PBRUSH pbrDefaultBrush = NULL

Definition at line 18 of file dclife.c.

Referenced by DC_vInitDc(), DC_vUpdateBackgroundBrush(), DC_vUpdateTextBrush(), and InitDcImpl().

◆ psurfDefaultBitmap

PSURFACE psurfDefaultBitmap = NULL

Definition at line 17 of file dclife.c.

Referenced by EBRUSHOBJ_vInit(), InitDcImpl(), IntCreateCompatibleBitmap(), and TranslateCOLORREF().