2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS kernel
4 * PURPOSE: Functions for creation and destruction of DCs
5 * FILE: subsystem/win32/win32k/objects/dclife.c
6 * PROGRAMER: Timo Kreuzer (timo.kreuzer@rectos.org)
15 //FIXME: windows uses 0x0012009f
16 #define DIRTY_DEFAULT DIRTY_CHARSET|DIRTY_BACKGROUND|DIRTY_TEXT|DIRTY_LINE|DIRTY_FILL
18 PSURFACE psurfDefaultBitmap
= NULL
;
19 PBRUSH pbrDefaultBrush
= NULL
;
21 // FIXME: these should go to floatobj.h or something
22 #define FLOATOBJ_0 {0x00000000, 0x00000000}
23 #define FLOATOBJ_1 {0x40000000, 0x00000002}
24 #define FLOATOBJ_16 {0x40000000, 0x00000006}
25 #define FLOATOBJ_1_16 {0x40000000, 0xfffffffe}
27 static const FLOATOBJ gef0
= FLOATOBJ_0
;
28 static const FLOATOBJ gef1
= FLOATOBJ_1
;
29 static const FLOATOBJ gef16
= FLOATOBJ_16
;
31 static const MATRIX gmxWorldToDeviceDefault
=
33 FLOATOBJ_16
, FLOATOBJ_0
,
34 FLOATOBJ_0
, FLOATOBJ_16
,
35 FLOATOBJ_0
, FLOATOBJ_0
,
39 static const MATRIX gmxDeviceToWorldDefault
=
41 FLOATOBJ_1_16
, FLOATOBJ_0
,
42 FLOATOBJ_0
, FLOATOBJ_1_16
,
43 FLOATOBJ_0
, FLOATOBJ_0
,
47 static const MATRIX gmxWorldToPageDefault
=
49 FLOATOBJ_1
, FLOATOBJ_0
,
50 FLOATOBJ_0
, FLOATOBJ_1
,
51 FLOATOBJ_0
, FLOATOBJ_0
,
55 // HACK!! Fix XFORMOBJ then use 1:16 / 16:1
56 #define gmxWorldToDeviceDefault gmxWorldToPageDefault
57 #define gmxDeviceToWorldDefault gmxWorldToPageDefault
59 /** Internal functions ********************************************************/
64 psurfDefaultBitmap
= SURFACE_ShareLockSurface(StockObjects
[DEFAULT_BITMAP
]);
65 if (!psurfDefaultBitmap
)
66 return STATUS_UNSUCCESSFUL
;
68 pbrDefaultBrush
= BRUSH_ShareLockBrush(StockObjects
[BLACK_BRUSH
]);
70 return STATUS_UNSUCCESSFUL
;
72 return STATUS_SUCCESS
;
78 DC_AllocDcWithHandle()
81 pdc
= (PDC
)GDIOBJ_AllocObjWithHandle(GDILoObjType_LO_DC_TYPE
);
83 pdc
->pdcattr
= &pdc
->dcattr
;
94 TextIntRealizeFont(pdc
->pdcattr
->hlfntNew
,NULL
);
95 pdc
->pdcattr
->iCS_CP
= ftGdiGetTextCharsetInfo(pdc
,NULL
,0);
97 /* This should never fail */
98 ASSERT(pdc
->dclevel
.ppal
);
101 // FIXME: too complicated, broken error handling
102 pdc
->rosdc
.hClipRgn
= NULL
;
103 pdc
->rosdc
.hGCClipRgn
= NULL
;
104 hVisRgn
= NtGdiCreateRectRgn(0, 0, pdc
->dclevel
.sizl
.cx
, pdc
->dclevel
.sizl
.cy
);
106 GdiSelectVisRgn(pdc
->BaseObject
.hHmgr
, hVisRgn
);
107 GreDeleteObject(hVisRgn
);
108 ASSERT(pdc
->prgnVis
);
109 pdc
->rosdc
.bitsPerPixel
= pdc
->ppdev
->gdiinfo
.cBitsPixel
*
110 pdc
->ppdev
->gdiinfo
.cPlanes
;
120 if (dctype
== DCTYPE_DIRECT
)
123 EngAcquireSemaphoreShared(ppdev
->hsemDevLock
);
126 /* Setup some basic fields */
127 pdc
->dctype
= dctype
;
129 pdc
->dhpdev
= ppdev
->dhpdev
;
130 pdc
->hsem
= ppdev
->hsemDevLock
;
131 pdc
->flGraphicsCaps
= ppdev
->devinfo
.flGraphicsCaps
;
132 pdc
->flGraphicsCaps2
= ppdev
->devinfo
.flGraphicsCaps2
;
133 pdc
->fs
= DC_DIRTY_RAO
;
135 /* Setup dc attribute */
136 pdc
->pdcattr
= &pdc
->dcattr
;
137 pdc
->dcattr
.pvLDC
= NULL
;
138 pdc
->dcattr
.ulDirty_
= DIRTY_DEFAULT
;
139 if (ppdev
== gppdevPrimary
)
140 pdc
->dcattr
.ulDirty_
|= DC_PRIMARY_DISPLAY
;
142 /* Setup the DC size */
143 if (dctype
== DCTYPE_MEMORY
)
145 /* Memory DCs have a 1 x 1 bitmap by default */
146 pdc
->dclevel
.sizl
.cx
= 1;
147 pdc
->dclevel
.sizl
.cy
= 1;
151 /* Other DC's are as big as the related PDEV */
152 pdc
->dclevel
.sizl
.cx
= ppdev
->gdiinfo
.ulHorzRes
;
153 pdc
->dclevel
.sizl
.cy
= ppdev
->gdiinfo
.ulVertRes
;
156 /* Setup Window rect based on DC size */
157 pdc
->erclWindow
.left
= 0;
158 pdc
->erclWindow
.top
= 0;
159 pdc
->erclWindow
.right
= pdc
->dclevel
.sizl
.cx
;
160 pdc
->erclWindow
.bottom
= pdc
->dclevel
.sizl
.cy
;
162 if (dctype
== DCTYPE_DIRECT
)
164 /* Direct DCs get the surface from the PDEV */
165 pdc
->dclevel
.pSurface
= PDEVOBJ_pSurface(ppdev
);
167 pdc
->erclBounds
.left
= 0x7fffffff;
168 pdc
->erclBounds
.top
= 0x7fffffff;
169 pdc
->erclBounds
.right
= 0x80000000;
170 pdc
->erclBounds
.bottom
= 0x80000000;
171 pdc
->erclBoundsApp
.left
= 0xffffffff;
172 pdc
->erclBoundsApp
.top
= 0xfffffffc;
173 pdc
->erclBoundsApp
.right
= 0x00007ffc; // FIXME
174 pdc
->erclBoundsApp
.bottom
= 0x00000333; // FIXME
175 pdc
->erclClip
= pdc
->erclBounds
;
178 pdc
->fs
|= DC_SYNCHRONIZEACCESS
| DC_ACCUM_APP
| DC_PERMANANT
| DC_DISPLAY
;
182 /* Non-direct DCs don't have a surface by default */
183 pdc
->dclevel
.pSurface
= NULL
;
185 // FIXME: HACK, because our code expects a surface
186 pdc
->dclevel
.pSurface
= SURFACE_ShareLockSurface(StockObjects
[DEFAULT_BITMAP
]);
188 pdc
->erclBounds
.left
= 0;
189 pdc
->erclBounds
.top
= 0;
190 pdc
->erclBounds
.right
= 0;
191 pdc
->erclBounds
.bottom
= 0;
192 pdc
->erclBoundsApp
= pdc
->erclBounds
;
193 pdc
->erclClip
= pdc
->erclWindow
;
197 // pdc->dcattr.VisRectRegion:
199 /* Setup coordinate transformation data */
200 pdc
->dclevel
.mxWorldToDevice
= gmxWorldToDeviceDefault
;
201 pdc
->dclevel
.mxDeviceToWorld
= gmxDeviceToWorldDefault
;
202 pdc
->dclevel
.mxWorldToPage
= gmxWorldToPageDefault
;
203 pdc
->dclevel
.efM11PtoD
= gef16
;
204 pdc
->dclevel
.efM22PtoD
= gef16
;
205 pdc
->dclevel
.efDxPtoD
= gef0
;
206 pdc
->dclevel
.efDyPtoD
= gef0
;
207 pdc
->dclevel
.efM11_TWIPS
= gef0
;
208 pdc
->dclevel
.efM22_TWIPS
= gef0
;
209 pdc
->dclevel
.efPr11
= gef0
;
210 pdc
->dclevel
.efPr22
= gef0
;
211 pdc
->dcattr
.mxWorldToDevice
= pdc
->dclevel
.mxWorldToDevice
;
212 pdc
->dcattr
.mxDeviceToWorld
= pdc
->dclevel
.mxDeviceToWorld
;
213 pdc
->dcattr
.mxWorldToPage
= pdc
->dclevel
.mxWorldToPage
;
214 pdc
->dcattr
.efM11PtoD
= pdc
->dclevel
.efM11PtoD
;
215 pdc
->dcattr
.efM22PtoD
= pdc
->dclevel
.efM22PtoD
;
216 pdc
->dcattr
.efDxPtoD
= pdc
->dclevel
.efDxPtoD
;
217 pdc
->dcattr
.efDyPtoD
= pdc
->dclevel
.efDyPtoD
;
218 pdc
->dcattr
.iMapMode
= MM_TEXT
;
219 pdc
->dcattr
.dwLayout
= 0;
220 pdc
->dcattr
.flXform
= PAGE_TO_DEVICE_SCALE_IDENTITY
|
221 PAGE_TO_DEVICE_IDENTITY
|
222 WORLD_TO_PAGE_IDENTITY
;
224 /* Setup more coordinates */
225 pdc
->ptlDCOrig
.x
= 0;
226 pdc
->ptlDCOrig
.y
= 0;
227 pdc
->dcattr
.lWindowOrgx
= 0;
228 pdc
->dcattr
.ptlWindowOrg
.x
= 0;
229 pdc
->dcattr
.ptlWindowOrg
.y
= 0;
230 pdc
->dcattr
.szlWindowExt
.cx
= 1;
231 pdc
->dcattr
.szlWindowExt
.cy
= 1;
232 pdc
->dcattr
.ptlViewportOrg
.x
= 0;
233 pdc
->dcattr
.ptlViewportOrg
.y
= 0;
234 pdc
->dcattr
.szlViewportExt
.cx
= 1;
235 pdc
->dcattr
.szlViewportExt
.cy
= 1;
236 pdc
->dcattr
.szlVirtualDevicePixel
.cx
= 0;
237 pdc
->dcattr
.szlVirtualDevicePixel
.cy
= 0;
238 pdc
->dcattr
.szlVirtualDeviceMm
.cx
= 0;
239 pdc
->dcattr
.szlVirtualDeviceMm
.cy
= 0;
240 pdc
->dcattr
.szlVirtualDeviceSize
.cx
= 0;
241 pdc
->dcattr
.szlVirtualDeviceSize
.cy
= 0;
245 pdc
->prgnVis
= NULL
; // FIXME
249 pdc
->dclevel
.hpal
= StockObjects
[DEFAULT_PALETTE
];
250 pdc
->dclevel
.ppal
= PALETTE_ShareLockPalette(pdc
->dclevel
.hpal
);
253 pdc
->dclevel
.hPath
= NULL
;
254 pdc
->dclevel
.flPath
= 0;
255 // pdc->dclevel.lapath:
258 pdc
->dcattr
.crBackgroundClr
= RGB(0xff, 0xff, 0xff);
259 pdc
->dcattr
.ulBackgroundClr
= RGB(0xff, 0xff, 0xff);
260 pdc
->dcattr
.crForegroundClr
= RGB(0, 0, 0);
261 pdc
->dcattr
.ulForegroundClr
= RGB(0, 0, 0);
262 pdc
->dcattr
.crBrushClr
= RGB(0xff, 0xff, 0xff);
263 pdc
->dcattr
.ulBrushClr
= RGB(0xff, 0xff, 0xff);
264 pdc
->dcattr
.crPenClr
= RGB(0, 0, 0);
265 pdc
->dcattr
.ulPenClr
= RGB(0, 0, 0);
267 /* Select the default fill and line brush */
268 pdc
->dcattr
.hbrush
= StockObjects
[WHITE_BRUSH
];
269 pdc
->dcattr
.hpen
= StockObjects
[BLACK_PEN
];
270 pdc
->dclevel
.pbrFill
= BRUSH_ShareLockBrush(pdc
->pdcattr
->hbrush
);
271 pdc
->dclevel
.pbrLine
= PEN_ShareLockPen(pdc
->pdcattr
->hpen
);
272 pdc
->dclevel
.ptlBrushOrigin
.x
= 0;
273 pdc
->dclevel
.ptlBrushOrigin
.y
= 0;
274 pdc
->dcattr
.ptlBrushOrigin
= pdc
->dclevel
.ptlBrushOrigin
;
276 /* Initialize EBRUSHOBJs */
277 EBRUSHOBJ_vInit(&pdc
->eboFill
, pdc
->dclevel
.pbrFill
, pdc
);
278 EBRUSHOBJ_vInit(&pdc
->eboLine
, pdc
->dclevel
.pbrLine
, pdc
);
279 EBRUSHOBJ_vInit(&pdc
->eboText
, pbrDefaultBrush
, pdc
);
280 EBRUSHOBJ_vInit(&pdc
->eboBackground
, pbrDefaultBrush
, pdc
);
282 /* Setup fill data */
283 pdc
->dcattr
.jROP2
= R2_COPYPEN
;
284 pdc
->dcattr
.jBkMode
= 2;
285 pdc
->dcattr
.lBkMode
= 2;
286 pdc
->dcattr
.jFillMode
= ALTERNATE
;
287 pdc
->dcattr
.lFillMode
= 1;
288 pdc
->dcattr
.jStretchBltMode
= 1;
289 pdc
->dcattr
.lStretchBltMode
= 1;
290 pdc
->ptlFillOrigin
.x
= 0;
291 pdc
->ptlFillOrigin
.y
= 0;
293 /* Setup drawing position */
294 pdc
->dcattr
.ptlCurrent
.x
= 0;
295 pdc
->dcattr
.ptlCurrent
.y
= 0;
296 pdc
->dcattr
.ptfxCurrent
.x
= 0;
297 pdc
->dcattr
.ptfxCurrent
.y
= 0;
300 pdc
->dclevel
.lIcmMode
= 0;
301 pdc
->dcattr
.lIcmMode
= 0;
302 pdc
->dcattr
.hcmXform
= NULL
;
303 pdc
->dcattr
.flIcmFlags
= 0;
304 pdc
->dcattr
.IcmBrushColor
= CLR_INVALID
;
305 pdc
->dcattr
.IcmPenColor
= CLR_INVALID
;
306 pdc
->dcattr
.pvLIcm
= NULL
;
307 pdc
->dcattr
.hColorSpace
= NULL
; // FIXME: 0189001f
308 pdc
->dclevel
.pColorSpace
= NULL
; // FIXME
309 pdc
->pClrxFormLnk
= NULL
;
312 /* Setup font data */
313 pdc
->hlfntCur
= NULL
; // FIXME: 2f0a0cf8
314 pdc
->pPFFList
= NULL
;
315 pdc
->flSimulationFlags
= 0;
316 pdc
->lEscapement
= 0;
318 pdc
->dcattr
.flFontMapper
= 0;
319 pdc
->dcattr
.flTextAlign
= 0;
320 pdc
->dcattr
.lTextAlign
= 0;
321 pdc
->dcattr
.lTextExtra
= 0;
322 pdc
->dcattr
.lRelAbs
= 1;
323 pdc
->dcattr
.lBreakExtra
= 0;
324 pdc
->dcattr
.cBreak
= 0;
325 pdc
->dcattr
.hlfntNew
= StockObjects
[SYSTEM_FONT
];
326 // pdc->dclevel.pFont = LFONT_ShareLockFont(pdc->dcattr.hlfntNew);
331 pdc
->ipfdDevMax
= 0x0000ffff;
332 pdc
->ulCopyCount
= -1;
333 pdc
->ptlDoBanding
.x
= 0;
334 pdc
->ptlDoBanding
.y
= 0;
335 pdc
->dclevel
.lSaveDepth
= 1;
336 pdc
->dclevel
.hdcSave
= NULL
;
337 pdc
->dcattr
.iGraphicsMode
= GM_COMPATIBLE
;
338 pdc
->dcattr
.iCS_CP
= 0;
339 pdc
->pSurfInfo
= NULL
;
345 DC_Cleanup(PVOID ObjectBody
)
347 PDC pdc
= (PDC
)ObjectBody
;
352 /* Delete saved DCs */
353 DC_vRestoreDC(pdc
, 1);
355 /* Deselect dc objects */
356 DC_vSelectSurface(pdc
, NULL
);
357 DC_vSelectFillBrush(pdc
, NULL
);
358 DC_vSelectLineBrush(pdc
, NULL
);
359 DC_vSelectPalette(pdc
, NULL
);
361 /* Cleanup the dc brushes */
362 EBRUSHOBJ_vCleanup(&pdc
->eboFill
);
363 EBRUSHOBJ_vCleanup(&pdc
->eboLine
);
364 EBRUSHOBJ_vCleanup(&pdc
->eboText
);
365 EBRUSHOBJ_vCleanup(&pdc
->eboBackground
);
368 if (pdc
->rosdc
.hClipRgn
)
369 GreDeleteObject(pdc
->rosdc
.hClipRgn
);
371 REGION_FreeRgnByHandle(pdc
->prgnVis
->BaseObject
.hHmgr
);
372 ASSERT(pdc
->rosdc
.hGCClipRgn
);
373 if (pdc
->rosdc
.hGCClipRgn
)
374 GreDeleteObject(pdc
->rosdc
.hGCClipRgn
);
375 if (NULL
!= pdc
->rosdc
.CombinedClip
)
376 IntEngDeleteClipRegion(pdc
->rosdc
.CombinedClip
);
378 PATH_Delete(pdc
->dclevel
.hPath
);
380 if(pdc
->dclevel
.pSurface
)
381 SURFACE_ShareUnlockSurface(pdc
->dclevel
.pSurface
);
383 PDEVOBJ_vRelease(pdc
->ppdev
) ;
390 DC_SetOwnership(HDC hDC
, PEPROCESS Owner
)
393 PGDI_TABLE_ENTRY Entry
;
397 /* FIXME: This function has broken error handling */
399 if (!GDIOBJ_SetOwnership(hDC
, Owner
))
401 DPRINT1("GDIOBJ_SetOwnership failed\n");
405 pDC
= DC_LockDc(hDC
);
408 DPRINT1("Could not lock DC\n");
414 These regions do not use attribute sections and when allocated, use
415 gdiobj level functions.
417 if (pDC
->rosdc
.hClipRgn
)
419 Index
= GDI_HANDLE_GET_INDEX(pDC
->rosdc
.hClipRgn
);
420 Entry
= &GdiHandleTable
->Entries
[Index
];
421 if (Entry
->UserData
) FreeObjectAttr(Entry
->UserData
);
422 Entry
->UserData
= NULL
;
424 if (!GDIOBJ_SetOwnership(pDC
->rosdc
.hClipRgn
, Owner
)) goto leave
;
428 Index
= GDI_HANDLE_GET_INDEX(pDC
->prgnVis
->BaseObject
.hHmgr
);
429 Entry
= &GdiHandleTable
->Entries
[Index
];
430 if (Entry
->UserData
) FreeObjectAttr(Entry
->UserData
);
431 Entry
->UserData
= NULL
;
433 if (!GDIOBJ_SetOwnership(pDC
->prgnVis
->BaseObject
.hHmgr
, Owner
)) goto leave
;
435 if (pDC
->rosdc
.hGCClipRgn
)
437 Index
= GDI_HANDLE_GET_INDEX(pDC
->rosdc
.hGCClipRgn
);
438 Entry
= &GdiHandleTable
->Entries
[Index
];
439 if (Entry
->UserData
) FreeObjectAttr(Entry
->UserData
);
440 Entry
->UserData
= NULL
;
442 if (!GDIOBJ_SetOwnership(pDC
->rosdc
.hGCClipRgn
, Owner
)) goto leave
;
444 if (pDC
->dclevel
.hPath
)
446 if (!GDIOBJ_SetOwnership(pDC
->dclevel
.hPath
, Owner
)) goto leave
;
459 PUNICODE_STRING pustrDevice
,
461 PUNICODE_STRING pustrLogAddr
,
472 DPRINT("GreOpenDCW(%S, iType=%ld)\n",
473 pustrDevice
? pustrDevice
->Buffer
: NULL
, iType
);
475 /* Get a PDEVOBJ for the device */
476 ppdev
= EngpGetPDEV(pustrDevice
);
479 DPRINT1("Didn't find a suitable PDEV\n");
483 DPRINT("GreOpenDCW - ppdev = %p\n", ppdev
);
485 pdc
= DC_AllocDcWithHandle();
488 DPRINT1("Could not Allocate a DC\n");
489 PDEVOBJ_vRelease(ppdev
);
492 hdc
= pdc
->BaseObject
.hHmgr
;
494 /* Lock ppdev and initialize the new DC */
495 DC_vInitDc(pdc
, iType
, ppdev
);
503 DPRINT("returning hdc = %p\n", hdc
);
511 PUNICODE_STRING pustrDevice
,
513 PUNICODE_STRING pustrLogAddr
,
520 UNICODE_STRING ustrDevice
;
521 WCHAR awcDevice
[CCHDEVICENAME
];
526 /* Only if a devicename is given, we need any data */
529 /* Initialize destination string */
530 RtlInitEmptyUnicodeString(&ustrDevice
, awcDevice
, sizeof(awcDevice
));
534 /* Probe the UNICODE_STRING and the buffer */
535 ProbeForRead(pustrDevice
, sizeof(UNICODE_STRING
), 1);
536 ProbeForRead(pustrDevice
->Buffer
, pustrDevice
->Length
, 1);
538 /* Copy the string */
539 RtlCopyUnicodeString(&ustrDevice
, pustrDevice
);
543 /* FIXME: could be larger */
544 ProbeForRead(pdmInit
, sizeof(DEVMODEW
), 1);
545 RtlCopyMemory(&dmInit
, pdmInit
, sizeof(DEVMODEW
));
550 ProbeForWrite(pUMdhpdev
, sizeof(HANDLE
), 1);
553 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
555 SetLastNtError(_SEH2_GetExceptionCode());
556 _SEH2_YIELD(return NULL
);
569 UNICODE_STRING ustrDISPLAY
= RTL_CONSTANT_STRING(L
"DISPLAY");
570 if (RtlEqualUnicodeString(&ustrDevice
, &ustrDISPLAY
, TRUE
))
576 /* Call the internal function */
577 hdc
= GreOpenDCW(pustrDevice
? &ustrDevice
: NULL
,
578 pdmInit
? &dmInit
: NULL
,
579 NULL
, // fixme pwszLogAddress
583 NULL
, //FIXME: pDriverInfo2
584 pUMdhpdev
? &dhpdev
: NULL
);
586 /* If we got a HDC and a UM dhpdev is requested,... */
587 if (hdc
&& pUMdhpdev
)
589 /* Copy dhpdev to caller (FIXME: use dhpdev?? */
592 /* Pointer was already probed */
593 *(HANDLE
*)pUMdhpdev
= dhpdev
;
595 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
608 NtGdiCreateCompatibleDC(HDC hdc
)
614 DPRINT("NtGdiCreateCompatibleDC(0x%p)\n", hdc
);
616 /* Did the caller provide a DC? */
619 /* Yes, try to lock it */
620 pdc
= DC_LockDc(hdc
);
623 DPRINT1("Could not lock source DC %p\n", hdc
);
627 /* Get the pdev from the DC */
629 InterlockedIncrement(&ppdev
->cPdevRefs
);
631 /* Unlock the source DC */
636 /* No DC given, get default device */
637 ppdev
= EngpGetPDEV(NULL
);
642 DPRINT1("Didn't find a suitable PDEV\n");
646 /* Allocate a new DC */
647 pdcNew
= DC_AllocDcWithHandle();
650 DPRINT1("Could not allocate a new DC\n");
651 PDEVOBJ_vRelease(ppdev
);
654 hdcNew
= pdcNew
->BaseObject
.hHmgr
;
656 /* Lock ppdev and initialize the new DC */
657 DC_vInitDc(pdcNew
, DCTYPE_MEMORY
, ppdev
);
661 /* Allocate a dc attribute */
662 DC_AllocDcAttr(pdcNew
);
665 DC_vSelectSurface(pdcNew
, psurfDefaultBitmap
);
669 DPRINT("Leave NtGdiCreateCompatibleDC hdcNew = %p\n", hdcNew
);
676 IntGdiDeleteDC(HDC hDC
, BOOL Force
)
678 PDC DCToDelete
= DC_LockDc(hDC
);
680 if (DCToDelete
== NULL
)
682 SetLastWin32Error(ERROR_INVALID_HANDLE
);
688 if (DCToDelete
->fs
& DC_FLAG_PERMANENT
)
690 DPRINT1("No! You Naughty Application!\n");
691 DC_UnlockDc(DCToDelete
);
692 return UserReleaseDC(NULL
, hDC
, FALSE
);
696 DC_UnlockDc(DCToDelete
);
698 if (!IsObjectDead(hDC
))
700 if (!GDIOBJ_FreeObjByHandle(hDC
, GDI_OBJECT_TYPE_DC
))
702 DPRINT1("DC_FreeDC failed\n");
707 DPRINT1("Attempted to Delete 0x%x currently being destroyed!!!\n", hDC
);
715 NtGdiDeleteObjectApp(HANDLE DCHandle
)
717 /* Complete all pending operations */
718 NtGdiFlushUserBatch();
720 if (GDI_HANDLE_IS_STOCKOBJ(DCHandle
)) return TRUE
;
722 if (GDI_HANDLE_GET_TYPE(DCHandle
) != GDI_OBJECT_TYPE_DC
)
723 return GreDeleteObject((HGDIOBJ
) DCHandle
);
725 if (IsObjectDead((HGDIOBJ
)DCHandle
)) return TRUE
;
727 if (!GDIOBJ_OwnedByCurrentProcess(DCHandle
))
729 SetLastWin32Error(ERROR_INVALID_HANDLE
);
733 return IntGdiDeleteDC(DCHandle
, FALSE
);
738 MakeInfoDC(PDC pdc
, BOOL bSet
)
743 /* Can not be a display DC. */
744 if (pdc
->fs
& DC_FLAG_DISPLAY
) return FALSE
;
747 if (pdc
->fs
& DC_FLAG_TEMPINFODC
|| pdc
->dctype
== DC_TYPE_DIRECT
)
750 pSurface
= pdc
->dclevel
.pSurface
;
751 pdc
->fs
|= DC_FLAG_TEMPINFODC
;
752 pdc
->pSurfInfo
= pSurface
;
753 pdc
->dctype
= DC_TYPE_INFO
;
754 pdc
->dclevel
.pSurface
= NULL
;
756 PDEVOBJ_sizl(pdc
->ppdev
, &sizl
);
758 if ( sizl
.cx
== pdc
->dclevel
.sizl
.cx
&&
759 sizl
.cy
== pdc
->dclevel
.sizl
.cy
)
762 pdc
->dclevel
.sizl
.cx
= sizl
.cx
;
763 pdc
->dclevel
.sizl
.cy
= sizl
.cy
;
767 if (!(pdc
->fs
& DC_FLAG_TEMPINFODC
) || pdc
->dctype
!= DC_TYPE_INFO
)
770 pSurface
= pdc
->pSurfInfo
;
771 pdc
->fs
&= ~DC_FLAG_TEMPINFODC
;
772 pdc
->dclevel
.pSurface
= pSurface
;
773 pdc
->dctype
= DC_TYPE_DIRECT
;
774 pdc
->pSurfInfo
= NULL
;
777 (pSurface
->SurfObj
.sizlBitmap
.cx
== pdc
->dclevel
.sizl
.cx
&&
778 pSurface
->SurfObj
.sizlBitmap
.cy
== pdc
->dclevel
.sizl
.cy
) )
781 pdc
->dclevel
.sizl
.cx
= pSurface
->SurfObj
.sizlBitmap
.cx
;
782 pdc
->dclevel
.sizl
.cy
= pSurface
->SurfObj
.sizlBitmap
.cy
;
784 return IntSetDefaultRegion(pdc
);
797 PDC pdc
= DC_LockDc(hdc
);
800 Ret
= MakeInfoDC(pdc
, bSet
);
810 PUNICODE_STRING Driver
,
811 PUNICODE_STRING pustrDevice
,
813 CONST PDEVMODEW pdmInit
,
818 hdc
= GreOpenDCW(pustrDevice
,
821 CreateAsIC
? DCTYPE_INFO
:
822 (Driver
? DC_TYPE_DIRECT
: DC_TYPE_DIRECT
),
832 IntGdiCreateDisplayDC(HDEV hDev
, ULONG DcType
, BOOL EmptyDC
)
838 if (DcType
== DC_TYPE_MEMORY
)
839 hDC
= NtGdiCreateCompatibleDC(NULL
); // OH~ Yuck! I think I taste vomit in my mouth!
841 hDC
= IntGdiCreateDC(NULL
, NULL
, NULL
, NULL
, (DcType
== DC_TYPE_INFO
));