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.

2746 lines
54 KiB

  1. /*++
  2. Copyright (c) 1990-1991 Microsoft Corporation
  3. Module Name:
  4. htgetbmp.c
  5. Abstract:
  6. This module provided a set of functions which read the 1/4/8/16/24/32
  7. bits per pel bitmap and composed it
  8. Author:
  9. 08-Jan-1999 Fri 18:14:42 updated -by- Daniel Chou (danielc)
  10. Re-write
  11. 23-Apr-1992 Thu 21:14:55 updated -by- Daniel Chou (danielc)
  12. 1. Delete InFuncInfo.StretchSize, and using Prim1/Prim2 to determined
  13. when we will stop the source stretch,
  14. 2. Change 'ColorInfoIncrement' from 'CHAR' to 'SHORT', this will make
  15. sure the default MIPS's 'unsigned char' will not affect our
  16. signed operation.
  17. 28-Mar-1992 Sat 20:54:58 updated -by- Daniel Chou (danielc)
  18. Update it for VGA intensity (16 colors mode), this make all the
  19. codes update to 4 primaries internal.
  20. 05-Apr-1991 Fri 15:55:08 created -by- Daniel Chou (danielc)
  21. [Environment:]
  22. Printer Driver.
  23. [Notes:]
  24. Revision History:
  25. --*/
  26. #define DBGP_VARNAME dbgpHTGetBmp
  27. #include "htp.h"
  28. #include "htmapclr.h"
  29. #include "htpat.h"
  30. #include "htalias.h"
  31. #include "htrender.h"
  32. #include "htstret.h"
  33. #include "htgetbmp.h"
  34. #define DBGP_INPUT 0x00000001
  35. #define DBGP_GETFIXUP 0x00000002
  36. #define DBGP_CHK_FUDI 0x00000004
  37. #define DBGP_FUDI 0x00000008
  38. #define DBGP_EXP_MASK 0x00000010
  39. DEF_DBGPVAR(BIT_IF(DBGP_INPUT, 0) |
  40. BIT_IF(DBGP_GETFIXUP, 0) |
  41. BIT_IF(DBGP_CHK_FUDI, 0) |
  42. BIT_IF(DBGP_FUDI, 0) |
  43. BIT_IF(DBGP_EXP_MASK, 0))
  44. #if DBG
  45. INT cCXMask = 0;
  46. #define DBG_CXMASK 0
  47. #else
  48. #define DBG_CXMASK 0
  49. #endif
  50. #define GET_AV(p) (BYTE)(p)->f
  51. #define OR_AV(AV1, AV2) (BYTE)(((UINT)(AV1) + (UINT)(AV2) + 1) >> 1)
  52. extern DWORD dwABPreMul[256];
  53. #define GET_PREMUL_SRC(x, m) \
  54. (BYTE)((((DWORD)(x) * (DWORD)(m)) + 0x800000) >> 24)
  55. VOID
  56. HTENTRY
  57. BltAV_CX(
  58. PAAHEADER pAAHdr
  59. )
  60. /*++
  61. Routine Description:
  62. Arguments:
  63. Return Value:
  64. Author:
  65. 09-Dec-1998 Wed 15:32:38 created -by- Daniel Chou (danielc)
  66. Revision History:
  67. --*/
  68. {
  69. PAAINFO pAAInfo;
  70. LPBYTE pSrcAV;
  71. LPBYTE pSrcAVEnd;
  72. INT SrcAVInc;
  73. PBGRF pbgrfAB;
  74. pSrcAV = pAAHdr->pSrcAVBeg;
  75. pSrcAVEnd = pAAHdr->pSrcAVEnd;
  76. SrcAVInc = (INT)pAAHdr->SrcAVInc;
  77. pbgrfAB = pAAHdr->pbgrfAB;
  78. if (pAAHdr->Flags & AAHF_OR_AV) {
  79. do {
  80. *pSrcAV = OR_AV(*pSrcAV, GET_AV(pbgrfAB));
  81. ++pbgrfAB;
  82. } while (((LPBYTE)pSrcAV += SrcAVInc) != (LPBYTE)pSrcAVEnd);
  83. } else {
  84. do {
  85. *pSrcAV = GET_AV(pbgrfAB);
  86. ++pbgrfAB;
  87. } while (((LPBYTE)pSrcAV += SrcAVInc) != (LPBYTE)pSrcAVEnd);
  88. }
  89. }
  90. VOID
  91. HTENTRY
  92. BltAV_CY(
  93. PAAHEADER pAAHdr
  94. )
  95. /*++
  96. Routine Description:
  97. Arguments:
  98. Return Value:
  99. Author:
  100. 09-Dec-1998 Wed 15:32:38 created -by- Daniel Chou (danielc)
  101. Revision History:
  102. --*/
  103. {
  104. pAAHdr->GetAVCXFunc(pAAHdr);
  105. (LPBYTE)pAAHdr->pbgrfAB += pAAHdr->cyABNext;
  106. }
  107. VOID
  108. HTENTRY
  109. TileAV_CY(
  110. PAAHEADER pAAHdr
  111. )
  112. /*++
  113. Routine Description:
  114. Arguments:
  115. Return Value:
  116. Author:
  117. 11-Jul-1997 Fri 14:26:26 created -by- Daniel Chou (danielc)
  118. Revision History:
  119. --*/
  120. {
  121. PAAINFO pAAInfo;
  122. LPBYTE pSrcAV;
  123. LPBYTE pSrcAVEnd;
  124. INT SrcAVInc;
  125. PBGRF pbgrfAB;
  126. PBGRF pbgrfABBeg;
  127. PBGRF pbgrfABEnd;
  128. pSrcAV = pAAHdr->pSrcAVBeg;
  129. pSrcAVEnd = pAAHdr->pSrcAVEnd;
  130. SrcAVInc = (INT)pAAHdr->SrcAVInc;
  131. pbgrfAB =
  132. pbgrfABBeg = pAAHdr->pbgrfAB;
  133. pbgrfABEnd = pbgrfAB + pAAHdr->SrcSurfInfo.cx;
  134. pbgrfAB += pAAHdr->pAAInfoCX->iSrcBeg;
  135. do {
  136. *pSrcAV = GET_AV(pbgrfAB);
  137. if (++pbgrfAB >= pbgrfABEnd) {
  138. pbgrfAB = pbgrfABBeg;
  139. }
  140. } while (((LPBYTE)pSrcAV += SrcAVInc) != (LPBYTE)pSrcAVEnd);
  141. if (--pAAHdr->cybgrfAB <= 0) {
  142. pAAHdr->pbgrfAB = (PBGRF)pAAHdr->SrcSurfInfo.pbOrg;
  143. pAAHdr->cybgrfAB = pAAHdr->SrcSurfInfo.cyOrg;
  144. }
  145. }
  146. VOID
  147. HTENTRY
  148. ExpandAV_CX(
  149. PAAHEADER pAAHdr
  150. )
  151. /*++
  152. Routine Description:
  153. Arguments:
  154. Return Value:
  155. Author:
  156. 09-Dec-1998 Wed 15:54:25 created -by- Daniel Chou (danielc)
  157. Revision History:
  158. --*/
  159. {
  160. PAAINFO pAAInfo;
  161. PREPDATA pRep;
  162. PREPDATA pRepEnd;
  163. LPBYTE pSrcAV;
  164. LPBYTE pSrcAVEnd;
  165. PBGRF pbgrfAB;
  166. INT SrcAVInc;
  167. BOOL OrAV;
  168. DWORD cRep;
  169. BYTE AV;
  170. pSrcAV = pAAHdr->pSrcAVBeg;
  171. pSrcAVEnd = pAAHdr->pSrcAVEnd;
  172. SrcAVInc = (INT)pAAHdr->SrcAVInc;
  173. pbgrfAB = pAAHdr->pbgrfAB;
  174. pAAInfo = pAAHdr->pAAInfoCX;
  175. pRep = pAAInfo->AB.pRep;
  176. pRepEnd = pAAInfo->AB.pRepEnd;
  177. cRep = 1;
  178. //
  179. // The AB set to 0xff so if the source AB is not available at begining
  180. // then it will be no AB
  181. //
  182. AV = 0xFF;
  183. OrAV = (BOOL)(pAAHdr->Flags & AAHF_OR_AV);
  184. do {
  185. if (--cRep == 0) {
  186. ASSERT(pRep < pRepEnd);
  187. cRep = (DWORD)pRep++->c;
  188. AV = GET_AV(pbgrfAB);
  189. if (OrAV) {
  190. AV = OR_AV(AV, *pSrcAV);
  191. }
  192. ++pbgrfAB;
  193. }
  194. *pSrcAV = (BYTE)AV;
  195. } while (((LPBYTE)pSrcAV += SrcAVInc) != (LPBYTE)pSrcAVEnd);
  196. }
  197. VOID
  198. HTENTRY
  199. ExpandAV_CY(
  200. PAAHEADER pAAHdr
  201. )
  202. /*++
  203. Routine Description:
  204. Arguments:
  205. Return Value:
  206. Author:
  207. 09-Dec-1998 Wed 15:32:38 created -by- Daniel Chou (danielc)
  208. Revision History:
  209. --*/
  210. {
  211. PAAINFO pAAInfo;
  212. pAAInfo = pAAHdr->pAAInfoCY;
  213. if (--pAAInfo->AB.cRep == 0) {
  214. ASSERT(pAAInfo->AB.pRep < pAAInfo->AB.pRepEnd);
  215. pAAInfo->AB.cRep = (DWORD)pAAInfo->AB.pRep++->c;
  216. BltAV_CY(pAAHdr);
  217. }
  218. }
  219. VOID
  220. HTENTRY
  221. ShrinkAV_CX(
  222. PAAHEADER pAAHdr
  223. )
  224. /*++
  225. Routine Description:
  226. Arguments:
  227. Return Value:
  228. Author:
  229. 09-Dec-1998 Wed 15:32:38 created -by- Daniel Chou (danielc)
  230. Revision History:
  231. --*/
  232. {
  233. PAAINFO pAAInfo;
  234. PREPDATA pRep;
  235. PREPDATA pRepEnd;
  236. LPBYTE pSrcAV;
  237. LPBYTE pSrcAVEnd;
  238. PBGRF pbgrfAB;
  239. INT SrcAVInc;
  240. DWORD cRep;
  241. BOOL OrAV;
  242. BYTE AV;
  243. pSrcAV = pAAHdr->pSrcAVBeg;
  244. pSrcAVEnd = pAAHdr->pSrcAVEnd;
  245. SrcAVInc = (INT)pAAHdr->SrcAVInc;
  246. pbgrfAB = pAAHdr->pbgrfAB;
  247. pAAInfo = pAAHdr->pAAInfoCX;
  248. pRep = pAAInfo->AB.pRep;
  249. pRepEnd = pAAInfo->AB.pRepEnd;
  250. OrAV = (BOOL)(pAAHdr->Flags & AAHF_OR_AV);
  251. do {
  252. AV = 0xFF;
  253. ASSERT(pRep < pRepEnd);
  254. if (pRep < pRepEnd) {
  255. AV = GET_AV(pbgrfAB);
  256. if (OrAV) {
  257. AV = OR_AV(*pSrcAV, AV);
  258. }
  259. ++pbgrfAB;
  260. cRep = (DWORD)pRep++->c;
  261. while (--cRep) {
  262. AV = OR_AV(AV, GET_AV(pbgrfAB));
  263. ++pbgrfAB;
  264. }
  265. }
  266. *pSrcAV = AV;
  267. } while (((LPBYTE)pSrcAV += SrcAVInc) != (LPBYTE)pSrcAVEnd);
  268. }
  269. VOID
  270. HTENTRY
  271. ShrinkAV_CY(
  272. PAAHEADER pAAHdr
  273. )
  274. /*++
  275. Routine Description:
  276. Arguments:
  277. Return Value:
  278. Author:
  279. 09-Dec-1998 Wed 15:32:38 created -by- Daniel Chou (danielc)
  280. Revision History:
  281. --*/
  282. {
  283. PAAINFO pAAInfoCY;
  284. DWORD AAHFlags;
  285. DWORD cRep;
  286. //
  287. // We will get the scan first then subsequence scans will be or in
  288. //
  289. pAAInfoCY = pAAHdr->pAAInfoCY;
  290. AAHFlags = pAAHdr->Flags;
  291. pAAHdr->Flags &= ~AAHF_OR_AV;
  292. ASSERT(pAAInfoCY->AB.pRep < pAAInfoCY->AB.pRepEnd);
  293. cRep = (DWORD)pAAInfoCY->AB.pRep++->c;
  294. while (cRep--) {
  295. pAAHdr->GetAVCXFunc(pAAHdr);
  296. pAAHdr->Flags = AAHFlags;
  297. (LPBYTE)pAAHdr->pbgrfAB += pAAHdr->cyABNext;
  298. }
  299. }
  300. VOID
  301. HTENTRY
  302. BltMask_CX(
  303. PAAHEADER pAAHdr
  304. )
  305. /*++
  306. Routine Description:
  307. Arguments:
  308. Return Value:
  309. Author:
  310. 09-Dec-1998 Wed 15:32:38 created -by- Daniel Chou (danielc)
  311. Revision History:
  312. --*/
  313. {
  314. PAAINFO pAAInfo;
  315. PBGRF pDst;
  316. PBGRF pDstEnd;
  317. LPBYTE pb;
  318. INT DstInc;
  319. DW2W4B dw4b;
  320. BYTE Mask;
  321. pAAInfo = pAAHdr->pAAInfoCX;
  322. pDst = pAAHdr->pAABufBeg;
  323. pDstEnd = pAAHdr->pAABufEnd;
  324. DstInc = pAAHdr->AABufInc;
  325. pb = pAAHdr->pMaskSrc;
  326. dw4b.dw = 0x01;
  327. dw4b.b[2] = *pb++;
  328. dw4b.dw <<= pAAHdr->MaskBitOff;
  329. do {
  330. if (dw4b.b[1]) {
  331. dw4b.dw = 0x01;
  332. dw4b.b[2] = *pb++;
  333. }
  334. pDst->f = (BYTE)((dw4b.b[2] & 0x80) ? PBGRF_MASK_FLAG : 0);
  335. dw4b.dw <<= 1;
  336. } while (((LPBYTE)pDst += DstInc) != (LPBYTE)pDstEnd);
  337. }
  338. VOID
  339. HTENTRY
  340. BltMask_CY(
  341. PAAHEADER pAAHdr
  342. )
  343. /*++
  344. Routine Description:
  345. Arguments:
  346. Return Value:
  347. Author:
  348. 09-Dec-1998 Wed 15:32:38 created -by- Daniel Chou (danielc)
  349. Revision History:
  350. --*/
  351. {
  352. GET_MASK_SCAN(pAAHdr);
  353. pAAHdr->AAMaskCXFunc(pAAHdr);
  354. }
  355. VOID
  356. HTENTRY
  357. ExpandMask_CX(
  358. PAAHEADER pAAHdr
  359. )
  360. /*++
  361. Routine Description:
  362. Arguments:
  363. Return Value:
  364. Author:
  365. 09-Dec-1998 Wed 15:54:25 created -by- Daniel Chou (danielc)
  366. Revision History:
  367. --*/
  368. {
  369. PAAINFO pAAInfo;
  370. PREPDATA pRep;
  371. PREPDATA pRepEnd;
  372. PBGRF pDst;
  373. PBGRF pDstEnd;
  374. LPBYTE pb;
  375. DWORD cRep;
  376. INT DstInc;
  377. DW2W4B dw4b;
  378. BYTE Mask;
  379. pAAInfo = pAAHdr->pAAInfoCX;
  380. pRep = pAAInfo->Mask.pRep;
  381. pRepEnd = pAAInfo->Mask.pRepEnd;
  382. pDst = pAAHdr->pAABufBeg;
  383. pDstEnd = pAAHdr->pAABufEnd;
  384. DstInc = pAAHdr->AABufInc;
  385. pb = pAAHdr->pMaskSrc;
  386. dw4b.dw = 0x01;
  387. dw4b.b[2] = *pb++;
  388. dw4b.dw <<= pAAHdr->MaskBitOff;
  389. //
  390. // The Mask set to 0xff so if the source mask is not available at begining
  391. // then it will be no mask
  392. //
  393. Mask = PBGRF_MASK_FLAG;
  394. cRep = 1;
  395. do {
  396. if (--cRep == 0) {
  397. ASSERT(pRep < pRepEnd);
  398. cRep = (DWORD)pRep++->c;
  399. //
  400. // Load new byte data if we already used up current byte
  401. //
  402. if (dw4b.b[1]) {
  403. dw4b.dw = 0x01;
  404. dw4b.b[2] = *pb++;
  405. }
  406. Mask = (BYTE)((dw4b.b[2] & 0x80) ? PBGRF_MASK_FLAG : 0);
  407. dw4b.dw <<= 1;
  408. }
  409. pDst->f = Mask;
  410. } while (((LPBYTE)pDst += DstInc) != (LPBYTE)pDstEnd);
  411. SETDBGVAR(cCXMask, -1);
  412. }
  413. VOID
  414. HTENTRY
  415. ExpandMask_CY(
  416. PAAHEADER pAAHdr
  417. )
  418. /*++
  419. Routine Description:
  420. Arguments:
  421. Return Value:
  422. Author:
  423. 09-Dec-1998 Wed 15:32:38 created -by- Daniel Chou (danielc)
  424. Revision History:
  425. --*/
  426. {
  427. PAAINFO pAAInfo;
  428. pAAInfo = pAAHdr->pAAInfoCY;
  429. if (--pAAInfo->Mask.cRep == 0) {
  430. ASSERT(pAAInfo->Mask.pRep < pAAInfo->Mask.pRepEnd);
  431. pAAInfo->Mask.cRep = (DWORD)pAAInfo->Mask.pRep++->c;
  432. DBGP_IF(DBGP_EXP_MASK,
  433. DBGP("LOAD: cy=%4ld, cMaskRem=%4ld, cMaskIn=%4ld, cMaskOut=%4ld"
  434. ARGDW(pAAHdr->cyMaskIn) ARGDW(pAAInfo->Mask.cRep)
  435. ARGDW(pAAInfo->Mask.cIn) ARGDW(pAAInfo->Mask.cOut)));
  436. BltMask_CY(pAAHdr);
  437. } else {
  438. DBGP_IF(DBGP_EXP_MASK,
  439. DBGP(" cy=%4ld, cMaskRem=%4ld, cMaskIn=%4ld, cMaskOut=%4ld"
  440. ARGDW(pAAHdr->cyMaskIn) ARGDW(pAAInfo->Mask.cRep)
  441. ARGDW(pAAInfo->Mask.cIn) ARGDW(pAAInfo->Mask.cOut)));
  442. }
  443. }
  444. VOID
  445. HTENTRY
  446. ShrinkMask_CX(
  447. PAAHEADER pAAHdr
  448. )
  449. /*++
  450. Routine Description:
  451. Arguments:
  452. Return Value:
  453. Author:
  454. 09-Dec-1998 Wed 15:32:38 created -by- Daniel Chou (danielc)
  455. Revision History:
  456. --*/
  457. {
  458. PAAINFO pAAInfo;
  459. PREPDATA pRep;
  460. PREPDATA pRepEnd;
  461. PBGRF pDst;
  462. PBGRF pDstEnd;
  463. LPBYTE pb;
  464. DWORD cRep;
  465. DW2W4B dw4b;
  466. INT DstInc;
  467. BYTE Mask;
  468. pAAInfo = pAAHdr->pAAInfoCX;
  469. pRep = pAAInfo->Mask.pRep;
  470. pRepEnd = pAAInfo->Mask.pRepEnd;
  471. pDst = pAAHdr->pAABufBeg;
  472. pDstEnd = pAAHdr->pAABufEnd;
  473. DstInc = pAAHdr->AABufInc;
  474. pb = pAAHdr->pMaskSrc;
  475. dw4b.dw = 0x01;
  476. dw4b.b[2] = *pb++;
  477. dw4b.dw <<= pAAHdr->MaskBitOff;
  478. //
  479. // --iMaskSize, because we want it to go negative when we reach 0, and
  480. // use bit 24-31 for mask
  481. //
  482. do {
  483. ASSERT(pRep < pRepEnd);
  484. cRep = (DWORD)pRep++->c;
  485. Mask = 0;
  486. while (cRep--) {
  487. //
  488. // Load new byte data if we already used up current byte
  489. //
  490. if (dw4b.b[1]) {
  491. dw4b.dw = 0x01;
  492. dw4b.b[2] = *pb++;
  493. }
  494. //
  495. // Or in the bit 0x80, we will mask it later
  496. //
  497. Mask |= dw4b.b[2];
  498. dw4b.dw <<= 1;
  499. }
  500. pDst->f = (BYTE)((Mask & 0x80) ? PBGRF_MASK_FLAG : 0);
  501. } while (((LPBYTE)pDst += DstInc) != (LPBYTE)pDstEnd);
  502. }
  503. VOID
  504. HTENTRY
  505. ShrinkMask_CY(
  506. PAAHEADER pAAHdr
  507. )
  508. /*++
  509. Routine Description:
  510. Arguments:
  511. Return Value:
  512. Author:
  513. 09-Dec-1998 Wed 15:32:38 created -by- Daniel Chou (danielc)
  514. Revision History:
  515. --*/
  516. {
  517. PAAINFO pAAInfo;
  518. DWORD cRep;
  519. //
  520. // We will get the scan first then subsequence scans will be or in
  521. //
  522. GET_MASK_SCAN(pAAHdr);
  523. pAAInfo = pAAHdr->pAAInfoCY;
  524. ASSERT(pAAInfo->Mask.pRep < pAAInfo->Mask.pRepEnd);
  525. cRep = (DWORD)pAAInfo->Mask.pRep++->c;
  526. while (--cRep) {
  527. OR_MASK_SCAN(pAAHdr);
  528. }
  529. pAAHdr->AAMaskCXFunc(pAAHdr);
  530. }
  531. PBGR8
  532. HTENTRY
  533. Input1BPPToAA24(
  534. PAASURFINFO pAASI,
  535. PBGR8 pInBuf
  536. )
  537. /*++
  538. Routine Description:
  539. Arguments:
  540. Return Value:
  541. Author:
  542. 15-Apr-1998 Wed 16:25:04 created -by- Daniel Chou (danielc)
  543. Revision History:
  544. --*/
  545. {
  546. LPBYTE pIn;
  547. PBGR8 pRet;
  548. UINT cIn;
  549. UINT Idx;
  550. UINT i;
  551. W2B Bit;
  552. UINT InData;
  553. pIn = pAASI->pb;
  554. cIn = (UINT)pAASI->cx;
  555. pRet = pInBuf;
  556. if (pAASI->Flags & AASIF_GRAY) {
  557. LPBYTE pbIB = (LPBYTE)pInBuf;
  558. BYTE Gray[2];
  559. Gray[0] = pAASI->pClrTable[0].a;
  560. Gray[1] = pAASI->pClrTable[1].a;
  561. if (Idx = pAASI->BitOffset) {
  562. Bit.w = (WORD)*pIn++ << Idx;
  563. if ((Idx = 8 - Idx) > cIn) {
  564. Idx = cIn;
  565. }
  566. cIn -= Idx;
  567. while (Idx--) {
  568. Bit.w <<= 1;
  569. *pbIB++ = Gray[i = (Bit.b[1] & 0x01)];
  570. }
  571. }
  572. Idx = cIn >> 3;
  573. while (Idx--) {
  574. InData = (UINT)*pIn++;
  575. *(pbIB + 0) = Gray[(InData >> 7) & 0x01];
  576. *(pbIB + 1) = Gray[(InData >> 6) & 0x01];
  577. *(pbIB + 2) = Gray[(InData >> 5) & 0x01];
  578. *(pbIB + 3) = Gray[(InData >> 4) & 0x01];
  579. *(pbIB + 4) = Gray[(InData >> 3) & 0x01];
  580. *(pbIB + 5) = Gray[(InData >> 2) & 0x01];
  581. *(pbIB + 6) = Gray[(InData >> 1) & 0x01];
  582. *(pbIB + 7) = Gray[(InData ) & 0x01];
  583. pbIB += 8;
  584. }
  585. if (cIn &= 0x07) {
  586. Bit.w = (WORD)*pIn;
  587. while (cIn--) {
  588. Bit.w <<= 1;
  589. *pbIB++ = Gray[i = (Bit.b[1] & 0x01)];
  590. }
  591. }
  592. } else {
  593. BGR8 rgb[2];
  594. rgb[0] = *(PBGR8)pAASI->pClrTable;
  595. rgb[1] = *(PBGR8)(pAASI->pClrTable + 1);
  596. if (Idx = pAASI->BitOffset) {
  597. Bit.w = (WORD)*pIn++ << Idx;
  598. if ((Idx = 8 - Idx) > cIn) {
  599. Idx = cIn;
  600. }
  601. cIn -= Idx;
  602. while (Idx--) {
  603. Bit.w <<= 1;
  604. *pInBuf++ = rgb[i = (Bit.b[1] & 0x01)];
  605. }
  606. }
  607. Idx = cIn >> 3;
  608. while (Idx--) {
  609. InData = (UINT)*pIn++;
  610. *(pInBuf + 0) = rgb[(InData >> 7) & 0x01];
  611. *(pInBuf + 1) = rgb[(InData >> 6) & 0x01];
  612. *(pInBuf + 2) = rgb[(InData >> 5) & 0x01];
  613. *(pInBuf + 3) = rgb[(InData >> 4) & 0x01];
  614. *(pInBuf + 4) = rgb[(InData >> 3) & 0x01];
  615. *(pInBuf + 5) = rgb[(InData >> 2) & 0x01];
  616. *(pInBuf + 6) = rgb[(InData >> 1) & 0x01];
  617. *(pInBuf + 7) = rgb[(InData ) & 0x01];
  618. pInBuf += 8;
  619. }
  620. if (cIn &= 0x07) {
  621. Bit.w = (WORD)*pIn;
  622. while (cIn--) {
  623. Bit.w <<= 1;
  624. *pInBuf++ = rgb[i = (Bit.b[1] & 0x01)];
  625. }
  626. }
  627. }
  628. DBGP_IF(DBGP_INPUT,
  629. DBGP("cyIn=%5ld, pIn=%p-%p, cbIn=%5ld, Buf=%p-%p"
  630. ARGDW(pAASI->cy) ARGPTR(pAASI->pb)
  631. ARGPTR(pIn) ARGDW(pAASI->cbCX)
  632. ARGPTR(pRet) ARGPTR((LPBYTE)pRet + pAASI->cbCX)));
  633. SET_NEXT_PIN(pAASI);
  634. return(pRet);
  635. }
  636. PBGR8
  637. HTENTRY
  638. Input4BPPToAA24(
  639. PAASURFINFO pAASI,
  640. PBGR8 pInBuf
  641. )
  642. /*++
  643. Routine Description:
  644. Arguments:
  645. Return Value:
  646. Author:
  647. 15-Apr-1998 Wed 16:25:04 created -by- Daniel Chou (danielc)
  648. Revision History:
  649. --*/
  650. {
  651. LPBYTE pIn;
  652. PBGR8 pRet;
  653. PRGB4B pColorTable;
  654. UINT InData;
  655. UINT InData2;
  656. UINT cIn;
  657. UINT Idx;
  658. pIn = pAASI->pb;
  659. cIn = (UINT)pAASI->cx;
  660. pRet = pInBuf;
  661. pColorTable = pAASI->pClrTable;
  662. if (pAASI->Flags & AASIF_GRAY) {
  663. LPBYTE pbIB = (LPBYTE)pInBuf;
  664. if (pAASI->BitOffset) {
  665. --cIn;
  666. InData = (UINT)(*pIn++ & 0x0F);
  667. *pbIB++ = pColorTable[InData].a;
  668. }
  669. Idx = cIn >> 1;
  670. while (Idx--) {
  671. InData = (UINT)*pIn++;
  672. *(pbIB + 0) = pColorTable[InData >> 4].a;
  673. *(pbIB + 1) = pColorTable[InData & 0x0F].a;
  674. pbIB += 2;
  675. }
  676. if (cIn & 0x01) {
  677. InData = (UINT)(*pIn >> 4);
  678. *pbIB++ = pColorTable[InData].a;
  679. }
  680. } else {
  681. if (pAASI->BitOffset) {
  682. --cIn;
  683. InData = (UINT)(*pIn++ & 0x0F);
  684. *pInBuf++ = *(PBGR8)(pColorTable + InData);
  685. }
  686. Idx = cIn >> 1;
  687. while (Idx--) {
  688. InData = (UINT)*pIn++;
  689. *(pInBuf + 0) = *(PBGR8)(pColorTable + (InData >> 4));
  690. *(pInBuf + 1) = *(PBGR8)(pColorTable + (InData & 0x0F));
  691. pInBuf += 2;
  692. }
  693. if (cIn & 0x01) {
  694. InData = (UINT)(*pIn >> 4);
  695. *pInBuf++ = *(PBGR8)(pColorTable + InData);
  696. }
  697. }
  698. DBGP_IF(DBGP_INPUT,
  699. DBGP("cyIn=%5ld, pIn=%p-%p, cbIn=%5ld, Buf=%p-%p"
  700. ARGDW(pAASI->cy) ARGPTR(pAASI->pb)
  701. ARGPTR(pIn) ARGDW(pAASI->cbCX)
  702. ARGPTR(pRet) ARGPTR((LPBYTE)pRet + pAASI->cbCX)));
  703. SET_NEXT_PIN(pAASI);
  704. return(pRet);
  705. }
  706. PBGR8
  707. HTENTRY
  708. Input8BPPToAA24(
  709. PAASURFINFO pAASI,
  710. PBGR8 pInBuf
  711. )
  712. /*++
  713. Routine Description:
  714. Arguments:
  715. Return Value:
  716. Author:
  717. 15-Apr-1998 Wed 16:25:04 created -by- Daniel Chou (danielc)
  718. Revision History:
  719. --*/
  720. {
  721. #define pbIB ((LPBYTE)pInBuf)
  722. LPBYTE pIn;
  723. LPBYTE pInBufEnd;
  724. PBGR8 pRet;
  725. PRGB4B pColorTable;
  726. pIn = pAASI->pb;
  727. pRet = pInBuf;
  728. pColorTable = pAASI->pClrTable;
  729. pInBufEnd = (LPBYTE)pInBuf + pAASI->cbCX;
  730. if (pAASI->Flags & AASIF_GRAY) {
  731. ASSERT(pAASI->cbCX == pAASI->cx);
  732. do {
  733. *pbIB = pColorTable[*pIn++].a;
  734. } while (++pbIB < pInBufEnd);
  735. } else {
  736. ASSERT(pAASI->cbCX == (LONG)(pAASI->cx * sizeof(BGR8)));
  737. do {
  738. *pInBuf = *(PBGR8)(pColorTable + *pIn++);
  739. } while (++pInBuf < (PBGR8)pInBufEnd);
  740. }
  741. DBGP_IF(DBGP_INPUT,
  742. DBGP("cyIn=%5ld, pIn=%p-%p, cbIn=%5ld, Buf=%p-%p"
  743. ARGDW(pAASI->cy) ARGPTR(pAASI->pb)
  744. ARGPTR(pIn) ARGDW(pAASI->cbCX)
  745. ARGPTR(pRet) ARGPTR((LPBYTE)pRet + pAASI->cbCX)));
  746. SET_NEXT_PIN(pAASI);
  747. return(pRet);
  748. #undef pbIB
  749. }
  750. PBGR8
  751. HTENTRY
  752. InputPreMul32BPPToAA24(
  753. PAASURFINFO pAASI,
  754. PBGR8 pInBuf
  755. )
  756. /*++
  757. Routine Description:
  758. This function will read input from a 32-bit (red, green, blue, alpha
  759. 8 bits for each channel) type of source and reverse mapped the input
  760. alpha channel pre-multiply RGB byte data to its orginal value.
  761. This function only used if alpha blending is requested and its is a per
  762. pixel alpha blending with 32-bit source
  763. Arguments:
  764. Return Value:
  765. pointer to the pInBuf
  766. Author:
  767. 16-Aug-2000 Wed 11:07:15 updated -by- Daniel Chou (danielc)
  768. Revision History:
  769. --*/
  770. {
  771. #define pbIB ((LPBYTE)pInBuf)
  772. #define mR (AABFData.MaskRGB[0])
  773. #define mG (AABFData.MaskRGB[1])
  774. #define mB (AABFData.MaskRGB[2])
  775. LPBYTE pbIn;
  776. PBGR8 pRet;
  777. LPBYTE pInBufEnd;
  778. AABFDATA AABFData;
  779. DWORD Mul;
  780. BYTE bgr[3];
  781. pbIn = (LPBYTE)pAASI->pb;
  782. pRet = pInBuf;
  783. AABFData = pAASI->AABFData;
  784. pInBufEnd = pbIB + pAASI->cbCX;
  785. ASSERT(AABFData.Flags & AABF_MASK_IS_ORDER);
  786. ASSERT(dwABPreMul[0] == 0);
  787. //
  788. // If the pbIn[0], pbIn[1], pbIn[2] is greater than is alpha value in
  789. // pbIn[3] then it will be some wrong xlate, but at here we trust that
  790. // caller doing the right math for its RGB values
  791. //
  792. if (pAASI->Flags & AASIF_GRAY) {
  793. PLONG pIdxBGR;
  794. BGR8 bgr8;
  795. pIdxBGR = pAASI->pIdxBGR;
  796. ASSERT((LONG)pAASI->cbCX == (LONG)pAASI->cx);
  797. ASSERT(pIdxBGR);
  798. //
  799. // When we need to translate from a 32-bits RGB source to gray, the
  800. // pIdxBGR mapping table must already re-arranged to have
  801. //
  802. // pIdxBGR[ 0 - 255] for 1st byte source RGB order
  803. // pIdxBGR[256 - 511] for 2nd byte source RGB order
  804. // pIdxBGR[512 - 768] for 3rd byte source RGB order
  805. //
  806. do {
  807. Mul = (DWORD)dwABPreMul[pbIn[3]];
  808. *pbIB = IDXBGR_2_GRAY_BYTE(pIdxBGR,
  809. GET_PREMUL_SRC(pbIn[0], Mul),
  810. GET_PREMUL_SRC(pbIn[1], Mul),
  811. GET_PREMUL_SRC(pbIn[2], Mul));
  812. pbIn += 4;
  813. } while (++pbIB < pInBufEnd);
  814. } else {
  815. ASSERT(pAASI->cbCX == (LONG)(pAASI->cx * sizeof(BGR8)));
  816. if (AABFData.Flags & AABF_SRC_IS_BGR_ALPHA) {
  817. do {
  818. Mul = (DWORD)dwABPreMul[pbIn[3]];
  819. pInBuf->b = GET_PREMUL_SRC(pbIn[0], Mul);
  820. pInBuf->g = GET_PREMUL_SRC(pbIn[1], Mul);
  821. pInBuf->r = GET_PREMUL_SRC(pbIn[2], Mul);
  822. pbIn += 4;
  823. } while (++pInBuf < (PBGR8)pInBufEnd);
  824. } else if (AABFData.Flags & AABF_SRC_IS_RGB_ALPHA) {
  825. do {
  826. Mul = (DWORD)dwABPreMul[pbIn[3]];
  827. pInBuf->r = GET_PREMUL_SRC(pbIn[0], Mul);
  828. pInBuf->g = GET_PREMUL_SRC(pbIn[1], Mul);
  829. pInBuf->b = GET_PREMUL_SRC(pbIn[2], Mul);
  830. pbIn += 4;
  831. } while (++pInBuf < (PBGR8)pInBufEnd);
  832. } else {
  833. do {
  834. Mul = (DWORD)dwABPreMul[pbIn[3]];
  835. bgr[0] = pbIn[mB];
  836. bgr[1] = pbIn[mG];
  837. bgr[2] = pbIn[mR];
  838. pInBuf->b = GET_PREMUL_SRC(bgr[0], Mul);
  839. pInBuf->g = GET_PREMUL_SRC(bgr[1], Mul);
  840. pInBuf->r = GET_PREMUL_SRC(bgr[2], Mul);
  841. pbIn += 4;
  842. } while (++pInBuf < (PBGR8)pInBufEnd);
  843. }
  844. }
  845. SET_NEXT_PIN(pAASI);
  846. return(pRet);
  847. #undef mR
  848. #undef mG
  849. #undef mB
  850. #undef pbIB
  851. }
  852. PBGR8
  853. HTENTRY
  854. InputAABFDATAToAA24(
  855. PAASURFINFO pAASI,
  856. PBGR8 pInBuf
  857. )
  858. /*++
  859. Routine Description:
  860. This function read input from a 16/24/32 bits per pixel source, these
  861. source can be bit mask type of source (16/32 bits)
  862. Arguments:
  863. Return Value:
  864. Author:
  865. 12-Mar-1999 Fri 12:53:16 created -by- Daniel Chou (danielc)
  866. Revision History:
  867. --*/
  868. {
  869. #define pbIB ((LPBYTE)pInBuf)
  870. #define pwIn ((LPWORD)pbIn)
  871. #define pdwIn ((LPDWORD)pbIn)
  872. #define mR (AABFData.MaskRGB[0])
  873. #define mG (AABFData.MaskRGB[1])
  874. #define mB (AABFData.MaskRGB[2])
  875. #define lR (AABFData.LShiftRGB[0])
  876. #define lG (AABFData.LShiftRGB[1])
  877. #define lB (AABFData.LShiftRGB[2])
  878. #define rR (AABFData.RShiftRGB[0])
  879. #define rG (AABFData.RShiftRGB[1])
  880. #define rB (AABFData.RShiftRGB[2])
  881. #define GET_AABFDATA_BGR8(pbgr8, dwIn) \
  882. { \
  883. (pbgr8)->r = (BYTE)(((dwIn >> rR) << lR) & mR); \
  884. (pbgr8)->g = (BYTE)(((dwIn >> rG) << lG) & mG); \
  885. (pbgr8)->b = (BYTE)(((dwIn >> rB) << lB) & mB); \
  886. }
  887. LPBYTE pbIn;
  888. PBGR8 pRet;
  889. LPBYTE pInBufEnd;
  890. AABFDATA AABFData;
  891. DWORD dwIn;
  892. UINT cbSrcInc;
  893. pbIn = (LPBYTE)pAASI->pb;
  894. pRet = pInBuf;
  895. AABFData = pAASI->AABFData;
  896. cbSrcInc = (UINT)AABFData.cbSrcInc;
  897. pInBufEnd = (LPBYTE)pInBuf + pAASI->cbCX;
  898. if (pAASI->Flags & AASIF_GRAY) {
  899. PLONG pIdxBGR;
  900. BGR8 bgr8;
  901. ASSERT((LONG)pAASI->cbCX == (LONG)pAASI->cx);
  902. pIdxBGR = pAASI->pIdxBGR;
  903. pInBufEnd = pbIB + pAASI->cx;
  904. if (AABFData.Flags & AABF_MASK_IS_ORDER) {
  905. //
  906. // When we have AASIF_GRAY, the pIdxBGR must already re-arranged
  907. // to have
  908. //
  909. // pIdxBGR[ 0 - 255] for 1st byte source RGB order
  910. // pIdxBGR[256 - 511] for 2nd byte source RGB order
  911. // pIdxBGR[512 - 768] for 3rd byte source RGB order
  912. //
  913. do {
  914. *pbIB = IDXBGR_2_GRAY_BYTE(pIdxBGR, pbIn[0], pbIn[1], pbIn[2]);
  915. pbIn += cbSrcInc;
  916. } while (++pbIB < pInBufEnd);
  917. } else if (cbSrcInc == 4) {
  918. do {
  919. dwIn = (DWORD)*pdwIn++;
  920. GET_AABFDATA_BGR8(&bgr8, dwIn);
  921. *pbIB = IDXBGR_2_GRAY_BYTE(pIdxBGR, bgr8.b, bgr8.g, bgr8.r);
  922. } while (++pbIB < pInBufEnd);
  923. } else {
  924. ASSERT(cbSrcInc == 2);
  925. do {
  926. dwIn = (DWORD)*pwIn++;
  927. GET_AABFDATA_BGR8(&bgr8, dwIn);
  928. *pbIB = IDXBGR_2_GRAY_BYTE(pIdxBGR, bgr8.b, bgr8.g, bgr8.r);
  929. } while (++pbIB < pInBufEnd);
  930. }
  931. } else {
  932. ASSERT(pAASI->cbCX == (LONG)(pAASI->cx * sizeof(BGR8)));
  933. if (AABFData.Flags & AABF_MASK_IS_ORDER) {
  934. if (AABFData.Flags & AABF_SRC_IS_BGR8) {
  935. CopyMemory(pInBuf, pbIn, pAASI->cbCX);
  936. } else {
  937. do {
  938. pInBuf->r = pbIn[mR];
  939. pInBuf->g = pbIn[mG];
  940. pInBuf->b = pbIn[mB];
  941. pbIn += cbSrcInc;
  942. } while (++pInBuf < (PBGR8)pInBufEnd);
  943. }
  944. } else if (cbSrcInc == 4) {
  945. do {
  946. dwIn = (DWORD)*pdwIn++;
  947. GET_AABFDATA_BGR8(pInBuf, dwIn);
  948. } while (++pInBuf < (PBGR8)pInBufEnd);
  949. } else {
  950. ASSERT(cbSrcInc == 2);
  951. do {
  952. dwIn = (DWORD)*pwIn++;
  953. GET_AABFDATA_BGR8(pInBuf, dwIn);
  954. } while (++pInBuf < (PBGR8)pInBufEnd);
  955. }
  956. }
  957. SET_NEXT_PIN(pAASI);
  958. return(pRet);
  959. #undef mR
  960. #undef mG
  961. #undef mB
  962. #undef lR
  963. #undef lG
  964. #undef lB
  965. #undef rR
  966. #undef rG
  967. #undef rB
  968. #undef pwIn
  969. #undef pdwIn
  970. #undef pbIB
  971. }
  972. #if DBG
  973. LPSTR
  974. GetAAInputFuncName(
  975. AAINPUTFUNC AAInputFunc
  976. )
  977. /*++
  978. Routine Description:
  979. Arguments:
  980. Return Value:
  981. Author:
  982. 06-Jan-1999 Wed 19:11:27 created -by- Daniel Chou (danielc)
  983. Revision History:
  984. --*/
  985. {
  986. if (AAInputFunc == (AAINPUTFUNC)Input1BPPToAA24) {
  987. return("Input1BPPToAA24");
  988. } else if (AAInputFunc == (AAINPUTFUNC)Input4BPPToAA24) {
  989. return("Input4BPPToAA24");
  990. } else if (AAInputFunc == (AAINPUTFUNC)Input8BPPToAA24) {
  991. return("Input8BPPToAA24");
  992. } else if (AAInputFunc == (AAINPUTFUNC)InputPreMul32BPPToAA24) {
  993. return("InputPreMul32BPPToAA24");
  994. } else if (AAInputFunc == (AAINPUTFUNC)InputAABFDATAToAA24) {
  995. return("InputAABFDATAToAA24");
  996. } else {
  997. return("ERROR: Unknown Function");
  998. }
  999. }
  1000. #endif
  1001. PBGR8
  1002. HTENTRY
  1003. FixupGrayScan(
  1004. PAAHEADER pAAHdr,
  1005. PBGR8 pInBuf
  1006. )
  1007. /*++
  1008. Routine Description:
  1009. Arguments:
  1010. Return Value:
  1011. Author:
  1012. 13-Apr-1999 Tue 11:48:14 created -by- Daniel Chou (danielc)
  1013. Revision History:
  1014. 06-May-1999 Thu 13:07:49 updated -by- Daniel Chou (danielc)
  1015. The pInBuf can be NULL now
  1016. --*/
  1017. {
  1018. FIXUPDIBINFO FUDI;
  1019. LPBYTE pS0;
  1020. LPBYTE pS1;
  1021. LPBYTE pS2;
  1022. LPBYTE pS3;
  1023. LPBYTE pD1;
  1024. LPBYTE pD2;
  1025. UINT cIn;
  1026. UINT cbIn;
  1027. BYTE Mask;
  1028. cbIn =
  1029. cIn = (UINT)pAAHdr->SrcSurfInfo.cx;
  1030. FUDI = pAAHdr->FUDI;
  1031. if (pAAHdr->Flags & AAHF_GET_LAST_SCAN) {
  1032. pS0 = (LPBYTE)FUDI.prgbD[4];
  1033. pAAHdr->Flags &= ~AAHF_GET_LAST_SCAN;
  1034. DBGP_IF(DBGP_GETFIXUP,
  1035. DBGP("*** GetFixupScan: Re-Copy cyIn=%ld LAST SCANLINE ***"
  1036. ARGDW(FUDI.cyIn)));
  1037. ++FUDI.cyIn;
  1038. } else if (FUDI.cyIn <= 1) {
  1039. pS0 = (LPBYTE)FUDI.prgbD[5];
  1040. DBGP_IF(DBGP_GETFIXUP,
  1041. DBGP("*** GetFixupScan: cyIn=%ld, FINAL SCANLINE, cChecker=%ld, cCorner=%ld, Tot=%ld"
  1042. ARGDW(FUDI.cyIn)
  1043. ARGDW(pAAHdr->FUDI.cChecker)
  1044. ARGDW(pAAHdr->FUDI.cCorner)
  1045. ARGDW(pAAHdr->FUDI.cCorner + pAAHdr->FUDI.cChecker)));
  1046. } else {
  1047. DWORD g0;
  1048. DWORD g1;
  1049. LONG c0;
  1050. LONG c1;
  1051. LONG c2;
  1052. LONG c3;
  1053. LONG c0L;
  1054. LONG c0T;
  1055. LONG c1R;
  1056. LONG c1T;
  1057. LONG c2L;
  1058. LONG c2B;
  1059. LONG c3R;
  1060. LONG c3B;
  1061. //
  1062. // Scroll up the scan lines
  1063. //
  1064. pD2 = (LPBYTE)FUDI.prgbD[0];
  1065. CopyMemory(&FUDI.prgbD[0], &FUDI.prgbD[1], sizeof(FUDI.prgbD[0]) * 5);
  1066. FUDI.prgbD[5] = (PBGR8)pD2;
  1067. pS0 = (LPBYTE)FUDI.prgbD[0];
  1068. pS1 = (LPBYTE)FUDI.prgbD[1];
  1069. pS2 = (LPBYTE)FUDI.prgbD[2];
  1070. pS3 = (LPBYTE)FUDI.prgbD[3];
  1071. pD1 = (LPBYTE)FUDI.prgbD[4];
  1072. CopyMemory(pD2, pS2, FUDI.cbbgr);
  1073. //
  1074. // Save the next source scan line
  1075. //
  1076. if (pAAHdr->SrcSurfInfo.cy > 0) {
  1077. pAAHdr->SrcSurfInfo.InputFunc(&(pAAHdr->SrcSurfInfo),
  1078. (PBGR8)(pS3 + 1));
  1079. *(pS3 + 0) = *(pS3 + 2);
  1080. *(pS3 + cIn + 1) = *(pS3 + cIn - 1);
  1081. } else {
  1082. //
  1083. // No more scan lines, so copy the prev -2
  1084. //
  1085. CopyMemory(pS3, pS1, FUDI.cbbgr);
  1086. }
  1087. c0 = (LONG)*(pS1 + 0);
  1088. c2 = (LONG)*(pS2 + 0);
  1089. c1 = (LONG)*(pS1 + 1);
  1090. c3 = (LONG)*(pS2 + 1);
  1091. c1R = (LONG)*(pS1 + 2);
  1092. c3R = (LONG)*(pS2 + 2);
  1093. g1 = c1;
  1094. while (--cIn) {
  1095. c0L = c0;
  1096. c2L = c2;
  1097. c0 = c1;
  1098. c2 = c3;
  1099. c1 = c1R;
  1100. c3 = c3R;
  1101. c1R = (LONG)*(pS1 + 3);
  1102. c3R = (LONG)*(pS2 + 3);
  1103. g0 = g1;
  1104. g1 = c1;
  1105. if ((c0 != c1) && (!((c0 ^ c3) | (c1 ^ c2)))) {
  1106. c0T = (LONG)*(pS0 + 1);
  1107. c1T = (LONG)*(pS0 + 2);
  1108. c2B = (LONG)*(pS3 + 1);
  1109. c3B = (LONG)*(pS3 + 2);
  1110. if ((!((c0L ^ c1) | (c2L ^ c3) | (c1R ^ c0) | (c3R ^ c2))) ||
  1111. (!((c0T ^ c2) | (c1T ^ c3) | (c2B ^ c0) | (c3B ^ c1)))) {
  1112. *(pD1 + 1) =
  1113. *(pD1 + 2) =
  1114. *(pD2 + 1) =
  1115. *(pD2 + 2) = (BYTE)(((LONG)*(pS1 + 1) +
  1116. (LONG)*(pS1 + 2) + 1) >> 1);
  1117. SETDBGVAR(FUDI.cChecker, FUDI.cChecker + 1);
  1118. } else {
  1119. if (g0 >= g1) {
  1120. SET_CORNER_GRAY(pD1 + 1, c1, c1R, c2, c2B);
  1121. SET_CORNER_GRAY(pD2 + 2, c1, c1T, c2, c2L);
  1122. } else {
  1123. SET_CORNER_GRAY(pD1 + 2, c0, c0L, c3, c3B);
  1124. SET_CORNER_GRAY(pD2 + 1, c0, c0T, c3, c3R);
  1125. }
  1126. SETDBGVAR(FUDI.cCorner, FUDI.cCorner + 1);
  1127. }
  1128. }
  1129. ++pS0;
  1130. ++pS1;
  1131. ++pS2;
  1132. ++pS3;
  1133. ++pD1;
  1134. ++pD2;
  1135. }
  1136. pS0 = (LPBYTE)FUDI.prgbD[4];
  1137. DBGP_IF(DBGP_GETFIXUP,
  1138. DBGP("*** GetFixupScan: cyIn=%ld" ARGDW(FUDI.cyIn - 1)));
  1139. }
  1140. if (pInBuf) {
  1141. CopyMemory(pInBuf, pS0 + 1, cbIn);
  1142. }
  1143. --FUDI.cyIn;
  1144. pAAHdr->FUDI = FUDI;
  1145. return(pInBuf);
  1146. }
  1147. PBGR8
  1148. HTENTRY
  1149. FixupColorScan(
  1150. PAAHEADER pAAHdr,
  1151. PBGR8 pInBuf
  1152. )
  1153. /*++
  1154. Routine Description:
  1155. Arguments:
  1156. Return Value:
  1157. Author:
  1158. 13-Apr-1999 Tue 11:48:20 created -by- Daniel Chou (danielc)
  1159. Revision History:
  1160. 06-May-1999 Thu 13:07:49 updated -by- Daniel Chou (danielc)
  1161. The pInBuf can be NULL now
  1162. --*/
  1163. {
  1164. FIXUPDIBINFO FUDI;
  1165. PBGR8 pS0;
  1166. PBGR8 pS1;
  1167. PBGR8 pS2;
  1168. PBGR8 pS3;
  1169. PBGR8 pD1;
  1170. PBGR8 pD2;
  1171. UINT cIn;
  1172. UINT cbIn;
  1173. BYTE Mask;
  1174. cIn = (UINT)pAAHdr->SrcSurfInfo.cx;
  1175. cbIn = (UINT)pAAHdr->SrcSurfInfo.cbCX;
  1176. FUDI = pAAHdr->FUDI;
  1177. if (pAAHdr->Flags & AAHF_GET_LAST_SCAN) {
  1178. pS0 = FUDI.prgbD[4];
  1179. pAAHdr->Flags &= ~AAHF_GET_LAST_SCAN;
  1180. DBGP_IF(DBGP_GETFIXUP,
  1181. DBGP("*** GetFixupScan: Re-Copy cyIn=%ld LAST SCANLINE ***"
  1182. ARGDW(FUDI.cyIn)));
  1183. ++FUDI.cyIn;
  1184. } else if (FUDI.cyIn <= 1) {
  1185. pS0 = FUDI.prgbD[5];
  1186. DBGP_IF(DBGP_GETFIXUP,
  1187. DBGP("*** GetFixupScan: cyIn=%ld, FINAL SCANLINE, cChecker=%ld, cCorner=%ld, Tot=%ld"
  1188. ARGDW(FUDI.cyIn)
  1189. ARGDW(pAAHdr->FUDI.cChecker)
  1190. ARGDW(pAAHdr->FUDI.cCorner)
  1191. ARGDW(pAAHdr->FUDI.cCorner + pAAHdr->FUDI.cChecker)));
  1192. } else {
  1193. DWORD g0;
  1194. DWORD g1;
  1195. LONG c0;
  1196. LONG c1;
  1197. LONG c2;
  1198. LONG c3;
  1199. LONG c0L;
  1200. LONG c0T;
  1201. LONG c1R;
  1202. LONG c1T;
  1203. LONG c2L;
  1204. LONG c2B;
  1205. LONG c3R;
  1206. LONG c3B;
  1207. //
  1208. // Scroll up the scan lines
  1209. //
  1210. pD2 = FUDI.prgbD[0];
  1211. CopyMemory(&FUDI.prgbD[0], &FUDI.prgbD[1], sizeof(FUDI.prgbD[0]) * 5);
  1212. FUDI.prgbD[5] = pD2;
  1213. pS0 = FUDI.prgbD[0];
  1214. pS1 = FUDI.prgbD[1];
  1215. pS2 = FUDI.prgbD[2];
  1216. pS3 = FUDI.prgbD[3];
  1217. pD1 = FUDI.prgbD[4];
  1218. CopyMemory(pD2, pS2, FUDI.cbbgr);
  1219. //
  1220. // Save the next source scan line
  1221. //
  1222. if (pAAHdr->SrcSurfInfo.cy > 0) {
  1223. pAAHdr->SrcSurfInfo.InputFunc(&(pAAHdr->SrcSurfInfo), pS3 + 1);
  1224. *(pS3 + 0) = *(pS3 + 2);
  1225. *(pS3 + cIn + 1) = *(pS3 + cIn - 1);
  1226. } else {
  1227. //
  1228. // No more scan lines, so copy the prev -2
  1229. //
  1230. CopyMemory(pS3, pS1, FUDI.cbbgr);
  1231. }
  1232. c0 = GET_LBGR(pS1 + 0);
  1233. c2 = GET_LBGR(pS2 + 0);
  1234. c1 = GET_LBGR(pS1 + 1);
  1235. c3 = GET_LBGR(pS2 + 1);
  1236. c1R = GET_LBGR(pS1 + 2);
  1237. c3R = GET_LBGR(pS2 + 2);
  1238. g1 = GET_GRAY_RGB(pS1 + 1);
  1239. while (--cIn) {
  1240. c0L = c0;
  1241. c2L = c2;
  1242. c0 = c1;
  1243. c2 = c3;
  1244. c1 = c1R;
  1245. c3 = c3R;
  1246. c1R = GET_LBGR(pS1 + 3);
  1247. c3R = GET_LBGR(pS2 + 3);
  1248. g0 = g1;
  1249. g1 = GET_GRAY_RGB(pS1 + 2);
  1250. if ((c0 != c1) && (!((c0 ^ c3) | (c1 ^ c2)))) {
  1251. c0T = GET_LBGR(pS0 + 1);
  1252. c1T = GET_LBGR(pS0 + 2);
  1253. c2B = GET_LBGR(pS3 + 1);
  1254. c3B = GET_LBGR(pS3 + 2);
  1255. if ((!((c0L ^ c1) | (c2L ^ c3) | (c1R ^ c0) | (c3R ^ c2))) ||
  1256. (!((c0T ^ c2) | (c1T ^ c3) | (c2B ^ c0) | (c3B ^ c1)))) {
  1257. (pD1 + 1)->r =
  1258. (pD1 + 2)->r =
  1259. (pD2 + 1)->r =
  1260. (pD2 + 2)->r = (BYTE)(((LONG)(pS1 + 1)->r +
  1261. (LONG)(pS1 + 2)->r + 1) >> 1);
  1262. (pD1 + 1)->g =
  1263. (pD1 + 2)->g =
  1264. (pD2 + 1)->g =
  1265. (pD2 + 2)->g = (BYTE)(((LONG)(pS1 + 1)->g +
  1266. (LONG)(pS1 + 2)->g + 1) >> 1);
  1267. (pD1 + 1)->b =
  1268. (pD1 + 2)->b =
  1269. (pD2 + 1)->b =
  1270. (pD2 + 2)->b = (BYTE)(((LONG)(pS1 + 1)->b +
  1271. (LONG)(pS1 + 2)->b + 1) >> 1);
  1272. SETDBGVAR(FUDI.cChecker, FUDI.cChecker + 1);
  1273. } else {
  1274. if (g0 >= g1) {
  1275. SET_CORNER_BGR(pD1 + 1, c1, c1R, c2, c2B);
  1276. SET_CORNER_BGR(pD2 + 2, c1, c1T, c2, c2L);
  1277. } else {
  1278. SET_CORNER_BGR(pD1 + 2, c0, c0L, c3, c3B);
  1279. SET_CORNER_BGR(pD2 + 1, c0, c0T, c3, c3R);
  1280. }
  1281. SETDBGVAR(FUDI.cCorner, FUDI.cCorner + 1);
  1282. }
  1283. }
  1284. ++pS0;
  1285. ++pS1;
  1286. ++pS2;
  1287. ++pS3;
  1288. ++pD1;
  1289. ++pD2;
  1290. }
  1291. pS0 = FUDI.prgbD[4];
  1292. DBGP_IF(DBGP_GETFIXUP,
  1293. DBGP("*** GetFixupScan: cyIn=%ld" ARGDW(FUDI.cyIn - 1)));
  1294. }
  1295. if (pInBuf) {
  1296. CopyMemory(pInBuf, pS0 + 1, cbIn);
  1297. }
  1298. --FUDI.cyIn;
  1299. pAAHdr->FUDI = FUDI;
  1300. return(pInBuf);
  1301. }
  1302. PBGR8
  1303. HTENTRY
  1304. GetFixupScan(
  1305. PAAHEADER pAAHdr,
  1306. PBGR8 pInBuf
  1307. )
  1308. /*++
  1309. Routine Description:
  1310. Arguments:
  1311. Return Value:
  1312. Author:
  1313. 17-Oct-1998 Sat 15:25:57 created -by- Daniel Chou (danielc)
  1314. Revision History:
  1315. 06-May-1999 Thu 13:07:49 updated -by- Daniel Chou (danielc)
  1316. The pInBuf can be NULL now
  1317. --*/
  1318. {
  1319. DWORD AAHFlags;
  1320. DBG_TIMER_BEG(TIMER_INPUT);
  1321. if (!((AAHFlags = pAAHdr->Flags) & AAHF_DO_FIXUPDIB)) {
  1322. if (AAHFlags & AAHF_GET_LAST_SCAN) {
  1323. if (++pAAHdr->SrcSurfInfo.cy > pAAHdr->SrcSurfInfo.cyOrg) {
  1324. DBGP("Error: GET_LAST_SCAN on first scan line %ld (%ld)"
  1325. ARGDW(pAAHdr->SrcSurfInfo.cy)
  1326. ARGDW(pAAHdr->SrcSurfInfo.cyOrg));
  1327. pAAHdr->SrcSurfInfo.cy = pAAHdr->SrcSurfInfo.cyOrg;
  1328. }
  1329. pAAHdr->SrcSurfInfo.pb = pAAHdr->SrcSurfInfo.pbOrg +
  1330. ((pAAHdr->SrcSurfInfo.cyOrg -
  1331. pAAHdr->SrcSurfInfo.cy) *
  1332. pAAHdr->SrcSurfInfo.cyNext);
  1333. pAAHdr->SrcSurfInfo.Flags |= AASIF_INC_PB;
  1334. pAAHdr->Flags &= ~AAHF_GET_LAST_SCAN;
  1335. }
  1336. if (pInBuf) {
  1337. pAAHdr->SrcSurfInfo.InputFunc(&(pAAHdr->SrcSurfInfo), pInBuf);
  1338. } else {
  1339. SET_NEXT_PIN((&(pAAHdr->SrcSurfInfo)));
  1340. }
  1341. } else if (pAAHdr->SrcSurfInfo.Flags & AASIF_GRAY) {
  1342. FixupGrayScan(pAAHdr, pInBuf);
  1343. } else {
  1344. FixupColorScan(pAAHdr, pInBuf);
  1345. }
  1346. if ((pAAHdr->Flags & AAHF_DO_SRC_CLR_MAPPING) && (pInBuf)) {
  1347. MappingBGR(pInBuf,
  1348. pAAHdr->SrcSurfInfo.cx,
  1349. (PBGR8)pAAHdr->pBGRMapTable,
  1350. (LPBYTE)pAAHdr->AAPI.pbPat555);
  1351. if ((pAAHdr->AAPI.pbPat555 += pAAHdr->AAPI.cyNext555) ==
  1352. pAAHdr->AAPI.pbWrap555) {
  1353. pAAHdr->AAPI.pbPat555 = pAAHdr->AAPI.pbBeg555;
  1354. }
  1355. }
  1356. DBG_TIMER_END(TIMER_INPUT);
  1357. return(pInBuf);
  1358. }
  1359. BOOL
  1360. HTENTRY
  1361. CheckBMPNeedFixup(
  1362. PDEVICECOLORINFO pDCI,
  1363. PAAHEADER pAAHdr,
  1364. PHTSURFACEINFO pSrcSI,
  1365. PAABBP pAABBP
  1366. )
  1367. /*++
  1368. Routine Description:
  1369. This function check the bitmap to see if we need to do a fixup, if yes
  1370. then it allocated memory accordingly
  1371. Arguments:
  1372. Return Value:
  1373. Author:
  1374. 07-Dec-1998 Mon 18:25:45 created -by- Daniel Chou (danielc)
  1375. Revision History:
  1376. 15-Aug-2000 Tue 19:05:25 updated -by- Daniel Chou (danielc)
  1377. At pre-read checking, we HAVE TO turn off the the gray conversion
  1378. and Alpha Blending pre-multiply conversion.
  1379. --*/
  1380. {
  1381. LPBYTE pbAlloc = NULL;
  1382. LPBYTE pInEnd;
  1383. LPDWORD pdwBegPal;
  1384. LPDWORD pdwEndPal;
  1385. LPDWORD pdw;
  1386. AASURFINFO SrcSurfInfo;
  1387. RECTL rclSrc;
  1388. UINT SrcFmt;
  1389. LONG cIn;
  1390. LONG cbIn;
  1391. LONG cPalChk;
  1392. LONG cPalTot;
  1393. LONG cyIn;
  1394. LONG cySkip;
  1395. LONG cy;
  1396. DW2W4B dw4b;
  1397. DWORD AAHFlags;
  1398. BOOL NewPal;
  1399. DEFDBGVAR(LONG, iY)
  1400. SrcFmt = (UINT)pSrcSI->SurfaceFormat;
  1401. if (!((AAHFlags = pAABBP->AAHFlags) & AAHF_DO_FIXUPDIB)) {
  1402. DBGP_IF(DBGP_FUDI | DBGP_CHK_FUDI,
  1403. DBGP("CheckBMPNeedFixup(%ld)=No" ARGDW(SrcFmt)));
  1404. return(FALSE);
  1405. }
  1406. switch (SrcFmt) {
  1407. case BMF_1BPP:
  1408. case BMF_4BPP:
  1409. case BMF_4BPP_VGA16:
  1410. pAABBP->AAHFlags |= (AAHF_DO_FIXUPDIB | AAHF_BBPF_AA_OFF);
  1411. DBGP_IF(DBGP_FUDI | DBGP_CHK_FUDI,
  1412. DBGP("CheckBMPNeedFixup(%ld)=1BPP/4BPPNo, Check DIB and AA=OFF" ARGDW(SrcFmt)));
  1413. return(TRUE);
  1414. break;
  1415. case BMF_8BPP:
  1416. case BMF_8BPP_VGA256:
  1417. case BMF_16BPP:
  1418. case BMF_16BPP_555:
  1419. case BMF_16BPP_565:
  1420. case BMF_24BPP:
  1421. case BMF_32BPP:
  1422. rclSrc.left =
  1423. rclSrc.top = 0;
  1424. rclSrc.right = pSrcSI->Width;
  1425. rclSrc.bottom = pSrcSI->Height;
  1426. if (!IntersectRECTL(&rclSrc, &pAABBP->rclSrc)) {
  1427. return(FALSE);
  1428. }
  1429. //
  1430. // 15-Aug-2000 Tue 19:05:25 updated -by- Daniel Chou (danielc)
  1431. // At pre-read checking, we HAVE TO turn off the the gray conversion
  1432. // and Alpha Blending pre-multiply conversion.
  1433. //
  1434. SrcSurfInfo = pAAHdr->SrcSurfInfo;
  1435. SrcSurfInfo.Flags &= ~(AASIF_GRAY | AASIF_AB_PREMUL_SRC);
  1436. SrcSurfInfo.cyNext =
  1437. cIn = GET_PHTSI_CXSIZE(pSrcSI);
  1438. cyIn =
  1439. SrcSurfInfo.cy = rclSrc.bottom - rclSrc.top;
  1440. SrcSurfInfo.pb = pSrcSI->pPlane +
  1441. (rclSrc.top * cIn) +
  1442. ComputeByteOffset(SrcFmt,
  1443. rclSrc.left,
  1444. &(SrcSurfInfo.BitOffset));
  1445. SrcSurfInfo.cx =
  1446. cIn = rclSrc.right - rclSrc.left;
  1447. SrcSurfInfo.cbCX = cIn * sizeof(BGR8);
  1448. cySkip = 1;
  1449. ALIGN_MEM(cbIn, (cIn + 2) * sizeof(BGR8));
  1450. if ((cPalTot = cyIn * cIn) <= MIN_FIXUP_SIZE) {
  1451. DBGP_IF(DBGP_FUDI,
  1452. DBGP("cyIn=%ld x cIn==%ld = %ld (<= MIN_FIXUP_SIZE=%ld, Turn off AA"
  1453. ARGDW(cyIn) ARGDW(cIn) ARGDW(cPalTot)
  1454. ARGDW(MIN_FIXUP_SIZE)));
  1455. AAHFlags |= AAHF_BBPF_AA_OFF;
  1456. break;
  1457. } else if (cPalTot <= MIN_PAL_SIZE) {
  1458. DBGP_IF(DBGP_FUDI,
  1459. DBGP("cPalTot=%ld <= MIN_PAL_SIZE=%ld, cPalChk: %ld -> %ld"
  1460. ARGDW(cPalTot) ARGDW(MIN_PAL_SIZE)
  1461. ARGDW(cPalTot) ARGDW(GET_PAL_CHK_COUNT(cPalTot))));
  1462. cPalChk = GET_PAL_CHK_COUNT(cPalTot);
  1463. } else {
  1464. SrcSurfInfo.cy = (cyIn + STD_PAL_CY_SKIP - 1) / STD_PAL_CY_SKIP;
  1465. SrcSurfInfo.cyNext *= (cySkip = STD_PAL_CY_SKIP);
  1466. cPalChk = MAX_FIXUPDIB_PAL;
  1467. DBGP_IF(DBGP_FUDI,
  1468. DBGP("REGULAR BITMAP, cySkip=%ld, cy=%ld -> %ld, cPalChk=%ld (MAX_FIXUPDIB_PAL)"
  1469. ARGDW(cySkip) ARGDW(cyIn) ARGDW(SrcSurfInfo.cy)
  1470. ARGDW(cPalChk) ARGDW(MAX_FIXUPDIB_PAL)));
  1471. }
  1472. if (!(pbAlloc = (LPBYTE)HTAllocMem((LPVOID)pDCI,
  1473. HTMEM_FIXUPDIB,
  1474. LPTR,
  1475. cbIn + ((cPalChk + 1) *
  1476. sizeof(DWORD))))) {
  1477. DBGP("Error: Cannot Allocate FixupDIB memory=%ld bytes, Turn of FIXUP"
  1478. ARGDW(cbIn + ((cPalChk + 1) * sizeof(DWORD))));
  1479. pAABBP->AAHFlags = (AAHFlags & ~AAHF_DO_FIXUPDIB);
  1480. return(FALSE);
  1481. }
  1482. pdwEndPal =
  1483. pdwBegPal = (LPDWORD)(pbAlloc + cbIn);
  1484. pInEnd = (LPBYTE)pbAlloc + (cIn * sizeof(BGR8));
  1485. cPalTot = 0;
  1486. SETDBGVAR(iY, 0);
  1487. DBGP_IF(DBGP_FUDI,
  1488. DBGP("SrcInputFunc=%p, cySkip=%ld, pIn=%p, Fmt=%ld (%ld x %ld), cPalChk=%ld"
  1489. ARGPTR(SrcSurfInfo.InputFunc) ARGDW(cySkip)
  1490. ARGPTR(SrcSurfInfo.pb) ARGDW(SrcFmt)
  1491. ARGDW(cIn) ARGDW(cyIn) ARGDW(cPalChk)));
  1492. cbIn = (cyIn * cIn);
  1493. dw4b.dw = 0;
  1494. do {
  1495. PBGR8 pbgr;
  1496. //
  1497. // Try to read some lines and determine if this is a non primary
  1498. // color bitmap, we only fixed up the bitmap if any of RGB is
  1499. // 0x00, 0x40, 0x80, 0xc0, 0xFF
  1500. //
  1501. NewPal = FALSE;
  1502. pbgr = SrcSurfInfo.InputFunc(&SrcSurfInfo, (PBGR8)pbAlloc);
  1503. do {
  1504. //
  1505. // The first entry is the sentinal, so it always stop there
  1506. //
  1507. dw4b.b[0] = pbgr->g;
  1508. if ((dw4b.b[1] = pbgr->r) ==
  1509. (dw4b.b[2] = pbgr->b)) {
  1510. //
  1511. // This is a gray scale data, make it collapse by 4,
  1512. // the 0, 1, 2, 3 = 0, 4, 5, 6, 7 = 4,...., 252, 253,
  1513. // 254, 255 = 252
  1514. //
  1515. dw4b.dw &= 0xFCFCFCFC;
  1516. }
  1517. *pdwBegPal = dw4b.dw;
  1518. pdw = pdwEndPal;
  1519. while (*pdw != dw4b.dw) {
  1520. --pdw;
  1521. }
  1522. if (pdw == pdwBegPal) {
  1523. //
  1524. // We have new palette entry
  1525. //
  1526. if (++cPalTot > cPalChk) {
  1527. break;
  1528. }
  1529. *(++pdwEndPal) = dw4b.dw;
  1530. NewPal = TRUE;
  1531. }
  1532. } while (++pbgr < (PBGR8)pInEnd);
  1533. DBGP_IF(DBGP_FUDI,
  1534. DBGP("IsBmpNeedFixup(%4ld/%4ld) [%4ld/%4ld]: cPalTot=%4ld, cPalChk=%4ld"
  1535. ARGDW(iY) ARGDW(SrcSurfInfo.cy)
  1536. ARGDW((iY * cySkip) + 1)
  1537. ARGDW(cyIn) ARGDW(cPalTot) ARGDW(cPalChk)));
  1538. SETDBGVAR(iY, iY + 1);
  1539. if ((cPalChk != MAX_FIXUPDIB_PAL) && (!NewPal)) {
  1540. DBGP_IF(DBGP_FUDI,
  1541. DBGP("Same Scanline Pal (%4ld / %4ld), cPalChk=%ld (%ld)"
  1542. ARGDW(iY) ARGDW(SrcSurfInfo.cy)
  1543. ARGDW(cPalChk) ARGDW(MAX_FIXUPDIB_PAL)));
  1544. //
  1545. // Scan line is same, so reduced the cPalChk for SMALL BMP
  1546. //
  1547. if ((cbIn -= cIn) <= MIN_FIXUP_SIZE) {
  1548. DBGP_IF(DBGP_FUDI | DBGP_CHK_FUDI,
  1549. DBGP("cx*cy=%ld <= MIN_FIXUP_SIZE=%ld, Turn off AA"
  1550. ARGDW(cbIn) ARGDW(MIN_FIXUP_SIZE)));
  1551. AAHFlags |= AAHF_BBPF_AA_OFF;
  1552. break;
  1553. }
  1554. cPalChk = GET_PAL_CHK_COUNT2(cbIn);
  1555. }
  1556. } while ((cPalTot <= cPalChk) && (SrcSurfInfo.cy));
  1557. DBGP_IF(DBGP_CHK_FUDI,
  1558. DBGP("IsBmpNeedFixup(): cPalChk=%ld, cy=%ld, cPalTot=%ld"
  1559. ARGDW(cPalChk) ARGDW((iY * cySkip) + 1)
  1560. ARGDW(cPalTot)));
  1561. if (cPalTot < MAX_FIXUPDIB_PAL) {
  1562. DBGP_IF(DBGP_FUDI | DBGP_CHK_FUDI,
  1563. DBGP("cPalTot=%ld < MAX_FIXUPDIB_PAL (%ld) Turn off AA"
  1564. ARGDW(cPalTot) ARGDW(MAX_FIXUPDIB_PAL)));
  1565. AAHFlags |= AAHF_BBPF_AA_OFF;
  1566. }
  1567. if (cPalChk == MAX_FIXUPDIB_PAL) {
  1568. //
  1569. // We are checking regular size bitmap, turn OFF FIXUPDIB if
  1570. // cPalTot > cPalChk
  1571. //
  1572. if (cPalTot > cPalChk) {
  1573. AAHFlags &= ~AAHF_DO_FIXUPDIB;
  1574. }
  1575. DBGP_IF(DBGP_FUDI | DBGP_CHK_FUDI,
  1576. DBGP("Checking REGULAR BITMAP: cPalTot=%ld, cPalChk=%ld, DO_FIXUP=%hs"
  1577. ARGDW(cPalTot) ARGDW(cPalChk)
  1578. ARGPTR((AAHFlags & AAHF_DO_FIXUPDIB) ? "Yes" : "No")));
  1579. } else {
  1580. //
  1581. // We are checking bitmap size <= MIN_PAL_SIZE (smaller size)
  1582. // the FIXUPDIB will be turn ON if (cPalTot <= MAX_FIXUPDIB_PAL) ||
  1583. // (cPalTot > cPalChk)
  1584. //
  1585. if ((cPalTot > MAX_FIXUPDIB_PAL) ||
  1586. (cPalTot <= cPalChk)) {
  1587. AAHFlags &= ~AAHF_DO_FIXUPDIB;
  1588. }
  1589. DBGP_IF(DBGP_FUDI | DBGP_CHK_FUDI,
  1590. DBGP("Checking SMALL BITMAP: Min=%ld, cPalTot=%ld, cPalChk=%ld, DO_FIXUP=%hs"
  1591. ARGDW(MAX_FIXUPDIB_PAL) ARGDW(cPalTot) ARGDW(cPalChk)
  1592. ARGPTR((AAHFlags & AAHF_DO_FIXUPDIB) ? "Yes" : "No")));
  1593. }
  1594. }
  1595. if (pbAlloc) {
  1596. HTFreeMem(pbAlloc);
  1597. }
  1598. pAABBP->AAHFlags = AAHFlags;
  1599. DBGP_IF(DBGP_FUDI | DBGP_CHK_FUDI,
  1600. DBGP("CheckBMPNeedFixup(%ld): DoFixup=%hs, AA=%hs"
  1601. ARGDW(SrcFmt)
  1602. ARGPTR((AAHFlags & AAHF_DO_FIXUPDIB) ? "Yes" : "No")
  1603. ARGPTR((AAHFlags & AAHF_BBPF_AA_OFF) ? "Off" : "On")));
  1604. return((BOOL)(AAHFlags & AAHF_DO_FIXUPDIB));
  1605. }
  1606. VOID
  1607. HTENTRY
  1608. InitializeFUDI(
  1609. PAAHEADER pAAHdr
  1610. )
  1611. /*++
  1612. Routine Description:
  1613. Arguments:
  1614. Return Value:
  1615. Author:
  1616. 16-Dec-1998 Wed 17:30:34 created -by- Daniel Chou (danielc)
  1617. Revision History:
  1618. --*/
  1619. {
  1620. PBGR8 pbgr;
  1621. LPBYTE pb;
  1622. UINT cIn;
  1623. UINT i;
  1624. pAAHdr->FUDI.cyIn = (pAAHdr->Flags & AAHF_TILE_SRC) ?
  1625. pAAHdr->DstSurfInfo.cy :
  1626. pAAHdr->SrcSurfInfo.cy;
  1627. cIn = pAAHdr->SrcSurfInfo.cx;
  1628. if (pAAHdr->SrcSurfInfo.Flags & AASIF_GRAY) {
  1629. for (i = 2; i <= 3; i++) {
  1630. pb = (LPBYTE)pAAHdr->FUDI.prgbD[i];
  1631. pAAHdr->SrcSurfInfo.InputFunc(&(pAAHdr->SrcSurfInfo),
  1632. (PBGR8)(pb + 1));
  1633. *(pb + 0) = *(pb + 2);
  1634. *(pb + cIn + 1) = *(pb + cIn - 1);
  1635. }
  1636. } else {
  1637. for (i = 2; i <= 3; i++) {
  1638. pbgr = pAAHdr->FUDI.prgbD[i];
  1639. pAAHdr->SrcSurfInfo.InputFunc(&(pAAHdr->SrcSurfInfo), pbgr + 1);
  1640. *(pbgr + 0) = *(pbgr + 2);
  1641. *(pbgr + cIn + 1) = *(pbgr + cIn - 1);
  1642. }
  1643. }
  1644. //
  1645. // Save this one in case we need to copy first scan line
  1646. //
  1647. CopyMemory(pAAHdr->FUDI.prgbD[5],
  1648. pAAHdr->FUDI.prgbD[2],
  1649. pAAHdr->FUDI.cbbgr);
  1650. CopyMemory(pAAHdr->FUDI.prgbD[1],
  1651. pAAHdr->FUDI.prgbD[3],
  1652. pAAHdr->FUDI.cbbgr);
  1653. }