Source code of Windows XP (NT5)
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.

741 lines
32 KiB

  1. /******************************Module*Header*******************************\
  2. * Module Name: driver.h
  3. *
  4. * Contains prototypes for the display driver.
  5. *
  6. * Copyright (c) 1992-1995 Microsoft Corporation
  7. \**************************************************************************/
  8. //////////////////////////////////////////////////////////////////////
  9. // Put all the conditional-compile constants here. There had better
  10. // not be many!
  11. // Set this bit when GDI's HOOK_SYNCHRONIZEACCESS works so that we don't
  12. // have to worry about synchronizing device-bitmap access. Note that
  13. // this wasn't an option in the first release of NT:
  14. #define SYNCHRONIZEACCESS_WORKS 1
  15. // When running on an x86, we can make banked call-backs to GDI where
  16. // GDI can write directly on the frame buffer. The Alpha has a weird
  17. // bus scheme, and can't do that:
  18. #if !defined(_ALPHA_)
  19. #define GDI_BANKING 1
  20. #else
  21. #define GDI_BANKING 0
  22. #endif
  23. // Multi-board support can be enabled by setting this to 1:
  24. #define MULTI_BOARDS 0
  25. // This is the maximum number of boards we'll support in a single
  26. // virtual driver:
  27. #if MULTI_BOARDS
  28. #define MAX_BOARDS 16
  29. #define IBOARD(ppdev) ((ppdev)->iBoard)
  30. #else
  31. #define MAX_BOARDS 1
  32. #define IBOARD(ppdev) 0
  33. #endif
  34. // Useful for visualizing the 2-d heap:
  35. #define DEBUG_HEAP 0
  36. //////////////////////////////////////////////////////////////////////
  37. // Miscellaneous shared stuff
  38. #define DLL_NAME L"QV" // Name of the DLL in UNICODE
  39. #define STANDARD_DEBUG_PREFIX "Qv: " // All debug output is prefixed
  40. // by this string
  41. #define ALLOC_TAG ' vqD' // Dqv
  42. // Four byte tag (characters in
  43. // reverse order) used for memory
  44. // allocations
  45. #define CLIP_LIMIT 50 // We'll be taking 800 bytes of stack space
  46. #define DRIVER_EXTRA_SIZE 0 // Size of the DriverExtra information in the
  47. // DEVMODE structure
  48. #define TMP_BUFFER_SIZE 8192 // Size in bytes of 'pvTmpBuffer'. Has to
  49. // be at least enough to store an entire
  50. // scan line (i.e., 6400 for 1600x1200x32).
  51. #if defined(ALPHA)
  52. #define XFER_BUFFERS 16 // Defines the maximum number of write buffers
  53. // possible on any Alpha. Must be a power
  54. #else // of two.
  55. #define XFER_BUFFERS 1 // On non-alpha systems, we don't have to
  56. // worry about the chip caching our bus
  57. #endif // writes.
  58. #define XFER_MASK (XFER_BUFFERS - 1)
  59. typedef struct _CLIPENUM {
  60. LONG c;
  61. RECTL arcl[CLIP_LIMIT]; // Space for enumerating complex clipping
  62. } CLIPENUM; /* ce, pce */
  63. typedef struct _PDEV PDEV; // Handy forward declaration
  64. VOID vSetClipping(PDEV*, RECTL*);
  65. VOID vResetClipping(PDEV*);
  66. //////////////////////////////////////////////////////////////////////
  67. // Text stuff
  68. #define GLYPH_CACHE_HEIGHT 32 // Number of scans to allocate for glyph cache
  69. #define GLYPH_GRANULARITY 31 // Horizontal granularity for packing glyphs,
  70. // expressed in pixels as width minus one
  71. #define GLYPH_CACHE_CX 32 // Maximal width of glyphs that we'll consider
  72. // caching
  73. #define GLYPH_CACHE_CY 32 // Maximum height of glyphs that we'll consider
  74. // caching
  75. #define MAX_GLYPH_SIZE ((((GLYPH_CACHE_CX + GLYPH_GRANULARITY) & ~GLYPH_GRANULARITY) \
  76. * GLYPH_CACHE_CY + 7) / 8)
  77. // Maximum amount of off-screen memory required
  78. // to cache a glyph, in bytes
  79. #define GLYPH_ALLOC_SIZE 8100
  80. // Do all cached glyph memory allocations
  81. // in 8k chunks
  82. #define HGLYPH_SENTINEL ((ULONG) -1)
  83. // GDI will never give us a glyph with a
  84. // handle value of 0xffffffff, so we can
  85. // use this as a sentinel for the end of
  86. // our linked lists
  87. #define GLYPH_HASH_SIZE 256
  88. #define GLYPH_HASH_FUNC(x) ((x) & (GLYPH_HASH_SIZE - 1))
  89. typedef struct _CACHEDGLYPH CACHEDGLYPH;
  90. typedef struct _CACHEDGLYPH
  91. {
  92. CACHEDGLYPH* pcgNext; // Points to next glyph that was assigned
  93. // to the same hash table bucket
  94. HGLYPH hg; // Handles in the bucket-list are kept in
  95. // increasing order
  96. POINTL ptlOrigin; // Origin of glyph bits
  97. LONG yxHeightWidth;
  98. // Packed height and width of glyph
  99. ULONG ulSrcLin; // QVision style linear address for glyph in
  100. // off-screen memory
  101. } CACHEDGLYPH; /* cg, pcg */
  102. typedef struct _GLYPHALLOC GLYPHALLOC;
  103. typedef struct _GLYPHALLOC
  104. {
  105. GLYPHALLOC* pgaNext; // Points to next glyph structure that
  106. // was allocated for this font
  107. CACHEDGLYPH acg[1]; // This array is a bit misleading, because
  108. // the CACHEDGLYPH structures are actually
  109. // variable sized
  110. } GLYPHAALLOC; /* ga, pga */
  111. typedef struct _CACHEDFONT CACHEDFONT;
  112. typedef struct _CACHEDFONT
  113. {
  114. CACHEDFONT* pcfNext; // Points to next entry in CACHEDFONT list
  115. CACHEDFONT* pcfPrev; // Points to previous entry in CACHEDFONT list
  116. GLYPHALLOC* pgaChain; // Points to start of allocated memory list
  117. CACHEDGLYPH* pcgNew; // Points to where in the current glyph
  118. // allocation structure a new glyph should
  119. // be placed
  120. LONG cjAlloc; // Bytes remaining in current glyph allocation
  121. // structure
  122. CACHEDGLYPH cgSentinel; // Sentinel entry of the end of our bucket
  123. // lists, with a handle of HGLYPH_SENTINEL
  124. CACHEDGLYPH* apcg[GLYPH_HASH_SIZE];
  125. // Hash table for glyphs
  126. } CACHEDFONT; /* cf, pcf */
  127. BOOL bEnableText(PDEV*);
  128. VOID vDisableText(PDEV*);
  129. VOID vAssertModeText(PDEV*, BOOL);
  130. //////////////////////////////////////////////////////////////////////
  131. // Dither stuff
  132. // Describes a single colour tetrahedron vertex for dithering:
  133. typedef struct _VERTEX_DATA {
  134. ULONG ulCount; // Number of pixels in this vertex
  135. ULONG ulVertex; // Vertex number
  136. } VERTEX_DATA; /* vd, pv */
  137. VERTEX_DATA* vComputeSubspaces(ULONG, VERTEX_DATA*);
  138. VOID vDitherColor(ULONG*, VERTEX_DATA*, VERTEX_DATA*, ULONG);
  139. //////////////////////////////////////////////////////////////////////
  140. // Brush stuff
  141. #define RBRUSH_2COLOR 1 // For RBRUSH flags
  142. #define TOTAL_BRUSH_SIZE 64 // We'll only ever handle 8x8 patterns,
  143. // and this is the number of pels
  144. typedef struct _BRUSHENTRY BRUSHENTRY;
  145. // NOTE: Changes to the RBRUSH or BRUSHENTRY structures must be reflected
  146. // in strucs.inc!
  147. typedef struct _RBRUSH {
  148. FLONG fl; // Type flags
  149. ULONG ulForeColor; // Foreground colour if 1bpp
  150. ULONG ulBackColor; // Background colour if 1bpp
  151. LONG cy; // Unique height of pattern
  152. ULONG cyLog2; // Unique height expressed as power of 2
  153. LONG xBlockAlign; // 'x' alignment of block-write pattern
  154. ULONG aulBlockPattern[TOTAL_BRUSH_SIZE / 4];
  155. // Contains screen-aligned version of
  156. // 'aulPattern', used for block-write
  157. // patterns; -1 indicates it's not yet
  158. // aligned
  159. ULONG aulPattern[1]; // Open-ended array for keeping copy of the
  160. // Don't put anything // actual pattern bits in case the brush
  161. // after here, or // origin changes, or someone else steals
  162. // you'll be sorry! // our brush entry (declared as a ULONG
  163. // for proper dword alignment)
  164. } RBRUSH; /* rb, prb */
  165. typedef union _RBRUSH_COLOR {
  166. RBRUSH* prb;
  167. ULONG iSolidColor;
  168. } RBRUSH_COLOR; /* rbc, prbc */
  169. BOOL bEnableBrushCache(PDEV*);
  170. VOID vDisableBrushCache(PDEV*);
  171. VOID vAssertModeBrushCache(PDEV*, BOOL);
  172. /////////////////////////////////////////////////////////////////////////
  173. // Heap stuff
  174. typedef enum {
  175. OFL_INUSE = 1, // The device bitmap is no longer located in
  176. // off-screen memory; it's been converted to
  177. // a DIB
  178. OFL_AVAILABLE = 2, // Space is in-use
  179. OFL_PERMANENT = 4 // Space is available
  180. } OHFLAGS; // Space is permanently allocated; never free it
  181. typedef struct _DSURF DSURF;
  182. typedef struct _OH OH;
  183. typedef struct _OH
  184. {
  185. OHFLAGS ofl; // OH_ flags
  186. LONG x; // x-coordinate of left edge of allocation
  187. LONG y; // y-coordinate of top edge of allocation
  188. LONG cx; // Width in pixels of allocation
  189. LONG cy; // Height in pixels of allocation
  190. OH* pohNext; // When OFL_AVAILABLE, points to the next free node,
  191. // in ascending cxcy value. This is kept as a
  192. // circular doubly-linked list with a sentinel
  193. // at the end.
  194. // When OFL_INUSE, points to the next most recently
  195. // blitted allocation. This is kept as a circular
  196. // doubly-linked list so that the list can be
  197. // quickly be updated on every blt.
  198. OH* pohPrev; // Opposite of 'pohNext'
  199. ULONG cxcy; // Width and height in a dword for searching
  200. OH* pohLeft; // Adjacent allocation when in-use or available
  201. OH* pohUp;
  202. OH* pohRight;
  203. OH* pohDown;
  204. DSURF* pdsurf; // Points to our DSURF structure
  205. }; /* oh, poh */
  206. // This is the smallest structure used for memory allocations:
  207. typedef struct _OHALLOC OHALLOC;
  208. typedef struct _OHALLOC
  209. {
  210. OHALLOC* pohaNext;
  211. OH aoh[1];
  212. } OHALLOC; /* oha, poha */
  213. typedef struct _HEAP
  214. {
  215. LONG cxMax; // Largest possible free space by area
  216. LONG cyMax;
  217. OH ohAvailable; // Head of available list (pohNext points to
  218. // smallest available rectangle, pohPrev
  219. // points to largest available rectangle,
  220. // sorted by cxcy)
  221. OH ohDfb; // Head of the list of all DFBs currently in
  222. // offscreen memory that are eligible to be
  223. // tossed out of the heap (pohNext points to
  224. // the most recently blitted; pohPrev points
  225. // to least recently blitted)
  226. OH* pohFreeList; // List of OH node data structures available
  227. OHALLOC* pohaChain; // Chain of allocations
  228. } HEAP; /* heap, pheap */
  229. typedef enum {
  230. DT_SCREEN, // Surface is kept in screen memory
  231. DT_DIB // Surface is kept as a DIB
  232. } DSURFTYPE; /* dt, pdt */
  233. typedef struct _DSURF
  234. {
  235. DSURFTYPE dt; // DSURF status (whether off-screen or in a DIB)
  236. SIZEL sizl; // Size of the original bitmap (could be smaller
  237. // than poh->sizl)
  238. PDEV* ppdev; // Need this for deleting the bitmap
  239. union {
  240. OH* poh; // If DT_SCREEN, points to off-screen heap node
  241. SURFOBJ* pso; // If DT_DIB, points to locked GDI surface
  242. };
  243. // The following are used for DT_DIB only...
  244. ULONG cBlt; // Counts down the number of blts necessary at
  245. // the current uniqueness before we'll consider
  246. // putting the DIB back into off-screen memory
  247. ULONG iUniq; // Tells us whether there have been any heap
  248. // 'free's since the last time we looked at
  249. // this DIB
  250. } DSURF; /* dsurf, pdsurf */
  251. // GDI expects dword alignment for any bitmaps on which it is expected
  252. // to draw. Since we occasionally ask GDI to draw directly on our off-
  253. // screen bitmaps, this means that any off-screen bitmaps must be dword
  254. // aligned in the frame buffer. We enforce this merely by ensuring that
  255. // all off-screen bitmaps are four-pel aligned (we may waste a couple of
  256. // pixels at the higher colour depths):
  257. #define HEAP_X_ALIGNMENT 4
  258. // Number of blts necessary before we'll consider putting a DIB DFB back
  259. // into off-screen memory:
  260. #define HEAP_COUNT_DOWN 6
  261. // Flags for 'pohAllocate':
  262. typedef enum {
  263. FLOH_ONLY_IF_ROOM = 0x00000001, // Don't kick stuff out of off-
  264. // screen memory to make room
  265. } FLOH;
  266. BOOL bEnableOffscreenHeap(PDEV*);
  267. VOID vDisableOffscreenHeap(PDEV*);
  268. BOOL bAssertModeOffscreenHeap(PDEV*, BOOL);
  269. OH* pohMoveOffscreenDfbToDib(PDEV*, OH*);
  270. BOOL bMoveDibToOffscreenDfbIfRoom(PDEV*, DSURF*);
  271. OH* pohAllocatePermanent(PDEV*, LONG, LONG);
  272. BOOL bMoveAllDfbsFromOffscreenToDibs(PDEV* ppdev);
  273. /////////////////////////////////////////////////////////////////////////
  274. // Bank manager stuff
  275. #define BANK_DATA_SIZE 80 // Number of bytes to allocate for the
  276. // miniport down-loaded bank code working
  277. // space
  278. typedef struct _BANK
  279. {
  280. // Private data:
  281. RECTL rclDraw; // Rectangle describing the remaining undrawn
  282. // portion of the drawing operation
  283. RECTL rclSaveBounds; // Saved from original CLIPOBJ for restoration
  284. BYTE iSaveDComplexity; // Saved from original CLIPOBJ for restoration
  285. BYTE fjSaveOptions; // Saved from original CLIPOBJ for restoration
  286. LONG iBank; // Current bank
  287. PDEV* ppdev; // Saved copy
  288. // Public data:
  289. SURFOBJ* pso; // Surface wrapped around the bank. Has to be
  290. // passed as the surface in any banked call-
  291. // back.
  292. CLIPOBJ* pco; // Clip object that is the intersection of the
  293. // original clip object with the bounds of the
  294. // current bank. Has to be passed as the clip
  295. // object in any banked call-back.
  296. } BANK; /* bnk, pbnk */
  297. typedef enum {
  298. BANK_OFF = 0, // We've finished using the memory aperture
  299. BANK_ON, // We're about to use the memory aperture
  300. BANK_DISABLE, // We're about to enter full-screen; shut down banking
  301. BANK_ENABLE, // We've exited full-screen; re-enable banking
  302. } BANK_MODE; /* bankm, pbankm */
  303. typedef BOOL (FNBANKCOMPUTE)(PDEV*, RECTL*, RECTL*, LONG*, LONG*);
  304. VOID vBankStart(PDEV*, RECTL*, CLIPOBJ*, BANK*);
  305. BOOL bBankEnum(BANK*);
  306. FNBANKCOMPUTE bBankComputeNonPower2;
  307. FNBANKCOMPUTE bBankComputePower2;
  308. BOOL bEnableBanking(PDEV*);
  309. VOID vDisableBanking(PDEV*);
  310. VOID vAssertModeBanking(PDEV*, BOOL);
  311. /////////////////////////////////////////////////////////////////////////
  312. // Pointer stuff
  313. BOOL bEnablePointer(PDEV*);
  314. VOID vDisablePointer(PDEV*);
  315. VOID vAssertModePointer(PDEV*, BOOL);
  316. BOOL bInitializePointer(PDEV*);
  317. VOID vUninitializePointer(PDEV*);
  318. /////////////////////////////////////////////////////////////////////////
  319. // Palette stuff
  320. BOOL bEnablePalette(PDEV*);
  321. VOID vDisablePalette(PDEV*);
  322. VOID vAssertModePalette(PDEV*, BOOL);
  323. BOOL bInitializePalette(PDEV*, DEVINFO*);
  324. VOID vUninitializePalette(PDEV*);
  325. #define MAX_CLUT_SIZE (sizeof(VIDEO_CLUT) + (sizeof(ULONG) * 256))
  326. /////////////////////////////////////////////////////////////////////////
  327. // 3D DDI Rendering Extension stuff
  328. BOOL bEnableRx(PDEV*);
  329. VOID vDisableRx(PDEV*);
  330. VOID vAssertModeRx(PDEV*, BOOL);
  331. //////////////////////////////////////////////////////////////////////
  332. // Low-level blt function prototypes
  333. typedef VOID (FNFILL)(PDEV*, LONG, RECTL*, ULONG, RBRUSH_COLOR, POINTL*);
  334. typedef VOID (FNXFER)(PDEV*, LONG, RECTL*, ULONG, SURFOBJ*, POINTL*,
  335. RECTL*, XLATEOBJ*);
  336. typedef VOID (FNCOPY)(PDEV*, LONG, RECTL*, ULONG, POINTL*, RECTL*);
  337. typedef VOID (FNTEXTOUT)(PDEV*, STROBJ*, FONTOBJ*, CLIPOBJ*, RECTL*,
  338. BRUSHOBJ*, BRUSHOBJ*);
  339. FNFILL vIoFillPat;
  340. FNFILL vIoFillSolid;
  341. FNXFER vIoXfer1bpp;
  342. FNCOPY vIoCopyBlt;
  343. FNTEXTOUT vIoTextOut;
  344. FNFILL vMmFillPat;
  345. FNFILL vMmFillSolid;
  346. FNXFER vMmXfer1bpp;
  347. FNCOPY vMmCopyBlt;
  348. FNTEXTOUT vMmTextOut;
  349. VOID vPutBits(PDEV*, SURFOBJ*, RECTL*, POINTL*);
  350. VOID vGetBits(PDEV*, SURFOBJ*, RECTL*, POINTL*);
  351. BOOL bFastFill(PDEV*, LONG, POINTFIX*, ULONG, ULONG, RBRUSH*, POINTL*);
  352. ////////////////////////////////////////////////////////////////////////
  353. // Capabilities flags
  354. //
  355. // These are private flags passed to us from the S3 miniport. They
  356. // come from the high word of the 'AttributeFlags' field of the
  357. // 'VIDEO_MODE_INFORMATION' structure (found in 'ntddvdeo.h') passed
  358. // to us via an 'VIDEO_QUERY_AVAIL_MODES' or 'VIDEO_QUERY_CURRENT_MODE'
  359. // IOCTL.
  360. //
  361. // NOTE: These definitions must match those in the S3 miniport's 's3.h'!
  362. typedef enum {
  363. } CAPS;
  364. ////////////////////////////////////////////////////////////////////////
  365. // Status flags
  366. typedef enum {
  367. STAT_UNACCELERATED = 0x0001, // Unaccelerated 16bpp or 32bpp mode
  368. STAT_GLYPH_CACHE = 0x0002, // Off-screen glyph cache allocated
  369. } STATUS;
  370. ////////////////////////////////////////////////////////////////////////
  371. // The Physical Device data structure
  372. typedef struct _PDEV
  373. {
  374. LONG xOffset; // Pixel offset from (0, 0) to current
  375. LONG yOffset; // DFB located in off-screen memory
  376. BYTE* pjMmBase; // Start of memory mapped I/O
  377. BYTE* pjScreen; // Points to base screen address
  378. LONG lDelta; // Distance from one scan to the next.
  379. LONG cPelSize; // 0 if 8bpp, 1 if 16bpp, 2 if 32bpp
  380. ULONG iBitmapFormat; // BMF_8BPP or BMF_16BPP or BMF_32BPP
  381. // (our current colour depth)
  382. LONG iBoard; // Logical multi-board identifier
  383. // (zero by default)
  384. // Rendering extensions colour information.
  385. UCHAR rDepth; // Number of red bits
  386. UCHAR gDepth; // Number of green bits
  387. UCHAR bDepth; // Number of blue bits
  388. UCHAR aDepth; // Number of alpha bits
  389. UCHAR rBitShift; // Left bit-shift for red component
  390. UCHAR gBitShift; // Left bit-shift for green component
  391. UCHAR bBitShift; // Left bit-shift for blue component
  392. UCHAR aBitShift; // Left bit-shift for alpha component
  393. BYTE* pjIoBase; // !!!
  394. LONG cjPel; // !!!
  395. CAPS flCaps; // Capabilities flags
  396. STATUS flStat; // Status flags
  397. BOOL bEnabled; // In graphics mode (not full-screen)
  398. HANDLE hDriver; // Handle to \Device\Screen
  399. HDEV hdevEng; // Engine's handle to PDEV
  400. HSURF hsurfScreen; // Engine's handle to screen surface
  401. DSURF* pdsurfScreen; // Our private DSURF for the screen
  402. LONG cxScreen; // Visible screen width
  403. LONG cyScreen; // Visible screen height
  404. LONG cxMemory; // Width of Video RAM
  405. LONG cyMemory; // Height of Video RAM
  406. ULONG ulMode; // Mode the mini-port driver is in.
  407. FLONG flHooks; // What we're hooking from GDI
  408. ULONG ulWhite; // 0xff if 8bpp, 0xffff if 16bpp,
  409. // 0xffffffff if 32bpp
  410. VOID* pvTmpBuffer; // General purpose temporary buffer,
  411. // TMP_BUFFER_SIZE bytes in size
  412. // (Remember to synchronize if you
  413. // use this for device bitmaps or
  414. // async pointers)
  415. ////////// Low-level blt function pointers:
  416. FNFILL* pfnFillSolid;
  417. FNFILL* pfnFillPat;
  418. FNXFER* pfnXfer1bpp;
  419. FNCOPY* pfnCopyBlt;
  420. FNTEXTOUT* pfnTextOut;
  421. ////////// Palette stuff:
  422. PALETTEENTRY* pPal; // The palette if palette managed
  423. HPALETTE hpalDefault; // GDI handle to the default palette.
  424. FLONG flRed; // Red mask for 16/32bpp bitfields
  425. FLONG flGreen; // Green mask for 16/32bpp bitfields
  426. FLONG flBlue; // Blue mask for 16/32bpp bitfields
  427. ULONG cPaletteShift; // number of bits the 8-8-8 palette must
  428. // be shifted by to fit in the hardware
  429. // palette.
  430. ////////// Heap stuff:
  431. HEAP heap; // All our off-screen heap data
  432. ULONG iHeapUniq; // Incremented every time room is freed
  433. // in the off-screen heap
  434. ////////// Banking stuff:
  435. LONG cjBank; // Size of a bank, in bytes
  436. LONG cPower2ScansPerBank; // Used by 'bBankComputePower2'
  437. LONG cPower2BankSizeInBytes; // Used by 'bBankComputePower2'
  438. CLIPOBJ* pcoBank; // Clip object for banked call backs
  439. SURFOBJ* psoBank; // Surface object for banked call backs
  440. PFN pfnBankSwitchCode; // Pointer to bank switch code
  441. VIDEO_BANK_SELECT* pBankInfo; // Bank info for current mode returned
  442. // by miniport
  443. FNBANKCOMPUTE* pfnBankCompute;
  444. ////////// Pointer stuff:
  445. VIDEO_POINTER_CAPABILITIES PointerCapabilities;
  446. // Capabilities of the hardware
  447. // pointer, as reported back by
  448. // the miniport
  449. VIDEO_POINTER_ATTRIBUTES* pPointerAttributes;
  450. // Points to attributes buffer for
  451. // current pointer shape
  452. LONG cjPointerAttributes; // Length of allocated pointer
  453. // attributes buffer
  454. LONG cjXorMaskStartOffset; // Offset from start of AND buffer to
  455. // start of XOR buffer, in bytes
  456. POINTL ptlHotSpot; // Current pointer hot-spot
  457. BOOL bPointerEnabled; // True if pointer is current visible
  458. ////////// Brush stuff:
  459. LONG iBrushCache; // Index for next brush to be allocated
  460. LONG cBrushCache; // Total number of brushes cached
  461. POINTL ptlReRealize; // Work area for 864/964 pattern
  462. // hardware bug work-around
  463. ////////// Text stuff:
  464. LONG xGlyphCurrent; // x-position of next glyph to be
  465. // cached in off-screen memory
  466. LONG yGlyphCurrent; // y-position of next glyph
  467. LONG yGlyphStart; // y-coordinate of start of glyph cache
  468. LONG yGlyphEnd; // y-coordinate of one-past end of
  469. // cache
  470. CACHEDFONT cfSentinel; // Sentinel for the doubly-linked list
  471. // we use to keep track of all
  472. // cached font allocations
  473. ////////// 3D DDI Rendering Extension stuff:
  474. VOID* pvOut; // Points to current output buffer
  475. VOID* pvOutMax; // Points to end of current output buffer
  476. VOID* pvInMax; // Points to end of current input buffer
  477. OH* pohFrontBuffer; // Allocation structure for the screen
  478. OH* pohBackBuffer; // Allocation structure for optional
  479. // off-screen back buffer
  480. LONG cDoubleBufferRef; // Reference count for current number
  481. // of RC's that have active double-
  482. // buffers
  483. POINTL ptlDoubleBuffer[2]; // (x, y) positions of front and back
  484. // buffers in video memory
  485. // 0 -- RX_BACK_LEFT
  486. // 1 -- RX_FRONT_LEFT
  487. // Note: Make sure that the index
  488. // is in the range [0, 1]!
  489. } PDEV;
  490. /////////////////////////////////////////////////////////////////////////
  491. // Miscellaneous prototypes:
  492. BOOL bIntersect(RECTL*, RECTL*, RECTL*);
  493. LONG cIntersect(RECTL*, RECTL*, LONG);
  494. DWORD getAvailableModes(HANDLE, PVIDEO_MODE_INFORMATION*, DWORD*);
  495. BOOL bInitializeModeFields(PDEV*, GDIINFO*, DEVINFO*, DEVMODEW*);
  496. BOOL bEnableHardware(PDEV*);
  497. VOID vDisableHardware(PDEV*);
  498. BOOL bAssertModeHardware(PDEV*, BOOL);
  499. extern BYTE gaRop3FromMix[];
  500. extern BYTE gabMixNeedsPattern[];
  501. extern BYTE gabRopNeedsPattern[];
  502. /////////////////////////////////////////////////////////////////////////
  503. // The x86 C compiler insists on making a divide and modulus operation
  504. // into two DIVs, when it can in fact be done in one. So we use this
  505. // macro.
  506. //
  507. // Note: QUOTIENT_REMAINDER implicitly takes unsigned arguments.
  508. #if defined(i386)
  509. #define QUOTIENT_REMAINDER(ulNumerator, ulDenominator, ulQuotient, ulRemainder) \
  510. { \
  511. __asm mov eax, ulNumerator \
  512. __asm sub edx, edx \
  513. __asm div ulDenominator \
  514. __asm mov ulQuotient, eax \
  515. __asm mov ulRemainder, edx \
  516. }
  517. #else
  518. #define QUOTIENT_REMAINDER(ulNumerator, ulDenominator, ulQuotient, ulRemainder) \
  519. { \
  520. ulQuotient = (ULONG) ulNumerator / (ULONG) ulDenominator; \
  521. ulRemainder = (ULONG) ulNumerator % (ULONG) ulDenominator; \
  522. }
  523. #endif
  524. /////////////////////////////////////////////////////////////////////////
  525. // OVERLAP - Returns TRUE if the same-size lower-right exclusive
  526. // rectangles defined by 'pptl' and 'prcl' overlap:
  527. #define OVERLAP(prcl, pptl) \
  528. (((prcl)->right > (pptl)->x) && \
  529. ((prcl)->bottom > (pptl)->y) && \
  530. ((prcl)->left < ((pptl)->x + (prcl)->right - (prcl)->left)) && \
  531. ((prcl)->top < ((pptl)->y + (prcl)->bottom - (prcl)->top)))
  532. /////////////////////////////////////////////////////////////////////////
  533. // SWAP - Swaps the value of two variables, using a temporary variable
  534. #define SWAP(a, b, tmp) { (tmp) = (a); (a) = (b); (b) = (tmp); }
  535. //////////////////////////////////////////////////////////////////////
  536. // These Mul prototypes are thunks for multi-board support:
  537. ULONG MulGetModes(HANDLE, ULONG, DEVMODEW*);
  538. DHPDEV MulEnablePDEV(DEVMODEW*, PWSTR, ULONG, HSURF*, ULONG, ULONG*,
  539. ULONG, DEVINFO*, HDEV, PWSTR, HANDLE);
  540. VOID MulCompletePDEV(DHPDEV, HDEV);
  541. HSURF MulEnableSurface(DHPDEV);
  542. BOOL MulStrokePath(SURFOBJ*, PATHOBJ*, CLIPOBJ*, XFORMOBJ*, BRUSHOBJ*,
  543. POINTL*, LINEATTRS*, MIX);
  544. BOOL MulFillPath(SURFOBJ*, PATHOBJ*, CLIPOBJ*, BRUSHOBJ*, POINTL*,
  545. MIX, FLONG);
  546. BOOL MulBitBlt(SURFOBJ*, SURFOBJ*, SURFOBJ*, CLIPOBJ*, XLATEOBJ*,
  547. RECTL*, POINTL*, POINTL*, BRUSHOBJ*, POINTL*, ROP4);
  548. VOID MulDisablePDEV(DHPDEV);
  549. VOID MulDisableSurface(DHPDEV);
  550. BOOL MulAssertMode(DHPDEV, BOOL);
  551. VOID MulMovePointer(SURFOBJ*, LONG, LONG, RECTL*);
  552. ULONG MulSetPointerShape(SURFOBJ*, SURFOBJ*, SURFOBJ*, XLATEOBJ*, LONG,
  553. LONG, LONG, LONG, RECTL*, FLONG);
  554. ULONG MulDitherColor(DHPDEV, ULONG, ULONG, ULONG*);
  555. BOOL MulSetPalette(DHPDEV, PALOBJ*, FLONG, ULONG, ULONG);
  556. BOOL MulCopyBits(SURFOBJ*, SURFOBJ*, CLIPOBJ*, XLATEOBJ*, RECTL*, POINTL*);
  557. BOOL MulTextOut(SURFOBJ*, STROBJ*, FONTOBJ*, CLIPOBJ*, RECTL*, RECTL*,
  558. BRUSHOBJ*, BRUSHOBJ*, POINTL*, MIX);
  559. VOID MulDestroyFont(FONTOBJ*);
  560. BOOL MulPaint(SURFOBJ*, CLIPOBJ*, BRUSHOBJ*, POINTL*, MIX);
  561. BOOL MulRealizeBrush(BRUSHOBJ*, SURFOBJ*, SURFOBJ*, SURFOBJ*, XLATEOBJ*,
  562. ULONG);
  563. HBITMAP MulCreateDeviceBitmap(DHPDEV, SIZEL, ULONG);
  564. VOID MulDeleteDeviceBitmap(DHSURF);
  565. BOOL MulStretchBlt(SURFOBJ*, SURFOBJ*, SURFOBJ*, CLIPOBJ*, XLATEOBJ*,
  566. COLORADJUSTMENT*, POINTL*, RECTL*, RECTL*, POINTL*,
  567. ULONG);
  568. // These Dbg prototypes are thunks for debugging:
  569. ULONG DbgGetModes(HANDLE, ULONG, DEVMODEW*);
  570. DHPDEV DbgEnablePDEV(DEVMODEW*, PWSTR, ULONG, HSURF*, ULONG, ULONG*,
  571. ULONG, DEVINFO*, HDEV, PWSTR, HANDLE);
  572. VOID DbgCompletePDEV(DHPDEV, HDEV);
  573. HSURF DbgEnableSurface(DHPDEV);
  574. BOOL DbgStrokePath(SURFOBJ*, PATHOBJ*, CLIPOBJ*, XFORMOBJ*, BRUSHOBJ*,
  575. POINTL*, LINEATTRS*, MIX);
  576. BOOL DbgFillPath(SURFOBJ*, PATHOBJ*, CLIPOBJ*, BRUSHOBJ*, POINTL*,
  577. MIX, FLONG);
  578. BOOL DbgBitBlt(SURFOBJ*, SURFOBJ*, SURFOBJ*, CLIPOBJ*, XLATEOBJ*,
  579. RECTL*, POINTL*, POINTL*, BRUSHOBJ*, POINTL*, ROP4);
  580. VOID DbgDisablePDEV(DHPDEV);
  581. VOID DbgDisableSurface(DHPDEV);
  582. BOOL DbgAssertMode(DHPDEV, BOOL);
  583. VOID DbgMovePointer(SURFOBJ*, LONG, LONG, RECTL*);
  584. ULONG DbgSetPointerShape(SURFOBJ*, SURFOBJ*, SURFOBJ*, XLATEOBJ*, LONG,
  585. LONG, LONG, LONG, RECTL*, FLONG);
  586. ULONG DbgDitherColor(DHPDEV, ULONG, ULONG, ULONG*);
  587. BOOL DbgSetPalette(DHPDEV, PALOBJ*, FLONG, ULONG, ULONG);
  588. BOOL DbgCopyBits(SURFOBJ*, SURFOBJ*, CLIPOBJ*, XLATEOBJ*, RECTL*, POINTL*);
  589. BOOL DbgTextOut(SURFOBJ*, STROBJ*, FONTOBJ*, CLIPOBJ*, RECTL*, RECTL*,
  590. BRUSHOBJ*, BRUSHOBJ*, POINTL*, MIX);
  591. VOID DbgDestroyFont(FONTOBJ*);
  592. BOOL DbgPaint(SURFOBJ*, CLIPOBJ*, BRUSHOBJ*, POINTL*, MIX);
  593. BOOL DbgRealizeBrush(BRUSHOBJ*, SURFOBJ*, SURFOBJ*, SURFOBJ*, XLATEOBJ*,
  594. ULONG);
  595. HBITMAP DbgCreateDeviceBitmap(DHPDEV, SIZEL, ULONG);
  596. VOID DbgDeleteDeviceBitmap(DHSURF);
  597. BOOL DbgStretchBlt(SURFOBJ*, SURFOBJ*, SURFOBJ*, CLIPOBJ*, XLATEOBJ*,
  598. COLORADJUSTMENT*, POINTL*, RECTL*, RECTL*, POINTL*,
  599. ULONG);
  600. BOOL DbgEscape(SURFOBJ*, ULONG, ULONG, VOID*, ULONG, VOID*);