ReactOS 0.4.15-dev-6068-g8061a6f
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 726 of file pdevobj.c.

728{
729 UNICODE_STRING ustrCurrent;
730 PPDEVOBJ ppdev = NULL;
731 PGRAPHICS_DEVICE pGraphicsDevice;
732 ULONG i;
733
734 /* Acquire PDEV lock */
736
737 /* Did the caller pass a device name? */
738 if (pustrDeviceName)
739 {
740 /* Loop all present PDEVs */
741 for (i = 0; i < gpmdev->cDev; i++)
742 {
743 /* Get a pointer to the GRAPHICS_DEVICE */
744 pGraphicsDevice = gpmdev->dev[i].ppdev->pGraphicsDevice;
745
746 /* Compare the name */
747 RtlInitUnicodeString(&ustrCurrent, pGraphicsDevice->szWinDeviceName);
748 if (RtlEqualUnicodeString(pustrDeviceName, &ustrCurrent, FALSE))
749 {
750 /* Found! */
751 ppdev = gpmdev->dev[i].ppdev;
752 break;
753 }
754 }
755 }
756 else if (gpmdev)
757 {
758 /* Otherwise use the primary PDEV */
759 ppdev = gpmdev->ppdevGlobal;
760 }
761
762 /* Did we find one? */
763 if (ppdev)
764 {
765 /* Yes, reference the PDEV */
766 PDEVOBJ_vReference(ppdev);
767 }
768
769 /* Release PDEV lock */
771
772 return ppdev;
773}
#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:15
FORCEINLINE VOID PDEVOBJ_vReference(_In_ PPDEVOBJ ppdev)
Definition: pdevobj.h:161
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 30 of file pdevobj.c.

31{
34 return STATUS_SUCCESS;
35}
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 360 of file pdevobj.c.

362{
363 BOOL assertVal;
364
365 if (ppdev->flFlags & PDEV_DISABLED)
366 return TRUE;
367
368 TRACE("DrvAssertMode(dhpdev %p, FALSE)\n", ppdev->dhpdev);
369 assertVal = ppdev->pfn.AssertMode(ppdev->dhpdev, FALSE);
370 TRACE("DrvAssertMode(dhpdev %p, FALSE) => %d\n", ppdev->dhpdev, assertVal);
371
372 if (assertVal)
373 ppdev->flFlags |= PDEV_DISABLED;
374
375 return assertVal;
376}
#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 640 of file pdevobj.c.

643{
644 PPDEVOBJ ppdevTmp;
646 BOOL retval = FALSE;
647
648 /* Lock the PDEV */
650
651 /* And everything else */
653
654 DPRINT1("PDEVOBJ_bSwitchMode, ppdev = %p, pSurface = %p\n", ppdev, ppdev->pSurface);
655
656 // Lookup the GraphicsDevice + select DEVMODE
657 // pdm = LDEVOBJ_bProbeAndCaptureDevmode(ppdev, pdm);
658
659 /* 1. Temporarily disable the current PDEV and reset video to its default mode */
660 if (!PDEVOBJ_bDisableDisplay(ppdev))
661 {
662 DPRINT1("PDEVOBJ_bDisableDisplay() failed\n");
663 goto leave;
664 }
665
666 /* 2. Create new PDEV */
667 ppdevTmp = PDEVOBJ_Create(ppdev->pGraphicsDevice, pdm, 0, LDEV_DEVICE_DISPLAY);
668 if (!ppdevTmp)
669 {
670 DPRINT1("Failed to create a new PDEV\n");
671 goto leave2;
672 }
673
674 /* 3. Create a new surface */
675 pSurface = PDEVOBJ_pSurface(ppdevTmp);
676 if (!pSurface)
677 {
678 DPRINT1("PDEVOBJ_pSurface failed\n");
679 PDEVOBJ_vRelease(ppdevTmp);
680 goto leave2;
681 }
682
683 /* 4. Get DirectDraw information */
684 /* 5. Enable DirectDraw Not traced */
685 /* 6. Copy old PDEV state to new PDEV instance */
686
687 /* 7. Switch the PDEVs */
688 if (!PDEVOBJ_bDynamicModeChange(ppdev, ppdevTmp))
689 {
690 DPRINT1("PDEVOBJ_bDynamicModeChange() failed\n");
691 PDEVOBJ_vRelease(ppdevTmp);
692 goto leave2;
693 }
694
695 /* 8. Disable DirectDraw */
696
697 PDEVOBJ_vRelease(ppdevTmp);
698
699 /* Update primary display capabilities */
700 if (ppdev == gpmdev->ppdevGlobal)
701 {
702 PDEVOBJ_vGetDeviceCaps(ppdev, &GdiHandleTable->DevCaps);
703 }
704
705 /* Success! */
706 retval = TRUE;
707
708leave2:
709 /* Set the new video mode, or restore the original one in case of failure */
711
712leave:
713 /* Unlock everything else */
715 /* Unlock the PDEV */
717
718 DPRINT1("leave, ppdev = %p, pSurface = %p\n", ppdev, ppdev->pSurface);
719
720 return retval;
721}
#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:360
PPDEVOBJ PDEVOBJ_Create(_In_opt_ PGRAPHICS_DEVICE pGraphicsDevice, _In_opt_ PDEVMODEW pdm, _In_ ULONG dwAccelerationLevel, _In_ ULONG ldevtype)
Definition: pdevobj.c:411
BOOL NTAPI PDEVOBJ_bDynamicModeChange(PPDEVOBJ ppdev, PPDEVOBJ ppdev2)
Definition: pdevobj.c:584
VOID NTAPI PDEVOBJ_vRelease(_Inout_ PPDEVOBJ ppdev)
Definition: pdevobj.c:104
VOID NTAPI PDEVOBJ_vGetDeviceCaps(IN PPDEVOBJ ppdev, OUT PDEVCAPS pDevCaps)
Definition: pdevobj.c:964
PSURFACE NTAPI PDEVOBJ_pSurface(PPDEVOBJ ppdev)
Definition: pdevobj.c:310
VOID PDEVOBJ_vEnableDisplay(_Inout_ PPDEVOBJ ppdev)
Definition: pdevobj.c:340
PSURFACE pSurface
Definition: pdevobj.h:124
HSEMAPHORE hsemDevLock
Definition: pdevobj.h:89
#define GdiHandleTable
Definition: win32nt.h:35
_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 411 of file pdevobj.c.

416{
417 PPDEVOBJ ppdev, ppdevMatch = NULL;
418 PLDEVOBJ pldev;
420
421 TRACE("PDEVOBJ_Create(%p %p %d)\n", pGraphicsDevice, pdm, ldevtype);
422
423 if (ldevtype != LDEV_DEVICE_META)
424 {
425 ASSERT(pGraphicsDevice);
426 ASSERT(pdm);
427 /* Search if we already have a PPDEV with the required characteristics.
428 * We will compare the graphics device, the devmode and the desktop
429 */
430 for (ppdev = gppdevList; ppdev; ppdev = ppdev->ppdevNext)
431 {
432 if (ppdev->pGraphicsDevice == pGraphicsDevice)
433 {
434 PDEVOBJ_vReference(ppdev);
435
436 if (RtlEqualMemory(pdm, ppdev->pdmwDev, sizeof(DEVMODEW)) &&
437 ppdev->dwAccelerationLevel == dwAccelerationLevel)
438 {
439 PDEVOBJ_vReference(ppdev);
440 ppdevMatch = ppdev;
441 }
442 else
443 {
445 }
446
447 PDEVOBJ_vRelease(ppdev);
448 }
449 }
450
451 if (ppdevMatch)
452 {
453 PDEVOBJ_vEnableDisplay(ppdevMatch);
454
455 return ppdevMatch;
456 }
457 }
458
459 /* Try to get a display driver */
460 if (ldevtype == LDEV_DEVICE_META)
461 pldev = LDEVOBJ_pLoadInternal(MultiEnableDriver, ldevtype);
462 else
463 pldev = LDEVOBJ_pLoadDriver(pdm->dmDeviceName, ldevtype);
464 if (!pldev)
465 {
466 ERR("Could not load display driver '%S'\n",
467 (ldevtype == LDEV_DEVICE_META) ? L"" : pdm->dmDeviceName);
468 return NULL;
469 }
470
471 /* Allocate a new PDEVOBJ */
472 ppdev = PDEVOBJ_AllocPDEV();
473 if (!ppdev)
474 {
475 ERR("failed to allocate a PDEV\n");
476 return NULL;
477 }
478
479 if (ldevtype != LDEV_DEVICE_META)
480 {
481 ppdev->pGraphicsDevice = pGraphicsDevice;
482
483 // DxEngGetHdevData asks for Graphics DeviceObject in hSpooler field
484 ppdev->hSpooler = ppdev->pGraphicsDevice->DeviceObject;
485
486 /* Keep selected resolution */
487 if (ppdev->pdmwDev)
489 ppdev->pdmwDev = ExAllocatePoolWithTag(PagedPool, pdm->dmSize + pdm->dmDriverExtra, GDITAG_DEVMODE);
490 if (ppdev->pdmwDev)
491 {
492 RtlCopyMemory(ppdev->pdmwDev, pdm, pdm->dmSize + pdm->dmDriverExtra);
493 /* FIXME: this must be done in a better way */
495 }
496 }
497
498 /* FIXME! */
499 ppdev->flFlags = PDEV_DISPLAY;
500
501 /* HACK: Don't use the pointer */
502 ppdev->Pointer.Exclude.right = -1;
503
504 /* Initialize PDEV */
505 ppdev->pldev = pldev;
506 ppdev->dwAccelerationLevel = dwAccelerationLevel;
507
508 /* Copy the function table */
509 if ((ldevtype == LDEV_DEVICE_DISPLAY && dwAccelerationLevel >= 5) ||
510 pdm->dmFields & (DM_PANNINGWIDTH | DM_PANNINGHEIGHT))
511 {
512 ULONG i;
513
514 /* Initialize missing fields */
515 if (!(pdm->dmFields & DM_PANNINGWIDTH))
516 pdm->dmPanningWidth = pdm->dmPelsWidth;
517 if (!(pdm->dmFields & DM_PANNINGHEIGHT))
518 pdm->dmPanningHeight = pdm->dmPelsHeight;
519
520 /* Replace vtable by panning vtable */
521 for (i = 0; i < gPanDispDrvCount; i++)
523 }
524 else
525 {
526 ppdev->pfn = ppdev->pldev->pfn;
527 }
528
529 /* Call the driver to enable the PDEV */
530 if (!PDEVOBJ_bEnablePDEV(ppdev, pdm, NULL))
531 {
532 ERR("Failed to enable PDEV!\n");
533 PDEVOBJ_vRelease(ppdev);
534 EngUnloadImage(pldev);
535 return NULL;
536 }
537
538 /* Tell the driver that the PDEV is ready */
540
541 /* Create the initial surface */
542 pSurface = PDEVOBJ_pSurface(ppdev);
543 if (!pSurface)
544 {
545 ERR("Failed to create surface\n");
546 PDEVOBJ_vRelease(ppdev);
547 EngUnloadImage(pldev);
548 return NULL;
549 }
550
551 /* Remove some acceleration capabilities from driver */
553
554 /* Set MovePointer function */
555 ppdev->pfnMovePointer = ppdev->pfn.MovePointer;
556 if (!ppdev->pfnMovePointer)
558
559 /* Insert the PDEV into the list */
560 ppdev->ppdevNext = gppdevList;
561 gppdevList = ppdev;
562
563 /* Return the PDEV */
564 return ppdev;
565}
#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:173
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:254
DRVFN gPanDispDrvFn[]
Definition: pandisp.c:477
static PPDEVOBJ gppdevList
Definition: pdevobj.c:14
PPDEVOBJ PDEVOBJ_AllocPDEV(VOID)
Definition: pdevobj.c:62
ULONG gPanDispDrvCount
Definition: pandisp.c:501
VOID NTAPI PDEVOBJ_vCompletePDEV(PPDEVOBJ ppdev)
Definition: pdevobj.c:244
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:144
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 776 of file pdevobj.c.

782{
783 PGRAPHICS_DEVICE pGraphicsDevice = NULL;
784 PMDEVOBJ pmdev = NULL;
785 PDEVMODEW pdm = NULL;
787 ULONG i, j;
788
789 TRACE("PDEVOBJ_lChangeDisplaySettings('%wZ' '%dx%dx%d (%d Hz)' %p %p)\n",
790 pustrDeviceName,
791 RequestedMode ? RequestedMode->dmPelsWidth : 0,
792 RequestedMode ? RequestedMode->dmPelsHeight : 0,
793 RequestedMode ? RequestedMode->dmBitsPerPel : 0,
794 RequestedMode ? RequestedMode->dmDisplayFrequency : 0,
795 pmdevOld, ppmdevNew);
796
797 if (pustrDeviceName)
798 {
799 pGraphicsDevice = EngpFindGraphicsDevice(pustrDeviceName, 0);
800 if (!pGraphicsDevice)
801 {
802 ERR("Wrong device name provided: '%wZ'\n", pustrDeviceName);
804 goto cleanup;
805 }
806 }
807 else if (RequestedMode)
808 {
809 pGraphicsDevice = gpPrimaryGraphicsDevice;
810 if (!pGraphicsDevice)
811 {
812 ERR("Wrong device'\n");
814 goto cleanup;
815 }
816 }
817
818 if (pGraphicsDevice)
819 {
820 if (!LDEVOBJ_bProbeAndCaptureDevmode(pGraphicsDevice, RequestedMode, &pdm, bSearchClosestMode))
821 {
822 ERR("DrvProbeAndCaptureDevmode() failed\n");
823 lRet = DISP_CHANGE_BADMODE;
824 goto cleanup;
825 }
826 }
827
828 /* Here, we know that input parameters were correct */
829
830 {
831 /* Create new MDEV. Note that if we provide a device name,
832 * MDEV will only contain one device.
833 * */
834
835 if (pmdevOld)
836 {
837 /* Disable old MDEV */
838 if (MDEVOBJ_bDisable(pmdevOld))
839 {
840 /* Create new MDEV. On failure, reenable old MDEV */
841 pmdev = MDEVOBJ_Create(pustrDeviceName, pdm);
842 if (!pmdev)
843 MDEVOBJ_vEnable(pmdevOld);
844 }
845 }
846 else
847 {
848 pmdev = MDEVOBJ_Create(pustrDeviceName, pdm);
849 }
850
851 if (!pmdev)
852 {
853 ERR("Failed to create new MDEV\n");
854 lRet = DISP_CHANGE_FAILED;
855 goto cleanup;
856 }
857
859 *ppmdevNew = pmdev;
860
861 /* We now have to do the mode switch */
862
863 if (pustrDeviceName && pmdevOld)
864 {
865 /* We changed settings of one device. Add other devices which were already present */
866 for (i = 0; i < pmdevOld->cDev; i++)
867 {
868 for (j = 0; j < pmdev->cDev; j++)
869 {
870 if (pmdev->dev[j].ppdev->pGraphicsDevice == pmdevOld->dev[i].ppdev->pGraphicsDevice)
871 {
872 if (PDEVOBJ_bDynamicModeChange(pmdevOld->dev[i].ppdev, pmdev->dev[j].ppdev))
873 {
874 PPDEVOBJ tmp = pmdevOld->dev[i].ppdev;
875 pmdevOld->dev[i].ppdev = pmdev->dev[j].ppdev;
876 pmdev->dev[j].ppdev = tmp;
877 }
878 else
879 {
880 ERR("Failed to apply new settings\n");
882 ASSERT(FALSE);
883 }
884 break;
885 }
886 }
887 if (j == pmdev->cDev)
888 {
889 PDEVOBJ_vReference(pmdevOld->dev[i].ppdev);
890 pmdev->dev[pmdev->cDev].ppdev = pmdevOld->dev[i].ppdev;
891 pmdev->cDev++;
892 }
893 }
894 }
895
896 if (pmdev->cDev == 1)
897 {
898 pmdev->ppdevGlobal = pmdev->dev[0].ppdev;
899 }
900 else
901 {
902 /* Enable MultiDriver */
904 if (!pmdev->ppdevGlobal)
905 {
906 WARN("Failed to create meta-device. Using only first display\n");
907 PDEVOBJ_vReference(pmdev->dev[0].ppdev);
908 pmdev->ppdevGlobal = pmdev->dev[0].ppdev;
909 }
910 }
911
912 if (pmdevOld)
913 {
914 /* Search PDEVs which were in pmdevOld, but are not anymore in pmdev, and disable them */
915 for (i = 0; i < pmdevOld->cDev; i++)
916 {
917 for (j = 0; j < pmdev->cDev; j++)
918 {
919 if (pmdev->dev[j].ppdev->pGraphicsDevice == pmdevOld->dev[i].ppdev->pGraphicsDevice)
920 break;
921 }
922 if (j == pmdev->cDev)
923 PDEVOBJ_bDisableDisplay(pmdevOld->dev[i].ppdev);
924 }
925 }
926 }
927
928cleanup:
929 if (lRet != DISP_CHANGE_SUCCESSFUL)
930 {
931 *ppmdevNew = NULL;
932 if (pmdev)
933 MDEVOBJ_vDestroy(pmdev);
934 if (pdm && pdm != RequestedMode)
936 }
937
938 return lRet;
939}
#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 340 of file pdevobj.c.

342{
343 BOOL assertVal;
344
345 if (!(ppdev->flFlags & PDEV_DISABLED))
346 return;
347
348 /* Try to enable display until success */
349 do
350 {
351 TRACE("DrvAssertMode(dhpdev %p, TRUE)\n", ppdev->dhpdev);
352 assertVal = ppdev->pfn.AssertMode(ppdev->dhpdev, TRUE);
353 TRACE("DrvAssertMode(dhpdev %p, TRUE) => %d\n", ppdev->dhpdev, assertVal);
354 } while (!assertVal);
355
356 ppdev->flFlags &= ~PDEV_DISABLED;
357}

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 161 of file pdevobj.h.

163{
164 ASSERT(ppdev);
165
166 /* Fail if the PDEV is being destroyed */
167 if (ppdev->cPdevRefs == 0)
168 {
169 ASSERT(FALSE);
170 return;
171 }
172 ASSERT(ppdev->cPdevRefs > 0);
173
174 InterlockedIncrement(&ppdev->cPdevRefs);
175}
#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 104 of file pdevobj.c.

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