Author: tkreuzer
Date: Mon Dec 29 13:12:05 2014
New Revision: 65885
URL:
http://svn.reactos.org/svn/reactos?rev=65885&view=rev
Log:
[WIN32K]
- Implement GreCreateCompatibleDC, allowing to pass in a boolean value, specifying the DC
type (normal or "alternative" DC, aka metafile DC)
- Properly implement NtGdiCreateMetafileDC around GreCreateCompatibleDC
Modified:
trunk/reactos/win32ss/gdi/ntgdi/dc.h
trunk/reactos/win32ss/gdi/ntgdi/dclife.c
trunk/reactos/win32ss/gdi/ntgdi/dcstate.c
trunk/reactos/win32ss/gdi/ntgdi/metafile.c
Modified: trunk/reactos/win32ss/gdi/ntgdi/dc.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/gdi/ntgdi/dc.h?rev…
==============================================================================
--- trunk/reactos/win32ss/gdi/ntgdi/dc.h [iso-8859-1] (original)
+++ trunk/reactos/win32ss/gdi/ntgdi/dc.h [iso-8859-1] Mon Dec 29 13:12:05 2014
@@ -182,7 +182,7 @@
INIT_FUNCTION NTSTATUS NTAPI InitDcImpl(VOID);
PPDEVOBJ FASTCALL IntEnumHDev(VOID);
-PDC NTAPI DC_AllocDcWithHandle(VOID);
+PDC NTAPI DC_AllocDcWithHandle(GDILOOBJTYPE eDcObjType);
BOOL NTAPI DC_bAllocDcAttr(PDC pdc);
VOID NTAPI DC_vCleanup(PVOID ObjectBody);
BOOL FASTCALL IntGdiDeleteDC(HDC, BOOL);
@@ -205,6 +205,7 @@
VOID FASTCALL IntvGetDeviceCaps(PPDEVOBJ, PDEVCAPS);
BOOL NTAPI GreSetDCOwner(HDC hdc, ULONG ulOwner);
+HDC APIENTRY GreCreateCompatibleDC(HDC hdc, BOOL bAltDc);
VOID
NTAPI
@@ -219,7 +220,8 @@
pdc = GDIOBJ_LockObject(hdc, GDIObjType_DC_TYPE);
if (pdc)
{
- ASSERT(GDI_HANDLE_GET_TYPE(pdc->BaseObject.hHmgr) ==
GDILoObjType_LO_DC_TYPE);
+ ASSERT((GDI_HANDLE_GET_TYPE(pdc->BaseObject.hHmgr) == GDILoObjType_LO_DC_TYPE)
||
+ (GDI_HANDLE_GET_TYPE(pdc->BaseObject.hHmgr) ==
GDILoObjType_LO_ALTDC_TYPE));
ASSERT(pdc->dclevel.plfnt != NULL);
ASSERT(GDI_HANDLE_GET_TYPE(((POBJ)pdc->dclevel.plfnt)->hHmgr) ==
GDILoObjType_LO_FONT_TYPE);
}
Modified: trunk/reactos/win32ss/gdi/ntgdi/dclife.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/gdi/ntgdi/dclife.c…
==============================================================================
--- trunk/reactos/win32ss/gdi/ntgdi/dclife.c [iso-8859-1] (original)
+++ trunk/reactos/win32ss/gdi/ntgdi/dclife.c [iso-8859-1] Mon Dec 29 13:12:05 2014
@@ -66,10 +66,14 @@
PDC
NTAPI
-DC_AllocDcWithHandle()
+DC_AllocDcWithHandle(GDILOOBJTYPE eDcObjType)
{
PDC pdc;
+ NT_ASSERT((eDcObjType == GDILoObjType_LO_DC_TYPE) ||
+ (eDcObjType == GDILoObjType_LO_ALTDC_TYPE));
+
+ /* Allocate the object */
pdc = (PDC)GDIOBJ_AllocateObject(GDIObjType_DC_TYPE,
sizeof(DC),
BASEFLAG_LOOKASIDE);
@@ -79,6 +83,10 @@
return NULL;
}
+ /* Set the actual DC type */
+ pdc->BaseObject.hHmgr = UlongToHandle(eDcObjType);
+
+ /* Insert the object */
if (!GDIOBJ_hInsertObject(&pdc->BaseObject, GDI_OBJ_HMGR_POWNED))
{
DPRINT1("Could not insert DC into handle table.\n");
@@ -95,6 +103,15 @@
void
DC_InitHack(PDC pdc)
{
+ if (defaultDCstate == NULL)
+ {
+ defaultDCstate = ExAllocatePoolWithTag(PagedPool, sizeof(DC), TAG_DC);
+ ASSERT(defaultDCstate);
+ RtlZeroMemory(defaultDCstate, sizeof(DC));
+ defaultDCstate->pdcattr = &defaultDCstate->dcattr;
+ DC_vCopyState(pdc, defaultDCstate, TRUE);
+ }
+
TextIntRealizeFont(pdc->pdcattr->hlfntNew,NULL);
pdc->pdcattr->iCS_CP = ftGdiGetTextCharsetInfo(pdc,NULL,0);
@@ -327,15 +344,6 @@
pdc->dcattr.iGraphicsMode = GM_COMPATIBLE;
pdc->dcattr.iCS_CP = 0;
pdc->pSurfInfo = NULL;
-
- if (defaultDCstate == NULL)
- {
- defaultDCstate = ExAllocatePoolWithTag(PagedPool, sizeof(DC), TAG_DC);
- ASSERT(defaultDCstate);
- RtlZeroMemory(defaultDCstate, sizeof(DC));
- defaultDCstate->pdcattr = &defaultDCstate->dcattr;
- DC_vCopyState(pdc, defaultDCstate, TRUE);
- }
}
VOID
@@ -631,7 +639,7 @@
DPRINT("GreOpenDCW - ppdev = %p\n", ppdev);
- pdc = DC_AllocDcWithHandle();
+ pdc = DC_AllocDcWithHandle(GDILoObjType_LO_DC_TYPE);
if (!pdc)
{
DPRINT1("Could not Allocate a DC\n");
@@ -755,8 +763,9 @@
HDC
APIENTRY
-NtGdiCreateCompatibleDC(HDC hdc)
-{
+GreCreateCompatibleDC(HDC hdc, BOOL bAltDc)
+{
+ GDILOOBJTYPE eDcObjType;
HDC hdcNew;
PPDEVOBJ ppdev;
PDC pdc, pdcNew;
@@ -794,7 +803,8 @@
}
/* Allocate a new DC */
- pdcNew = DC_AllocDcWithHandle();
+ eDcObjType = bAltDc ? GDILoObjType_LO_ALTDC_TYPE : GDILoObjType_LO_DC_TYPE;
+ pdcNew = DC_AllocDcWithHandle(eDcObjType);
if (!pdcNew)
{
DPRINT1("Could not allocate a new DC\n");
@@ -804,7 +814,7 @@
hdcNew = pdcNew->BaseObject.hHmgr;
/* Lock ppdev and initialize the new DC */
- DC_vInitDc(pdcNew, DCTYPE_MEMORY, ppdev);
+ DC_vInitDc(pdcNew, bAltDc ? DCTYPE_INFO : DCTYPE_MEMORY, ppdev);
/* FIXME: HACK! */
DC_InitHack(pdcNew);
@@ -816,6 +826,14 @@
DPRINT("Leave NtGdiCreateCompatibleDC hdcNew = %p\n", hdcNew);
return hdcNew;
+}
+
+HDC
+APIENTRY
+NtGdiCreateCompatibleDC(HDC hdc)
+{
+ /* Call the internal function to create a normal memory DC */
+ return GreCreateCompatibleDC(hdc, FALSE);
}
BOOL
Modified: trunk/reactos/win32ss/gdi/ntgdi/dcstate.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/gdi/ntgdi/dcstate.…
==============================================================================
--- trunk/reactos/win32ss/gdi/ntgdi/dcstate.c [iso-8859-1] (original)
+++ trunk/reactos/win32ss/gdi/ntgdi/dcstate.c [iso-8859-1] Mon Dec 29 13:12:05 2014
@@ -262,7 +262,7 @@
}
/* Allocate a new dc */
- pdcSave = DC_AllocDcWithHandle();
+ pdcSave = DC_AllocDcWithHandle(GDILoObjType_LO_DC_TYPE);
if (pdcSave == NULL)
{
DPRINT("Could not allocate a new DC\n");
Modified: trunk/reactos/win32ss/gdi/ntgdi/metafile.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/gdi/ntgdi/metafile…
==============================================================================
--- trunk/reactos/win32ss/gdi/ntgdi/metafile.c [iso-8859-1] (original)
+++ trunk/reactos/win32ss/gdi/ntgdi/metafile.c [iso-8859-1] Mon Dec 29 13:12:05 2014
@@ -34,23 +34,8 @@
APIENTRY
NtGdiCreateMetafileDC(IN HDC hdc)
{
- PDC pDc;
- HDC ret = NULL;
-
- if (hdc)
- {
- pDc = DC_LockDc(hdc);
- if (pDc)
- { // Not sure this is right for getting the HDEV handle, maybe Timo could help or
just if'ed it out.
- ret = IntGdiCreateDisplayDC(pDc->ppdev->BaseObject.hHmgr, DC_TYPE_INFO,
TRUE);
- DC_UnlockDc(pDc);
- }
- }
- else
- {
- ret = UserGetDesktopDC(DC_TYPE_INFO, TRUE, FALSE);
- }
- return ret;
+ /* Call the internal function to create an alternative info DC */
+ return GreCreateCompatibleDC(hdc, TRUE);
}
/*
@@ -68,7 +53,7 @@
UNIMPLEMENTED;
return NULL;
}
-
+
/*
* @unimplemented
*/