Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

980 lines
36 KiB

  1. /******************************Module*Header********************************\
  2. * Module Name: pdevobj.hxx *
  3. * *
  4. * User object for the PDEV *
  5. * *
  6. * Copyright (c) 1990-1999 Microsoft Corporation *
  7. * *
  8. \**************************************************************************/
  9. #define _PDEVOBJ_
  10. #ifndef GDIFLAGS_ONLY // used for gdikdx
  11. extern PPDEV gppdevList;
  12. extern PPDEV gppdevTrueType;
  13. extern PPDEV gppdevATMFD;
  14. #endif // GDIFLAGS_ONLY used for gdikdx
  15. #define HOOK_BitBlt HOOK_BITBLT
  16. #define HOOK_StretchBlt HOOK_STRETCHBLT
  17. #define HOOK_PlgBlt HOOK_PLGBLT
  18. #define HOOK_TextOut HOOK_TEXTOUT
  19. #define HOOK_Paint HOOK_PAINT
  20. #define HOOK_StrokePath HOOK_STROKEPATH
  21. #define HOOK_FillPath HOOK_FILLPATH
  22. #define HOOK_StrokeAndFillPath HOOK_STROKEANDFILLPATH
  23. #define HOOK_CopyBits HOOK_COPYBITS
  24. #define HOOK_LineTo HOOK_LINETO
  25. #define HOOK_StretchBltROP HOOK_STRETCHBLTROP
  26. #define HOOK_TransparentBlt HOOK_TRANSPARENTBLT
  27. #define HOOK_AlphaBlend HOOK_ALPHABLEND
  28. #define HOOK_GradientFill HOOK_GRADIENTFILL
  29. /******************************Public*MACRO*******************************\
  30. * PDEV Creation flag
  31. *
  32. \*************************************************************************/
  33. #define GCH_DEFAULT_DISPLAY 1
  34. #define GCH_DDML 2
  35. #define GCH_PANNING 3
  36. #define GCH_MIRRORING 4
  37. #define GCH_CLONE_DISPLAY 5
  38. #define GCH_GDIPLUS_DISPLAY 6
  39. /******************************Public*MACRO*******************************\
  40. *
  41. * This is the acceleration level at which we allow absolutely no driver
  42. * accelerations.
  43. *
  44. \*************************************************************************/
  45. #define DRIVER_ACCELERATIONS_FULL 0
  46. #define DRIVER_ACCELERATIONS_NONE 5
  47. #define DRIVER_ACCELERATIONS_INVALID ((DWORD)(-1))
  48. /******************************Public*MACRO*******************************\
  49. *
  50. * This is the capable override defination. The value is set in registry.
  51. * It tells us what's the capability of a driver
  52. *
  53. \*************************************************************************/
  54. #define DRIVER_CAPABLE_ALL 0
  55. #define DRIVER_NOT_CAPABLE_GDI 1
  56. #define DRIVER_NOT_CAPABLE_DDRAW 2
  57. #define DRIVER_NOT_CAPABLE_D3D 4
  58. #define DRIVER_NOT_CAPABLE_OPENGL 8
  59. #define DRIVER_NOT_CAPABLE_ESCAPE 0x10
  60. /******************************Public*MACRO*******************************\
  61. * PFNDRV/PFNGET
  62. *
  63. * PFNDRV gets the device driver entry point, period.
  64. * PFNGET gets the device driver entry point if it is hooked, otherwise gets
  65. * the engine entry point. The flag is set by EngAssociate in the surface.
  66. *
  67. \**************************************************************************/
  68. #ifndef GDIFLAGS_ONLY // used for gdikdx
  69. #define PPFNGET(po,name,flag) ((flag & HOOK_##name) ? ((PFN_Drv##name) (po).ppfn(INDEX_Drv##name)) : ((PFN_Drv##name) Eng##name))
  70. #define PPFNDRV(po,name) ((PFN_Drv##name) (po).ppfn(INDEX_Drv##name))
  71. #define PPFNVALID(po,name) (PPFNDRV(po,name) != ((PFN_Drv##name) NULL))
  72. #define PPFNTABLE(apfn,name) ((PFN_Drv##name) apfn[INDEX_Drv##name])
  73. #define PPFNDRVENG(po,name) ((po).ppfn(INDEX_Drv##name) ? (PFN_Drv##name) (po).ppfn(INDEX_Drv##name) : (PFN_Drv##name) Eng##name )
  74. /******************************Public*MACRO*******************************\
  75. * PPFNDIRECT
  76. *
  77. * PPFNDIRECT retrieves the true device driver entry, bypassing any hooks
  78. * by the sprite layer or the like. This should be used only in very
  79. * limited circumstances; typically, all drawing should go through the
  80. * sprite layer and so one of the above macros should be used.
  81. \**************************************************************************/
  82. #define SPRITESTATE(pso) (&((PDEV*) pso->hdev)->SpriteState)
  83. #define PPFNDIRECT(pso, Name) \
  84. ((SURFOBJ_TO_SURFACE_NOT_NULL(pso)->flags() & HOOK_##Name) \
  85. ? SPRITESTATE(pso)->pfn##Name \
  86. : Eng##Name)
  87. #define PPFNDIRECTENG(pso, Name) \
  88. (SPRITESTATE(pso)->pfn##Name ? SPRITESTATE(pso)->pfn##Name \
  89. : Eng##Name)
  90. /**************************************************************************\
  91. * Stuff used for type one fonts.
  92. *
  93. \**************************************************************************/
  94. typedef struct tagTYPEONEMAP
  95. {
  96. FONTFILEVIEW fv;
  97. ULONG Checksum;
  98. } TYPEONEMAP;
  99. typedef struct tagTYPEONEINFO
  100. {
  101. COUNT cRef;
  102. COUNT cNumFonts;
  103. LARGE_INTEGER LastWriteTime;
  104. TYPEONEMAP aTypeOneMap[1];
  105. } TYPEONEINFO, *PTYPEONEINFO;
  106. extern LARGE_INTEGER gLastTypeOneWriteTime;
  107. extern PTYPEONEINFO gpTypeOneInfo;
  108. #endif // GDIFLAGS_ONLY used for gdikdx
  109. /*********************************Class************************************\
  110. * class PDEV : public OBJECT
  111. *
  112. \**************************************************************************/
  113. // Allowed flags for pdev.fl
  114. #define PDEV_DISPLAY 0x0001
  115. #define PDEV_HARDWARE_POINTER 0x0002
  116. #define PDEV_SOFTWARE_POINTER 0x0004
  117. #define PDEV_xxx1 0x0008
  118. #define PDEV_xxx2 0x0010
  119. #define PDEV_xxx3 0x0020
  120. #define PDEV_GOTFONTS 0x0040
  121. #define PDEV_PRINTER 0x0080
  122. #define PDEV_ALLOCATEDBRUSHES 0x0100
  123. #define PDEV_HTPAL_IS_DEVPAL 0x0200
  124. #define PDEV_DISABLED 0x0400
  125. #define PDEV_SYNCHRONIZE_ENABLED 0x0800
  126. #define PDEV_xxx4 0x1000
  127. #define PDEV_FONTDRIVER 0x2000
  128. #define PDEV_GAMMARAMP_TABLE 0x4000
  129. #define PDEV_UMPD 0x8000
  130. #define PDEV_SHARED_DEVLOCK 0x00010000
  131. #define PDEV_META_DEVICE 0x00020000
  132. #define PDEV_DRIVER_PUNTED_CALL 0x00040000
  133. #define PDEV_CLONE_DEVICE 0x00080000
  134. #define PDEV_MOUSE_TRAILS 0x00100000
  135. #define PDEV_SYNCHRONOUS_POINTER 0x00200000
  136. #define PDEV_WOW64_HTPATSIZE_USER 0x00400000
  137. // Allowed flags for pdev.flAccelerated
  138. #define ACCELERATED_CONSTANT_ALPHA 0x0001
  139. #define ACCELERATED_PIXEL_ALPHA 0x0002
  140. #define ACCELERATED_TRANSPARENT_BLT 0x0004
  141. #ifndef GDIFLAGS_ONLY // used for gdikdx
  142. class PDEV : public OBJECT /* pdev */
  143. {
  144. public:
  145. //
  146. // The following three fields may be accessed only when the
  147. // ghsemDriverMgmt semaphore is held.
  148. //
  149. PDEV *ppdevNext; // Next PDEV in the list.
  150. ULONG cPdevRefs; // Number of clients.
  151. ULONG cPdevOpenRefs; // OpenCount
  152. // - Number of references open from
  153. // DrvCreateMDEV including Desktop
  154. // MDEV and HDCs created from
  155. // CreateDC with a specified mode.
  156. //
  157. // WinBug 306193 2001-02-05 jasonha
  158. // CreateDC references are never
  159. // subtracted when DC is deleted.
  160. public:
  161. //
  162. // State that is persistent across calls to bDynamicModeChange:
  163. //
  164. PDEV *ppdevParent; // Parent PDEV. Same as 'this' if not multi-mon.
  165. FLONG fl; // PDEV_ flags.
  166. FLONG flAccelerated; // Hardware acceleration flags
  167. HSEMAPHORE hsemDevLock; // For display locking
  168. HSEMAPHORE hsemPointer; // For hardware locking.
  169. POINTL ptlPointer; // Where the pointer is.
  170. POINTL ptlHotSpot; // Current pointer's hot-spot.
  171. SPRITESTATE SpriteState; // Sprite drawing state
  172. HLFONT hlfntDefault; // Device default LFONT
  173. HLFONT hlfntAnsiVariable; // ANSI variable LFONT
  174. HLFONT hlfntAnsiFixed; // ANSI fixed LFONT
  175. HSURF ahsurf[HS_DDI_MAX]; // Default patterns.
  176. LPWSTR pwszDataFile; //
  177. PVOID pDevHTInfo; // Device halftone info.
  178. RFONT *prfntActive; // list of active (i.e. 'selected) rfnts
  179. RFONT *prfntInactive; // list of inactive rfnts
  180. UINT cInactive; // cnt of rfonts on inactive list
  181. ULONG_PTR ajbo[(sizeof(EBRUSHOBJ)+sizeof(ULONG_PTR)-1) /
  182. sizeof(ULONG_PTR)];// Gray brush used for drag rect
  183. ULONG cDirectDrawDisableLocks;// Count of outstanding requests to
  184. // disable DirectDraw; when zero,
  185. // DirectDraw can be re-enabled.
  186. PTYPEONEINFO TypeOneInfo; // Point to Type 1 Info given to this
  187. // pdev if PSCRIPT driver.
  188. PVOID pvGammaRampTable; // ICM DeviceGammaRamp table (256*3 bytes)
  189. PREMOTETYPEONENODE RemoteTypeOne; // Linked list of RemoteType1 fonts
  190. SIZEL sizlMeta; // Combined meta device size for multimon
  191. //
  192. // The following is PDEV data that is swapped along with the device by
  193. // 'bDynamicModeChange'. The rest of the PDEV is state that is tied
  194. // more to this PDEV than to the device.
  195. //
  196. PFN_DrvSetPointerShape pfnDrvSetPointerShape; // Accelerator
  197. PFN_DrvMovePointer pfnDrvMovePointer; // Accelerator
  198. PFN_DrvMovePointer pfnMovePointer; // Accelerator
  199. PFN_DrvSynchronize pfnSync; // Accelerator
  200. PFN_DrvSynchronizeSurface pfnSyncSurface; // Accelerator
  201. PFN_DrvSetPalette pfnSetPalette;
  202. PFN_DrvNotify pfnNotify;
  203. ULONG ulTag; // For debugging, should be 'Pdev'
  204. LDEV *pldev; // Pointer to the LDEV
  205. DHPDEV dhpdev; // Device PDEV
  206. PPALETTE ppalSurf; // Pointer to Surface palette
  207. DEVINFO devinfo; // Caps, fonts, and style steps
  208. GDIINFO GdiInfo; // Device parameters
  209. SURFACE *pSurface; // Pointer to locked device surface
  210. HANDLE hSpooler; // Spooler or miniport handle
  211. // in the virtual desktop
  212. PVOID pDesktopId; // Id of the desktop this device is
  213. // associated with
  214. GRAPHICS_DEVICE *pGraphicsDevice; // Pointer to the graphics device structure
  215. POINTL ptlOrigin; // Where this device is anchored
  216. DEVMODEW *ppdevDevmode; // DEVMODE for this instance
  217. PFN_DrvBitBlt pfnUnfilteredBitBlt;
  218. // Point to true driver DrvBitBlt routine,
  219. // from before vFilterDriverHooks() did its
  220. // work
  221. DWORD dwDriverCapableOverride;
  222. // A flag which indicates if the driver
  223. // is capable to GDI/DDRAW/D3D or not
  224. DWORD dwDriverAccelerationLevel;
  225. // Level that indicates how many
  226. // accelerations we allow for this
  227. // driver
  228. #ifdef DDI_WATCHDOG
  229. PVOID pWatchdogContext; // Points to shared watchdog context
  230. PWATCHDOG_DATA pWatchdogData; // Points to storage for watchdogs
  231. #endif
  232. PFN apfn[INDEX_LAST]; // Dispatch table
  233. DWORD daDirectDrawContext[1]; // DirectDraw state
  234. // !!! SHOULD NOT PUT ANYTHING AFTER daDirectDrawContext[1] !!!
  235. };
  236. /*********************************Class************************************\
  237. * class PDEVOBJ *
  238. * *
  239. * User object for the PDEV class. *
  240. * *
  241. \**************************************************************************/
  242. class PDEVOBJ
  243. {
  244. public:
  245. PDEV *ppdev;
  246. public:
  247. VOID vInit(HDEV hdev) {ppdev = (PDEV *) hdev;}
  248. PDEVOBJ() {vInit(NULL);}
  249. PDEVOBJ(HDEV hdev) {vInit(hdev);}
  250. PDEVOBJ(PLDEV pldev,
  251. PDEVMODEW pdriv,
  252. PWSZ pwszLogAddr,
  253. PWSZ pwszDataFile,
  254. PWSZ pwszDeviceName,
  255. HANDLE hSpooler,
  256. PREMOTETYPEONENODE pRemoteTypeOne = NULL,
  257. PGDIINFO pMirroredGdiInfo = NULL,
  258. PDEVINFO pMirroredDevInfo = NULL,
  259. BOOL bUMPD = FALSE,
  260. DWORD dwCapableOverride = DRIVER_CAPABLE_ALL,
  261. DWORD dwAccelerationLevel = 0);
  262. PDEVOBJ(HDEV hdev,
  263. FLONG fl);
  264. ~PDEVOBJ() {}
  265. #if DBG
  266. VOID vAssertDevLock(); // On checked builds, assert is in
  267. VOID vAssertDynaLock(); // pdevobj.cxx
  268. VOID vAssertNoDevLock();
  269. #else
  270. VOID vAssertDevLock() {} // On free builds, define to nothing
  271. VOID vAssertDynaLock() {}
  272. VOID vAssertNoDevLock() {}
  273. #endif
  274. BOOL bValid()
  275. {
  276. // Assert if the PDEV is pointing to garbage. We assert in this
  277. // case, rather than return failure, as no one should ever pass
  278. // us an invalid PDEV, and if they do we want to assert so that
  279. // the caller can be fixed.
  280. if (ppdev != NULL)
  281. {
  282. ASSERTGDI(ppdev->ulTag == 'Pdev', "Bad hdev");
  283. }
  284. return(ppdev != (PDEV *) NULL);
  285. }
  286. // 'hdevParent' returns the parent PDEV when the PDEV is a child PDEV in
  287. // a multi-monitor system. 'hdevParent' will be the same as 'hdev' when
  288. // not multi-monitor.
  289. HDEV hdev() {return((HDEV) ppdev);}
  290. HDEV hdevParent() {return((HDEV) ppdev->ppdevParent);}
  291. LDEV *pldev() {return(ppdev->pldev);}
  292. PW32PROCESS pid() {return(ppdev->pldev->pid);}
  293. HBITMAP hbmPattern(ULONG ul) {ASSERTGDI(ul < (HS_DDI_MAX), "ul too big");
  294. return((HBITMAP)ppdev->ahsurf[ul]);}
  295. ULONG cxDither() {return(ppdev->devinfo.cxDither); }
  296. ULONG cyDither() {return(ppdev->devinfo.cyDither); }
  297. //////////////////////////////////////////////////////////////////////////////
  298. // Fields that may be asynchronously modified by Dynamic Mode Changes
  299. //
  300. // The following fields may be changed by display driver dynamic mode
  301. // changes, so the appropriate locks must be acquired to access them.
  302. BOOL bMetaDriver() {vAssertDynaLock(); return(ppdev->fl & PDEV_META_DEVICE);}
  303. BOOL bMetaDriver(BOOL b) {SETFLAG(b,ppdev->fl,PDEV_META_DEVICE);return(b);}
  304. BOOL bCloneDriver() {vAssertDynaLock(); return(ppdev->fl & PDEV_CLONE_DEVICE);}
  305. BOOL bCloneDriver(BOOL b) {SETFLAG(b,ppdev->fl,PDEV_CLONE_DEVICE);return(b);}
  306. ULONG iDitherFormat() {vAssertDynaLock(); return(ppdev->devinfo.iDitherFormat);}
  307. ULONG iDitherFormatNotDynamic(){return(ppdev->devinfo.iDitherFormat);}
  308. ULONG iParentDitherFormat()
  309. {
  310. vAssertDynaLock();
  311. return(ppdev->ppdevParent->devinfo.iDitherFormat);
  312. }
  313. BOOL bIsPalManaged() {vAssertDynaLock(); return(ppdev->GdiInfo.flRaster & RC_PALETTE);}
  314. SURFACE *pSurface() {vAssertDynaLock(); return(ppdev->pSurface);}
  315. POINTL *pptlOrigin() {vAssertDynaLock(); return(&(ppdev->ptlOrigin)); }
  316. HANDLE hScreen() {vAssertDynaLock(); return(ppdev->hSpooler);}
  317. SIZEL sizl()
  318. {
  319. vAssertDynaLock();
  320. if (bMetaDriver())
  321. return(ppdev->sizlMeta);
  322. else
  323. return(*((SIZEL *)&(ppdev->GdiInfo.ulHorzRes)));
  324. }
  325. // Dispatch table functions:
  326. #if DBG
  327. PFN ppfn(ULONG i); // Call out-of-line for some debug code
  328. #else
  329. PFN ppfn(ULONG i) {return(ppdev->apfn[i]);}
  330. #endif
  331. PFN* apfn() {vAssertDynaLock(); return(ppdev->apfn);}
  332. // The following two methods must be used with care because their values may
  333. // change asynchronously, and no locks are asserted:
  334. BOOL bAsyncPointerMove() {return((ppdev->devinfo.flGraphicsCaps & GCAPS_ASYNCMOVE) &&
  335. !bSynchronousPointer());}
  336. PVOID pDevHTInfo() {return(ppdev->pDevHTInfo);}
  337. // 'dhpdevNotDynamic' and 'ppalSurfNotDynamic' may be used to skip the assert
  338. // verifying that a dynamic mode change lock is held, and should be used only
  339. // when the dhpdev or ppalSurf is not from a display device that can
  340. // dynamically change modes:
  341. DHPDEV dhpdev() {vAssertDynaLock(); return(ppdev->dhpdev);}
  342. DHPDEV dhpdevNotDynamic() {return(ppdev->dhpdev);}
  343. DHPDEV dhpdevParent()
  344. {
  345. vAssertDynaLock();
  346. ASSERTGDI(ppdev->ppdevParent,"PDEVOBJ::dhpdevParent(): ppdevParent is NULL\n");
  347. return(ppdev->ppdevParent->dhpdev);
  348. }
  349. PPALETTE ppalSurf() {vAssertDynaLock(); return(ppdev->ppalSurf); }
  350. PPALETTE ppalSurfNotDynamic() {return(ppdev->ppalSurf);}
  351. VOID ppalSurf(PPALETTE p) {ppdev->ppalSurf = p;}
  352. // Dynamic mode changes may cause the contents of the GDIINFO and DEVINFO
  353. // data to change at any time (but not the actual GdiInfo() or pdevinfo()
  354. // pointers). Consequently, a dynamic mode change lock must be held to
  355. // access the fields if you're concerned that the data may change. If you
  356. // don't care, use the 'NotDynamic' member function to access the data:
  357. FLONG flGraphicsCaps() {vAssertDynaLock(); return(ppdev->devinfo.flGraphicsCaps);}
  358. FLONG flGraphicsCapsNotDynamic() {return(ppdev->devinfo.flGraphicsCaps);}
  359. FLONG flGraphicsCaps2() {vAssertDynaLock(); return(ppdev->devinfo.flGraphicsCaps2);}
  360. FLONG flGraphicsCaps2NotDynamic(){return(ppdev->devinfo.flGraphicsCaps2);}
  361. GDIINFO *GdiInfo() {vAssertDynaLock(); return(&ppdev->GdiInfo);}
  362. GDIINFO *GdiInfoNotDynamic() {return(&ppdev->GdiInfo);}
  363. DEVINFO *pdevinfo() {vAssertDynaLock(); return(&ppdev->devinfo);}
  364. DEVINFO *pdevinfoNotDynamic() {return(&ppdev->devinfo);}
  365. BOOL bPrimary(SURFACE *pSurface) {return(pSurface == ppdev->pSurface);}
  366. // The following GDIINFO fields are currently guaranteed not to change during
  367. // dynamic mode changes, because bDynamicModeChange ensures that they don't
  368. // change. So call these member functions to access these fields:
  369. ULONG ulLogPixelsX() {return(ppdev->GdiInfo.ulLogPixelsX);}
  370. ULONG ulLogPixelsY() {return(ppdev->GdiInfo.ulLogPixelsY);}
  371. ULONG ulTechnology() {return(ppdev->GdiInfo.ulTechnology);}
  372. ULONG flTextCaps() {return(ppdev->GdiInfo.flTextCaps);}
  373. LONG xStyleStep() {return(ppdev->GdiInfo.xStyleStep);}
  374. LONG yStyleStep() {return(ppdev->GdiInfo.yStyleStep);}
  375. LONG denStyleStep() {return(ppdev->GdiInfo.denStyleStep);}
  376. ULONG ulGamma() {return(ppdev->GdiInfo.ulPhysicalPixelGamma);}
  377. BOOL bCapsHighResText() {return(ppdev->devinfo.flGraphicsCaps & GCAPS_HIGHRESTEXT);}
  378. BOOL bCapsForceDither() {return(ppdev->devinfo.flGraphicsCaps & GCAPS_FORCEDITHER);}
  379. //////////////////////////////////////////////////////////////////////////////
  380. ULONG cFonts();
  381. ULONG cPdevRefs() {return(ppdev->cPdevRefs);}
  382. // bDeleted -- determines whether a PDEV has been marked for deletion.
  383. // The PDEV will not be deleted immediately if there are active
  384. // references open on it. Note that this field can be accessed
  385. // only if ghsemDriverMgmt is held!
  386. BOOL bDeleted() {return(ppdev->cPdevOpenRefs == 0);}
  387. // fl -- Test the current status word
  388. FLONG fl(FLONG fl_ ) {return(ppdev->fl & fl_);}
  389. FLONG setfl(BOOL b,FLONG fl_ ) {SETFLAG(b,ppdev->fl,fl_);return(b);}
  390. // Flag test and set.
  391. BOOL bDisabled() {return(ppdev->fl & PDEV_DISABLED);}
  392. BOOL bDisabled(BOOL b);
  393. BOOL bFontDriver() {return(ppdev->fl & PDEV_FONTDRIVER);}
  394. BOOL bHardwarePointer() {return(ppdev->fl & PDEV_HARDWARE_POINTER);}
  395. BOOL bHardwarePointer(BOOL b) {SETFLAG(b,ppdev->fl,PDEV_HARDWARE_POINTER);return(b);}
  396. BOOL bSoftwarePointer() {return(ppdev->fl & PDEV_SOFTWARE_POINTER);}
  397. BOOL bSoftwarePointer(BOOL b) {SETFLAG(b,ppdev->fl,PDEV_SOFTWARE_POINTER);return(b);}
  398. BOOL bSynchronousPointer() {return(ppdev->fl & PDEV_SYNCHRONOUS_POINTER);}
  399. BOOL bSynchronousPointer(BOOL b) {SETFLAG(b,ppdev->fl,PDEV_SYNCHRONOUS_POINTER);return(b);}
  400. BOOL bMouseTrails() {return(ppdev->fl & PDEV_MOUSE_TRAILS);}
  401. BOOL bMouseTrails(BOOL b) {SETFLAG(b,ppdev->fl,PDEV_MOUSE_TRAILS);return(b);}
  402. BOOL bDisplayPDEV() {return(ppdev->fl & PDEV_DISPLAY);}
  403. BOOL bGotFonts() {return(ppdev->fl & PDEV_GOTFONTS);}
  404. BOOL bGotFonts(BOOL b) {SETFLAG(b,ppdev->fl,PDEV_GOTFONTS);return(b);}
  405. BOOL bPrinter() {return(ppdev->fl & PDEV_PRINTER);}
  406. BOOL bPrinter(BOOL b) {SETFLAG(b,ppdev->fl,PDEV_PRINTER);return(b);}
  407. BOOL bHTPalIsDevPal() {return(ppdev->fl & PDEV_HTPAL_IS_DEVPAL);}
  408. VOID vHTPalIsDevPal(BOOL b) {SETFLAG(b,ppdev->fl,PDEV_HTPAL_IS_DEVPAL);}
  409. BOOL bDriverPuntedCall() {return(ppdev->fl & PDEV_DRIVER_PUNTED_CALL);}
  410. VOID vDriverPuntedCall(BOOL b) {SETFLAG(b,ppdev->fl,PDEV_DRIVER_PUNTED_CALL);}
  411. BOOL bSynchronizeEnabled() {return(ppdev->fl & PDEV_SYNCHRONIZE_ENABLED);}
  412. VOID vSynchronizeEnabled(BOOL b) {SETFLAG(b,ppdev->fl,PDEV_SYNCHRONIZE_ENABLED);}
  413. // remote Type1 stuff
  414. PREMOTETYPEONENODE RemoteTypeOneGet(VOID){return(ppdev->RemoteTypeOne);}
  415. VOID RemoteTypeOneSet(PREMOTETYPEONENODE _RemoteTypeOne)
  416. {
  417. ppdev->RemoteTypeOne = _RemoteTypeOne;
  418. }
  419. // ptlPointer -- Where the pointer is.
  420. POINTL& ptlPointer() {return(ppdev->ptlPointer);}
  421. POINTL& ptlPointer(LONG x,LONG y)
  422. {
  423. ppdev->ptlPointer.x = x;
  424. ppdev->ptlPointer.y = y;
  425. return(ppdev->ptlPointer);
  426. }
  427. // ptlHotSpot - Current pointer's hot-spot.
  428. POINTL& ptlHotSpot() {return(ppdev->ptlHotSpot);}
  429. POINTL& ptlHotSpot(LONG x,LONG y)
  430. {
  431. ppdev->ptlHotSpot.x = x;
  432. ppdev->ptlHotSpot.y = y;
  433. return(ppdev->ptlHotSpot);
  434. }
  435. // pbo() -- Returns the brush used for drag rects.
  436. EBRUSHOBJ *pbo() { return((EBRUSHOBJ *) ppdev->ajbo); }
  437. // pfnSync() -- Get the driver synchronization routine.
  438. PFN_DrvSynchronize pfnSync() {return(ppdev->pfnSync);}
  439. VOID pfnSync(
  440. PFN_DrvSynchronize pfn) {ppdev->pfnSync=pfn;}
  441. PFN_DrvSynchronizeSurface pfnSyncSurface() {return(ppdev->pfnSyncSurface);}
  442. VOID pfnSyncSurface(
  443. PFN_DrvSynchronizeSurface pfn) {ppdev->pfnSyncSurface=pfn;}
  444. VOID vSync(SURFOBJ* pso, RECTL* prcl, FLONG fl);
  445. // pfnSetPalette -- Get the set palette routine.
  446. PFN_DrvSetPalette pfnSetPalette() {return(ppdev->pfnSetPalette);}
  447. VOID pfnSetPalette(
  448. PFN_DrvSetPalette pfn) {ppdev->pfnSetPalette=pfn;}
  449. // vUnreferencePdev --
  450. // Decrements the reference count of the PDEV. Deletes the PDEV if
  451. // there are no references left. NOTE: The DEVLOCK must not be held
  452. // if there's the possibility the PDEV may actually be freed!
  453. // vReferencePdev --
  454. // Increments the reference count.
  455. VOID vUnreferencePdev(CLEANUPTYPE cutype = CLEANUP_NONE);
  456. VOID vReferencePdev();
  457. // hsemDevLock() -- Returns the display semaphore.
  458. HSEMAPHORE hsemDevLock() {return(ppdev->hsemDevLock);}
  459. // vUseParentDevLock() -- Flip the devlock with parent and save old to Original
  460. BOOL bUseParentDevLock() {vAssertDynaLock(); return(ppdev->fl & PDEV_SHARED_DEVLOCK);}
  461. BOOL bUseParentDevLock(BOOL b) {SETFLAG(b,ppdev->fl,PDEV_SHARED_DEVLOCK);return(b);}
  462. VOID vUseParentDevLock()
  463. {
  464. //
  465. // 1) Parent should be existed.
  466. // 2) Parent should NOT be same as me.
  467. // 3) Parent DEVLOCK should NOT be NULL.
  468. //
  469. ASSERTGDI(ppdev->ppdevParent != NULL,"PDEVOBJ.UseParentDevLock():Parent is NULL\n");
  470. ASSERTGDI(ppdev->ppdevParent != ppdev,"PDEVOBJ.UseParentDevLock():Parent is Me\n");
  471. ASSERTGDI(ppdev->ppdevParent->hsemDevLock != NULL,"PDEVOBJ.UseParentDevLock():Parent DevLock is NULL\n");
  472. //
  473. // If hsemDevLock points same as parent, we are done.
  474. //
  475. if (ppdev->hsemDevLock != ppdev->ppdevParent->hsemDevLock)
  476. {
  477. //
  478. // 4) My own DEVLOCK should NOT be locked.
  479. //
  480. // ASSERTGDI(ppdev->hsemDevLock->ActiveCount == 0,"PDEVOBJ.UseParentDevLock():Locked!\n");
  481. //
  482. // If we are switch from Private Lock to Shared Lock, delete old lock and mark it
  483. // "shared". If we are already using shared lock, we don't delete it here, owner
  484. // (= most of case it's parent) will delete it.
  485. //
  486. if (!bUseParentDevLock())
  487. {
  488. GreDeleteSemaphore(ppdev->hsemDevLock);
  489. bUseParentDevLock(TRUE);
  490. }
  491. //
  492. // Exchanges the pointer with parent devlock.
  493. //
  494. ppdev->hsemDevLock = ppdev->ppdevParent->hsemDevLock;
  495. }
  496. else
  497. {
  498. ASSERTGDI(bUseParentDevLock(),"PDEVOBJ.UseParentDevLock():Not mark as shared\n");
  499. }
  500. }
  501. // hsemPointer() -- Returns the hardware semaphore.
  502. HSEMAPHORE hsemPointer() {return(ppdev->hsemPointer);}
  503. // bMakeSurface -- Asks the device driver to create a surface for the PDEV.
  504. BOOL bMakeSurface();
  505. // vDisableSurface() -- deletes the surface
  506. VOID vDisableSurface(CLEANUPTYPE cutype = CLEANUP_NONE);
  507. HANDLE hSpooler() { return ppdev->hSpooler; }
  508. HANDLE hSpooler(HANDLE hS) { return ppdev->hSpooler = hS; }
  509. // pDirectDrawContext() -- Returns a pointer to DirectDraw context for this PDEV
  510. PVOID pDirectDrawContext() { return(&(ppdev->daDirectDrawContext[0])); }
  511. // cDirectDrawDisableLocks() -- Return a lock count of DirectDraw
  512. ULONG cDirectDrawDisableLocks() { return(ppdev->cDirectDrawDisableLocks); }
  513. VOID cDirectDrawDisableLocks(ULONG c)
  514. { ppdev->cDirectDrawDisableLocks = c; }
  515. // pSpriteState() -- Returns a pointer to Sprite context for this PDEV
  516. SPRITESTATE *pSpriteState() { return(&ppdev->SpriteState); }
  517. // flAccelerated() -- Returns flags that indicated device acceleration
  518. FLONG flAccelerated() { return(ppdev->flAccelerated); }
  519. VOID vAccelerated(FLONG fl) { ppdev->flAccelerated |= fl; }
  520. // hlfntDefault -- Returns the handle to the PDEV's default LFONT.
  521. HLFONT hlfntDefault() { return(ppdev->hlfntDefault); }
  522. // hlfntAnsiVariable -- Returns the handle to the PDEV's ANSI
  523. // variable-pitch LFONT.
  524. HLFONT hlfntAnsiVariable() { return(ppdev->hlfntAnsiVariable); }
  525. // hlfntAnsiFixed -- Returns the handle to the PDEV's ANSI fixed-pitch LFONT.
  526. HLFONT hlfntAnsiFixed() { return(ppdev->hlfntAnsiFixed); }
  527. // Creates the default brushes for the display driver.
  528. BOOL bCreateDefaultBrushes();
  529. // bEnableHalftone -- Create and initialize the device halftone info.
  530. BOOL bEnableHalftone(COLORADJUSTMENT *pca);
  531. // bDisableHalftone -- Delete the device halftone info.
  532. BOOL bDisableHalftone();
  533. #if defined(_WIN64)
  534. // vDeleteWOW64HTPATSIZEUSER
  535. VOID vDeleteWOW64HTPATSIZEUSERAllocations()
  536. {
  537. if (fl(PDEV_WOW64_HTPATSIZE_USER))
  538. {
  539. EngFreeUserMem(ppdev->GdiInfo.pHTPatA);
  540. EngFreeUserMem(ppdev->GdiInfo.pHTPatB);
  541. EngFreeUserMem(ppdev->GdiInfo.pHTPatC);
  542. }
  543. }
  544. #endif
  545. // bCreateHalftoneBrushes() -- init the standard brushs if the driver didn't
  546. BOOL bCreateHalftoneBrushes();
  547. // prfntActive() -- returns the head of the active list of rfnts
  548. RFONT *prfntActive() { return ppdev->prfntActive; }
  549. // prfntActive(RFONT *) -- set head of active list of rfnt, return old head
  550. RFONT *prfntActive(RFONT *prf)
  551. {
  552. RFONT *prfntrv = ppdev->prfntActive;
  553. ppdev->prfntActive = prf;
  554. return prfntrv;
  555. }
  556. // prfntInactive() -- returns the head of the inactive list of rfnts
  557. RFONT *prfntInactive() { return ppdev->prfntInactive; }
  558. // prfntInactive(RFONT *) -- set head of inactive list of rfnt, return old head
  559. RFONT *prfntInactive(RFONT *prf)
  560. {
  561. RFONT *prfntrv = ppdev->prfntInactive;
  562. ppdev->prfntInactive = prf;
  563. return prfntrv;
  564. }
  565. UINT cInactive() { return ppdev->cInactive; };
  566. UINT cInactive(UINT i) { return ppdev->cInactive = i; };
  567. // lazy load of device fonts
  568. BOOL bGetDeviceFonts();
  569. // User-mode-printer-driver flag
  570. BOOL bUMPD() {return(ppdev->fl & PDEV_UMPD);}
  571. BOOL bUMPD(BOOL b) {SETFLAG(b,ppdev->fl,PDEV_UMPD);return(b);}
  572. // ICM stuff
  573. BOOL bHasGammaRampTable() {return(ppdev->fl & PDEV_GAMMARAMP_TABLE);}
  574. BOOL bHasGammaRampTable(BOOL b) {SETFLAG(b,ppdev->fl,PDEV_GAMMARAMP_TABLE);return(b);}
  575. PVOID pvGammaRampTable() {return(ppdev->pvGammaRampTable);}
  576. PVOID pvGammaRampTable(PVOID p) {ppdev->pvGammaRampTable = p;return (p);}
  577. // returns TRUE if path matches the path of the image of this PDEV's LDEV
  578. BOOL MatchingLDEVImage(UNICODE_STRING usDriverName)
  579. {
  580. return((ppdev->pldev->pGdiDriverInfo != NULL) &&
  581. RtlEqualUnicodeString(&(ppdev->pldev->pGdiDriverInfo->DriverName),
  582. &usDriverName,
  583. TRUE));
  584. }
  585. // Notify
  586. VOID vNotify(ULONG iType, PVOID pvData);
  587. // disable driver functionality as appropriate
  588. VOID vFilterDriverHooks();
  589. // driver capable override.
  590. DWORD dwDriverCapableOverride() {return(ppdev->dwDriverCapableOverride);}
  591. // driver acceleration level.
  592. DWORD dwDriverAccelerationsLevel() {return(ppdev->dwDriverAccelerationLevel);}
  593. VOID vSetDriverAccelerationsLevel(DWORD dwNewLevel) {ppdev->dwDriverAccelerationLevel=dwNewLevel;}
  594. // proile the driver
  595. VOID vProfileDriver();
  596. DHPDEV EnablePDEV(
  597. DEVMODEW *pdm
  598. , LPWSTR pwszLogAddress
  599. , ULONG cPat
  600. , HSURF *phsurfPatterns
  601. , ULONG cjCaps
  602. , GDIINFO *pGdiInfo
  603. , ULONG cjDevInfo
  604. , DEVINFO *pdi
  605. , HDEV hdev
  606. , LPWSTR pwszDeviceName
  607. , HANDLE hDriver
  608. );
  609. VOID DisablePDEV(
  610. DHPDEV dhpdev
  611. );
  612. VOID CompletePDEV(
  613. DHPDEV dhpdev
  614. , HDEV hdev
  615. );
  616. IFIMETRICS* QueryFont(
  617. DHPDEV dhpdev
  618. , ULONG_PTR iFile
  619. , ULONG iFace
  620. , ULONG_PTR *pid
  621. );
  622. PVOID QueryFontTree(
  623. DHPDEV dhpdev
  624. , ULONG_PTR iFile
  625. , ULONG iFace
  626. , ULONG iMode
  627. , ULONG_PTR *pid
  628. );
  629. PFD_GLYPHATTR QueryGlyphAttrs(
  630. FONTOBJ *pfo,
  631. ULONG iMode
  632. );
  633. LONG QueryFontData(
  634. DHPDEV dhpdev
  635. , FONTOBJ *pfo
  636. , ULONG iMode
  637. , HGLYPH hg
  638. , GLYPHDATA *pgd
  639. , PVOID pv
  640. , ULONG cjSize
  641. );
  642. VOID DestroyFont(
  643. FONTOBJ *pfo
  644. );
  645. LONG QueryFontCaps(
  646. ULONG culCaps
  647. , ULONG *pulCaps
  648. );
  649. HFF LoadFontFile(
  650. ULONG cFiles
  651. , ULONG_PTR *piFile
  652. , PVOID *ppvView
  653. , ULONG *pcjView
  654. , DESIGNVECTOR *pdv
  655. , ULONG ulLangID
  656. , ULONG ulFastCheckSum
  657. );
  658. BOOL UnloadFontFile(
  659. ULONG_PTR iFile
  660. );
  661. LONG QueryFontFile(
  662. ULONG_PTR iFile
  663. , ULONG ulMode
  664. , ULONG cjBuf
  665. , ULONG *pulBuf
  666. );
  667. BOOL QueryAdvanceWidths(
  668. DHPDEV dhpdev
  669. , FONTOBJ *pfo
  670. , ULONG iMode
  671. , HGLYPH *phg
  672. , PVOID pvWidths
  673. , ULONG cGlyphs
  674. );
  675. VOID Free(
  676. PVOID pv
  677. , ULONG_PTR id
  678. );
  679. LONG QueryTrueTypeTable(
  680. ULONG_PTR iFile
  681. , ULONG ulFont
  682. , ULONG ulTag
  683. , PTRDIFF dpStart
  684. , ULONG cjBuf
  685. , BYTE *pjBuf
  686. , BYTE **ppjTable
  687. , ULONG *pcjTable
  688. );
  689. LONG QueryTrueTypeOutline(
  690. DHPDEV dhpdev
  691. , FONTOBJ *pfo
  692. , HGLYPH hglyph
  693. , BOOL bMetricsOnly
  694. , GLYPHDATA *pgldt
  695. , ULONG cjBuf
  696. , TTPOLYGONHEADER *ppoly
  697. );
  698. PVOID GetTrueTypeFile(
  699. ULONG_PTR iFile
  700. , ULONG *pcj
  701. );
  702. BOOL FontManagement (
  703. SURFOBJ *pso,
  704. FONTOBJ *pfo,
  705. ULONG iEsc,
  706. ULONG cjIn,
  707. PVOID pvIn,
  708. ULONG cjOut,
  709. PVOID pvOut
  710. );
  711. ULONG Escape(
  712. SURFOBJ *pso
  713. , ULONG iEsc
  714. , ULONG cjIn
  715. , PVOID pvIn
  716. , ULONG cjOut
  717. , PVOID pvOut
  718. );
  719. };
  720. typedef PDEVOBJ *PPDEVOBJ;
  721. // Miscellaneous PDEV-related prototypes:
  722. VOID vEnableSynchronize(HDEV hdev);
  723. VOID vDisableSynchronize(HDEV hdev);
  724. HDEV hdevEnumerate(HDEV hdevPrevious);
  725. // Support class to disable and enable Watchdog
  726. class SUSPENDWATCH
  727. {
  728. public:
  729. PDEV *_ppdev;
  730. SUSPENDWATCH()
  731. {
  732. #ifdef DDI_WATCHDOG
  733. _ppdev = NULL;
  734. #endif
  735. }
  736. SUSPENDWATCH(PDEVOBJ& pdo)
  737. {
  738. Suspend(pdo);
  739. }
  740. void Suspend(PDEVOBJ& pdo)
  741. {
  742. #ifdef DDI_WATCHDOG
  743. _ppdev = NULL;
  744. if (pdo.bValid() && pdo.bDisplayPDEV())
  745. {
  746. _ppdev = pdo.ppdev;
  747. GreSuspendWatch(_ppdev, WD_DEVLOCK);
  748. }
  749. #endif
  750. }
  751. void Resume()
  752. {
  753. #ifdef DDI_WATCHDOG
  754. if (_ppdev)
  755. {
  756. GreResumeWatch(_ppdev, WD_DEVLOCK);
  757. _ppdev = NULL;
  758. }
  759. #endif
  760. }
  761. ~SUSPENDWATCH()
  762. {
  763. Resume();
  764. }
  765. };
  766. #endif // GDIFLAGS_ONLY used for gdikdx