ReactOS 0.4.15-dev-8413-gc1c91f2
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)
 
FORCEINLINE VOID PDEVOBJ_vReference (_In_ PPDEVOBJ ppdev)
 
VOID NTAPI PDEVOBJ_vRelease (_Inout_ PPDEVOBJ ppdev)
 
PSURFACE NTAPI PDEVOBJ_pSurface (_In_ PPDEVOBJ ppdev)
 
VOID NTAPI PDEVOBJ_vGetDeviceCaps (_In_ PPDEVOBJ ppdev, _Out_ PDEVCAPS pDevCaps)
 
NTSTATUS NTAPI InitPDEVImpl (VOID)
 
PSIZEL FASTCALL PDEVOBJ_sizl (_In_ PPDEVOBJ ppdev, _Out_ PSIZEL psizl)
 
BOOL NTAPI PDEVOBJ_bSwitchMode (PPDEVOBJ ppdev, PDEVMODEW pdm)
 
BOOL NTAPI PDEVOBJ_bDynamicModeChange (_Inout_ PPDEVOBJ ppdev, _Inout_ PPDEVOBJ ppdev2)
 
VOID PDEVOBJ_vEnableDisplay (_Inout_ PPDEVOBJ ppdev)
 
BOOL PDEVOBJ_bDisableDisplay (_Inout_ PPDEVOBJ ppdev)
 
PPDEVOBJ PDEVOBJ_Create (_In_opt_ PGRAPHICS_DEVICE pGraphicsDevice, _In_opt_ PDEVMODEW pdm, _In_ ULONG dwAccelerationLevel, _In_ ULONG ldevtype)
 
LONG PDEVOBJ_lChangeDisplaySettings (_In_opt_ PUNICODE_STRING pustrDeviceName, _In_opt_ PDEVMODEW RequestedMode, _In_opt_ PMDEVOBJ pmdevOld, _Out_ PMDEVOBJ *ppmdevNew, _In_ BOOL bSearchClosestMode)
 

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};
@ PDEV_UMPD
Definition: pdevobj.h:18
@ PDEV_FONTDRIVER
Definition: pdevobj.h:16
@ PDEV_HTPAL_IS_DEVPAL
Definition: pdevobj.h:13
@ PDEV_DISABLED
Definition: pdevobj.h:14
@ PDEV_DISPLAY
Definition: pdevobj.h:7
@ PDEV_GAMMARAMP_TABLE
Definition: pdevobj.h:17
@ PDEV_SYNCHRONIZE_ENABLED
Definition: pdevobj.h:15
@ PDEV_META_DEVICE
Definition: pdevobj.h:20
@ PDEV_GOTFONTS
Definition: pdevobj.h:10
@ PDEV_CLONE_DEVICE
Definition: pdevobj.h:22
@ PDEV_ALLOCATEDBRUSHES
Definition: pdevobj.h:12
@ PDEV_HARDWARE_POINTER
Definition: pdevobj.h:8
@ PDEV_SOFTWARE_POINTER
Definition: pdevobj.h:9
@ PDEV_PRINTER
Definition: pdevobj.h:11
@ PDEV_DRIVER_PUNTED_CALL
Definition: pdevobj.h:21
@ PDEV_SHARED_DEVLOCK
Definition: pdevobj.h:19

Function Documentation

◆ EngpGetPDEV()

PPDEVOBJ NTAPI EngpGetPDEV ( _In_opt_ PUNICODE_STRING  pustrDevice)

Definition at line 815 of file pdevobj.c.

817{
818 UNICODE_STRING ustrCurrent;
819 PPDEVOBJ ppdev = NULL;
820 PGRAPHICS_DEVICE pGraphicsDevice;
821 ULONG i;
822
823 /* Acquire PDEV lock */
825
826 /* Did the caller pass a device name? */
827 if (pustrDeviceName)
828 {
829 /* Loop all present PDEVs */
830 for (i = 0; i < gpmdev->cDev; i++)
831 {
832 /* Get a pointer to the GRAPHICS_DEVICE */
833 pGraphicsDevice = gpmdev->dev[i].ppdev->pGraphicsDevice;
834
835 /* Compare the name */
836 RtlInitUnicodeString(&ustrCurrent, pGraphicsDevice->szWinDeviceName);
837 if (RtlEqualUnicodeString(pustrDeviceName, &ustrCurrent, FALSE))
838 {
839 /* Found! */
840 ppdev = gpmdev->dev[i].ppdev;
841 break;
842 }
843 }
844 }
845 else if (gpmdev)
846 {
847 /* Otherwise use the primary PDEV */
848 ppdev = gpmdev->ppdevGlobal;
849 }
850
851 /* Did we find one? */
852 if (ppdev)
853 {
854 /* Yes, reference the PDEV */
855 PDEVOBJ_vReference(ppdev);
856 }
857
858 /* Release PDEV lock */
860
861 return ppdev;
862}
#define NULL
Definition: types.h:112
#define FALSE
Definition: types.h:117
VOID WINAPI EngReleaseSemaphore(IN HSEMAPHORE hsem)
Definition: eng.c:235
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
PMDEVOBJ gpmdev
Definition: mdevobj.c:14
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
NTSYSAPI BOOLEAN NTAPI RtlEqualUnicodeString(PUNICODE_STRING String1, PUNICODE_STRING String2, BOOLEAN CaseInSensitive)
static HSEMAPHORE ghsemPDEV
Definition: pdevobj.c:16
FORCEINLINE VOID PDEVOBJ_vReference(_In_ PPDEVOBJ ppdev)
Definition: pdevobj.h:160
WCHAR szWinDeviceName[CCHDEVICENAME/2]
Definition: pdevobj.h:60
PPDEVOBJ ppdev
Definition: mdevobj.h:10
PPDEVOBJ ppdevGlobal
Definition: mdevobj.h:16
ULONG cDev
Definition: mdevobj.h:15
MDEVDISPLAY dev[0]
Definition: mdevobj.h:17
PGRAPHICS_DEVICE pGraphicsDevice
Definition: pdevobj.h:127
uint32_t ULONG
Definition: typedefs.h:59
ENGAPI VOID APIENTRY EngAcquireSemaphore(_Inout_ HSEMAPHORE hsem)

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

◆ InitPDEVImpl()

NTSTATUS NTAPI InitPDEVImpl ( VOID  )

Definition at line 31 of file pdevobj.c.

32{
35 return STATUS_SUCCESS;
36}
HSEMAPHORE WINAPI EngCreateSemaphore(VOID)
Definition: eng.c:75
#define STATUS_SUCCESS
Definition: shellext.h:65
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158

Referenced by DriverEntry().

◆ PDEVOBJ_bDisableDisplay()

BOOL PDEVOBJ_bDisableDisplay ( _Inout_ PPDEVOBJ  ppdev)

Definition at line 412 of file pdevobj.c.

414{
415 BOOL assertVal;
416
417 if (ppdev->flFlags & PDEV_DISABLED)
418 return TRUE;
419
420#ifdef NATIVE_REACTX
421 PDEVOBJ_vSuspendDirectDraw(ppdev);
422#endif
423
424 TRACE("DrvAssertMode(dhpdev %p, FALSE)\n", ppdev->dhpdev);
425 assertVal = ppdev->pfn.AssertMode(ppdev->dhpdev, FALSE);
426 TRACE("DrvAssertMode(dhpdev %p, FALSE) => %d\n", ppdev->dhpdev, assertVal);
427
428 if (assertVal)
429 ppdev->flFlags |= PDEV_DISABLED;
430
431 return assertVal;
432}
#define TRUE
Definition: types.h:120
unsigned int BOOL
Definition: ntddk_ex.h:94
#define TRACE(s)
Definition: solgame.cpp:4

Referenced by MDEVOBJ_bDisable(), PDEVOBJ_bSwitchMode(), PDEVOBJ_Create(), and PDEVOBJ_lChangeDisplaySettings().

◆ PDEVOBJ_bDynamicModeChange()

BOOL NTAPI PDEVOBJ_bDynamicModeChange ( _Inout_ PPDEVOBJ  ppdev,
_Inout_ PPDEVOBJ  ppdev2 
)

◆ PDEVOBJ_bSwitchMode()

BOOL NTAPI PDEVOBJ_bSwitchMode ( PPDEVOBJ  ppdev,
PDEVMODEW  pdm 
)

Definition at line 712 of file pdevobj.c.

715{
716 PPDEVOBJ ppdevTmp;
718 BOOL retval = FALSE;
719
720 /* Lock the PDEV */
722
723 /* And everything else */
725
726 DPRINT1("PDEVOBJ_bSwitchMode, ppdev = %p, pSurface = %p\n", ppdev, ppdev->pSurface);
727
728 // Lookup the GraphicsDevice + select DEVMODE
729 // pdm = LDEVOBJ_bProbeAndCaptureDevmode(ppdev, pdm);
730
731 /* 1. Temporarily disable the current PDEV and reset video to its default mode */
732 if (!PDEVOBJ_bDisableDisplay(ppdev))
733 {
734 DPRINT1("PDEVOBJ_bDisableDisplay() failed\n");
735#ifdef NATIVE_REACTX
736 /* Resume DirectDraw in case of failure */
737 PDEVOBJ_vResumeDirectDraw(ppdev);
738#endif
739 goto leave;
740 }
741
742 /* 2. Create new PDEV */
743 ppdevTmp = PDEVOBJ_Create(ppdev->pGraphicsDevice, pdm, 0, LDEV_DEVICE_DISPLAY);
744 if (!ppdevTmp)
745 {
746 DPRINT1("Failed to create a new PDEV\n");
747 goto leave2;
748 }
749
750 /* 3. Create a new surface */
751 pSurface = PDEVOBJ_pSurface(ppdevTmp);
752 if (!pSurface)
753 {
754 DPRINT1("PDEVOBJ_pSurface failed\n");
755 PDEVOBJ_vRelease(ppdevTmp);
756 goto leave2;
757 }
758
759#ifdef NATIVE_REACTX
760 /* 4. Temporarily suspend DirectDraw for mode change */
761 PDEVOBJ_vSuspendDirectDraw(ppdev);
762 PDEVOBJ_vSuspendDirectDraw(ppdevTmp);
763#endif
764
765 /* 5. Switch the PDEVs */
766 if (!PDEVOBJ_bDynamicModeChange(ppdev, ppdevTmp))
767 {
768 DPRINT1("PDEVOBJ_bDynamicModeChange() failed\n");
769 PDEVOBJ_vRelease(ppdevTmp);
770 goto leave2;
771 }
772
773#ifdef NATIVE_REACTX
774 /* 6. Resume DirectDraw */
775 PDEVOBJ_vResumeDirectDraw(ppdev);
776 PDEVOBJ_vResumeDirectDraw(ppdevTmp);
777#endif
778
779 /* Release temp PDEV */
780 PDEVOBJ_vRelease(ppdevTmp);
781
782#ifdef NATIVE_REACTX
783 /* Re-initialize DirectDraw data */
784 ppdev->pEDDgpl->hDev = (HDEV)ppdev;
785 ppdev->pEDDgpl->dhpdev = ppdev->dhpdev;
786#endif
787
788 /* Update primary display capabilities */
789 if (ppdev == gpmdev->ppdevGlobal)
790 {
791 PDEVOBJ_vGetDeviceCaps(ppdev, &GdiHandleTable->DevCaps);
792 }
793
794 /* Success! */
795 retval = TRUE;
796
797leave2:
798 /* Set the new video mode, or restore the original one in case of failure */
800
801leave:
802 /* Unlock everything else */
804 /* Unlock the PDEV */
806
807 DPRINT1("leave, ppdev = %p, pSurface = %p\n", ppdev, ppdev->pSurface);
808
809 return retval;
810}
#define DPRINT1
Definition: precomp.h:8
#define leave
Definition: btrfs_drv.h:138
@ LDEV_DEVICE_DISPLAY
Definition: ldevobj.h:8
BOOL PDEVOBJ_bDisableDisplay(_Inout_ PPDEVOBJ ppdev)
Definition: pdevobj.c:412
PPDEVOBJ PDEVOBJ_Create(_In_opt_ PGRAPHICS_DEVICE pGraphicsDevice, _In_opt_ PDEVMODEW pdm, _In_ ULONG dwAccelerationLevel, _In_ ULONG ldevtype)
Definition: pdevobj.c:467
BOOL NTAPI PDEVOBJ_bDynamicModeChange(PPDEVOBJ ppdev, PPDEVOBJ ppdev2)
Definition: pdevobj.c:651
VOID NTAPI PDEVOBJ_vRelease(_Inout_ PPDEVOBJ ppdev)
Definition: pdevobj.c:105
VOID NTAPI PDEVOBJ_vGetDeviceCaps(IN PPDEVOBJ ppdev, OUT PDEVCAPS pDevCaps)
Definition: pdevobj.c:1053
PSURFACE NTAPI PDEVOBJ_pSurface(PPDEVOBJ ppdev)
Definition: pdevobj.c:311
VOID PDEVOBJ_vEnableDisplay(_Inout_ PPDEVOBJ ppdev)
Definition: pdevobj.c:392
PSURFACE pSurface
Definition: pdevobj.h:124
struct _EDD_DIRECTDRAW_GLOBAL * pEDDgpl
Definition: pdevobj.h:148
DHPDEV dhpdev
Definition: pdevobj.h:120
HSEMAPHORE hsemDevLock
Definition: pdevobj.h:89
#define GdiHandleTable
Definition: win32nt.h:37
_In_ DD_SURFACE_LOCAL * pSurface
Definition: winddi.h:3481

Referenced by UserChangeDisplaySettings(), and UserRefreshDisplay().

◆ PDEVOBJ_Create()

PPDEVOBJ PDEVOBJ_Create ( _In_opt_ PGRAPHICS_DEVICE  pGraphicsDevice,
_In_opt_ PDEVMODEW  pdm,
_In_ ULONG  dwAccelerationLevel,
_In_ ULONG  ldevtype 
)

Definition at line 467 of file pdevobj.c.

472{
473 PPDEVOBJ ppdev, ppdevMatch = NULL;
474 PLDEVOBJ pldev;
476
477 TRACE("PDEVOBJ_Create(%p %p %d)\n", pGraphicsDevice, pdm, ldevtype);
478
479 if (ldevtype != LDEV_DEVICE_META)
480 {
481 ASSERT(pGraphicsDevice);
482 ASSERT(pdm);
483 /* Search if we already have a PPDEV with the required characteristics.
484 * We will compare the graphics device, the devmode and the desktop
485 */
486 for (ppdev = gppdevList; ppdev; ppdev = ppdev->ppdevNext)
487 {
488 if (ppdev->pGraphicsDevice == pGraphicsDevice)
489 {
490 PDEVOBJ_vReference(ppdev);
491
492 if (RtlEqualMemory(pdm, ppdev->pdmwDev, sizeof(DEVMODEW)) &&
493 ppdev->dwAccelerationLevel == dwAccelerationLevel)
494 {
495 PDEVOBJ_vReference(ppdev);
496 ppdevMatch = ppdev;
497 }
498 else
499 {
501 }
502
503 PDEVOBJ_vRelease(ppdev);
504 }
505 }
506
507 if (ppdevMatch)
508 {
509 PDEVOBJ_vEnableDisplay(ppdevMatch);
510
511 return ppdevMatch;
512 }
513 }
514
515 /* Try to get a display driver */
516 if (ldevtype == LDEV_DEVICE_META)
517 pldev = LDEVOBJ_pLoadInternal(MultiEnableDriver, ldevtype);
518 else
519 pldev = LDEVOBJ_pLoadDriver(pdm->dmDeviceName, ldevtype);
520 if (!pldev)
521 {
522 ERR("Could not load display driver '%S'\n",
523 (ldevtype == LDEV_DEVICE_META) ? L"" : pdm->dmDeviceName);
524 return NULL;
525 }
526
527 /* Allocate a new PDEVOBJ */
528 ppdev = PDEVOBJ_AllocPDEV();
529 if (!ppdev)
530 {
531 ERR("failed to allocate a PDEV\n");
532 return NULL;
533 }
534
535 if (ldevtype != LDEV_DEVICE_META)
536 {
537 ppdev->pGraphicsDevice = pGraphicsDevice;
538
539 // DxEngGetHdevData asks for Graphics DeviceObject in hSpooler field
540 ppdev->hSpooler = ppdev->pGraphicsDevice->DeviceObject;
541
542 /* Keep selected resolution */
543 if (ppdev->pdmwDev)
545 ppdev->pdmwDev = ExAllocatePoolWithTag(PagedPool, pdm->dmSize + pdm->dmDriverExtra, GDITAG_DEVMODE);
546 if (ppdev->pdmwDev)
547 {
548 RtlCopyMemory(ppdev->pdmwDev, pdm, pdm->dmSize + pdm->dmDriverExtra);
549 /* FIXME: this must be done in a better way */
551 }
552 }
553
554 /* FIXME! */
555 ppdev->flFlags = PDEV_DISPLAY;
556
557 /* HACK: Don't use the pointer */
558 ppdev->Pointer.Exclude.right = -1;
559
560 /* Initialize PDEV */
561 ppdev->pldev = pldev;
562 ppdev->dwAccelerationLevel = dwAccelerationLevel;
563
564 /* Copy the function table */
565 if ((ldevtype == LDEV_DEVICE_DISPLAY && dwAccelerationLevel >= 5) ||
566 pdm->dmFields & (DM_PANNINGWIDTH | DM_PANNINGHEIGHT))
567 {
568 ULONG i;
569
570 /* Initialize missing fields */
571 if (!(pdm->dmFields & DM_PANNINGWIDTH))
572 pdm->dmPanningWidth = pdm->dmPelsWidth;
573 if (!(pdm->dmFields & DM_PANNINGHEIGHT))
574 pdm->dmPanningHeight = pdm->dmPelsHeight;
575
576 /* Replace vtable by panning vtable */
577 for (i = 0; i < gPanDispDrvCount; i++)
579 }
580 else
581 {
582 ppdev->pfn = ppdev->pldev->pfn;
583 }
584
585 /* Call the driver to enable the PDEV */
586 if (!PDEVOBJ_bEnablePDEV(ppdev, pdm, NULL))
587 {
588 ERR("Failed to enable PDEV!\n");
589 PDEVOBJ_vRelease(ppdev);
590 EngUnloadImage(pldev);
591 return NULL;
592 }
593
594 /* Tell the driver that the PDEV is ready */
596
597 /* Create the initial surface */
598 pSurface = PDEVOBJ_pSurface(ppdev);
599 if (!pSurface)
600 {
601 ERR("Failed to create surface\n");
602 PDEVOBJ_vRelease(ppdev);
603 EngUnloadImage(pldev);
604 return NULL;
605 }
606
607#ifdef NATIVE_REACTX
608 /* Enable DirectDraw */
609 if (!PDEVOBJ_bEnableDirectDraw(ppdev))
610 {
611 ERR("Failed to enable DirectDraw\n");
612 PDEVOBJ_vRelease(ppdev);
613 EngUnloadImage(pldev);
614 return NULL;
615 }
616#endif
617
618 /* Remove some acceleration capabilities from driver */
620
621 /* Set MovePointer function */
622 ppdev->pfnMovePointer = ppdev->pfn.MovePointer;
623 if (!ppdev->pfnMovePointer)
625
626 /* Insert the PDEV into the list */
627 ppdev->ppdevNext = gppdevList;
628 gppdevList = ppdev;
629
630 /* Return the PDEV */
631 return ppdev;
632}
#define ERR(fmt,...)
Definition: precomp.h:57
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
#define PagedPool
Definition: env_spec_w32.h:308
#define RtlEqualMemory(dst, src, len)
Definition: kdvm.h:18
PLDEVOBJ NTAPI LDEVOBJ_pLoadDriver(_In_z_ LPWSTR pwszDriverName, _In_ ULONG ldevtype)
Definition: ldevobj.c:347
PLDEVOBJ LDEVOBJ_pLoadInternal(_In_ PFN_DrvEnableDriver pfnEnableDriver, _In_ ULONG ldevtype)
Definition: ldevobj.c:303
@ LDEV_DEVICE_META
Definition: ldevobj.h:10
#define ASSERT(a)
Definition: mode.c:44
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1109
#define L(x)
Definition: ntvdm.h:50
BOOL NTAPI PDEVOBJ_bEnablePDEV(_In_ PPDEVOBJ ppdev, _In_ PDEVMODEW pdevmode, _In_ PWSTR pwszLogAddress)
Definition: pdevobj.c:174
BOOL APIENTRY MultiEnableDriver(_In_ ULONG iEngineVersion, _In_ ULONG cj, _Inout_bytecount_(cj) PDRVENABLEDATA pded)
Definition: multidisp.c:17
static VOID PDEVOBJ_vFilterDriverHooks(_In_ PPDEVOBJ ppdev)
Definition: pdevobj.c:255
DRVFN gPanDispDrvFn[]
Definition: pandisp.c:477
static PPDEVOBJ gppdevList
Definition: pdevobj.c:15
PPDEVOBJ PDEVOBJ_AllocPDEV(VOID)
Definition: pdevobj.c:63
ULONG gPanDispDrvCount
Definition: pandisp.c:501
VOID NTAPI PDEVOBJ_vCompletePDEV(PPDEVOBJ ppdev)
Definition: pdevobj.c:245
long right
Definition: polytest.cpp:53
PFN_DrvMovePointer MovePointer
Definition: ntgdityp.h:599
PFN pfn
Definition: winddi.h:531
ULONG iFunc
Definition: winddi.h:530
RECTL Exclude
Definition: pdevobj.h:39
PDEVICE_OBJECT DeviceObject
Definition: pdevobj.h:63
DRIVER_FUNCTIONS pfn
Definition: pdevobj.h:138
struct _PDEVOBJ * ppdevNext
Definition: pdevobj.h:83
GDIPOINTER Pointer
Definition: pdevobj.h:143
struct _LDEVOBJ * pldev
Definition: pdevobj.h:119
DWORD dwAccelerationLevel
Definition: pdevobj.h:132
FLONG flFlags
Definition: pdevobj.h:87
HANDLE hSpooler
Definition: pdevobj.h:125
PDEVMODEW pdmwDev
Definition: pdevobj.h:129
PFN_DrvMovePointer pfnMovePointer
Definition: pdevobj.h:113
PVOID apfn[INDEX_LAST]
Definition: pdevobj.h:139
WORD dmSize
Definition: wingdi.h:1620
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
#define GDITAG_DEVMODE
Definition: tags.h:73
ENGAPI VOID APIENTRY EngMovePointer(_In_ SURFOBJ *pso, _In_ LONG x, _In_ LONG y, _In_ RECTL *prcl)
Definition: mouse.c:575
ENGAPI VOID APIENTRY EngUnloadImage(_In_ HANDLE hModule)
Definition: ldevobj.c:913
#define DM_PANNINGHEIGHT
Definition: wingdi.h:1278
#define DISPLAY_DEVICE_PRIMARY_DEVICE
Definition: wingdi.h:1398
#define DISPLAY_DEVICE_ATTACHED_TO_DESKTOP
Definition: wingdi.h:1396
#define DM_PANNINGWIDTH
Definition: wingdi.h:1277

Referenced by MDEVOBJ_Create(), PDEVOBJ_bSwitchMode(), and PDEVOBJ_lChangeDisplaySettings().

◆ PDEVOBJ_lChangeDisplaySettings()

LONG PDEVOBJ_lChangeDisplaySettings ( _In_opt_ PUNICODE_STRING  pustrDeviceName,
_In_opt_ PDEVMODEW  RequestedMode,
_In_opt_ PMDEVOBJ  pmdevOld,
_Out_ PMDEVOBJ ppmdevNew,
_In_ BOOL  bSearchClosestMode 
)

Definition at line 865 of file pdevobj.c.

871{
872 PGRAPHICS_DEVICE pGraphicsDevice = NULL;
873 PMDEVOBJ pmdev = NULL;
874 PDEVMODEW pdm = NULL;
876 ULONG i, j;
877
878 TRACE("PDEVOBJ_lChangeDisplaySettings('%wZ' '%dx%dx%d (%d Hz)' %p %p)\n",
879 pustrDeviceName,
880 RequestedMode ? RequestedMode->dmPelsWidth : 0,
881 RequestedMode ? RequestedMode->dmPelsHeight : 0,
882 RequestedMode ? RequestedMode->dmBitsPerPel : 0,
883 RequestedMode ? RequestedMode->dmDisplayFrequency : 0,
884 pmdevOld, ppmdevNew);
885
886 if (pustrDeviceName)
887 {
888 pGraphicsDevice = EngpFindGraphicsDevice(pustrDeviceName, 0);
889 if (!pGraphicsDevice)
890 {
891 ERR("Wrong device name provided: '%wZ'\n", pustrDeviceName);
893 goto cleanup;
894 }
895 }
896 else if (RequestedMode)
897 {
898 pGraphicsDevice = gpPrimaryGraphicsDevice;
899 if (!pGraphicsDevice)
900 {
901 ERR("Wrong device'\n");
903 goto cleanup;
904 }
905 }
906
907 if (pGraphicsDevice)
908 {
909 if (!LDEVOBJ_bProbeAndCaptureDevmode(pGraphicsDevice, RequestedMode, &pdm, bSearchClosestMode))
910 {
911 ERR("DrvProbeAndCaptureDevmode() failed\n");
912 lRet = DISP_CHANGE_BADMODE;
913 goto cleanup;
914 }
915 }
916
917 /* Here, we know that input parameters were correct */
918
919 {
920 /* Create new MDEV. Note that if we provide a device name,
921 * MDEV will only contain one device.
922 * */
923
924 if (pmdevOld)
925 {
926 /* Disable old MDEV */
927 if (MDEVOBJ_bDisable(pmdevOld))
928 {
929 /* Create new MDEV. On failure, reenable old MDEV */
930 pmdev = MDEVOBJ_Create(pustrDeviceName, pdm);
931 if (!pmdev)
932 MDEVOBJ_vEnable(pmdevOld);
933 }
934 }
935 else
936 {
937 pmdev = MDEVOBJ_Create(pustrDeviceName, pdm);
938 }
939
940 if (!pmdev)
941 {
942 ERR("Failed to create new MDEV\n");
943 lRet = DISP_CHANGE_FAILED;
944 goto cleanup;
945 }
946
948 *ppmdevNew = pmdev;
949
950 /* We now have to do the mode switch */
951
952 if (pustrDeviceName && pmdevOld)
953 {
954 /* We changed settings of one device. Add other devices which were already present */
955 for (i = 0; i < pmdevOld->cDev; i++)
956 {
957 for (j = 0; j < pmdev->cDev; j++)
958 {
959 if (pmdev->dev[j].ppdev->pGraphicsDevice == pmdevOld->dev[i].ppdev->pGraphicsDevice)
960 {
961 if (PDEVOBJ_bDynamicModeChange(pmdevOld->dev[i].ppdev, pmdev->dev[j].ppdev))
962 {
963 PPDEVOBJ tmp = pmdevOld->dev[i].ppdev;
964 pmdevOld->dev[i].ppdev = pmdev->dev[j].ppdev;
965 pmdev->dev[j].ppdev = tmp;
966 }
967 else
968 {
969 ERR("Failed to apply new settings\n");
971 ASSERT(FALSE);
972 }
973 break;
974 }
975 }
976 if (j == pmdev->cDev)
977 {
978 PDEVOBJ_vReference(pmdevOld->dev[i].ppdev);
979 pmdev->dev[pmdev->cDev].ppdev = pmdevOld->dev[i].ppdev;
980 pmdev->cDev++;
981 }
982 }
983 }
984
985 if (pmdev->cDev == 1)
986 {
987 pmdev->ppdevGlobal = pmdev->dev[0].ppdev;
988 }
989 else
990 {
991 /* Enable MultiDriver */
993 if (!pmdev->ppdevGlobal)
994 {
995 WARN("Failed to create meta-device. Using only first display\n");
996 PDEVOBJ_vReference(pmdev->dev[0].ppdev);
997 pmdev->ppdevGlobal = pmdev->dev[0].ppdev;
998 }
999 }
1000
1001 if (pmdevOld)
1002 {
1003 /* Search PDEVs which were in pmdevOld, but are not anymore in pmdev, and disable them */
1004 for (i = 0; i < pmdevOld->cDev; i++)
1005 {
1006 for (j = 0; j < pmdev->cDev; j++)
1007 {
1008 if (pmdev->dev[j].ppdev->pGraphicsDevice == pmdevOld->dev[i].ppdev->pGraphicsDevice)
1009 break;
1010 }
1011 if (j == pmdev->cDev)
1012 PDEVOBJ_bDisableDisplay(pmdevOld->dev[i].ppdev);
1013 }
1014 }
1015 }
1016
1017cleanup:
1018 if (lRet != DISP_CHANGE_SUCCESSFUL)
1019 {
1020 *ppmdevNew = NULL;
1021 if (pmdev)
1022 MDEVOBJ_vDestroy(pmdev);
1023 if (pdm && pdm != RequestedMode)
1025 }
1026
1027 return lRet;
1028}
#define WARN(fmt,...)
Definition: precomp.h:61
#define UNIMPLEMENTED
Definition: debug.h:118
static void cleanup(void)
Definition: main.c:1335
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 GLint GLint j
Definition: glfuncs.h:250
BOOL LDEVOBJ_bProbeAndCaptureDevmode(_Inout_ PGRAPHICS_DEVICE pGraphicsDevice, _In_ PDEVMODEW RequestedMode, _Out_ PDEVMODEW *pSelectedMode, _In_ BOOL bSearchClosestMode)
Definition: ldevobj.c:737
VOID MDEVOBJ_vDestroy(_Inout_ PMDEVOBJ pmdev)
Definition: mdevobj.c:164
PMDEVOBJ MDEVOBJ_Create(_In_opt_ PUNICODE_STRING pustrDeviceName, _In_opt_ PDEVMODEW pdm)
Definition: mdevobj.c:57
BOOL MDEVOBJ_bDisable(_Inout_ PMDEVOBJ pmdev)
Definition: mdevobj.c:29
VOID MDEVOBJ_vEnable(_Inout_ PMDEVOBJ pmdev)
Definition: mdevobj.c:17
PGRAPHICS_DEVICE NTAPI EngpFindGraphicsDevice(_In_opt_ PUNICODE_STRING pustrDevice, _In_ ULONG iDevNum)
Definition: device.c:641
PGRAPHICS_DEVICE gpPrimaryGraphicsDevice
Definition: device.c:15
#define DISP_CHANGE_BADMODE
Definition: winuser.h:195
#define DISP_CHANGE_SUCCESSFUL
Definition: winuser.h:190
#define DISP_CHANGE_BADPARAM
Definition: winuser.h:193
#define DISP_CHANGE_FAILED
Definition: winuser.h:194

Referenced by co_IntInitializeDesktopGraphics().

◆ PDEVOBJ_pSurface()

PSURFACE NTAPI PDEVOBJ_pSurface ( _In_ PPDEVOBJ  ppdev)

◆ PDEVOBJ_sizl()

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

◆ PDEVOBJ_vEnableDisplay()

VOID PDEVOBJ_vEnableDisplay ( _Inout_ PPDEVOBJ  ppdev)

Definition at line 392 of file pdevobj.c.

394{
395 BOOL assertVal;
396
397 if (!(ppdev->flFlags & PDEV_DISABLED))
398 return;
399
400 /* Try to enable display until success */
401 do
402 {
403 TRACE("DrvAssertMode(dhpdev %p, TRUE)\n", ppdev->dhpdev);
404 assertVal = ppdev->pfn.AssertMode(ppdev->dhpdev, TRUE);
405 TRACE("DrvAssertMode(dhpdev %p, TRUE) => %d\n", ppdev->dhpdev, assertVal);
406 } while (!assertVal);
407
408 ppdev->flFlags &= ~PDEV_DISABLED;
409}

Referenced by MDEVOBJ_bDisable(), MDEVOBJ_vEnable(), PDEVOBJ_bSwitchMode(), and PDEVOBJ_Create().

◆ PDEVOBJ_vGetDeviceCaps()

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

◆ PDEVOBJ_vReference()

FORCEINLINE VOID PDEVOBJ_vReference ( _In_ PPDEVOBJ  ppdev)

Definition at line 160 of file pdevobj.h.

162{
163 ASSERT(ppdev);
164
165 /* Fail if the PDEV is being destroyed */
166 if (ppdev->cPdevRefs == 0)
167 {
168 ASSERT(FALSE);
169 return;
170 }
171 ASSERT(ppdev->cPdevRefs > 0);
172
173 InterlockedIncrement(&ppdev->cPdevRefs);
174}
#define InterlockedIncrement
Definition: armddk.h:53

Referenced by DxEngReferenceHdev(), EngpGetPDEV(), GreCreateCompatibleDC(), MDEVOBJ_Create(), NtGdiExtEscape(), NtGdiSaveDC(), PDEVOBJ_Create(), PDEVOBJ_lChangeDisplaySettings(), and UserRefreshDisplay().

◆ PDEVOBJ_vRelease()

VOID NTAPI PDEVOBJ_vRelease ( _Inout_ PPDEVOBJ  ppdev)

Definition at line 105 of file pdevobj.c.

107{
108 /* Lock loader */
110
111 /* Decrease reference count */
112 InterlockedDecrement(&ppdev->cPdevRefs);
113 ASSERT(ppdev->cPdevRefs >= 0);
114
115 /* Check if references are left */
116 if (ppdev->cPdevRefs == 0)
117 {
118 /* Do we have a surface? */
119 if (ppdev->pSurface)
120 {
121 /* Release the surface and let the driver free it */
122 SURFACE_ShareUnlockSurface(ppdev->pSurface);
123 TRACE("DrvDisableSurface(dhpdev %p)\n", ppdev->dhpdev);
124 ppdev->pfn.DisableSurface(ppdev->dhpdev);
125 }
126
127 /* Do we have a palette? */
128 if (ppdev->ppalSurf)
129 {
130 PALETTE_ShareUnlockPalette(ppdev->ppalSurf);
131 }
132
133 /* Check if the PDEV was enabled */
134 if (ppdev->dhpdev != NULL)
135 {
136 /* Disable the PDEV */
137 TRACE("DrvDisablePDEV(dhpdev %p)\n", ppdev->dhpdev);
138 ppdev->pfn.DisablePDEV(ppdev->dhpdev);
139 }
140
141 /* Remove it from list */
142 if (ppdev == gppdevList)
143 {
144 gppdevList = ppdev->ppdevNext;
145 }
146 else if (gppdevList)
147 {
148 PPDEVOBJ ppdevCurrent = gppdevList;
149 BOOL found = FALSE;
150 while (!found && ppdevCurrent->ppdevNext)
151 {
152 if (ppdevCurrent->ppdevNext == ppdev)
153 found = TRUE;
154 else
155 ppdevCurrent = ppdevCurrent->ppdevNext;
156 }
157 if (found)
158 ppdevCurrent->ppdevNext = ppdev->ppdevNext;
159 }
160
161 /* Unload display driver */
162 EngUnloadImage(ppdev->pldev);
163
164 /* Free it */
165 PDEVOBJ_vDeletePDEV(ppdev);
166 }
167
168 /* Unlock loader */
170}
#define InterlockedDecrement
Definition: armddk.h:52
static VOID PDEVOBJ_vDeletePDEV(PPDEVOBJ ppdev)
Definition: pdevobj.c:92
#define SURFACE_ShareUnlockSurface(pBMObj)
Definition: surface.h:102
#define PALETTE_ShareUnlockPalette(ppal)
Definition: palette.h:59

Referenced by DC_vCleanup(), DxEngUnreferenceHdev(), GreCreateCompatibleDC(), GreOpenDCW(), MDEVOBJ_vDestroy(), NtGdiExtEscape(), PDEVOBJ_bSwitchMode(), PDEVOBJ_Create(), UserChangeDisplaySettings(), UserEnumCurrentDisplaySettings(), UserEnumDisplaySettings(), and UserRefreshDisplay().