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.

1005 lines
31 KiB

  1. #include "precomp.hxx"
  2. extern "C"
  3. {
  4. #include <dpf.h>
  5. }
  6. #if 0
  7. // This slightly faster bitblt code does it the hard way. I'm not
  8. // entirely sure about the going backwards and up case, but I'm
  9. // confident otherwise. We decided not to turn this on since it is a
  10. // small performance gain in an obscure case and didn't justify the
  11. // risk we would introduce at this late date. The origional, slower
  12. // implementation is below. -mdm 04/18/96
  13. void Blt24Pto24P_NoBlend_NoTrans_Hcopy_SRCCOPY_NoVcopy(
  14. BYTE* pbSrcScanLine,
  15. int iSrcScanStride,
  16. int iNumSrcRows,
  17. BYTE* pbDstScanLine,
  18. int iDstScanStride,
  19. int iNumDstCols,
  20. int iNumDstRows)
  21. {
  22. DWORD *pdSrcData, *pdDstData,*pdEndOfData;
  23. int iVertError=0,iVertAdvanceError,iSrcScanAdvance;
  24. int iAlign, iAlignSrc, iAlignDst,iAlignDstEnd;
  25. int iLeftSrcShift,iRightSrcShift;
  26. DWORD dLeftDstMask, dLeftSrcMask, dAlignMask,dRightDstMask;
  27. // compute advance and error terms for stepping
  28. // vertically through the src bitmap
  29. if (iNumSrcRows < iNumDstRows)
  30. {
  31. iSrcScanAdvance = 0;
  32. iVertAdvanceError = iNumSrcRows;
  33. }
  34. else
  35. {
  36. iSrcScanAdvance = iSrcScanStride * (iNumSrcRows / iNumDstRows);
  37. iVertAdvanceError = iNumSrcRows % iNumDstRows;
  38. }
  39. // Calculate relative alignment ofthe data. We'll have to shift
  40. // the data to the right by (dst-src) bits to do DWORD-aligned
  41. // stores. In the general unaligned case, we'll be using data
  42. // from 2 src dwords to fill in the data for the dst.
  43. iAlignSrc = (((DWORD)pbSrcScanLine) & 0x03) * 8;
  44. iAlignDst = (((DWORD)pbDstScanLine) & 0x03) * 8;
  45. iAlignDstEnd = ((((DWORD)pbDstScanLine) + iNumDstCols * 3) & 0x03) * 8;
  46. iAlign = iAlignDst - iAlignSrc;
  47. // Calculate the masks in advance. Yes, this gives me a headache,
  48. // too. The idea is that we're going to break up the blt into a
  49. // left column, a center part, and a right column. Since the left
  50. // and right columns will have DWORDS with data we won't be
  51. // touching, we'll need some masks to make sure we keep the data.
  52. dLeftDstMask = ((1 << (32 - iAlignDst)) - 1) << iAlignDst; // mask of bits we'll be replacing in leftmost dst dword
  53. dLeftSrcMask = ((1 << (32 - iAlignSrc)) - 1) << iAlignSrc; // mask of bits we'll be using form the leftmost src dword.
  54. if(iAlign < 0)
  55. {
  56. dAlignMask = ((1 << (-iAlign)) - 1); // mask of bits we'll be using from the second src dword
  57. }
  58. else
  59. {
  60. dAlignMask = (1 << (32 - iAlign)) - 1; // mask of bits we'll be using from the second src dword
  61. }
  62. dRightDstMask = (1 << iAlignDstEnd) - 1; // mask of bits we'll be replacing in the rightmost dst dword
  63. // calculate shift necessary to properly align data
  64. if(iAlign > 0)
  65. {
  66. pdSrcData--; // back up because we want our data in the right src dword (for consistency)
  67. iLeftSrcShift = 32 - iAlign;
  68. iRightSrcShift = iAlign;
  69. }
  70. else if(iAlign < 0)
  71. {
  72. iLeftSrcShift = -iAlign;
  73. iRightSrcShift = 32 - (-iAlign);
  74. }
  75. else // iAlign == 0
  76. {
  77. iLeftSrcShift = 0;
  78. iRightSrcShift = 31;
  79. }
  80. // NOTE WATCH OUT FOR CASES WHERE WE ARE ACTUALLY GOING FROM RIGHT TO LEFT. NOT HANDLED YET!
  81. for (int i = 0; i < iNumDstRows; i++)
  82. {
  83. // set up pointers to the first DWORDS on src and dst
  84. // scanlines, and last DWORD on dst scanline
  85. pdSrcData = (DWORD*)(((DWORD)pbSrcScanLine) & ~0x03);
  86. pdDstData = (DWORD*)(((DWORD)pbDstScanLine) & ~0x03);
  87. pdEndOfData = (DWORD*)(((DWORD)pbDstScanLine + iNumDstCols * 3) & ~0x03);
  88. // Do the left column
  89. if(iAlignSrc || iAlignDst)
  90. {
  91. if(iAlign)
  92. {
  93. *pdDstData = ( (*pdDstData & ~dLeftDstMask) | // old data
  94. (((pdSrcData[0] & dLeftSrcMask) >> iLeftSrcShift) | // data from first src dword
  95. (((pdSrcData[1] & dAlignMask) << iRightSrcShift )) & dLeftDstMask) );
  96. }
  97. else // iAlign == 0
  98. {
  99. // No shift needed here, just watch out for the old data
  100. *pdDstData = (*pdDstData & ~dLeftDstMask) | (*pdSrcData & dLeftSrcMask);
  101. }
  102. pdSrcData++;
  103. pdDstData++;
  104. }
  105. // Now do the center section
  106. if(iAlign)
  107. {
  108. while(pdDstData < pdEndOfData)
  109. {
  110. *pdDstData = (((pdSrcData[0] & ~dAlignMask) >> iLeftSrcShift) | // data from first src dword
  111. ((pdSrcData[1] & dAlignMask) << iRightSrcShift));
  112. pdSrcData++;
  113. pdDstData++;
  114. }
  115. }
  116. else // iAlign == 0
  117. {
  118. while(pdDstData < pdEndOfData)
  119. {
  120. *pdDstData++ = *pdSrcData++;
  121. }
  122. }
  123. // Do the right column
  124. if(dRightDstMask)
  125. {
  126. if(iAlign)
  127. {
  128. *pdDstData = ( (*pdDstData & ~dRightDstMask) | // old data
  129. ( (((pdSrcData[0] & ~dAlignMask) >> iLeftSrcShift) | // data from first src dword
  130. ((pdSrcData[1] & dAlignMask) << iRightSrcShift)) & dRightDstMask) );
  131. }
  132. else // iAlign == 0
  133. {
  134. *pdDstData =(*pdDstData & ~dRightDstMask) | (*pdSrcData & dRightDstMask);
  135. }
  136. }
  137. // advance to next scanline
  138. pbSrcScanLine += iSrcScanAdvance;
  139. pbDstScanLine += iDstScanStride;
  140. // update and check vertical stepping error,
  141. // adjust src scanline pointer if necessary
  142. iVertError += iVertAdvanceError;
  143. if (iVertError >= iNumDstRows)
  144. {
  145. pbSrcScanLine += iSrcScanStride;
  146. iVertError -= iNumDstRows;
  147. }
  148. }
  149. }
  150. #endif // 0
  151. void Blt24Pto24P_NoBlend_NoTrans_Hcopy_SRCCOPY_NoVcopy(
  152. BYTE* pbSrcScanLine,
  153. int iSrcScanStride,
  154. int iNumSrcRows,
  155. BYTE* pbDstScanLine,
  156. int iDstScanStride,
  157. int iNumDstCols,
  158. int iNumDstRows)
  159. {
  160. RGBTRIPLE *ptSrcPixel,
  161. *ptDstPixel,
  162. *ptEndDstPixel;
  163. int iVertError = 0,
  164. iVertAdvanceError,
  165. iSrcScanAdvance;
  166. // compute advance and error terms for stepping
  167. // vertically through the src bitmap
  168. if (iNumSrcRows < iNumDstRows) {
  169. iSrcScanAdvance = 0;
  170. iVertAdvanceError = iNumSrcRows;
  171. } else {
  172. iSrcScanAdvance = iSrcScanStride * (iNumSrcRows / iNumDstRows);
  173. iVertAdvanceError = iNumSrcRows % iNumDstRows;
  174. }
  175. for (int i = 0; i < iNumDstRows; i++) {
  176. // set up pointers to the first pixels
  177. // on src and dst scanlines, and next
  178. // pixel after last on dst scanline
  179. ptSrcPixel = (RGBTRIPLE *)pbSrcScanLine;
  180. ptDstPixel = (RGBTRIPLE *)pbDstScanLine;
  181. ptEndDstPixel = ptDstPixel + iNumDstCols;
  182. // copy scanline one pixel at a time
  183. while (ptDstPixel != ptEndDstPixel)
  184. {
  185. ((BYTE*)ptDstPixel)[0] = ((BYTE*)ptSrcPixel)[0];
  186. ((BYTE*)ptDstPixel)[1] = ((BYTE*)ptSrcPixel)[1];
  187. ((BYTE*)ptDstPixel)[2] = ((BYTE*)ptSrcPixel)[2];
  188. ptDstPixel++;
  189. ptSrcPixel++;
  190. }
  191. // advance to next scanline
  192. pbSrcScanLine += iSrcScanAdvance;
  193. pbDstScanLine += iDstScanStride;
  194. // update and check vertical stepping error,
  195. // adjust src scanline pointer if necessary
  196. iVertError += iVertAdvanceError;
  197. if (iVertError >= iNumDstRows) {
  198. pbSrcScanLine += iSrcScanStride;
  199. iVertError -= iNumDstRows;
  200. }
  201. }
  202. }
  203. void Blt24Pto24P_NoBlend_NoTrans_NoHcopy_SRCCOPY(
  204. BYTE* pbSrcScanLine,
  205. int iSrcScanStride,
  206. int iNumSrcCols,
  207. int iNumSrcRows,
  208. BYTE* pbDstScanLine,
  209. int iDstScanStride,
  210. int iNumDstCols,
  211. int iNumDstRows,
  212. int iHorizMirror)
  213. {
  214. RGBTRIPLE *ptSrcPixel,
  215. *ptDstPixel;
  216. int iVertError = 0,
  217. iVertAdvanceError,
  218. iSrcScanAdvance,
  219. iHorizError,
  220. iHorizAdvanceError,
  221. iSrcPixelAdvance;
  222. // compute advance and error terms for stepping
  223. // vertically through the src bitmap
  224. if (iNumSrcRows < iNumDstRows) {
  225. iSrcScanAdvance = 0;
  226. iVertAdvanceError = iNumSrcRows;
  227. } else {
  228. iSrcScanAdvance = iSrcScanStride * (iNumSrcRows / iNumDstRows);
  229. iVertAdvanceError = iNumSrcRows % iNumDstRows;
  230. }
  231. // compute advance and error terms for stepping
  232. // horizontally through src bitmap
  233. if (iNumSrcCols < iNumDstCols) {
  234. iSrcPixelAdvance = 0;
  235. iHorizAdvanceError = iNumSrcCols;
  236. } else {
  237. iSrcPixelAdvance = iNumSrcCols / iNumDstCols;
  238. iHorizAdvanceError = iNumSrcCols % iNumDstCols;
  239. }
  240. for (int i = 0; i < iNumDstRows; i++) {
  241. // set up pointers to the first pixels
  242. // on src and dst scanline
  243. ptSrcPixel = (RGBTRIPLE *)pbSrcScanLine;
  244. ptDstPixel = (RGBTRIPLE *)pbDstScanLine;
  245. iHorizError = 0;
  246. for (int j = 0; j < iNumDstCols; j++)
  247. {
  248. // copy a pixel
  249. ((BYTE*)ptDstPixel)[0] = ((BYTE*)ptSrcPixel)[0];
  250. ((BYTE*)ptDstPixel)[1] = ((BYTE*)ptSrcPixel)[1];
  251. ((BYTE*)ptDstPixel)[2] = ((BYTE*)ptSrcPixel)[2];
  252. // advance to next pixel
  253. ptSrcPixel += iSrcPixelAdvance;
  254. ptDstPixel += iHorizMirror;
  255. // update and check horizontal stepping error,
  256. // adjust src pixel pointer if necessary
  257. iHorizError += iHorizAdvanceError;
  258. if (iHorizError >= iNumDstCols) {
  259. ptSrcPixel++;
  260. iHorizError -= iNumDstCols;
  261. }
  262. }
  263. // advance to next scanline
  264. pbSrcScanLine += iSrcScanAdvance;
  265. pbDstScanLine += iDstScanStride;
  266. // update and check vertical stepping error,
  267. // adjust src scanline pointer if necessary
  268. iVertError += iVertAdvanceError;
  269. if (iVertError >= iNumDstRows) {
  270. pbSrcScanLine += iSrcScanStride;
  271. iVertError -= iNumDstRows;
  272. }
  273. }
  274. }
  275. void Blt24Pto24P_NoBlend_Trans_Hcopy_SRCCOPY(
  276. BYTE* pbSrcScanLine,
  277. int iSrcScanStride,
  278. int iNumSrcRows,
  279. BYTE* pbDstScanLine,
  280. int iDstScanStride,
  281. int iNumDstCols,
  282. int iNumDstRows,
  283. COLORREF crTransparent)
  284. {
  285. RGBTRIPLE *ptSrcPixel,
  286. *ptDstPixel;
  287. DWORD dwPixel;
  288. int iVertError = 0,
  289. iVertAdvanceError,
  290. iSrcScanAdvance;
  291. // compute advance and error terms for stepping
  292. // vertically through the src bitmap
  293. if (iNumSrcRows < iNumDstRows) {
  294. iSrcScanAdvance = 0;
  295. iVertAdvanceError = iNumSrcRows;
  296. } else {
  297. iSrcScanAdvance = iSrcScanStride * (iNumSrcRows / iNumDstRows);
  298. iVertAdvanceError = iNumSrcRows % iNumDstRows;
  299. }
  300. for (int i = 0; i < iNumDstRows; i++) {
  301. // set up pointers to the first pixels
  302. // on src and dst scanlines, and next
  303. // pixel after last on dst scanline
  304. ptSrcPixel = (RGBTRIPLE *)pbSrcScanLine;
  305. ptDstPixel = (RGBTRIPLE *)pbDstScanLine;
  306. // copy scanline one pixel at a time
  307. for (int j = 0; j < iNumDstCols; j++) {
  308. dwPixel = (ptSrcPixel->rgbtRed << 16) |
  309. (ptSrcPixel->rgbtGreen << 8) |
  310. (ptSrcPixel->rgbtBlue);
  311. // only copy pixel if it's not transparent
  312. if ((dwPixel ^ (DWORD) crTransparent) & UNUSED_MASK)
  313. {
  314. ((BYTE*)ptDstPixel)[0] = ((BYTE*)ptSrcPixel)[0];
  315. ((BYTE*)ptDstPixel)[1] = ((BYTE*)ptSrcPixel)[1];
  316. ((BYTE*)ptDstPixel)[2] = ((BYTE*)ptSrcPixel)[2];
  317. }
  318. ptDstPixel++;
  319. ptSrcPixel++;
  320. }
  321. // advance to next scanline
  322. pbSrcScanLine += iSrcScanAdvance;
  323. pbDstScanLine += iDstScanStride;
  324. // update and check vertical stepping error,
  325. // adjust src scanline pointer if necessary
  326. iVertError += iVertAdvanceError;
  327. if (iVertError >= iNumDstRows) {
  328. pbSrcScanLine += iSrcScanStride;
  329. iVertError -= iNumDstRows;
  330. }
  331. }
  332. }
  333. void Blt24Pto24P_NoBlend_Trans_NoHcopy_SRCCOPY(
  334. BYTE* pbSrcScanLine,
  335. int iSrcScanStride,
  336. int iNumSrcCols,
  337. int iNumSrcRows,
  338. BYTE* pbDstScanLine,
  339. int iDstScanStride,
  340. int iNumDstCols,
  341. int iNumDstRows,
  342. int iHorizMirror,
  343. COLORREF crTransparent)
  344. {
  345. RGBTRIPLE *ptSrcPixel,
  346. *ptDstPixel;
  347. DWORD dwPixel;
  348. int iVertError = 0,
  349. iVertAdvanceError,
  350. iSrcScanAdvance,
  351. iHorizError,
  352. iHorizAdvanceError,
  353. iSrcPixelAdvance;
  354. // compute advance and error terms for stepping
  355. // vertically through the src bitmap
  356. if (iNumSrcRows < iNumDstRows) {
  357. iSrcScanAdvance = 0;
  358. iVertAdvanceError = iNumSrcRows;
  359. } else {
  360. iSrcScanAdvance = iSrcScanStride * (iNumSrcRows / iNumDstRows);
  361. iVertAdvanceError = iNumSrcRows % iNumDstRows;
  362. }
  363. // compute advance and error terms for stepping
  364. // horizontally through src bitmap
  365. if (iNumSrcCols < iNumDstCols) {
  366. iSrcPixelAdvance = 0;
  367. iHorizAdvanceError = iNumSrcCols;
  368. } else {
  369. iSrcPixelAdvance = iNumSrcCols / iNumDstCols;
  370. iHorizAdvanceError = iNumSrcCols % iNumDstCols;
  371. }
  372. for (int i = 0; i < iNumDstRows; i++) {
  373. // set up pointers to the first pixels
  374. // on src and dst scanlines, and next
  375. // pixel after last on dst scanline
  376. ptSrcPixel = (RGBTRIPLE *)pbSrcScanLine;
  377. ptDstPixel = (RGBTRIPLE *)pbDstScanLine;
  378. iHorizError = 0;
  379. for (int j = 0; j < iNumDstCols; j++) {
  380. dwPixel = (ptSrcPixel->rgbtRed << 16) |
  381. (ptSrcPixel->rgbtGreen << 8) |
  382. (ptSrcPixel->rgbtBlue);
  383. // only copy pixel if it's not transparent
  384. if ((dwPixel ^ (DWORD) crTransparent) & UNUSED_MASK)
  385. {
  386. ((BYTE*)ptDstPixel)[0] = ((BYTE*)ptSrcPixel)[0];
  387. ((BYTE*)ptDstPixel)[1] = ((BYTE*)ptSrcPixel)[1];
  388. ((BYTE*)ptDstPixel)[2] = ((BYTE*)ptSrcPixel)[2];
  389. }
  390. // advance to next pixel
  391. ptSrcPixel += iSrcPixelAdvance;
  392. ptDstPixel += iHorizMirror;
  393. // update and check horizontal stepping error,
  394. // adjust src pixel pointer if necessary
  395. iHorizError += iHorizAdvanceError;
  396. if (iHorizError >= iNumDstCols) {
  397. ptSrcPixel++;
  398. iHorizError -= iNumDstCols;
  399. }
  400. }
  401. // advance to next scanline
  402. pbSrcScanLine += iSrcScanAdvance;
  403. pbDstScanLine += iDstScanStride;
  404. // update and check vertical stepping error,
  405. // adjust src scanline pointer if necessary
  406. iVertError += iVertAdvanceError;
  407. if (iVertError >= iNumDstRows)
  408. {
  409. pbSrcScanLine += iSrcScanStride;
  410. iVertError -= iNumDstRows;
  411. }
  412. }
  413. }
  414. void Blt24Pto24P_NoBlend_Trans_Hcopy_SRCCOPY_VCopy(
  415. BYTE* pbSrcScanLine,
  416. int iSrcScanStride,
  417. BYTE* pbDstScanLine,
  418. int iDstScanStride,
  419. int iNumDstCols,
  420. int iNumDstRows,
  421. COLORREF crTransparent)
  422. {
  423. RGBTRIPLE *ptSrcPixel;
  424. RGBTRIPLE *ptDstPixel;
  425. RGBTRIPLE *ptEndDstPixel;
  426. BYTE *pbEndDstScanLine;
  427. DWORD dwPixel;
  428. // set up pointer to next dst scanline beyond last
  429. pbEndDstScanLine = pbDstScanLine + iNumDstRows * iDstScanStride;
  430. while (pbDstScanLine != pbEndDstScanLine) {
  431. // set up pointers to the first pixels
  432. // on src and dst scanlines, and next
  433. // pixel after last on dst scanline
  434. ptSrcPixel = (RGBTRIPLE *)pbSrcScanLine;
  435. ptDstPixel = (RGBTRIPLE *)pbDstScanLine;
  436. ptEndDstPixel = ptDstPixel + iNumDstCols;
  437. // copy scanline one pixel at a time
  438. while (ptDstPixel != ptEndDstPixel) {
  439. dwPixel = (ptSrcPixel->rgbtRed << 16) |
  440. (ptSrcPixel->rgbtGreen << 8) |
  441. (ptSrcPixel->rgbtBlue);
  442. // only copy pixel if it's not transparent
  443. if ((dwPixel ^ (DWORD) crTransparent) & UNUSED_MASK)
  444. {
  445. ((BYTE*)ptDstPixel)[0] = ((BYTE*)ptSrcPixel)[0];
  446. ((BYTE*)ptDstPixel)[1] = ((BYTE*)ptSrcPixel)[1];
  447. ((BYTE*)ptDstPixel)[2] = ((BYTE*)ptSrcPixel)[2];
  448. }
  449. ptDstPixel++;
  450. ptSrcPixel++;
  451. }
  452. // advance to next scanline
  453. pbSrcScanLine += iSrcScanStride;
  454. pbDstScanLine += iDstScanStride;
  455. }
  456. }
  457. #ifndef DDRAW
  458. void Blt24Pto24P_Blend_NoTrans_Hcopy_SRCCOPY_VCopy(
  459. BYTE* pbSrcScanLine,
  460. int iSrcScanStride,
  461. BYTE* pbDstScanLine,
  462. int iDstScanStride,
  463. int iNumDstCols,
  464. int iNumDstRows,
  465. ALPHAREF arAlpha)
  466. {
  467. RGBTRIPLE *ptSrcPixel,
  468. *ptDstPixel,
  469. *ptEndDstPixel;
  470. BYTE *pbEndDstScanLine;
  471. UINT uiAlpha = (UINT)ALPHAFROMDWORD(arAlpha),
  472. uiAlphaComp = 256 - uiAlpha;
  473. DWORD dwSrcColor;
  474. // set up pointer to next dst scanline beyond last
  475. pbEndDstScanLine = pbDstScanLine + iNumDstRows * iDstScanStride;
  476. while (pbDstScanLine != pbEndDstScanLine) {
  477. // set up pointers to the first pixels
  478. // on src and dst scanlines, and next
  479. // pixel after last on dst scanline
  480. ptSrcPixel = (RGBTRIPLE *)pbSrcScanLine;
  481. ptDstPixel = (RGBTRIPLE *)pbDstScanLine;
  482. ptEndDstPixel = ptDstPixel + iNumDstCols;
  483. // copy scanline one pixel at a time
  484. while (ptDstPixel != ptEndDstPixel) {
  485. dwSrcColor = (ptSrcPixel->rgbtRed << 16) |
  486. (ptSrcPixel->rgbtGreen << 8) |
  487. (ptSrcPixel->rgbtBlue);
  488. BlitLib_BLIT_BLEND24(dwSrcColor, ptDstPixel++, uiAlpha, uiAlphaComp);
  489. ptSrcPixel++;
  490. }
  491. // advance to next scanline
  492. pbSrcScanLine += iSrcScanStride;
  493. pbDstScanLine += iDstScanStride;
  494. }
  495. }
  496. void Blt24Pto24P_Blend_Trans_Hcopy_SRCCOPY_VCopy(
  497. BYTE* pbSrcScanLine,
  498. int iSrcScanStride,
  499. BYTE* pbDstScanLine,
  500. int iDstScanStride,
  501. int iNumDstCols,
  502. int iNumDstRows,
  503. COLORREF crTransparent,
  504. ALPHAREF arAlpha)
  505. {
  506. RGBTRIPLE *ptSrcPixel,
  507. *ptDstPixel,
  508. *ptEndDstPixel;
  509. BYTE *pbEndDstScanLine;
  510. DWORD dwPixel;
  511. UINT uiAlpha = (UINT)ALPHAFROMDWORD(arAlpha),
  512. uiAlphaComp = 256 - uiAlpha;
  513. // set up pointer to next dst scanline beyond last
  514. pbEndDstScanLine = pbDstScanLine + iNumDstRows * iDstScanStride;
  515. while (pbDstScanLine != pbEndDstScanLine) {
  516. // set up pointers to the first pixels
  517. // on src and dst scanlines, and next
  518. // pixel after last on dst scanline
  519. ptSrcPixel = (RGBTRIPLE *)pbSrcScanLine;
  520. ptDstPixel = (RGBTRIPLE *)pbDstScanLine;
  521. ptEndDstPixel = ptDstPixel + iNumDstCols;
  522. // copy scanline one pixel at a time
  523. while (ptDstPixel != ptEndDstPixel) {
  524. dwPixel = (ptSrcPixel->rgbtRed << 16) |
  525. (ptSrcPixel->rgbtGreen << 8) |
  526. (ptSrcPixel->rgbtBlue);
  527. // only copy pixel if it's not transparent
  528. if ((dwPixel ^ (DWORD) crTransparent) & UNUSED_MASK)
  529. BlitLib_BLIT_BLEND24(dwPixel, ptDstPixel,
  530. uiAlpha, uiAlphaComp);
  531. ptDstPixel++;
  532. ptSrcPixel++;
  533. }
  534. // advance to next scanline
  535. pbSrcScanLine += iSrcScanStride;
  536. pbDstScanLine += iDstScanStride;
  537. }
  538. }
  539. #endif
  540. ///////////////////////////////////////////////////////////////////////
  541. //
  542. // Private Blt24Pto24P_LeftToRight_BottomToTop_Trans_SRCCOPY -
  543. // BitBlit using a transparent color index from source bitmap to
  544. // destination bitmap (where these bitmaps overlap) by walking
  545. // both the source and destination from left to right and bottom
  546. // to top
  547. //
  548. // Parameters:
  549. // pSrcScanLine Pointer to the first Source scan line
  550. // iSrcScanStride The Source scan stride
  551. // pDstScanLine Pointer to the first Destination scan line
  552. // iDstScanStride The Destination scan stride
  553. // iNumDstCols Number of destination columns
  554. // iNumDstRows Number of destination rows
  555. // crTransparent Transparent color colorref
  556. //
  557. // Return Value:
  558. // NO_ERROR or E_* value as specified in the .H file.
  559. //
  560. ///////////////////////////////////////////////////////////////////////
  561. void Blt24Pto24P_LeftToRight_BottomToTop_Trans_SRCCOPY(BYTE* pbSrcScanLine,
  562. int iSrcScanStride,
  563. BYTE* pbDstScanLine,
  564. int iDstScanStride,
  565. int iNumDstCols,
  566. int iNumDstRows,
  567. COLORREF crTransparent)
  568. {
  569. RGBTRIPLE *ptSrcPixel,
  570. *ptDstPixel;
  571. DWORD dwPixel;
  572. for (int i = 0; i < iNumDstRows; i++) {
  573. // set up pointers to the first pixels
  574. // on src and dst scanlines, and next
  575. // pixel after last on dst scanline
  576. ptSrcPixel = (RGBTRIPLE *)pbSrcScanLine;
  577. ptDstPixel = (RGBTRIPLE *)pbDstScanLine;
  578. // copy scanline one pixel at a time
  579. for (int j = 0; j < iNumDstCols; j++) {
  580. dwPixel = (ptSrcPixel->rgbtRed << 16) |
  581. (ptSrcPixel->rgbtGreen << 8) |
  582. (ptSrcPixel->rgbtBlue);
  583. // only copy pixel if it's not transparent
  584. if ((dwPixel ^ (DWORD) crTransparent) & UNUSED_MASK){
  585. ((BYTE*)ptDstPixel)[0] = ((BYTE*)ptSrcPixel)[0];
  586. ((BYTE*)ptDstPixel)[1] = ((BYTE*)ptSrcPixel)[1];
  587. ((BYTE*)ptDstPixel)[2] = ((BYTE*)ptSrcPixel)[2];
  588. }
  589. ptDstPixel++;
  590. ptSrcPixel++;
  591. }
  592. // advance to next scanline
  593. pbSrcScanLine -= iSrcScanStride;
  594. pbDstScanLine -= iDstScanStride;
  595. }
  596. }
  597. ///////////////////////////////////////////////////////////////////////
  598. //
  599. // Private Blt24Pto24P_RightToLeft_TopToBottom_Trans_SRCCOPY -
  600. // BitBlit using a transparent color index from source bitmap to
  601. // destination bitmap (where these bitmaps overlap) by walking
  602. // both the source and destination from right to left and top
  603. // to bottom
  604. //
  605. // Parameters:
  606. // pSrcScanLine Pointer to the first Source scan line
  607. // iSrcScanStride The Source scan stride
  608. // pDstScanLine Pointer to the first Destination scan line
  609. // iDstScanStride The Destination scan stride
  610. // iNumDstCols Number of destination columns
  611. // iNumDstRows Number of destination rows
  612. // crTransparent Transparent color colorref
  613. //
  614. // Return Value:
  615. // NO_ERROR or E_* value as specified in the .H file.
  616. //
  617. ///////////////////////////////////////////////////////////////////////
  618. void Blt24Pto24P_RightToLeft_TopToBottom_Trans_SRCCOPY(BYTE* pbSrcScanLine,
  619. int iSrcScanStride,
  620. BYTE* pbDstScanLine,
  621. int iDstScanStride,
  622. int iNumDstCols,
  623. int iNumDstRows,
  624. COLORREF crTransparent)
  625. {
  626. RGBTRIPLE *ptSrcPixel,
  627. *ptDstPixel;
  628. DWORD dwPixel;
  629. for (int i = 0; i < iNumDstRows; i++) {
  630. // set up pointers to the first pixels
  631. // on src and dst scanlines, and next
  632. // pixel after last on dst scanline
  633. ptSrcPixel = (RGBTRIPLE *)pbSrcScanLine;
  634. ptDstPixel = (RGBTRIPLE *)pbDstScanLine;
  635. // copy scanline one pixel at a time
  636. for (int j = 0; j < iNumDstCols; j++) {
  637. dwPixel = (ptSrcPixel->rgbtRed << 16) |
  638. (ptSrcPixel->rgbtGreen << 8) |
  639. (ptSrcPixel->rgbtBlue);
  640. // only copy pixel if it's not transparent
  641. if ((dwPixel ^ (DWORD) crTransparent) & UNUSED_MASK){
  642. ((BYTE*)ptDstPixel)[0] = ((BYTE*)ptSrcPixel)[0];
  643. ((BYTE*)ptDstPixel)[1] = ((BYTE*)ptSrcPixel)[1];
  644. ((BYTE*)ptDstPixel)[2] = ((BYTE*)ptSrcPixel)[2];
  645. }
  646. ptDstPixel--;
  647. ptSrcPixel--;
  648. }
  649. // advance to next scanline
  650. pbSrcScanLine += iSrcScanStride;
  651. pbDstScanLine += iDstScanStride;
  652. }
  653. }
  654. #ifndef DDRAW
  655. ///////////////////////////////////////////////////////////////////////
  656. //
  657. // Private Blt24Pto24P_LeftToRight_BottomToTop_Alpha_SRCCOPY -
  658. // BitBlit using a transparent color index from source bitmap to
  659. // destination bitmap (where these bitmaps overlap) by walking
  660. // both the source and destination from left to right and bottom
  661. // to top
  662. //
  663. // Parameters:
  664. // pSrcScanLine Pointer to the first Source scan line
  665. // iSrcScanStride The Source scan stride
  666. // pDstScanLine Pointer to the first Destination scan line
  667. // iDstScanStride The Destination scan stride
  668. // iNumDstCols Number of destination columns
  669. // iNumDstRows Number of destination rows
  670. // arAlpha Alpha value
  671. //
  672. // Return Value:
  673. // NO_ERROR or E_* value as specified in the .H file.
  674. //
  675. ///////////////////////////////////////////////////////////////////////
  676. void Blt24Pto24P_LeftToRight_BottomToTop_Alpha_SRCCOPY(BYTE* pbSrcScanLine,
  677. int iSrcScanStride,
  678. BYTE* pbDstScanLine,
  679. int iDstScanStride,
  680. int iNumDstCols,
  681. int iNumDstRows,
  682. ALPHAREF arAlpha)
  683. {
  684. RGBTRIPLE *ptSrcPixel,
  685. *ptDstPixel;
  686. UINT uiAlpha = (UINT)ALPHAFROMDWORD(arAlpha),
  687. uiAlphaComp = 256 - uiAlpha;
  688. DWORD dwSrcColor;
  689. for (int i = 0; i < iNumDstRows; i++) {
  690. // set up pointers to the first pixels
  691. // on src and dst scanlines, and next
  692. // pixel after last on dst scanline
  693. ptSrcPixel = (RGBTRIPLE *)pbSrcScanLine;
  694. ptDstPixel = (RGBTRIPLE *)pbDstScanLine;
  695. // copy scanline one pixel at a time
  696. for (int j = 0; j < iNumDstCols; j++) {
  697. dwSrcColor = (ptSrcPixel->rgbtRed << 16) |
  698. (ptSrcPixel->rgbtGreen << 8) |
  699. (ptSrcPixel->rgbtBlue);
  700. BlitLib_BLIT_BLEND24(dwSrcColor, ptDstPixel++,
  701. uiAlpha, uiAlphaComp);
  702. ptSrcPixel++;
  703. }
  704. // advance to next scanline
  705. pbSrcScanLine -= iSrcScanStride;
  706. pbDstScanLine -= iDstScanStride;
  707. }
  708. }
  709. ///////////////////////////////////////////////////////////////////////
  710. //
  711. // Private Blt24Pto24P_RightToLeft_TopToBottom_Alpha_SRCCOPY -
  712. // BitBlit using a transparent color index from source bitmap to
  713. // destination bitmap (where these bitmaps overlap) by walking
  714. // both the source and destination from right to left and top
  715. // to bottom
  716. //
  717. // Parameters:
  718. // pSrcScanLine Pointer to the first Source scan line
  719. // iSrcScanStride The Source scan stride
  720. // pDstScanLine Pointer to the first Destination scan line
  721. // iDstScanStride The Destination scan stride
  722. // iNumDstCols Number of destination columns
  723. // iNumDstRows Number of destination rows
  724. // arAlpha Alpha value
  725. //
  726. // Return Value:
  727. // NO_ERROR or E_* value as specified in the .H file.
  728. //
  729. ///////////////////////////////////////////////////////////////////////
  730. void Blt24Pto24P_RightToLeft_TopToBottom_Alpha_SRCCOPY(BYTE* pbSrcScanLine,
  731. int iSrcScanStride,
  732. BYTE* pbDstScanLine,
  733. int iDstScanStride,
  734. int iNumDstCols,
  735. int iNumDstRows,
  736. ALPHAREF arAlpha)
  737. {
  738. RGBTRIPLE *ptSrcPixel,
  739. *ptDstPixel;
  740. UINT uiAlpha = (UINT)ALPHAFROMDWORD(arAlpha),
  741. uiAlphaComp = 256 - uiAlpha;
  742. DWORD dwSrcColor;
  743. for (int i = 0; i < iNumDstRows; i++) {
  744. // set up pointers to the first pixels
  745. // on src and dst scanlines, and next
  746. // pixel after last on dst scanline
  747. ptSrcPixel = (RGBTRIPLE *)pbSrcScanLine;
  748. ptDstPixel = (RGBTRIPLE *)pbDstScanLine;
  749. // copy scanline one pixel at a time
  750. for (int j = 0; j < iNumDstCols; j++) {
  751. dwSrcColor = (ptSrcPixel->rgbtRed << 16) |
  752. (ptSrcPixel->rgbtGreen << 8) |
  753. (ptSrcPixel->rgbtBlue);
  754. BlitLib_BLIT_BLEND24(dwSrcColor, ptDstPixel--,
  755. uiAlpha, uiAlphaComp);
  756. ptSrcPixel--;
  757. }
  758. // advance to next scanline
  759. pbSrcScanLine += iSrcScanStride;
  760. pbDstScanLine += iDstScanStride;
  761. }
  762. }
  763. ///////////////////////////////////////////////////////////////////////
  764. //
  765. // Private Blt24Pto24P_LeftToRight_BottomToTop_Trans_Alpha_SRCCOPY -
  766. // BitBlit using a transparent color index from source bitmap to
  767. // destination bitmap (where these bitmaps overlap) by walking
  768. // both the source and destination from left to right and bottom
  769. // to top
  770. //
  771. // Parameters:
  772. // pSrcScanLine Pointer to the first Source scan line
  773. // iSrcScanStride The Source scan stride
  774. // pDstScanLine Pointer to the first Destination scan line
  775. // iDstScanStride The Destination scan stride
  776. // iNumDstCols Number of destination columns
  777. // iNumDstRows Number of destination rows
  778. // crTransparent Transparent color colorref
  779. // arAlpha Alpha value
  780. //
  781. // Return Value:
  782. // NO_ERROR or E_* value as specified in the .H file.
  783. //
  784. ///////////////////////////////////////////////////////////////////////
  785. void Blt24Pto24P_LeftToRight_BottomToTop_Trans_Alpha_SRCCOPY(BYTE* pbSrcScanLine,
  786. int iSrcScanStride,
  787. BYTE* pbDstScanLine,
  788. int iDstScanStride,
  789. int iNumDstCols,
  790. int iNumDstRows,
  791. COLORREF crTransparent,
  792. ALPHAREF arAlpha)
  793. {
  794. RGBTRIPLE *ptSrcPixel,
  795. *ptDstPixel;
  796. DWORD dwPixel;
  797. UINT uiAlpha = (UINT)ALPHAFROMDWORD(arAlpha),
  798. uiAlphaComp = 256 - uiAlpha;
  799. for (int i = 0; i < iNumDstRows; i++) {
  800. // set up pointers to the first pixels
  801. // on src and dst scanlines, and next
  802. // pixel after last on dst scanline
  803. ptSrcPixel = (RGBTRIPLE *)pbSrcScanLine;
  804. ptDstPixel = (RGBTRIPLE *)pbDstScanLine;
  805. // copy scanline one pixel at a time
  806. for (int j = 0; j < iNumDstCols; j++) {
  807. dwPixel = (ptSrcPixel->rgbtRed << 16) |
  808. (ptSrcPixel->rgbtGreen << 8) |
  809. (ptSrcPixel->rgbtBlue);
  810. // only copy pixel if it's not transparent
  811. if ((dwPixel ^ (DWORD) crTransparent) & UNUSED_MASK)
  812. BlitLib_BLIT_BLEND24(dwPixel, ptDstPixel,
  813. uiAlpha, uiAlphaComp);
  814. ptDstPixel++;
  815. ptSrcPixel++;
  816. }
  817. // advance to next scanline
  818. pbSrcScanLine -= iSrcScanStride;
  819. pbDstScanLine -= iDstScanStride;
  820. }
  821. }
  822. ///////////////////////////////////////////////////////////////////////
  823. //
  824. // Private Blt24Pto24P_RightToLeft_TopToBottom_Trans_Alpha_SRCCOPY -
  825. // BitBlit using a transparent color index from source bitmap to
  826. // destination bitmap (where these bitmaps overlap) by walking
  827. // both the source and destination from right to left and top
  828. // to bottom
  829. //
  830. // Parameters:
  831. // pSrcScanLine Pointer to the first Source scan line
  832. // iSrcScanStride The Source scan stride
  833. // pDstScanLine Pointer to the first Destination scan line
  834. // iDstScanStride The Destination scan stride
  835. // iNumDstCols Number of destination columns
  836. // iNumDstRows Number of destination rows
  837. // crTransparent Transparent color colorref
  838. // arAlpha Alpha value
  839. //
  840. // Return Value:
  841. // NO_ERROR or E_* value as specified in the .H file.
  842. //
  843. ///////////////////////////////////////////////////////////////////////
  844. void Blt24Pto24P_RightToLeft_TopToBottom_Trans_Alpha_SRCCOPY(BYTE* pbSrcScanLine,
  845. int iSrcScanStride,
  846. BYTE* pbDstScanLine,
  847. int iDstScanStride,
  848. int iNumDstCols,
  849. int iNumDstRows,
  850. COLORREF crTransparent,
  851. ALPHAREF arAlpha)
  852. {
  853. RGBTRIPLE *ptSrcPixel,
  854. *ptDstPixel;
  855. DWORD dwPixel;
  856. UINT uiAlpha = (UINT)ALPHAFROMDWORD(arAlpha),
  857. uiAlphaComp = 256 - uiAlpha;
  858. for (int i = 0; i < iNumDstRows; i++) {
  859. // set up pointers to the first pixels
  860. // on src and dst scanlines, and next
  861. // pixel after last on dst scanline
  862. ptSrcPixel = (RGBTRIPLE *)pbSrcScanLine;
  863. ptDstPixel = (RGBTRIPLE *)pbDstScanLine;
  864. // copy scanline one pixel at a time
  865. for (int j = 0; j < iNumDstCols; j++) {
  866. dwPixel = (ptSrcPixel->rgbtRed << 16) |
  867. (ptSrcPixel->rgbtGreen << 8) |
  868. (ptSrcPixel->rgbtBlue);
  869. // only copy pixel if it's not transparent
  870. if ((dwPixel ^ (DWORD) crTransparent) & UNUSED_MASK)
  871. BlitLib_BLIT_BLEND24(dwPixel, ptDstPixel,
  872. uiAlpha, uiAlphaComp);
  873. ptDstPixel--;
  874. ptSrcPixel--;
  875. }
  876. // advance to next scanline
  877. pbSrcScanLine += iSrcScanStride;
  878. pbDstScanLine += iDstScanStride;
  879. }
  880. }
  881. #endif