ReactOS 0.4.15-dev-7889-g76290a6
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 799 of file pdevobj.c.

801{
802 UNICODE_STRING ustrCurrent;
803 PPDEVOBJ ppdev = NULL;
804 PGRAPHICS_DEVICE pGraphicsDevice;
805 ULONG i;
806
807 /* Acquire PDEV lock */
809
810 /* Did the caller pass a device name? */
811 if (pustrDeviceName)
812 {
813 /* Loop all present PDEVs */
814 for (i = 0; i < gpmdev->cDev; i++)
815 {
816 /* Get a pointer to the GRAPHICS_DEVICE */
817 pGraphicsDevice = gpmdev->dev[i].ppdev->pGraphicsDevice;
818
819 /* Compare the name */
820 RtlInitUnicodeString(&ustrCurrent, pGraphicsDevice->szWinDeviceName);
821 if (RtlEqualUnicodeString(pustrDeviceName, &ustrCurrent, FALSE))
822 {
823 /* Found! */
824 ppdev = gpmdev->dev[i].ppdev;
825 break;
826 }
827 }
828 }
829 else if (gpmdev)
830 {
831 /* Otherwise use the primary PDEV */
832 ppdev = gpmdev->ppdevGlobal;
833 }
834
835 /* Did we find one? */
836 if (ppdev)
837 {
838 /* Yes, reference the PDEV */
839 PDEVOBJ_vReference(ppdev);
840 }
841
842 /* Release PDEV lock */
844
845 return ppdev;
846}
#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 410 of file pdevobj.c.

412{
413 BOOL assertVal;
414
415 if (ppdev->flFlags & PDEV_DISABLED)
416 return TRUE;
417
419
420 TRACE("DrvAssertMode(dhpdev %p, FALSE)\n", ppdev->dhpdev);
421 assertVal = ppdev->pfn.AssertMode(ppdev->dhpdev, FALSE);
422 TRACE("DrvAssertMode(dhpdev %p, FALSE) => %d\n", ppdev->dhpdev, assertVal);
423
424 if (assertVal)
425 ppdev->flFlags |= PDEV_DISABLED;
426
427 return assertVal;
428}
#define TRUE
Definition: types.h:120
unsigned int BOOL
Definition: ntddk_ex.h:94
VOID PDEVOBJ_vSuspendDirectDraw(_Inout_ PPDEVOBJ ppdev)
Definition: pdevobj.c:367
#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 704 of file pdevobj.c.

707{
708 PPDEVOBJ ppdevTmp;
710 BOOL retval = FALSE;
711
712 /* Lock the PDEV */
714
715 /* And everything else */
717
718 DPRINT1("PDEVOBJ_bSwitchMode, ppdev = %p, pSurface = %p\n", ppdev, ppdev->pSurface);
719
720 // Lookup the GraphicsDevice + select DEVMODE
721 // pdm = LDEVOBJ_bProbeAndCaptureDevmode(ppdev, pdm);
722
723 /* 1. Temporarily disable the current PDEV and reset video to its default mode */
724 if (!PDEVOBJ_bDisableDisplay(ppdev))
725 {
726 DPRINT1("PDEVOBJ_bDisableDisplay() failed\n");
727 /* Resume DirectDraw in case of failure */
729 goto leave;
730 }
731
732 /* 2. Create new PDEV */
733 ppdevTmp = PDEVOBJ_Create(ppdev->pGraphicsDevice, pdm, 0, LDEV_DEVICE_DISPLAY);
734 if (!ppdevTmp)
735 {
736 DPRINT1("Failed to create a new PDEV\n");
737 goto leave2;
738 }
739
740 /* 3. Create a new surface */
741 pSurface = PDEVOBJ_pSurface(ppdevTmp);
742 if (!pSurface)
743 {
744 DPRINT1("PDEVOBJ_pSurface failed\n");
745 PDEVOBJ_vRelease(ppdevTmp);
746 goto leave2;
747 }
748
749 /* 4. Temporarily suspend DirectDraw for mode change */
752
753 /* 5. Switch the PDEVs */
754 if (!PDEVOBJ_bDynamicModeChange(ppdev, ppdevTmp))
755 {
756 DPRINT1("PDEVOBJ_bDynamicModeChange() failed\n");
757 PDEVOBJ_vRelease(ppdevTmp);
758 goto leave2;
759 }
760
761 /* 6. Resume DirectDraw */
764
765 /* Release temp PDEV */
766 PDEVOBJ_vRelease(ppdevTmp);
767
768 /* Re-initialize DirectDraw data */
769 ppdev->pEDDgpl->hDev = (HDEV)ppdev;
770 ppdev->pEDDgpl->dhpdev = ppdev->dhpdev;
771
772 /* Update primary display capabilities */
773 if (ppdev == gpmdev->ppdevGlobal)
774 {
775 PDEVOBJ_vGetDeviceCaps(ppdev, &GdiHandleTable->DevCaps);
776 }
777
778 /* Success! */
779 retval = TRUE;
780
781leave2:
782 /* Set the new video mode, or restore the original one in case of failure */
784
785leave:
786 /* Unlock everything else */
788 /* Unlock the PDEV */
790
791 DPRINT1("leave, ppdev = %p, pSurface = %p\n", ppdev, ppdev->pSurface);
792
793 return retval;
794}
#define DPRINT1
Definition: precomp.h:8
#define leave
Definition: btrfs_drv.h:138
@ LDEV_DEVICE_DISPLAY
Definition: ldevobj.h:8
VOID PDEVOBJ_vResumeDirectDraw(_Inout_ PPDEVOBJ ppdev)
Definition: pdevobj.c:356
BOOL PDEVOBJ_bDisableDisplay(_Inout_ PPDEVOBJ ppdev)
Definition: pdevobj.c:410
PPDEVOBJ PDEVOBJ_Create(_In_opt_ PGRAPHICS_DEVICE pGraphicsDevice, _In_opt_ PDEVMODEW pdm, _In_ ULONG dwAccelerationLevel, _In_ ULONG ldevtype)
Definition: pdevobj.c:463
BOOL NTAPI PDEVOBJ_bDynamicModeChange(PPDEVOBJ ppdev, PPDEVOBJ ppdev2)
Definition: pdevobj.c:645
VOID NTAPI PDEVOBJ_vRelease(_Inout_ PPDEVOBJ ppdev)
Definition: pdevobj.c:105
VOID NTAPI PDEVOBJ_vGetDeviceCaps(IN PPDEVOBJ ppdev, OUT PDEVCAPS pDevCaps)
Definition: pdevobj.c:1037
PSURFACE NTAPI PDEVOBJ_pSurface(PPDEVOBJ ppdev)
Definition: pdevobj.c:311
VOID PDEVOBJ_vEnableDisplay(_Inout_ PPDEVOBJ ppdev)
Definition: pdevobj.c:390
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 463 of file pdevobj.c.

468{
469 PPDEVOBJ ppdev, ppdevMatch = NULL;
470 PLDEVOBJ pldev;
472
473 TRACE("PDEVOBJ_Create(%p %p %d)\n", pGraphicsDevice, pdm, ldevtype);
474
475 if (ldevtype != LDEV_DEVICE_META)
476 {
477 ASSERT(pGraphicsDevice);
478 ASSERT(pdm);
479 /* Search if we already have a PPDEV with the required characteristics.
480 * We will compare the graphics device, the devmode and the desktop
481 */
482 for (ppdev = gppdevList; ppdev; ppdev = ppdev->ppdevNext)
483 {
484 if (ppdev->pGraphicsDevice == pGraphicsDevice)
485 {
486 PDEVOBJ_vReference(ppdev);
487
488 if (RtlEqualMemory(pdm, ppdev->pdmwDev, sizeof(DEVMODEW)) &&
489 ppdev->dwAccelerationLevel == dwAccelerationLevel)
490 {
491 PDEVOBJ_vReference(ppdev);
492 ppdevMatch = ppdev;
493 }
494 else
495 {
497 }
498
499 PDEVOBJ_vRelease(ppdev);
500 }
501 }
502
503 if (ppdevMatch)
504 {
505 PDEVOBJ_vEnableDisplay(ppdevMatch);
506
507 return ppdevMatch;
508 }
509 }
510
511 /* Try to get a display driver */
512 if (ldevtype == LDEV_DEVICE_META)
513 pldev = LDEVOBJ_pLoadInternal(MultiEnableDriver, ldevtype);
514 else
515 pldev = LDEVOBJ_pLoadDriver(pdm->dmDeviceName, ldevtype);
516 if (!pldev)
517 {
518 ERR("Could not load display driver '%S'\n",
519 (ldevtype == LDEV_DEVICE_META) ? L"" : pdm->dmDeviceName);
520 return NULL;
521 }
522
523 /* Allocate a new PDEVOBJ */
524 ppdev = PDEVOBJ_AllocPDEV();
525 if (!ppdev)
526 {
527 ERR("failed to allocate a PDEV\n");
528 return NULL;
529 }
530
531 if (ldevtype != LDEV_DEVICE_META)
532 {
533 ppdev->pGraphicsDevice = pGraphicsDevice;
534
535 // DxEngGetHdevData asks for Graphics DeviceObject in hSpooler field
536 ppdev->hSpooler = ppdev->pGraphicsDevice->DeviceObject;
537
538 /* Keep selected resolution */
539 if (ppdev->pdmwDev)
541 ppdev->pdmwDev = ExAllocatePoolWithTag(PagedPool, pdm->dmSize + pdm->dmDriverExtra, GDITAG_DEVMODE);
542 if (ppdev->pdmwDev)
543 {
544 RtlCopyMemory(ppdev->pdmwDev, pdm, pdm->dmSize + pdm->dmDriverExtra);
545 /* FIXME: this must be done in a better way */
547 }
548 }
549
550 /* FIXME! */
551 ppdev->flFlags = PDEV_DISPLAY;
552
553 /* HACK: Don't use the pointer */
554 ppdev->Pointer.Exclude.right = -1;
555
556 /* Initialize PDEV */
557 ppdev->pldev = pldev;
558 ppdev->dwAccelerationLevel = dwAccelerationLevel;
559
560 /* Copy the function table */
561 if ((ldevtype == LDEV_DEVICE_DISPLAY && dwAccelerationLevel >= 5) ||
562 pdm->dmFields & (DM_PANNINGWIDTH | DM_PANNINGHEIGHT))
563 {
564 ULONG i;
565
566 /* Initialize missing fields */
567 if (!(pdm->dmFields & DM_PANNINGWIDTH))
568 pdm->dmPanningWidth = pdm->dmPelsWidth;
569 if (!(pdm->dmFields & DM_PANNINGHEIGHT))
570 pdm->dmPanningHeight = pdm->dmPelsHeight;
571
572 /* Replace vtable by panning vtable */
573 for (i = 0; i < gPanDispDrvCount; i++)
575 }
576 else
577 {
578 ppdev->pfn = ppdev->pldev->pfn;
579 }
580
581 /* Call the driver to enable the PDEV */
582 if (!PDEVOBJ_bEnablePDEV(ppdev, pdm, NULL))
583 {
584 ERR("Failed to enable PDEV!\n");
585 PDEVOBJ_vRelease(ppdev);
586 EngUnloadImage(pldev);
587 return NULL;
588 }
589
590 /* Tell the driver that the PDEV is ready */
592
593 /* Create the initial surface */
594 pSurface = PDEVOBJ_pSurface(ppdev);
595 if (!pSurface)
596 {
597 ERR("Failed to create surface\n");
598 PDEVOBJ_vRelease(ppdev);
599 EngUnloadImage(pldev);
600 return NULL;
601 }
602
603 /* Enable DirectDraw */
604 if (!PDEVOBJ_bEnableDirectDraw(ppdev))
605 {
606 ERR("Failed to enable DirectDraw\n");
607 PDEVOBJ_vRelease(ppdev);
608 EngUnloadImage(pldev);
609 return NULL;
610 }
611
612 /* Remove some acceleration capabilities from driver */
614
615 /* Set MovePointer function */
616 ppdev->pfnMovePointer = ppdev->pfn.MovePointer;
617 if (!ppdev->pfnMovePointer)
619
620 /* Insert the PDEV into the list */
621 ppdev->ppdevNext = gppdevList;
622 gppdevList = ppdev;
623
624 /* Return the PDEV */
625 return ppdev;
626}
#define ERR(fmt,...)
Definition: debug.h:110
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
#define PagedPool
Definition: env_spec_w32.h:308
#define RtlEqualMemory(a, b, c)
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
BOOL PDEVOBJ_bEnableDirectDraw(_Inout_ PPDEVOBJ ppdev)
Definition: pdevobj.c:341
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 849 of file pdevobj.c.

855{
856 PGRAPHICS_DEVICE pGraphicsDevice = NULL;
857 PMDEVOBJ pmdev = NULL;
858 PDEVMODEW pdm = NULL;
860 ULONG i, j;
861
862 TRACE("PDEVOBJ_lChangeDisplaySettings('%wZ' '%dx%dx%d (%d Hz)' %p %p)\n",
863 pustrDeviceName,
864 RequestedMode ? RequestedMode->dmPelsWidth : 0,
865 RequestedMode ? RequestedMode->dmPelsHeight : 0,
866 RequestedMode ? RequestedMode->dmBitsPerPel : 0,
867 RequestedMode ? RequestedMode->dmDisplayFrequency : 0,
868 pmdevOld, ppmdevNew);
869
870 if (pustrDeviceName)
871 {
872 pGraphicsDevice = EngpFindGraphicsDevice(pustrDeviceName, 0);
873 if (!pGraphicsDevice)
874 {
875 ERR("Wrong device name provided: '%wZ'\n", pustrDeviceName);
877 goto cleanup;
878 }
879 }
880 else if (RequestedMode)
881 {
882 pGraphicsDevice = gpPrimaryGraphicsDevice;
883 if (!pGraphicsDevice)
884 {
885 ERR("Wrong device'\n");
887 goto cleanup;
888 }
889 }
890
891 if (pGraphicsDevice)
892 {
893 if (!LDEVOBJ_bProbeAndCaptureDevmode(pGraphicsDevice, RequestedMode, &pdm, bSearchClosestMode))
894 {
895 ERR("DrvProbeAndCaptureDevmode() failed\n");
896 lRet = DISP_CHANGE_BADMODE;
897 goto cleanup;
898 }
899 }
900
901 /* Here, we know that input parameters were correct */
902
903 {
904 /* Create new MDEV. Note that if we provide a device name,
905 * MDEV will only contain one device.
906 * */
907
908 if (pmdevOld)
909 {
910 /* Disable old MDEV */
911 if (MDEVOBJ_bDisable(pmdevOld))
912 {
913 /* Create new MDEV. On failure, reenable old MDEV */
914 pmdev = MDEVOBJ_Create(pustrDeviceName, pdm);
915 if (!pmdev)
916 MDEVOBJ_vEnable(pmdevOld);
917 }
918 }
919 else
920 {
921 pmdev = MDEVOBJ_Create(pustrDeviceName, pdm);
922 }
923
924 if (!pmdev)
925 {
926 ERR("Failed to create new MDEV\n");
927 lRet = DISP_CHANGE_FAILED;
928 goto cleanup;
929 }
930
932 *ppmdevNew = pmdev;
933
934 /* We now have to do the mode switch */
935
936 if (pustrDeviceName && pmdevOld)
937 {
938 /* We changed settings of one device. Add other devices which were already present */
939 for (i = 0; i < pmdevOld->cDev; i++)
940 {
941 for (j = 0; j < pmdev->cDev; j++)
942 {
943 if (pmdev->dev[j].ppdev->pGraphicsDevice == pmdevOld->dev[i].ppdev->pGraphicsDevice)
944 {
945 if (PDEVOBJ_bDynamicModeChange(pmdevOld->dev[i].ppdev, pmdev->dev[j].ppdev))
946 {
947 PPDEVOBJ tmp = pmdevOld->dev[i].ppdev;
948 pmdevOld->dev[i].ppdev = pmdev->dev[j].ppdev;
949 pmdev->dev[j].ppdev = tmp;
950 }
951 else
952 {
953 ERR("Failed to apply new settings\n");
955 ASSERT(FALSE);
956 }
957 break;
958 }
959 }
960 if (j == pmdev->cDev)
961 {
962 PDEVOBJ_vReference(pmdevOld->dev[i].ppdev);
963 pmdev->dev[pmdev->cDev].ppdev = pmdevOld->dev[i].ppdev;
964 pmdev->cDev++;
965 }
966 }
967 }
968
969 if (pmdev->cDev == 1)
970 {
971 pmdev->ppdevGlobal = pmdev->dev[0].ppdev;
972 }
973 else
974 {
975 /* Enable MultiDriver */
977 if (!pmdev->ppdevGlobal)
978 {
979 WARN("Failed to create meta-device. Using only first display\n");
980 PDEVOBJ_vReference(pmdev->dev[0].ppdev);
981 pmdev->ppdevGlobal = pmdev->dev[0].ppdev;
982 }
983 }
984
985 if (pmdevOld)
986 {
987 /* Search PDEVs which were in pmdevOld, but are not anymore in pmdev, and disable them */
988 for (i = 0; i < pmdevOld->cDev; i++)
989 {
990 for (j = 0; j < pmdev->cDev; j++)
991 {
992 if (pmdev->dev[j].ppdev->pGraphicsDevice == pmdevOld->dev[i].ppdev->pGraphicsDevice)
993 break;
994 }
995 if (j == pmdev->cDev)
996 PDEVOBJ_bDisableDisplay(pmdevOld->dev[i].ppdev);
997 }
998 }
999 }
1000
1001cleanup:
1002 if (lRet != DISP_CHANGE_SUCCESSFUL)
1003 {
1004 *ppmdevNew = NULL;
1005 if (pmdev)
1006 MDEVOBJ_vDestroy(pmdev);
1007 if (pdm && pdm != RequestedMode)
1009 }
1010
1011 return lRet;
1012}
#define UNIMPLEMENTED
Definition: debug.h:115
#define WARN(fmt,...)
Definition: debug.h:112
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 390 of file pdevobj.c.

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

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().