2009-03-24 03:15:18 +00:00
|
|
|
|
/*
|
2009-03-23 03:43:11 +00:00
|
|
|
|
* COPYRIGHT: See COPYING in the top level directory
|
|
|
|
|
* PROJECT: ReactOS kernel
|
|
|
|
|
* PURPOSE: Functions for creation and destruction of DCs
|
|
|
|
|
* FILE: subsystem/win32/win32k/objects/dclife.c
|
|
|
|
|
* PROGRAMER: Timo Kreuzer (timo.kreuzer@rectos.org)
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include <w32k.h>
|
|
|
|
|
#include <bugcodes.h>
|
|
|
|
|
|
|
|
|
|
#define NDEBUG
|
|
|
|
|
#include <debug.h>
|
|
|
|
|
|
|
|
|
|
/** Internal functions ********************************************************/
|
|
|
|
|
|
|
|
|
|
HDC FASTCALL
|
|
|
|
|
DC_AllocDC(PUNICODE_STRING Driver)
|
|
|
|
|
{
|
2009-03-24 03:15:18 +00:00
|
|
|
|
PDC NewDC;
|
|
|
|
|
PDC_ATTR pdcattr;
|
|
|
|
|
HDC hDC;
|
|
|
|
|
PWSTR Buf = NULL;
|
|
|
|
|
XFORM xformTemplate;
|
2009-04-01 01:49:18 +00:00
|
|
|
|
PBRUSH pbrush;
|
2009-08-04 20:37:10 +00:00
|
|
|
|
HSURF hsurf;
|
2009-03-24 03:15:18 +00:00
|
|
|
|
|
|
|
|
|
if (Driver != NULL)
|
2009-03-23 03:43:11 +00:00
|
|
|
|
{
|
2009-03-24 03:15:18 +00:00
|
|
|
|
Buf = ExAllocatePoolWithTag(PagedPool, Driver->MaximumLength, TAG_DC);
|
|
|
|
|
if (!Buf)
|
|
|
|
|
{
|
|
|
|
|
DPRINT1("ExAllocatePoolWithTag failed\n");
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
RtlCopyMemory(Buf, Driver->Buffer, Driver->MaximumLength);
|
2009-03-23 03:43:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
2009-03-24 03:15:18 +00:00
|
|
|
|
NewDC = (PDC)GDIOBJ_AllocObjWithHandle(GDI_OBJECT_TYPE_DC);
|
|
|
|
|
if (!NewDC)
|
2009-03-23 03:43:11 +00:00
|
|
|
|
{
|
2009-03-24 03:15:18 +00:00
|
|
|
|
if (Buf)
|
|
|
|
|
{
|
|
|
|
|
ExFreePoolWithTag(Buf, TAG_DC);
|
|
|
|
|
}
|
|
|
|
|
DPRINT1("GDIOBJ_AllocObjWithHandle failed\n");
|
|
|
|
|
return NULL;
|
2009-03-23 03:43:11 +00:00
|
|
|
|
}
|
2009-03-24 03:15:18 +00:00
|
|
|
|
|
|
|
|
|
hDC = NewDC->BaseObject.hHmgr;
|
|
|
|
|
|
|
|
|
|
NewDC->pdcattr = &NewDC->dcattr;
|
|
|
|
|
DC_AllocateDcAttr(hDC);
|
|
|
|
|
|
|
|
|
|
if (Driver != NULL)
|
|
|
|
|
{
|
|
|
|
|
RtlCopyMemory(&NewDC->rosdc.DriverName, Driver, sizeof(UNICODE_STRING));
|
|
|
|
|
NewDC->rosdc.DriverName.Buffer = Buf;
|
|
|
|
|
}
|
|
|
|
|
pdcattr = NewDC->pdcattr;
|
|
|
|
|
|
2009-03-24 04:10:49 +00:00
|
|
|
|
// FIXME: no floating point in the kernel!
|
2009-03-24 03:15:18 +00:00
|
|
|
|
xformTemplate.eM11 = 1.0f;
|
|
|
|
|
xformTemplate.eM12 = 0.0f;
|
|
|
|
|
xformTemplate.eM21 = 0.0f;
|
|
|
|
|
xformTemplate.eM22 = 1.0f;
|
|
|
|
|
xformTemplate.eDx = 0.0f;
|
|
|
|
|
xformTemplate.eDy = 0.0f;
|
|
|
|
|
XForm2MatrixS(&NewDC->dclevel.mxWorldToDevice, &xformTemplate);
|
|
|
|
|
XForm2MatrixS(&NewDC->dclevel.mxDeviceToWorld, &xformTemplate);
|
|
|
|
|
XForm2MatrixS(&NewDC->dclevel.mxWorldToPage, &xformTemplate);
|
2009-03-23 03:43:11 +00:00
|
|
|
|
|
2009-03-24 04:10:49 +00:00
|
|
|
|
// Setup syncing bits for the dcattr data packets.
|
2009-03-24 03:15:18 +00:00
|
|
|
|
pdcattr->flXform = DEVICE_TO_PAGE_INVALID;
|
2009-03-23 03:43:11 +00:00
|
|
|
|
|
2009-03-24 03:15:18 +00:00
|
|
|
|
pdcattr->ulDirty_ = 0; // Server side
|
2009-03-23 03:43:11 +00:00
|
|
|
|
|
2009-03-24 03:15:18 +00:00
|
|
|
|
pdcattr->iMapMode = MM_TEXT;
|
|
|
|
|
pdcattr->iGraphicsMode = GM_COMPATIBLE;
|
|
|
|
|
pdcattr->jFillMode = ALTERNATE;
|
2009-03-23 03:43:11 +00:00
|
|
|
|
|
2009-03-24 03:15:18 +00:00
|
|
|
|
pdcattr->szlWindowExt.cx = 1; // Float to Int,,, WRONG!
|
|
|
|
|
pdcattr->szlWindowExt.cy = 1;
|
|
|
|
|
pdcattr->szlViewportExt.cx = 1;
|
|
|
|
|
pdcattr->szlViewportExt.cy = 1;
|
2009-03-23 03:43:11 +00:00
|
|
|
|
|
2009-03-24 03:15:18 +00:00
|
|
|
|
pdcattr->crForegroundClr = 0;
|
|
|
|
|
pdcattr->ulForegroundClr = 0;
|
2009-03-23 03:43:11 +00:00
|
|
|
|
|
2009-03-24 03:15:18 +00:00
|
|
|
|
pdcattr->ulBackgroundClr = 0xffffff;
|
|
|
|
|
pdcattr->crBackgroundClr = 0xffffff;
|
2009-03-23 03:43:11 +00:00
|
|
|
|
|
2009-03-24 04:10:49 +00:00
|
|
|
|
pdcattr->ulPenClr = RGB(0, 0, 0);
|
|
|
|
|
pdcattr->crPenClr = RGB(0, 0, 0);
|
2009-03-23 03:43:11 +00:00
|
|
|
|
|
2009-03-24 04:10:49 +00:00
|
|
|
|
pdcattr->ulBrushClr = RGB(255, 255, 255); // Do this way too.
|
|
|
|
|
pdcattr->crBrushClr = RGB(255, 255, 255);
|
2009-03-23 03:43:11 +00:00
|
|
|
|
|
|
|
|
|
//// This fixes the default brush and pen settings. See DC_InitDC.
|
|
|
|
|
|
2009-03-24 03:15:18 +00:00
|
|
|
|
/* Create the default fill brush */
|
2009-03-24 04:10:49 +00:00
|
|
|
|
pdcattr->hbrush = NtGdiGetStockObject(WHITE_BRUSH);
|
2009-03-24 03:15:18 +00:00
|
|
|
|
NewDC->dclevel.pbrFill = BRUSH_ShareLockBrush(pdcattr->hbrush);
|
2009-07-10 23:44:05 +00:00
|
|
|
|
EBRUSHOBJ_vInit(&NewDC->eboFill, NewDC->dclevel.pbrFill, NewDC);
|
2009-03-23 03:43:11 +00:00
|
|
|
|
|
2009-03-24 03:15:18 +00:00
|
|
|
|
/* Create the default pen / line brush */
|
2009-03-24 04:10:49 +00:00
|
|
|
|
pdcattr->hpen = NtGdiGetStockObject(BLACK_PEN);
|
2009-03-24 03:15:18 +00:00
|
|
|
|
NewDC->dclevel.pbrLine = PEN_ShareLockPen(pdcattr->hpen);
|
2009-07-10 23:44:05 +00:00
|
|
|
|
EBRUSHOBJ_vInit(&NewDC->eboLine, NewDC->dclevel.pbrLine, NewDC);
|
2009-03-23 03:43:11 +00:00
|
|
|
|
|
2009-04-01 01:49:18 +00:00
|
|
|
|
/* Create the default text brush */
|
|
|
|
|
pbrush = BRUSH_ShareLockBrush(NtGdiGetStockObject(BLACK_BRUSH));
|
2009-07-10 23:44:05 +00:00
|
|
|
|
EBRUSHOBJ_vInit(&NewDC->eboText, pbrush, NewDC);
|
2009-04-01 01:49:18 +00:00
|
|
|
|
pdcattr->ulDirty_ |= DIRTY_TEXT;
|
|
|
|
|
|
|
|
|
|
/* Create the default background brush */
|
|
|
|
|
pbrush = BRUSH_ShareLockBrush(NtGdiGetStockObject(WHITE_BRUSH));
|
2009-07-10 23:44:05 +00:00
|
|
|
|
EBRUSHOBJ_vInit(&NewDC->eboBackground, pbrush, NewDC);
|
2009-03-23 03:43:11 +00:00
|
|
|
|
|
2009-03-24 03:15:18 +00:00
|
|
|
|
pdcattr->hlfntNew = NtGdiGetStockObject(SYSTEM_FONT);
|
|
|
|
|
TextIntRealizeFont(pdcattr->hlfntNew,NULL);
|
2009-03-23 03:43:11 +00:00
|
|
|
|
|
2009-03-24 03:15:18 +00:00
|
|
|
|
NewDC->dclevel.hpal = NtGdiGetStockObject(DEFAULT_PALETTE);
|
2009-07-15 21:06:40 +00:00
|
|
|
|
NewDC->dclevel.ppal = PALETTE_ShareLockPalette(NewDC->dclevel.hpal);
|
|
|
|
|
/* This should never fail */
|
|
|
|
|
ASSERT(NewDC->dclevel.ppal);
|
|
|
|
|
|
|
|
|
|
NewDC->dclevel.laPath.eMiterLimit = 10.0; // FIXME: use FLOATL or FLOATOBJ!
|
2009-03-23 03:43:11 +00:00
|
|
|
|
|
2009-03-25 04:20:59 +00:00
|
|
|
|
NewDC->dclevel.lSaveDepth = 1;
|
|
|
|
|
|
2009-08-04 20:37:10 +00:00
|
|
|
|
hsurf = (HBITMAP)PrimarySurface.pSurface; // <- what kind of haxx0ry is that?
|
|
|
|
|
NewDC->dclevel.pSurface = SURFACE_ShareLockSurface(hsurf);
|
|
|
|
|
|
2009-03-24 04:10:49 +00:00
|
|
|
|
return NewDC;
|
2009-03-23 03:43:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BOOL INTERNAL_CALL
|
|
|
|
|
DC_Cleanup(PVOID ObjectBody)
|
|
|
|
|
{
|
2009-03-24 03:15:18 +00:00
|
|
|
|
PDC pDC = (PDC)ObjectBody;
|
2009-03-26 00:56:46 +00:00
|
|
|
|
|
|
|
|
|
/* Free driver name (HACK) */
|
2009-03-24 03:15:18 +00:00
|
|
|
|
if (pDC->rosdc.DriverName.Buffer)
|
|
|
|
|
ExFreePoolWithTag(pDC->rosdc.DriverName.Buffer, TAG_DC);
|
2009-03-26 00:56:46 +00:00
|
|
|
|
|
2009-07-15 21:06:40 +00:00
|
|
|
|
/* Deselect dc objects */
|
2009-03-24 03:15:18 +00:00
|
|
|
|
DC_vSelectSurface(pDC, NULL);
|
2009-03-26 00:56:46 +00:00
|
|
|
|
DC_vSelectFillBrush(pDC, NULL);
|
|
|
|
|
DC_vSelectLineBrush(pDC, NULL);
|
2009-07-15 21:06:40 +00:00
|
|
|
|
DC_vSelectPalette(pDC, NULL);
|
2009-03-26 00:56:46 +00:00
|
|
|
|
|
2009-04-01 01:49:18 +00:00
|
|
|
|
/* Dereference default brushes */
|
|
|
|
|
BRUSH_ShareUnlockBrush(pDC->eboText.pbrush);
|
|
|
|
|
BRUSH_ShareUnlockBrush(pDC->eboBackground.pbrush);
|
|
|
|
|
|
2009-07-10 23:44:05 +00:00
|
|
|
|
/* Cleanup the dc brushes */
|
|
|
|
|
EBRUSHOBJ_vCleanup(&pDC->eboFill);
|
|
|
|
|
EBRUSHOBJ_vCleanup(&pDC->eboLine);
|
|
|
|
|
EBRUSHOBJ_vCleanup(&pDC->eboText);
|
|
|
|
|
EBRUSHOBJ_vCleanup(&pDC->eboBackground);
|
|
|
|
|
|
2009-03-24 03:15:18 +00:00
|
|
|
|
return TRUE;
|
2009-03-23 03:43:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BOOL
|
|
|
|
|
FASTCALL
|
|
|
|
|
DC_SetOwnership(HDC hDC, PEPROCESS Owner)
|
|
|
|
|
{
|
2010-01-21 00:14:06 +00:00
|
|
|
|
INT Index;
|
|
|
|
|
PGDI_TABLE_ENTRY Entry;
|
2009-03-23 03:43:11 +00:00
|
|
|
|
PDC pDC;
|
|
|
|
|
|
2009-03-24 03:15:18 +00:00
|
|
|
|
if (!GDIOBJ_SetOwnership(hDC, Owner)) return FALSE;
|
2009-03-23 03:43:11 +00:00
|
|
|
|
pDC = DC_LockDc(hDC);
|
|
|
|
|
if (pDC)
|
|
|
|
|
{
|
2010-01-21 00:14:06 +00:00
|
|
|
|
/*
|
|
|
|
|
System Regions:
|
|
|
|
|
These regions do not use attribute sections and when allocated, use
|
|
|
|
|
gdiobj level functions.
|
|
|
|
|
*/
|
2009-03-23 03:43:11 +00:00
|
|
|
|
if (pDC->rosdc.hClipRgn)
|
2010-01-21 00:14:06 +00:00
|
|
|
|
{ // FIXME! HAX!!!
|
|
|
|
|
Index = GDI_HANDLE_GET_INDEX(pDC->rosdc.hClipRgn);
|
|
|
|
|
Entry = &GdiHandleTable->Entries[Index];
|
|
|
|
|
if (Entry->UserData) FreeObjectAttr(Entry->UserData);
|
|
|
|
|
Entry->UserData = NULL;
|
|
|
|
|
//
|
2009-03-24 03:15:18 +00:00
|
|
|
|
if (!GDIOBJ_SetOwnership(pDC->rosdc.hClipRgn, Owner)) return FALSE;
|
2009-03-23 03:43:11 +00:00
|
|
|
|
}
|
|
|
|
|
if (pDC->rosdc.hVisRgn)
|
2010-01-21 00:14:06 +00:00
|
|
|
|
{ // FIXME! HAX!!!
|
|
|
|
|
Index = GDI_HANDLE_GET_INDEX(pDC->rosdc.hVisRgn);
|
|
|
|
|
Entry = &GdiHandleTable->Entries[Index];
|
|
|
|
|
if (Entry->UserData) FreeObjectAttr(Entry->UserData);
|
|
|
|
|
Entry->UserData = NULL;
|
|
|
|
|
//
|
2009-03-24 03:15:18 +00:00
|
|
|
|
if (!GDIOBJ_SetOwnership(pDC->rosdc.hVisRgn, Owner)) return FALSE;
|
2009-03-23 03:43:11 +00:00
|
|
|
|
}
|
|
|
|
|
if (pDC->rosdc.hGCClipRgn)
|
2010-01-21 00:14:06 +00:00
|
|
|
|
{ // FIXME! HAX!!!
|
|
|
|
|
Index = GDI_HANDLE_GET_INDEX(pDC->rosdc.hGCClipRgn);
|
|
|
|
|
Entry = &GdiHandleTable->Entries[Index];
|
|
|
|
|
if (Entry->UserData) FreeObjectAttr(Entry->UserData);
|
|
|
|
|
Entry->UserData = NULL;
|
|
|
|
|
//
|
2009-03-24 03:15:18 +00:00
|
|
|
|
if (!GDIOBJ_SetOwnership(pDC->rosdc.hGCClipRgn, Owner)) return FALSE;
|
2009-03-23 03:43:11 +00:00
|
|
|
|
}
|
|
|
|
|
if (pDC->dclevel.hPath)
|
|
|
|
|
{
|
2009-03-24 03:15:18 +00:00
|
|
|
|
if (!GDIOBJ_SetOwnership(pDC->dclevel.hPath, Owner)) return FALSE;
|
2009-03-23 03:43:11 +00:00
|
|
|
|
}
|
|
|
|
|
DC_UnlockDc(pDC);
|
|
|
|
|
}
|
2009-03-24 04:10:49 +00:00
|
|
|
|
|
2009-03-23 03:43:11 +00:00
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
HDC FASTCALL
|
2009-03-24 03:15:18 +00:00
|
|
|
|
IntGdiCreateDC(
|
|
|
|
|
PUNICODE_STRING Driver,
|
|
|
|
|
PUNICODE_STRING Device,
|
|
|
|
|
PVOID pUMdhpdev,
|
|
|
|
|
CONST PDEVMODEW InitData,
|
|
|
|
|
BOOL CreateAsIC)
|
2009-03-23 03:43:11 +00:00
|
|
|
|
{
|
2009-03-24 03:15:18 +00:00
|
|
|
|
HDC hdc;
|
|
|
|
|
PDC pdc;
|
|
|
|
|
PDC_ATTR pdcattr;
|
|
|
|
|
HRGN hVisRgn;
|
|
|
|
|
UNICODE_STRING StdDriver;
|
|
|
|
|
BOOL calledFromUser;
|
2009-03-23 03:43:11 +00:00
|
|
|
|
|
2009-03-24 03:15:18 +00:00
|
|
|
|
RtlInitUnicodeString(&StdDriver, L"DISPLAY");
|
2009-03-23 03:43:11 +00:00
|
|
|
|
|
2009-03-24 03:15:18 +00:00
|
|
|
|
DPRINT("DriverName: %wZ, DeviceName: %wZ\n", Driver, Device);
|
2009-03-23 03:43:11 +00:00
|
|
|
|
|
2009-03-24 03:15:18 +00:00
|
|
|
|
if (NULL == Driver || 0 == RtlCompareUnicodeString(Driver, &StdDriver, TRUE))
|
2009-03-23 03:43:11 +00:00
|
|
|
|
{
|
2009-03-24 03:15:18 +00:00
|
|
|
|
if (CreateAsIC)
|
2009-03-23 03:43:11 +00:00
|
|
|
|
{
|
2009-03-24 03:15:18 +00:00
|
|
|
|
if (! IntPrepareDriverIfNeeded())
|
2009-03-23 03:43:11 +00:00
|
|
|
|
{
|
2009-03-24 03:15:18 +00:00
|
|
|
|
/* Here, we have two possibilities:
|
|
|
|
|
* a) return NULL, and hope that the caller
|
|
|
|
|
* won't call us in a loop
|
|
|
|
|
* b) bugcheck, but caller is unable to
|
|
|
|
|
* react on the problem
|
|
|
|
|
*/
|
|
|
|
|
/*DPRINT1("Unable to prepare graphics driver, returning NULL ic\n");
|
|
|
|
|
return NULL;*/
|
|
|
|
|
KeBugCheck(VIDEO_DRIVER_INIT_FAILURE);
|
2009-03-23 03:43:11 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2009-03-24 03:15:18 +00:00
|
|
|
|
else
|
2009-03-23 03:43:11 +00:00
|
|
|
|
{
|
2009-03-24 03:15:18 +00:00
|
|
|
|
calledFromUser = UserIsEntered();
|
|
|
|
|
if (!calledFromUser)
|
|
|
|
|
{
|
|
|
|
|
UserEnterExclusive();
|
2009-03-23 03:43:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
2009-03-24 03:15:18 +00:00
|
|
|
|
if (! co_IntGraphicsCheck(TRUE))
|
|
|
|
|
{
|
|
|
|
|
if (!calledFromUser)
|
|
|
|
|
{
|
|
|
|
|
UserLeave();
|
|
|
|
|
}
|
|
|
|
|
DPRINT1("Unable to initialize graphics, returning NULL dc\n");
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!calledFromUser)
|
|
|
|
|
{
|
|
|
|
|
UserLeave();
|
|
|
|
|
}
|
2009-03-23 03:43:11 +00:00
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2009-03-24 03:15:18 +00:00
|
|
|
|
/* Check for existing DC object */
|
|
|
|
|
if ((hdc = DC_FindOpenDC(Driver)) != NULL)
|
|
|
|
|
{
|
|
|
|
|
hdc = NtGdiCreateCompatibleDC(hdc);
|
|
|
|
|
if (!hdc)
|
|
|
|
|
DPRINT1("NtGdiCreateCompatibleDC() failed\n");
|
|
|
|
|
return hdc;
|
|
|
|
|
}
|
2009-03-23 03:43:11 +00:00
|
|
|
|
|
2009-03-24 03:15:18 +00:00
|
|
|
|
/* Allocate a DC object */
|
2009-03-24 04:10:49 +00:00
|
|
|
|
pdc = DC_AllocDC(Driver);
|
|
|
|
|
if (pdc == NULL)
|
2009-03-24 03:15:18 +00:00
|
|
|
|
{
|
|
|
|
|
DPRINT1("DC_AllocDC() failed\n");
|
|
|
|
|
return NULL;
|
2009-03-23 03:43:11 +00:00
|
|
|
|
}
|
2009-03-24 04:10:49 +00:00
|
|
|
|
hdc = pdc->BaseObject.hHmgr;
|
2009-03-24 03:15:18 +00:00
|
|
|
|
pdcattr = pdc->pdcattr;
|
|
|
|
|
|
|
|
|
|
pdc->dctype = DC_TYPE_DIRECT;
|
|
|
|
|
|
2009-08-16 12:57:41 +00:00
|
|
|
|
pdc->dhpdev = PrimarySurface.dhpdev;
|
2009-03-24 03:15:18 +00:00
|
|
|
|
if (pUMdhpdev) pUMdhpdev = pdc->dhpdev; // set DHPDEV for device.
|
|
|
|
|
pdc->ppdev = (PVOID)&PrimarySurface;
|
2009-04-14 20:50:02 +00:00
|
|
|
|
|
2009-03-24 03:15:18 +00:00
|
|
|
|
// ATM we only have one display.
|
|
|
|
|
pdcattr->ulDirty_ |= DC_PRIMARY_DISPLAY;
|
|
|
|
|
|
2009-08-16 12:57:41 +00:00
|
|
|
|
pdc->rosdc.bitsPerPixel = pdc->ppdev->gdiinfo.cBitsPixel *
|
|
|
|
|
pdc->ppdev->gdiinfo.cPlanes;
|
2009-03-24 03:15:18 +00:00
|
|
|
|
DPRINT("Bits per pel: %u\n", pdc->rosdc.bitsPerPixel);
|
|
|
|
|
|
2009-08-16 12:57:41 +00:00
|
|
|
|
pdc->flGraphicsCaps = PrimarySurface.devinfo.flGraphicsCaps;
|
|
|
|
|
pdc->flGraphicsCaps2 = PrimarySurface.devinfo.flGraphicsCaps2;
|
2009-03-24 03:15:18 +00:00
|
|
|
|
|
|
|
|
|
pdc->dclevel.hpal = NtGdiGetStockObject(DEFAULT_PALETTE);
|
|
|
|
|
|
|
|
|
|
pdcattr->jROP2 = R2_COPYPEN;
|
|
|
|
|
|
|
|
|
|
pdc->erclWindow.top = pdc->erclWindow.left = 0;
|
2009-08-16 12:57:41 +00:00
|
|
|
|
pdc->erclWindow.right = pdc->ppdev->gdiinfo.ulHorzRes;
|
|
|
|
|
pdc->erclWindow.bottom = pdc->ppdev->gdiinfo.ulVertRes;
|
2009-03-24 03:15:18 +00:00
|
|
|
|
pdc->dclevel.flPath &= ~DCPATH_CLOCKWISE; // Default is CCW.
|
|
|
|
|
|
|
|
|
|
pdcattr->iCS_CP = ftGdiGetTextCharsetInfo(pdc,NULL,0);
|
|
|
|
|
|
2010-01-21 13:18:33 +00:00
|
|
|
|
hVisRgn = IntSysCreateRectRgn(0, 0, pdc->ppdev->gdiinfo.ulHorzRes,
|
2009-08-16 12:57:41 +00:00
|
|
|
|
pdc->ppdev->gdiinfo.ulVertRes);
|
2009-03-24 03:15:18 +00:00
|
|
|
|
|
|
|
|
|
if (!CreateAsIC)
|
2009-03-23 03:43:11 +00:00
|
|
|
|
{
|
2009-03-24 03:15:18 +00:00
|
|
|
|
pdc->pSurfInfo = NULL;
|
|
|
|
|
// pdc->dclevel.pSurface =
|
2009-03-24 04:10:49 +00:00
|
|
|
|
DC_UnlockDc(pdc);
|
2009-03-24 03:15:18 +00:00
|
|
|
|
|
|
|
|
|
/* Initialize the DC state */
|
|
|
|
|
IntGdiSetTextColor(hdc, RGB(0, 0, 0));
|
|
|
|
|
IntGdiSetBkColor(hdc, RGB(255, 255, 255));
|
2009-03-23 03:43:11 +00:00
|
|
|
|
}
|
2009-03-24 03:15:18 +00:00
|
|
|
|
else
|
2009-03-23 03:43:11 +00:00
|
|
|
|
{
|
2009-03-24 03:15:18 +00:00
|
|
|
|
/* From MSDN2:
|
|
|
|
|
The CreateIC function creates an information context for the specified device.
|
|
|
|
|
The information context provides a fast way to get information about the
|
|
|
|
|
device without creating a device context (DC). However, GDI drawing functions
|
|
|
|
|
cannot accept a handle to an information context.
|
|
|
|
|
*/
|
|
|
|
|
pdc->dctype = DC_TYPE_INFO;
|
|
|
|
|
// pdc->pSurfInfo =
|
2009-08-04 20:37:10 +00:00
|
|
|
|
// DC_vSelectSurface(pdc, NULL);
|
2009-03-24 03:15:18 +00:00
|
|
|
|
pdcattr->crBackgroundClr = pdcattr->ulBackgroundClr = RGB(255, 255, 255);
|
|
|
|
|
pdcattr->crForegroundClr = RGB(0, 0, 0);
|
2009-03-24 04:10:49 +00:00
|
|
|
|
DC_UnlockDc(pdc);
|
2009-03-23 03:43:11 +00:00
|
|
|
|
}
|
2009-12-20 17:18:36 +00:00
|
|
|
|
DC_InitDC(hdc);
|
2009-03-23 03:43:11 +00:00
|
|
|
|
|
2009-03-24 03:15:18 +00:00
|
|
|
|
if (hVisRgn)
|
2009-03-23 03:43:11 +00:00
|
|
|
|
{
|
2009-03-24 03:15:18 +00:00
|
|
|
|
GdiSelectVisRgn(hdc, hVisRgn);
|
2010-01-21 13:18:33 +00:00
|
|
|
|
REGION_FreeRgnByHandle(hVisRgn);
|
2009-03-24 03:15:18 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
IntGdiSetTextAlign(hdc, TA_TOP);
|
|
|
|
|
IntGdiSetBkMode(hdc, OPAQUE);
|
|
|
|
|
|
|
|
|
|
return hdc;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
HDC APIENTRY
|
|
|
|
|
NtGdiOpenDCW(
|
|
|
|
|
PUNICODE_STRING Device,
|
|
|
|
|
DEVMODEW *InitData,
|
|
|
|
|
PUNICODE_STRING pustrLogAddr,
|
|
|
|
|
ULONG iType,
|
2009-07-06 16:22:11 +00:00
|
|
|
|
BOOL bDisplay,
|
2009-03-24 03:15:18 +00:00
|
|
|
|
HANDLE hspool,
|
|
|
|
|
VOID *pDriverInfo2,
|
2009-03-24 04:10:49 +00:00
|
|
|
|
VOID *pUMdhpdev)
|
2009-03-24 03:15:18 +00:00
|
|
|
|
{
|
|
|
|
|
UNICODE_STRING SafeDevice;
|
|
|
|
|
DEVMODEW SafeInitData;
|
|
|
|
|
PVOID Dhpdev;
|
|
|
|
|
HDC Ret;
|
|
|
|
|
NTSTATUS Status = STATUS_SUCCESS;
|
|
|
|
|
|
2009-07-15 05:33:21 +00:00
|
|
|
|
if (!Device) return UserGetDesktopDC(iType,FALSE,TRUE);
|
|
|
|
|
|
2009-03-24 03:15:18 +00:00
|
|
|
|
if (InitData)
|
|
|
|
|
{
|
|
|
|
|
_SEH2_TRY
|
|
|
|
|
{
|
|
|
|
|
if (pUMdhpdev)
|
|
|
|
|
{
|
|
|
|
|
ProbeForWrite(pUMdhpdev, sizeof(PVOID), 1);
|
|
|
|
|
}
|
|
|
|
|
ProbeForRead(InitData, sizeof(DEVMODEW), 1);
|
|
|
|
|
RtlCopyMemory(&SafeInitData, InitData, sizeof(DEVMODEW));
|
|
|
|
|
}
|
|
|
|
|
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
|
|
|
|
|
{
|
|
|
|
|
Status = _SEH2_GetExceptionCode();
|
|
|
|
|
}
|
|
|
|
|
_SEH2_END;
|
|
|
|
|
|
|
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
|
{
|
|
|
|
|
SetLastNtError(Status);
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
/* FIXME - InitData can have some more bytes! */
|
2009-03-23 03:43:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
2009-03-24 03:15:18 +00:00
|
|
|
|
if (Device)
|
|
|
|
|
{
|
|
|
|
|
Status = IntSafeCopyUnicodeString(&SafeDevice, Device);
|
|
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
|
{
|
|
|
|
|
SetLastNtError(Status);
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
}
|
2009-03-23 03:43:11 +00:00
|
|
|
|
|
2009-03-24 03:15:18 +00:00
|
|
|
|
Ret = IntGdiCreateDC(Device ? &SafeDevice : NULL,
|
|
|
|
|
NULL,
|
|
|
|
|
pUMdhpdev ? &Dhpdev : NULL,
|
|
|
|
|
InitData ? &SafeInitData : NULL,
|
|
|
|
|
(BOOL) iType); // FALSE 0 DCW, TRUE 1 ICW
|
2009-03-23 03:43:11 +00:00
|
|
|
|
|
2009-03-24 03:15:18 +00:00
|
|
|
|
// FIXME!!!!
|
|
|
|
|
if (pUMdhpdev) pUMdhpdev = Dhpdev;
|
2009-03-23 03:43:11 +00:00
|
|
|
|
|
2009-03-24 03:15:18 +00:00
|
|
|
|
return Ret;
|
2009-03-23 03:43:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
HDC FASTCALL
|
|
|
|
|
IntGdiCreateDisplayDC(HDEV hDev, ULONG DcType, BOOL EmptyDC)
|
|
|
|
|
{
|
2009-03-24 03:15:18 +00:00
|
|
|
|
HDC hDC;
|
|
|
|
|
UNICODE_STRING DriverName;
|
|
|
|
|
RtlInitUnicodeString(&DriverName, L"DISPLAY");
|
|
|
|
|
|
|
|
|
|
if (DcType != DC_TYPE_MEMORY)
|
|
|
|
|
hDC = IntGdiCreateDC(&DriverName, NULL, NULL, NULL, (DcType == DC_TYPE_INFO));
|
|
|
|
|
else
|
|
|
|
|
hDC = NtGdiCreateCompatibleDC(NULL); // OH~ Yuck! I think I taste vomit in my mouth!
|
2009-03-23 03:43:11 +00:00
|
|
|
|
//
|
|
|
|
|
// There is room to grow here~
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// If NULL, first time through! Build the default (was window) dc!
|
2009-07-02 19:09:32 +00:00
|
|
|
|
// Setup clean DC state for the system.
|
2009-03-23 03:43:11 +00:00
|
|
|
|
//
|
2009-03-24 03:15:18 +00:00
|
|
|
|
if (hDC && !defaultDCstate) // Ultra HAX! Dedicated to GvG!
|
|
|
|
|
{ // This is a cheesy way to do this.
|
2009-03-24 04:10:49 +00:00
|
|
|
|
PDC dc = DC_LockDc(hDC);
|
2009-08-04 20:37:10 +00:00
|
|
|
|
HSURF hsurf;
|
2009-03-24 03:15:18 +00:00
|
|
|
|
defaultDCstate = ExAllocatePoolWithTag(PagedPool, sizeof(DC), TAG_DC);
|
|
|
|
|
if (!defaultDCstate)
|
|
|
|
|
{
|
2009-03-24 04:10:49 +00:00
|
|
|
|
DC_UnlockDc(dc);
|
2009-03-24 03:15:18 +00:00
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
RtlZeroMemory(defaultDCstate, sizeof(DC));
|
|
|
|
|
defaultDCstate->pdcattr = &defaultDCstate->dcattr;
|
2009-08-04 20:37:10 +00:00
|
|
|
|
hsurf = (HSURF)PrimarySurface.pSurface; // HAX<41>
|
|
|
|
|
defaultDCstate->dclevel.pSurface = SURFACE_ShareLockSurface(hsurf);
|
2010-01-25 01:33:01 +00:00
|
|
|
|
DC_vCopyState(dc, defaultDCstate, TRUE);
|
2009-03-24 04:10:49 +00:00
|
|
|
|
DC_UnlockDc(dc);
|
2009-03-24 03:15:18 +00:00
|
|
|
|
}
|
|
|
|
|
return hDC;
|
2009-03-23 03:43:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BOOL
|
|
|
|
|
FASTCALL
|
|
|
|
|
IntGdiDeleteDC(HDC hDC, BOOL Force)
|
|
|
|
|
{
|
2009-03-24 04:10:49 +00:00
|
|
|
|
PDC DCToDelete = DC_LockDc(hDC);
|
2009-03-23 03:43:11 +00:00
|
|
|
|
|
2009-03-24 03:15:18 +00:00
|
|
|
|
if (DCToDelete == NULL)
|
2009-03-23 03:43:11 +00:00
|
|
|
|
{
|
2009-03-24 03:15:18 +00:00
|
|
|
|
SetLastWin32Error(ERROR_INVALID_HANDLE);
|
|
|
|
|
return FALSE;
|
2009-03-23 03:43:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
2009-03-24 03:15:18 +00:00
|
|
|
|
if (!Force)
|
2009-03-23 03:43:11 +00:00
|
|
|
|
{
|
2009-03-24 03:15:18 +00:00
|
|
|
|
if (DCToDelete->fs & DC_FLAG_PERMANENT)
|
|
|
|
|
{
|
|
|
|
|
DPRINT1("No! You Naughty Application!\n");
|
2009-03-24 04:10:49 +00:00
|
|
|
|
DC_UnlockDc(DCToDelete);
|
2009-03-24 03:15:18 +00:00
|
|
|
|
return UserReleaseDC(NULL, hDC, FALSE);
|
|
|
|
|
}
|
2009-03-23 03:43:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
2009-03-24 03:15:18 +00:00
|
|
|
|
/* First delete all saved DCs */
|
2009-03-25 04:20:59 +00:00
|
|
|
|
while (DCToDelete->dclevel.lSaveDepth > 1)
|
2009-03-24 03:15:18 +00:00
|
|
|
|
{
|
|
|
|
|
PDC savedDC;
|
|
|
|
|
HDC savedHDC;
|
|
|
|
|
|
2009-03-24 04:10:49 +00:00
|
|
|
|
savedHDC = DCToDelete->hdcNext;
|
|
|
|
|
savedDC = DC_LockDc(savedHDC);
|
2009-03-24 03:15:18 +00:00
|
|
|
|
if (savedDC == NULL)
|
|
|
|
|
{
|
|
|
|
|
break;
|
|
|
|
|
}
|
2009-03-24 04:10:49 +00:00
|
|
|
|
DCToDelete->hdcNext = savedDC->hdcNext;
|
2009-03-24 03:15:18 +00:00
|
|
|
|
DCToDelete->dclevel.lSaveDepth--;
|
2009-03-24 04:10:49 +00:00
|
|
|
|
DC_UnlockDc(savedDC);
|
2009-03-24 03:15:18 +00:00
|
|
|
|
IntGdiDeleteDC(savedHDC, Force);
|
|
|
|
|
}
|
2009-03-23 03:43:11 +00:00
|
|
|
|
|
2009-03-24 03:15:18 +00:00
|
|
|
|
/* Free GDI resources allocated to this DC */
|
|
|
|
|
if (!(DCToDelete->dclevel.flPath & DCPATH_SAVESTATE))
|
2009-03-23 03:43:11 +00:00
|
|
|
|
{
|
2009-03-24 03:15:18 +00:00
|
|
|
|
/*
|
|
|
|
|
NtGdiSelectPen (DCHandle, STOCK_BLACK_PEN);
|
|
|
|
|
NtGdiSelectBrush (DCHandle, STOCK_WHITE_BRUSH);
|
|
|
|
|
NtGdiSelectFont (DCHandle, STOCK_SYSTEM_FONT);
|
|
|
|
|
DC_LockDC (DCHandle); NtGdiSelectXxx does not recognize stock objects yet */
|
2009-03-23 03:43:11 +00:00
|
|
|
|
}
|
2009-03-24 03:15:18 +00:00
|
|
|
|
if (DCToDelete->rosdc.hClipRgn)
|
|
|
|
|
{
|
2009-03-25 20:24:34 +00:00
|
|
|
|
GreDeleteObject(DCToDelete->rosdc.hClipRgn);
|
2009-03-24 03:15:18 +00:00
|
|
|
|
}
|
|
|
|
|
if (DCToDelete->rosdc.hVisRgn)
|
|
|
|
|
{
|
2009-03-25 20:24:34 +00:00
|
|
|
|
GreDeleteObject(DCToDelete->rosdc.hVisRgn);
|
2009-03-24 03:15:18 +00:00
|
|
|
|
}
|
|
|
|
|
if (NULL != DCToDelete->rosdc.CombinedClip)
|
|
|
|
|
{
|
|
|
|
|
IntEngDeleteClipRegion(DCToDelete->rosdc.CombinedClip);
|
|
|
|
|
}
|
|
|
|
|
if (DCToDelete->rosdc.hGCClipRgn)
|
|
|
|
|
{
|
2009-03-25 20:24:34 +00:00
|
|
|
|
GreDeleteObject(DCToDelete->rosdc.hGCClipRgn);
|
2009-03-24 03:15:18 +00:00
|
|
|
|
}
|
2010-01-25 01:33:01 +00:00
|
|
|
|
if (DCToDelete->dclevel.prgnMeta)
|
|
|
|
|
{
|
|
|
|
|
GreDeleteObject(((PROSRGNDATA)DCToDelete->dclevel.prgnMeta)->BaseObject.hHmgr);
|
|
|
|
|
}
|
|
|
|
|
if (DCToDelete->prgnAPI)
|
|
|
|
|
{
|
|
|
|
|
GreDeleteObject(((PROSRGNDATA)DCToDelete->prgnAPI)->BaseObject.hHmgr);
|
|
|
|
|
}
|
2009-03-24 03:15:18 +00:00
|
|
|
|
PATH_Delete(DCToDelete->dclevel.hPath);
|
|
|
|
|
|
2009-03-24 04:10:49 +00:00
|
|
|
|
DC_UnlockDc(DCToDelete);
|
2009-12-29 21:07:04 +00:00
|
|
|
|
GreDeleteObject(hDC);
|
2009-03-24 03:15:18 +00:00
|
|
|
|
return TRUE;
|
2009-03-23 03:43:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
HDC FASTCALL
|
|
|
|
|
DC_FindOpenDC(PUNICODE_STRING Driver)
|
|
|
|
|
{
|
2009-03-24 03:15:18 +00:00
|
|
|
|
return NULL;
|
2009-03-23 03:43:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
|
* Initialize some common fields in the Device Context structure.
|
|
|
|
|
*/
|
|
|
|
|
VOID FASTCALL
|
|
|
|
|
DC_InitDC(HDC DCHandle)
|
|
|
|
|
{
|
|
|
|
|
// NtGdiRealizeDefaultPalette(DCHandle);
|
|
|
|
|
|
|
|
|
|
//// Removed for now.. See above brush and pen.
|
|
|
|
|
// NtGdiSelectBrush(DCHandle, NtGdiGetStockObject( WHITE_BRUSH ));
|
|
|
|
|
// NtGdiSelectPen(DCHandle, NtGdiGetStockObject( BLACK_PEN ));
|
|
|
|
|
////
|
2009-03-24 03:15:18 +00:00
|
|
|
|
//NtGdiSelectFont(DCHandle, hFont);
|
2009-03-23 03:43:11 +00:00
|
|
|
|
|
2009-03-24 03:15:18 +00:00
|
|
|
|
/*
|
|
|
|
|
{
|
|
|
|
|
int res;
|
|
|
|
|
res = CLIPPING_UpdateGCRegion(DCToInit);
|
|
|
|
|
ASSERT ( res != ERROR );
|
|
|
|
|
}
|
|
|
|
|
*/
|
2009-12-20 13:55:45 +00:00
|
|
|
|
|
|
|
|
|
/* Set virtual resolution */
|
|
|
|
|
NtGdiSetVirtualResolution(DCHandle, 0, 0, 0, 0);
|
2009-03-23 03:43:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
2009-03-24 03:15:18 +00:00
|
|
|
|
/*
|
|
|
|
|
* @unimplemented
|
|
|
|
|
*/
|
2009-03-23 03:43:11 +00:00
|
|
|
|
BOOL
|
|
|
|
|
APIENTRY
|
|
|
|
|
NtGdiMakeInfoDC(
|
|
|
|
|
IN HDC hdc,
|
|
|
|
|
IN BOOL bSet)
|
|
|
|
|
{
|
|
|
|
|
UNIMPLEMENTED;
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
HDC APIENTRY
|
|
|
|
|
NtGdiCreateCompatibleDC(HDC hDC)
|
|
|
|
|
{
|
2009-03-24 04:10:49 +00:00
|
|
|
|
PDC pdcNew, pdcOld;
|
2009-03-24 03:15:18 +00:00
|
|
|
|
PDC_ATTR pdcattrNew, pdcattrOld;
|
2009-03-24 04:10:49 +00:00
|
|
|
|
HDC hdcNew, DisplayDC = NULL;
|
2009-03-24 03:15:18 +00:00
|
|
|
|
HRGN hVisRgn;
|
|
|
|
|
UNICODE_STRING DriverName;
|
|
|
|
|
DWORD Layout = 0;
|
2009-04-14 20:50:02 +00:00
|
|
|
|
HSURF hsurf;
|
2009-03-24 03:15:18 +00:00
|
|
|
|
|
|
|
|
|
if (hDC == NULL)
|
2009-03-23 03:43:11 +00:00
|
|
|
|
{
|
2009-03-24 03:15:18 +00:00
|
|
|
|
RtlInitUnicodeString(&DriverName, L"DISPLAY");
|
|
|
|
|
DisplayDC = IntGdiCreateDC(&DriverName, NULL, NULL, NULL, TRUE);
|
|
|
|
|
if (NULL == DisplayDC)
|
2009-03-23 03:43:11 +00:00
|
|
|
|
{
|
2009-03-24 03:15:18 +00:00
|
|
|
|
DPRINT1("Failed to create DisplayDC\n");
|
|
|
|
|
return NULL;
|
2009-03-23 03:43:11 +00:00
|
|
|
|
}
|
2009-03-24 03:15:18 +00:00
|
|
|
|
hDC = DisplayDC;
|
2009-03-23 03:43:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
2009-03-24 03:15:18 +00:00
|
|
|
|
/* Allocate a new DC based on the original DC's device */
|
2009-03-24 04:10:49 +00:00
|
|
|
|
pdcOld = DC_LockDc(hDC);
|
|
|
|
|
if (NULL == pdcOld)
|
2009-03-23 03:43:11 +00:00
|
|
|
|
{
|
2009-03-24 03:15:18 +00:00
|
|
|
|
if (NULL != DisplayDC)
|
2009-03-23 03:43:11 +00:00
|
|
|
|
{
|
2009-03-24 03:15:18 +00:00
|
|
|
|
NtGdiDeleteObjectApp(DisplayDC);
|
2009-03-23 03:43:11 +00:00
|
|
|
|
}
|
2009-03-24 03:15:18 +00:00
|
|
|
|
DPRINT1("Failed to lock hDC\n");
|
|
|
|
|
return NULL;
|
2009-03-23 03:43:11 +00:00
|
|
|
|
}
|
2009-03-24 04:10:49 +00:00
|
|
|
|
pdcNew = DC_AllocDC(&pdcOld->rosdc.DriverName);
|
|
|
|
|
if (!pdcNew)
|
2009-03-23 03:43:11 +00:00
|
|
|
|
{
|
2009-03-24 04:10:49 +00:00
|
|
|
|
DPRINT1("Failed to create pdcNew\n");
|
|
|
|
|
DC_UnlockDc(pdcOld);
|
|
|
|
|
if (DisplayDC)
|
2009-03-23 03:43:11 +00:00
|
|
|
|
{
|
2009-03-24 03:15:18 +00:00
|
|
|
|
NtGdiDeleteObjectApp(DisplayDC);
|
2009-03-23 03:43:11 +00:00
|
|
|
|
}
|
2009-03-24 03:15:18 +00:00
|
|
|
|
return NULL;
|
2009-03-23 03:43:11 +00:00
|
|
|
|
}
|
2009-03-24 04:10:49 +00:00
|
|
|
|
hdcNew = pdcNew->BaseObject.hHmgr;
|
2009-03-23 03:43:11 +00:00
|
|
|
|
|
2009-03-24 04:10:49 +00:00
|
|
|
|
pdcattrOld = pdcOld->pdcattr;
|
|
|
|
|
pdcattrNew = pdcNew->pdcattr;
|
2009-03-24 03:15:18 +00:00
|
|
|
|
|
|
|
|
|
/* Copy information from original DC to new DC */
|
2009-03-24 04:10:49 +00:00
|
|
|
|
pdcNew->dclevel.hdcSave = hdcNew;
|
2009-03-24 03:15:18 +00:00
|
|
|
|
|
2009-03-24 04:10:49 +00:00
|
|
|
|
pdcNew->dhpdev = pdcOld->dhpdev;
|
2009-03-24 03:15:18 +00:00
|
|
|
|
|
2009-03-24 04:10:49 +00:00
|
|
|
|
pdcNew->rosdc.bitsPerPixel = pdcOld->rosdc.bitsPerPixel;
|
2009-03-24 03:15:18 +00:00
|
|
|
|
|
|
|
|
|
/* DriverName is copied in the AllocDC routine */
|
|
|
|
|
pdcattrNew->ptlWindowOrg = pdcattrOld->ptlWindowOrg;
|
|
|
|
|
pdcattrNew->szlWindowExt = pdcattrOld->szlWindowExt;
|
|
|
|
|
pdcattrNew->ptlViewportOrg = pdcattrOld->ptlViewportOrg;
|
|
|
|
|
pdcattrNew->szlViewportExt = pdcattrOld->szlViewportExt;
|
|
|
|
|
|
2009-03-24 04:10:49 +00:00
|
|
|
|
pdcNew->dctype = DC_TYPE_MEMORY; // Always!
|
2009-04-14 20:50:02 +00:00
|
|
|
|
hsurf = NtGdiGetStockObject(DEFAULT_BITMAP);
|
|
|
|
|
pdcNew->dclevel.pSurface = SURFACE_ShareLockSurface(hsurf);
|
2009-03-24 04:10:49 +00:00
|
|
|
|
pdcNew->ppdev = pdcOld->ppdev;
|
|
|
|
|
pdcNew->dclevel.hpal = pdcOld->dclevel.hpal;
|
2009-03-24 03:15:18 +00:00
|
|
|
|
|
|
|
|
|
pdcattrNew->lTextAlign = pdcattrOld->lTextAlign;
|
|
|
|
|
pdcattrNew->lBkMode = pdcattrOld->lBkMode;
|
|
|
|
|
pdcattrNew->jBkMode = pdcattrOld->jBkMode;
|
|
|
|
|
pdcattrNew->jROP2 = pdcattrOld->jROP2;
|
|
|
|
|
pdcattrNew->dwLayout = pdcattrOld->dwLayout;
|
|
|
|
|
if (pdcattrOld->dwLayout & LAYOUT_ORIENTATIONMASK) Layout = pdcattrOld->dwLayout;
|
2009-03-24 04:10:49 +00:00
|
|
|
|
pdcNew->dclevel.flPath = pdcOld->dclevel.flPath;
|
2009-03-24 03:15:18 +00:00
|
|
|
|
pdcattrNew->ulDirty_ = pdcattrOld->ulDirty_;
|
|
|
|
|
pdcattrNew->iCS_CP = pdcattrOld->iCS_CP;
|
|
|
|
|
|
2009-07-31 18:21:24 +00:00
|
|
|
|
pdcNew->erclWindow.left = pdcNew->erclWindow.top = 0;
|
|
|
|
|
pdcNew->erclWindow.right = pdcNew->erclWindow.bottom = 1;
|
2009-03-24 03:15:18 +00:00
|
|
|
|
|
2009-03-24 04:10:49 +00:00
|
|
|
|
DC_UnlockDc(pdcNew);
|
|
|
|
|
DC_UnlockDc(pdcOld);
|
2009-03-24 03:15:18 +00:00
|
|
|
|
if (NULL != DisplayDC)
|
|
|
|
|
{
|
|
|
|
|
NtGdiDeleteObjectApp(DisplayDC);
|
|
|
|
|
}
|
|
|
|
|
|
2010-01-21 13:18:33 +00:00
|
|
|
|
hVisRgn = IntSysCreateRectRgn(0, 0, 1, 1);
|
2009-03-24 03:15:18 +00:00
|
|
|
|
if (hVisRgn)
|
|
|
|
|
{
|
2009-03-24 04:10:49 +00:00
|
|
|
|
GdiSelectVisRgn(hdcNew, hVisRgn);
|
2010-01-21 13:18:33 +00:00
|
|
|
|
REGION_FreeRgnByHandle(hVisRgn);
|
2009-03-24 03:15:18 +00:00
|
|
|
|
}
|
2009-03-24 04:10:49 +00:00
|
|
|
|
if (Layout) NtGdiSetLayout(hdcNew, -1, Layout);
|
2009-03-24 03:15:18 +00:00
|
|
|
|
|
2009-03-24 04:10:49 +00:00
|
|
|
|
DC_InitDC(hdcNew);
|
|
|
|
|
return hdcNew;
|
2009-03-23 03:43:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
BOOL
|
|
|
|
|
APIENTRY
|
2009-03-24 04:10:49 +00:00
|
|
|
|
NtGdiDeleteObjectApp(HANDLE DCHandle)
|
2009-03-23 03:43:11 +00:00
|
|
|
|
{
|
2009-03-24 03:15:18 +00:00
|
|
|
|
/* Complete all pending operations */
|
|
|
|
|
NtGdiFlushUserBatch();
|
2009-03-23 03:43:11 +00:00
|
|
|
|
|
2009-03-24 03:15:18 +00:00
|
|
|
|
if (GDI_HANDLE_IS_STOCKOBJ(DCHandle)) return TRUE;
|
2009-03-23 03:43:11 +00:00
|
|
|
|
|
2009-03-24 03:15:18 +00:00
|
|
|
|
if (GDI_HANDLE_GET_TYPE(DCHandle) != GDI_OBJECT_TYPE_DC)
|
2009-03-25 20:24:34 +00:00
|
|
|
|
return GreDeleteObject((HGDIOBJ) DCHandle);
|
2009-03-23 03:43:11 +00:00
|
|
|
|
|
2009-03-24 03:15:18 +00:00
|
|
|
|
if (IsObjectDead((HGDIOBJ)DCHandle)) return TRUE;
|
2009-03-23 03:43:11 +00:00
|
|
|
|
|
2009-03-24 03:15:18 +00:00
|
|
|
|
if (!GDIOBJ_OwnedByCurrentProcess(DCHandle))
|
2009-03-23 03:43:11 +00:00
|
|
|
|
{
|
2009-03-24 03:15:18 +00:00
|
|
|
|
SetLastWin32Error(ERROR_INVALID_HANDLE);
|
|
|
|
|
return FALSE;
|
2009-03-23 03:43:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
2009-03-24 03:15:18 +00:00
|
|
|
|
return IntGdiDeleteDC(DCHandle, FALSE);
|
2009-03-23 03:43:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
2009-03-25 01:07:02 +00:00
|
|
|
|
BOOL
|
|
|
|
|
APIENTRY
|
|
|
|
|
NewNtGdiDeleteObjectApp(HANDLE DCHandle)
|
|
|
|
|
{
|
|
|
|
|
GDIOBJTYPE ObjType;
|
|
|
|
|
|
|
|
|
|
if (GDI_HANDLE_IS_STOCKOBJ(DCHandle)) return TRUE;
|
|
|
|
|
|
|
|
|
|
ObjType = GDI_HANDLE_GET_TYPE(DCHandle) >> GDI_ENTRY_UPPER_SHIFT;
|
|
|
|
|
|
|
|
|
|
if (GreGetObjectOwner( DCHandle, ObjType))
|
|
|
|
|
{
|
|
|
|
|
switch(ObjType)
|
|
|
|
|
{
|
|
|
|
|
case GDIObjType_DC_TYPE:
|
|
|
|
|
return IntGdiDeleteDC(DCHandle, FALSE);
|
|
|
|
|
|
|
|
|
|
case GDIObjType_RGN_TYPE:
|
|
|
|
|
case GDIObjType_SURF_TYPE:
|
|
|
|
|
case GDIObjType_PAL_TYPE:
|
|
|
|
|
case GDIObjType_LFONT_TYPE:
|
|
|
|
|
case GDIObjType_BRUSH_TYPE:
|
2009-03-25 20:24:34 +00:00
|
|
|
|
return GreDeleteObject((HGDIOBJ) DCHandle);
|
2009-03-25 01:07:02 +00:00
|
|
|
|
|
|
|
|
|
default:
|
2009-07-08 21:53:35 +00:00
|
|
|
|
return FALSE;
|
2009-03-25 01:07:02 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return (DCHandle != NULL);
|
|
|
|
|
}
|
|
|
|
|
|