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.

356 lines
13 KiB

  1. /*++
  2. Copyright (c) 1990-2003 Microsoft Corporation
  3. Module Name:
  4. plotters.h
  5. Abstract:
  6. This module contains basic plotter infomation to be includes by most of
  7. the source file
  8. This module contains the bulk of the plotter driver defines. It is included
  9. by most modules.
  10. Development History:
  11. 18-Nov-1993 Thu 01:25:51 created
  12. Wrote for the Windows.
  13. 07-Dec-1993 Tue 01:14:40 updated
  14. another round of clean up, adding new PDEV stuff
  15. 21-Dec-1993 Tue 10:58:03 updated
  16. Change PLOTFORM's flags
  17. Replaced PAL_BGR_ENTRY with PALENTRY and moved all pen cached stuff to
  18. local output.c
  19. 06-Jan-1994 Thu 00:05:56 updated
  20. remove PLOTTER_UNIT_DPI and used pPlotGPC->PlotXDPI in GPC,
  21. change PDEV's wCurPenSelected to CurPenSelected (WORD to LONG) to have
  22. DWORD aligned for next field in the structure.
  23. 14-Jan-1994 Fri 20:24:12 updated
  24. Change DEVBRUSH
  25. 19-Jan-1994 Wed 14:28:45 updated
  26. Adding hack to handle EngStretchBlt() to our own temp surfobj
  27. 27-Jan-1994 Thu 23:38:48 updated
  28. Add DBCACHE structure, modify PDEV to handle cached fill type and
  29. cached User defined pattern
  30. 03-Mar-1994 Thu 09:40:36 updated
  31. Remove dead stufff which confused, adding minimum required DDI version
  32. for this plotter driver to run
  33. 18-Mar-1994 Fri 12:58:24 updated
  34. Adding ptlRTLCAP in PDEV to catch the RTL relative position problem
  35. Adding PLOTF_RTL_NO_DPI_XY, PLOTF_RTLMONO_NO_CID and
  36. PLOTF_RTLMONO_FIXPAL flags
  37. 12-Apr-1994 Tue 14:14:15 updated
  38. Changed DIVRNDUP from +0.5 round up to round to next smallest integer
  39. [Environment:]
  40. GDI Device Driver - Plotter.
  41. [Notes:]
  42. 13-Apr-1994 Wed 14:29:57 updated
  43. FXTOL(x) is assumed to be (X >> 4) (Defined by WINDDI.H)
  44. LTOFX(x) is (X << 4)
  45. IF WINDDI.H changes that definition then we must change LTOFX and
  46. FXTOL2(x)
  47. Revision History:
  48. --*/
  49. #ifndef _PLOTTER_MAIN_HEADER_
  50. #define _PLOTTER_MAIN_HEADER_
  51. #define DRIVER_VERSION 0x0500
  52. #define COUNT_ARRAY(x) (sizeof((x)) / sizeof((x)[0]))
  53. #define ABS(Value) ((Value) > 0 ? (Value) : (-(Value)))
  54. #define DW_ALIGN(x) (((DWORD)(x) + 3) & ~(DWORD)3)
  55. //
  56. // In order to have the style units mean something we break them up
  57. // into units that are 1/25 of an inch.
  58. //
  59. #define PLOT_STYLE_STEP(p) ((p)->lCurResolution / 25)
  60. //
  61. // Define where WHITE is when the plotter driver is a Pallete device
  62. //
  63. #define WHITE_INDEX 0
  64. //
  65. // The PALENTRY is the correct RGB order for the plotter driver, if any changes
  66. // need to be made to the order then only this structure needs to be changed.
  67. //
  68. // CURRENTLY it is in Blue/Green/Red order, for accessing bits in the BGR format
  69. // instead of RGB
  70. //
  71. typedef struct PALENTRY {
  72. BYTE B;
  73. BYTE G;
  74. BYTE R;
  75. BYTE Flags;
  76. } PALENTRY, FAR *PPALENTRY;
  77. #define PFF_ROT_COORD_L90 0x0001
  78. #define PFF_FLIP_X_COORD 0x0002
  79. #define PFF_FLIP_Y_COORD 0x0004
  80. #define BMP_ROT_NONE 0
  81. #define BMP_ROT_RIGHT_90 1
  82. typedef struct _PLOTFORM {
  83. WORD Flags; // PFF_xxxx flags;
  84. BYTE BmpRotMode; // BMP_ROT_xxx
  85. BYTE NotUsed; // not used
  86. SIZEL PlotSize; // Hard Clip Limit SIZE Size for PS cmd
  87. POINTL PhyOrg; // Physical origin from PlotSize origin
  88. SIZEL LogSize; // Logical Paper Size in 1/1000mm unit
  89. POINTL LogOrg; // Logical left/top margin in 1/1000mm unit
  90. SIZEL LogExt; // Printable area in 1/1000mm unit
  91. POINTL BmpOffset; // Bitmap Offset location
  92. } PLOTFORM, FAR *PPLOTFORM;
  93. //
  94. // Define the PDEV that this driver uses.
  95. //
  96. #define PDEV_BEG_ID 'tolP'
  97. #define PDEV_END_ID 'VEDP'
  98. #define RF_MAX_IDX 8
  99. typedef struct _DBCACHE {
  100. WORD RFIndex; // RF command index 1-RF_MAX_IDX
  101. WORD DBUniq; // unique for cache
  102. } DBCACHE, FAR *PDBCACHE;
  103. typedef struct _INTDECIW {
  104. WORD Integer;
  105. WORD Decimal;
  106. } INTDECIW, *PINTDECIW;
  107. #define PW_HATCH_INT 0
  108. #define PW_HATCH_DECI 26
  109. typedef struct _PDEV {
  110. DWORD PDEVBegID; // Check if we got the right one
  111. DWORD SizePDEV; // pdev size to be checked against
  112. DWORD Flags; // PDEVF_xxx
  113. HDEV hpdev; // Engines handle to this structure
  114. HSURF hsurf; // Engine's handle to drawing surface
  115. HPALETTE hPalDefault; // default palette for pdev
  116. SURFOBJ *pso; // Current surface
  117. HANDLE hPrinter; // handle to the current pdev printer
  118. SURFOBJ *psoHTBlt; // temporary blt surfobj
  119. RECTL rclHTBlt; // location for curreent psoHTBlt
  120. PPLOTGPC pPlotGPC; // plotter characterization data
  121. LPBYTE pOutBuffer; // output buffer location
  122. DWORD cbBufferBytes; // current count of bytes in output buffer
  123. PLOTDEVMODE PlotDM; // plotter extended devmode structure
  124. FORMSIZE CurForm; // Current user requested form
  125. PAPERINFO CurPaper; // current loaded paper
  126. PPDATA PPData; // PrinterProperties data PPDATA
  127. PLOTFORM PlotForm; // computed current selected form
  128. LONG lCurResolution; // The current resolution.
  129. LONG VertRes; // Printable page height, pels
  130. LONG HorzRes; // Printable page width, pels
  131. POINTL ptlAnchorCorner; // current brush origin.
  132. POINTL ptlRTLCAP; // Current RTL CAP
  133. RECTL rclCurClip; // current clipping rectangle
  134. LPVOID pTransPosTable; // bitmap rotation xlate table
  135. LPVOID pvDrvHTData; // device's halftone info
  136. LPVOID pPenCache; // Pointer to the device pen cache
  137. LONG BrightestPen; // brightest pen for pen plotter
  138. LONG CurPenSelected; // Tracks the pen currently in plotter
  139. WORD LastDevROP; // Current MERGE (ROP2) sent to plotter
  140. WORD Rop3CopyBits; // Rop3 used in DrvCopyBits()
  141. WORD LastFillTypeIndex; // last filltype (FT) index sent
  142. WORD LastLineType; // Last line type used (LT)
  143. WORD MinLToDevL; // Min RasDPI->PlotDPI Transform unit
  144. WORD DevBrushUniq; // uniq number for DEVBRUSH cache
  145. INTDECIW PenWidth; // pen width variable cache
  146. DBCACHE DBCache[RF_MAX_IDX];// DevBrush cache
  147. DWORD PDEVEndID; // ending block ID checking
  148. } PDEV, *PPDEV;
  149. //
  150. // Following are the flags for pPDev->Flags
  151. //
  152. #define PDEVF_CANCEL_JOB 0x80000000
  153. #define PDEVF_IN_BANDHTBLT 0x00000001
  154. #define PDEVF_PP_CENTER 0x00000002
  155. #define PDEVF_HAS_CLIPRECT 0x00000004
  156. #define PLOT_CANCEL_JOB(pPDev) (pPDev->Flags & PDEVF_CANCEL_JOB)
  157. //
  158. // Following are the flags definitions for the GPC data
  159. //
  160. #define GET_PLOTFLAGS(pPDev) (DWORD)(pPDev->pPlotGPC->Flags)
  161. #define PF_RASTER(PlotFlags) (PlotFlags & PLOTF_RASTER)
  162. #define PF_COLOR(PlotFlags) (PlotFlags & PLOTF_COLOR)
  163. #define PF_BEZIER(PlotFlags) (PlotFlags & PLOTF_BEZIER)
  164. #define PF_TRANSPARENT(PlotFlags) (PlotFlags & PLOTF_TRANSPARENT)
  165. #define PF_WINDINGFILL(PlotFlags) (PlotFlags & PLOTF_WINDINGFILL)
  166. #define PF_ROLLFEED(PlotFlags) (PlotFlags & PLOTF_ROLLFEED)
  167. #define PF_PAPERTRAY(PlotFlags) (PlotFlags & PLOTF_PAPERTRAY)
  168. #define PF_BYTEALIGN(PlotFlags) (PlotFlags & PLOTF_RASTERBYTEALIGN)
  169. #define PF_PUSHPAL(PlotFlags) (PlotFlags & PLOTF_PUSHPOPPAL)
  170. #define PF_NO_BMP_FONT(PlotFlags) (PlotFlags & PLOTF_NO_BMP_FONT)
  171. #define PF_RTLMONOENCODE_5(PlotFlags) (PlotFlags & PLOTF_RTLMONOENCODE_5)
  172. #define PF_RTL_NO_DPI_XY(PlotFlags) (PlotFlags & PLOTF_RTL_NO_DPI_XY)
  173. #define PF_RTLMONO_NO_CID(PlotFlags) (PlotFlags & PLOTF_RTLMONO_NO_CID)
  174. #define PF_RTLMONO_FIXPAL(PlotFlags) (PlotFlags & PLOTF_RTLMONO_FIXPAL)
  175. #define IS_RASTER(pPDev) (pPDev->pPlotGPC->Flags&PLOTF_RASTER)
  176. #define IS_COLOR(pPDev) (pPDev->pPlotGPC->Flags&PLOTF_COLOR)
  177. #define IS_BEZIER(pPDev) (pPDev->pPlotGPC->Flags&PLOTF_BEZIER)
  178. #define IS_TRANSPARENT(pPDev) (pPDev->pPlotGPC->Flags&PLOTF_TRANSPARENT)
  179. #define IS_WINDINGFILL(pPDev) (pPDev->pPlotGPC->Flags&PLOTF_WINDINGFILL)
  180. #define IS_ROLLFEED(pPDev) (pPDev->pPlotGPC->Flags&PLOTF_ROLLFEED)
  181. #define HAS_PAPERTRAY(pPDev) (pPDev->pPlotGPC->Flags&PLOTF_PAPERTRAY)
  182. #define NEED_BYTEALIGN(pPDev) (pPDev->pPlotGPC->Flags&PLOTF_RASTERBYTEALIGN)
  183. #define NEED_PUSHPAL(pPDev) (pPDev->pPlotGPC->Flags&PLOTF_PUSHPOPPAL)
  184. #define NO_BMP_FONT(pPDev) (pPDev->pPlotGPC->Flags&PLOTF_NO_BMP_FONT)
  185. #define RTLMONOENCODE_5(pPDev) (pPDev->pPlotGPC->Flags&PLOTF_RTLMONOENCODE_5)
  186. #define RTL_NO_DPI_XY(pPDev) (pPDev->pPlotGPC->Flags&PLOTF_RTL_NO_DPI_XY)
  187. #define RTLMONO_NO_CID(pPDev) (pPDev->pPlotGPC->Flags&PLOTF_RTLMONO_NO_CID)
  188. #define RTLMONO_FIXPAL(pPDev) (pPDev->pPlotGPC->Flags&PLOTF_RTLMONO_FIXPAL)
  189. #define HTPATSIZE(pPDev) (((pPDev->pPlotGPC->HTPatternSize>>1)+1)<<1)
  190. #define HTBMPFORMAT(pPDev) (((PDRVHTINFO)(pPDev->pvDrvHTData))->HTBmpFormat)
  191. #define DB_INV_PATIDX 0xFFFF
  192. //
  193. // This structure defines our realization of a logical brush. Since GDI
  194. // asks us to construct this, GDI keeps giving it back to us
  195. //
  196. typedef struct _DEVBRUSH {
  197. SURFOBJ *psoMask; // the mask for the pattern
  198. WORD PatIndex; // Pattern Index (iHatch HS_xxxx)
  199. WORD Uniq; // Uniq number for DEVBRUSH
  200. LONG LineSpacing; // Brush line spacing
  201. DWORD ColorFG; // foreground color of the brush
  202. DWORD ColorBG; // background color of the brush
  203. SIZEL sizlBitmap; // sizeof the bitmap
  204. LONG ScanLineDelta; // Number of bytes to move per scanline
  205. WORD BmpFormat; // format of the bitmap
  206. WORD BmpFlags; // Flags in surfobj
  207. LPBYTE pbgr24; // 24bpp BGR bitmap for user pattern
  208. WORD cxbgr24; // cx Size of the BGR
  209. WORD cybgr24; // cy Size of the BGR
  210. BYTE BmpBits[32]; // pattern bitmap. (min 8x8 of 4bpp)
  211. } DEVBRUSH, *PDEVBRUSH;
  212. //
  213. // data_structure used in GenPolyGon()
  214. //
  215. typedef struct _POLYGONDATA {
  216. PPDEV pPDev;
  217. SURFOBJ *pso; // only required in GenPolygonPath()
  218. PATHOBJ *ppo;
  219. CLIPOBJ *pco;
  220. DEVBRUSH *pBrush;
  221. PPOINTL pptlBrushOrg;
  222. RECTL *prectl;
  223. short iType; // only required in GenPolygon()
  224. MIX mixMode;
  225. BRUSHOBJ *pBrushToUse;
  226. } POLYGONDATA, *PPOLYGONDATA;
  227. //
  228. // Conversion type of things
  229. //
  230. #define DIVROUND(x,y) ((y)?(((LONG)(x)+(LONG)((y)>>1))/(LONG)(y)):0)
  231. #define DIVRNDUP(x,y) ((y)?(((LONG)(x)+(LONG)((y)-1))/(LONG)(y)):0)
  232. #define __PLOT_DPI (LONG)pPDev->pPlotGPC->PlotXDPI
  233. #define _PLOT_DPI (LONG)pPlotGPC->PlotXDPI
  234. #define _CURR_DPI (LONG)pPDev->lCurResolution
  235. #define LTOFX(x) ((x)<<4)
  236. #define DMTOSPL(dm) ((LONG)(dm) * 100L)
  237. #define SPLTODM(spl) (SHORT)DIVROUND(spl, 100)
  238. #define MMTODM(mm) ((LONG)(mm) * 10L)
  239. #define DMTOENGUNITS(pPDev, dm) DIVROUND((dm)*_CURR_DPI, 254)
  240. #define DMTOPLOTUNITS(pPlotGPC, dm) DIVROUND((dm)*_PLOT_DPI, 254)
  241. #define MMTOENGUNITS(pPDev, mm) DMTOENGUNITS(pPDev, MMTODM(mm))
  242. #define MMTOPLOTUNITS(pPlotGPC, mm) DMTOPLOTUNITS(pPlotGPC, MMTODM(mm))
  243. #define SPLTOENGUNITS(pPDev, spl) DIVROUND((spl/100)*_CURR_DPI, 254)
  244. #define SPLTOPLOTUNITS(pPlotGPC, spl) DIVROUND((spl/100)*_PLOT_DPI, 254)
  245. //
  246. // Change to using Raster DPI as user unit
  247. //
  248. // #define ENGTODEV(pPDev, x) DIVROUND((x)*__PLOT_DPI, _CURR_DPI)
  249. //
  250. #define ENGTODEV(pPDev, x) (x)
  251. #define FXTODEVL(pPDev, x) ENGTODEV(pPDev, FXTOLROUND(x))
  252. #define LTODEVL(pPDev, x) ENGTODEV(pPDev, x)
  253. //
  254. // Minimum type of form supported
  255. //
  256. #define MIN_SPL_FORM_CX MIN_PLOTGPC_FORM_CX
  257. #define MIN_SPL_FORM_CY MIN_PLOTGPC_FORM_CY
  258. #define MIN_DM_FORM_CX SPLTODM(MIN_SPL_FORM_CX)
  259. #define MIN_DM_FORM_CY SPLTODM(MIN_SPL_FORM_CY)
  260. //
  261. // Finally include this one in order to validate the PDEV
  262. //
  263. #include "pdevinfo.h"
  264. #endif // _PLOTTER_MAIN_HEADER_