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.

554 lines
18 KiB

  1. /*++
  2. Copyright (c) 1999-2001 Microsoft Corporation
  3. All rights reserved.
  4. Module Name:
  5. glpdev.h
  6. Abstract:
  7. This module contains the definitions of various data structures
  8. used by the driver.
  9. The main structure is the OEMPDEV
  10. Author:
  11. [Environment:]
  12. Windows 2000/Whistler Unidrv driver
  13. [Notes:]
  14. Revision History:
  15. --*/
  16. #ifndef _GLPDEV_H
  17. #define _GLPDEV_H
  18. #include "brshcach.h"
  19. #include "oemdev.h"
  20. #include "prcomoem.h"
  21. //
  22. // OEM Signature and version.
  23. //
  24. #define OEM_SIGNATURE 'CDCB' // Command Callback & DDI test dll
  25. #define PCL_RGB_ENTRIES 770 // 3 * 256 = 768 -- a little wary in NT km. //dz
  26. #define NUM_PURE_COLORS 8 // C, M, Y, K, W, R, G, B.
  27. #define NUM_PURE_GRAYS 2 // Black and White.
  28. #define PALETTE_MAX 256 //max entries in raster palette
  29. #define PCL_BRUSH_RGB 0
  30. #define PCL_BRUSH_GRAY 1
  31. #define PCL_BRUSH_PATTERN 2
  32. #define PCL_BRUSH_NULLBRUSH 3
  33. #define PCL_MITERJOIN_LIMIT 10
  34. #define DPI_1200 1200
  35. #define DPI_600 600
  36. #define DPI_300 300
  37. #define DPI_150 150
  38. #define HPGL_INVALID_COLOR 0xffffffff
  39. #define UNDEFINED_PATTERN_NUMBER ((LONG)-1)
  40. //
  41. // The default PCL ROP code is 252. Setup a default ROP3 value and
  42. // a default ROP4 value using 252.
  43. //
  44. #define DEFAULT_ROP3 0xFC // 252: TSo
  45. #define DEFAULT_ROP (((DEFAULT_ROP3) << 8) | (DEFAULT_ROP3))
  46. #define ROP4_SRC_COPY 0xCCCC //SRC_COPY_ROP = 0xCCCC
  47. //
  48. // The unidriver now sets the ROP at the beginning of each page. I don't want
  49. // to guess at the value, but this is the current one. Don't use this for
  50. // anthing unless you have to.
  51. //
  52. #define UNIDRV_ROP3 0xB8 // 184: TSDTxax
  53. #define INVALID_ROP3 0xFFFFFFFF
  54. ////////////////////////////////////////////////////////
  55. // OEM UD Type Defines
  56. ////////////////////////////////////////////////////////
  57. //
  58. // Warning: the following enum order must match the order in OEMHookFuncs[].
  59. //
  60. enum {
  61. UD_DrvRealizeBrush,
  62. UD_DrvDitherColor,
  63. UD_DrvCopyBits,
  64. UD_DrvBitBlt,
  65. UD_DrvStretchBlt,
  66. UD_DrvStretchBltROP,
  67. UD_DrvPlgBlt,
  68. UD_DrvTransparentBlt,
  69. UD_DrvAlphaBlend,
  70. UD_DrvGradientFill,
  71. UD_DrvTextOut,
  72. UD_DrvStrokePath,
  73. UD_DrvFillPath,
  74. UD_DrvStrokeAndFillPath,
  75. UD_DrvPaint,
  76. UD_DrvLineTo,
  77. UD_DrvStartPage,
  78. UD_DrvSendPage,
  79. UD_DrvEscape,
  80. UD_DrvStartDoc,
  81. UD_DrvEndDoc,
  82. UD_DrvNextBand,
  83. UD_DrvStartBanding,
  84. #ifdef HOOK_DEVICE_FONTS
  85. UD_DrvQueryFont,
  86. UD_DrvQueryFontTree,
  87. UD_DrvQueryFontData,
  88. UD_DrvQueryAdvanceWidths,
  89. UD_DrvFontManagement,
  90. UD_DrvGetGlyphMode,
  91. #endif
  92. MAX_DDI_HOOKS,
  93. };
  94. #define BBITS 8 // Bits per BYTE
  95. #define WBITS (sizeof( WORD ) * BBITS)
  96. #define WBYTES (sizeof( WORD ))
  97. #define DWBITS (sizeof( DWORD ) * BBITS)
  98. #define DWBYTES (sizeof( DWORD ))
  99. #ifndef _ERENDERLANGUAGE
  100. #define _ERENDERLANGUAGE
  101. typedef enum { ePCL,
  102. eHPGL,
  103. eUNKNOWN
  104. } ERenderLanguage;
  105. #endif
  106. // Note: Constants match HPGL spec when possible.
  107. typedef enum { ePIX_PLACE_INTERSECT = 0,
  108. ePIX_PLACE_CENTER = 1 } EPixelPlacement;
  109. typedef enum { eLINE_END_BUTT = 1,
  110. eLINE_END_SQUARE = 2,
  111. eLINE_END_TRIANGULAR = 3,
  112. eLINE_END_ROUND = 4 } ELineEnd;
  113. typedef enum { eLINE_JOIN_MITERED = 1,
  114. eLINE_JOIN_MITERED_BEVELED = 2,
  115. eLINE_JOIN_TRIANGULAR = 3,
  116. eLINE_JOIN_ROUND = 4,
  117. eLINE_JOIN_BEVELED = 5,
  118. eLINE_JOIN_NONE = 6 } ELineJoin;
  119. typedef enum { eNULLOBJECT = 0xFF,
  120. eTEXTOBJECT = 0,
  121. eHPGLOBJECT = 1,
  122. eRASTEROBJECT = 2,
  123. eRASTERPATTERNOBJECT = 3,
  124. eTEXTASRASTEROBJECT = 4 //Text printed as Graphics
  125. } EObjectType;
  126. //
  127. // PCL defines
  128. // 0 as transparent and 1 as opaque. (Esc*v#0, Esc*v#N).
  129. // HPGL says TR0 is transparency off i.e. Opaque
  130. // while TR1 is Transparent.
  131. // So if eTransparent is passed in and we are in HP-GL mode
  132. // then TR1 should be passed instead of TR0
  133. //
  134. typedef enum { eTRANSPARENT = 0,
  135. eOPAQUE = 1 } ETransparency;
  136. typedef enum { kPen ,
  137. kBrush } ESTYLUSTYPE;
  138. //
  139. // Current Pattern Page 16-16 of PCL Implementors guide v6.0
  140. //
  141. typedef enum { kSolidBlackFg, // 0 This is also the default in PCL
  142. kSolidWhite, // 1
  143. kHPShade, // 2
  144. kHPHatch, // 3
  145. kUserDefined, // 4
  146. } ECURRENTPATTERNTYPE;
  147. //
  148. // We have 8 palettes to use: 0-7
  149. // Unidriver text uses palette 0
  150. // 16, 24, and 32 bit cid commands all use the 24 bit palette
  151. // HPGL uses palette 1
  152. //
  153. typedef enum { eUnknownPalette = -1,
  154. eHPGL_CID_PALETTE = 1,
  155. eRASTER_PATTERN_CID_PALETTE = 3,
  156. eTEXT_CID_PALETTE = 5,
  157. eRASTER_CID_24BIT_PALETTE = 6,
  158. eRASTER_CID_8BIT_PALETTE = 7,
  159. eRASTER_CID_4BIT_PALETTE = 8,
  160. eRASTER_CID_1BIT_PALETTE = 9 } ECIDPalette;
  161. typedef enum { eDEVICE_RGB = 0,
  162. eDEVICE_CMY = 1,
  163. eCOLORIMETRIC_RGB = 2,
  164. eCIE_LAB = 3,
  165. eLUM_CHROM = 4 } EColorSpace;
  166. typedef enum { eSolidLine, eCustomLine, eDefinedLine } ELineType;
  167. typedef struct _LINETYPE
  168. {
  169. ELineType eType;
  170. FLOATOBJ foPatternLength;
  171. INT iId;
  172. } LINETYPE, *PLINETYPE;
  173. /*dz POINTUI, COLORTABLETYPE and PCLPATTERNTYPE were moved here from
  174. realize.h putting them here allows the raster code to use these
  175. structures.
  176. */
  177. // Brush data types
  178. //dz there is probably a predefined POINT Structure to use
  179. typedef struct _POINTUI { //POINTUI
  180. UINT x;
  181. UINT y;
  182. } POINTUI, *PPOINTUI;
  183. typedef struct _COLORTABLETYPE { // COLORTABLETYPE
  184. ULONG iUniq; // Unique Palette ID as extracted from XLATEOBJ.
  185. BYTE Depth; // The depth of the palette. HP_e8bit only.
  186. BYTE byData[PCL_RGB_ENTRIES]; // This is pData necessary for HP_eIndexedPixel case.
  187. ULONG cEntries; // Number of entries in the palette.
  188. } COLORTABLE, *PCOLORTABLE;
  189. //
  190. // Raster palette
  191. // The requirement for the ulValidPalID entry can be explained by an
  192. // example.
  193. // 1,4,8bpp images are downloaded using palettes (BGetPalette in palette.cpp).
  194. // We create a different palette for each bpp image (look at ECIDPalette above).
  195. // A palette for 4bpp image has 16 colors while that for 8bpp has 256 colors.
  196. // Suppose a 4bpp image is followed by 8bpp image. When palette for 4bpp image
  197. // is being downloaded eRASTER_CID_4BIT_PALETTE is the active palette.
  198. // When palette for 8bpp image is downloaded eRASTER_CID_8BIT_PALETTE is the
  199. // active palette. Can the palette entries downloaded in 4bpp case be re-used
  200. // in 8bpp case.(i.e. after downloading 16 colors in first case, can we download
  201. // only 256-16 colors in second case).
  202. // Answer is NO, cos the palette ID's in both are cases are different.
  203. // Colors from one palette id cannot be carried over to colors to a different
  204. // palette ID. So we use the ulValidPalID to record which color has been downloaded
  205. // for which palette.
  206. // if ulValidPalID[0] = 1, it means that color is downloaded for eRASTER_CID_1BIT_PALETTE
  207. // if ulValidPalID[0] = 4, it means that color is downloaded for eRASTER_CID_4BIT_PALETTE
  208. // if ulValidPalID[0] = 8, it means that color is downloaded for eRASTER_CID_8BIT_PALETTE
  209. // if ulValidPalID[0] = 9, it means that color is downloaded for eRASTER_CID_8BIT_PALETTE
  210. // (0x9 = 0x0001 | 0x1000) and for eRASTER_CID_1BIT_PALETTE
  211. //
  212. // It should be evident that this method can be used only for 2^n bpp. and n <=5
  213. // because sizeof(ULONG) = 32 and 2^5=32.
  214. //
  215. typedef struct _HPGLPAL_DATA {
  216. ULONG pEntries; // Number of entries in the palette.
  217. INT iWhiteIndex; // Index for white entry (background)
  218. INT iBlackIndex; // Index for black entry (background)
  219. ULONG ulDirty [ PALETTE_MAX ]; // need to reselect the palette entry - the color has changed
  220. ULONG ulPalCol[ PALETTE_MAX ]; // Palette entries!
  221. ULONG ulValidPalID[PALETTE_MAX ]; // The palette entry is valid for which palette.
  222. } HPGLPAL_DATA;
  223. //
  224. // Defines a realized bitmap pattern brush object
  225. //
  226. typedef struct _PCLPATTERNTYPE {
  227. //LONG iPatIndex; // Index to special patterns: HS_DDI_MAX, HS_xxx...
  228. LONG lPatIndex; // Pattern Number of downloaded pattern. Used for cache'ing.
  229. ECURRENTPATTERNTYPE eCurPatType;
  230. BYTE compressionEnum; // The compression associated with this pattern.
  231. BYTE colorMappingEnum; // HP_eDirectPixel, or HP_eIndexedPixel. If DirectPixel, Palette is invalid.
  232. BYTE PersistenceEnum; // The persistence of this pattern.
  233. SIZEL size; // size of the bitmap
  234. POINTUI destSize; // Specifies target size for the bitmap.
  235. ULONG iBitmapFormat; // bitmap format from GDI - psoSrc->iBitmapFormat
  236. LONG lDelta; // byte offset from one line to the next
  237. COLORTABLE ColorTable; // The palette associated with this pattern.
  238. HPGLPAL_DATA palData; // Raster palette;
  239. ULONG cBytes; // Number of bytes of bitmap data.
  240. PBYTE pBits; // bitmap data
  241. } PCLPATTERN, *PPCLPATTERN;
  242. typedef LONG PENID; // Pen ids: These map to the numerical ids of pens used by HPGL
  243. typedef LONG PATID; // Pattern ids:
  244. typedef struct _SolidMarkerImp
  245. {
  246. LONG lPatternID; // To be used for monochrome printers.
  247. DWORD dwRGBColor; // To be used for monochrome&color printers.
  248. PENID iPenNumber; // To be used for color printers.
  249. } SolidMarkerImp;
  250. typedef enum { FT_eSOLID = 1,
  251. FT_eHPGL_PEN = 2,
  252. FT_ePERCENT_FILL = 10,
  253. FT_eHPGL_BRUSH = 11,
  254. FT_eHATCH_FILL = 21,
  255. FT_ePCL_PEN = 22,
  256. FT_ePCL_BRUSH = 22 } EFillType;
  257. typedef struct _PatternMakerImp
  258. {
  259. LONG lPatternID;
  260. EFillType eFillType;
  261. POINTL origin;
  262. } PatternMarkerImp;
  263. typedef struct _PercentFillImp
  264. {
  265. WORD wPercent;
  266. PENID iPenNumber; //Required for color printers.
  267. } PercentFillImp;
  268. typedef struct HatchFillImp
  269. {
  270. ULONG iHatch;
  271. SolidMarkerImp ColorInfo; //Hatch brush also have color associated with it.
  272. } HatchFillImp;
  273. typedef enum { MARK_eSOLID_COLOR,
  274. MARK_eNULL_PEN,
  275. MARK_eRASTER_FILL,
  276. MARK_eHATCH_FILL,
  277. MARK_ePERCENT_FILL } EMarkerType;
  278. // Use ULONG instead of enum for fill mode to avoid possible casting problems
  279. // in sprintf.
  280. const ULONG FILL_eODD_EVEN = 0;
  281. const ULONG FILL_eWINDING = 1;
  282. typedef ULONG EMarkerFill;
  283. // typedef enum { FILL_eODD_EVEN = 0, FILL_eWINDING = 1 } EMarkerFill;
  284. typedef struct _HPGLMARKER
  285. {
  286. EMarkerType eType;
  287. EMarkerFill eFillMode; // Fill mode for a brush. Meaningless for pens.
  288. // M = Monochrome, C = Color
  289. LONG lPatternID; // Pattern(MC), SolidColor(M), Hatch(MC), Percent(MC)
  290. DWORD dwRGBColor; // Solid(MC)
  291. PENID iPenNumber; // Solid (C)
  292. ULONG iHatch; // Hatch(MC)
  293. ULONG iPercent; // Hatch(MC)
  294. POINTL origin; // Pattern(MC)
  295. EFillType eFillType; // FT_?
  296. ERenderLanguage eDwnldType; //whether the pattern was downloaded as HPGL/PCL
  297. /***
  298. union
  299. {
  300. SolidMarkerImp Solid;
  301. PatternMarkerImp Pattern;
  302. PercentFillImp Percent;
  303. HatchFillImp Hatch;
  304. } u;
  305. **/
  306. } HPGLMARKER, *PHPGLMARKER;
  307. #define PENPOOLSIZE 5
  308. typedef struct _PENPOOL
  309. {
  310. PENID firstPenID;
  311. PENID lastPenID;
  312. struct
  313. {
  314. INT useCount;
  315. COLORREF color;
  316. } aPens[PENPOOLSIZE];
  317. } PENPOOL, *PPENPOOL;
  318. typedef struct _HPGLSTATE
  319. {
  320. // ROP: How will this be stored? Is this the same as transparency mode?
  321. EPixelPlacement ePixelPlacement;
  322. RECTL rClipRect;
  323. FLOATOBJ fLineWidth;
  324. INT iLineType;
  325. ELineEnd eLineEnd;
  326. ELineJoin eLineJoin;
  327. FLOATOBJ fMiterLimit;
  328. LINETYPE LineType;
  329. PENPOOL PenPool;
  330. PENPOOL BrushPool;
  331. CLIPOBJ *pComplexClipObj;
  332. PatternMarkerImp Pattern;
  333. INT iNumPens;
  334. } HPGLSTATE, *PHPGLSTATE;
  335. typedef struct _RASTERSTATE
  336. {
  337. PCLPATTERN PCLPattern;
  338. } RASTERSTATE, *PRASTERSTATE;
  339. //
  340. // Configure Image Commands and related data structures
  341. //
  342. typedef struct _CIDSHORT
  343. {
  344. BYTE ubColorSpace;
  345. BYTE ubPixelEncodingMode;
  346. BYTE ubBitsPerIndex;
  347. BYTE ubPrimary1;
  348. BYTE ubPrimary2;
  349. BYTE ubPrimary3;
  350. } CIDSHORT, *PCIDSHORT;
  351. typedef enum { eSHORTFORM = 0,
  352. eLONGFORM = 1 } ECIDFormat;
  353. // Use these flags in bInitHPGL to control the initialization of
  354. // various HPGL settings. Note that these won't always be used as
  355. // you expect. There are some sticky initialization issues and if
  356. // you change these TEST THE RESULTS! -and on multiple pages! JFF
  357. #define INIT_HPGL_STARTPAGE 0x01
  358. #define INIT_HPGL_STARTDOC 0x02
  359. //
  360. // Flags used to initialize the color commands
  361. //
  362. #define PF_INIT_TEXT_STARTPAGE 0x01
  363. #define PF_INIT_TEXT_STARTDOC 0x02
  364. #define PF_INIT_RASTER_STARTPAGE 0x04
  365. #define PF_INIT_RASTER_STARTDOC 0x08
  366. //
  367. // Flags for SelectTransparancy
  368. //
  369. // Just overwrite the transparency.
  370. #define PF_FORCE_SOURCE_TRANSPARENCY (0x01)
  371. #define PF_FORCE_PATTERN_TRANSPARENCY (0x01 << 1)
  372. //
  373. // Do not change the transparency.
  374. //
  375. #define PF_NOCHANGE_SOURCE_TRANSPARENCY (0x01 << 2)
  376. #define PF_NOCHANGE_PATTERN_TRANSPARENCY (0x01 << 3)
  377. //
  378. // Flags for job start and page start commands
  379. //
  380. #define PF_STARTDOC 0x01
  381. #define PF_STARTPAGE 0x02
  382. //
  383. // BUGBUG sandram - find out how GDI defines the DMBIN_USER
  384. // for front tray and rear tray
  385. //
  386. #define DMBIN_HPFRONTTRAY 0x0102
  387. #define DMBIN_HPREARTRAY 0x0101
  388. //
  389. // BUGBUG - sandram: Our data structures should DWORD aligned
  390. // to run correctly on Intel and Alpha.
  391. // We're very lucky it's working now.
  392. //
  393. //
  394. // Following are the flags for OEMPDEV->Flags
  395. // PDEVF_CANCEL_JOB : To indicate job cancel
  396. // PDEVF_IN_COMMONROPBLT : Is set when dwCommonROPBlt() is entered, and reset on exit. This
  397. // helps in catching recursion.
  398. // PDEVF_USE_HTSURF : The driver is declared a color driver (i.e. destination surface is 24bpp)
  399. // but in fact driver is monochrome. So we create a monochrome shadow bitmap
  400. // to render color images. So whenever that bitmap has to be
  401. // used, we set this flag.
  402. // PDEVF_INVERT_BITMAP : When bitmap needs to be inverted before rendering.
  403. // The function that sets it should also unset it.
  404. //
  405. #define PDEVF_CANCEL_JOB 0x80000000
  406. #define PDEVF_IN_COMMONROPBLT (0x00000001)
  407. #define PDEVF_USE_HTSURF (0x00000001 << 1) // same as 0x2
  408. #define PDEVF_HAS_CLIPRECT (0x00000001 << 2) // same as 0x4
  409. #define PDEVF_INVERT_BITMAP (0x00000001 << 3) // same as 0x8
  410. #define PDEVF_RENDER_IN_COPYBITS (0x00000001 << 4) // same as 0x10
  411. #define PDEVF_RENDER_TRANSPARENT (0x00000001 << 5) // same as 0x10
  412. struct IPrintOemDriverUni;
  413. #define HPGLPDEV_SIG 'hpgl'
  414. typedef struct _OEMPDEV {
  415. //
  416. // Start this pdev with a signature, to differentiate it from pclxl's pdev
  417. //
  418. DWORD dwSig;
  419. //
  420. // define whatever needed, such as working buffers, tracking information,
  421. // etc.
  422. //
  423. // This test DLL hooks out every drawing DDI. So it needs to remember
  424. // Unidrv's hook function pointer so it call back.
  425. //
  426. PFN pfnUnidrv[MAX_DDI_HOOKS];
  427. ERenderLanguage eCurRenderLang;
  428. BOOL bInitHPGL;
  429. WORD wInitCIDPalettes;
  430. WORD wJobSetup;
  431. BOOL bTextTransparencyMode;
  432. BOOL bTextAsBitmapMode;
  433. HPGLSTATE HPGLState;
  434. RASTERSTATE RasterState;
  435. EObjectType eCurObjectType;
  436. ECIDPalette eCurCIDPalette;
  437. ULONG uCurFgColor;
  438. DWORD dwCursorOriginX;
  439. DWORD dwCursorOriginY;
  440. ROP4 CurrentROP3; // keep track of the current ROP (MIX)
  441. OEMHALFTONE CurHalftone; //
  442. OEMCOLORCONTROL CurColorControl; // Keep track of previous Color Smart settings
  443. int iPalType;
  444. int CurSourceTransparency;
  445. int CurPatternTransparency;
  446. ETransparency CurHPGLTransparency; //Transparency, eOPAQUE=OFF, eTRANSPARENT=ON
  447. IPrintOemDriverUni* pOEMHelp; // Note: I'm NOT going to refcount this pointer!
  448. HPALETTE hOEMPalette;
  449. //
  450. // The fields below were earlier in OEMDEVMODE. But since merging the plugin within
  451. // unidrv, we are copying them here.
  452. //
  453. OEMGRAPHICSMODE UIGraphicsMode;
  454. OEMRESOLUTION dmResolution;
  455. OEMPRINTERMODEL PrinterModel;
  456. //
  457. // BrushCache
  458. //
  459. BrushCache *pBrushCache;
  460. BrushCache *pPCLBrushCache;
  461. //
  462. // Other
  463. //
  464. DWORD dwFlags;
  465. LONG lRecursionLevel;
  466. WORD Rop3CopyBits; // Can I use CurrentROP3 ?????
  467. SURFOBJ *psoHTBlt; // Shadow bitmap.
  468. RECTL rclHTBlt;
  469. BOOL bColorPrinter;
  470. BOOL bStick;
  471. ULONG ulNupCompr; // What shall be the compression factor for values values
  472. // of nup. i.e. if iLayout = NINE_UP, this value is 3
  473. } OEMPDEV, *POEMPDEV;
  474. #endif