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.

377 lines
18 KiB

  1. /**************************************************************************\
  2. *
  3. * Copyright (c) 1998 Microsoft Corporation
  4. *
  5. * Abstract:
  6. *
  7. * Contains all the globals used by GDI+.
  8. *
  9. * History:
  10. *
  11. * 12/06/1998 andrewgo
  12. * Created it.
  13. *
  14. \**************************************************************************/
  15. #ifndef __GLOBALS_HPP
  16. #define __GLOBALS_HPP
  17. class GpDevice;
  18. class GpPrinterDevice;
  19. class DpBitmap;
  20. class DpDriver;
  21. class DriverMulti;
  22. class GpFontTable;
  23. class GpFontLink;
  24. class GpFontFile;
  25. class GpDeviceList;
  26. // Private DirectDraw export:
  27. typedef HRESULT (WINAPI *DIRECTDRAWCREATEEXFUNCTION)(GUID*,
  28. VOID*,
  29. REFIID,
  30. IUnknown*);
  31. typedef HRESULT (WINAPI *GETDDRAWSURFACEFROMDCFUNCTION)(HDC,
  32. LPDIRECTDRAWSURFACE*,
  33. HDC*);
  34. typedef HRESULT (WINAPI *DIRECTDRAWENUMERATEEXFUNCTION)(LPDDENUMCALLBACKEXA,
  35. LPVOID,
  36. DWORD);
  37. // GDI exports
  38. typedef BOOL (WINAPI *EXTTEXTOUTFUNCTION) ( HDC,
  39. int,
  40. int,
  41. UINT,
  42. CONST RECT *,
  43. LPCWSTR,
  44. UINT,
  45. CONST INT *);
  46. // Private NT GDI export:
  47. typedef BOOL (APIENTRY *GDIISMETAPRINTDCFUNCTION)(HDC);
  48. // Win98/NT5 only stuff:
  49. typedef WINUSERAPI BOOL (WINAPI *GETMONITORINFOFUNCTION)(HMONITOR,
  50. LPMONITORINFOEXA);
  51. typedef WINUSERAPI BOOL (WINAPI *ENUMDISPLAYMONITORSFUNCTION)(HDC,
  52. LPCRECT,
  53. MONITORENUMPROC,
  54. LPARAM);
  55. typedef WINUSERAPI BOOL (WINAPI *ENUMDISPLAYDEVICESFUNCTION)(LPCSTR,
  56. DWORD,
  57. PDISPLAY_DEVICEA,
  58. DWORD);
  59. typedef WINUSERAPI HWINEVENTHOOK (WINAPI *SETWINEVENTHOOKFUNCTION)(DWORD,
  60. DWORD,
  61. HMODULE,
  62. WINEVENTPROC,
  63. DWORD,
  64. DWORD,
  65. DWORD);
  66. typedef WINUSERAPI BOOL (WINAPI *UNHOOKWINEVENTFUNCTION)(HWINEVENTHOOK);
  67. typedef WINUSERAPI BOOL (WINAPI *GETWINDOWINFOFUNCTION)(HWND, PWINDOWINFO);
  68. typedef WINUSERAPI HWND (WINAPI *GETANCESTORFUNCTION)(HWND, UINT);
  69. typedef USHORT (*CAPTURESTACKBACKTRACEFUNCTION)(ULONG, ULONG, PVOID *, PULONG);
  70. // Lazy load of DCI:
  71. typedef int (WINAPI *DCICREATEPRIMARYFUNCTION)(HDC, LPDCISURFACEINFO FAR *);
  72. typedef void (WINAPI *DCIDESTROYFUNCTION)(LPDCISURFACEINFO);
  73. typedef DCIRVAL (WINAPI *DCIBEGINACCESSFUNCTION)(LPDCISURFACEINFO, int, int, int, int);
  74. typedef void (WINAPI *DCIENDACCESSFUNCTION)(LPDCISURFACEINFO);
  75. // Winspool.drv export ('A' version only)
  76. typedef BOOL (WINAPI *WINSPOOLGETPRINTERDRIVERFUNCTION)(HANDLE hPrinter,
  77. LPSTR pEnvironment,
  78. DWORD Level,
  79. LPBYTE pDriverInfo,
  80. DWORD vbBuf,
  81. LPDWORD pcbNeeded);
  82. // Most of our globals.
  83. // There are additions to the Globals namespace in engine\entry\initialize.cpp
  84. // See also, globals.cpp.
  85. namespace Globals
  86. {
  87. extern BOOL IsNt; // Are we running on any version of NT?
  88. extern BOOL IsWin95; // Neither NT nor Win98?
  89. extern BOOL VersionInfoInitialized; // Wheter the version info has been
  90. // initialized or not.
  91. extern OSVERSIONINFOA OsVer; // More specific OS Version info
  92. extern UINT ACP; // Active Code Page
  93. extern GpDevice *DesktopDevice; // The device representing the entire
  94. // desktop
  95. extern GpDeviceList *DeviceList; // List of devices that we know about
  96. extern DpBitmap *DesktopSurface; // A surface representing the desktop
  97. extern DpDriver *DesktopDriver; // The driver representing desktop
  98. // drawing
  99. extern DpDriver *EngineDriver; // The virtual driver representing only
  100. // GDI+ Eng drawing functionality
  101. extern DpDriver *GdiDriver; // The virtual driver that draws using
  102. // only GDI routines
  103. extern DpDriver *D3DDriver; // The virtual driver that draws using
  104. // only D3D/DD routines
  105. extern DpDriver *InfoDriver; // The virtual driver that doesn't draw
  106. // anything -- used for metafiles
  107. extern DpDriver *MetaDriver; // The virtual driver that draws using
  108. // only GDI routines for Metafiles
  109. extern BOOL DirectDrawInitialized; // Flag indicating whether diret draw
  110. // and direct 3D related globals have
  111. // been initialized.
  112. extern BOOL DirectDrawInitAttempted;// Flag indicating whether we have tried
  113. // to initialized direct draw and
  114. // direct 3d globals
  115. extern HINSTANCE DdrawHandle; // DirectDraw DLL handle
  116. extern IDirectDraw7 * DirectDraw; // Pointer to the direct draw interface
  117. // for the desktop
  118. extern IDirect3D7 * Direct3D; // Pointer to the direct 3D interface
  119. // for the desktop
  120. extern DIRECTDRAWCREATEEXFUNCTION DirectDrawCreateExFunction;
  121. // Pointer to the direct draw static
  122. // function used for creation of the
  123. // direct draw interface
  124. extern DIRECTDRAWENUMERATEEXFUNCTION DirectDrawEnumerateExFunction;
  125. // Pointer to the direct draw
  126. // enumeration function
  127. extern GETDDRAWSURFACEFROMDCFUNCTION GetDdrawSurfaceFromDcFunction;
  128. // Pointer to private DirectDraw
  129. // function for getting a DDraw
  130. // surface from an HDC
  131. extern EXTTEXTOUTFUNCTION ExtTextOutFunction;
  132. // Pointer to either ExtTextOutA
  133. // or ExtTextOutW. depends on IsNt
  134. extern GDIISMETAPRINTDCFUNCTION GdiIsMetaPrintDCFunction;
  135. // Pointer to appropriate function for
  136. // determining if a metafile DC is
  137. // actually a metafiled printer DC
  138. // (Points to an internal GDI
  139. // function on NT, and to our own
  140. // routine on Win9x)
  141. extern GETMONITORINFOFUNCTION GetMonitorInfoFunction;
  142. // Pointer to GetMonitorInfo used
  143. // used for getting information
  144. // for a monitor identified by a
  145. // HMONITOR.
  146. extern ENUMDISPLAYMONITORSFUNCTION EnumDisplayMonitorsFunction;
  147. // Pointer to EnumDisplayMonitors
  148. // function used for enumerating all
  149. // of the monitors of a multi-mon
  150. // capable Win32 platform.
  151. extern ENUMDISPLAYDEVICESFUNCTION EnumDisplayDevicesFunction;
  152. // Pointer to EnumDisplayDevices
  153. // function used for enumerating all
  154. // of the display devices of a
  155. // multi-mon capable Win32 platform.
  156. extern HMODULE DcimanHandle;
  157. extern DCICREATEPRIMARYFUNCTION DciCreatePrimaryFunction;
  158. extern DCIDESTROYFUNCTION DciDestroyFunction;
  159. extern DCIBEGINACCESSFUNCTION DciBeginAccessFunction;
  160. extern DCIENDACCESSFUNCTION DciEndAccessFunction;
  161. // Pointer to all functions imported
  162. // from DCI, so that we can
  163. // delay load DCIMAN32.DLL for perf
  164. // reasons
  165. extern CAPTURESTACKBACKTRACEFUNCTION CaptureStackBackTraceFunction;
  166. // Pointer to RtlCaptureStackBackTrace
  167. // function (if available)
  168. extern GETWINDOWINFOFUNCTION GetWindowInfoFunction;
  169. // Pointer to User32's GetWindowInfo
  170. // function (if available)
  171. extern GETANCESTORFUNCTION GetAncestorFunction;
  172. // Pointer to User32's GetAncestor
  173. // function (if available)
  174. extern SETWINEVENTHOOKFUNCTION SetWinEventHookFunction;
  175. // Pointer to User32's SetWinEventHook
  176. // function (if available)
  177. extern UNHOOKWINEVENTFUNCTION UnhookWinEventFunction;
  178. // Pointer to User32's UnhookWinEvent
  179. // function (if available)
  180. extern BOOL IsMoveSizeActive; // TRUE if we're running on NT and our
  181. // window event hook has indicated
  182. // that the user is currently dragging
  183. // windows around
  184. extern HRGN CachedGdiRegion; // Cached region for random calls that
  185. // require a region. The contents
  186. // aren't important; rather its
  187. // existence is. This handle must
  188. // always be non-NULL
  189. // On the NT codebase, the CreateDC(DISPLAY, NULL, NULL, NULL) call has
  190. // thread affinity. This means that the desktop DC would go away if the
  191. // thread which called GdiplusStartup terminated even if we were still
  192. // using it.
  193. // On NT we create an Info DC which has process affinity. Rendering onto
  194. // an Info DC is not supported but that's ok because we always create
  195. // DriverMulti on NT - and therefore always render on a monitor specific
  196. // DC instead.
  197. // Win9x does not have the thread affinity problem and we'd use an IC
  198. // if it weren't for the fact that win95 doesn't have EnumDisplayMonitors
  199. // and hence uses DriverGdi instead of DriverMulti - rendering directly
  200. // on the DesktopIc
  201. // see RAID:
  202. // 301407 GDI+ Globals::DesktopDC has thread affinity
  203. // 312342 CreateDC("Display", NULL, NULL, NULL) has thread affinity.
  204. // and gdiplus/test/multithread for a test app that exposes this problem.
  205. // I.e. Don't render on this DC - it won't work. It's for informational
  206. // purposes only.
  207. extern HDC DesktopIc; // Handle to the global desktop DC
  208. extern REAL DesktopDpiX; // DpiX of desktop HDC (from GetDeviceCaps)
  209. extern REAL DesktopDpiY; // DpiY of desktop HDC (from GetDeviceCaps)
  210. extern GpInstalledFontCollection *FontCollection; // Table of loaded fonts
  211. extern GpFontLink *FontLinkTable ; // Linked fonts Table
  212. extern GpFontFamily **SurrogateFontsTable; // Surrogate font fallback family table
  213. extern GpCacheFaceRealizationList *FontCacheLastRecentlyUsedList; // list of last recently used CacheFaceRealization
  214. extern WCHAR* FontsDirW; // Fonts dir needed by addfontresource (Nt)
  215. extern CHAR* FontsDirA; // Fonts dir needed by addfontresource (Win9x)
  216. extern WCHAR* FontsKeyW; // Registry key for fonts (Nt)
  217. extern CHAR* FontsKeyA; // Registry key for fonts (Win9x)
  218. extern BOOL TextCriticalSectionInitialized; // has the text critical section been initialized
  219. extern CRITICAL_SECTION TextCriticalSection; // global critical section that protect all the text calls
  220. // claudebe 4/5/00 at this time we want to protect globally as opposed
  221. // to protect separately font cache, font realization access like in GDI
  222. // the idea is that we don't expect to have a huge amount of threads in parallel as in GDI
  223. // so performance is considered as acceptable for GDI+
  224. // if we want to change it the other way, look for commented code with
  225. // FontFileCacheCritSection, FontFamilyCritSection, FaceRealizationCritSection, g_cstb, csCache and ghsemTTFD
  226. extern TextRenderingHint CurrentSystemRenderingHint; // current system text rendering mode, used to implement the TextRenderingHintSystemDefault mode
  227. extern BOOL CurrentSystemRenderingHintInvalid; // Should we re-read CurrentSystemRenderingHint user settings?
  228. extern USHORT LanguageID; // LangID needed by ttfd, for US = 0x0409
  229. extern LONG_PTR LookAsideCount;
  230. extern BYTE* LookAsideBuffer;
  231. extern INT LookAsideBufferSize;
  232. extern UINT PaletteChangeCount;
  233. extern COLORREF SystemColors[];
  234. extern HANDLE hCachedPrinter; // for postscript cache printer handle
  235. extern INT CachedPSLevel; // + level
  236. // !!![ericvan] We should use: CHAR CachedPrinterName[CCHDEVICENAME];
  237. extern HINSTANCE WinspoolHandle;
  238. extern WINSPOOLGETPRINTERDRIVERFUNCTION GetPrinterDriverFunction;
  239. extern HMODULE UniscribeDllModule; // Loaded Uniscribe (usp10.dll) module
  240. extern IntMap<BYTE> *NationalDigitCache; // National Digit Substitution cache
  241. extern BOOL UserDigitSubstituteInvalid; // Should we re-read digit sub user settings?
  242. // clear type lookup tables
  243. // filtered counts of RGB
  244. struct F_RGB
  245. {
  246. BYTE kR;
  247. BYTE kG;
  248. BYTE kB;
  249. BYTE kPadding;
  250. };
  251. extern const F_RGB * gaOutTable;
  252. extern const BYTE FilteredCTLut[];
  253. extern const BYTE TextContrastTableIdentity[256];
  254. typedef const BYTE TEXT_CONTRAST_TABLES[12][256];
  255. extern TEXT_CONTRAST_TABLES TextContrastTablesDir; // 1.1 ... 2.2
  256. extern TEXT_CONTRAST_TABLES TextContrastTablesInv; // 1.1 ... 2.2
  257. extern GpPath * PathLookAside;
  258. extern GpMatrix * MatrixLookAside;
  259. extern GpPen * PenLookAside;
  260. // Is this instance of gdiplus running in terminal server session space.
  261. extern BOOL IsTerminalServer;
  262. // For an explanation of GDIPLUS_MIRROR_DRIVER_NO_DCI, see
  263. // pdrivers\drivermulti.cpp or bug #92982.
  264. // TRUE if any mirror driver is active on the system.
  265. extern BOOL IsMirrorDriverActive;
  266. // User-supplied debug event reporting callback
  267. extern DebugEventProc UserDebugEventProc;
  268. //// START Synchronized under GdiplusStartupCriticalSection
  269. extern HANDLE ThreadNotify; // Thread handle for hidden window notify
  270. extern DWORD ThreadId; // Thread ID for hidden window notify
  271. // These two are used by GdiplusStartup and GdiplusShutdown
  272. extern ULONG_PTR LibraryInitToken;
  273. extern INT LibraryInitRefCount;
  274. // This is used by NotificationStartup and NotificationShutdown.
  275. extern ULONG_PTR NotificationInitToken;
  276. // The token of the module which owns the hidden window.
  277. // See "NotificationModuleToken" below.
  278. extern ULONG_PTR HiddenWindowOwnerToken;
  279. //// END Synchronized under GdiplusStartupCriticalSection (on GDIPLUS.DLL)
  280. //// START Synchronized under BackgroundThreadCriticalSection:
  281. extern HANDLE ThreadQuitEvent; // Event object for killing the background thread
  282. extern HWND HwndNotify; // HWND for hidden window notify
  283. extern ATOM WindowClassAtom; // Atom for our "notification window" class
  284. extern HWINEVENTHOOK WinEventHandle;// Handle to our window event hook
  285. //// END Synchronized under BackgroundThreadCriticalSection:
  286. extern BOOL g_fAccessibilityPresent;
  287. extern UINT g_nAccessibilityMessage;// Window message to disable accessibility messages.
  288. };
  289. // For the variable HiddenWindowOwnerToken, we have 2 values with special
  290. // meanings:
  291. //
  292. // NotificationModuleTokenNobody: No module currently owns the hidden window.
  293. // i.e. we're waiting for the first initializer to call NotificationStartup.
  294. // NotificationModuleTokenGdiplus: GDI+ itself owns the hidden window - i.e.
  295. // the background thread is running.
  296. enum NotificationModuleToken
  297. {
  298. NotificationModuleTokenNobody,
  299. NotificationModuleTokenGdiplus,
  300. NotificationModuleTokenMax = NotificationModuleTokenGdiplus
  301. };
  302. BOOL InitializeDirectDrawGlobals(void);
  303. #endif // __GLOBALS_HPP