ReactOS  0.4.15-dev-3203-gacde1e0
pdevobj.c File Reference
#include <win32k.h>
#include <debug.h>
Include dependency graph for pdevobj.c:

Go to the source code of this file.

Macros

#define NDEBUG
 

Functions

NTSTATUS NTAPI InitPDEVImpl (VOID)
 
PPDEVOBJ PDEVOBJ_AllocPDEV (VOID)
 
static VOID PDEVOBJ_vDeletePDEV (PPDEVOBJ ppdev)
 
VOID NTAPI PDEVOBJ_vRelease (_Inout_ PPDEVOBJ ppdev)
 
BOOL NTAPI PDEVOBJ_bEnablePDEV (PPDEVOBJ ppdev, PDEVMODEW pdevmode, PWSTR pwszLogAddress)
 
VOID NTAPI PDEVOBJ_vCompletePDEV (PPDEVOBJ ppdev)
 
PSURFACE NTAPI PDEVOBJ_pSurface (PPDEVOBJ ppdev)
 
VOID NTAPI PDEVOBJ_vRefreshModeList (PPDEVOBJ ppdev)
 
PDEVMODEW NTAPI PDEVOBJ_pdmMatchDevMode (PPDEVOBJ ppdev, PDEVMODEW pdm)
 
static PPDEVOBJ EngpCreatePDEV (PUNICODE_STRING pustrDeviceName, PDEVMODEW pdm)
 
FORCEINLINE VOID SwitchPointer (_Inout_ PVOID pvPointer1, _Inout_ PVOID pvPointer2)
 
VOID NTAPI PDEVOBJ_vSwitchPdev (PPDEVOBJ ppdev, PPDEVOBJ ppdev2)
 
BOOL NTAPI PDEVOBJ_bSwitchMode (PPDEVOBJ ppdev, PDEVMODEW pdm)
 
PPDEVOBJ NTAPI EngpGetPDEV (_In_opt_ PUNICODE_STRING pustrDeviceName)
 
INT NTAPI PDEVOBJ_iGetColorManagementCaps (PPDEVOBJ ppdev)
 
VOID NTAPI PDEVOBJ_vGetDeviceCaps (IN PPDEVOBJ ppdev, OUT PDEVCAPS pDevCaps)
 
_Must_inspect_result_ _Ret_z_ LPWSTR APIENTRY EngGetDriverName (_In_ HDEV hdev)
 
INT APIENTRY NtGdiGetDeviceCaps (HDC hdc, INT Index)
 
 _Success_ (return!=FALSE)
 
DHPDEV APIENTRY NtGdiGetDhpdev (IN HDEV hdev)
 
PSIZEL FASTCALL PDEVOBJ_sizl (PPDEVOBJ ppdev, PSIZEL psizl)
 

Variables

PPDEVOBJ gppdevPrimary = NULL
 
static PPDEVOBJ gppdevList = NULL
 
static HSEMAPHORE ghsemPDEV
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 10 of file pdevobj.c.

Function Documentation

◆ _Success_()

_Success_ ( return!  = FALSE)

Definition at line 902 of file pdevobj.c.

908 {
909  PDC pdc;
910  DEVCAPS devcaps;
911  BOOL bResult = TRUE;
912 
913  /* Lock the given DC */
914  pdc = DC_LockDc(hDC);
915  if (!pdc)
916  {
918  return FALSE;
919  }
920 
921  /* Get the data */
922  PDEVOBJ_vGetDeviceCaps(pdc->ppdev, &devcaps);
923 
924  /* Unlock the DC */
925  DC_UnlockDc(pdc);
926 
927  /* Copy data to caller */
928  _SEH2_TRY
929  {
930  ProbeForWrite(pDevCaps, sizeof(DEVCAPS), 1);
931  RtlCopyMemory(pDevCaps, &devcaps, sizeof(DEVCAPS));
932  }
934  {
936  bResult = FALSE;
937  }
938  _SEH2_END;
939 
940  return bResult;
941 }
_Out_ PDEVCAPS pDevCaps
Definition: ntgdi.h:2664
FORCEINLINE PDC DC_LockDc(HDC hdc)
Definition: dc.h:219
#define TRUE
Definition: types.h:120
#define ERROR_INVALID_HANDLE
Definition: compat.h:98
VOID NTAPI ProbeForWrite(IN PVOID Address, IN SIZE_T Length, IN ULONG Alignment)
Definition: exintrin.c:143
_SEH2_TRY
Definition: create.c:4226
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
VOID NTAPI PDEVOBJ_vGetDeviceCaps(IN PPDEVOBJ ppdev, OUT PDEVCAPS pDevCaps)
Definition: pdevobj.c:684
Definition: polytest.cpp:40
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
VOID FASTCALL SetLastNtError(NTSTATUS Status)
Definition: error.c:36
static HDC hDC
Definition: 3dtext.c:33
_SEH2_END
Definition: create.c:4400
FORCEINLINE VOID DC_UnlockDc(PDC pdc)
Definition: dc.h:237
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:40
#define _SEH2_GetExceptionCode()
Definition: pseh2_64.h:165
ENGAPI VOID APIENTRY EngSetLastError(_In_ ULONG iError)
Definition: error.c:27

◆ EngGetDriverName()

_Must_inspect_result_ _Ret_z_ LPWSTR APIENTRY EngGetDriverName ( _In_ HDEV  hdev)

Exported functions

Definition at line 741 of file pdevobj.c.

742 {
743  PPDEVOBJ ppdev = (PPDEVOBJ)hdev;
744 
745  ASSERT(ppdev);
746  ASSERT(ppdev->pldev);
747  ASSERT(ppdev->pldev->pGdiDriverInfo);
748  ASSERT(ppdev->pldev->pGdiDriverInfo->DriverName.Buffer);
749 
750  return ppdev->pldev->pGdiDriverInfo->DriverName.Buffer;
751 }
struct _LDEVOBJ * pldev
Definition: pdevobj.h:120
struct _PDEVOBJ * PPDEVOBJ
#define ASSERT(a)
Definition: mode.c:44
_In_ HDEV hdev
Definition: winddi.h:3449

◆ EngpCreatePDEV()

static PPDEVOBJ EngpCreatePDEV ( PUNICODE_STRING  pustrDeviceName,
PDEVMODEW  pdm 
)
static

Definition at line 346 of file pdevobj.c.

349 {
350  PGRAPHICS_DEVICE pGraphicsDevice;
351  PPDEVOBJ ppdev;
352 
353  DPRINT("EngpCreatePDEV(%wZ, %p)\n", pustrDeviceName, pdm);
354 
355  /* Try to find the GRAPHICS_DEVICE */
356  if (pustrDeviceName)
357  {
358  pGraphicsDevice = EngpFindGraphicsDevice(pustrDeviceName, 0, 0);
359  if (!pGraphicsDevice)
360  {
361  DPRINT1("No GRAPHICS_DEVICE found for %ls!\n",
362  pustrDeviceName ? pustrDeviceName->Buffer : 0);
363  return NULL;
364  }
365  }
366  else
367  {
369  pGraphicsDevice = gpPrimaryGraphicsDevice;
370  }
371 
372  /* Allocate a new PDEVOBJ */
373  ppdev = PDEVOBJ_AllocPDEV();
374  if (!ppdev)
375  {
376  DPRINT1("failed to allocate a PDEV\n");
377  return NULL;
378  }
379 
380  /* If no DEVMODEW is given, ... */
381  if (!pdm)
382  {
383  /* ... use the device's default one */
384  pdm = pGraphicsDevice->pDevModeList[pGraphicsDevice->iDefaultMode].pdm;
385  DPRINT("Using iDefaultMode = %lu\n", pGraphicsDevice->iDefaultMode);
386  }
387 
388  /* Try to get a diplay driver */
390  if (!ppdev->pldev)
391  {
392  DPRINT1("Could not load display driver '%ls', '%ls'\n",
393  pGraphicsDevice->pDiplayDrivers,
394  pdm->dmDeviceName);
395  PDEVOBJ_vRelease(ppdev);
396  return NULL;
397  }
398 
399  /* Copy the function table */
400  ppdev->pfn = ppdev->pldev->pfn;
401 
402  /* Set MovePointer function */
403  ppdev->pfnMovePointer = ppdev->pfn.MovePointer;
404  if (!ppdev->pfnMovePointer)
406 
407  ppdev->pGraphicsDevice = pGraphicsDevice;
408 
409  // DxEngGetHdevData asks for Graphics DeviceObject in hSpooler field
410  ppdev->hSpooler = ppdev->pGraphicsDevice->DeviceObject;
411 
412  // Should we change the ative mode of pGraphicsDevice ?
413  ppdev->pdmwDev = PDEVOBJ_pdmMatchDevMode(ppdev, pdm);
414 
415  /* FIXME! */
416  ppdev->flFlags = PDEV_DISPLAY;
417 
418  /* HACK: Don't use the pointer */
419  ppdev->Pointer.Exclude.right = -1;
420 
421  /* Call the driver to enable the PDEV */
422  if (!PDEVOBJ_bEnablePDEV(ppdev, pdm, NULL))
423  {
424  DPRINT1("Failed to enable PDEV!\n");
425  PDEVOBJ_vRelease(ppdev);
426  return NULL;
427  }
428 
429  /* FIXME: this must be done in a better way */
431 
432  /* Tell the driver that the PDEV is ready */
433  PDEVOBJ_vCompletePDEV(ppdev);
434 
435  /* Return the PDEV */
436  return ppdev;
437 }
BOOL NTAPI PDEVOBJ_bEnablePDEV(PPDEVOBJ ppdev, PDEVMODEW pdevmode, PWSTR pwszLogAddress)
Definition: pdevobj.c:161
PDEVICE_OBJECT DeviceObject
Definition: pdevobj.h:63
struct _LDEVOBJ * pldev
Definition: pdevobj.h:120
PFN_DrvMovePointer pfnMovePointer
Definition: pdevobj.h:114
DWORD StateFlags
Definition: pdevobj.h:66
PDEVMODEENTRY pDevModeList
Definition: pdevobj.h:70
PGRAPHICS_DEVICE gpPrimaryGraphicsDevice
Definition: device.c:15
PDEVMODEW pdm
Definition: pdevobj.h:53
PLDEVOBJ NTAPI EngLoadImageEx(_In_z_ LPWSTR pwszDriverName, _In_ ULONG ldevtype)
Definition: ldevobj.c:328
long right
Definition: polytest.cpp:53
PGRAPHICS_DEVICE NTAPI EngpFindGraphicsDevice(_In_opt_ PUNICODE_STRING pustrDevice, _In_ ULONG iDevNum, _In_ DWORD dwFlags)
Definition: device.c:469
FLONG flFlags
Definition: pdevobj.h:89
RECTL Exclude
Definition: pdevobj.h:39
PDEVMODEW pdmwDev
Definition: pdevobj.h:130
DRIVER_FUNCTIONS pfn
Definition: pdevobj.h:139
VOID NTAPI PDEVOBJ_vCompletePDEV(PPDEVOBJ ppdev)
Definition: pdevobj.c:225
#define ASSERT(a)
Definition: mode.c:44
LPWSTR pDiplayDrivers
Definition: pdevobj.h:71
#define DISPLAY_DEVICE_ATTACHED_TO_DESKTOP
Definition: wingdi.h:1395
WCHAR dmDeviceName[CCHDEVICENAME]
Definition: wingdi.h:1616
HANDLE hSpooler
Definition: pdevobj.h:126
PDEVMODEW NTAPI PDEVOBJ_pdmMatchDevMode(PPDEVOBJ ppdev, PDEVMODEW pdm)
Definition: pdevobj.c:307
PFN_DrvMovePointer MovePointer
Definition: ntgdityp.h:599
PPDEVOBJ PDEVOBJ_AllocPDEV(VOID)
Definition: pdevobj.c:53
#define NULL
Definition: types.h:112
GDIPOINTER Pointer
Definition: pdevobj.h:145
#define DPRINT1
Definition: precomp.h:8
ENGAPI VOID APIENTRY EngMovePointer(_In_ SURFOBJ *pso, _In_ LONG x, _In_ LONG y, _In_ RECTL *prcl)
Definition: mouse.c:566
#define DPRINT
Definition: sndvol32.h:71
VOID NTAPI PDEVOBJ_vRelease(_Inout_ PPDEVOBJ ppdev)
Definition: pdevobj.c:93
PGRAPHICS_DEVICE pGraphicsDevice
Definition: pdevobj.h:128
ULONG iDefaultMode
Definition: pdevobj.h:77

Referenced by EngpGetPDEV(), and PDEVOBJ_bSwitchMode().

◆ EngpGetPDEV()

PPDEVOBJ NTAPI EngpGetPDEV ( _In_opt_ PUNICODE_STRING  pustrDeviceName)

Definition at line 596 of file pdevobj.c.

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

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

◆ InitPDEVImpl()

NTSTATUS NTAPI InitPDEVImpl ( VOID  )

Definition at line 21 of file pdevobj.c.

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

Referenced by DriverEntry().

◆ NtGdiGetDeviceCaps()

INT APIENTRY NtGdiGetDeviceCaps ( HDC  hdc,
INT  Index 
)

Definition at line 756 of file pdevobj.c.

759 {
760  PDC pdc;
761  DEVCAPS devcaps;
762 
763  /* Lock the given DC */
764  pdc = DC_LockDc(hdc);
765  if (!pdc)
766  {
768  return 0;
769  }
770 
771  /* Get the data */
772  PDEVOBJ_vGetDeviceCaps(pdc->ppdev, &devcaps);
773 
774  /* Unlock the DC */
775  DC_UnlockDc(pdc);
776 
777  /* Return capability */
778  switch (Index)
779  {
780  case DRIVERVERSION:
781  return devcaps.ulVersion;
782 
783  case TECHNOLOGY:
784  return devcaps.ulTechnology;
785 
786  case HORZSIZE:
787  return devcaps.ulHorzSize;
788 
789  case VERTSIZE:
790  return devcaps.ulVertSize;
791 
792  case HORZRES:
793  return devcaps.ulHorzRes;
794 
795  case VERTRES:
796  return devcaps.ulVertRes;
797 
798  case LOGPIXELSX:
799  return devcaps.ulLogPixelsX;
800 
801  case LOGPIXELSY:
802  return devcaps.ulLogPixelsY;
803 
804  case BITSPIXEL:
805  return devcaps.ulBitsPixel;
806 
807  case PLANES:
808  return devcaps.ulPlanes;
809 
810  case NUMBRUSHES:
811  return -1;
812 
813  case NUMPENS:
814  return devcaps.ulNumPens;
815 
816  case NUMFONTS:
817  return devcaps.ulNumFonts;
818 
819  case NUMCOLORS:
820  return devcaps.ulNumColors;
821 
822  case ASPECTX:
823  return devcaps.ulAspectX;
824 
825  case ASPECTY:
826  return devcaps.ulAspectY;
827 
828  case ASPECTXY:
829  return devcaps.ulAspectXY;
830 
831  case CLIPCAPS:
832  return CP_RECTANGLE;
833 
834  case SIZEPALETTE:
835  return devcaps.ulSizePalette;
836 
837  case NUMRESERVED:
838  return 20;
839 
840  case COLORRES:
841  return devcaps.ulColorRes;
842 
843  case DESKTOPVERTRES:
844  return devcaps.ulVertRes;
845 
846  case DESKTOPHORZRES:
847  return devcaps.ulHorzRes;
848 
849  case BLTALIGNMENT:
850  return devcaps.ulBltAlignment;
851 
852  case SHADEBLENDCAPS:
853  return devcaps.ulShadeBlend;
854 
855  case COLORMGMTCAPS:
856  return devcaps.ulColorMgmtCaps;
857 
858  case PHYSICALWIDTH:
859  return devcaps.ulPhysicalWidth;
860 
861  case PHYSICALHEIGHT:
862  return devcaps.ulPhysicalHeight;
863 
864  case PHYSICALOFFSETX:
865  return devcaps.ulPhysicalOffsetX;
866 
867  case PHYSICALOFFSETY:
868  return devcaps.ulPhysicalOffsetY;
869 
870  case VREFRESH:
871  return devcaps.ulVRefresh;
872 
873  case RASTERCAPS:
874  return devcaps.ulRasterCaps;
875 
876  case CURVECAPS:
877  return (CC_CIRCLES | CC_PIE | CC_CHORD | CC_ELLIPSES | CC_WIDE |
879 
880  case LINECAPS:
883 
884  case POLYGONALCAPS:
887 
888  case TEXTCAPS:
889  return devcaps.ulTextCaps;
890 
891  case CAPS1:
892  case PDEVICESIZE:
893  case SCALINGFACTORX:
894  case SCALINGFACTORY:
895  default:
896  return 0;
897  }
898 
899  return 0;
900 }
#define CP_RECTANGLE
Definition: wingdi.h:825
#define DESKTOPHORZRES
Definition: wingdi.h:741
#define CC_PIE
Definition: wingdi.h:761
#define DESKTOPVERTRES
Definition: wingdi.h:742
#define NUMBRUSHES
Definition: wingdi.h:721
#define CC_CHORD
Definition: wingdi.h:762
#define BITSPIXEL
Definition: wingdi.h:719
#define HORZRES
Definition: wingdi.h:715
#define LOGPIXELSX
Definition: wingdi.h:717
ULONG ulBltAlignment
Definition: ntgdityp.h:327
#define NUMRESERVED
Definition: wingdi.h:732
#define LC_WIDE
Definition: wingdi.h:774
ULONG ulHorzRes
Definition: ntgdityp.h:304
FORCEINLINE PDC DC_LockDc(HDC hdc)
Definition: dc.h:219
#define PC_INTERIORS
Definition: wingdi.h:803
#define ASPECTX
Definition: wingdi.h:726
ULONG ulRasterCaps
Definition: ntgdityp.h:311
#define LC_POLYLINE
Definition: wingdi.h:771
#define CC_STYLED
Definition: wingdi.h:765
ULONG ulNumFonts
Definition: ntgdityp.h:309
#define ERROR_INVALID_HANDLE
Definition: compat.h:98
#define COLORRES
Definition: wingdi.h:733
#define DRIVERVERSION
Definition: wingdi.h:704
#define PDEVICESIZE
Definition: wingdi.h:729
#define BLTALIGNMENT
Definition: wingdi.h:743
ULONG ulHorzSize
Definition: ntgdityp.h:302
#define SCALINGFACTORX
Definition: wingdi.h:738
#define LC_POLYMARKER
Definition: wingdi.h:773
#define POLYGONALCAPS
Definition: wingdi.h:778
ULONG ulBitsPixel
Definition: ntgdityp.h:306
#define PC_WINDPOLYGON
Definition: wingdi.h:797
ULONG ulPhysicalHeight
Definition: ntgdityp.h:320
#define RASTERCAPS
Definition: wingdi.h:744
#define TECHNOLOGY
Definition: wingdi.h:705
ULONG ulVRefresh
Definition: ntgdityp.h:324
#define TEXTCAPS
Definition: wingdi.h:805
#define PHYSICALHEIGHT
Definition: wingdi.h:735
ULONG ulShadeBlend
Definition: ntgdityp.h:332
#define PC_WIDESTYLED
Definition: wingdi.h:802
#define NUMCOLORS
Definition: wingdi.h:724
ULONG ulNumPens
Definition: ntgdityp.h:308
ULONG ulVertRes
Definition: ntgdityp.h:305
#define VREFRESH
Definition: wingdi.h:740
#define CC_INTERIORS
Definition: wingdi.h:767
ULONG ulVertSize
Definition: ntgdityp.h:303
ULONG ulAspectXY
Definition: ntgdityp.h:314
#define LC_MARKER
Definition: wingdi.h:772
VOID NTAPI PDEVOBJ_vGetDeviceCaps(IN PPDEVOBJ ppdev, OUT PDEVCAPS pDevCaps)
Definition: pdevobj.c:684
#define SCALINGFACTORY
Definition: wingdi.h:739
#define PC_STYLED
Definition: wingdi.h:801
#define CC_WIDE
Definition: wingdi.h:764
ULONG ulColorRes
Definition: ntgdityp.h:318
ULONG ulPhysicalOffsetY
Definition: ntgdityp.h:322
#define LC_STYLED
Definition: wingdi.h:775
ULONG ulAspectY
Definition: ntgdityp.h:313
#define PC_WIDE
Definition: wingdi.h:800
ULONG ulPlanes
Definition: ntgdityp.h:307
Definition: polytest.cpp:40
#define ASPECTXY
Definition: wingdi.h:728
ULONG ulVersion
Definition: ntgdityp.h:298
#define PHYSICALOFFSETY
Definition: wingdi.h:737
_In_ WDFCOLLECTION _In_ ULONG Index
#define CC_ROUNDRECT
Definition: wingdi.h:768
#define ASPECTY
Definition: wingdi.h:727
#define CLIPCAPS
Definition: wingdi.h:730
#define LC_WIDESTYLED
Definition: wingdi.h:776
#define SIZEPALETTE
Definition: wingdi.h:731
ULONG ulLogPixelsY
Definition: ntgdityp.h:316
HDC hdc
Definition: main.c:9
#define CC_ELLIPSES
Definition: wingdi.h:763
ULONG ulPhysicalOffsetX
Definition: ntgdityp.h:321
#define CAPS1
Definition: mmsystem.h:934
#define HORZSIZE
Definition: wingdi.h:713
#define PHYSICALOFFSETX
Definition: wingdi.h:736
#define PHYSICALWIDTH
Definition: wingdi.h:734
#define PC_RECTANGLE
Definition: wingdi.h:796
#define VERTSIZE
Definition: wingdi.h:714
FORCEINLINE VOID DC_UnlockDc(PDC pdc)
Definition: dc.h:237
#define NUMPENS
Definition: wingdi.h:722
#define LINECAPS
Definition: wingdi.h:769
ULONG ulTextCaps
Definition: ntgdityp.h:323
ULONG ulPhysicalWidth
Definition: ntgdityp.h:319
#define VERTRES
Definition: wingdi.h:716
#define PC_POLYGON
Definition: wingdi.h:793
#define PC_SCANLINE
Definition: wingdi.h:798
ULONG ulAspectX
Definition: ntgdityp.h:312
ULONG ulColorMgmtCaps
Definition: ntgdityp.h:333
#define LOGPIXELSY
Definition: wingdi.h:718
ULONG ulNumColors
Definition: ntgdityp.h:310
#define CC_WIDESTYLED
Definition: wingdi.h:766
ULONG ulSizePalette
Definition: ntgdityp.h:317
#define CC_CIRCLES
Definition: wingdi.h:760
ULONG ulLogPixelsX
Definition: ntgdityp.h:315
#define LC_INTERIORS
Definition: wingdi.h:777
#define CURVECAPS
Definition: wingdi.h:758
#define NUMFONTS
Definition: wingdi.h:723
ENGAPI VOID APIENTRY EngSetLastError(_In_ ULONG iError)
Definition: error.c:27
ULONG ulTechnology
Definition: ntgdityp.h:299
#define PLANES
Definition: wingdi.h:720

◆ NtGdiGetDhpdev()

DHPDEV APIENTRY NtGdiGetDhpdev ( IN HDEV  hdev)

Definition at line 945 of file pdevobj.c.

947 {
948  PPDEVOBJ ppdev;
949  DHPDEV dhpdev = NULL;
950 
951  /* Check parameter */
952  if (!hdev || (PCHAR)hdev < (PCHAR)MmSystemRangeStart)
953  return NULL;
954 
955  /* Lock PDEV list */
956  EngAcquireSemaphoreShared(ghsemPDEV);
957 
958  /* Walk through the list of PDEVs */
959  for (ppdev = gppdevList; ppdev; ppdev = ppdev->ppdevNext)
960  {
961  /* Compare with the given HDEV */
962  if (ppdev == (PPDEVOBJ)hdev)
963  {
964  /* Found the PDEV! Get it's dhpdev and break */
965  dhpdev = ppdev->dhpdev;
966  break;
967  }
968  }
969 
970  /* Unlock PDEV list */
972 
973  return dhpdev;
974 }
DHPDEV dhpdev
Definition: pdevobj.h:121
signed char * PCHAR
Definition: retypes.h:7
VOID WINAPI EngReleaseSemaphore(IN HSEMAPHORE hsem)
Definition: eng.c:235
typedef DHPDEV(APIENTRY FN_DrvEnablePDEV)(_In_ DEVMODEW *pdm
struct _PDEVOBJ * ppdevNext
Definition: pdevobj.h:85
static HSEMAPHORE ghsemPDEV
Definition: pdevobj.c:16
static PPDEVOBJ gppdevList
Definition: pdevobj.c:15
#define NULL
Definition: types.h:112
#define MmSystemRangeStart
Definition: mm.h:32
_In_ HDEV hdev
Definition: winddi.h:3449

◆ PDEVOBJ_AllocPDEV()

PPDEVOBJ PDEVOBJ_AllocPDEV ( VOID  )

Definition at line 53 of file pdevobj.c.

54 {
55  PPDEVOBJ ppdev;
56 
58  if (!ppdev)
59  return NULL;
60 
61  RtlZeroMemory(ppdev, sizeof(PDEVOBJ));
62 
64  if (ppdev->hsemDevLock == NULL)
65  {
67  return NULL;
68  }
69 
70  /* Allocate EDD_DIRECTDRAW_GLOBAL for our ReactX driver */
72  if (ppdev->pEDDgpl)
74 
75  ppdev->cPdevRefs = 1;
76 
77  return ppdev;
78 }
LONG cPdevRefs
Definition: pdevobj.h:86
HSEMAPHORE hsemDevLock
Definition: pdevobj.h:91
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
struct _EDD_DIRECTDRAW_GLOBAL * pEDDgpl
Definition: pdevobj.h:150
#define NULL
Definition: types.h:112
HSEMAPHORE WINAPI EngCreateSemaphore(VOID)
Definition: eng.c:75
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099
#define GDITAG_PDEV
Definition: tags.h:74

Referenced by EngpCreatePDEV().

◆ PDEVOBJ_bEnablePDEV()

BOOL NTAPI PDEVOBJ_bEnablePDEV ( PPDEVOBJ  ppdev,
PDEVMODEW  pdevmode,
PWSTR  pwszLogAddress 
)

Definition at line 161 of file pdevobj.c.

165 {
166  PFN_DrvEnablePDEV pfnEnablePDEV;
167  ULONG i;
168 
169  DPRINT("PDEVOBJ_bEnablePDEV()\n");
170 
171  /* Get the DrvEnablePDEV function */
172  pfnEnablePDEV = ppdev->pldev->pfn.EnablePDEV;
173 
174  /* Call the drivers DrvEnablePDEV function */
175  ppdev->dhpdev = pfnEnablePDEV(pdevmode,
177  HS_DDI_MAX,
178  ppdev->ahsurf,
179  sizeof(GDIINFO),
180  (PULONG)&ppdev->gdiinfo,
181  sizeof(DEVINFO),
182  &ppdev->devinfo,
183  (HDEV)ppdev,
184  ppdev->pGraphicsDevice->pwszDescription,
185  ppdev->pGraphicsDevice->DeviceObject);
186  if (ppdev->dhpdev == NULL)
187  {
188  DPRINT1("Failed to enable PDEV\n");
189  return FALSE;
190  }
191 
192  /* Fix up some values */
193  if (ppdev->gdiinfo.ulLogPixelsX == 0)
194  ppdev->gdiinfo.ulLogPixelsX = 96;
195 
196  if (ppdev->gdiinfo.ulLogPixelsY == 0)
197  ppdev->gdiinfo.ulLogPixelsY = 96;
198 
199  /* Set raster caps */
201  if ((ppdev->gdiinfo.ulTechnology != DT_PLOTTER) && (ppdev->gdiinfo.ulTechnology != DT_CHARSTREAM))
203  if (ppdev->gdiinfo.ulTechnology == DT_RASDISPLAY)
204  ppdev->gdiinfo.flRaster |= RC_FLOODFILL;
206  ppdev->gdiinfo.flRaster |= RC_PALETTE;
207 
208  /* Setup Palette */
210 
211  /* Setup hatch brushes */
212  for (i = 0; i < HS_DDI_MAX; i++)
213  {
214  if (ppdev->ahsurf[i] == NULL)
215  ppdev->ahsurf[i] = gahsurfHatch[i];
216  }
217 
218  DPRINT("PDEVOBJ_bEnablePDEV - dhpdev = %p\n", ppdev->dhpdev);
219 
220  return TRUE;
221 }
DHPDEV dhpdev
Definition: pdevobj.h:121
#define RC_STRETCHBLT
Definition: wingdi.h:754
#define HS_DDI_MAX
Definition: winddi.h:3954
struct _LDEVOBJ * pldev
Definition: pdevobj.h:120
#define RC_BIGFONT
Definition: wingdi.h:780
#define RC_GDI20_OUTPUT
Definition: wingdi.h:785
#define TRUE
Definition: types.h:120
GDIINFO gdiinfo
Definition: pdevobj.h:124
#define RC_BITMAP64
Definition: wingdi.h:782
ULONG ulLogPixelsY
Definition: winddi.h:889
#define DT_RASDISPLAY
Definition: wingdi.h:707
#define RC_FLOODFILL
Definition: wingdi.h:750
#define FALSE
Definition: types.h:117
HPALETTE hpalDefault
Definition: winddi.h:398
struct _PALETTE * ppalSurf
Definition: pdevobj.h:122
ULONG ulTechnology
Definition: winddi.h:879
HSURF gahsurfHatch[HS_DDI_MAX]
Definition: engbrush.c:24
#define PALETTE_ShareLockPalette(hpal)
Definition: palette.h:57
#define RC_OP_DX_OUTPUT
Definition: wingdi.h:788
DEVINFO devinfo
Definition: pdevobj.h:123
#define RC_PALETTE
Definition: wingdi.h:789
#define RC_BITBLT
Definition: wingdi.h:781
#define DT_PLOTTER
Definition: wingdi.h:706
_In_ LPWSTR pwszLogAddress
Definition: winddi.h:3548
#define DT_CHARSTREAM
Definition: wingdi.h:710
ULONG flRaster
Definition: winddi.h:887
#define RC_DI_BITMAP
Definition: wingdi.h:784
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
#define RC_STRETCHDIB
Definition: wingdi.h:755
FLONG flGraphicsCaps
Definition: winddi.h:390
unsigned int * PULONG
Definition: retypes.h:1
#define NULL
Definition: types.h:112
#define RC_DIBTODEV
Definition: wingdi.h:749
#define DPRINT1
Definition: precomp.h:8
FN_DrvEnablePDEV * PFN_DrvEnablePDEV
Definition: winddi.h:3558
unsigned int ULONG
Definition: retypes.h:1
ULONG ulLogPixelsX
Definition: winddi.h:888
#define DPRINT
Definition: sndvol32.h:71
#define GCAPS_PALMANAGED
Definition: winddi.h:341
HSURF ahsurf[HS_DDI_MAX]
Definition: pdevobj.h:99

Referenced by EngpCreatePDEV().

◆ PDEVOBJ_bSwitchMode()

BOOL NTAPI PDEVOBJ_bSwitchMode ( PPDEVOBJ  ppdev,
PDEVMODEW  pdm 
)

Definition at line 510 of file pdevobj.c.

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

Referenced by UserChangeDisplaySettings(), and UserRefreshDisplay().

◆ PDEVOBJ_iGetColorManagementCaps()

INT NTAPI PDEVOBJ_iGetColorManagementCaps ( PPDEVOBJ  ppdev)

Definition at line 663 of file pdevobj.c.

664 {
665  INT ret = CM_NONE;
666 
667  if (ppdev->flFlags & PDEV_DISPLAY)
668  {
669  if (ppdev->devinfo.iDitherFormat == BMF_8BPP ||
671  ret = CM_GAMMA_RAMP;
672  }
673 
675  ret |= CM_CMYK_COLOR;
676  if (ppdev->devinfo.flGraphicsCaps & GCAPS_ICM)
677  ret |= CM_DEVICE_ICM;
678 
679  return ret;
680 }
#define GCAPS_CMYKCOLOR
Definition: winddi.h:347
int32_t INT
Definition: typedefs.h:58
FLONG flFlags
Definition: pdevobj.h:89
ULONG iDitherFormat
Definition: winddi.h:395
#define GCAPS2_CHANGEGAMMARAMP
Definition: winddi.h:370
DEVINFO devinfo
Definition: pdevobj.h:123
int ret
#define GCAPS_ICM
Definition: winddi.h:346
FLONG flGraphicsCaps
Definition: winddi.h:390
Definition: xlate.c:10
FLONG flGraphicsCaps2
Definition: winddi.h:399

Referenced by PDEVOBJ_vGetDeviceCaps().

◆ PDEVOBJ_pdmMatchDevMode()

PDEVMODEW NTAPI PDEVOBJ_pdmMatchDevMode ( PPDEVOBJ  ppdev,
PDEVMODEW  pdm 
)

Definition at line 307 of file pdevobj.c.

310 {
311  PGRAPHICS_DEVICE pGraphicsDevice;
312  PDEVMODEW pdmCurrent;
313  ULONG i;
314  DWORD dwFields;
315 
316  pGraphicsDevice = ppdev->pGraphicsDevice;
317 
318  for (i = 0; i < pGraphicsDevice->cDevModes; i++)
319  {
320  pdmCurrent = pGraphicsDevice->pDevModeList[i].pdm;
321 
322  /* Compare asked DEVMODE fields
323  * Only compare those that are valid in both DEVMODE structs */
324  dwFields = pdmCurrent->dmFields & pdm->dmFields;
325 
326  /* For now, we only need those */
327  if ((dwFields & DM_BITSPERPEL) &&
328  (pdmCurrent->dmBitsPerPel != pdm->dmBitsPerPel)) continue;
329  if ((dwFields & DM_PELSWIDTH) &&
330  (pdmCurrent->dmPelsWidth != pdm->dmPelsWidth)) continue;
331  if ((dwFields & DM_PELSHEIGHT) &&
332  (pdmCurrent->dmPelsHeight != pdm->dmPelsHeight)) continue;
333  if ((dwFields & DM_DISPLAYFREQUENCY) &&
334  (pdmCurrent->dmDisplayFrequency != pdm->dmDisplayFrequency)) continue;
335 
336  /* Match! Return the DEVMODE */
337  return pdmCurrent;
338  }
339 
340  /* Nothing found */
341  return NULL;
342 }
DWORD dmFields
Definition: wingdi.h:1621
PDEVMODEENTRY pDevModeList
Definition: pdevobj.h:70
DWORD dmBitsPerPel
Definition: wingdi.h:1646
PDEVMODEW pdm
Definition: pdevobj.h:53
#define DM_PELSWIDTH
Definition: wingdi.h:1268
ULONG cDevModes
Definition: pdevobj.h:69
unsigned long DWORD
Definition: ntddk_ex.h:95
DWORD dmPelsWidth
Definition: wingdi.h:1647
#define DM_DISPLAYFREQUENCY
Definition: wingdi.h:1271
DWORD dmDisplayFrequency
Definition: wingdi.h:1653
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
#define DM_PELSHEIGHT
Definition: wingdi.h:1269
#define NULL
Definition: types.h:112
DWORD dmPelsHeight
Definition: wingdi.h:1648
unsigned int ULONG
Definition: retypes.h:1
#define DM_BITSPERPEL
Definition: wingdi.h:1267
PGRAPHICS_DEVICE pGraphicsDevice
Definition: pdevobj.h:128

Referenced by EngpCreatePDEV(), PDEVOBJ_vRefreshModeList(), and UserChangeDisplaySettings().

◆ PDEVOBJ_pSurface()

PSURFACE NTAPI PDEVOBJ_pSurface ( PPDEVOBJ  ppdev)

Definition at line 234 of file pdevobj.c.

236 {
237  HSURF hsurf;
238 
239  /* Check if there is no surface for this PDEV yet */
240  if (ppdev->pSurface == NULL)
241  {
242  /* Call the drivers DrvEnableSurface */
243  hsurf = ppdev->pldev->pfn.EnableSurface(ppdev->dhpdev);
244  if (hsurf== NULL)
245  {
246  DPRINT1("Failed to create PDEV surface!\n");
247  return NULL;
248  }
249 
250  /* Get a reference to the surface */
251  ppdev->pSurface = SURFACE_ShareLockSurface(hsurf);
252  NT_ASSERT(ppdev->pSurface != NULL);
253  }
254 
255  /* Increment reference count */
257 
258  DPRINT("PDEVOBJ_pSurface() returning %p\n", ppdev->pSurface);
259  return ppdev->pSurface;
260 }
DHPDEV dhpdev
Definition: pdevobj.h:121
struct _LDEVOBJ * pldev
Definition: pdevobj.h:120
#define SURFACE_ShareLockSurface(hBMObj)
Definition: surface.h:91
typedef HSURF(APIENTRY FN_DrvEnableSurface)(_In_ DHPDEV dhpdev)
BASEOBJECT BaseObject
Definition: surface.h:6
VOID NTAPI GDIOBJ_vReferenceObjectByPointer(POBJ pobj)
Definition: gdiobj.c:734
#define NULL
Definition: types.h:112
PSURFACE pSurface
Definition: pdevobj.h:125
#define DPRINT1
Definition: precomp.h:8
#define DPRINT
Definition: sndvol32.h:71
#define NT_ASSERT
Definition: rtlfuncs.h:3310

Referenced by DC_vInitDc(), DC_vUpdateDC(), IntCreatePrimarySurface(), and PDEVOBJ_bSwitchMode().

◆ PDEVOBJ_sizl()

PSIZEL FASTCALL PDEVOBJ_sizl ( PPDEVOBJ  ppdev,
PSIZEL  psizl 
)

Definition at line 978 of file pdevobj.c.

979 {
980  if (ppdev->flFlags & PDEV_META_DEVICE)
981  {
982  psizl->cx = ppdev->ulHorzRes;
983  psizl->cy = ppdev->ulVertRes;
984  }
985  else
986  {
987  psizl->cx = ppdev->gdiinfo.ulHorzRes;
988  psizl->cy = ppdev->gdiinfo.ulVertRes;
989  }
990  return psizl;
991 }
GDIINFO gdiinfo
Definition: pdevobj.h:124
FLONG flFlags
Definition: pdevobj.h:89
ULONG ulHorzRes
Definition: winddi.h:882
LONG cx
Definition: windef.h:334
ULONG ulHorzRes
Definition: pdevobj.h:110
ULONG ulVertRes
Definition: pdevobj.h:111
ULONG ulVertRes
Definition: winddi.h:883
LONG cy
Definition: windef.h:335

Referenced by DC_vUpdateDC(), MakeInfoDC(), and UserUpdateMonitorSize().

◆ PDEVOBJ_vCompletePDEV()

VOID NTAPI PDEVOBJ_vCompletePDEV ( PPDEVOBJ  ppdev)

Definition at line 225 of file pdevobj.c.

227 {
228  /* Call the drivers DrvCompletePDEV function */
229  ppdev->pldev->pfn.CompletePDEV(ppdev->dhpdev, (HDEV)ppdev);
230 }
DHPDEV dhpdev
Definition: pdevobj.h:121
struct _LDEVOBJ * pldev
Definition: pdevobj.h:120

Referenced by EngpCreatePDEV().

◆ PDEVOBJ_vDeletePDEV()

static VOID PDEVOBJ_vDeletePDEV ( PPDEVOBJ  ppdev)
static

Definition at line 82 of file pdevobj.c.

84 {
86  if (ppdev->pEDDgpl)
89 }
_Requires_lock_not_held_ hsem ENGAPI VOID APIENTRY EngDeleteSemaphore(_Inout_ __drv_freesMem(Mem) HSEMAPHORE hsem)
Definition: semaphor.c:106
HSEMAPHORE hsemDevLock
Definition: pdevobj.h:91
struct _EDD_DIRECTDRAW_GLOBAL * pEDDgpl
Definition: pdevobj.h:150
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099
#define GDITAG_PDEV
Definition: tags.h:74

Referenced by PDEVOBJ_vRelease().

◆ PDEVOBJ_vGetDeviceCaps()

VOID NTAPI PDEVOBJ_vGetDeviceCaps ( IN PPDEVOBJ  ppdev,
OUT PDEVCAPS  pDevCaps 
)

Definition at line 684 of file pdevobj.c.

687 {
688  PGDIINFO pGdiInfo = &ppdev->gdiinfo;
689 
690  pDevCaps->ulVersion = pGdiInfo->ulVersion;
691  pDevCaps->ulTechnology = pGdiInfo->ulTechnology;
692  pDevCaps->ulHorzSizeM = (pGdiInfo->ulHorzSize + 500) / 1000;
693  pDevCaps->ulVertSizeM = (pGdiInfo->ulVertSize + 500) / 1000;
694  pDevCaps->ulHorzSize = pGdiInfo->ulHorzSize;
695  pDevCaps->ulVertSize = pGdiInfo->ulVertSize;
696  pDevCaps->ulHorzRes = pGdiInfo->ulHorzRes;
697  pDevCaps->ulVertRes = pGdiInfo->ulVertRes;
698  pDevCaps->ulBitsPixel = pGdiInfo->cBitsPixel;
699  if (pDevCaps->ulBitsPixel == 15) pDevCaps->ulBitsPixel = 16;
700  pDevCaps->ulPlanes = pGdiInfo->cPlanes;
701  pDevCaps->ulNumPens = pGdiInfo->ulNumColors;
702  if (pDevCaps->ulNumPens != -1) pDevCaps->ulNumPens *= 5;
703  pDevCaps->ulNumFonts = 0; // PDEVOBJ_cFonts(ppdev);
704  pDevCaps->ulNumColors = pGdiInfo->ulNumColors;
705  pDevCaps->ulRasterCaps = pGdiInfo->flRaster;
706  pDevCaps->ulAspectX = pGdiInfo->ulAspectX;
707  pDevCaps->ulAspectY = pGdiInfo->ulAspectY;
708  pDevCaps->ulAspectXY = pGdiInfo->ulAspectXY;
709  pDevCaps->ulLogPixelsX = pGdiInfo->ulLogPixelsX;
710  pDevCaps->ulLogPixelsY = pGdiInfo->ulLogPixelsY;
711  pDevCaps->ulSizePalette = pGdiInfo->ulNumPalReg;
712  pDevCaps->ulColorRes = pGdiInfo->ulDACRed +
713  pGdiInfo->ulDACGreen +
714  pGdiInfo->ulDACBlue;
715  pDevCaps->ulPhysicalWidth = pGdiInfo->szlPhysSize.cx;
719  pDevCaps->ulTextCaps = pGdiInfo->flTextCaps;
721  if (pGdiInfo->ulTechnology != DT_PLOTTER)
723  pDevCaps->ulVRefresh = pGdiInfo->ulVRefresh;
724  pDevCaps->ulDesktopHorzRes = pGdiInfo->ulHorzRes;
725  pDevCaps->ulDesktopVertRes = pGdiInfo->ulVertRes;
731  pDevCaps->ulShadeBlend = pGdiInfo->flShadeBlend;
733 }
SIZEL szlPhysSize
Definition: winddi.h:901
_Out_ PDEVCAPS pDevCaps
Definition: ntgdi.h:2664
#define TC_UA_ABLE
Definition: wingdi.h:817
ULONG flShadeBlend
Definition: winddi.h:920
ULONG ulBltAlignment
Definition: ntgdityp.h:327
ULONG ulHorzRes
Definition: ntgdityp.h:304
INT NTAPI PDEVOBJ_iGetColorManagementCaps(PPDEVOBJ ppdev)
Definition: pdevobj.c:663
ULONG ulDACRed
Definition: winddi.h:891
ULONG ulVertSizeM
Definition: ntgdityp.h:301
ULONG ulRasterCaps
Definition: ntgdityp.h:311
ULONG ulNumFonts
Definition: ntgdityp.h:309
ULONG yPanningAlignment
Definition: winddi.h:914
ULONG ulAspectY
Definition: winddi.h:895
ULONG ulDesktopVertRes
Definition: ntgdityp.h:326
ULONG ulHorzSize
Definition: ntgdityp.h:302
ULONG ulLogPixelsY
Definition: winddi.h:889
ULONG ulPanningHorzRes
Definition: winddi.h:911
ULONG ulBitsPixel
Definition: ntgdityp.h:306
ULONG cPlanes
Definition: winddi.h:885
ULONG flTextCaps
Definition: winddi.h:890
#define TC_SO_ABLE
Definition: wingdi.h:818
ULONG ulPhysicalHeight
Definition: ntgdityp.h:320
ULONG ulVRefresh
Definition: ntgdityp.h:324
LONG y
Definition: windef.h:330
ULONG ulPanningVertRes
Definition: ntgdityp.h:329
ULONG ulNumPalReg
Definition: winddi.h:902
ULONG ulShadeBlend
Definition: ntgdityp.h:332
ULONG ulVertSize
Definition: winddi.h:881
ULONG ulDACGreen
Definition: winddi.h:892
POINTL ptlPhysOffset
Definition: winddi.h:900
ULONG ulVersion
Definition: winddi.h:878
ULONG ulNumPens
Definition: ntgdityp.h:308
ULONG ulVertRes
Definition: ntgdityp.h:305
ULONG ulVertSize
Definition: ntgdityp.h:303
ULONG ulHorzRes
Definition: winddi.h:882
ULONG xPanningAlignment
Definition: ntgdityp.h:330
ULONG ulAspectXY
Definition: ntgdityp.h:314
LONG cx
Definition: windef.h:334
ULONG ulTechnology
Definition: winddi.h:879
ULONG ulAspectXY
Definition: winddi.h:896
ULONG xPanningAlignment
Definition: winddi.h:913
#define TC_VA_ABLE
Definition: wingdi.h:820
#define TC_OP_STROKE
Definition: wingdi.h:807
ULONG ulColorRes
Definition: ntgdityp.h:318
ULONG ulPhysicalOffsetY
Definition: ntgdityp.h:322
ULONG ulAspectY
Definition: ntgdityp.h:313
ULONG ulPlanes
Definition: ntgdityp.h:307
ULONG ulVersion
Definition: ntgdityp.h:298
ULONG ulBltAlignment
Definition: winddi.h:910
ULONG ulDACBlue
Definition: winddi.h:893
LONG x
Definition: windef.h:329
#define DT_PLOTTER
Definition: wingdi.h:706
ULONG ulHorzSize
Definition: winddi.h:880
ULONG ulPanningHorzRes
Definition: ntgdityp.h:328
ULONG ulDesktopHorzRes
Definition: ntgdityp.h:325
ULONG ulLogPixelsY
Definition: ntgdityp.h:316
ULONG flRaster
Definition: winddi.h:887
ULONG ulVRefresh
Definition: winddi.h:909
#define TC_OP_CHARACTER
Definition: wingdi.h:806
ULONG ulPhysicalOffsetX
Definition: ntgdityp.h:321
ULONG cBitsPixel
Definition: winddi.h:884
ULONG ulAspectX
Definition: winddi.h:894
ULONG ulTextCaps
Definition: ntgdityp.h:323
ULONG ulPhysicalWidth
Definition: ntgdityp.h:319
ULONG ulPanningVertRes
Definition: winddi.h:912
ULONG ulNumColors
Definition: winddi.h:886
ULONG ulAspectX
Definition: ntgdityp.h:312
ULONG ulColorMgmtCaps
Definition: ntgdityp.h:333
ULONG ulHorzSizeM
Definition: ntgdityp.h:300
ULONG ulNumColors
Definition: ntgdityp.h:310
ULONG ulLogPixelsX
Definition: winddi.h:888
ULONG ulVertRes
Definition: winddi.h:883
ULONG ulSizePalette
Definition: ntgdityp.h:317
ULONG yPanningAlignment
Definition: ntgdityp.h:331
ULONG ulLogPixelsX
Definition: ntgdityp.h:315
#define TC_CP_STROKE
Definition: wingdi.h:808
LONG cy
Definition: windef.h:335
ULONG ulTechnology
Definition: ntgdityp.h:299

Referenced by _Success_(), IntCreatePrimarySurface(), NtGdiGetDeviceCaps(), and PDEVOBJ_bSwitchMode().

◆ PDEVOBJ_vRefreshModeList()

VOID NTAPI PDEVOBJ_vRefreshModeList ( PPDEVOBJ  ppdev)

Definition at line 264 of file pdevobj.c.

266 {
267  PGRAPHICS_DEVICE pGraphicsDevice;
268  PDEVMODEINFO pdminfo, pdmiNext;
269  DEVMODEW dmDefault;
270  DEVMODEW dmCurrent;
271 
272  /* Lock the PDEV */
274 
275  pGraphicsDevice = ppdev->pGraphicsDevice;
276 
277  /* Remember our default mode */
278  dmDefault = *pGraphicsDevice->pDevModeList[pGraphicsDevice->iDefaultMode].pdm;
279  dmCurrent = *ppdev->pdmwDev;
280 
281  /* Clear out the modes */
282  for (pdminfo = pGraphicsDevice->pdevmodeInfo;
283  pdminfo;
284  pdminfo = pdmiNext)
285  {
286  pdmiNext = pdminfo->pdmiNext;
288  }
289  pGraphicsDevice->pdevmodeInfo = NULL;
290  ExFreePoolWithTag(pGraphicsDevice->pDevModeList, GDITAG_GDEVICE);
291  pGraphicsDevice->pDevModeList = NULL;
292 
293  /* Now re-populate the list */
294  if (!EngpPopulateDeviceModeList(pGraphicsDevice, &dmDefault))
295  {
296  DPRINT1("FIXME: EngpPopulateDeviceModeList failed, we just destroyed a perfectly good mode list\n");
297  }
298 
299  ppdev->pdmwDev = PDEVOBJ_pdmMatchDevMode(ppdev, &dmCurrent);
300 
301  /* Unlock PDEV */
303 }
BOOLEAN EngpPopulateDeviceModeList(_Inout_ PGRAPHICS_DEVICE pGraphicsDevice, _In_ PDEVMODEW pdmDefault)
Definition: device.c:125
VOID WINAPI EngReleaseSemaphore(IN HSEMAPHORE hsem)
Definition: eng.c:235
#define GDITAG_DEVMODE
Definition: tags.h:73
PDEVMODEENTRY pDevModeList
Definition: pdevobj.h:70
PDEVMODEW pdm
Definition: pdevobj.h:53
ENGAPI VOID APIENTRY EngAcquireSemaphore(_Inout_ HSEMAPHORE hsem)
PDEVMODEW pdmwDev
Definition: pdevobj.h:130
HSEMAPHORE hsemDevLock
Definition: pdevobj.h:91
struct _DEVMODEINFO * pdmiNext
Definition: pdevobj.h:44
PDEVMODEW NTAPI PDEVOBJ_pdmMatchDevMode(PPDEVOBJ ppdev, PDEVMODEW pdm)
Definition: pdevobj.c:307
#define GDITAG_GDEVICE
Definition: tags.h:98
#define NULL
Definition: types.h:112
#define DPRINT1
Definition: precomp.h:8
PDEVMODEINFO pdevmodeInfo
Definition: pdevobj.h:68
PGRAPHICS_DEVICE pGraphicsDevice
Definition: pdevobj.h:128
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099
ULONG iDefaultMode
Definition: pdevobj.h:77

Referenced by UserEnumDisplaySettings().

◆ PDEVOBJ_vRelease()

VOID NTAPI PDEVOBJ_vRelease ( _Inout_ PPDEVOBJ  ppdev)

Definition at line 93 of file pdevobj.c.

95 {
96  /* Lock loader */
98 
99  /* Decrease reference count */
100  InterlockedDecrement(&ppdev->cPdevRefs);
101  ASSERT(ppdev->cPdevRefs >= 0);
102 
103  /* Check if references are left */
104  if (ppdev->cPdevRefs == 0)
105  {
106  /* Do we have a surface? */
107  if (ppdev->pSurface)
108  {
109  /* Release the surface and let the driver free it */
110  SURFACE_ShareUnlockSurface(ppdev->pSurface);
111  ppdev->pfn.DisableSurface(ppdev->dhpdev);
112  }
113 
114  /* Do we have a palette? */
115  if (ppdev->ppalSurf)
116  {
117  PALETTE_ShareUnlockPalette(ppdev->ppalSurf);
118  }
119 
120  /* Check if the PDEV was enabled */
121  if (ppdev->dhpdev != NULL)
122  {
123  /* Disable the PDEV */
124  ppdev->pfn.DisablePDEV(ppdev->dhpdev);
125  }
126 
127  /* Remove it from list */
128  if (ppdev == gppdevList)
129  {
130  gppdevList = ppdev->ppdevNext;
131  }
132  else
133  {
134  PPDEVOBJ ppdevCurrent = gppdevList;
135  BOOL found = FALSE;
136  while (!found && ppdevCurrent->ppdevNext)
137  {
138  if (ppdevCurrent->ppdevNext == ppdev)
139  found = TRUE;
140  else
141  ppdevCurrent = ppdevCurrent->ppdevNext;
142  }
143  if (found)
144  ppdevCurrent->ppdevNext = ppdev->ppdevNext;
145  }
146 
147  /* Is this the primary one ? */
148  if (ppdev == gppdevPrimary)
150 
151  /* Free it */
152  PDEVOBJ_vDeletePDEV(ppdev);
153  }
154 
155  /* Unlock loader */
157 }
VOID WINAPI EngReleaseSemaphore(IN HSEMAPHORE hsem)
Definition: eng.c:235
#define SURFACE_ShareUnlockSurface(pBMObj)
Definition: surface.h:102
#define TRUE
Definition: types.h:120
PPDEVOBJ gppdevPrimary
Definition: pdevobj.c:13
struct _PDEVOBJ * ppdevNext
Definition: pdevobj.h:85
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
static HSEMAPHORE ghsemPDEV
Definition: pdevobj.c:16
ENGAPI VOID APIENTRY EngAcquireSemaphore(_Inout_ HSEMAPHORE hsem)
static PPDEVOBJ gppdevList
Definition: pdevobj.c:15
#define ASSERT(a)
Definition: mode.c:44
static VOID PDEVOBJ_vDeletePDEV(PPDEVOBJ ppdev)
Definition: pdevobj.c:82
#define InterlockedDecrement
Definition: armddk.h:52
#define PALETTE_ShareUnlockPalette(ppal)
Definition: palette.h:59
#define NULL
Definition: types.h:112

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

◆ PDEVOBJ_vSwitchPdev()

VOID NTAPI PDEVOBJ_vSwitchPdev ( PPDEVOBJ  ppdev,
PPDEVOBJ  ppdev2 
)

Definition at line 456 of file pdevobj.c.

459 {
460  union
461  {
462  DRIVER_FUNCTIONS pfn;
463  GDIINFO gdiinfo;
464  DEVINFO devinfo;
465  DWORD StateFlags;
466  } temp;
467 
468  /* Exchange driver functions */
469  temp.pfn = ppdev->pfn;
470  ppdev->pfn = ppdev2->pfn;
471  ppdev2->pfn = temp.pfn;
472 
473  /* Exchange LDEVs */
474  SwitchPointer(&ppdev->pldev, &ppdev2->pldev);
475 
476  /* Exchange DHPDEV */
477  SwitchPointer(&ppdev->dhpdev, &ppdev2->dhpdev);
478 
479  /* Exchange surfaces and associate them with their new PDEV */
480  SwitchPointer(&ppdev->pSurface, &ppdev2->pSurface);
481  ppdev->pSurface->SurfObj.hdev = (HDEV)ppdev;
482  ppdev2->pSurface->SurfObj.hdev = (HDEV)ppdev2;
483 
484  /* Exchange devinfo */
485  temp.devinfo = ppdev->devinfo;
486  ppdev->devinfo = ppdev2->devinfo;
487  ppdev2->devinfo = temp.devinfo;
488 
489  /* Exchange gdiinfo */
490  temp.gdiinfo = ppdev->gdiinfo;
491  ppdev->gdiinfo = ppdev2->gdiinfo;
492  ppdev2->gdiinfo = temp.gdiinfo;
493 
494  /* Exchange DEVMODE */
495  SwitchPointer(&ppdev->pdmwDev, &ppdev2->pdmwDev);
496 
497  /* Exchange state flags */
498  temp.StateFlags = ppdev->pGraphicsDevice->StateFlags;
500  ppdev2->pGraphicsDevice->StateFlags = temp.StateFlags;
501 
502  /* Notify each driver instance of its new HDEV association */
503  ppdev->pfn.CompletePDEV(ppdev->dhpdev, (HDEV)ppdev);
504  ppdev2->pfn.CompletePDEV(ppdev2->dhpdev, (HDEV)ppdev2);
505 }
DHPDEV dhpdev
Definition: pdevobj.h:121
struct _LDEVOBJ * pldev
Definition: pdevobj.h:120
GDIINFO gdiinfo
Definition: pdevobj.h:124
DWORD StateFlags
Definition: pdevobj.h:66
SURFOBJ SurfObj
Definition: surface.h:8
PDEVMODEW pdmwDev
Definition: pdevobj.h:130
DRIVER_FUNCTIONS pfn
Definition: pdevobj.h:139
DEVINFO devinfo
Definition: pdevobj.h:123
unsigned long DWORD
Definition: ntddk_ex.h:95
HDEV hdev
Definition: winddi.h:1208
static calc_node_t temp
Definition: rpn_ieee.c:38
PSURFACE pSurface
Definition: pdevobj.h:125
PFN_DrvCompletePDEV CompletePDEV
Definition: ntgdityp.h:570
PGRAPHICS_DEVICE pGraphicsDevice
Definition: pdevobj.h:128
FORCEINLINE VOID SwitchPointer(_Inout_ PVOID pvPointer1, _Inout_ PVOID pvPointer2)
Definition: pdevobj.c:441

Referenced by PDEVOBJ_bSwitchMode().

◆ SwitchPointer()

FORCEINLINE VOID SwitchPointer ( _Inout_ PVOID  pvPointer1,
_Inout_ PVOID  pvPointer2 
)

Definition at line 441 of file pdevobj.c.

444 {
445  PVOID *ppvPointer1 = pvPointer1;
446  PVOID *ppvPointer2 = pvPointer2;
447  PVOID pvTemp;
448 
449  pvTemp = *ppvPointer1;
450  *ppvPointer1 = *ppvPointer2;
451  *ppvPointer2 = pvTemp;
452 }

Referenced by PDEVOBJ_vSwitchPdev().

Variable Documentation

◆ ghsemPDEV

HSEMAPHORE ghsemPDEV
static

◆ gppdevList

PPDEVOBJ gppdevList = NULL
static

Definition at line 15 of file pdevobj.c.

Referenced by EngpGetPDEV(), NtGdiGetDhpdev(), and PDEVOBJ_vRelease().

◆ gppdevPrimary