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.

262 lines
8.8 KiB

  1. /*++
  2. Copyright (c) 1996 - 1999 Microsoft Corporation
  3. Module Name:
  4. raster.c
  5. Abstract:
  6. Definitions, structures and constants for unidrv rendering
  7. Environment:
  8. Windows NT Unidrv driver
  9. Revision History:
  10. 12/15/96 -alvins-
  11. Created
  12. --*/
  13. #ifndef _RMRENDER_H_
  14. #define _RMRENDER_H_
  15. /*
  16. * Miscellaneous constants involved in rendering.
  17. */
  18. #define BBITS 8 /* Bits per BYTE */
  19. #define WBITS (sizeof( WORD ) * BBITS)
  20. #define WBYTES (sizeof( WORD ))
  21. #define DWBITS (sizeof( DWORD ) * BBITS)
  22. #define DWBYTES (sizeof( DWORD ))
  23. #define COLOUR_MAX 4 /* Maximum number of colours to send to printer */
  24. #define MAX_COMPRESS_MODES 5
  25. /*
  26. * Data compression function prototypes.
  27. */
  28. typedef int (* COMPFN)( BYTE *, BYTE *, int );
  29. /*
  30. * The following structures contain the important information used
  31. * when rendering the bitmap image to the printer. Data is largely
  32. * calculated once for all future references (for this pdev).
  33. */
  34. /* Data specific to transpose operations */
  35. typedef struct
  36. {
  37. void *pvBuf; /* Where the output is placed */
  38. int iSkip; /* Bytes to skip to separte output bytes */
  39. int iHigh; /* Number of input scan lines to transpose */
  40. int iWide; /* Number of pixels in input scan lines */
  41. int cDWL; /* DWORDS per scan line - input */
  42. int cBYL; /* BYTES per scan line - input */
  43. int cBL; /* BITS per scan line */
  44. int iIntlace; /* Interlace factor */
  45. int icbL; /* Bytes to change pointer per line */
  46. DWORD *pdwTransTab; /* Transpose table OR colour separation */
  47. } TRANSPOSE;
  48. typedef struct _LEFTRIGHT
  49. {
  50. WORD left;
  51. WORD right;
  52. } LEFTRIGHT, *PLEFTRIGHT;
  53. /* Overall rendering data */
  54. typedef struct _RENDER
  55. {
  56. int iPassHigh; /* Scan lines processed per print pass */
  57. int iyBase; /* Processing bitmap in multiple passes */
  58. int iyPrtLine; /* Scan line # as printer sees it */
  59. int iyLookAhead; /* How far ahead we have looked - DeskJet */
  60. int iBitsPCol; /* Bits per column per head pass */
  61. WORD iFlags; /* Flag bits - see below for meaning */
  62. WORD fDump; /* Local copy of fDump from Resolution */
  63. int iCursor; /* Resolution.fCursor copy */
  64. int ixOrg; /* Reference point for graphics commands */
  65. int iPosnAdv; /* Scan lines moved after head pass printed */
  66. int iNumScans; /* Number of scan lines to be printed in one block */
  67. int iMaxNumScans; /* How high we can grow our block */
  68. int iHeight; /* Height in pixels of block to be processed*/
  69. int ix; /* Input bitmap x size, pels */
  70. int iy; /* Input bitmap y size, pels */
  71. int iBPP; /* Pel format (#bits per pel) */
  72. int iMaxBytesSend; /* Number of bytes to process in bottom level */
  73. int iSendCmd; /* Command OCD to send with data block */
  74. DWORD dwDevWhiteIndex; // white index for testing leading,trailing
  75. // white space
  76. DWORD *pdwBitMask; /* Bitmask table, built as needed */
  77. DWORD *pdwColrSep; /* Colour separation table */
  78. DWORD *pdwTrailingScans; /* Buffer for dangling scanlines */
  79. BYTE *pStripBlanks;
  80. BYTE *pbColSplit; /* For splitting colour bytes */
  81. BYTE *pbMirrorBuf; /* buffer for mirroring data */
  82. DWORD dwNumCompCmds; // number of different compression modes to run
  83. DWORD dwCompSize; // size of compression buffer
  84. DWORD dwLastCompCmd; // last compression command sent to device
  85. DWORD pdwCompCmds[MAX_COMPRESS_MODES];// table of active compression commands
  86. PBYTE pCompBufs[MAX_COMPRESS_MODES]; // pointers to compression buffers
  87. PBYTE pDeltaRowBuffer; // previous scan line buffer for delta row compression
  88. int iColOff[ COLOUR_MAX ]; /* Address shifting in sepn buffer */
  89. void (*vTransFn)( BYTE *, struct _RENDER * );
  90. /* Transpose function for multi-pin printers */
  91. void (*vLtoPTransFn)( BYTE *, struct _RENDER * );
  92. /* Landscape to portrait transpose fn */
  93. TRANSPOSE Trans; /* The transpose data */
  94. int (*iXMoveFn)( PDEV *, int, int ); /* X positioning function */
  95. int (*iYMoveFn)( PDEV *, int, int ); /* Y positioning function */
  96. BOOL (*bPassProc)( PDEV *, BYTE *, struct _RENDER * ); /* Color/mono */
  97. BOOL (*bWhiteLine)( DWORD *, struct _RENDER *, int ); /* A white scan line? */
  98. BOOL (*bWhiteBand)( DWORD *, struct _RENDER *, int ); /* A white band? */
  99. BOOL bInverted; /* have the bits been inverted yet */
  100. PLEFTRIGHT plrWhite; /* list of left/right pairs for each row */
  101. PLEFTRIGHT plrCurrent; /* left/right pair for current row */
  102. DWORD clr; /* count of left/right scans */
  103. BYTE ubFillWhite; // This value is used to initialize buffers
  104. PRINTERTYPE PrinterType; // type of printer, SERIAL,PAGE,TTY
  105. } RENDER;
  106. /* Make access to transpose data easier */
  107. #define pvTransBuf Trans.pvBuf
  108. #define iTransSkip Trans.iSkip
  109. #define iTransHigh Trans.iHigh
  110. #define iTransWide Trans.iWide
  111. #define cDWLine Trans.cDWL
  112. #define cBYLine Trans.cBYL
  113. #define cBLine Trans.cBL
  114. #define iInterlace Trans.iIntlace
  115. #define cbTLine Trans.icbL
  116. /*
  117. * Bits in iFlags above:
  118. */
  119. #define RD_GRAPHICS 0x0001 /* Printer is in graphics mode */
  120. #define RD_RESET_DRC 0x0002 /* Need to reset DRC buffer */
  121. #define RD_UNIDIR 0x0004 /* Printer in unidirectional mode */
  122. #define RD_ALL_COLOUR 0x0008 /* Set if ALL colour bands must be sent */
  123. /********************************
  124. * Function prototypes
  125. ********************************/
  126. /*
  127. * Initialisation functions.
  128. */
  129. BOOL bSkipInit( PDEV * );
  130. BOOL bInitTrans( PDEV * );
  131. /*
  132. * Functions to initialise the RENDER structure, and clean it up when done.
  133. */
  134. BOOL bRenderInit( PDEV *, SIZEL, int );
  135. void vRenderFree( PDEV * );
  136. /*
  137. * Functions to call at the start and finish of each page.
  138. */
  139. BOOL bRenderStartPage( PDEV * );
  140. BOOL bRenderPageEnd( PDEV * );
  141. /*
  142. * The top level rendering function.
  143. */
  144. BOOL bRender( SURFOBJ *, PDEV *, RENDER *, SIZEL, DWORD * );
  145. /*
  146. * Bitmap edge finding function. There are versions for each flavour
  147. * of bitmap we support. There is also the one for we always send all
  148. * the scan lines.
  149. */
  150. BOOL bIsBandWhite( DWORD *, RENDER *, int );
  151. BOOL bIsLineWhite( DWORD *, RENDER *, int );
  152. BOOL bIsNegatedLineWhite( DWORD *, RENDER *, int );
  153. BOOL bIsRGBBandWhite( DWORD *, RENDER *, int );
  154. BOOL bIsRGBLineWhite( DWORD *, RENDER *, int );
  155. BOOL bIs8BPPBandWhite( DWORD *, RENDER *, int );
  156. BOOL bIs8BPPLineWhite( DWORD *, RENDER *, int );
  157. BOOL bIs24BPPBandWhite( DWORD *, RENDER *, int );
  158. BOOL bIs24BPPLineWhite( DWORD *, RENDER *, int );
  159. BOOL bIsNeverWhite( DWORD *, RENDER *, int );
  160. int iStripBlanks( BYTE *, BYTE *, int, int, int,int);
  161. /*
  162. * Functions associated with finding rules in the bitmap. This
  163. * is really helpful for LaserJet style printers.
  164. */
  165. void vRuleInit( PDEV *, RENDER * );
  166. void vRuleFree( PDEV * );
  167. BOOL bRuleProc( PDEV *, RENDER *, DWORD * );
  168. void vRuleEndPage( PDEV * );
  169. /*
  170. * Functions related to transposing the bitmap from one format to
  171. * another. These are for protrait/landscape conversion, or for
  172. * turning the output data into the order required for dot matrix
  173. * style printers, where the data is in column order.
  174. */
  175. /* Special case: 8 x 8 transpose for dot matrix printers */
  176. void vTrans8x8( BYTE *, RENDER * );
  177. /* The more general case */
  178. void vTrans8N( BYTE *, RENDER * );
  179. /* Transpose for 4 bits per pel colour bitmap */
  180. void vTrans8N4BPP( BYTE *, RENDER * );
  181. /* Transpose for 8 bits per pel colour bitmap */
  182. void vTrans8BPP( BYTE *, RENDER * );
  183. /* Transpose for 24 bits per pel colour bitmap */
  184. void vTrans24BPP( BYTE *, RENDER * );
  185. /* Colour separation for single pin colour printers (e.g. PaintJet) */
  186. void vTransColSep( BYTE *, RENDER * );
  187. void vInvertBits(DWORD *, int);
  188. /* Output 24 bit data */
  189. BOOL b24BitOnePassOut( PDEV *, BYTE *, RENDER *);
  190. void SelectColor( PDEV *, int );
  191. int iLineOut( PDEV *,RENDER *, BYTE *, int, int );
  192. #endif // !_RMRENDER_H_