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.

816 lines
35 KiB

  1. /******************************Module*Header*******************************\
  2. * Module Name: driver.h
  3. *
  4. * Contains prototypes for the display driver.
  5. *
  6. * Copyright (c) 1992-1996 Microsoft Corporation
  7. * Copyright (c) 1993-1996 Matrox Electronic Systems, Ltd.
  8. \**************************************************************************/
  9. //////////////////////////////////////////////////////////////////////
  10. // Put all the conditional-compile constants here. There had better
  11. // not be many!
  12. // Multi-board support can be enabled by setting this to 1:
  13. #define MULTI_BOARDS 0
  14. // This is the maximum number of boards we'll support in a single
  15. // virtual driver:
  16. #if MULTI_BOARDS
  17. #define MAX_BOARDS 7
  18. #define IBOARD(ppdev) ((ppdev)->iBoard)
  19. #else
  20. #define MAX_BOARDS 1
  21. #define IBOARD(ppdev) 0
  22. #endif
  23. //////////////////////////////////////////////////////////////////////
  24. // Miscellaneous shared stuff
  25. #define DLL_NAME L"MGA" // Name of the DLL in UNICODE
  26. #define STANDARD_DEBUG_PREFIX "Mga: " // All debug output is prefixed
  27. // by this string
  28. #define ALLOC_TAG 'agmD' // Dmga
  29. // Four byte tag (characters in
  30. // reverse order) used for memory
  31. // allocations
  32. #define CLIP_LIMIT 50 // We'll be taking 800 bytes of stack space
  33. #define DRIVER_EXTRA_SIZE 0 // 16 // Size of the DriverExtra information
  34. // in the DEVMODE structure
  35. #define TMP_BUFFER_SIZE 8192 // Size in bytes of 'pvTmpBuffer'. Has to
  36. // be at least enough to store an entire
  37. // scan line (i.e., 6400 for 1600x1200x32).
  38. typedef struct _CLIPENUM {
  39. LONG c;
  40. RECTL arcl[CLIP_LIMIT]; // Space for enumerating complex clipping
  41. } CLIPENUM; /* ce, pce */
  42. typedef struct _PDEV PDEV; // Handy forward declaration
  43. VOID vSetClipping(PDEV*, RECTL*);
  44. VOID vResetClipping(PDEV*);
  45. VOID vPutBits(PDEV*, SURFOBJ*, RECTL*, POINTL*);
  46. VOID vGetBits(PDEV*, SURFOBJ*, RECTL*, POINTL*);
  47. VOID vMgaGetBits8bpp(PDEV*, SURFOBJ*, RECTL*, POINTL*);
  48. VOID vMgaGetBits16bpp(PDEV*, SURFOBJ*, RECTL*, POINTL*);
  49. VOID vMgaGetBits24bpp(PDEV*, SURFOBJ*, RECTL*, POINTL*);
  50. ////////////////////////////////////////////////////////////////////////
  51. // Status flags
  52. typedef enum {
  53. STAT_GLYPH_CACHE = 0x0001, // Glyph cache successfully allocated
  54. STAT_BRUSH_CACHE = 0x0002, // Brush cache successfully allocated
  55. STAT_DIRECTDRAW = 0x0004, // DirectDraw is enabled
  56. } STATUSFLAGS;
  57. //////////////////////////////////////////////////////////////////////
  58. // Text stuff
  59. #define GLYPH_CACHE_HEIGHT 47 // Number of scans to allocate for glyph cache,
  60. // divided by pel size
  61. #define GLYPH_CACHE_CX 64 // Maximal width of glyphs that we'll consider
  62. // caching
  63. #define GLYPH_CACHE_CY 64 // Maximum height of glyphs that we'll consider
  64. // caching
  65. #define MAX_GLYPH_SIZE ((GLYPH_CACHE_CX * GLYPH_CACHE_CY + 31) / 8)
  66. // Maximum amount of off-screen memory required
  67. // to cache a glyph, in bytes
  68. #define GLYPH_ALLOC_SIZE 8100
  69. // Do all cached glyph memory allocations
  70. // in 8k chunks
  71. #define HGLYPH_SENTINEL ((ULONG) -1)
  72. // GDI will never give us a glyph with a
  73. // handle value of 0xffffffff, so we can
  74. // use this as a sentinel for the end of
  75. // our linked lists
  76. #define GLYPH_HASH_SIZE 256
  77. #define GLYPH_HASH_FUNC(x) ((x) & (GLYPH_HASH_SIZE - 1))
  78. typedef struct _CACHEDGLYPH CACHEDGLYPH;
  79. typedef struct _CACHEDGLYPH
  80. {
  81. CACHEDGLYPH* pcgNext; // Points to next glyph that was assigned
  82. // to the same hash table bucket
  83. HGLYPH hg; // Handles in the bucket-list are kept in
  84. // increasing order
  85. POINTL ptlOrigin; // Origin of glyph bits
  86. // Device specific fields below here:
  87. LONG cy; // Glyph height
  88. LONG cxLessOne; // Glyph width, less one
  89. ULONG ulLinearStart;
  90. // Linear start address of glyph in off-screen
  91. // memory
  92. ULONG ulLinearEnd;// Linear end address
  93. } CACHEDGLYPH; /* cg, pcg */
  94. typedef struct _GLYPHALLOC GLYPHALLOC;
  95. typedef struct _GLYPHALLOC
  96. {
  97. GLYPHALLOC* pgaNext; // Points to next glyph structure that
  98. // was allocated for this font
  99. CACHEDGLYPH acg[1]; // This array is a bit misleading, because
  100. // the CACHEDGLYPH structures are actually
  101. // variable sized
  102. } GLYPHAALLOC; /* ga, pga */
  103. typedef struct _CACHEDFONT CACHEDFONT;
  104. typedef struct _CACHEDFONT
  105. {
  106. CACHEDFONT* pcfNext; // Points to next entry in CACHEDFONT list
  107. CACHEDFONT* pcfPrev; // Points to previous entry in CACHEDFONT list
  108. GLYPHALLOC* pgaChain; // Points to start of allocated memory list
  109. CACHEDGLYPH* pcgNew; // Points to where in the current glyph
  110. // allocation structure a new glyph should
  111. // be placed
  112. LONG cjAlloc; // Bytes remaining in current glyph allocation
  113. // structure
  114. CACHEDGLYPH cgSentinel; // Sentinel entry of the end of our bucket
  115. // lists, with a handle of HGLYPH_SENTINEL
  116. CACHEDGLYPH* apcg[GLYPH_HASH_SIZE];
  117. // Hash table for glyphs
  118. } CACHEDFONT; /* cf, pcf */
  119. BOOL bEnableText(PDEV*);
  120. VOID vDisableText(PDEV*);
  121. VOID vAssertModeText(PDEV*, BOOL);
  122. //////////////////////////////////////////////////////////////////////
  123. // Brush stuff
  124. #define BRUSH_CACHE_HEIGHT 2 // Number of scans to allocate for brush cache
  125. #define RBRUSH_2COLOR 1 // Monochrome brush
  126. #define TOTAL_BRUSH_SIZE 64 // We'll only ever handle 8x8 patterns,
  127. // and this is the number of pels
  128. typedef union _RBRUSH_COLOR RBRUSH_COLOR;
  129. typedef VOID (FNFILL)(PDEV*, LONG, RECTL*, ULONG, RBRUSH_COLOR, POINTL*);
  130. typedef struct _BRUSHENTRY BRUSHENTRY;
  131. typedef struct _RBRUSH {
  132. FLONG fl; // RBRUSH_ type flags
  133. ULONG ulColor[2]; // 0 -- background colour if 2-colour brush
  134. // 1 -- foreground colour if 2-colour brush
  135. FNFILL* pfnFillPat; // Fill routine to be called for this brush
  136. BRUSHENTRY* apbe[MAX_BOARDS];// Points to brush-entry that keeps track
  137. // of the cached off-screen brush bits
  138. ULONG aulPattern[1]; // Open-ended array for keeping copy of the
  139. // Don't put anything // actual pattern bits in case the brush
  140. // after here, or // origin changes, or someone else steals
  141. // you'll be sorry! // our brush entry (declared as a ULONG
  142. // for proper dword alignment)
  143. } RBRUSH; /* rb, prb */
  144. typedef struct _BRUSHENTRY {
  145. RBRUSH* prbVerify; // We never dereference this pointer to
  146. // find a brush realization; it is only
  147. // ever used in a compare to verify
  148. // that for a given realized brush, our
  149. // off-screen brush entry is still valid.
  150. ULONG ulLeft; // 'FXLEFT' coordinate for writing pattern
  151. // assuming a stride of 32
  152. ULONG ulYDst; // 'YDST' coordinate for writing pattern,
  153. // assuming a stride of 32
  154. ULONG ulLinear; // Linear start address of brush
  155. VOID* pvScan0; // Address of pattern (brush)
  156. } BRUSHENTRY; /* be, pbe */
  157. typedef union _RBRUSH_COLOR {
  158. RBRUSH* prb;
  159. ULONG iSolidColor;
  160. } RBRUSH_COLOR; /* rbc, prbc */
  161. VOID vMgaPatRealize8bpp(PDEV*, RBRUSH*);
  162. BOOL bEnableBrushCache(PDEV*);
  163. VOID vDisableBrushCache(PDEV*);
  164. VOID vAssertModeBrushCache(PDEV*, BOOL);
  165. //////////////////////////////////////////////////////////////////////
  166. // Stretch stuff
  167. typedef struct _STR_BLT {
  168. PDEV* ppdev;
  169. PBYTE pjSrcScan;
  170. LONG lDeltaSrc;
  171. LONG XSrcStart;
  172. PBYTE pjDstScan;
  173. LONG lDeltaDst;
  174. LONG XDstStart;
  175. LONG XDstEnd;
  176. LONG YDstStart;
  177. LONG YDstCount;
  178. ULONG ulXDstToSrcIntCeil;
  179. ULONG ulXDstToSrcFracCeil;
  180. ULONG ulYDstToSrcIntCeil;
  181. ULONG ulYDstToSrcFracCeil;
  182. ULONG ulXFracAccumulator;
  183. ULONG ulYFracAccumulator;
  184. } STR_BLT;
  185. typedef VOID (*PFN_DIRSTRETCH)(STR_BLT*);
  186. VOID vMgaDirectStretch8Narrow(STR_BLT*);
  187. VOID vMgaDirectStretch8(STR_BLT*);
  188. VOID vMgaDirectStretch16(STR_BLT*);
  189. VOID vMilDirectStretch8Narrow(STR_BLT*);
  190. VOID vMilDirectStretch8(STR_BLT*);
  191. VOID vMilDirectStretch16(STR_BLT*);
  192. //////////////////////////////////////////////////////////////////////
  193. // Dither stuff
  194. // Describes a single colour tetrahedron vertex for dithering:
  195. typedef struct _VERTEX_DATA {
  196. ULONG ulCount; // Number of pixels in this vertex
  197. ULONG ulVertex; // Vertex number
  198. } VERTEX_DATA; /* vd, pv */
  199. VERTEX_DATA* vComputeSubspaces(ULONG, VERTEX_DATA*);
  200. VOID vDitherColor(ULONG*, VERTEX_DATA*, VERTEX_DATA*, ULONG);
  201. VOID vRealize4ColorDither(RBRUSH*, ULONG);
  202. /////////////////////////////////////////////////////////////////////////
  203. // Heap stuff
  204. typedef enum {
  205. OH_FREE = 0, // The off-screen allocation is available for use
  206. OH_DISCARDABLE, // The allocation is occupied by a discardable bitmap
  207. // that may be moved out of off-screen memory
  208. OH_PERMANENT, // The allocation is occupied by a permanent bitmap
  209. // that cannot be moved out of off-screen memory
  210. } OHSTATE;
  211. typedef struct _DSURF DSURF;
  212. typedef struct _OH OH;
  213. typedef struct _OH
  214. {
  215. OHSTATE ohState; // State of off-screen allocation
  216. LONG x; // x-coordinate of left edge of allocation
  217. LONG y; // y-coordinate of top edge of allocation
  218. LONG cx; // Width in pixels of allocation
  219. LONG cy; // Height in pixels of allocation
  220. LONG cxReserved; // Dimensions of original reserved rectangle;
  221. LONG cyReserved; // zero if rectangle is not 'reserved'
  222. OH* pohNext; // When OH_FREE or OH_RESERVE, points to the next
  223. // free node, in ascending cxcy value. This is
  224. // kept as a circular doubly-linked list with a
  225. // sentinel at the end.
  226. // When OH_DISCARDABLE, points to the next most
  227. // recently created allocation. This is kept as
  228. // a circular doubly-linked list.
  229. OH* pohPrev; // Opposite of 'pohNext'
  230. ULONG cxcy; // Width and height in a dword for searching
  231. OH* pohLeft; // Adjacent allocation when in-use or available
  232. OH* pohUp;
  233. OH* pohRight;
  234. OH* pohDown;
  235. DSURF* pdsurf; // Points to our DSURF structure
  236. VOID* pvScan0; // Points to start of first scan-line
  237. }; /* oh, poh */
  238. // This is the smallest structure used for memory allocations:
  239. typedef struct _OHALLOC OHALLOC;
  240. typedef struct _OHALLOC
  241. {
  242. OHALLOC* pohaNext;
  243. OH aoh[1];
  244. } OHALLOC; /* oha, poha */
  245. typedef struct _HEAP
  246. {
  247. LONG cxMax; // Largest possible free space by area
  248. LONG cyMax;
  249. LONG cxBounds; // Largest possible bounding rectangle
  250. LONG cyBounds;
  251. OH ohFree; // Head of the free list, containing those
  252. // rectangles in off-screen memory that are
  253. // available for use. pohNext points to
  254. // hte smallest available rectangle, and pohPrev
  255. // points to the largest available rectangle,
  256. // sorted by cxcy.
  257. OH ohDiscardable; // Head of the discardable list that contains all
  258. // bitmaps located in offscreen memory that
  259. // are eligible to be tossed out of the heap.
  260. // It is kept in order of creation: pohNext
  261. // points to the most recently created; pohPrev
  262. // points to the least recently created.
  263. OH ohPermanent; // List of permanently allocated rectangles
  264. OH* pohFreeList; // List of OH node data structures available
  265. OHALLOC* pohaChain; // Chain of allocations
  266. } HEAP; /* heap, pheap */
  267. typedef enum {
  268. DT_SCREEN, // Surface is kept in screen memory
  269. DT_DIB // Surface is kept as a DIB
  270. } DSURFTYPE; /* dt, pdt */
  271. typedef struct _DSURF
  272. {
  273. DSURFTYPE dt; // DSURF status (whether off-screen or in a DIB)
  274. BOOL bDirectDraw; // TRUE if this is a DSURF wrapped around a
  275. // DirectDraw surface
  276. SIZEL sizl; // Size of the original bitmap (could be smaller
  277. // than poh->sizl)
  278. PDEV* ppdev; // Need this for deleting the bitmap
  279. union {
  280. OH* poh; // If DT_SCREEN, points to off-screen heap node
  281. SURFOBJ* pso; // If DT_DIB, points to locked GDI surface
  282. };
  283. // The following are used for DT_DIB only...
  284. ULONG cBlt; // Counts down the number of blts necessary at
  285. // the current uniqueness before we'll consider
  286. // putting the DIB back into off-screen memory
  287. ULONG iUniq; // Tells us whether there have been any heap
  288. // 'free's since the last time we looked at
  289. // this DIB
  290. } DSURF; /* dsurf, pdsurf */
  291. // GDI expects dword alignment for any bitmaps on which it is expected
  292. // to draw. Since we occasionally ask GDI to draw directly on our off-
  293. // screen bitmaps, this means that any off-screen bitmaps must be dword
  294. // aligned in the frame buffer. We enforce this merely by ensuring that
  295. // all off-screen bitmaps are four-pel aligned (we may waste a couple of
  296. // pixels at the higher colour depths):
  297. #define HEAP_X_ALIGNMENT 4
  298. // Number of blts necessary before we'll consider putting a DIB DFB back
  299. // into off-screen memory:
  300. #define HEAP_COUNT_DOWN 6
  301. // Max number of WRAM boundaries that can't be crossed by the FASTBLT
  302. // hardware on the STORM (Millennium).
  303. #define MAX_WRAM_BARRIERS 3
  304. // Flags for 'pohAllocate':
  305. typedef enum {
  306. FLOH_ONLY_IF_ROOM = 0x0001, // Don't kick stuff out of off-
  307. // screen memory to make room
  308. FLOH_MAKE_PERMANENT = 0x0002, // Allocate a permanent entry
  309. FLOH_RESERVE = 0x0004, // Allocate an off-screen entry,
  310. // but let it be used by discardable
  311. // bitmaps until it's needed
  312. } FLOH;
  313. // Publicly callable heap APIs:
  314. OH* pohAllocate(PDEV*, POINTL*, LONG, LONG, FLOH);
  315. BOOL bOhCommit(PDEV*, OH*, BOOL);
  316. OH* pohFree(PDEV*, OH*);
  317. OH* pohMoveOffscreenDfbToDib(PDEV*, OH*);
  318. BOOL bMoveDibToOffscreenDfbIfRoom(PDEV*, DSURF*);
  319. BOOL bMoveAllDfbsFromOffscreenToDibs(PDEV* ppdev);
  320. BOOL bEnableOffscreenHeap(PDEV*);
  321. VOID vDisableOffscreenHeap(PDEV*);
  322. BOOL bAssertModeOffscreenHeap(PDEV*, BOOL);
  323. /////////////////////////////////////////////////////////////////////////
  324. // Pointer stuff
  325. BOOL bEnablePointer(PDEV*);
  326. VOID vDisablePointer(PDEV*);
  327. VOID vAssertModePointer(PDEV*, BOOL);
  328. /////////////////////////////////////////////////////////////////////////
  329. // Palette stuff
  330. BOOL bEnablePalette(PDEV*);
  331. VOID vDisablePalette();
  332. VOID vAssertModePalette(PDEV*, BOOL);
  333. BOOL bInitializePalette(PDEV*, DEVINFO*);
  334. VOID vUninitializePalette(PDEV*);
  335. #define MAX_CLUT_SIZE (sizeof(VIDEO_CLUT) + (sizeof(ULONG) * 256))
  336. /////////////////////////////////////////////////////////////////////////
  337. // DirectDraw stuff
  338. #define ROUND_UP_TO_64K(x) (((ULONG)(x) + 0x10000 - 1) & ~(0x10000 - 1))
  339. typedef struct _FLIPRECORD
  340. {
  341. LONGLONG liFlipDuration; // Exact duration of a vertical refresh
  342. // cycle
  343. LONGLONG liFlipTime; // Exact time at which the flip command
  344. // was given
  345. FLATPTR fpFlipFrom; // Identifies the surface which was
  346. // 'flipped from'. We have to prevent
  347. // all drawing to this surface until we
  348. // know that a vertical retrace has
  349. // happened since the command was given,
  350. // so it's now non-visible and thus safe
  351. // to draw on.
  352. DWORD dwScanLine; // Scan line that was current the last time
  353. // we sampled whether the flip was
  354. // complete
  355. BOOL bFlipFlag; // Indicates whether a flip is pending
  356. } FLIPRECORD;
  357. BOOL bEnableDirectDraw(PDEV*);
  358. VOID vDisableDirectDraw(PDEV*);
  359. VOID vAssertModeDirectDraw(PDEV*, BOOL);
  360. /////////////////////////////////////////////////////////////////////////
  361. // DirectDraw stuff
  362. BOOL bEnableMCD(PDEV*);
  363. VOID vDisableMCD(PDEV*);
  364. VOID vAssertModeMCD(PDEV*, BOOL);
  365. //////////////////////////////////////////////////////////////////////
  366. // Low-level blt function prototypes
  367. typedef BOOL (FNBITBLT)(SURFOBJ*, SURFOBJ*, SURFOBJ*, CLIPOBJ*, XLATEOBJ*,
  368. RECTL*, POINTL*, POINTL*, BRUSHOBJ*, POINTL*, ROP4);
  369. typedef VOID (FNXFER)(PDEV*, LONG, RECTL*, ULONG, SURFOBJ*, POINTL*,
  370. RECTL*, XLATEOBJ*);
  371. typedef VOID (FNCOPY)(PDEV*, LONG, RECTL*, ULONG, POINTL*, RECTL*);
  372. typedef BOOL (FNFASTFILL)(PDEV*, LONG, POINTFIX*, ULONG, ULONG, RBRUSH*,
  373. POINTL*, RECTL*);
  374. typedef VOID (FNPATREALIZE)(PDEV*, RBRUSH*);
  375. FNFILL vFillPat1bpp;
  376. FNXFER vXfer4bpp;
  377. FNXFER vXfer8bpp;
  378. FNXFER vXferNative;
  379. FNFASTFILL bFastFill;
  380. FNBITBLT bMilPuntBlt;
  381. FNPATREALIZE vMilPatRealize;
  382. FNPATREALIZE vMilPatRealize24bpp;
  383. FNFILL vMilFillPat;
  384. FNFILL vMilFillPat24bpp;
  385. FNFILL vMilFillSolid;
  386. FNXFER vMilXfer1bpp;
  387. FNCOPY vMilCopyBlt;
  388. FNBITBLT bMgaPuntBlt;
  389. FNFILL vMgaFillPat8bpp;
  390. FNFILL vMgaFillPat16bpp;
  391. FNFILL vMgaFillPat24bpp;
  392. FNFILL vMgaFillSolid;
  393. FNXFER vMgaXfer1bpp;
  394. FNCOPY vMgaCopyBlt;
  395. ////////////////////////////////////////////////////////////////////////
  396. // Capabilities flags
  397. //
  398. // These are private flags passed to us from the miniport. They
  399. // come from the high word of the 'AttributeFlags' field of the
  400. // 'VIDEO_MODE_INFORMATION' structure (found in 'ntddvdeo.h') passed
  401. // to us via an 'VIDEO_QUERY_AVAIL_MODES' or 'VIDEO_QUERY_CURRENT_MODE'
  402. // IOCTL.
  403. //
  404. // NOTE: These definitions must match those in the miniport's header!
  405. typedef enum {
  406. } CAPS;
  407. ////////////////////////////////////////////////////////////////////////
  408. // The Physical Device data structure
  409. typedef struct _PDEV
  410. {
  411. LONG xOffset; // DFB offset for current surface
  412. LONG yOffset; // DFB offset for current surface
  413. LONG cxMemory; // Width of video RAM
  414. LONG cyMemory; // Height of video RAM
  415. BYTE* pjBase; // Points to coprocessor base address
  416. BYTE* pjScreen; // Points to base screen address
  417. LONG lDelta; // Distance from one scan to the next.
  418. ULONG ulYDstOrg; // Offset in pixels to be factored in
  419. // whenever computing an MGA linear
  420. // address
  421. // -------------------------------------------------------------------
  422. // NOTE: Changes up to here in the PDEV structure must be reflected in
  423. // i386\strucs.inc (assuming you're on an x86, of course)!
  424. LONG cjMemAvail; // Amount of video memory in bytes.
  425. LONG iBoard; // Logical multi-board identifier
  426. // (zero by default)
  427. ULONG iBitmapFormat; // BMF_8BPP, BMF_16BPP, BMF_24BPP or
  428. // BMF_32BPP (our current colour
  429. // depth)
  430. VOID* pvTmpBuffer; // General purpose temporary buffer,
  431. // TMP_BUFFER_SIZE bytes in size
  432. // (Remember to synchronize if you
  433. // use this for device bitmaps or
  434. // async pointers)
  435. BOOL bEnabled; // In graphics mode (not full-screen)
  436. CAPS flCaps; // Capabilities flags
  437. ULONG flFeatures;
  438. STATUSFLAGS flStatus; // Status flags
  439. ULONG cjDmaOffset; // Current offset for next write into
  440. // DMA window, used to avoid memory
  441. // barriers on the Alpha
  442. ULONG ulPlnWt; // Default write mask for mode
  443. ULONG ulAccess; // Default MACCESS register state
  444. ULONG ulBoardId; // MGA product ID
  445. ULONG HopeFlags; // For register accelerations
  446. HANDLE hDriver; // Handle to \Device\Screen
  447. HDEV hdevEng; // Engine's handle to PDEV
  448. HSURF hsurfScreen; // Engine's handle to screen surface
  449. DSURF* pdsurfScreen; // Our private DSURF for the screen
  450. LONG cxScreen; // Visible screen width
  451. LONG cyScreen; // Visible screen height
  452. ULONG ulMode; // Mode the mini-port driver is in.
  453. FLONG flHooks; // What we're hooking from GDI
  454. ULONG ulWhite; // 0xff if 8bpp, 0xffff if 16bpp,
  455. // 0xffffffff if 32bpp
  456. LONG cjPelSize; // Number of bytes per pel, according
  457. // to GDI
  458. LONG cjHwPel; // Number of bytes per pel, as stored
  459. // in the frame buffer
  460. ULONG ulRefresh; // For debug output
  461. ////////// Low-level blt function pointers:
  462. FNFILL* pfnFillSolid; // Call this function for solid fills
  463. FNFILL* pfnFillPatNative;
  464. FNXFER* pfnXfer1bpp;
  465. FNCOPY* pfnCopyBlt;
  466. FNBITBLT* pfnPuntBlt;
  467. ////////// Palette stuff:
  468. PALETTEENTRY* pPal; // The palette if palette managed
  469. HPALETTE hpalDefault; // GDI handle to the default palette.
  470. FLONG flRed; // Red mask for 16/32bpp bitfields
  471. FLONG flGreen; // Green mask for 16/32bpp bitfields
  472. FLONG flBlue; // Blue mask for 16/32bpp bitfields
  473. ULONG cPaletteShift; // number of bits the 8-8-8 palette must
  474. // be shifted by to fit in the hardware
  475. // palette.
  476. ////////// Heap stuff:
  477. HEAP heap; // All our off-screen heap data
  478. ULONG iHeapUniq; // Incremented every time room is freed
  479. // in the off-screen heap
  480. SURFOBJ* psoPunt; // Wrapper surface for having GDI draw
  481. // on off-screen bitmaps
  482. SURFOBJ* psoPunt2; // Another one for off-screen to off-
  483. // screen blts
  484. OH* pohScreen; // Off-screen heap structure for the
  485. // visible screen
  486. POINTL ptlOrg; // Where the screen 0,0 is anchored
  487. // in the virtual display.
  488. ////////// Pointer stuff:
  489. ULONG RamDacFlags; // Ramdac pointer type
  490. SIZEL szlPointerOverscan; // Pointer overscan x and y
  491. BOOL bHwPointerActive; // Currently using the h/w pointer?
  492. POINTL ptlHotSpot; // For remembering pointer hot spot
  493. LONG cyPointerHeight; // Current pointer-height
  494. ////////// Brush stuff:
  495. LONG iBrushCache; // Index for next brush to be allocated
  496. LONG cBrushCache; // Total number of brushes cached
  497. BRUSHENTRY* pbe; // Keeps track of brush cache
  498. BRUSHENTRY beUnrealizedBrush; // Place holder for unrealized brushes
  499. LONG lPatSrcAdd; // Bug fix for the Storm
  500. ULONG ulBrushSize; // Size of a brush realization in bytes
  501. ////////// Line stuff:
  502. ULONG ulLineControl; // Control register for current line
  503. // command
  504. ////////// Text stuff:
  505. ULONG ulTextControl; // MGA DwgCtl setting for bltting
  506. // text
  507. ULONG ulGlyphCurrent; // Linear address of next glyph to be
  508. // cached in off-screen memory
  509. ULONG ulGlyphStart; // Linear address of start of glyph
  510. // cache
  511. ULONG ulGlyphEnd; // Linear address of end of glyph
  512. // cache
  513. CACHEDFONT cfSentinel; // Sentinel for the doubly-linked list
  514. // we use to keep track of all
  515. // cached font allocations
  516. /////////// DirectDraw stuff:
  517. FLIPRECORD flipRecord; // Used to track VBlank status
  518. /////////// WRAM fast copy stuff:
  519. LONG ayBreak[MAX_WRAM_BARRIERS]; // Array of the precalculated
  520. // WRAM breaks in y.
  521. LONG cyBreak; // Number of WRAM breaks in y.
  522. ////////// OpenGL MCD stuff:
  523. ULONG iUniqueness; // display uniqueness for tracking
  524. // resolution changes
  525. LONG cDoubleBufferRef; // Reference count for current number
  526. // of RC's that have active double-
  527. // buffers
  528. OH* pohBackBuffer; // Our 2-d heap allocation structure
  529. // for the back-buffer
  530. ULONG ulBackBuffer; // Byte offset in the frame buffer
  531. // to the start of the back-buffer
  532. LONG cZBufferRef; // Reference count for current number
  533. // of RC's that have active z-buffers
  534. // (which, on Athenta, is all RC's)
  535. OH* pohZBuffer; // Our 2-d heap allocation structure
  536. // for the z-buffer
  537. ULONG ulFrontZBuffer; // Byte offset in the frame buffer
  538. // to the start of the front z-buffer
  539. // (the MGA sometimes has to have
  540. // separate z-buffers for front and
  541. // back)
  542. ULONG ulBackZBuffer; // Byte offset in the frame buffer
  543. // to the start of the back z-buffer
  544. HANDLE hMCD; // Handle to MCD engine dll
  545. MCDENGESCFILTERFUNC pMCDFilterFunc; // MCD engine filter function
  546. // Added to support GetAvailDriverMemory callback in DDraw
  547. ULONG ulTotalAvailVideoMemory;
  548. } PDEV, *PPDEV;
  549. /////////////////////////////////////////////////////////////////////////
  550. // Miscellaneous prototypes:
  551. VOID vStretchDIB(PDEV*, RECTL*, VOID*, LONG, RECTL*, RECTL*);
  552. BOOL bIntersect(RECTL*, RECTL*, RECTL*);
  553. LONG cIntersect(RECTL*, RECTL*, LONG);
  554. DWORD getAvailableModes(HANDLE, PVIDEO_MODE_INFORMATION*, DWORD*);
  555. BOOL bInitializeModeFields(PDEV*, GDIINFO*, DEVINFO*, DEVMODEW*);
  556. BOOL bSelectMode(HANDLE, DEVMODEW*, VIDEO_MODE_INFORMATION*, ULONG*);
  557. BOOL bEnableHardware(PDEV*);
  558. VOID vDisableHardware(PDEV*);
  559. BOOL bAssertModeHardware(PDEV*, BOOL);
  560. extern BYTE gaRop3FromMix[];
  561. extern BYTE gajFlip[];
  562. /////////////////////////////////////////////////////////////////////////
  563. // The x86 C compiler insists on making a divide and modulus operation
  564. // into two DIVs, when it can in fact be done in one. So we use this
  565. // macro.
  566. //
  567. // Note: QUOTIENT_REMAINDER implicitly takes unsigned arguments.
  568. #if defined(i386)
  569. #define QUOTIENT_REMAINDER(ulNumerator, ulDenominator, ulQuotient, ulRemainder) \
  570. { \
  571. __asm mov eax, ulNumerator \
  572. __asm sub edx, edx \
  573. __asm div ulDenominator \
  574. __asm mov ulQuotient, eax \
  575. __asm mov ulRemainder, edx \
  576. }
  577. #else
  578. #define QUOTIENT_REMAINDER(ulNumerator, ulDenominator, ulQuotient, ulRemainder) \
  579. { \
  580. ulQuotient = (ULONG) ulNumerator / (ULONG) ulDenominator; \
  581. ulRemainder = (ULONG) ulNumerator % (ULONG) ulDenominator; \
  582. }
  583. #endif
  584. /////////////////////////////////////////////////////////////////////////
  585. // OVERLAP - Returns TRUE if the same-size lower-right exclusive
  586. // rectangles defined by 'pptl' and 'prcl' overlap:
  587. #define OVERLAP(prcl, pptl) \
  588. (((prcl)->right > (pptl)->x) && \
  589. ((prcl)->bottom > (pptl)->y) && \
  590. ((prcl)->left < ((pptl)->x + (prcl)->right - (prcl)->left)) && \
  591. ((prcl)->top < ((pptl)->y + (prcl)->bottom - (prcl)->top)))
  592. // Prototype to handle display (resolution) uniqueness for MCD:
  593. ULONG GetDisplayUniqueness(PDEV *);
  594. //////////////////////////////////////////////////////////////////////
  595. // These Mul prototypes are thunks for multi-board support:
  596. ULONG MulGetModes(HANDLE, ULONG, DEVMODEW*);
  597. DHPDEV MulEnablePDEV(DEVMODEW*, PWSTR, ULONG, HSURF*, ULONG, ULONG*,
  598. ULONG, DEVINFO*, HDEV, PWSTR, HANDLE);
  599. VOID MulCompletePDEV(DHPDEV, HDEV);
  600. HSURF MulEnableSurface(DHPDEV);
  601. BOOL MulStrokePath(SURFOBJ*, PATHOBJ*, CLIPOBJ*, XFORMOBJ*, BRUSHOBJ*,
  602. POINTL*, LINEATTRS*, MIX);
  603. BOOL MulFillPath(SURFOBJ*, PATHOBJ*, CLIPOBJ*, BRUSHOBJ*, POINTL*,
  604. MIX, FLONG);
  605. BOOL MulBitBlt(SURFOBJ*, SURFOBJ*, SURFOBJ*, CLIPOBJ*, XLATEOBJ*,
  606. RECTL*, POINTL*, POINTL*, BRUSHOBJ*, POINTL*, ROP4);
  607. VOID MulDisablePDEV(DHPDEV);
  608. VOID MulDisableSurface(DHPDEV);
  609. BOOL MulAssertMode(DHPDEV, BOOL);
  610. VOID MulMovePointer(SURFOBJ*, LONG, LONG, RECTL*);
  611. ULONG MulSetPointerShape(SURFOBJ*, SURFOBJ*, SURFOBJ*, XLATEOBJ*, LONG,
  612. LONG, LONG, LONG, RECTL*, FLONG);
  613. ULONG MulDitherColor(DHPDEV, ULONG, ULONG, ULONG*);
  614. BOOL MulSetPalette(DHPDEV, PALOBJ*, FLONG, ULONG, ULONG);
  615. BOOL MulCopyBits(SURFOBJ*, SURFOBJ*, CLIPOBJ*, XLATEOBJ*, RECTL*, POINTL*);
  616. BOOL MulTextOut(SURFOBJ*, STROBJ*, FONTOBJ*, CLIPOBJ*, RECTL*, RECTL*,
  617. BRUSHOBJ*, BRUSHOBJ*, POINTL*, MIX);
  618. VOID MulDestroyFont(FONTOBJ*);
  619. BOOL MulPaint(SURFOBJ*, CLIPOBJ*, BRUSHOBJ*, POINTL*, MIX);
  620. BOOL MulRealizeBrush(BRUSHOBJ*, SURFOBJ*, SURFOBJ*, SURFOBJ*, XLATEOBJ*,
  621. ULONG);
  622. HBITMAP MulCreateDeviceBitmap(DHPDEV, SIZEL, ULONG);
  623. VOID MulDeleteDeviceBitmap(DHSURF);
  624. ULONG MulEscape(SURFOBJ*, ULONG, ULONG, VOID*, ULONG, VOID*);
  625. // These Dbg prototypes are thunks for debugging:
  626. ULONG DbgGetModes(HANDLE, ULONG, DEVMODEW*);
  627. DHPDEV DbgEnablePDEV(DEVMODEW*, PWSTR, ULONG, HSURF*, ULONG, ULONG*,
  628. ULONG, DEVINFO*, HDEV, PWSTR, HANDLE);
  629. VOID DbgCompletePDEV(DHPDEV, HDEV);
  630. HSURF DbgEnableSurface(DHPDEV);
  631. BOOL DbgLineTo(SURFOBJ*, CLIPOBJ*, BRUSHOBJ*, LONG, LONG, LONG, LONG,
  632. RECTL*, MIX);
  633. BOOL DbgStrokePath(SURFOBJ*, PATHOBJ*, CLIPOBJ*, XFORMOBJ*, BRUSHOBJ*,
  634. POINTL*, LINEATTRS*, MIX);
  635. BOOL DbgFillPath(SURFOBJ*, PATHOBJ*, CLIPOBJ*, BRUSHOBJ*, POINTL*,
  636. MIX, FLONG);
  637. BOOL DbgBitBlt(SURFOBJ*, SURFOBJ*, SURFOBJ*, CLIPOBJ*, XLATEOBJ*,
  638. RECTL*, POINTL*, POINTL*, BRUSHOBJ*, POINTL*, ROP4);
  639. VOID DbgDisablePDEV(DHPDEV);
  640. VOID DbgDisableSurface(DHPDEV);
  641. BOOL DbgAssertMode(DHPDEV, BOOL);
  642. BOOL DbgOffset(SURFOBJ*,LONG,LONG,FLONG);
  643. VOID DbgMovePointer(SURFOBJ*, LONG, LONG, RECTL*);
  644. ULONG DbgSetPointerShape(SURFOBJ*, SURFOBJ*, SURFOBJ*, XLATEOBJ*, LONG,
  645. LONG, LONG, LONG, RECTL*, FLONG);
  646. ULONG DbgDitherColor(DHPDEV, ULONG, ULONG, ULONG*);
  647. BOOL DbgSetPalette(DHPDEV, PALOBJ*, FLONG, ULONG, ULONG);
  648. BOOL DbgCopyBits(SURFOBJ*, SURFOBJ*, CLIPOBJ*, XLATEOBJ*, RECTL*, POINTL*);
  649. BOOL DbgTextOut(SURFOBJ*, STROBJ*, FONTOBJ*, CLIPOBJ*, RECTL*, RECTL*,
  650. BRUSHOBJ*, BRUSHOBJ*, POINTL*, MIX);
  651. VOID DbgDestroyFont(FONTOBJ*);
  652. BOOL DbgPaint(SURFOBJ*, CLIPOBJ*, BRUSHOBJ*, POINTL*, MIX);
  653. BOOL DbgRealizeBrush(BRUSHOBJ*, SURFOBJ*, SURFOBJ*, SURFOBJ*, XLATEOBJ*,
  654. ULONG);
  655. HBITMAP DbgCreateDeviceBitmap(DHPDEV, SIZEL, ULONG);
  656. VOID DbgDeleteDeviceBitmap(DHSURF);
  657. BOOL DbgStretchBlt(SURFOBJ*, SURFOBJ*, SURFOBJ*, CLIPOBJ*, XLATEOBJ*,
  658. COLORADJUSTMENT*, POINTL*, RECTL*, RECTL*, POINTL*,
  659. ULONG);
  660. ULONG DbgEscape(SURFOBJ*, ULONG, ULONG, VOID*, ULONG, VOID*);
  661. BOOL DbgResetPDEV(DHPDEV, DHPDEV);
  662. BOOL DbgGetDirectDrawInfo(DHPDEV, DD_HALINFO*, DWORD*, VIDEOMEMORY*,
  663. DWORD*, DWORD*);
  664. BOOL DbgEnableDirectDraw(DHPDEV, DD_CALLBACKS*, DD_SURFACECALLBACKS*,
  665. DD_PALETTECALLBACKS*);
  666. VOID DbgDisableDirectDraw(DHPDEV);
  667. BOOL DbgIcmSetDeviceGammaRamp(DHPDEV, ULONG, LPVOID);