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.

436 lines
12 KiB

  1. /*++
  2. Copyright (c) 1990-1993 Microsoft Corporation
  3. Module Name:
  4. htalias.h
  5. Abstract:
  6. This module contains defines and structure for anti-aliasing
  7. Author:
  8. 09-Apr-1998 Thu 20:25:29 created -by- Daniel Chou (danielc)
  9. [Environment:]
  10. GDI Device Driver - Plotter.
  11. [Notes:]
  12. Revision History:
  13. --*/
  14. #ifndef _HTALIAS_
  15. #define _HTALIAS_
  16. #define XCHG(a,b,t) { (t)=(a); (a)=(b); (b)=(t); }
  17. #define DI_R_SHIFT 13
  18. #define DI_MAX_NUM (0x0001 << DI_R_SHIFT)
  19. #define DI_NUM_MASK (DI_MAX_NUM - 1)
  20. #define DI_MUL_SHIFT (DI_R_SHIFT >> 1)
  21. #define MUL_TABLE_SIZE (DI_MUL_SHIFT * 256 * sizeof(LONG))
  22. #define AABF_MASK_IS_ORDER 0x01
  23. #define AABF_SRC_IS_BGR8 0x02
  24. #define AABF_SRC_IS_BGR_ALPHA 0x04
  25. #define AABF_SRC_IS_RGB_ALPHA 0x08
  26. typedef struct _AABFDATA {
  27. BYTE Flags;
  28. BYTE Format;
  29. BYTE MaskRGB[3];
  30. BYTE LShiftRGB[3];
  31. BYTE RShiftRGB[3];
  32. BYTE cbSrcInc;
  33. } AABFDATA, *PAABFDATA;
  34. #define GET_FIRST_EDMUL(em, m, n, t) \
  35. { \
  36. (n) = ((LONGLONG)(m) * (LONGLONG)DI_MAX_NUM); \
  37. (em) = (WORD)((n) / (LONGLONG)(t)); \
  38. }
  39. #define GET_NEXT_EDMUL(em, m, n, t) \
  40. { \
  41. (n) = ((LONGLONG)(m) * (LONGLONG)DI_MAX_NUM) + ((n) % (LONGLONG)(t)); \
  42. (em) = (WORD)((n) / (LONGLONG)(t)); \
  43. }
  44. #define SDF_LARGE_MUL (0x0001 << (DI_R_SHIFT + 2))
  45. #define SDF_DONE (0x0001 << (DI_R_SHIFT + 1))
  46. #define SDF_MUL_MASK (0xFFFF >> (15 - DI_R_SHIFT))
  47. #define GET_SDF_LARGE_MASK(m) (BYTE)((SHORT)(m) >> 15)
  48. #define GET_SDF_LARGE_INC(m) (UINT)((m) >> 15)
  49. #define GET_SDF_LARGE_OFF(m) (((UINT)(m) >> ((DI_R_SHIFT+2)-10)) & 0x400)
  50. typedef struct _SHRINKDATA {
  51. WORD Mul;
  52. } SHRINKDATA, *PSHRINKDATA;
  53. #define EDF_LOAD_PIXEL 0x8000
  54. #define EDF_NO_NEWSRC 0x4000
  55. typedef struct _EXPDATA {
  56. WORD Mul[4];
  57. } EXPDATA, *PEXPDATA;
  58. #define AAIF_EXP_HAS_1ST_LEFT 0x0001
  59. #define AAIF_EXP_NO_LAST_RIGHT 0x0002
  60. #define AAIF_EXP_NO_SHARPEN 0x0004
  61. typedef struct _REPDATA {
  62. WORD c;
  63. } REPDATA, *PREPDATA;
  64. typedef struct _SRCBLTINFO {
  65. LONG cIn;
  66. LONG cOut;
  67. LONG iBeg;
  68. LONG iSize;
  69. LONG iSrcBeg;
  70. LONG iSrcEnd;
  71. LONG iDstBeg;
  72. LONG iDstEnd;
  73. BYTE cPrevSrc;
  74. BYTE cNextSrc;
  75. BYTE cFirstSkip;
  76. BYTE cLastSkip;
  77. PREPDATA pRep;
  78. PREPDATA pRepEnd;
  79. DWORD cRep;
  80. } SRCBLTINFO, *PSRCBLTINFO;
  81. typedef struct _AAINFO {
  82. LONG cIn; // Input pixels Count
  83. LONG cOut; // Output Pixel Count
  84. WORD Flags; // AAIF_xxxx
  85. WORD PreSrcInc; // For shrinking
  86. WORD cPreLoad; // Preload
  87. WORD PreMul; // pre mul for shrinking
  88. DWORD cAAData;
  89. union {
  90. DWORD cAALoad; // for expand, blt
  91. DWORD cAADone; // for shrinking
  92. } DUMMYUNIONNAME2;
  93. union {
  94. PLONG pMapMul; // use by SHRINK
  95. DWORD cMaxMul; // use by EXPAND
  96. LONG iSrcBeg; // use by TILE (Offset for the first one)
  97. } DUMMYUNIONNAME3;
  98. LPBYTE pbExtra; // extra buffer allocated
  99. LPVOID pAAData; // either PEXPDATA or PSHRINKDATA
  100. SRCBLTINFO Src;
  101. SRCBLTINFO Mask;
  102. SRCBLTINFO AB;
  103. #if DBG
  104. DWORD cbAlloc; // allocating size
  105. #endif
  106. } AAINFO, *PAAINFO;
  107. typedef VOID (HTENTRY *AACXFUNC)(PAAINFO pAAInfo,
  108. PBGR8 pIn,
  109. PBGR8 pOut,
  110. LPBYTE pOutEnd,
  111. LONG OutInc);
  112. typedef LONG (HTENTRY *AACYFUNC)(struct _AAHEADER *pAAHdr);
  113. typedef PBGR8 (HTENTRY *AAINPUTFUNC)(struct _AASURFINFO *pAASI,
  114. PBGR8 pInBuf);
  115. #define XLATE_666_IDX_OR 0x01
  116. #define XLATE_RGB_IDX_OR 0x02
  117. #define XLATE_IDX_MASK (XLATE_RGB_IDX_OR | XLATE_666_IDX_OR)
  118. #define XLATE_IDX_MAX 3
  119. typedef struct _BM8BPPDATA {
  120. BYTE pXlateIdx;
  121. BYTE bXor;
  122. BYTE bBlack;
  123. BYTE bWhite;
  124. } BM8BPPDATA, *PBM8BPPDATA;
  125. typedef union _BM8BPPINFO {
  126. DWORD dw;
  127. BYTE b4[4];
  128. BM8BPPDATA Data;
  129. } BM8BPPINFO, *PBM8BPPINFO;
  130. typedef struct _AABGRINFO {
  131. BYTE Order;
  132. BYTE iR;
  133. BYTE iG;
  134. BYTE iB;
  135. } AABGRINFO;
  136. typedef struct AABITMASKINFO {
  137. BYTE cFirst;
  138. BYTE XorMask;
  139. BYTE LSFirst;
  140. BYTE cLast;
  141. } AABITMASKINFO;
  142. typedef struct _AAOUTPUTINFO {
  143. union {
  144. AABITMASKINFO bm;
  145. AABGRINFO bgri;
  146. BM8BPPINFO bm8i;
  147. LPBYTE pXlate8BPP;
  148. PCMY8BPPMASK pCMY8BPPMask;
  149. BYTE b4[4];
  150. WORD w2[2];
  151. DWORD dw;
  152. } DUMMYUNIONNAME;
  153. } AAOUTPUTINFO, *PAAOUTPUTINFO;
  154. typedef VOID (HTENTRY *AAOUTPUTFUNC)(struct _AAHEADER *pAAHdr,
  155. PBGRF pInBeg,
  156. PBGRF pInEnd,
  157. LPBYTE pDst,
  158. PLONG pIdxBGR,
  159. LPBYTE pbPat,
  160. LPBYTE pbPatEnd,
  161. LONG cbWrapBGR,
  162. AAOUTPUTINFO AAOutputInfo);
  163. typedef VOID (HTENTRY *AAMASKFUNC)(struct _AAHEADER *pAAHdr);
  164. #define FAST_MAX_CX 5
  165. #define FAST_MAX_CY 5
  166. #define AAHF_FLIP_X 0x00000001
  167. #define AAHF_FLIP_Y 0x00000002
  168. #define AAHF_ADDITIVE 0x00000004
  169. #define AAHF_DO_SRC_CLR_MAPPING 0x00000008
  170. #define AAHF_DO_DST_CLR_MAPPING 0x00000010
  171. #define AAHF_GET_LAST_SCAN 0x00000020
  172. #define AAHF_DO_FIXUPDIB 0x00000040
  173. #define AAHF_HAS_MASK 0x00000080
  174. #define AAHF_INVERT_MASK 0x00000100
  175. #define AAHF_BBPF_AA_OFF 0x00000200
  176. #define AAHF_TILE_SRC 0x00000400
  177. #define AAHF_ALPHA_BLEND 0x00000800
  178. #define AAHF_CONST_ALPHA 0x00001000
  179. #define AAHF_OR_AV 0x00002000
  180. #define AAHF_FAST_EXP_AA 0x00004000
  181. #define AAHF_SHRINKING 0x00080000
  182. #define AAHF_AB_DEST 0x00100000
  183. #define AAHF_USE_DCI_DATA 0x80000000
  184. #define AAHF_DO_CLR_MAPPING (AAHF_DO_SRC_CLR_MAPPING | \
  185. AAHF_DO_DST_CLR_MAPPING)
  186. #define PBGRF_MASK_FLAG 0xFF
  187. #define PBGRF_END_FLAG 0xED
  188. #define PBGRF_HAS_MASK(p) ((p)->f)
  189. typedef struct _FIXUPDIBINFO {
  190. PBGR8 prgbD[6];
  191. DWORD cbbgr;
  192. LONG cyIn;
  193. #if DBG
  194. LONG cCorner;
  195. LONG cChecker;
  196. #endif
  197. } FIXUPDIBINFO;
  198. #define AASIF_TILE_SRC 0x01
  199. #define AASIF_INC_PB 0x02
  200. #define AASIF_GRAY 0x04
  201. #define AASIF_AB_PREMUL_SRC 0x08
  202. typedef struct _AASURFINFO {
  203. BYTE Flags;
  204. BYTE BitOffset;
  205. WORD cClrTable;
  206. PLONG pIdxBGR;
  207. AAINPUTFUNC InputFunc;
  208. LPBYTE pbOrg;
  209. LONG cyOrg;
  210. LPBYTE pb;
  211. LONG cx;
  212. LONG cy;
  213. LONG cbCX;
  214. LONG cyNext;
  215. AABFDATA AABFData;
  216. PRGB4B pClrTable;
  217. } AASURFINFO, *PAASURFINFO;
  218. typedef struct _AAHEADER {
  219. DWORD Flags;
  220. BYTE MaskBitOff;
  221. BYTE bReserved[3];
  222. AASURFINFO SrcSurfInfo;
  223. AASURFINFO DstSurfInfo;
  224. AAMASKFUNC AAMaskCXFunc;
  225. AAMASKFUNC AAMaskCYFunc;
  226. LONG cbMaskSrc;
  227. LPBYTE pMaskSrc;
  228. LPBYTE pMaskIn;
  229. LONG cyMaskNext;
  230. LONG cyMaskIn;
  231. AAMASKFUNC GetAVCXFunc;
  232. AAMASKFUNC GetAVCYFunc;
  233. PBGRF pbgrfAB;
  234. LONG cybgrfAB;
  235. LONG cyABNext;
  236. LPBYTE pbFixupDIB;
  237. AAOUTPUTFUNC AAOutputFunc;
  238. AAOUTPUTINFO AAOutputInfo;
  239. AACXFUNC AACXFunc;
  240. AACYFUNC AACYFunc;
  241. PAAINFO pAAInfoCX;
  242. PAAINFO pAAInfoCY;
  243. LPBYTE pOutLast;
  244. POINTL ptlBrushOrg;
  245. LPBYTE pAlphaBlendBGR;
  246. LPBYTE pSrcAV;
  247. LPBYTE pSrcAVBeg;
  248. LPBYTE pSrcAVEnd;
  249. LONG SrcAVInc;
  250. PRGBLUTAA prgbLUT;
  251. PLONG pIdxBGR;
  252. PBGR8 pBGRMapTable;
  253. LPBYTE pXlate8BPP;
  254. AAPATINFO AAPI;
  255. FIXUPDIBINFO FUDI;
  256. PBGR8 pInputBeg; // For input the source
  257. PBGRF pRealOutBeg; // original output buffer begin
  258. PBGRF pRealOutEnd; // original output buffer end
  259. PBGRF pOutputBeg; // for output to the destination the
  260. PBGRF pOutputEnd; // pOutputEnd (will be modified)
  261. PBGRF pAABufBeg; // for temporary anti-aliasing storage
  262. PBGRF pAABufEnd; // This is exclusive
  263. LONG AABufInc; // Buffer increment (may be negative)
  264. #if DBG
  265. DWORD cbAlloc;
  266. LPBYTE pOutBeg;
  267. LPBYTE pOutEnd;
  268. #endif
  269. } AAHEADER, *PAAHEADER;
  270. typedef PAAINFO (HTENTRY *AABUILDFUNC)(PDEVICECOLORINFO pDCI,
  271. DWORD AAHFlags,
  272. PLONG piSrcBeg,
  273. PLONG piSrcEnd,
  274. LONG SrcSize,
  275. LONG cOut,
  276. LONG IdxDst,
  277. PLONG piDstBeg,
  278. PLONG piDstEnd,
  279. LONG cbExtra);
  280. #define AACYMODE_TILE 0
  281. #define AACYMODE_BLT 1
  282. #define AACYMODE_SHRINK 2
  283. #define AACYMODE_SHRINK_SRKCX 3
  284. #define AACYMODE_EXPAND 4
  285. #define AACYMODE_EXPAND_EXPCX 5
  286. #define AACYMODE_NONE 0xFF
  287. #define AACXMODE_BLT 0
  288. #define AACXMODE_SHRINK 1
  289. #define AACXMODE_EXPAND 2
  290. typedef struct _AABBP {
  291. DWORD AAHFlags;
  292. BYTE CYFuncMode;
  293. BYTE CXFuncMode;
  294. WORD wReserved;
  295. AACXFUNC AACXFunc;
  296. AABUILDFUNC AABuildCXFunc;
  297. AABUILDFUNC AABuildCYFunc;
  298. AAMASKFUNC AAMaskCXFunc;
  299. AAMASKFUNC AAMaskCYFunc;
  300. AAMASKFUNC GetAVCXFunc;
  301. AAMASKFUNC GetAVCYFunc;
  302. RECTL rclSrc; // original source, not well ordered
  303. RECTL rclDst; // Final destination, well ordered
  304. RECTL rclDstOrg; // Original Destination, well ordered
  305. POINTL ptlFlip; // flipping's substraction
  306. LONG cxDst;
  307. LONG cyDst;
  308. POINTL ptlBrushOrg;
  309. POINTL ptlMask; // Final source mask offset
  310. } AABBP, *PAABBP;
  311. //
  312. // Function prototype
  313. //
  314. VOID
  315. HTENTRY
  316. SetGrayColorTable(
  317. PLONG pIdxBGR,
  318. PAASURFINFO pAASI
  319. );
  320. VOID
  321. HTENTRY
  322. GetColorTable(
  323. PHTSURFACEINFO pSrcSI,
  324. PAAHEADER pAAHdr,
  325. PBFINFO pBFInfo
  326. );
  327. VOID
  328. HTENTRY
  329. ComputeInputColorInfo(
  330. LPBYTE pSrcTable,
  331. UINT cPerTable,
  332. UINT PrimaryOrder,
  333. PBFINFO pBFInfo,
  334. PAASURFINFO pAASI
  335. );
  336. LONG
  337. HTENTRY
  338. SetupAAHeader(
  339. PHALFTONERENDER pHR,
  340. PDEVICECOLORINFO pDCI,
  341. PAAHEADER pAAHdr,
  342. AACYFUNC *pAACYFunc
  343. );
  344. #endif // _HTALIAS_