[WIN32SS] Introduce the MDEVOBJ structure

This will be used (later) to store the list of all enabled display devices.

Add a global variable gpmdev (should really be stored in DISPLAYINFO structure)
Replace global variable gppdevPrimary by pmdev->ppdevGlobal.
This commit is contained in:
Hervé Poussineau 2022-03-20 15:38:20 +01:00 committed by hpoussin
parent 0f617ddfbb
commit a0cfdcd409
15 changed files with 66 additions and 31 deletions

View file

@ -73,6 +73,7 @@ list(APPEND SOURCE
gdi/eng/ldevobj.c
gdi/eng/mapping.c
gdi/eng/math.c
gdi/eng/mdevobj.c
gdi/eng/mem.c
gdi/eng/engmisc.c
gdi/eng/mouse.c

View file

@ -198,7 +198,7 @@ VideoPortCallout(
if (CallbackParams->Param == TRUE)
{
/* Re-enable the display */
UserRefreshDisplay(gppdevPrimary);
UserRefreshDisplay(gpmdev->ppdevGlobal);
}
else
{

View file

@ -324,7 +324,7 @@ EBRUSHOBJ_bRealizeBrush(EBRUSHOBJ *pebo, BOOL bCallDriver)
ppdev = (PPDEVOBJ)pebo->psurfTrg->SurfObj.hdev;
if (!ppdev)
ppdev = gppdevPrimary;
ppdev = gpmdev->ppdevGlobal;
if (bCallDriver)
{
@ -458,7 +458,7 @@ EBRUSHOBJ_psoMask(EBRUSHOBJ *pebo)
/* Get the PDEV */
ppdev = (PPDEVOBJ)pebo->psurfTrg->SurfObj.hdev;
if (!ppdev)
ppdev = gppdevPrimary;
ppdev = gpmdev->ppdevGlobal;
/* Use the hatch bitmap as the mask */
hbmMask = (HBITMAP)ppdev->ahsurf[pebo->pbrush->iHatch];

13
win32ss/gdi/eng/mdevobj.c Normal file
View file

@ -0,0 +1,13 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
* PURPOSE: Support for meta devices
* FILE: win32ss/gdi/eng/mdevobj.c
* PROGRAMER: Hervé Poussineau
*/
#include <win32k.h>
#define NDEBUG
#include <debug.h>
PMDEVOBJ gpmdev = NULL; /* FIXME: should be stored in gpDispInfo->pmdev */

17
win32ss/gdi/eng/mdevobj.h Normal file
View file

@ -0,0 +1,17 @@
#ifndef __WIN32K_MDEVOBJ_H
#define __WIN32K_MDEVOBJ_H
/* Type definitions ***********************************************************/
typedef struct _PDEVOBJ *PPDEVOBJ;
typedef struct _MDEVOBJ
{
PPDEVOBJ ppdevGlobal;
} MDEVOBJ, *PMDEVOBJ;
/* Globals ********************************************************************/
extern PMDEVOBJ gpmdev; /* FIXME: should be stored in gpDispInfo->pmdev */
#endif /* !__WIN32K_MDEVOBJ_H */

View file

@ -11,8 +11,6 @@
#include <debug.h>
DBG_DEFAULT_CHANNEL(EngPDev);
PPDEVOBJ gppdevPrimary = NULL;
static PPDEVOBJ gppdevList = NULL;
static HSEMAPHORE ghsemPDEV;
@ -150,8 +148,8 @@ PDEVOBJ_vRelease(
}
/* Is this the primary one ? */
if (ppdev == gppdevPrimary)
gppdevPrimary = NULL;
if (ppdev == gpmdev->ppdevGlobal)
gpmdev->ppdevGlobal = NULL;
/* Unload display driver */
EngUnloadImage(ppdev->pldev);
@ -615,7 +613,7 @@ PDEVOBJ_bSwitchMode(
PDEVOBJ_vRelease(ppdevTmp);
/* Update primary display capabilities */
if (ppdev == gppdevPrimary)
if (ppdev == gpmdev->ppdevGlobal)
{
PDEVOBJ_vGetDeviceCaps(ppdev, &GdiHandleTable->DevCaps);
}
@ -669,10 +667,10 @@ EngpGetPDEV(
}
}
}
else
else if (gpmdev)
{
/* Otherwise use the primary PDEV */
ppdev = gppdevPrimary;
ppdev = gpmdev->ppdevGlobal;
}
/* Did we find one? */
@ -695,9 +693,9 @@ EngpGetPDEV(
if (ppdev)
{
/* Set as primary PDEV, if we don't have one yet */
if (!gppdevPrimary)
if (!gpmdev->ppdevGlobal)
{
gppdevPrimary = ppdev;
gpmdev->ppdevGlobal = ppdev;
ppdev->pGraphicsDevice->StateFlags |= DISPLAY_DEVICE_PRIMARY_DEVICE;
}
}

View file

@ -150,11 +150,6 @@ typedef struct _PDEVOBJ
struct _EDD_DIRECTDRAW_GLOBAL * pEDDgpl;
} PDEVOBJ, *PPDEVOBJ;
/* Globals ********************************************************************/
extern PPDEVOBJ gppdevPrimary;
/* Function prototypes ********************************************************/
PPDEVOBJ

View file

@ -144,7 +144,7 @@ DC_vInitDc(
pdc->pdcattr = &pdc->dcattr;
pdc->dcattr.pvLDC = NULL;
pdc->dcattr.ulDirty_ = DIRTY_DEFAULT;
if (ppdev == gppdevPrimary)
if (ppdev == gpmdev->ppdevGlobal)
pdc->dcattr.ulDirty_ |= DC_PRIMARY_DISPLAY;
/* Setup the DC size */

View file

@ -29,13 +29,13 @@ BOOL FASTCALL
IntCreatePrimarySurface(VOID)
{
/* Create surface */
PDEVOBJ_pSurface(gppdevPrimary);
PDEVOBJ_pSurface(gpmdev->ppdevGlobal);
DPRINT("IntCreatePrimarySurface, gppdevPrimary=%p, gppdevPrimary->pSurface = %p\n",
gppdevPrimary, gppdevPrimary->pSurface);
DPRINT("IntCreatePrimarySurface, ppdevGlobal=%p, ppdevGlobal->pSurface = %p\n",
gpmdev->ppdevGlobal, gpmdev->ppdevGlobal->pSurface);
// Init Primary Displays Device Capabilities.
PDEVOBJ_vGetDeviceCaps(gppdevPrimary, &GdiHandleTable->DevCaps);
PDEVOBJ_vGetDeviceCaps(gpmdev->ppdevGlobal, &GdiHandleTable->DevCaps);
return TRUE;
}
@ -51,7 +51,7 @@ IntEnumHDev(VOID)
{
// I guess we will soon have more than one primary surface.
// This will do for now.
return gppdevPrimary;
return gpmdev->ppdevGlobal;
}

View file

@ -32,6 +32,7 @@ DBG_CHANNEL DbgChannels[DbgChCount] = {
{L"EngLDev", DbgChEngLDev},
{L"EngLine", DbgChEngLine},
{L"EngMapping", DbgChEngMapping},
{L"EngMDev", DbgChEngMDev},
{L"EngPDev", DbgChEngPDev},
{L"EngSurface", DbgChEngSurface},
{L"EngWnd", DbgChEngWnd},

View file

@ -47,16 +47,16 @@ InitMetrics(VOID)
ZwClose(hKey);
}
/* FIXME: HACK, due to missing PDEV on first init */
if (!gppdevPrimary)
/* FIXME: HACK, due to missing MDEV on first init */
if (!gpmdev)
{
Width = 640;
Height = 480;
}
else
{
Width = gppdevPrimary->gdiinfo.ulHorzRes;
Height = gppdevPrimary->gdiinfo.ulVertRes;
Width = gpmdev->ppdevGlobal->gdiinfo.ulHorzRes;
Height = gpmdev->ppdevGlobal->gdiinfo.ulVertRes;
}
/* Screen sizes */

View file

@ -71,6 +71,7 @@
#define GDITAG_DC_FREELIST 'fcdG'
#define GDITAG_DWMSTATE 'scDG'
#define GDITAG_DEVMODE 'vedG'
#define GDITAG_MDEV 'vdmG'
#define GDITAG_PDEV 'veDG'
#define GDITAG_HGLYPH_ARRAY 'mfdG'
#define GDITAG_DRVSUP 'srdG'

View file

@ -53,6 +53,7 @@
DbgChEngLDev,
DbgChEngLine,
DbgChEngMapping,
DbgChEngMDev,
DbgChEngPDev,
DbgChEngSurface,
DbgChEngWnd,

View file

@ -263,6 +263,13 @@ co_IntInitializeDesktopGraphics(VOID)
UNICODE_STRING DriverName = RTL_CONSTANT_STRING(L"DISPLAY");
PDESKTOP pdesk;
gpmdev = ExAllocatePoolZero(PagedPool, sizeof(MDEVOBJ), GDITAG_MDEV);
if (!gpmdev)
{
ERR("Failed to allocate MDEV.\n");
return FALSE;
}
ScreenDeviceContext = IntGdiCreateDC(&DriverName, NULL, NULL, NULL, FALSE);
if (NULL == ScreenDeviceContext)
{
@ -285,11 +292,11 @@ co_IntInitializeDesktopGraphics(VOID)
InitMetrics();
/* Set new size of the monitor */
UserUpdateMonitorSize((HDEV)gppdevPrimary);
UserUpdateMonitorSize((HDEV)gpmdev->ppdevGlobal);
/* Update the SERVERINFO */
gpsi->aiSysMet[SM_CXSCREEN] = gppdevPrimary->gdiinfo.ulHorzRes;
gpsi->aiSysMet[SM_CYSCREEN] = gppdevPrimary->gdiinfo.ulVertRes;
gpsi->aiSysMet[SM_CXSCREEN] = gpmdev->ppdevGlobal->gdiinfo.ulHorzRes;
gpsi->aiSysMet[SM_CYSCREEN] = gpmdev->ppdevGlobal->gdiinfo.ulVertRes;
gpsi->Planes = NtGdiGetDeviceCaps(ScreenDeviceContext, PLANES);
gpsi->BitsPixel = NtGdiGetDeviceCaps(ScreenDeviceContext, BITSPIXEL);
gpsi->BitCount = gpsi->Planes * gpsi->BitsPixel;
@ -311,7 +318,7 @@ co_IntInitializeDesktopGraphics(VOID)
gpsi->ptCursor.y = gpsi->aiSysMet[SM_CYSCREEN] / 2;
/* Attach monitor */
UserAttachMonitor((HDEV)gppdevPrimary);
UserAttachMonitor((HDEV)gpmdev->ppdevGlobal);
/* Setup the cursor */
co_IntLoadDefaultCursors();

View file

@ -23,6 +23,7 @@ typedef struct _DC *PDC;
#include "gdi/ntgdi/gdiobj.h"
#include "gdi/ntgdi/palette.h"
#include "gdi/eng/surface.h"
#include "gdi/eng/mdevobj.h"
#include "gdi/eng/pdevobj.h"
#include "gdi/eng/ldevobj.h"
#include "gdi/eng/device.h"