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.

603 lines
17 KiB

  1. #include "precomp.hxx"
  2. void Blt24to24_NoBlend_NoTrans_Hcopy_SRCCOPY_Vcopy(
  3. DWORD* pdSrcScanLine,
  4. int iSrcScanStride,
  5. DWORD* pdDstScanLine,
  6. int iDstScanStride,
  7. int iNumDstCols,
  8. int iNumDstRows)
  9. {
  10. DWORD *pdSrcPixel,
  11. *pdDstPixel,
  12. *pdEndDstPixel,
  13. *pdEndDstScanLine;
  14. // set up pointer to next dst scanline beyond last
  15. pdEndDstScanLine = pdDstScanLine + iNumDstRows * iDstScanStride;
  16. while (pdDstScanLine != pdEndDstScanLine) {
  17. // set up pointers to the first pixels
  18. // on src and dst scanlines, and next
  19. // pixel after last on dst scanline
  20. pdSrcPixel = pdSrcScanLine;
  21. pdDstPixel = pdDstScanLine;
  22. pdEndDstPixel = pdDstPixel + iNumDstCols;
  23. // copy scanline one pixel at a time
  24. while (pdDstPixel != pdEndDstPixel) {
  25. *pdDstPixel++ = *pdSrcPixel++;
  26. }
  27. // advance to next scanline
  28. pdSrcScanLine += iSrcScanStride;
  29. pdDstScanLine += iDstScanStride;
  30. }
  31. }
  32. void Blt24to24_NoBlend_NoTrans_Hcopy_SRCCOPY_NoVcopy(
  33. DWORD* pdSrcScanLine,
  34. int iSrcScanStride,
  35. int iNumSrcRows,
  36. DWORD* pdDstScanLine,
  37. int iDstScanStride,
  38. int iNumDstCols,
  39. int iNumDstRows)
  40. {
  41. DWORD *pdSrcPixel,
  42. *pdDstPixel,
  43. *pdEndDstPixel;
  44. int iVertError = 0,
  45. iVertAdvanceError,
  46. iSrcScanAdvance;
  47. // compute advance and error terms for stepping
  48. // vertically through the src bitmap
  49. if (iNumSrcRows < iNumDstRows) {
  50. iSrcScanAdvance = 0;
  51. iVertAdvanceError = iNumSrcRows;
  52. } else {
  53. iSrcScanAdvance = iSrcScanStride * (iNumSrcRows / iNumDstRows);
  54. iVertAdvanceError = iNumSrcRows % iNumDstRows;
  55. }
  56. for (int i = 0; i < iNumDstRows; i++) {
  57. // set up pointers to first pixels on src and dst
  58. // scanlines, and next pixel after last on dst
  59. pdSrcPixel = pdSrcScanLine;
  60. pdDstPixel = pdDstScanLine;
  61. pdEndDstPixel = pdDstPixel + iNumDstCols;
  62. // copy scanline one pixel at a time
  63. while (pdDstPixel != pdEndDstPixel) {
  64. *pdDstPixel++ = *pdSrcPixel++;
  65. }
  66. // advance to next scanline
  67. pdSrcScanLine += iSrcScanAdvance;
  68. pdDstScanLine += iDstScanStride;
  69. // update and check vertical stepping error,
  70. // adjust src scanline pointer if necessary
  71. iVertError += iVertAdvanceError;
  72. if (iVertError >= iNumDstRows) {
  73. pdSrcScanLine += iSrcScanStride;
  74. iVertError -= iNumDstRows;
  75. }
  76. }
  77. }
  78. void Blt24to24_NoBlend_NoTrans_NoHcopy_SRCCOPY(
  79. DWORD* pdSrcScanLine,
  80. int iSrcScanStride,
  81. int iNumSrcCols,
  82. int iNumSrcRows,
  83. DWORD* pdDstScanLine,
  84. int iDstScanStride,
  85. int iNumDstCols,
  86. int iNumDstRows,
  87. int iHorizMirror)
  88. {
  89. DWORD *pdSrcPixel,
  90. *pdDstPixel;
  91. int iVertError = 0,
  92. iVertAdvanceError,
  93. iSrcScanAdvance,
  94. iHorizError,
  95. iHorizAdvanceError,
  96. iSrcPixelAdvance;
  97. // compute advance and error terms for stepping
  98. // vertically through the src bitmap
  99. if (iNumSrcRows < iNumDstRows) {
  100. iSrcScanAdvance = 0;
  101. iVertAdvanceError = iNumSrcRows;
  102. } else {
  103. iSrcScanAdvance = iSrcScanStride * (iNumSrcRows / iNumDstRows);
  104. iVertAdvanceError = iNumSrcRows % iNumDstRows;
  105. }
  106. // compute advance and error terms for stepping
  107. // horizontally through src bitmap
  108. if (iNumSrcCols < iNumDstCols) {
  109. iSrcPixelAdvance = 0;
  110. iHorizAdvanceError = iNumSrcCols;
  111. } else {
  112. iSrcPixelAdvance = iNumSrcCols / iNumDstCols;
  113. iHorizAdvanceError = iNumSrcCols % iNumDstCols;
  114. }
  115. for (int i = 0; i < iNumDstRows; i++) {
  116. // set pointers to the beginning of src and dst scanlines,
  117. // clear horizontal stepping error accumulator
  118. pdSrcPixel = pdSrcScanLine;
  119. pdDstPixel = pdDstScanLine;
  120. iHorizError = 0;
  121. for (int j = 0; j < iNumDstCols; j++) {
  122. // copy a pixel
  123. *pdDstPixel = *pdSrcPixel;
  124. // advance to next pixel
  125. pdSrcPixel += iSrcPixelAdvance;
  126. pdDstPixel += iHorizMirror;
  127. // update and check horizontal stepping error,
  128. // adjust src pixel pointer if necessary
  129. iHorizError += iHorizAdvanceError;
  130. if (iHorizError >= iNumDstCols) {
  131. pdSrcPixel++;
  132. iHorizError -= iNumDstCols;
  133. }
  134. }
  135. // advance to next scanline
  136. pdSrcScanLine += iSrcScanAdvance;
  137. pdDstScanLine += iDstScanStride;
  138. // update and check vertical stepping error,
  139. // adjust src scanline pointer if necessary
  140. iVertError += iVertAdvanceError;
  141. if (iVertError >= iNumDstRows) {
  142. pdSrcScanLine += iSrcScanStride;
  143. iVertError -= iNumDstRows;
  144. }
  145. }
  146. }
  147. void Blt24to24_NoBlend_Trans_Hcopy_SRCCOPY(
  148. DWORD* pdSrcScanLine,
  149. int iSrcScanStride,
  150. int iNumSrcRows,
  151. DWORD* pdDstScanLine,
  152. int iDstScanStride,
  153. int iNumDstCols,
  154. int iNumDstRows,
  155. COLORREF crTransparent)
  156. {
  157. DWORD *pdSrcPixel,
  158. *pdDstPixel;
  159. int iVertError = 0,
  160. iVertAdvanceError,
  161. iSrcScanAdvance;
  162. // compute advance and error terms for stepping
  163. // vertically through the src bitmap
  164. if (iNumSrcRows < iNumDstRows) {
  165. iSrcScanAdvance = 0;
  166. iVertAdvanceError = iNumSrcRows;
  167. } else {
  168. iSrcScanAdvance = iSrcScanStride * (iNumSrcRows / iNumDstRows);
  169. iVertAdvanceError = iNumSrcRows % iNumDstRows;
  170. }
  171. for (int i = 0; i < iNumDstRows; i++) {
  172. // set pointers to beginning of src and dest scanlines
  173. pdSrcPixel = pdSrcScanLine;
  174. pdDstPixel = pdDstScanLine;
  175. for (int j = 0; j < iNumDstCols; j++) {
  176. // only copy pixel if it's not transparent
  177. if ((*pdSrcPixel ^ (DWORD) crTransparent) & UNUSED_MASK) {
  178. *pdDstPixel = *pdSrcPixel;
  179. }
  180. pdSrcPixel++;
  181. pdDstPixel++;
  182. }
  183. // advance to next scanline
  184. pdSrcScanLine += iSrcScanAdvance;
  185. pdDstScanLine += iDstScanStride;
  186. // update and check vertical stepping error,
  187. // adjust src scanline pointer if necessary
  188. iVertError += iVertAdvanceError;
  189. if (iVertError >= iNumDstRows) {
  190. pdSrcScanLine += iSrcScanStride;
  191. iVertError -= iNumDstRows;
  192. }
  193. }
  194. }
  195. void Blt24to24_NoBlend_Trans_NoHcopy_SRCCOPY(
  196. DWORD* pdSrcScanLine,
  197. int iSrcScanStride,
  198. int iNumSrcCols,
  199. int iNumSrcRows,
  200. DWORD* pdDstScanLine,
  201. int iDstScanStride,
  202. int iNumDstCols,
  203. int iNumDstRows,
  204. int iHorizMirror,
  205. COLORREF crTransparent)
  206. {
  207. DWORD *pdSrcPixel,
  208. *pdDstPixel;
  209. int iVertError = 0,
  210. iVertAdvanceError,
  211. iSrcScanAdvance,
  212. iHorizError,
  213. iHorizAdvanceError,
  214. iSrcPixelAdvance;
  215. // compute advance and error terms for stepping
  216. // vertically through the src bitmap
  217. if (iNumSrcRows < iNumDstRows) {
  218. iSrcScanAdvance = 0;
  219. iVertAdvanceError = iNumSrcRows;
  220. } else {
  221. iSrcScanAdvance = iSrcScanStride * (iNumSrcRows / iNumDstRows);
  222. iVertAdvanceError = iNumSrcRows % iNumDstRows;
  223. }
  224. // compute advance and error terms for stepping
  225. // horizontally through src bitmap
  226. if (iNumSrcCols < iNumDstCols) {
  227. iSrcPixelAdvance = 0;
  228. iHorizAdvanceError = iNumSrcCols;
  229. } else {
  230. iSrcPixelAdvance = iNumSrcCols / iNumDstCols;
  231. iHorizAdvanceError = iNumSrcCols % iNumDstCols;
  232. }
  233. for (int i = 0; i < iNumDstRows; i++) {
  234. // set pointers to the beginning of src and dst scanlines,
  235. // clear horizontal stepping error accumulator
  236. pdSrcPixel = pdSrcScanLine;
  237. pdDstPixel = pdDstScanLine;
  238. iHorizError = 0;
  239. for (int j = 0; j < iNumDstCols; j++) {
  240. // only copy pixel if it's not transparent
  241. if ((*pdSrcPixel ^ (DWORD) crTransparent) & UNUSED_MASK) {
  242. *pdDstPixel = *pdSrcPixel;
  243. }
  244. // advance to next pixel
  245. pdSrcPixel += iSrcPixelAdvance;
  246. pdDstPixel += iHorizMirror;
  247. // update and check horizontal stepping error,
  248. // adjust src pixel pointer if necessary
  249. iHorizError += iHorizAdvanceError;
  250. if (iHorizError >= iNumDstCols) {
  251. pdSrcPixel++;
  252. iHorizError -= iNumDstCols;
  253. }
  254. }
  255. // advance to next scanline
  256. pdSrcScanLine += iSrcScanAdvance;
  257. pdDstScanLine += iDstScanStride;
  258. // update and check vertical stepping error,
  259. // adjust src scanline pointer if necessary
  260. iVertError += iVertAdvanceError;
  261. if (iVertError >= iNumDstRows) {
  262. pdSrcScanLine += iSrcScanStride;
  263. iVertError -= iNumDstRows;
  264. }
  265. }
  266. }
  267. #ifndef DDRAW
  268. void Blt24to24_Blend_NoTrans_Hcopy_SRCCOPY(
  269. DWORD* pdSrcScanLine,
  270. int iSrcScanStride,
  271. int iNumSrcRows,
  272. DWORD* pdDstScanLine,
  273. int iDstScanStride,
  274. int iNumDstCols,
  275. int iNumDstRows,
  276. ALPHAREF arAlpha)
  277. {
  278. DWORD *pdSrcPixel,
  279. *pdDstPixel,
  280. *pdEndDstPixel;
  281. int iVertError = 0,
  282. iVertAdvanceError,
  283. iSrcScanAdvance;
  284. UINT uiAlpha = (UINT)ALPHAFROMDWORD(arAlpha),
  285. uiAlphaComp = 256 - uiAlpha;
  286. // compute advance and error terms for stepping
  287. // vertically through the src bitmap
  288. if (iNumSrcRows < iNumDstRows) {
  289. iSrcScanAdvance = 0;
  290. iVertAdvanceError = iNumSrcRows;
  291. } else {
  292. iSrcScanAdvance = iSrcScanStride * (iNumSrcRows / iNumDstRows);
  293. iVertAdvanceError = iNumSrcRows % iNumDstRows;
  294. }
  295. for (int i = 0; i < iNumDstRows; i++) {
  296. // set up pointers to first pixels on src and dst
  297. // scanlines, and next pixel after last on dst
  298. pdSrcPixel = pdSrcScanLine;
  299. pdDstPixel = pdDstScanLine;
  300. pdEndDstPixel = pdDstPixel + iNumDstCols;
  301. // copy scanline one pixel at a time
  302. while (pdDstPixel != pdEndDstPixel) {
  303. *pdDstPixel++ = BLIT_BLEND(*pdSrcPixel,*pdDstPixel,
  304. uiAlpha,uiAlphaComp);
  305. pdSrcPixel++;
  306. }
  307. // advance to next scanline
  308. pdSrcScanLine += iSrcScanAdvance;
  309. pdDstScanLine += iDstScanStride;
  310. // update and check vertical stepping error,
  311. // adjust src scanline pointer if necessary
  312. iVertError += iVertAdvanceError;
  313. if (iVertError >= iNumDstRows) {
  314. pdSrcScanLine += iSrcScanStride;
  315. iVertError -= iNumDstRows;
  316. }
  317. }
  318. }
  319. void Blt24to24_Blend_NoTrans_NoHcopy_SRCCOPY(
  320. DWORD* pdSrcScanLine,
  321. int iSrcScanStride,
  322. int iNumSrcCols,
  323. int iNumSrcRows,
  324. DWORD* pdDstScanLine,
  325. int iDstScanStride,
  326. int iNumDstCols,
  327. int iNumDstRows,
  328. int iHorizMirror,
  329. ALPHAREF arAlpha)
  330. {
  331. DWORD *pdSrcPixel,
  332. *pdDstPixel;
  333. int iVertError = 0,
  334. iVertAdvanceError,
  335. iSrcScanAdvance,
  336. iHorizError,
  337. iHorizAdvanceError,
  338. iSrcPixelAdvance;
  339. UINT uiAlpha = (UINT)ALPHAFROMDWORD(arAlpha),
  340. uiAlphaComp = 256 - uiAlpha;
  341. // compute advance and error terms for stepping
  342. // vertically through the src bitmap
  343. if (iNumSrcRows < iNumDstRows) {
  344. iSrcScanAdvance = 0;
  345. iVertAdvanceError = iNumSrcRows;
  346. } else {
  347. iSrcScanAdvance = iSrcScanStride * (iNumSrcRows / iNumDstRows);
  348. iVertAdvanceError = iNumSrcRows % iNumDstRows;
  349. }
  350. // compute advance and error terms for stepping
  351. // horizontally through src bitmap
  352. if (iNumSrcCols < iNumDstCols) {
  353. iSrcPixelAdvance = 0;
  354. iHorizAdvanceError = iNumSrcCols;
  355. } else {
  356. iSrcPixelAdvance = iNumSrcCols / iNumDstCols;
  357. iHorizAdvanceError = iNumSrcCols % iNumDstCols;
  358. }
  359. for (int i = 0; i < iNumDstRows; i++) {
  360. // set pointers to the beginning of src and dst scanlines,
  361. // clear horizontal stepping error accumulator
  362. pdSrcPixel = pdSrcScanLine;
  363. pdDstPixel = pdDstScanLine;
  364. iHorizError = 0;
  365. for (int j = 0; j < iNumDstCols; j++) {
  366. // copy a pixel
  367. *pdDstPixel = BLIT_BLEND(*pdSrcPixel,*pdDstPixel,
  368. uiAlpha,uiAlphaComp);
  369. // advance to next pixel
  370. pdSrcPixel += iSrcPixelAdvance;
  371. pdDstPixel += iHorizMirror;
  372. // update and check horizontal stepping error,
  373. // adjust src pixel pointer if necessary
  374. iHorizError += iHorizAdvanceError;
  375. if (iHorizError >= iNumDstCols) {
  376. pdSrcPixel++;
  377. iHorizError -= iNumDstCols;
  378. }
  379. }
  380. // advance to next scanline
  381. pdSrcScanLine += iSrcScanAdvance;
  382. pdDstScanLine += iDstScanStride;
  383. // update and check vertical stepping error,
  384. // adjust src scanline pointer if necessary
  385. iVertError += iVertAdvanceError;
  386. if (iVertError >= iNumDstRows) {
  387. pdSrcScanLine += iSrcScanStride;
  388. iVertError -= iNumDstRows;
  389. }
  390. }
  391. }
  392. void Blt24to24_Blend_Trans_Hcopy_SRCCOPY(
  393. DWORD* pdSrcScanLine,
  394. int iSrcScanStride,
  395. int iNumSrcRows,
  396. DWORD* pdDstScanLine,
  397. int iDstScanStride,
  398. int iNumDstCols,
  399. int iNumDstRows,
  400. COLORREF crTransparent,
  401. ALPHAREF arAlpha)
  402. {
  403. DWORD *pdSrcPixel,
  404. *pdDstPixel;
  405. int iVertError = 0,
  406. iVertAdvanceError,
  407. iSrcScanAdvance;
  408. UINT uiAlpha = (UINT)ALPHAFROMDWORD(arAlpha),
  409. uiAlphaComp = 256 - uiAlpha;
  410. // compute advance and error terms for stepping
  411. // vertically through the src bitmap
  412. if (iNumSrcRows < iNumDstRows) {
  413. iSrcScanAdvance = 0;
  414. iVertAdvanceError = iNumSrcRows;
  415. } else {
  416. iSrcScanAdvance = iSrcScanStride * (iNumSrcRows / iNumDstRows);
  417. iVertAdvanceError = iNumSrcRows % iNumDstRows;
  418. }
  419. for (int i = 0; i < iNumDstRows; i++) {
  420. // set pointers to beginning of src and dest scanlines
  421. pdSrcPixel = pdSrcScanLine;
  422. pdDstPixel = pdDstScanLine;
  423. for (int j = 0; j < iNumDstCols; j++) {
  424. // only copy pixel if it's not transparent
  425. if ((*pdSrcPixel ^ (DWORD) crTransparent) & UNUSED_MASK){
  426. *pdDstPixel = BLIT_BLEND(*pdSrcPixel,*pdDstPixel,
  427. uiAlpha,uiAlphaComp);
  428. }
  429. pdSrcPixel++;
  430. pdDstPixel++;
  431. }
  432. // advance to next scanline
  433. pdSrcScanLine += iSrcScanAdvance;
  434. pdDstScanLine += iDstScanStride;
  435. // update and check vertical stepping error,
  436. // adjust src scanline pointer if necessary
  437. iVertError += iVertAdvanceError;
  438. if (iVertError >= iNumDstRows) {
  439. pdSrcScanLine += iSrcScanStride;
  440. iVertError -= iNumDstRows;
  441. }
  442. }
  443. }
  444. void Blt24to24_Blend_Trans_NoHcopy_SRCCOPY(
  445. DWORD* pdSrcScanLine,
  446. int iSrcScanStride,
  447. int iNumSrcCols,
  448. int iNumSrcRows,
  449. DWORD* pdDstScanLine,
  450. int iDstScanStride,
  451. int iNumDstCols,
  452. int iNumDstRows,
  453. int iHorizMirror,
  454. COLORREF crTransparent,
  455. ALPHAREF arAlpha)
  456. {
  457. DWORD *pdSrcPixel,
  458. *pdDstPixel;
  459. int iVertError = 0,
  460. iVertAdvanceError,
  461. iSrcScanAdvance,
  462. iHorizError,
  463. iHorizAdvanceError,
  464. iSrcPixelAdvance;
  465. UINT uiAlpha = (UINT)ALPHAFROMDWORD(arAlpha),
  466. uiAlphaComp = 256 - uiAlpha;
  467. // compute advance and error terms for stepping
  468. // vertically through the src bitmap
  469. if (iNumSrcRows < iNumDstRows) {
  470. iSrcScanAdvance = 0;
  471. iVertAdvanceError = iNumSrcRows;
  472. } else {
  473. iSrcScanAdvance = iSrcScanStride * (iNumSrcRows / iNumDstRows);
  474. iVertAdvanceError = iNumSrcRows % iNumDstRows;
  475. }
  476. // compute advance and error terms for stepping
  477. // horizontally through src bitmap
  478. if (iNumSrcCols < iNumDstCols) {
  479. iSrcPixelAdvance = 0;
  480. iHorizAdvanceError = iNumSrcCols;
  481. } else {
  482. iSrcPixelAdvance = iNumSrcCols / iNumDstCols;
  483. iHorizAdvanceError = iNumSrcCols % iNumDstCols;
  484. }
  485. for (int i = 0; i < iNumDstRows; i++) {
  486. // set pointers to the beginning of src and dst scanlines,
  487. // clear horizontal stepping error accumulator
  488. pdSrcPixel = pdSrcScanLine;
  489. pdDstPixel = pdDstScanLine;
  490. iHorizError = 0;
  491. for (int j = 0; j < iNumDstCols; j++) {
  492. // only copy pixel if it's not transparent
  493. if ((*pdSrcPixel ^ (DWORD) crTransparent) & UNUSED_MASK) {
  494. *pdDstPixel = BLIT_BLEND(*pdSrcPixel,*pdDstPixel,
  495. uiAlpha,uiAlphaComp);
  496. }
  497. // advance to next pixel
  498. pdSrcPixel += iSrcPixelAdvance;
  499. pdDstPixel += iHorizMirror;
  500. // update and check horizontal stepping error,
  501. // adjust src pixel pointer if necessary
  502. iHorizError += iHorizAdvanceError;
  503. if (iHorizError >= iNumDstCols) {
  504. pdSrcPixel++;
  505. iHorizError -= iNumDstCols;
  506. }
  507. }
  508. // advance to next scanline
  509. pdSrcScanLine += iSrcScanAdvance;
  510. pdDstScanLine += iDstScanStride;
  511. // update and check vertical stepping error,
  512. // adjust src scanline pointer if necessary
  513. iVertError += iVertAdvanceError;
  514. if (iVertError >= iNumDstRows) {
  515. pdSrcScanLine += iSrcScanStride;
  516. iVertError -= iNumDstRows;
  517. }
  518. }
  519. }
  520. #endif