ReactOS  0.4.13-dev-241-g63286c6
pdevobj.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  _GDIPOINTER
 
struct  _DEVMODEINFO
 
struct  _DEVMODEENTRY
 
struct  _GRAPHICS_DEVICE
 
struct  _PDEVOBJ
 

Typedefs

typedef struct _GDIPOINTER GDIPOINTER
 
typedef struct _GDIPOINTERPGDIPOINTER
 
typedef struct _DEVMODEINFO DEVMODEINFO
 
typedef struct _DEVMODEINFOPDEVMODEINFO
 
typedef struct _DEVMODEENTRY DEVMODEENTRY
 
typedef struct _DEVMODEENTRYPDEVMODEENTRY
 
typedef struct _GRAPHICS_DEVICE GRAPHICS_DEVICE
 
typedef struct _GRAPHICS_DEVICEPGRAPHICS_DEVICE
 
typedef struct _PDEVOBJ PDEVOBJ
 
typedef struct _PDEVOBJPPDEVOBJ
 

Enumerations

enum  _PDEVFLAGS {
  PDEV_DISPLAY = 0x00000001, PDEV_HARDWARE_POINTER = 0x00000002, PDEV_SOFTWARE_POINTER = 0x00000004, PDEV_GOTFONTS = 0x00000040,
  PDEV_PRINTER = 0x00000080, PDEV_ALLOCATEDBRUSHES = 0x00000100, PDEV_HTPAL_IS_DEVPAL = 0x00000200, PDEV_DISABLED = 0x00000400,
  PDEV_SYNCHRONIZE_ENABLED = 0x00000800, PDEV_FONTDRIVER = 0x00002000, PDEV_GAMMARAMP_TABLE = 0x00004000, PDEV_UMPD = 0x00008000,
  PDEV_SHARED_DEVLOCK = 0x00010000, PDEV_META_DEVICE = 0x00020000, PDEV_DRIVER_PUNTED_CALL = 0x00040000, PDEV_CLONE_DEVICE = 0x00080000
}
 

Functions

PPDEVOBJ NTAPI EngpGetPDEV (_In_opt_ PUNICODE_STRING pustrDevice)
 
VOID NTAPI PDEVOBJ_vRelease (_Inout_ PPDEVOBJ ppdev)
 
PSURFACE NTAPI PDEVOBJ_pSurface (_In_ PPDEVOBJ ppdev)
 
VOID NTAPI PDEVOBJ_vGetDeviceCaps (_In_ PPDEVOBJ ppdev, _Out_ PDEVCAPS pDevCaps)
 
INIT_FUNCTION NTSTATUS NTAPI InitPDEVImpl (VOID)
 
PSIZEL FASTCALL PDEVOBJ_sizl (_In_ PPDEVOBJ ppdev, _Out_ PSIZEL psizl)
 
BOOL NTAPI PDEVOBJ_bSwitchMode (PPDEVOBJ ppdev, PDEVMODEW pdm)
 
PDEVMODEW NTAPI PDEVOBJ_pdmMatchDevMode (PPDEVOBJ ppdev, PDEVMODEW pdm)
 
FORCEINLINE VOID PDEVOBJ_vReference (PPDEVOBJ ppdev)
 

Variables

PPDEVOBJ gppdevPrimary
 

Typedef Documentation

◆ DEVMODEENTRY

◆ DEVMODEINFO

◆ GDIPOINTER

◆ GRAPHICS_DEVICE

◆ PDEVMODEENTRY

◆ PDEVMODEINFO

◆ PDEVOBJ

◆ PGDIPOINTER

◆ PGRAPHICS_DEVICE

◆ PPDEVOBJ

Enumeration Type Documentation

◆ _PDEVFLAGS

Enumerator
PDEV_DISPLAY 
PDEV_HARDWARE_POINTER 
PDEV_SOFTWARE_POINTER 
PDEV_GOTFONTS 
PDEV_PRINTER 
PDEV_ALLOCATEDBRUSHES 
PDEV_HTPAL_IS_DEVPAL 
PDEV_DISABLED 
PDEV_SYNCHRONIZE_ENABLED 
PDEV_FONTDRIVER 
PDEV_GAMMARAMP_TABLE 
PDEV_UMPD 
PDEV_SHARED_DEVLOCK 
PDEV_META_DEVICE 
PDEV_DRIVER_PUNTED_CALL 
PDEV_CLONE_DEVICE 

Definition at line 5 of file pdevobj.h.

6 {
7  PDEV_DISPLAY = 0x00000001, /* Display device */
8  PDEV_HARDWARE_POINTER = 0x00000002, /* Supports hardware cursor */
9  PDEV_SOFTWARE_POINTER = 0x00000004,
10  PDEV_GOTFONTS = 0x00000040, /* Has font driver */
11  PDEV_PRINTER = 0x00000080,
12  PDEV_ALLOCATEDBRUSHES = 0x00000100,
13  PDEV_HTPAL_IS_DEVPAL = 0x00000200,
14  PDEV_DISABLED = 0x00000400,
15  PDEV_SYNCHRONIZE_ENABLED = 0x00000800,
16  PDEV_FONTDRIVER = 0x00002000, /* Font device */
17  PDEV_GAMMARAMP_TABLE = 0x00004000,
18  PDEV_UMPD = 0x00008000,
19  PDEV_SHARED_DEVLOCK = 0x00010000,
20  PDEV_META_DEVICE = 0x00020000,
21  PDEV_DRIVER_PUNTED_CALL = 0x00040000, /* Driver calls back to GDI engine */
22  PDEV_CLONE_DEVICE = 0x00080000
23 };

Function Documentation

◆ EngpGetPDEV()

PPDEVOBJ NTAPI EngpGetPDEV ( _In_opt_ PUNICODE_STRING  pustrDevice)

Definition at line 591 of file pdevobj.c.

593 {
594  UNICODE_STRING ustrCurrent;
595  PPDEVOBJ ppdev;
596  PGRAPHICS_DEVICE pGraphicsDevice;
597 
598  /* Acquire PDEV lock */
600 
601  /* Did the caller pass a device name? */
602  if (pustrDeviceName)
603  {
604  /* Loop all present PDEVs */
605  for (ppdev = gppdevList; ppdev; ppdev = ppdev->ppdevNext)
606  {
607  /* Get a pointer to the GRAPHICS_DEVICE */
608  pGraphicsDevice = ppdev->pGraphicsDevice;
609 
610  /* Compare the name */
611  RtlInitUnicodeString(&ustrCurrent, pGraphicsDevice->szWinDeviceName);
612  if (RtlEqualUnicodeString(pustrDeviceName, &ustrCurrent, FALSE))
613  {
614  /* Found! */
615  break;
616  }
617  }
618  }
619  else
620  {
621  /* Otherwise use the primary PDEV */
622  ppdev = gppdevPrimary;
623  }
624 
625  /* Did we find one? */
626  if (ppdev)
627  {
628  /* Yes, reference the PDEV */
630  }
631  else
632  {
633  /* No, create a new PDEV for the given device */
634  ppdev = EngpCreatePDEV(pustrDeviceName, NULL);
635  if (ppdev)
636  {
637  /* Insert the PDEV into the list */
638  ppdev->ppdevNext = gppdevList;
639  gppdevList = ppdev;
640 
641  /* Set as primary PDEV, if we don't have one yet */
642  if (!gppdevPrimary)
643  {
644  gppdevPrimary = ppdev;
646  }
647  }
648  }
649 
650  /* Release PDEV lock */
652 
653  return ppdev;
654 }
VOID WINAPI EngReleaseSemaphore(IN HSEMAPHORE hsem)
Definition: eng.c:235
LONG cPdevRefs
Definition: pdevobj.h:86
WCHAR szWinDeviceName[CCHDEVICENAME/2]
Definition: pdevobj.h:60
PPDEVOBJ gppdevPrimary
Definition: pdevobj.c:13
DWORD StateFlags
Definition: pdevobj.h:66
static PPDEVOBJ EngpCreatePDEV(PUNICODE_STRING pustrDeviceName, PDEVMODEW pdm)
Definition: pdevobj.c:343
struct _PDEVOBJ * ppdevNext
Definition: pdevobj.h:85
static HSEMAPHORE ghsemPDEV
Definition: pdevobj.c:16
ENGAPI VOID APIENTRY EngAcquireSemaphore(_Inout_ HSEMAPHORE hsem)
smooth NULL
Definition: ftsmooth.c:416
#define DISPLAY_DEVICE_PRIMARY_DEVICE
Definition: wingdi.h:1380
static PPDEVOBJ gppdevList
Definition: pdevobj.c:15
#define InterlockedIncrement
Definition: armddk.h:53
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
PGRAPHICS_DEVICE pGraphicsDevice
Definition: pdevobj.h:128
NTSYSAPI BOOLEAN NTAPI RtlEqualUnicodeString(PUNICODE_STRING String1, PUNICODE_STRING String2, BOOLEAN CaseInSensitive)

Referenced by GreCreateCompatibleDC(), GreOpenDCW(), NtGdiExtEscape(), UserChangeDisplaySettings(), UserEnumCurrentDisplaySettings(), and UserEnumDisplaySettings().

◆ InitPDEVImpl()

INIT_FUNCTION NTSTATUS NTAPI InitPDEVImpl ( VOID  )

Definition at line 21 of file pdevobj.c.

22 {
25  return STATUS_SUCCESS;
26 }
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
static HSEMAPHORE ghsemPDEV
Definition: pdevobj.c:16
HSEMAPHORE WINAPI EngCreateSemaphore(VOID)
Definition: eng.c:75
return STATUS_SUCCESS
Definition: btrfs.c:2745

Referenced by DriverEntry().

◆ PDEVOBJ_bSwitchMode()

BOOL NTAPI PDEVOBJ_bSwitchMode ( PPDEVOBJ  ppdev,
PDEVMODEW  pdm 
)

Definition at line 505 of file pdevobj.c.

508 {
509  UNICODE_STRING ustrDevice;
510  PPDEVOBJ ppdevTmp;
512  BOOL retval = FALSE;
513 
514  /* Lock the PDEV */
516 
517  /* And everything else */
519 
520  DPRINT1("PDEVOBJ_bSwitchMode, ppdev = %p, pSurface = %p\n", ppdev, ppdev->pSurface);
521 
522  // Lookup the GraphicsDevice + select DEVMODE
523  // pdm = PDEVOBJ_pdmMatchDevMode(ppdev, pdm);
524 
525  /* 1. Temporarily disable the current PDEV and reset video to its default mode */
526  if (!ppdev->pfn.AssertMode(ppdev->dhpdev, FALSE))
527  {
528  DPRINT1("DrvAssertMode(FALSE) failed\n");
529  goto leave;
530  }
531 
532  /* 2. Create new PDEV */
534  ppdevTmp = EngpCreatePDEV(&ustrDevice, pdm);
535  if (!ppdevTmp)
536  {
537  DPRINT1("Failed to create a new PDEV\n");
538  goto leave2;
539  }
540 
541  /* 3. Create a new surface */
542  pSurface = PDEVOBJ_pSurface(ppdevTmp);
543  if (!pSurface)
544  {
545  DPRINT1("PDEVOBJ_pSurface failed\n");
546  PDEVOBJ_vRelease(ppdevTmp);
547  goto leave2;
548  }
549 
550  /* 4. Get DirectDraw information */
551  /* 5. Enable DirectDraw Not traced */
552  /* 6. Copy old PDEV state to new PDEV instance */
553 
554  /* 7. Switch the PDEVs */
555  PDEVOBJ_vSwitchPdev(ppdev, ppdevTmp);
556 
557  /* 8. Disable DirectDraw */
558 
559  PDEVOBJ_vRelease(ppdevTmp);
560 
561  /* Update primary display capabilities */
562  if(ppdev == gppdevPrimary)
563  {
564  PDEVOBJ_vGetDeviceCaps(ppdev, &GdiHandleTable->DevCaps);
565  }
566 
567  /* Success! */
568  retval = TRUE;
569 
570 leave2:
571  /* Set the new video mode, or restore the original one in case of failure */
572  if (!ppdev->pfn.AssertMode(ppdev->dhpdev, TRUE))
573  {
574  DPRINT1("DrvAssertMode(TRUE) failed\n");
575  }
576 
577 leave:
578  /* Unlock everything else */
580  /* Unlock the PDEV */
582 
583  DPRINT1("leave, ppdev = %p, pSurface = %p\n", ppdev, ppdev->pSurface);
584 
585  return retval;
586 }
DHPDEV dhpdev
Definition: pdevobj.h:121
VOID WINAPI EngReleaseSemaphore(IN HSEMAPHORE hsem)
Definition: eng.c:235
#define TRUE
Definition: types.h:120
WCHAR szWinDeviceName[CCHDEVICENAME/2]
Definition: pdevobj.h:60
PSURFACE NTAPI PDEVOBJ_pSurface(PPDEVOBJ ppdev)
Definition: pdevobj.c:233
PPDEVOBJ gppdevPrimary
Definition: pdevobj.c:13
static PPDEVOBJ EngpCreatePDEV(PUNICODE_STRING pustrDeviceName, PDEVMODEW pdm)
Definition: pdevobj.c:343
unsigned int BOOL
Definition: ntddk_ex.h:94
static HSEMAPHORE ghsemPDEV
Definition: pdevobj.c:16
ENGAPI VOID APIENTRY EngAcquireSemaphore(_Inout_ HSEMAPHORE hsem)
HSEMAPHORE hsemDevLock
Definition: pdevobj.h:91
DRIVER_FUNCTIONS pfn
Definition: pdevobj.h:139
VOID NTAPI PDEVOBJ_vGetDeviceCaps(IN PPDEVOBJ ppdev, OUT PDEVCAPS pDevCaps)
Definition: pdevobj.c:679
#define GdiHandleTable
Definition: win32nt.h:36
_In_ DD_SURFACE_LOCAL * pSurface
Definition: winddi.h:3481
VOID NTAPI PDEVOBJ_vSwitchPdev(PPDEVOBJ ppdev, PPDEVOBJ ppdev2)
Definition: pdevobj.c:451
PFN_DrvAssertMode AssertMode
Definition: ntgdityp.h:568
PSURFACE pSurface
Definition: pdevobj.h:125
#define DPRINT1
Definition: precomp.h:8
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
PGRAPHICS_DEVICE pGraphicsDevice
Definition: pdevobj.h:128
VOID NTAPI PDEVOBJ_vRelease(PPDEVOBJ ppdev)
Definition: pdevobj.c:93

Referenced by UserChangeDisplaySettings().

◆ PDEVOBJ_pdmMatchDevMode()

PDEVMODEW NTAPI PDEVOBJ_pdmMatchDevMode ( PPDEVOBJ  ppdev,
PDEVMODEW  pdm 
)

Definition at line 304 of file pdevobj.c.

307 {
308  PGRAPHICS_DEVICE pGraphicsDevice;
309  PDEVMODEW pdmCurrent;
310  ULONG i;
311  DWORD dwFields;
312 
313  pGraphicsDevice = ppdev->pGraphicsDevice;
314 
315  for (i = 0; i < pGraphicsDevice->cDevModes; i++)
316  {
317  pdmCurrent = pGraphicsDevice->pDevModeList[i].pdm;
318 
319  /* Compare asked DEVMODE fields
320  * Only compare those that are valid in both DEVMODE structs */
321  dwFields = pdmCurrent->dmFields & pdm->dmFields ;
322 
323  /* For now, we only need those */
324  if ((dwFields & DM_BITSPERPEL) &&
325  (pdmCurrent->dmBitsPerPel != pdm->dmBitsPerPel)) continue;
326  if ((dwFields & DM_PELSWIDTH) &&
327  (pdmCurrent->dmPelsWidth != pdm->dmPelsWidth)) continue;
328  if ((dwFields & DM_PELSHEIGHT) &&
329  (pdmCurrent->dmPelsHeight != pdm->dmPelsHeight)) continue;
330  if ((dwFields & DM_DISPLAYFREQUENCY) &&
331  (pdmCurrent->dmDisplayFrequency != pdm->dmDisplayFrequency)) continue;
332 
333  /* Match! Return the DEVMODE */
334  return pdmCurrent;
335  }
336 
337  /* Nothing found */
338  return NULL;
339 }
DWORD dmFields
Definition: wingdi.h:1600
PDEVMODEENTRY pDevModeList
Definition: pdevobj.h:70
DWORD dmBitsPerPel
Definition: wingdi.h:1625
PDEVMODEW pdm
Definition: pdevobj.h:53
#define DM_PELSWIDTH
Definition: wingdi.h:1251
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
smooth NULL
Definition: ftsmooth.c:416
ULONG cDevModes
Definition: pdevobj.h:69
unsigned long DWORD
Definition: ntddk_ex.h:95
DWORD dmPelsWidth
Definition: wingdi.h:1626
#define DM_DISPLAYFREQUENCY
Definition: wingdi.h:1254
DWORD dmDisplayFrequency
Definition: wingdi.h:1632
#define DM_PELSHEIGHT
Definition: wingdi.h:1252
DWORD dmPelsHeight
Definition: wingdi.h:1627
unsigned int ULONG
Definition: retypes.h:1
#define DM_BITSPERPEL
Definition: wingdi.h:1250
PGRAPHICS_DEVICE pGraphicsDevice
Definition: pdevobj.h:128

Referenced by EngpCreatePDEV(), and UserChangeDisplaySettings().

◆ PDEVOBJ_pSurface()

PSURFACE NTAPI PDEVOBJ_pSurface ( _In_ PPDEVOBJ  ppdev)

◆ PDEVOBJ_sizl()

PSIZEL FASTCALL PDEVOBJ_sizl ( _In_ PPDEVOBJ  ppdev,
_Out_ PSIZEL  psizl 
)

◆ PDEVOBJ_vGetDeviceCaps()

VOID NTAPI PDEVOBJ_vGetDeviceCaps ( _In_ PPDEVOBJ  ppdev,
_Out_ PDEVCAPS  pDevCaps 
)

◆ PDEVOBJ_vReference()

FORCEINLINE VOID PDEVOBJ_vReference ( PPDEVOBJ  ppdev)

Definition at line 206 of file pdevobj.h.

207 {
209 }
LONG cPdevRefs
Definition: pdevobj.h:86
#define InterlockedIncrement
Definition: armddk.h:53

Referenced by NtGdiExtEscape().

◆ PDEVOBJ_vRelease()

VOID NTAPI PDEVOBJ_vRelease ( _Inout_ PPDEVOBJ  ppdev)

Variable Documentation

◆ gppdevPrimary