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.

3625 lines
90 KiB

  1. /******************************Module*Header*******************************\
  2. * Module Name: stretch.cxx
  3. *
  4. * Internal DDAs for EngStretchBlt
  5. *
  6. * Created: 16-Feb-1993 15:35:02
  7. * Author: Donald Sidoroff [donalds]
  8. *
  9. * Copyright (c) 1993-1999 Microsoft Corporation
  10. \**************************************************************************/
  11. #include "precomp.hxx"
  12. #include "stretch.hxx"
  13. #ifdef DBG_STRBLT
  14. extern BOOL gflStrBlt;
  15. #endif
  16. static VOID STR_DIV(
  17. DIV_T *pdt,
  18. LONG lNum,
  19. LONG lDen)
  20. {
  21. if (lNum < 0)
  22. {
  23. lNum = - (lNum + 1);
  24. pdt->lQuo = lNum / lDen;
  25. pdt->lRem = lNum % lDen;
  26. pdt->lQuo = - (pdt->lQuo + 1);
  27. pdt->lRem = lDen - pdt->lRem - 1;
  28. }
  29. else
  30. {
  31. pdt->lQuo = lNum / lDen;
  32. pdt->lRem = lNum % lDen;
  33. }
  34. #ifdef DBG_STRBLT
  35. if (gflStrBlt & STRBLT_SHOW_INIT)
  36. DbgPrint("%ld / %ld = %ld R %ld\n", lNum, lDen, pdt->lQuo, pdt->lRem);
  37. #endif
  38. }
  39. /******************************Public*Routine******************************\
  40. * VOID vInitStrDDA(pdda, prclScan, prclSrc, prclTrg)
  41. *
  42. * Initialize the DDA
  43. *
  44. * History:
  45. * 16-Feb-1993 -by- Donald Sidoroff [donalds]
  46. * Wrote it.
  47. \**************************************************************************/
  48. VOID vInitStrDDA(
  49. STRDDA *pdda,
  50. RECTL *prclScan,
  51. RECTL *prclSrc,
  52. RECTL *prclTrg)
  53. {
  54. RECTL rclScan;
  55. RECTL rclSrc;
  56. // If the source surface does not have a 0,0 origin, deal with it here.
  57. if ((prclSrc->left != 0) || (prclSrc->top != 0))
  58. {
  59. rclScan.left = prclScan->left - prclSrc->left;
  60. rclScan.top = prclScan->top - prclSrc->top;
  61. rclScan.right = prclScan->right - prclSrc->left;
  62. rclScan.bottom = prclScan->bottom - prclSrc->top;
  63. prclScan = &rclScan;
  64. rclSrc.left = 0;
  65. rclSrc.top = 0;
  66. rclSrc.right = prclSrc->right - prclSrc->left;
  67. rclSrc.bottom = prclSrc->bottom - prclSrc->top;
  68. prclSrc = &rclSrc;
  69. }
  70. #ifdef DBG_STRBLT
  71. if (gflStrBlt & STRBLT_SHOW_INIT)
  72. {
  73. DbgPrint("prclScan = [(%ld,%ld) (%ld,%ld)]\n",
  74. prclScan->left, prclScan->top, prclScan->right, prclScan->bottom);
  75. DbgPrint("prclSrc = [(%ld,%ld) (%ld,%ld)]\n",
  76. prclSrc->left, prclSrc->top, prclSrc->right, prclSrc->bottom);
  77. DbgPrint("prclTrg = [(%ld,%ld) (%ld,%ld)]\n",
  78. prclTrg->left, prclTrg->top, prclTrg->right, prclTrg->bottom);
  79. }
  80. #endif
  81. pdda->plYStep = &pdda->al[prclSrc->right];
  82. DDA_STEP dQnext; // increment on position of next pixel image
  83. DIV_T Qnext; // starting position of next pixel image
  84. LONG lQ; // current positon
  85. LONG iLoop;
  86. LONG j;
  87. //
  88. // x-coordinates
  89. //
  90. STR_DIV(&dQnext.dt, prclTrg->right - prclTrg->left, prclSrc->right);
  91. dQnext.lDen = prclSrc->right;
  92. Qnext.lQuo = dQnext.dt.lQuo;
  93. Qnext.lRem = dQnext.dt.lRem + ((dQnext.lDen - 1)>>1);
  94. if (Qnext.lRem >= dQnext.lDen)
  95. {
  96. Qnext.lQuo += 1;
  97. Qnext.lRem -= dQnext.lDen;
  98. }
  99. for (lQ = 0, iLoop = 0; iLoop < prclScan->left; iLoop++)
  100. {
  101. lQ = Qnext.lQuo;
  102. DDA(&Qnext, &dQnext);
  103. }
  104. pdda->rcl.left = lQ + prclTrg->left;
  105. for (j = 0; iLoop < prclScan->right; iLoop++, j++)
  106. {
  107. pdda->al[j] = Qnext.lQuo - lQ;
  108. lQ = Qnext.lQuo;
  109. DDA(&Qnext, &dQnext);
  110. }
  111. pdda->rcl.right = lQ + prclTrg->left;
  112. //
  113. // y-coordinates
  114. //
  115. STR_DIV(&dQnext.dt, prclTrg->bottom - prclTrg->top, prclSrc->bottom);
  116. dQnext.lDen = prclSrc->bottom;
  117. Qnext.lQuo = dQnext.dt.lQuo;
  118. Qnext.lRem = dQnext.dt.lRem + ((dQnext.lDen - 1)>>1);
  119. if (Qnext.lRem >= dQnext.lDen)
  120. {
  121. Qnext.lQuo += 1;
  122. Qnext.lRem -= dQnext.lDen;
  123. }
  124. for (lQ = 0, iLoop = 0; iLoop < prclScan->top; iLoop++)
  125. {
  126. lQ = Qnext.lQuo;
  127. DDA(&Qnext, &dQnext);
  128. }
  129. pdda->rcl.top = lQ + prclTrg->top;
  130. for (j = 0; iLoop < prclScan->bottom; iLoop++, j++)
  131. {
  132. pdda->plYStep[j] = Qnext.lQuo - lQ;
  133. lQ = Qnext.lQuo;
  134. DDA(&Qnext, &dQnext);
  135. }
  136. pdda->rcl.bottom = lQ + prclTrg->top;
  137. #ifdef DBG_STRBLT
  138. if (gflStrBlt & STRBLT_SHOW_INIT)
  139. DbgPrint("XStep @%08lx, YStep @%08lx\n", (ULONG) pdda->al, (ULONG) pdda->plYStep);
  140. #endif
  141. }
  142. /******************************Public*Routine******************************\
  143. * VOID vInitBuffer(prun, ercl, iMode)
  144. *
  145. * Initialize the run buffer for overwrite modes
  146. *
  147. * History:
  148. * 27-Feb-1993 -by- Donald Sidoroff [donalds]
  149. * Wrote it.
  150. \**************************************************************************/
  151. VOID vInitBuffer(
  152. STRRUN *prun,
  153. RECTL *prcl,
  154. ULONG iOver)
  155. {
  156. prun->xrl.xPos = prcl->left;
  157. prun->xrl.cRun = prcl->right - prcl->left;
  158. RtlFillMemoryUlong((VOID *) &prun->xrl.aul[0], prun->xrl.cRun << 2, iOver);
  159. }
  160. static ULONG gaulMaskEdge[] =
  161. {
  162. 0xFFFFFFFF, 0xFFFFFF7F, 0xFFFFFF3F, 0xFFFFFF1F,
  163. 0xFFFFFF0F, 0xFFFFFF07, 0xFFFFFF03, 0xFFFFFF01,
  164. 0xFFFFFF00, 0xFFFF7F00, 0xFFFF3F00, 0xFFFF1F00,
  165. 0xFFFF0F00, 0xFFFF0700, 0xFFFF0300, 0xFFFF0100,
  166. 0xFFFF0000, 0xFF7F0000, 0xFF3F0000, 0xFF1F0000,
  167. 0xFF0F0000, 0xFF070000, 0xFF030000, 0xFF010000,
  168. 0xFF000000, 0x7F000000, 0x3F000000, 0x1F000000,
  169. 0x0F000000, 0x07000000, 0x03000000, 0x01000000
  170. };
  171. static ULONG gaulMaskMono[] =
  172. {
  173. 0x00000080, 0x00000040, 0x00000020, 0x00000010,
  174. 0x00000008, 0x00000004, 0x00000002, 0x00000001,
  175. 0x00008000, 0x00004000, 0x00002000, 0x00001000,
  176. 0x00000800, 0x00000400, 0x00000200, 0x00000100,
  177. 0x00800000, 0x00400000, 0x00200000, 0x00100000,
  178. 0x00080000, 0x00040000, 0x00020000, 0x00010000,
  179. 0x80000000, 0x40000000, 0x20000000, 0x10000000,
  180. 0x08000000, 0x04000000, 0x02000000, 0x01000000
  181. };
  182. static ULONG gaulShftMono[] =
  183. {
  184. 0x00000007, 0x00000006, 0x00000005, 0x00000004,
  185. 0x00000003, 0x00000002, 0x00000001, 0x00000000,
  186. 0x0000000F, 0x0000000E, 0x0000000D, 0x0000000C,
  187. 0x0000000B, 0x0000000A, 0x00000009, 0x00000008,
  188. 0x00000017, 0x00000016, 0x00000015, 0x00000014,
  189. 0x00000013, 0x00000012, 0x00000011, 0x00000010,
  190. 0x0000001F, 0x0000001E, 0x0000001D, 0x0000001C,
  191. 0x0000001B, 0x0000001A, 0x00000019, 0x00000018
  192. };
  193. static ULONG gaulMaskQuad[] =
  194. {
  195. 0x000000F0, 0x0000000F, 0x0000F000, 0x00000F00,
  196. 0x00F00000, 0x000F0000, 0xF0000000, 0x0F000000
  197. };
  198. static ULONG gaulShftQuad[] =
  199. {
  200. 0x00000004, 0x00000000, 0x0000000C, 0x00000008,
  201. 0x00000014, 0x00000010, 0x0000001C, 0x00000018
  202. };
  203. /******************************Public*Routine******************************\
  204. * VOID vStrMirror01(pSurf)
  205. *
  206. * Mirror the 1BPP surface in X.
  207. *
  208. * History:
  209. * 08-Mar-1993 -by- Donald Sidoroff [donalds]
  210. * Wrote it.
  211. \**************************************************************************/
  212. VOID vStrMirror01(SURFACE *pSurf)
  213. {
  214. ULONG *pulBase;
  215. ULONG *pulSrc;
  216. ULONG *pulTrg;
  217. ULONG ulSrc;
  218. ULONG ulTrg;
  219. ULONG ulSwp;
  220. ULONG ulTmp;
  221. LONG cFlip;
  222. LONG cLeft;
  223. LONG cRght;
  224. LONG iLeft;
  225. LONG iRght;
  226. LONG x;
  227. LONG y;
  228. pulBase = (ULONG *) pSurf->pvScan0();
  229. cFlip = pSurf->sizl().cx / 2;
  230. for (y = 0; y < pSurf->sizl().cy; y++)
  231. {
  232. iLeft = 0;
  233. cLeft = 0;
  234. iRght = pSurf->sizl().cx - 1;
  235. cRght = iRght >> 5;
  236. iRght &= 31;
  237. pulSrc = pulBase;
  238. pulTrg = pulSrc + cRght;
  239. ulSrc = *pulSrc;
  240. ulTrg = *pulTrg;
  241. for (x = 0; x < cFlip; x++)
  242. {
  243. if (cLeft == cRght)
  244. {
  245. ulSwp = (ulSrc & gaulMaskMono[iLeft]) >> gaulShftMono[iLeft];
  246. ulTmp = (ulSrc & gaulMaskMono[iRght]) >> gaulShftMono[iRght];
  247. ulSrc = (ulSrc & ~gaulMaskMono[iLeft]) | (ulTmp << gaulShftMono[iLeft]);
  248. ulSrc = (ulSrc & ~gaulMaskMono[iRght]) | (ulSwp << gaulShftMono[iRght]);
  249. }
  250. else
  251. {
  252. ulSwp = (ulSrc & gaulMaskMono[iLeft]) >> gaulShftMono[iLeft];
  253. ulTmp = (ulTrg & gaulMaskMono[iRght]) >> gaulShftMono[iRght];
  254. ulSrc = (ulSrc & ~gaulMaskMono[iLeft]) | (ulTmp << gaulShftMono[iLeft]);
  255. ulTrg = (ulTrg & ~gaulMaskMono[iRght]) | (ulSwp << gaulShftMono[iRght]);
  256. }
  257. iLeft++;
  258. iRght--;
  259. if (iLeft & 32)
  260. {
  261. *pulSrc = ulSrc;
  262. pulSrc++;
  263. cLeft++;
  264. if (cLeft == cRght)
  265. *pulTrg = ulTrg;
  266. ulSrc = *pulSrc;
  267. iLeft = 0;
  268. }
  269. if (iRght < 0)
  270. {
  271. *pulTrg = ulTrg;
  272. pulTrg--;
  273. cRght--;
  274. if (cRght == cLeft)
  275. *pulSrc = ulSrc;
  276. else
  277. ulTrg = *pulTrg;
  278. iRght = 31;
  279. }
  280. }
  281. *pulSrc = ulSrc;
  282. if (cLeft != cRght)
  283. *pulTrg = ulTrg;
  284. pulBase = (ULONG *) (((BYTE *) pulBase) + pSurf->lDelta());
  285. }
  286. }
  287. /******************************Public*Routine******************************\
  288. * VOID vStrMirror04(pSurf)
  289. *
  290. * Mirror the 4BPP surface in X.
  291. *
  292. * History:
  293. * 08-Mar-1993 -by- Donald Sidoroff [donalds]
  294. * Wrote it.
  295. \**************************************************************************/
  296. VOID vStrMirror04(SURFACE *pSurf)
  297. {
  298. ULONG *pulBase;
  299. ULONG *pulSrc;
  300. ULONG *pulTrg;
  301. ULONG ulSrc;
  302. ULONG ulTrg;
  303. ULONG ulSwp;
  304. ULONG ulTmp;
  305. LONG cFlip;
  306. LONG cLeft;
  307. LONG cRght;
  308. LONG iLeft;
  309. LONG iRght;
  310. LONG x;
  311. LONG y;
  312. pulBase = (ULONG *) pSurf->pvScan0();
  313. cFlip = pSurf->sizl().cx / 2;
  314. for (y = 0; y < pSurf->sizl().cy; y++)
  315. {
  316. iLeft = 0;
  317. cLeft = 0;
  318. iRght = pSurf->sizl().cx - 1;
  319. cRght = iRght >> 3;
  320. iRght &= 7;
  321. pulSrc = pulBase;
  322. pulTrg = pulSrc + cRght;
  323. ulSrc = *pulSrc;
  324. ulTrg = *pulTrg;
  325. for (x = 0; x < cFlip; x++)
  326. {
  327. if (cLeft == cRght)
  328. {
  329. ulSwp = (ulSrc & gaulMaskQuad[iLeft]) >> gaulShftQuad[iLeft];
  330. ulTmp = (ulSrc & gaulMaskQuad[iRght]) >> gaulShftQuad[iRght];
  331. ulSrc = (ulSrc & ~gaulMaskQuad[iLeft]) | (ulTmp << gaulShftQuad[iLeft]);
  332. ulSrc = (ulSrc & ~gaulMaskQuad[iRght]) | (ulSwp << gaulShftQuad[iRght]);
  333. }
  334. else
  335. {
  336. ulSwp = (ulSrc & gaulMaskQuad[iLeft]) >> gaulShftQuad[iLeft];
  337. ulTmp = (ulTrg & gaulMaskQuad[iRght]) >> gaulShftQuad[iRght];
  338. ulSrc = (ulSrc & ~gaulMaskQuad[iLeft]) | (ulTmp << gaulShftQuad[iLeft]);
  339. ulTrg = (ulTrg & ~gaulMaskQuad[iRght]) | (ulSwp << gaulShftQuad[iRght]);
  340. }
  341. iLeft++;
  342. iRght--;
  343. if (iLeft & 8)
  344. {
  345. *pulSrc = ulSrc;
  346. pulSrc++;
  347. cLeft++;
  348. if (cLeft == cRght)
  349. *pulTrg = ulTrg;
  350. ulSrc = *pulSrc;
  351. iLeft = 0;
  352. }
  353. if (iRght < 0)
  354. {
  355. *pulTrg = ulTrg;
  356. pulTrg--;
  357. cRght--;
  358. if (cRght == cLeft)
  359. *pulSrc = ulSrc;
  360. else
  361. ulTrg = *pulTrg;
  362. iRght = 7;
  363. }
  364. *pulSrc = ulSrc;
  365. if (cLeft != cRght)
  366. *pulTrg = ulTrg;
  367. }
  368. pulBase = (ULONG *) (((BYTE *) pulBase) + pSurf->lDelta());
  369. }
  370. }
  371. /******************************Public*Routine******************************\
  372. * VOID vStrMirror08(pSurf)
  373. *
  374. * Mirror the 8BPP surface in X.
  375. *
  376. * History:
  377. * 08-Mar-1993 -by- Donald Sidoroff [donalds]
  378. * Wrote it.
  379. \**************************************************************************/
  380. VOID vStrMirror08(SURFACE *pSurf)
  381. {
  382. BYTE *pjSrc;
  383. BYTE *pjTrg;
  384. BYTE *pjBase;
  385. BYTE jTemp;
  386. LONG cFlip;
  387. LONG x;
  388. LONG y;
  389. pjBase = (BYTE *) pSurf->pvScan0();
  390. cFlip = pSurf->sizl().cx / 2;
  391. for (y = 0; y < pSurf->sizl().cy; y++)
  392. {
  393. pjSrc = pjBase;
  394. pjTrg = pjSrc + pSurf->sizl().cx - 1;
  395. for (x = 0; x < cFlip; x++)
  396. {
  397. jTemp = *pjSrc;
  398. *pjSrc = *pjTrg;
  399. *pjTrg = jTemp;
  400. pjSrc++;
  401. pjTrg--;
  402. }
  403. pjBase += pSurf->lDelta();
  404. }
  405. }
  406. /******************************Public*Routine******************************\
  407. * VOID vStrMirror16(pSurf)
  408. *
  409. * Mirror the 16BPP surface in X.
  410. *
  411. * History:
  412. * 08-Mar-1993 -by- Donald Sidoroff [donalds]
  413. * Wrote it.
  414. \**************************************************************************/
  415. VOID vStrMirror16(SURFACE *pSurf)
  416. {
  417. WORD *pwSrc;
  418. WORD *pwTrg;
  419. WORD *pwBase;
  420. WORD wTemp;
  421. LONG cFlip;
  422. LONG x;
  423. LONG y;
  424. pwBase = (WORD *) pSurf->pvScan0();
  425. cFlip = pSurf->sizl().cx / 2;
  426. for (y = 0; y < pSurf->sizl().cy; y++)
  427. {
  428. pwSrc = pwBase;
  429. pwTrg = pwSrc + pSurf->sizl().cx - 1;
  430. for (x = 0; x < cFlip; x++)
  431. {
  432. wTemp = *pwSrc;
  433. *pwSrc = *pwTrg;
  434. *pwTrg = wTemp;
  435. pwSrc++;
  436. pwTrg--;
  437. }
  438. pwBase = (WORD *) (((BYTE *) pwBase) + pSurf->lDelta());
  439. }
  440. }
  441. /******************************Public*Routine******************************\
  442. * VOID vStrMirror24(pSurf)
  443. *
  444. * Mirror the 24BPP surface in X.
  445. *
  446. * History:
  447. * 08-Mar-1993 -by- Donald Sidoroff [donalds]
  448. * Wrote it.
  449. \**************************************************************************/
  450. VOID vStrMirror24(SURFACE *pSurf)
  451. {
  452. RGBTRIPLE *prgbSrc;
  453. RGBTRIPLE *prgbTrg;
  454. RGBTRIPLE *prgbBase;
  455. RGBTRIPLE rgbTemp;
  456. LONG cFlip;
  457. LONG x;
  458. LONG y;
  459. prgbBase = (RGBTRIPLE *) pSurf->pvScan0();
  460. cFlip = pSurf->sizl().cx / 2;
  461. for (y = 0; y < pSurf->sizl().cy; y++)
  462. {
  463. prgbSrc = prgbBase;
  464. prgbTrg = prgbSrc + pSurf->sizl().cx - 1;
  465. for (x = 0; x < cFlip; x++)
  466. {
  467. rgbTemp = *prgbSrc;
  468. *prgbSrc = *prgbTrg;
  469. *prgbTrg = rgbTemp;
  470. prgbSrc++;
  471. prgbTrg--;
  472. }
  473. prgbBase = (RGBTRIPLE *) (((BYTE *) prgbBase) + pSurf->lDelta());
  474. }
  475. }
  476. /******************************Public*Routine******************************\
  477. * VOID vStrMirror32(pSurf)
  478. *
  479. * Mirror the 32BPP surface in X.
  480. *
  481. * History:
  482. * 08-Mar-1993 -by- Donald Sidoroff [donalds]
  483. * Wrote it.
  484. \**************************************************************************/
  485. VOID vStrMirror32(SURFACE *pSurf)
  486. {
  487. DWORD *pdwSrc;
  488. DWORD *pdwTrg;
  489. DWORD *pdwBase;
  490. DWORD dwTemp;
  491. LONG cFlip;
  492. LONG x;
  493. LONG y;
  494. pdwBase = (DWORD *) pSurf->pvScan0();
  495. cFlip = pSurf->sizl().cx / 2;
  496. for (y = 0; y < pSurf->sizl().cy; y++)
  497. {
  498. pdwSrc = pdwBase;
  499. pdwTrg = pdwSrc + pSurf->sizl().cx - 1;
  500. for (x = 0; x < cFlip; x++)
  501. {
  502. dwTemp = *pdwSrc;
  503. *pdwSrc = *pdwTrg;
  504. *pdwTrg = dwTemp;
  505. pdwSrc++;
  506. pdwTrg--;
  507. }
  508. pdwBase = (DWORD *) (((BYTE *) pdwBase) + pSurf->lDelta());
  509. }
  510. }
  511. /******************************Public*Routine******************************\
  512. * XRUNLEN *pxrlStrRead01AND(prun, pjSrc, pjMask, pxlo, xLeft, xRght, xMask)
  513. *
  514. * Read the source, xlate colors, AND the pels and produce a run
  515. * list for a row of a 1BPP surface.
  516. *
  517. * History:
  518. * 27-Feb-1993 -by- Donald Sidoroff [donalds]
  519. * Wrote it.
  520. \**************************************************************************/
  521. XRUNLEN *pxrlStrRead01AND(
  522. STRDDA *pdda,
  523. STRRUN *prun,
  524. BYTE *pjSrc,
  525. BYTE *pjMask,
  526. XLATEOBJ *pxlo,
  527. LONG xLeft,
  528. LONG xRght,
  529. LONG xMask)
  530. {
  531. XRUNLEN *pxrl = &prun->xrl;
  532. ULONG *pulSrc;
  533. ULONG ulSrc;
  534. ULONG iBlack;
  535. ULONG iWhite;
  536. LONG cLeft;
  537. LONG iLeft;
  538. LONG cnt;
  539. LONG i;
  540. LONG j;
  541. DONTUSE(pjMask);
  542. DONTUSE(xMask);
  543. cLeft = xLeft >> 5; // Index of leftmost DWORD
  544. iLeft = xLeft & 31; // Bits used in leftmost DWORD
  545. pulSrc = ((DWORD *) pjSrc) + cLeft; // Adjust base address
  546. // To prevent derefences of the XLATE, do it upfront. We can easily do
  547. // this on monochrome bitmaps.
  548. if (pxlo == NULL)
  549. {
  550. iBlack = 0;
  551. iWhite = 1;
  552. }
  553. else
  554. {
  555. iBlack = pxlo->pulXlate[0];
  556. iWhite = pxlo->pulXlate[1];
  557. }
  558. i = 0;
  559. j = 0;
  560. pxrl->xPos = pdda->rcl.left;
  561. pxrl->cRun = pdda->rcl.right - pxrl->xPos;
  562. ulSrc = *pulSrc;
  563. if (xLeft < xRght)
  564. {
  565. while (TRUE)
  566. {
  567. if (!(ulSrc & gaulMaskMono[iLeft]))
  568. {
  569. cnt = pdda->al[i++];
  570. if (!cnt)
  571. pxrl->aul[j] &= iBlack;
  572. else
  573. while (cnt--)
  574. pxrl->aul[j++] &= iBlack;
  575. }
  576. else
  577. {
  578. cnt = pdda->al[i++];
  579. if (!cnt)
  580. pxrl->aul[j] &= iWhite;
  581. else
  582. while (cnt--)
  583. pxrl->aul[j++] &= iWhite;
  584. }
  585. xLeft++;
  586. iLeft++;
  587. if (xLeft >= xRght)
  588. break;
  589. if (iLeft & 32)
  590. {
  591. pulSrc++;
  592. ulSrc = *pulSrc;
  593. iLeft = 0;
  594. }
  595. }
  596. }
  597. return((XRUNLEN *) &pxrl->aul[j]);
  598. }
  599. /******************************Public*Routine******************************\
  600. * XRUNLEN *pxrlStrRead04AND(prun, pjSrc, pjMask, pxlo, xLeft, xRght, xMask)
  601. *
  602. * Read the source, xlate colors, AND the pels and produce a run
  603. * list for a row of a 4BPP surface.
  604. *
  605. * History:
  606. * 13-Apr-1993 -by- Donald Sidoroff [donalds]
  607. * Wrote it.
  608. \**************************************************************************/
  609. XRUNLEN *pxrlStrRead04AND(
  610. STRDDA *pdda,
  611. STRRUN *prun,
  612. BYTE *pjSrc,
  613. BYTE *pjMask,
  614. XLATEOBJ *pxlo,
  615. LONG xLeft,
  616. LONG xRght,
  617. LONG xMask)
  618. {
  619. XRUNLEN *pxrl = &prun->xrl;
  620. ULONG *pulSrc;
  621. ULONG ulSrc;
  622. ULONG iColor;
  623. LONG cLeft;
  624. LONG iLeft;
  625. LONG cnt;
  626. LONG i;
  627. LONG j;
  628. DONTUSE(pjMask);
  629. DONTUSE(xMask);
  630. cLeft = xLeft >> 3; // Index of leftmost DWORD
  631. iLeft = xLeft & 7; // Nybbles used in leftmost DWORD
  632. pulSrc = ((DWORD *) pjSrc) + cLeft; // Adjust base address
  633. ulSrc = *pulSrc;
  634. i = 0;
  635. j = 0;
  636. pxrl->xPos = pdda->rcl.left;
  637. pxrl->cRun = pdda->rcl.right - pxrl->xPos;
  638. if (pxlo == NULL)
  639. {
  640. if (xLeft < xRght)
  641. {
  642. while (TRUE)
  643. {
  644. iColor = (ulSrc & gaulMaskQuad[iLeft]) >> gaulShftQuad[iLeft];
  645. cnt = pdda->al[i++];
  646. if (!cnt)
  647. pxrl->aul[j] &= iColor;
  648. else
  649. while (cnt--)
  650. pxrl->aul[j++] &= iColor;
  651. xLeft++;
  652. iLeft++;
  653. if (xLeft >= xRght)
  654. break;
  655. if (iLeft & 8)
  656. {
  657. pulSrc++;
  658. ulSrc = *pulSrc;
  659. iLeft = 0;
  660. }
  661. }
  662. }
  663. }
  664. else
  665. {
  666. if (xLeft < xRght)
  667. {
  668. while (TRUE)
  669. {
  670. iColor = pxlo->pulXlate[(ulSrc & gaulMaskQuad[iLeft]) >> gaulShftQuad[iLeft]];
  671. cnt = pdda->al[i++];
  672. if (!cnt)
  673. pxrl->aul[j] &= iColor;
  674. else
  675. while (cnt--)
  676. pxrl->aul[j++] &= iColor;
  677. xLeft++;
  678. iLeft++;
  679. if (xLeft >= xRght)
  680. break;
  681. if (iLeft & 8)
  682. {
  683. pulSrc++;
  684. ulSrc = *pulSrc;
  685. iLeft = 0;
  686. }
  687. }
  688. }
  689. }
  690. return((XRUNLEN *) &pxrl->aul[j]);
  691. }
  692. /******************************Public*Routine******************************\
  693. * XRUNLEN *pxrlStrRead08AND(prun, pjSrc, pjMask, pxlo, xLeft, xRght, xMask)
  694. *
  695. * Read the source, xlate colors, AND the pels and produce a run
  696. * list for a row of a 8BPP surface.
  697. *
  698. * History:
  699. * 13-Apr-1993 -by- Donald Sidoroff [donalds]
  700. * Wrote it.
  701. \**************************************************************************/
  702. XRUNLEN *pxrlStrRead08AND(
  703. STRDDA *pdda,
  704. STRRUN *prun,
  705. BYTE *pjSrc,
  706. BYTE *pjMask,
  707. XLATEOBJ *pxlo,
  708. LONG xLeft,
  709. LONG xRght,
  710. LONG xMask)
  711. {
  712. XRUNLEN *pxrl = &prun->xrl;
  713. LONG cnt;
  714. LONG i;
  715. LONG j;
  716. DONTUSE(pjMask);
  717. DONTUSE(xMask);
  718. pjSrc += xLeft;
  719. pxrl->xPos = pdda->rcl.left;
  720. pxrl->cRun = pdda->rcl.right - pdda->rcl.left;
  721. i = 0;
  722. j = 0;
  723. if (pxlo == NULL)
  724. while (xLeft != xRght)
  725. {
  726. cnt = pdda->al[i++];
  727. if (!cnt)
  728. pxrl->aul[j] &= *pjSrc;
  729. else
  730. while (cnt--)
  731. pxrl->aul[j++] &= *pjSrc;
  732. pjSrc++;
  733. xLeft++;
  734. }
  735. else
  736. while (xLeft != xRght)
  737. {
  738. cnt = pdda->al[i++];
  739. if (!cnt)
  740. pxrl->aul[j] &= pxlo->pulXlate[*pjSrc];
  741. else
  742. while (cnt--)
  743. pxrl->aul[j++] &= pxlo->pulXlate[*pjSrc];
  744. pjSrc++;
  745. xLeft++;
  746. }
  747. return((XRUNLEN *) &pxrl->aul[j]);
  748. }
  749. /******************************Public*Routine******************************\
  750. * XRUNLEN *pxrlStrRead16AND(prun, pjSrc, pjMask, pxlo, xLeft, xRght, xMask)
  751. *
  752. * Read the source, xlate colors, AND the pels and produce a run
  753. * list for a row of a 16BPP surface.
  754. *
  755. * History:
  756. * 13-Apr-1993 -by- Donald Sidoroff [donalds]
  757. * Wrote it.
  758. \**************************************************************************/
  759. XRUNLEN *pxrlStrRead16AND(
  760. STRDDA *pdda,
  761. STRRUN *prun,
  762. BYTE *pjSrc,
  763. BYTE *pjMask,
  764. XLATEOBJ *pxlo,
  765. LONG xLeft,
  766. LONG xRght,
  767. LONG xMask)
  768. {
  769. XRUNLEN *pxrl = &prun->xrl;
  770. WORD *pwSrc = (WORD *) pjSrc;
  771. ULONG ulTmp;
  772. LONG cnt;
  773. LONG i;
  774. LONG j;
  775. DONTUSE(pjMask);
  776. DONTUSE(xMask);
  777. pwSrc += xLeft;
  778. pxrl->xPos = pdda->rcl.left;
  779. pxrl->cRun = pdda->rcl.right - pdda->rcl.left;
  780. i = 0;
  781. j = 0;
  782. if (pxlo == NULL)
  783. while (xLeft != xRght)
  784. {
  785. cnt = pdda->al[i++];
  786. if (!cnt)
  787. pxrl->aul[j] &= *pwSrc;
  788. else
  789. while (cnt--)
  790. pxrl->aul[j++] &= *pwSrc;
  791. pwSrc++;
  792. xLeft++;
  793. }
  794. else
  795. while (xLeft != xRght)
  796. {
  797. cnt = pdda->al[i++];
  798. ulTmp = ((XLATE *) pxlo)->ulTranslate((ULONG) *pwSrc);
  799. if (!cnt)
  800. pxrl->aul[j] &= ulTmp;
  801. else
  802. while (cnt--)
  803. pxrl->aul[j++] &= ulTmp;
  804. pwSrc++;
  805. xLeft++;
  806. }
  807. return((XRUNLEN *) &pxrl->aul[j]);
  808. }
  809. /******************************Public*Routine******************************\
  810. * XRUNLEN *pxrlStrRead24AND(prun, pjSrc, pjMask, pxlo, xLeft, xRght, xMask)
  811. *
  812. * Read the source, xlate colors, AND the pels and produce a run
  813. * list for a row of a 24BPP surface.
  814. *
  815. * History:
  816. * 13-Apr-1993 -by- Donald Sidoroff [donalds]
  817. * Wrote it.
  818. \**************************************************************************/
  819. XRUNLEN *pxrlStrRead24AND(
  820. STRDDA *pdda,
  821. STRRUN *prun,
  822. BYTE *pjSrc,
  823. BYTE *pjMask,
  824. XLATEOBJ *pxlo,
  825. LONG xLeft,
  826. LONG xRght,
  827. LONG xMask)
  828. {
  829. XRUNLEN *pxrl = &prun->xrl;
  830. RGBTRIPLE *prgbSrc = (RGBTRIPLE *) pjSrc;
  831. ULONG ulTmp = 0;
  832. LONG cnt;
  833. LONG i;
  834. LONG j;
  835. DONTUSE(pjMask);
  836. DONTUSE(xMask);
  837. prgbSrc += xLeft;
  838. pxrl->xPos = pdda->rcl.left;
  839. pxrl->cRun = pdda->rcl.right - pdda->rcl.left;
  840. i = 0;
  841. j = 0;
  842. if (pxlo == NULL)
  843. while (xLeft != xRght)
  844. {
  845. *((RGBTRIPLE *) &ulTmp) = *prgbSrc;
  846. cnt = pdda->al[i++];
  847. if (!cnt)
  848. pxrl->aul[j] &= ulTmp;
  849. else
  850. while (cnt--)
  851. pxrl->aul[j++] &= ulTmp;
  852. prgbSrc++;
  853. xLeft++;
  854. }
  855. else
  856. while (xLeft != xRght)
  857. {
  858. cnt = pdda->al[i++];
  859. *((RGBTRIPLE *) &ulTmp) = *prgbSrc;
  860. ulTmp = ((XLATE *) pxlo)->ulTranslate(ulTmp);
  861. if (!cnt)
  862. pxrl->aul[j] &= ulTmp;
  863. else
  864. while (cnt--)
  865. pxrl->aul[j++] &= ulTmp;
  866. prgbSrc++;
  867. xLeft++;
  868. }
  869. return((XRUNLEN *) &pxrl->aul[j]);
  870. }
  871. /******************************Public*Routine******************************\
  872. * XRUNLEN *pxrlStrRead32AND(prun, pjSrc, pjMask, pxlo, xLeft, xRght, xMask)
  873. *
  874. * Read the source, xlate colors, AND the pels and produce a run
  875. * list for a row of a 32BPP surface.
  876. *
  877. * History:
  878. * 13-Apr-1993 -by- Donald Sidoroff [donalds]
  879. * Wrote it.
  880. \**************************************************************************/
  881. XRUNLEN *pxrlStrRead32AND(
  882. STRDDA *pdda,
  883. STRRUN *prun,
  884. BYTE *pjSrc,
  885. BYTE *pjMask,
  886. XLATEOBJ *pxlo,
  887. LONG xLeft,
  888. LONG xRght,
  889. LONG xMask)
  890. {
  891. XRUNLEN *pxrl = &prun->xrl;
  892. DWORD *pdwSrc = (DWORD *) pjSrc;
  893. ULONG ulTmp;
  894. LONG cnt;
  895. LONG i;
  896. LONG j;
  897. DONTUSE(pjMask);
  898. DONTUSE(xMask);
  899. pdwSrc += xLeft;
  900. pxrl->xPos = pdda->rcl.left;
  901. pxrl->cRun = pdda->rcl.right - pdda->rcl.left;
  902. i = 0;
  903. j = 0;
  904. if (pxlo == NULL)
  905. while (xLeft != xRght)
  906. {
  907. cnt = pdda->al[i++];
  908. if (!cnt)
  909. pxrl->aul[j] &= *pdwSrc;
  910. else
  911. while (cnt--)
  912. pxrl->aul[j++] &= *pdwSrc;
  913. pdwSrc++;
  914. xLeft++;
  915. }
  916. else
  917. while (xLeft != xRght)
  918. {
  919. cnt = pdda->al[i++];
  920. ulTmp = ((XLATE *) pxlo)->ulTranslate((ULONG) *pdwSrc);
  921. if (!cnt)
  922. pxrl->aul[j] &= ulTmp;
  923. else
  924. while (cnt--)
  925. pxrl->aul[j++] &= ulTmp;
  926. pdwSrc++;
  927. xLeft++;
  928. }
  929. return((XRUNLEN *) &pxrl->aul[j]);
  930. }
  931. /******************************Public*Routine******************************\
  932. * XRUNLEN *pxrlStrRead01OR(prun, pjSrc, pjMask, pxlo, xLeft, xRght, xMask)
  933. *
  934. * Read the source, xlate colors, OR the pels and produce a run
  935. * list for a row of a 1BPP surface.
  936. *
  937. * History:
  938. * 27-Feb-1993 -by- Donald Sidoroff [donalds]
  939. * Wrote it.
  940. \**************************************************************************/
  941. XRUNLEN *pxrlStrRead01OR(
  942. STRDDA *pdda,
  943. STRRUN *prun,
  944. BYTE *pjSrc,
  945. BYTE *pjMask,
  946. XLATEOBJ *pxlo,
  947. LONG xLeft,
  948. LONG xRght,
  949. LONG xMask)
  950. {
  951. XRUNLEN *pxrl = &prun->xrl;
  952. ULONG *pulSrc;
  953. ULONG ulSrc;
  954. ULONG iBlack;
  955. ULONG iWhite;
  956. LONG cLeft;
  957. LONG iLeft;
  958. LONG cnt;
  959. LONG i;
  960. LONG j;
  961. DONTUSE(pjMask);
  962. DONTUSE(xMask);
  963. cLeft = xLeft >> 5; // Index of leftmost DWORD
  964. iLeft = xLeft & 31; // Bits used in leftmost DWORD
  965. pulSrc = ((DWORD *) pjSrc) + cLeft; // Adjust base address
  966. // To prevent derefences of the XLATE, do it upfront. We can easily do
  967. // this on monochrome bitmaps.
  968. if (pxlo == NULL)
  969. {
  970. iBlack = 0;
  971. iWhite = 1;
  972. }
  973. else
  974. {
  975. iBlack = pxlo->pulXlate[0];
  976. iWhite = pxlo->pulXlate[1];
  977. }
  978. i = 0;
  979. j = 0;
  980. pxrl->xPos = pdda->rcl.left;
  981. pxrl->cRun = pdda->rcl.right - pxrl->xPos;
  982. ulSrc = *pulSrc;
  983. if (xLeft < xRght)
  984. {
  985. while (TRUE)
  986. {
  987. if (!(ulSrc & gaulMaskMono[iLeft]))
  988. {
  989. cnt = pdda->al[i++];
  990. if (!cnt)
  991. pxrl->aul[j] |= iBlack;
  992. else
  993. while (cnt--)
  994. pxrl->aul[j++] |= iBlack;
  995. }
  996. else
  997. {
  998. cnt = pdda->al[i++];
  999. if (!cnt)
  1000. pxrl->aul[j] |= iWhite;
  1001. else
  1002. while (cnt--)
  1003. pxrl->aul[j++] |= iWhite;
  1004. }
  1005. xLeft++;
  1006. iLeft++;
  1007. if (xLeft >= xRght)
  1008. break;
  1009. if (iLeft & 32)
  1010. {
  1011. pulSrc++;
  1012. ulSrc = *pulSrc;
  1013. iLeft = 0;
  1014. }
  1015. }
  1016. }
  1017. return((XRUNLEN *) &pxrl->aul[j]);
  1018. }
  1019. /******************************Public*Routine******************************\
  1020. * XRUNLEN *pxrlStrRead04OR(prun, pjSrc, pjMask, pxlo, xLeft, xRght, xMask)
  1021. *
  1022. * Read the source, xlate colors, OR the pels and produce a run
  1023. * list for a row of a 4BPP surface.
  1024. *
  1025. * History:
  1026. * 13-Apr-1993 -by- Donald Sidoroff [donalds]
  1027. * Wrote it.
  1028. \**************************************************************************/
  1029. XRUNLEN *pxrlStrRead04OR(
  1030. STRDDA *pdda,
  1031. STRRUN *prun,
  1032. BYTE *pjSrc,
  1033. BYTE *pjMask,
  1034. XLATEOBJ *pxlo,
  1035. LONG xLeft,
  1036. LONG xRght,
  1037. LONG xMask)
  1038. {
  1039. XRUNLEN *pxrl = &prun->xrl;
  1040. ULONG *pulSrc;
  1041. ULONG ulSrc;
  1042. ULONG iColor;
  1043. LONG cLeft;
  1044. LONG iLeft;
  1045. LONG cnt;
  1046. LONG i;
  1047. LONG j;
  1048. DONTUSE(pjMask);
  1049. DONTUSE(xMask);
  1050. cLeft = xLeft >> 3; // Index of leftmost DWORD
  1051. iLeft = xLeft & 7; // Nybbles used in leftmost DWORD
  1052. pulSrc = ((DWORD *) pjSrc) + cLeft; // Adjust base address
  1053. ulSrc = *pulSrc;
  1054. i = 0;
  1055. j = 0;
  1056. pxrl->xPos = pdda->rcl.left;
  1057. pxrl->cRun = pdda->rcl.right - pxrl->xPos;
  1058. if (pxlo == NULL)
  1059. {
  1060. if (xLeft < xRght)
  1061. {
  1062. while (TRUE)
  1063. {
  1064. iColor = (ulSrc & gaulMaskQuad[iLeft]) >> gaulShftQuad[iLeft];
  1065. cnt = pdda->al[i++];
  1066. if (!cnt)
  1067. pxrl->aul[j] |= iColor;
  1068. else
  1069. while (cnt--)
  1070. pxrl->aul[j++] |= iColor;
  1071. xLeft++;
  1072. iLeft++;
  1073. if (xLeft >= xRght)
  1074. break;
  1075. if (iLeft & 8)
  1076. {
  1077. pulSrc++;
  1078. ulSrc = *pulSrc;
  1079. iLeft = 0;
  1080. }
  1081. }
  1082. }
  1083. }
  1084. else
  1085. {
  1086. if (xLeft < xRght)
  1087. {
  1088. while (TRUE)
  1089. {
  1090. iColor = pxlo->pulXlate[(ulSrc & gaulMaskQuad[iLeft]) >> gaulShftQuad[iLeft]];
  1091. cnt = pdda->al[i++];
  1092. if (!cnt)
  1093. pxrl->aul[j] |= iColor;
  1094. else
  1095. while (cnt--)
  1096. pxrl->aul[j++] |= iColor;
  1097. xLeft++;
  1098. iLeft++;
  1099. if (xLeft >= xRght)
  1100. break;
  1101. if (iLeft & 8)
  1102. {
  1103. pulSrc++;
  1104. ulSrc = *pulSrc;
  1105. iLeft = 0;
  1106. }
  1107. }
  1108. }
  1109. }
  1110. return((XRUNLEN *) &pxrl->aul[j]);
  1111. }
  1112. /******************************Public*Routine******************************\
  1113. * XRUNLEN *pxrlStrRead08OR(prun, pjSrc, pjMask, pxlo, xLeft, xRght, xMask)
  1114. *
  1115. * Read the source, xlate colors, OR the pels and produce a run
  1116. * list for a row of a 8BPP surface.
  1117. *
  1118. * History:
  1119. * 13-Apr-1993 -by- Donald Sidoroff [donalds]
  1120. * Wrote it.
  1121. \**************************************************************************/
  1122. XRUNLEN *pxrlStrRead08OR(
  1123. STRDDA *pdda,
  1124. STRRUN *prun,
  1125. BYTE *pjSrc,
  1126. BYTE *pjMask,
  1127. XLATEOBJ *pxlo,
  1128. LONG xLeft,
  1129. LONG xRght,
  1130. LONG xMask)
  1131. {
  1132. XRUNLEN *pxrl = &prun->xrl;
  1133. LONG cnt;
  1134. LONG i;
  1135. LONG j;
  1136. DONTUSE(pjMask);
  1137. DONTUSE(xMask);
  1138. pjSrc += xLeft;
  1139. pxrl->xPos = pdda->rcl.left;
  1140. pxrl->cRun = pdda->rcl.right - pdda->rcl.left;
  1141. i = 0;
  1142. j = 0;
  1143. if (pxlo == NULL)
  1144. while (xLeft != xRght)
  1145. {
  1146. cnt = pdda->al[i++];
  1147. if (!cnt)
  1148. pxrl->aul[j] |= *pjSrc;
  1149. else
  1150. while (cnt--)
  1151. pxrl->aul[j++] |= *pjSrc;
  1152. pjSrc++;
  1153. xLeft++;
  1154. }
  1155. else
  1156. while (xLeft != xRght)
  1157. {
  1158. cnt = pdda->al[i++];
  1159. if (!cnt)
  1160. pxrl->aul[j] |= pxlo->pulXlate[*pjSrc];
  1161. else
  1162. while (cnt--)
  1163. pxrl->aul[j++] |= pxlo->pulXlate[*pjSrc];
  1164. pjSrc++;
  1165. xLeft++;
  1166. }
  1167. return((XRUNLEN *) &pxrl->aul[j]);
  1168. }
  1169. /******************************Public*Routine******************************\
  1170. * XRUNLEN *pxrlStrRead16OR(prun, pjSrc, pjMask, pxlo, xLeft, xRght, xMask)
  1171. *
  1172. * Read the source, xlate colors, OR the pels and produce a run
  1173. * list for a row of a 16BPP surface.
  1174. *
  1175. * History:
  1176. * 13-Apr-1993 -by- Donald Sidoroff [donalds]
  1177. * Wrote it.
  1178. \**************************************************************************/
  1179. XRUNLEN *pxrlStrRead16OR(
  1180. STRDDA *pdda,
  1181. STRRUN *prun,
  1182. BYTE *pjSrc,
  1183. BYTE *pjMask,
  1184. XLATEOBJ *pxlo,
  1185. LONG xLeft,
  1186. LONG xRght,
  1187. LONG xMask)
  1188. {
  1189. XRUNLEN *pxrl = &prun->xrl;
  1190. WORD *pwSrc = (WORD *) pjSrc;
  1191. ULONG ulTmp;
  1192. LONG cnt;
  1193. LONG i;
  1194. LONG j;
  1195. DONTUSE(pjMask);
  1196. DONTUSE(xMask);
  1197. pwSrc += xLeft;
  1198. pxrl->xPos = pdda->rcl.left;
  1199. pxrl->cRun = pdda->rcl.right - pdda->rcl.left;
  1200. i = 0;
  1201. j = 0;
  1202. if (pxlo == NULL)
  1203. while (xLeft != xRght)
  1204. {
  1205. cnt = pdda->al[i++];
  1206. if (!cnt)
  1207. pxrl->aul[j] |= *pwSrc;
  1208. else
  1209. while (cnt--)
  1210. pxrl->aul[j++] |= *pwSrc;
  1211. pwSrc++;
  1212. xLeft++;
  1213. }
  1214. else
  1215. while (xLeft != xRght)
  1216. {
  1217. cnt = pdda->al[i++];
  1218. ulTmp = ((XLATE *) pxlo)->ulTranslate((ULONG) *pwSrc);
  1219. if (!cnt)
  1220. pxrl->aul[j] |= ulTmp;
  1221. else
  1222. while (cnt--)
  1223. pxrl->aul[j++] |= ulTmp;
  1224. pwSrc++;
  1225. xLeft++;
  1226. }
  1227. return((XRUNLEN *) &pxrl->aul[j]);
  1228. }
  1229. /******************************Public*Routine******************************\
  1230. * XRUNLEN *pxrlStrRead24OR(prun, pjSrc, pjMask, pxlo, xLeft, xRght, xMask)
  1231. *
  1232. * Read the source, xlate colors, OR the pels and produce a run
  1233. * list for a row of a 24BPP surface.
  1234. *
  1235. * History:
  1236. * 13-Apr-1993 -by- Donald Sidoroff [donalds]
  1237. * Wrote it.
  1238. \**************************************************************************/
  1239. XRUNLEN *pxrlStrRead24OR(
  1240. STRDDA *pdda,
  1241. STRRUN *prun,
  1242. BYTE *pjSrc,
  1243. BYTE *pjMask,
  1244. XLATEOBJ *pxlo,
  1245. LONG xLeft,
  1246. LONG xRght,
  1247. LONG xMask)
  1248. {
  1249. XRUNLEN *pxrl = &prun->xrl;
  1250. RGBTRIPLE *prgbSrc = (RGBTRIPLE *) pjSrc;
  1251. ULONG ulTmp = 0;
  1252. LONG cnt;
  1253. LONG i;
  1254. LONG j;
  1255. DONTUSE(pjMask);
  1256. DONTUSE(xMask);
  1257. prgbSrc += xLeft;
  1258. pxrl->xPos = pdda->rcl.left;
  1259. pxrl->cRun = pdda->rcl.right - pdda->rcl.left;
  1260. i = 0;
  1261. j = 0;
  1262. if (pxlo == NULL)
  1263. while (xLeft != xRght)
  1264. {
  1265. *((RGBTRIPLE *) &ulTmp) = *prgbSrc;
  1266. cnt = pdda->al[i++];
  1267. if (!cnt)
  1268. pxrl->aul[j] |= ulTmp;
  1269. else
  1270. while (cnt--)
  1271. pxrl->aul[j++] |= ulTmp;
  1272. prgbSrc++;
  1273. xLeft++;
  1274. }
  1275. else
  1276. while (xLeft != xRght)
  1277. {
  1278. cnt = pdda->al[i++];
  1279. *((RGBTRIPLE *) &ulTmp) = *prgbSrc;
  1280. ulTmp = ((XLATE *) pxlo)->ulTranslate(ulTmp);
  1281. if (!cnt)
  1282. pxrl->aul[j] |= ulTmp;
  1283. else
  1284. while (cnt--)
  1285. pxrl->aul[j++] |= ulTmp;
  1286. prgbSrc++;
  1287. xLeft++;
  1288. }
  1289. return((XRUNLEN *) &pxrl->aul[j]);
  1290. }
  1291. /******************************Public*Routine******************************\
  1292. * XRUNLEN *pxrlStrRead32OR(prun, pjSrc, pjMask, pxlo, xLeft, xRght, xMask)
  1293. *
  1294. * Read the source, xlate colors, OR the pels and produce a run
  1295. * list for a row of a 32BPP surface.
  1296. *
  1297. * History:
  1298. * 13-Apr-1993 -by- Donald Sidoroff [donalds]
  1299. * Wrote it.
  1300. \**************************************************************************/
  1301. XRUNLEN *pxrlStrRead32OR(
  1302. STRDDA *pdda,
  1303. STRRUN *prun,
  1304. BYTE *pjSrc,
  1305. BYTE *pjMask,
  1306. XLATEOBJ *pxlo,
  1307. LONG xLeft,
  1308. LONG xRght,
  1309. LONG xMask)
  1310. {
  1311. XRUNLEN *pxrl = &prun->xrl;
  1312. DWORD *pdwSrc = (DWORD *) pjSrc;
  1313. ULONG ulTmp;
  1314. LONG cnt;
  1315. LONG i;
  1316. LONG j;
  1317. DONTUSE(pjMask);
  1318. DONTUSE(xMask);
  1319. pdwSrc += xLeft;
  1320. pxrl->xPos = pdda->rcl.left;
  1321. pxrl->cRun = pdda->rcl.right - pdda->rcl.left;
  1322. i = 0;
  1323. j = 0;
  1324. if (pxlo == NULL)
  1325. while (xLeft != xRght)
  1326. {
  1327. cnt = pdda->al[i++];
  1328. if (!cnt)
  1329. pxrl->aul[j] |= *pdwSrc;
  1330. else
  1331. while (cnt--)
  1332. pxrl->aul[j++] |= *pdwSrc;
  1333. pdwSrc++;
  1334. xLeft++;
  1335. }
  1336. else
  1337. while (xLeft != xRght)
  1338. {
  1339. cnt = pdda->al[i++];
  1340. ulTmp = ((XLATE *) pxlo)->ulTranslate((ULONG) *pdwSrc);
  1341. if (!cnt)
  1342. pxrl->aul[j] |= ulTmp;
  1343. else
  1344. while (cnt--)
  1345. pxrl->aul[j++] |= ulTmp;
  1346. pdwSrc++;
  1347. xLeft++;
  1348. }
  1349. return((XRUNLEN *) &pxrl->aul[j]);
  1350. }
  1351. /******************************Public*Routine******************************\
  1352. * XRUNLEN *pxrlStrRead01(prun, pjSrc, pjMask, pxlo, xLeft, xRght, xMask)
  1353. *
  1354. * Read the source, mask it, xlate colors and produce a run list
  1355. * for a row of a 1BPP surface.
  1356. *
  1357. * History:
  1358. * 16-Feb-1993 -by- Donald Sidoroff [donalds]
  1359. * Wrote it.
  1360. \**************************************************************************/
  1361. XRUNLEN *pxrlStrRead01(
  1362. STRDDA *pdda,
  1363. STRRUN *prun,
  1364. BYTE *pjSrc,
  1365. BYTE *pjMask,
  1366. XLATEOBJ *pxlo,
  1367. LONG xLeft,
  1368. LONG xRght,
  1369. LONG xMask)
  1370. {
  1371. XRUNLEN *pxrl = &prun->xrl;
  1372. ULONG *pulMsk;
  1373. ULONG *pulSrc;
  1374. ULONG ulMsk;
  1375. ULONG ulSrc;
  1376. ULONG iBlack;
  1377. ULONG iWhite;
  1378. LONG xPos;
  1379. LONG cLeft;
  1380. LONG iLeft;
  1381. LONG iMask;
  1382. LONG cnt;
  1383. LONG i;
  1384. LONG j;
  1385. cLeft = xLeft >> 5; // Index of leftmost DWORD
  1386. iLeft = xLeft & 31; // Bits used in leftmost DWORD
  1387. pulSrc = ((DWORD *) pjSrc) + cLeft; // Adjust base address
  1388. ulSrc = *pulSrc;
  1389. // To prevent derefences of the XLATE, do it upfront. We can easily do
  1390. // this on monochrome bitmaps.
  1391. if (pxlo == NULL)
  1392. {
  1393. iBlack = 0;
  1394. iWhite = 1;
  1395. }
  1396. else
  1397. {
  1398. iBlack = pxlo->pulXlate[0];
  1399. iWhite = pxlo->pulXlate[1];
  1400. }
  1401. if (pjMask == (BYTE *) NULL)
  1402. {
  1403. i = 0;
  1404. j = 0;
  1405. pxrl->xPos = pdda->rcl.left;
  1406. pxrl->cRun = pdda->rcl.right - pxrl->xPos;
  1407. if (xLeft < xRght)
  1408. {
  1409. while (TRUE)
  1410. {
  1411. if (ulSrc & gaulMaskMono[iLeft])
  1412. for (cnt = pdda->al[i++]; cnt; cnt--)
  1413. prun->xrl.aul[j++] = iWhite;
  1414. else
  1415. for (cnt = pdda->al[i++]; cnt; cnt--)
  1416. prun->xrl.aul[j++] = iBlack;
  1417. xLeft++;
  1418. iLeft++;
  1419. if (xLeft >= xRght)
  1420. break;
  1421. if (iLeft & 32)
  1422. {
  1423. pulSrc++;
  1424. ulSrc = *pulSrc;
  1425. iLeft = 0;
  1426. }
  1427. }
  1428. }
  1429. return((XRUNLEN *) &pxrl->aul[j]);
  1430. }
  1431. // Compute initial state of mask
  1432. pulMsk = ((DWORD *) pjMask) + (xMask >> 5);
  1433. iMask = xMask & 31;
  1434. xPos = pdda->rcl.left;
  1435. ulMsk = *pulMsk;
  1436. i = 0;
  1437. j = 0;
  1438. if (xLeft < xRght)
  1439. {
  1440. while (TRUE)
  1441. {
  1442. if (ulMsk & gaulMaskMono[iMask])
  1443. {
  1444. if (ulSrc & gaulMaskMono[iLeft])
  1445. for (cnt = pdda->al[i]; cnt; cnt--)
  1446. pxrl->aul[j++] = iWhite;
  1447. else
  1448. for (cnt = pdda->al[i]; cnt; cnt--)
  1449. pxrl->aul[j++] = iBlack;
  1450. }
  1451. else
  1452. {
  1453. if (j > 0)
  1454. {
  1455. pxrl->xPos = xPos;
  1456. pxrl->cRun = j;
  1457. pxrl = (XRUNLEN *) &pxrl->aul[j];
  1458. xPos += j;
  1459. j = 0;
  1460. }
  1461. xPos += pdda->al[i];
  1462. }
  1463. xLeft++;
  1464. iLeft++;
  1465. iMask++;
  1466. i++;
  1467. if (xLeft >= xRght)
  1468. break;
  1469. if (iLeft & 32)
  1470. {
  1471. pulSrc++;
  1472. ulSrc = *pulSrc;
  1473. iLeft = 0;
  1474. }
  1475. if (iMask & 32)
  1476. {
  1477. pulMsk++;
  1478. ulMsk = *pulMsk;
  1479. iMask = 0;
  1480. }
  1481. }
  1482. }
  1483. if (j > 0)
  1484. {
  1485. pxrl->xPos = xPos;
  1486. pxrl->cRun = j;
  1487. pxrl = (XRUNLEN *) &pxrl->aul[j];
  1488. }
  1489. return(pxrl);
  1490. }
  1491. /******************************Public*Routine******************************\
  1492. * XRUNLEN *pxrlStrRead04(prun, pjSrc, pjMask, pxlo, xLeft, xRght, xMask)
  1493. *
  1494. * Read the source, mask it, xlate colors and produce a run list
  1495. * for a row of a 4BPP surface.
  1496. *
  1497. * History:
  1498. * 16-Feb-1993 -by- Donald Sidoroff [donalds]
  1499. * Wrote it.
  1500. \**************************************************************************/
  1501. XRUNLEN *pxrlStrRead04(
  1502. STRDDA *pdda,
  1503. STRRUN *prun,
  1504. BYTE *pjSrc,
  1505. BYTE *pjMask,
  1506. XLATEOBJ *pxlo,
  1507. LONG xLeft,
  1508. LONG xRght,
  1509. LONG xMask)
  1510. {
  1511. XRUNLEN *pxrl = &prun->xrl;
  1512. ULONG *pulMsk;
  1513. ULONG *pulSrc;
  1514. ULONG ulMsk;
  1515. ULONG ulSrc;
  1516. ULONG iColor;
  1517. LONG xPos;
  1518. LONG cLeft;
  1519. LONG iLeft;
  1520. LONG iMask;
  1521. LONG cnt;
  1522. LONG i;
  1523. LONG j;
  1524. cLeft = xLeft >> 3; // Index of leftmost DWORD
  1525. iLeft = xLeft & 7; // Nybbles used in leftmost DWORD
  1526. pulSrc = ((DWORD *) pjSrc) + cLeft; // Adjust base address
  1527. ulSrc = *pulSrc;
  1528. if (pjMask == (BYTE *) NULL)
  1529. {
  1530. i = 0;
  1531. j = 0;
  1532. pxrl->xPos = pdda->rcl.left;
  1533. pxrl->cRun = pdda->rcl.right - pxrl->xPos;
  1534. if (pxlo == NULL)
  1535. {
  1536. if (xLeft < xRght)
  1537. {
  1538. while (TRUE)
  1539. {
  1540. iColor = (ulSrc & gaulMaskQuad[iLeft]) >> gaulShftQuad[iLeft];
  1541. for (cnt = pdda->al[i++]; cnt; cnt--)
  1542. pxrl->aul[j++] = iColor;
  1543. xLeft++;
  1544. iLeft++;
  1545. if (xLeft >= xRght)
  1546. break;
  1547. if (iLeft & 8)
  1548. {
  1549. pulSrc++;
  1550. ulSrc = *pulSrc;
  1551. iLeft = 0;
  1552. }
  1553. }
  1554. }
  1555. }
  1556. else
  1557. {
  1558. if (xLeft < xRght)
  1559. {
  1560. while (TRUE)
  1561. {
  1562. iColor = pxlo->pulXlate[(ulSrc & gaulMaskQuad[iLeft]) >> gaulShftQuad[iLeft]];
  1563. for (cnt = pdda->al[i++]; cnt; cnt--)
  1564. pxrl->aul[j++] = iColor;
  1565. xLeft++;
  1566. iLeft++;
  1567. if (xLeft >= xRght)
  1568. break;
  1569. if (iLeft & 8)
  1570. {
  1571. pulSrc++;
  1572. ulSrc = *pulSrc;
  1573. iLeft = 0;
  1574. }
  1575. }
  1576. }
  1577. }
  1578. return((XRUNLEN *) &pxrl->aul[j]);
  1579. }
  1580. // Compute initial state of mask
  1581. pulMsk = ((DWORD *) pjMask) + (xMask >> 5);
  1582. iMask = xMask & 31;
  1583. xPos = pdda->rcl.left;
  1584. ulMsk = *pulMsk;
  1585. i = 0;
  1586. j = 0;
  1587. if (xLeft < xRght)
  1588. {
  1589. while (TRUE)
  1590. {
  1591. iColor = (ulSrc & gaulMaskQuad[iLeft]) >> gaulShftQuad[iLeft];
  1592. if (pxlo != NULL)
  1593. iColor = pxlo->pulXlate[iColor];
  1594. if (ulMsk & gaulMaskMono[iMask])
  1595. {
  1596. for (cnt = pdda->al[i]; cnt; cnt--)
  1597. pxrl->aul[j++] = iColor;
  1598. }
  1599. else
  1600. {
  1601. if (j > 0)
  1602. {
  1603. pxrl->xPos = xPos;
  1604. pxrl->cRun = j;
  1605. pxrl = (XRUNLEN *) &pxrl->aul[j];
  1606. xPos += j;
  1607. j = 0;
  1608. }
  1609. xPos += pdda->al[i];
  1610. }
  1611. xLeft++;
  1612. iLeft++;
  1613. iMask++;
  1614. i++;
  1615. if (xLeft >= xRght)
  1616. break;
  1617. if (iLeft & 8)
  1618. {
  1619. pulSrc++;
  1620. ulSrc = *pulSrc;
  1621. iLeft = 0;
  1622. }
  1623. if (iMask & 32)
  1624. {
  1625. pulMsk++;
  1626. ulMsk = *pulMsk;
  1627. iMask = 0;
  1628. }
  1629. }
  1630. }
  1631. if (j > 0)
  1632. {
  1633. pxrl->xPos = xPos;
  1634. pxrl->cRun = j;
  1635. pxrl = (XRUNLEN *) &pxrl->aul[j];
  1636. }
  1637. return(pxrl);
  1638. }
  1639. /******************************Public*Routine******************************\
  1640. * XRUNLEN *pxrlStrRead08(prun, pjSrc, pjMask, pxlo, xLeft, xRght, xMask)
  1641. *
  1642. * Read the source, mask it, xlate colors and produce a run list
  1643. * for a row of a 8BPP surface.
  1644. *
  1645. * History:
  1646. * 16-Feb-1993 -by- Donald Sidoroff [donalds]
  1647. * Wrote it.
  1648. \**************************************************************************/
  1649. XRUNLEN *pxrlStrRead08(
  1650. STRDDA *pdda,
  1651. STRRUN *prun,
  1652. BYTE *pjSrc,
  1653. BYTE *pjMask,
  1654. XLATEOBJ *pxlo,
  1655. LONG xLeft,
  1656. LONG xRght,
  1657. LONG xMask)
  1658. {
  1659. XRUNLEN *pxrl = &prun->xrl;
  1660. ULONG *pulMsk;
  1661. ULONG ulMsk;
  1662. ULONG iColor;
  1663. LONG xPos;
  1664. LONG iMask;
  1665. LONG cnt;
  1666. LONG i;
  1667. LONG j;
  1668. pjSrc += xLeft;
  1669. if (pjMask == (BYTE *) NULL)
  1670. {
  1671. pxrl->xPos = pdda->rcl.left;
  1672. pxrl->cRun = pdda->rcl.right - pdda->rcl.left;
  1673. i = 0;
  1674. j = 0;
  1675. if (pxlo == NULL)
  1676. while (xLeft != xRght)
  1677. {
  1678. for (cnt = pdda->al[i++]; cnt; cnt--)
  1679. pxrl->aul[j++] = *pjSrc;
  1680. pjSrc++;
  1681. xLeft++;
  1682. }
  1683. else
  1684. while (xLeft != xRght)
  1685. {
  1686. for (cnt = pdda->al[i++]; cnt; cnt--)
  1687. pxrl->aul[j++] = pxlo->pulXlate[*pjSrc];
  1688. pjSrc++;
  1689. xLeft++;
  1690. }
  1691. return((XRUNLEN *) &pxrl->aul[j]);
  1692. }
  1693. // Compute initial state of mask
  1694. pulMsk = ((DWORD *) pjMask) + (xMask >> 5);
  1695. iMask = xMask & 31;
  1696. xPos = pdda->rcl.left;
  1697. ulMsk = *pulMsk;
  1698. i = 0;
  1699. j = 0;
  1700. if (xLeft < xRght)
  1701. {
  1702. while(TRUE)
  1703. {
  1704. iColor = (DWORD) *pjSrc++;
  1705. if (pxlo != NULL)
  1706. iColor = pxlo->pulXlate[iColor];
  1707. if (ulMsk & gaulMaskMono[iMask])
  1708. {
  1709. for (cnt = pdda->al[i]; cnt; cnt--)
  1710. pxrl->aul[j++] = iColor;
  1711. }
  1712. else
  1713. {
  1714. if (j > 0)
  1715. {
  1716. pxrl->xPos = xPos;
  1717. pxrl->cRun = j;
  1718. pxrl = (XRUNLEN *) &pxrl->aul[j];
  1719. xPos += j;
  1720. j = 0;
  1721. }
  1722. xPos += pdda->al[i];
  1723. }
  1724. xLeft++;
  1725. iMask++;
  1726. i++;
  1727. if(xLeft >= xRght)
  1728. break;
  1729. if (iMask & 32)
  1730. {
  1731. pulMsk++;
  1732. ulMsk = *pulMsk;
  1733. iMask = 0;
  1734. }
  1735. }
  1736. }
  1737. if (j > 0)
  1738. {
  1739. pxrl->xPos = xPos;
  1740. pxrl->cRun = j;
  1741. pxrl = (XRUNLEN *) &pxrl->aul[j];
  1742. }
  1743. return(pxrl);
  1744. }
  1745. /******************************Public*Routine******************************\
  1746. * XRUNLEN *pxrlStrRead16(prun, pjSrc, pjMask, pxlo, xLeft, xRght, xMask)
  1747. *
  1748. * Read the source, mask it, xlate colors and produce a run list
  1749. * for a row of a 16BPP surface.
  1750. *
  1751. * History:
  1752. * 16-Feb-1993 -by- Donald Sidoroff [donalds]
  1753. * Wrote it.
  1754. \**************************************************************************/
  1755. XRUNLEN *pxrlStrRead16(
  1756. STRDDA *pdda,
  1757. STRRUN *prun,
  1758. BYTE *pjSrc,
  1759. BYTE *pjMask,
  1760. XLATEOBJ *pxlo,
  1761. LONG xLeft,
  1762. LONG xRght,
  1763. LONG xMask)
  1764. {
  1765. XRUNLEN *pxrl = &prun->xrl;
  1766. WORD *pwSrc = (WORD *) pjSrc;
  1767. ULONG *pulMsk;
  1768. ULONG ulMsk;
  1769. ULONG ulTmp;
  1770. ULONG iColor;
  1771. LONG xPos;
  1772. LONG iMask;
  1773. LONG cnt;
  1774. LONG i;
  1775. LONG j;
  1776. pwSrc += xLeft;
  1777. if (pjMask == (BYTE *) NULL)
  1778. {
  1779. pxrl->xPos = pdda->rcl.left;
  1780. pxrl->cRun = pdda->rcl.right - pdda->rcl.left;
  1781. i = 0;
  1782. j = 0;
  1783. if (pxlo == NULL)
  1784. while (xLeft != xRght)
  1785. {
  1786. for (cnt = pdda->al[i++]; cnt; cnt--)
  1787. pxrl->aul[j++] = *pwSrc;
  1788. pwSrc++;
  1789. xLeft++;
  1790. }
  1791. else
  1792. while (xLeft != xRght)
  1793. {
  1794. cnt = pdda->al[i++];
  1795. if (cnt)
  1796. {
  1797. ulTmp = ((XLATE *) pxlo)->ulTranslate((ULONG) *pwSrc);
  1798. while (cnt--)
  1799. pxrl->aul[j++] = ulTmp;
  1800. }
  1801. pwSrc++;
  1802. xLeft++;
  1803. }
  1804. return((XRUNLEN *) &pxrl->aul[j]);
  1805. }
  1806. // Compute initial state of mask
  1807. pulMsk = ((DWORD *) pjMask) + (xMask >> 5);
  1808. iMask = xMask & 31;
  1809. xPos = pdda->rcl.left;
  1810. ulMsk = *pulMsk;
  1811. i = 0;
  1812. j = 0;
  1813. if (xLeft < xRght)
  1814. {
  1815. while(TRUE)
  1816. {
  1817. iColor = (DWORD) *pwSrc++;
  1818. if (pxlo != NULL)
  1819. iColor = ((XLATE *) pxlo)->ulTranslate(iColor);
  1820. if (ulMsk & gaulMaskMono[iMask])
  1821. {
  1822. for (cnt = pdda->al[i]; cnt; cnt--)
  1823. pxrl->aul[j++] = iColor;
  1824. }
  1825. else
  1826. {
  1827. if (j > 0)
  1828. {
  1829. pxrl->xPos = xPos;
  1830. pxrl->cRun = j;
  1831. pxrl = (XRUNLEN *) &pxrl->aul[j];
  1832. xPos += j;
  1833. j = 0;
  1834. }
  1835. xPos += pdda->al[i];
  1836. }
  1837. xLeft++;
  1838. iMask++;
  1839. i++;
  1840. if (xLeft >= xRght)
  1841. break;
  1842. if (iMask & 32)
  1843. {
  1844. pulMsk++;
  1845. ulMsk = *pulMsk;
  1846. iMask = 0;
  1847. }
  1848. }
  1849. }
  1850. if (j > 0)
  1851. {
  1852. pxrl->xPos = xPos;
  1853. pxrl->cRun = j;
  1854. pxrl = (XRUNLEN *) &pxrl->aul[j];
  1855. }
  1856. return(pxrl);
  1857. }
  1858. /******************************Public*Routine******************************\
  1859. * XRUNLEN *pxrlStrRead24(prun, pjSrc, pjMask, pxlo, xLeft, xRght, xMask)
  1860. *
  1861. * Read the source, mask it, xlate colors and produce a run list
  1862. * for a row of a 24BPP surface.
  1863. *
  1864. * History:
  1865. * 16-Feb-1993 -by- Donald Sidoroff [donalds]
  1866. * Wrote it.
  1867. \**************************************************************************/
  1868. XRUNLEN *pxrlStrRead24(
  1869. STRDDA *pdda,
  1870. STRRUN *prun,
  1871. BYTE *pjSrc,
  1872. BYTE *pjMask,
  1873. XLATEOBJ *pxlo,
  1874. LONG xLeft,
  1875. LONG xRght,
  1876. LONG xMask)
  1877. {
  1878. XRUNLEN *pxrl = &prun->xrl;
  1879. RGBTRIPLE *prgbSrc = (RGBTRIPLE *) pjSrc;
  1880. ULONG *pulMsk;
  1881. ULONG ulTmp = 0;
  1882. ULONG ulMsk;
  1883. ULONG iColor = 0;
  1884. LONG iMask;
  1885. LONG xPos;
  1886. LONG cnt;
  1887. LONG i;
  1888. LONG j;
  1889. prgbSrc += xLeft;
  1890. if (pjMask == (BYTE *) NULL)
  1891. {
  1892. pxrl->xPos = pdda->rcl.left;
  1893. pxrl->cRun = pdda->rcl.right - pdda->rcl.left;
  1894. i = 0;
  1895. j = 0;
  1896. if (pxlo == NULL)
  1897. while (xLeft != xRght)
  1898. {
  1899. *((RGBTRIPLE *) &ulTmp) = *prgbSrc;
  1900. for (cnt = pdda->al[i++]; cnt; cnt--)
  1901. pxrl->aul[j++] = ulTmp;
  1902. prgbSrc++;
  1903. xLeft++;
  1904. }
  1905. else
  1906. while (xLeft != xRght)
  1907. {
  1908. cnt = pdda->al[i++];
  1909. if (cnt)
  1910. {
  1911. *((RGBTRIPLE *) &ulTmp) = *prgbSrc;
  1912. ulTmp = ((XLATE *) pxlo)->ulTranslate(ulTmp);
  1913. while (cnt--)
  1914. pxrl->aul[j++] = ulTmp;
  1915. }
  1916. prgbSrc++;
  1917. xLeft++;
  1918. }
  1919. return((XRUNLEN *) &pxrl->aul[j]);
  1920. }
  1921. // Compute initial state of mask
  1922. pulMsk = ((DWORD *) pjMask) + (xMask >> 5);
  1923. iMask = xMask & 31;
  1924. xPos = pdda->rcl.left;
  1925. ulMsk = *pulMsk;
  1926. i = 0;
  1927. j = 0;
  1928. if (xLeft < xRght)
  1929. {
  1930. while (TRUE)
  1931. {
  1932. *((RGBTRIPLE *) &iColor) = *prgbSrc++;
  1933. if (pxlo != NULL)
  1934. iColor = ((XLATE *) pxlo)->ulTranslate(iColor);
  1935. if (ulMsk & gaulMaskMono[iMask])
  1936. {
  1937. for (cnt = pdda->al[i]; cnt; cnt--)
  1938. pxrl->aul[j++] = iColor;
  1939. }
  1940. else
  1941. {
  1942. if (j > 0)
  1943. {
  1944. pxrl->xPos = xPos;
  1945. pxrl->cRun = j;
  1946. pxrl = (XRUNLEN *) &pxrl->aul[j];
  1947. xPos += j;
  1948. j = 0;
  1949. }
  1950. xPos += pdda->al[i];
  1951. }
  1952. xLeft++;
  1953. iMask++;
  1954. i++;
  1955. if (xLeft >= xRght)
  1956. break;
  1957. if (iMask & 32)
  1958. {
  1959. pulMsk++;
  1960. ulMsk = *pulMsk;
  1961. iMask = 0;
  1962. }
  1963. }
  1964. }
  1965. if (j > 0)
  1966. {
  1967. pxrl->xPos = xPos;
  1968. pxrl->cRun = j;
  1969. pxrl = (XRUNLEN *) &pxrl->aul[j];
  1970. }
  1971. return(pxrl);
  1972. }
  1973. /******************************Public*Routine******************************\
  1974. * XRUNLEN *pxrlStrRead32(prun, pjSrc, pjMask, pxlo, xLeft, xRght, xMask)
  1975. *
  1976. * Read the source, mask it, xlate colors and produce a run list
  1977. * for a row of a 32BPP surface.
  1978. *
  1979. * History:
  1980. * 16-Feb-1993 -by- Donald Sidoroff [donalds]
  1981. * Wrote it.
  1982. \**************************************************************************/
  1983. XRUNLEN *pxrlStrRead32(
  1984. STRDDA *pdda,
  1985. STRRUN *prun,
  1986. BYTE *pjSrc,
  1987. BYTE *pjMask,
  1988. XLATEOBJ *pxlo,
  1989. LONG xLeft,
  1990. LONG xRght,
  1991. LONG xMask)
  1992. {
  1993. XRUNLEN *pxrl = &prun->xrl;
  1994. DWORD *pdwSrc = (DWORD *) pjSrc;
  1995. ULONG *pulMsk;
  1996. ULONG ulTmp;
  1997. ULONG ulMsk;
  1998. ULONG iColor;
  1999. LONG xPos;
  2000. LONG iMask;
  2001. LONG cnt;
  2002. LONG i;
  2003. LONG j;
  2004. pdwSrc += xLeft;
  2005. if (pjMask == (BYTE *) NULL)
  2006. {
  2007. pxrl->xPos = pdda->rcl.left;
  2008. pxrl->cRun = pdda->rcl.right - pdda->rcl.left;
  2009. i = 0;
  2010. j = 0;
  2011. if (pxlo == NULL)
  2012. while (xLeft != xRght)
  2013. {
  2014. for (cnt = pdda->al[i++]; cnt; cnt--)
  2015. pxrl->aul[j++] = *pdwSrc;
  2016. pdwSrc++;
  2017. xLeft++;
  2018. }
  2019. else
  2020. while (xLeft != xRght)
  2021. {
  2022. cnt = pdda->al[i++];
  2023. if (cnt)
  2024. {
  2025. ulTmp = ((XLATE *) pxlo)->ulTranslate((ULONG) *pdwSrc);
  2026. while (cnt--)
  2027. pxrl->aul[j++] = ulTmp;
  2028. }
  2029. pdwSrc++;
  2030. xLeft++;
  2031. }
  2032. return((XRUNLEN *) &pxrl->aul[j]);
  2033. }
  2034. // Compute initial state of mask
  2035. pulMsk = ((DWORD *) pjMask) + (xMask >> 5);
  2036. iMask = xMask & 31;
  2037. xPos = pdda->rcl.left;
  2038. ulMsk = *pulMsk;
  2039. i = 0;
  2040. j = 0;
  2041. if (xLeft < xRght)
  2042. {
  2043. while (TRUE)
  2044. {
  2045. iColor = *pdwSrc++;
  2046. if (pxlo != NULL)
  2047. iColor = ((XLATE *) pxlo)->ulTranslate(iColor);
  2048. if (ulMsk & gaulMaskMono[iMask])
  2049. {
  2050. for (cnt = pdda->al[i]; cnt; cnt--)
  2051. pxrl->aul[j++] = iColor;
  2052. }
  2053. else
  2054. {
  2055. if (j > 0)
  2056. {
  2057. pxrl->xPos = xPos;
  2058. pxrl->cRun = j;
  2059. pxrl = (XRUNLEN *) &pxrl->aul[j];
  2060. xPos += j;
  2061. j = 0;
  2062. }
  2063. xPos += pdda->al[i];
  2064. }
  2065. xLeft++;
  2066. iMask++;
  2067. i++;
  2068. if (xLeft >= xRght)
  2069. break;
  2070. if (iMask & 32)
  2071. {
  2072. pulMsk++;
  2073. ulMsk = *pulMsk;
  2074. iMask = 0;
  2075. }
  2076. }
  2077. }
  2078. if (j > 0)
  2079. {
  2080. pxrl->xPos = xPos;
  2081. pxrl->cRun = j;
  2082. pxrl = (XRUNLEN *) &pxrl->aul[j];
  2083. }
  2084. return(pxrl);
  2085. }
  2086. /******************************Public*Routine******************************\
  2087. * VOID vStrWrite01(prun, prunEnd, pSurf, pco)
  2088. *
  2089. * Write the clipped run list of pels to the target 1BPP surface.
  2090. *
  2091. * History:
  2092. * 16-Feb-1993 -by- Donald Sidoroff [donalds]
  2093. * Wrote it.
  2094. \**************************************************************************/
  2095. VOID vStrWrite01(
  2096. STRRUN *prun,
  2097. XRUNLEN *pxrlEnd,
  2098. SURFACE *pSurf,
  2099. CLIPOBJ *pco)
  2100. {
  2101. XRUNLEN *pxrl = &prun->xrl;
  2102. DWORD *pjBase;
  2103. DWORD *pjCurr;
  2104. DWORD *pjDraw;
  2105. ULONG ulTemp;
  2106. ULONG ulMask;
  2107. LONG xLeft;
  2108. LONG xRght;
  2109. LONG yCurr;
  2110. LONG cLeft;
  2111. LONG cRght;
  2112. LONG cByte;
  2113. LONG iMask;
  2114. LONG iLeft;
  2115. LONG iRght;
  2116. LONG iRep;
  2117. LONG jDraw;
  2118. BOOL bValid;
  2119. // There maybe no clipping.
  2120. if (pco == (CLIPOBJ *) NULL)
  2121. {
  2122. pjBase = (DWORD *) ((BYTE *) pSurf->pvScan0() + pSurf->lDelta() * prun->yPos);
  2123. jDraw = 0;
  2124. while (pxrl != pxrlEnd)
  2125. {
  2126. xLeft = pxrl->xPos;
  2127. xRght = pxrl->cRun + xLeft;
  2128. pjDraw = pjCurr = pjBase + (xLeft >> 5);
  2129. iMask = xLeft & 31;
  2130. ulTemp = *pjDraw;
  2131. if (xLeft < xRght)
  2132. {
  2133. while (TRUE)
  2134. {
  2135. if (pxrl->aul[jDraw++])
  2136. ulTemp |= gaulMaskMono[iMask];
  2137. else
  2138. ulTemp &= ~gaulMaskMono[iMask];
  2139. iMask++;
  2140. xLeft++;
  2141. if (xLeft >= xRght)
  2142. break;
  2143. if (iMask & 32)
  2144. {
  2145. *pjDraw = ulTemp;
  2146. pjDraw++;
  2147. ulTemp = *pjDraw;
  2148. iMask = 0;
  2149. }
  2150. }
  2151. }
  2152. *pjDraw = ulTemp;
  2153. if (prun->cRep > 1)
  2154. {
  2155. iLeft = pxrl->xPos;
  2156. iRght = pxrl->cRun + iLeft;
  2157. cLeft = iLeft >> 5;
  2158. cRght = iRght >> 5;
  2159. iLeft &= 31;
  2160. iRght &= 31;
  2161. if (cLeft == cRght)
  2162. {
  2163. ulMask = gaulMaskEdge[iLeft] & ~gaulMaskEdge[iRght];
  2164. for (iRep = 1; iRep < prun->cRep; iRep++)
  2165. {
  2166. pjDraw = (DWORD *) ((BYTE *) pjCurr + pSurf->lDelta());
  2167. *pjDraw = (*pjCurr & ulMask) | (*pjDraw & ~ulMask);
  2168. pjCurr = pjDraw;
  2169. }
  2170. }
  2171. else
  2172. {
  2173. if (iLeft)
  2174. {
  2175. ulMask = ~gaulMaskEdge[iLeft];
  2176. ulTemp = *pjCurr & ~ulMask;
  2177. for (iRep = 1; iRep < prun->cRep; iRep++)
  2178. {
  2179. pjDraw = (DWORD *) ((BYTE *) pjCurr + pSurf->lDelta());
  2180. *pjDraw = ulTemp | (*pjDraw & ulMask);
  2181. pjCurr = pjDraw;
  2182. }
  2183. cLeft++;
  2184. }
  2185. if (cLeft != cRght)
  2186. {
  2187. pjCurr = pjBase + cLeft;
  2188. cByte = (cRght - cLeft) << 2;
  2189. for (iRep = 1; iRep < prun->cRep; iRep++)
  2190. {
  2191. pjDraw = (DWORD *) ((BYTE *) pjCurr + pSurf->lDelta());
  2192. RtlCopyMemory(pjDraw, pjCurr, cByte);
  2193. pjCurr = pjDraw;
  2194. }
  2195. }
  2196. if (iRght)
  2197. {
  2198. pjCurr = pjBase + cRght;
  2199. ulMask = gaulMaskEdge[iRght];
  2200. ulTemp = *pjCurr & ~ulMask;
  2201. for (iRep = 1; iRep < prun->cRep; iRep++)
  2202. {
  2203. pjDraw = (DWORD *) ((BYTE *) pjCurr + pSurf->lDelta());
  2204. *pjDraw = ulTemp | (*pjDraw & ulMask);
  2205. pjCurr = pjDraw;
  2206. }
  2207. }
  2208. }
  2209. }
  2210. pxrl = (XRUNLEN *) &pxrl->aul[pxrl->cRun];
  2211. jDraw = 0;
  2212. }
  2213. return;
  2214. }
  2215. // Setup the clipping code.
  2216. ((ECLIPOBJ *) pco)->cEnumStart(FALSE, CT_RECTANGLES, CD_ANY, 100);
  2217. RECTL rclClip;
  2218. rclClip.left = POS_INFINITY;
  2219. rclClip.top = POS_INFINITY;
  2220. rclClip.right = NEG_INFINITY;
  2221. rclClip.bottom = NEG_INFINITY;
  2222. yCurr = prun->yPos;
  2223. iRep = prun->cRep;
  2224. ((ECLIPOBJ *) pco)->vFindScan(&rclClip, yCurr);
  2225. pjBase = (DWORD *) ((BYTE *) pSurf->pvScan0() + pSurf->lDelta() * yCurr);
  2226. while (iRep--)
  2227. {
  2228. if ((yCurr >= rclClip.top) && (yCurr < rclClip.bottom))
  2229. {
  2230. jDraw = 0;
  2231. while (pxrl != pxrlEnd)
  2232. {
  2233. xLeft = pxrl->xPos;
  2234. xRght = pxrl->cRun + xLeft;
  2235. pjDraw = pjBase + (xLeft >> 5);
  2236. iMask = xLeft & 31;
  2237. bValid = ((xLeft >= 0) && (xLeft < pSurf->sizl().cx));
  2238. ulTemp = bValid ? *pjDraw : (ULONG) 0;
  2239. while (xLeft < xRght)
  2240. {
  2241. if ((xLeft < rclClip.left) || (xLeft >= rclClip.right))
  2242. ((ECLIPOBJ *) pco)->vFindSegment(&rclClip, xLeft, yCurr);
  2243. if ((xLeft >= rclClip.left) && (xLeft < rclClip.right))
  2244. {
  2245. if (pxrl->aul[jDraw])
  2246. ulTemp |= gaulMaskMono[iMask];
  2247. else
  2248. ulTemp &= ~gaulMaskMono[iMask];
  2249. }
  2250. iMask++;
  2251. xLeft++;
  2252. jDraw++;
  2253. if (iMask & 32)
  2254. {
  2255. if (bValid)
  2256. *pjDraw = ulTemp;
  2257. pjDraw++;
  2258. iMask = 0;
  2259. bValid = ((xLeft >= 0) && (xLeft < pSurf->sizl().cx));
  2260. ulTemp = bValid ? *pjDraw : (ULONG) 0;
  2261. }
  2262. }
  2263. if (bValid)
  2264. *pjDraw = ulTemp;
  2265. pxrl = (XRUNLEN *) &pxrl->aul[pxrl->cRun];
  2266. jDraw = 0;
  2267. }
  2268. pxrl = &prun->xrl;
  2269. }
  2270. pjBase = (DWORD *) ((BYTE *) pjBase + pSurf->lDelta());
  2271. yCurr++;
  2272. if ((yCurr < rclClip.top) || (yCurr >= rclClip.bottom))
  2273. ((ECLIPOBJ *) pco)->vFindScan(&rclClip, yCurr);
  2274. }
  2275. }
  2276. /******************************Public*Routine******************************\
  2277. * VOID vStrWrite04(prun, prunEnd, pSurf, pco)
  2278. *
  2279. * Write the clipped run list of pels to the target 4BPP surface.
  2280. *
  2281. * History:
  2282. * 16-Feb-1993 -by- Donald Sidoroff [donalds]
  2283. * Wrote it.
  2284. \**************************************************************************/
  2285. VOID vStrWrite04(
  2286. STRRUN *prun,
  2287. XRUNLEN *pxrlEnd,
  2288. SURFACE *pSurf,
  2289. CLIPOBJ *pco)
  2290. {
  2291. XRUNLEN *pxrl = &prun->xrl;
  2292. DWORD *pjBase;
  2293. DWORD *pjCurr;
  2294. DWORD *pjDraw;
  2295. ULONG ulTemp;
  2296. ULONG ulMask;
  2297. ULONG ulShft;
  2298. LONG xLeft;
  2299. LONG xRght;
  2300. LONG yCurr;
  2301. LONG cLeft;
  2302. LONG cRght;
  2303. LONG cByte;
  2304. LONG iMask;
  2305. LONG iLeft;
  2306. LONG iRght;
  2307. LONG iRep;
  2308. LONG jDraw;
  2309. BOOL bValid;
  2310. // There maybe no clipping.
  2311. if (pco == (CLIPOBJ *) NULL)
  2312. {
  2313. pjBase = (DWORD *) ((BYTE *) pSurf->pvScan0() + pSurf->lDelta() * prun->yPos);
  2314. jDraw = 0;
  2315. while (pxrl != pxrlEnd)
  2316. {
  2317. xLeft = pxrl->xPos;
  2318. xRght = pxrl->cRun + xLeft;
  2319. pjDraw = pjCurr = pjBase + (xLeft >> 3);
  2320. ulTemp = *pjDraw;
  2321. iMask = xLeft & 7;
  2322. if (xLeft < xRght)
  2323. {
  2324. while (TRUE)
  2325. {
  2326. ulShft = gaulShftQuad[iMask];
  2327. ulMask = gaulMaskQuad[iMask];
  2328. ulTemp = (ULONG) ((ulTemp & ~ulMask) |
  2329. ((pxrl->aul[jDraw++] << ulShft) & ulMask));
  2330. iMask++;
  2331. xLeft++;
  2332. if (xLeft >= xRght)
  2333. break;
  2334. if (iMask & 8)
  2335. {
  2336. *pjDraw = ulTemp;
  2337. pjDraw++;
  2338. ulTemp = *pjDraw;
  2339. iMask = 0;
  2340. }
  2341. }
  2342. }
  2343. *pjDraw = ulTemp;
  2344. if (prun->cRep > 1)
  2345. {
  2346. iLeft = pxrl->xPos;
  2347. iRght = pxrl->cRun + iLeft;
  2348. cLeft = iLeft >> 3;
  2349. cRght = iRght >> 3;
  2350. iLeft = (iLeft & 7) << 2;
  2351. iRght = (iRght & 7) << 2;
  2352. if (cLeft == cRght)
  2353. {
  2354. ulMask = gaulMaskEdge[iLeft] & ~gaulMaskEdge[iRght];
  2355. for (iRep = 1; iRep < prun->cRep; iRep++)
  2356. {
  2357. pjDraw = (DWORD *) ((BYTE *) pjCurr + pSurf->lDelta());
  2358. *pjDraw = (*pjCurr & ulMask) | (*pjDraw & ~ulMask);
  2359. pjCurr = pjDraw;
  2360. }
  2361. }
  2362. else
  2363. {
  2364. if (iLeft)
  2365. {
  2366. ulMask = ~gaulMaskEdge[iLeft];
  2367. ulTemp = *pjCurr & ~ulMask;
  2368. for (iRep = 1; iRep < prun->cRep; iRep++)
  2369. {
  2370. pjDraw = (DWORD *) ((BYTE *) pjCurr + pSurf->lDelta());
  2371. *pjDraw = ulTemp | (*pjDraw & ulMask);
  2372. pjCurr = pjDraw;
  2373. }
  2374. cLeft++;
  2375. }
  2376. if (cLeft != cRght)
  2377. {
  2378. pjCurr = pjBase + cLeft;
  2379. cByte = (cRght - cLeft) << 2;
  2380. for (iRep = 1; iRep < prun->cRep; iRep++)
  2381. {
  2382. pjDraw = (DWORD *) ((BYTE *) pjCurr + pSurf->lDelta());
  2383. RtlCopyMemory(pjDraw, pjCurr, cByte);
  2384. pjCurr = pjDraw;
  2385. }
  2386. }
  2387. if (iRght)
  2388. {
  2389. pjCurr = pjBase + cRght;
  2390. ulMask = gaulMaskEdge[iRght];
  2391. ulTemp = *pjCurr & ~ulMask;
  2392. for (iRep = 1; iRep < prun->cRep; iRep++)
  2393. {
  2394. pjDraw = (DWORD *) ((BYTE *) pjCurr + pSurf->lDelta());
  2395. *pjDraw = ulTemp | (*pjDraw & ulMask);
  2396. pjCurr = pjDraw;
  2397. }
  2398. }
  2399. }
  2400. }
  2401. pxrl = (XRUNLEN *) &pxrl->aul[pxrl->cRun];
  2402. jDraw = 0;
  2403. }
  2404. return;
  2405. }
  2406. // Setup the clipping code.
  2407. ((ECLIPOBJ *) pco)->cEnumStart(FALSE, CT_RECTANGLES, CD_ANY, 100);
  2408. RECTL rclClip;
  2409. rclClip.left = POS_INFINITY;
  2410. rclClip.top = POS_INFINITY;
  2411. rclClip.right = NEG_INFINITY;
  2412. rclClip.bottom = NEG_INFINITY;
  2413. yCurr = prun->yPos;
  2414. iRep = prun->cRep;
  2415. ((ECLIPOBJ *) pco)->vFindScan(&rclClip, yCurr);
  2416. pjBase = (DWORD *) ((BYTE *) pSurf->pvScan0() + pSurf->lDelta() * yCurr);
  2417. while (iRep--)
  2418. {
  2419. if ((yCurr >= rclClip.top) && (yCurr < rclClip.bottom))
  2420. {
  2421. jDraw = 0;
  2422. while (pxrl != pxrlEnd)
  2423. {
  2424. xLeft = pxrl->xPos;
  2425. xRght = pxrl->cRun + xLeft;
  2426. pjDraw = pjBase + (xLeft >> 3);
  2427. iMask = xLeft & 7;
  2428. bValid = ((xLeft >= 0) && (xLeft < pSurf->sizl().cx));
  2429. ulTemp = bValid ? *pjDraw : (ULONG) 0;
  2430. while (xLeft < xRght)
  2431. {
  2432. if ((xLeft < rclClip.left) || (xLeft >= rclClip.right))
  2433. ((ECLIPOBJ *) pco)->vFindSegment(&rclClip, xLeft, yCurr);
  2434. if ((xLeft >= rclClip.left) && (xLeft < rclClip.right))
  2435. {
  2436. ulMask = gaulMaskQuad[iMask];
  2437. ulShft = gaulShftQuad[iMask];
  2438. ulTemp = (ULONG) ((ulTemp & ~ulMask) |
  2439. ((pxrl->aul[jDraw] << ulShft) & ulMask));
  2440. }
  2441. iMask++;
  2442. xLeft++;
  2443. jDraw++;
  2444. if (iMask & 8)
  2445. {
  2446. if (bValid)
  2447. *pjDraw = ulTemp;
  2448. pjDraw++;
  2449. iMask = 0;
  2450. bValid = ((xLeft >= 0) && (xLeft < pSurf->sizl().cx));
  2451. ulTemp = bValid ? *pjDraw : (ULONG) 0;
  2452. }
  2453. }
  2454. if (bValid)
  2455. *pjDraw = ulTemp;
  2456. pxrl = (XRUNLEN *) &pxrl->aul[pxrl->cRun];
  2457. jDraw = 0;
  2458. }
  2459. pxrl = &prun->xrl;
  2460. }
  2461. pjBase = (DWORD *) ((BYTE *) pjBase + pSurf->lDelta());
  2462. yCurr++;
  2463. if ((yCurr < rclClip.top) || (yCurr >= rclClip.bottom))
  2464. ((ECLIPOBJ *) pco)->vFindScan(&rclClip, yCurr);
  2465. }
  2466. }
  2467. /******************************Public*Routine******************************\
  2468. * VOID vStrWrite08(prun, prunEnd, pSurf, pco)
  2469. *
  2470. * Write the clipped run list of pels to the target 8BPP surface.
  2471. *
  2472. * History:
  2473. * 16-Feb-1993 -by- Donald Sidoroff [donalds]
  2474. * Wrote it.
  2475. \**************************************************************************/
  2476. VOID vStrWrite08(
  2477. STRRUN *prun,
  2478. XRUNLEN *pxrlEnd,
  2479. SURFACE *pSurf,
  2480. CLIPOBJ *pco)
  2481. {
  2482. XRUNLEN *pxrl = &prun->xrl;
  2483. BYTE *pjBase;
  2484. BYTE *pjCurr;
  2485. BYTE *pjDraw;
  2486. LONG xLeft;
  2487. LONG xRght;
  2488. LONG yCurr;
  2489. LONG iTop;
  2490. LONG iBot;
  2491. LONG iRep;
  2492. LONG jLeft;
  2493. LONG jRght;
  2494. LONG jDraw;
  2495. LONG jByte;
  2496. // See if this can be handled without clipping.
  2497. if (pco == (CLIPOBJ *) NULL)
  2498. {
  2499. pjBase = (BYTE *) pSurf->pvScan0() + pSurf->lDelta() * prun->yPos;
  2500. while (pxrl != pxrlEnd)
  2501. {
  2502. xLeft = pxrl->xPos;
  2503. xRght = pxrl->cRun + xLeft;
  2504. jDraw = 0;
  2505. pjDraw = pjCurr = pjBase + xLeft;
  2506. while (xLeft < xRght)
  2507. {
  2508. *pjDraw++ = (BYTE) pxrl->aul[jDraw++];
  2509. xLeft++;
  2510. }
  2511. for (jDraw = 1; jDraw < prun->cRep; jDraw++)
  2512. {
  2513. RtlCopyMemory(pjCurr + pSurf->lDelta(), pjCurr, pxrl->cRun);
  2514. pjCurr += pSurf->lDelta();
  2515. }
  2516. pxrl = (XRUNLEN *) &pxrl->aul[pxrl->cRun];
  2517. }
  2518. return;
  2519. }
  2520. RECTL rclClip;
  2521. if (pco->iDComplexity == DC_RECT)
  2522. {
  2523. rclClip = pco->rclBounds;
  2524. iTop = prun->yPos;
  2525. iBot = prun->yPos + prun->cRep;
  2526. if ((iTop >= rclClip.bottom) || (iBot <= rclClip.top))
  2527. return;
  2528. iTop = iTop >= rclClip.top ? iTop : rclClip.top;
  2529. iBot = iBot < rclClip.bottom ? iBot : rclClip.bottom;
  2530. iRep = iBot - iTop;
  2531. pjBase = (BYTE *) pSurf->pvScan0() + pSurf->lDelta() * iTop;
  2532. while (pxrl != pxrlEnd)
  2533. {
  2534. xLeft = pxrl->xPos;
  2535. xRght = pxrl->cRun + xLeft;
  2536. if (xRght < rclClip.left)
  2537. {
  2538. pxrl = (XRUNLEN *) &pxrl->aul[pxrl->cRun];
  2539. continue;
  2540. }
  2541. if (xLeft >= rclClip.right)
  2542. return;
  2543. jLeft = xLeft >= rclClip.left ? xLeft : rclClip.left;
  2544. jRght = xRght < rclClip.right ? xRght : rclClip.right;
  2545. jByte = jRght - jLeft;
  2546. pjDraw = pjCurr = pjBase + jLeft;
  2547. jDraw = jLeft - xLeft;
  2548. while (jLeft < jRght)
  2549. {
  2550. *pjDraw++ = (BYTE) pxrl->aul[jDraw++];
  2551. jLeft++;
  2552. }
  2553. for (jDraw = 1; jDraw < iRep; jDraw++)
  2554. {
  2555. RtlCopyMemory(pjCurr + pSurf->lDelta(), pjCurr, jByte);
  2556. pjCurr += pSurf->lDelta();
  2557. }
  2558. pxrl = (XRUNLEN *) &pxrl->aul[pxrl->cRun];
  2559. }
  2560. return;
  2561. }
  2562. // There is complex clipping. Set up the clipping code.
  2563. ((ECLIPOBJ *) pco)->cEnumStart(FALSE, CT_RECTANGLES, CD_ANY, 100);
  2564. rclClip.left = POS_INFINITY;
  2565. rclClip.top = POS_INFINITY;
  2566. rclClip.right = NEG_INFINITY;
  2567. rclClip.bottom = NEG_INFINITY;
  2568. yCurr = prun->yPos;
  2569. iRep = prun->cRep;
  2570. ((ECLIPOBJ *) pco)->vFindScan(&rclClip, yCurr);
  2571. pjBase = (BYTE *) pSurf->pvScan0() + pSurf->lDelta() * yCurr;
  2572. while (iRep--)
  2573. {
  2574. if ((yCurr >= rclClip.top) && (yCurr < rclClip.bottom))
  2575. {
  2576. jDraw = 0;
  2577. while (pxrl != pxrlEnd)
  2578. {
  2579. xLeft = pxrl->xPos;
  2580. xRght = pxrl->cRun + xLeft;
  2581. pjDraw = pjCurr = pjBase + xLeft;
  2582. while (xLeft < xRght)
  2583. {
  2584. if ((xLeft < rclClip.left) || (xLeft >= rclClip.right))
  2585. ((ECLIPOBJ *) pco)->vFindSegment(&rclClip, xLeft, yCurr);
  2586. if ((xLeft >= rclClip.left) && (xLeft < rclClip.right))
  2587. *pjDraw = (BYTE) pxrl->aul[jDraw];
  2588. pjDraw++;
  2589. jDraw++;
  2590. xLeft++;
  2591. }
  2592. pxrl = (XRUNLEN *) &pxrl->aul[pxrl->cRun];
  2593. jDraw = 0;
  2594. }
  2595. pxrl = &prun->xrl;
  2596. }
  2597. pjBase += pSurf->lDelta();
  2598. yCurr++;
  2599. if ((yCurr < rclClip.top) || (yCurr >= rclClip.bottom))
  2600. ((ECLIPOBJ *) pco)->vFindScan(&rclClip, yCurr);
  2601. }
  2602. }
  2603. /******************************Public*Routine******************************\
  2604. * VOID vStrWrite16(prun, prunEnd, pSurf, pco)
  2605. *
  2606. * Write the clipped run list of pels to the target 16BPP surface.
  2607. *
  2608. * History:
  2609. * 16-Feb-1993 -by- Donald Sidoroff [donalds]
  2610. * Wrote it.
  2611. \**************************************************************************/
  2612. VOID vStrWrite16(
  2613. STRRUN *prun,
  2614. XRUNLEN *pxrlEnd,
  2615. SURFACE *pSurf,
  2616. CLIPOBJ *pco)
  2617. {
  2618. XRUNLEN *pxrl = &prun->xrl;
  2619. WORD *pjBase;
  2620. WORD *pjCurr;
  2621. WORD *pjDraw;
  2622. LONG xLeft;
  2623. LONG xRght;
  2624. LONG yCurr;
  2625. LONG iTop;
  2626. LONG iBot;
  2627. LONG iRep;
  2628. LONG jLeft;
  2629. LONG jRght;
  2630. LONG jDraw;
  2631. LONG jByte;
  2632. // See if this can be handled without clipping.
  2633. if (pco == (CLIPOBJ *) NULL)
  2634. {
  2635. pjBase = (WORD *) ((BYTE *) pSurf->pvScan0() + pSurf->lDelta() * prun->yPos);
  2636. while (pxrl != pxrlEnd)
  2637. {
  2638. xLeft = pxrl->xPos;
  2639. xRght = pxrl->cRun + xLeft;
  2640. jDraw = 0;
  2641. pjDraw = pjCurr = pjBase + xLeft;
  2642. while (xLeft < xRght)
  2643. {
  2644. *pjDraw++ = (WORD) pxrl->aul[jDraw++];
  2645. xLeft++;
  2646. }
  2647. for (jDraw = 1; jDraw < prun->cRep; jDraw++)
  2648. {
  2649. pjDraw = (WORD *) ((BYTE *) pjCurr + pSurf->lDelta());
  2650. RtlCopyMemory(pjDraw, pjCurr, pxrl->cRun * 2);
  2651. pjCurr = pjDraw;
  2652. }
  2653. pxrl = (XRUNLEN *) &pxrl->aul[pxrl->cRun];
  2654. }
  2655. return;
  2656. }
  2657. RECTL rclClip;
  2658. if (pco->iDComplexity == DC_RECT)
  2659. {
  2660. rclClip = pco->rclBounds;
  2661. iTop = prun->yPos;
  2662. iBot = prun->yPos + prun->cRep;
  2663. if ((iTop >= rclClip.bottom) || (iBot <= rclClip.top))
  2664. return;
  2665. iTop = iTop >= rclClip.top ? iTop : rclClip.top;
  2666. iBot = iBot < rclClip.bottom ? iBot : rclClip.bottom;
  2667. iRep = iBot - iTop;
  2668. pjBase = (WORD *) ((BYTE *) pSurf->pvScan0() + pSurf->lDelta() * iTop);
  2669. while (pxrl != pxrlEnd)
  2670. {
  2671. xLeft = pxrl->xPos;
  2672. xRght = pxrl->cRun + xLeft;
  2673. if (xRght < rclClip.left)
  2674. {
  2675. pxrl = (XRUNLEN *) &pxrl->aul[pxrl->cRun];
  2676. continue;
  2677. }
  2678. if (xLeft >= rclClip.right)
  2679. return;
  2680. jLeft = xLeft >= rclClip.left ? xLeft : rclClip.left;
  2681. jRght = xRght < rclClip.right ? xRght : rclClip.right;
  2682. jByte = jRght - jLeft;
  2683. pjDraw = pjCurr = pjBase + jLeft;
  2684. jDraw = jLeft - xLeft;
  2685. while (jLeft < jRght)
  2686. {
  2687. *pjDraw++ = (WORD) pxrl->aul[jDraw++];
  2688. jLeft++;
  2689. }
  2690. for (jDraw = 1; jDraw < iRep; jDraw++)
  2691. {
  2692. pjDraw = (WORD *) ((BYTE *) pjCurr + pSurf->lDelta());
  2693. RtlCopyMemory(pjDraw, pjCurr, jByte * 2);
  2694. pjCurr = pjDraw;
  2695. }
  2696. pxrl = (XRUNLEN *) &pxrl->aul[pxrl->cRun];
  2697. }
  2698. return;
  2699. }
  2700. // There is complex clipping. Set up the clipping code.
  2701. ((ECLIPOBJ *) pco)->cEnumStart(FALSE, CT_RECTANGLES, CD_ANY, 100);
  2702. rclClip.left = POS_INFINITY;
  2703. rclClip.top = POS_INFINITY;
  2704. rclClip.right = NEG_INFINITY;
  2705. rclClip.bottom = NEG_INFINITY;
  2706. yCurr = prun->yPos;
  2707. iRep = prun->cRep;
  2708. ((ECLIPOBJ *) pco)->vFindScan(&rclClip, yCurr);
  2709. pjBase = (WORD *) ((BYTE *) pSurf->pvScan0() + pSurf->lDelta() * yCurr);
  2710. while (iRep--)
  2711. {
  2712. if ((yCurr >= rclClip.top) && (yCurr < rclClip.bottom))
  2713. {
  2714. jDraw = 0;
  2715. while (pxrl != pxrlEnd)
  2716. {
  2717. xLeft = pxrl->xPos;
  2718. xRght = pxrl->cRun + xLeft;
  2719. pjDraw = pjCurr = pjBase + xLeft;
  2720. while (xLeft < xRght)
  2721. {
  2722. if ((xLeft < rclClip.left) || (xLeft >= rclClip.right))
  2723. ((ECLIPOBJ *) pco)->vFindSegment(&rclClip, xLeft, yCurr);
  2724. if ((xLeft >= rclClip.left) && (xLeft < rclClip.right))
  2725. *pjDraw = (WORD) pxrl->aul[jDraw];
  2726. pjDraw++;
  2727. jDraw++;
  2728. xLeft++;
  2729. }
  2730. pxrl = (XRUNLEN *) &pxrl->aul[pxrl->cRun];
  2731. jDraw = 0;
  2732. }
  2733. pxrl = &prun->xrl;
  2734. }
  2735. pjBase = (WORD *) ((BYTE *) pjBase + pSurf->lDelta());
  2736. yCurr++;
  2737. if ((yCurr < rclClip.top) || (yCurr >= rclClip.bottom))
  2738. ((ECLIPOBJ *) pco)->vFindScan(&rclClip, yCurr);
  2739. }
  2740. }
  2741. /******************************Public*Routine******************************\
  2742. * VOID vStrWrite24(prun, prunEnd, pSurf, pco)
  2743. *
  2744. * Write the clipped run list of pels to the target 24BPP surface.
  2745. *
  2746. * History:
  2747. * 16-Feb-1993 -by- Donald Sidoroff [donalds]
  2748. * Wrote it.
  2749. \**************************************************************************/
  2750. VOID vStrWrite24(
  2751. STRRUN *prun,
  2752. XRUNLEN *pxrlEnd,
  2753. SURFACE *pSurf,
  2754. CLIPOBJ *pco)
  2755. {
  2756. XRUNLEN *pxrl = &prun->xrl;
  2757. RGBTRIPLE *pjBase;
  2758. RGBTRIPLE *pjCurr;
  2759. RGBTRIPLE *pjDraw;
  2760. LONG xLeft;
  2761. LONG xRght;
  2762. LONG yCurr;
  2763. LONG iTop;
  2764. LONG iBot;
  2765. LONG iRep;
  2766. LONG jLeft;
  2767. LONG jRght;
  2768. LONG jDraw;
  2769. LONG jByte;
  2770. // See if this can be handled without clipping.
  2771. if (pco == (CLIPOBJ *) NULL)
  2772. {
  2773. pjBase = (RGBTRIPLE *) ((BYTE *) pSurf->pvScan0() + pSurf->lDelta() * prun->yPos);
  2774. while (pxrl != pxrlEnd)
  2775. {
  2776. xLeft = pxrl->xPos;
  2777. xRght = pxrl->cRun + xLeft;
  2778. jDraw = 0;
  2779. pjDraw = pjCurr = pjBase + xLeft;
  2780. while (xLeft < xRght)
  2781. {
  2782. *pjDraw++ = *((RGBTRIPLE *) &pxrl->aul[jDraw++]);
  2783. xLeft++;
  2784. }
  2785. for (jDraw = 1; jDraw < prun->cRep; jDraw++)
  2786. {
  2787. pjDraw = (RGBTRIPLE *) ((BYTE *) pjCurr + pSurf->lDelta());
  2788. RtlCopyMemory(pjDraw, pjCurr, pxrl->cRun * 3);
  2789. pjCurr = pjDraw;
  2790. }
  2791. pxrl = (XRUNLEN *) &pxrl->aul[pxrl->cRun];
  2792. }
  2793. return;
  2794. }
  2795. RECTL rclClip;
  2796. if (pco->iDComplexity == DC_RECT)
  2797. {
  2798. rclClip = pco->rclBounds;
  2799. iTop = prun->yPos;
  2800. iBot = prun->yPos + prun->cRep;
  2801. if ((iTop >= rclClip.bottom) || (iBot <= rclClip.top))
  2802. return;
  2803. iTop = iTop >= rclClip.top ? iTop : rclClip.top;
  2804. iBot = iBot < rclClip.bottom ? iBot : rclClip.bottom;
  2805. iRep = iBot - iTop;
  2806. pjBase = (RGBTRIPLE *) ((BYTE *) pSurf->pvScan0() + pSurf->lDelta() * iTop);
  2807. while (pxrl != pxrlEnd)
  2808. {
  2809. xLeft = pxrl->xPos;
  2810. xRght = pxrl->cRun + xLeft;
  2811. if (xRght < rclClip.left)
  2812. {
  2813. pxrl = (XRUNLEN *) &pxrl->aul[pxrl->cRun];
  2814. continue;
  2815. }
  2816. if (xLeft >= rclClip.right)
  2817. return;
  2818. jLeft = xLeft >= rclClip.left ? xLeft : rclClip.left;
  2819. jRght = xRght < rclClip.right ? xRght : rclClip.right;
  2820. jByte = jRght - jLeft;
  2821. pjDraw = pjCurr = pjBase + jLeft;
  2822. jDraw = jLeft - xLeft;
  2823. while (jLeft < jRght)
  2824. {
  2825. *pjDraw++ = *((RGBTRIPLE *) &pxrl->aul[jDraw++]);
  2826. jLeft++;
  2827. }
  2828. for (jDraw = 1; jDraw < iRep; jDraw++)
  2829. {
  2830. pjDraw = (RGBTRIPLE *) ((BYTE *) pjCurr + pSurf->lDelta());
  2831. RtlCopyMemory(pjDraw, pjCurr, jByte * 3);
  2832. pjCurr = pjDraw;
  2833. }
  2834. pxrl = (XRUNLEN *) &pxrl->aul[pxrl->cRun];
  2835. }
  2836. return;
  2837. }
  2838. // There is complex clipping. Set up the clipping code.
  2839. ((ECLIPOBJ *) pco)->cEnumStart(FALSE, CT_RECTANGLES, CD_ANY, 100);
  2840. rclClip.left = POS_INFINITY;
  2841. rclClip.top = POS_INFINITY;
  2842. rclClip.right = NEG_INFINITY;
  2843. rclClip.bottom = NEG_INFINITY;
  2844. yCurr = prun->yPos;
  2845. iRep = prun->cRep;
  2846. ((ECLIPOBJ *) pco)->vFindScan(&rclClip, yCurr);
  2847. pjBase = (RGBTRIPLE *) ((BYTE *) pSurf->pvScan0() + pSurf->lDelta() * yCurr);
  2848. while (iRep--)
  2849. {
  2850. if ((yCurr >= rclClip.top) && (yCurr < rclClip.bottom))
  2851. {
  2852. jDraw = 0;
  2853. while (pxrl != pxrlEnd)
  2854. {
  2855. xLeft = pxrl->xPos;
  2856. xRght = pxrl->cRun + xLeft;
  2857. pjDraw = pjCurr = pjBase + xLeft;
  2858. while (xLeft < xRght)
  2859. {
  2860. if ((xLeft < rclClip.left) || (xLeft >= rclClip.right))
  2861. ((ECLIPOBJ *) pco)->vFindSegment(&rclClip, xLeft, yCurr);
  2862. if ((xLeft >= rclClip.left) && (xLeft < rclClip.right))
  2863. *pjDraw = *((RGBTRIPLE *) &pxrl->aul[jDraw]);
  2864. pjDraw++;
  2865. jDraw++;
  2866. xLeft++;
  2867. }
  2868. pxrl = (XRUNLEN *) &pxrl->aul[pxrl->cRun];
  2869. jDraw = 0;
  2870. }
  2871. pxrl = &prun->xrl;
  2872. }
  2873. pjBase = (RGBTRIPLE *) ((BYTE *) pjBase + pSurf->lDelta());
  2874. yCurr++;
  2875. if ((yCurr < rclClip.top) || (yCurr >= rclClip.bottom))
  2876. ((ECLIPOBJ *) pco)->vFindScan(&rclClip, yCurr);
  2877. }
  2878. }
  2879. /******************************Public*Routine******************************\
  2880. * VOID vStrWrite32(prun, prunEnd, pSurf, pco)
  2881. *
  2882. * Write the clipped run list of pels to the target 32BPP surface.
  2883. *
  2884. * History:
  2885. * 16-Feb-1993 -by- Donald Sidoroff [donalds]
  2886. * Wrote it.
  2887. \**************************************************************************/
  2888. VOID vStrWrite32(
  2889. STRRUN *prun,
  2890. XRUNLEN *pxrlEnd,
  2891. SURFACE *pSurf,
  2892. CLIPOBJ *pco)
  2893. {
  2894. XRUNLEN *pxrl = &prun->xrl;
  2895. DWORD *pjBase;
  2896. DWORD *pjCurr;
  2897. DWORD *pjDraw;
  2898. LONG xLeft;
  2899. LONG xRght;
  2900. LONG yCurr;
  2901. LONG iTop;
  2902. LONG iBot;
  2903. LONG iRep;
  2904. LONG jLeft;
  2905. LONG jRght;
  2906. LONG jDraw;
  2907. LONG jByte;
  2908. // See if this can be handled without clipping.
  2909. if (pco == (CLIPOBJ *) NULL)
  2910. {
  2911. pjBase = (DWORD *) ((BYTE *) pSurf->pvScan0() + pSurf->lDelta() * prun->yPos);
  2912. while (pxrl != pxrlEnd)
  2913. {
  2914. xLeft = pxrl->xPos;
  2915. xRght = pxrl->cRun + xLeft;
  2916. jDraw = 0;
  2917. pjDraw = pjCurr = pjBase + xLeft;
  2918. while (xLeft < xRght)
  2919. {
  2920. *pjDraw++ = (DWORD) pxrl->aul[jDraw++];
  2921. xLeft++;
  2922. }
  2923. for (jDraw = 1; jDraw < prun->cRep; jDraw++)
  2924. {
  2925. pjDraw = (DWORD *) ((BYTE *) pjCurr + pSurf->lDelta());
  2926. RtlCopyMemory(pjDraw, pjCurr, pxrl->cRun * 4);
  2927. pjCurr = pjDraw;
  2928. }
  2929. pxrl = (XRUNLEN *) &pxrl->aul[pxrl->cRun];
  2930. }
  2931. return;
  2932. }
  2933. RECTL rclClip;
  2934. if (pco->iDComplexity == DC_RECT)
  2935. {
  2936. rclClip = pco->rclBounds;
  2937. iTop = prun->yPos;
  2938. iBot = prun->yPos + prun->cRep;
  2939. if ((iTop >= rclClip.bottom) || (iBot <= rclClip.top))
  2940. return;
  2941. iTop = iTop >= rclClip.top ? iTop : rclClip.top;
  2942. iBot = iBot < rclClip.bottom ? iBot : rclClip.bottom;
  2943. iRep = iBot - iTop;
  2944. pjBase = (DWORD *) ((BYTE *) pSurf->pvScan0() + pSurf->lDelta() * iTop);
  2945. while (pxrl != pxrlEnd)
  2946. {
  2947. xLeft = pxrl->xPos;
  2948. xRght = pxrl->cRun + xLeft;
  2949. if (xRght < rclClip.left)
  2950. {
  2951. pxrl = (XRUNLEN *) &pxrl->aul[pxrl->cRun];
  2952. continue;
  2953. }
  2954. if (xLeft >= rclClip.right)
  2955. return;
  2956. jLeft = xLeft >= rclClip.left ? xLeft : rclClip.left;
  2957. jRght = xRght < rclClip.right ? xRght : rclClip.right;
  2958. jByte = jRght - jLeft;
  2959. pjDraw = pjCurr = pjBase + jLeft;
  2960. jDraw = jLeft - xLeft;
  2961. while (jLeft < jRght)
  2962. {
  2963. *pjDraw++ = (DWORD) pxrl->aul[jDraw++];
  2964. jLeft++;
  2965. }
  2966. for (jDraw = 1; jDraw < iRep; jDraw++)
  2967. {
  2968. pjDraw = (DWORD *) ((BYTE *) pjCurr + pSurf->lDelta());
  2969. RtlCopyMemory(pjDraw, pjCurr, jByte * 4);
  2970. pjCurr = pjDraw;
  2971. }
  2972. pxrl = (XRUNLEN *) &pxrl->aul[pxrl->cRun];
  2973. }
  2974. return;
  2975. }
  2976. // There is complex clipping. Set up the clipping code.
  2977. ((ECLIPOBJ *) pco)->cEnumStart(FALSE, CT_RECTANGLES, CD_ANY, 100);
  2978. rclClip.left = POS_INFINITY;
  2979. rclClip.top = POS_INFINITY;
  2980. rclClip.right = NEG_INFINITY;
  2981. rclClip.bottom = NEG_INFINITY;
  2982. yCurr = prun->yPos;
  2983. iRep = prun->cRep;
  2984. ((ECLIPOBJ *) pco)->vFindScan(&rclClip, yCurr);
  2985. pjBase = (DWORD *) ((BYTE *) pSurf->pvScan0() + pSurf->lDelta() * yCurr);
  2986. while (iRep--)
  2987. {
  2988. if ((yCurr >= rclClip.top) && (yCurr < rclClip.bottom))
  2989. {
  2990. jDraw = 0;
  2991. while (pxrl != pxrlEnd)
  2992. {
  2993. xLeft = pxrl->xPos;
  2994. xRght = pxrl->cRun + xLeft;
  2995. pjDraw = pjCurr = pjBase + xLeft;
  2996. while (xLeft < xRght)
  2997. {
  2998. if ((xLeft < rclClip.left) || (xLeft >= rclClip.right))
  2999. ((ECLIPOBJ *) pco)->vFindSegment(&rclClip, xLeft, yCurr);
  3000. if ((xLeft >= rclClip.left) && (xLeft < rclClip.right))
  3001. *pjDraw = (DWORD) pxrl->aul[jDraw];
  3002. pjDraw++;
  3003. jDraw++;
  3004. xLeft++;
  3005. }
  3006. pxrl = (XRUNLEN *) &pxrl->aul[pxrl->cRun];
  3007. jDraw = 0;
  3008. }
  3009. pxrl = &prun->xrl;
  3010. }
  3011. pjBase = (DWORD *) ((BYTE *) pjBase + pSurf->lDelta());
  3012. yCurr++;
  3013. if ((yCurr < rclClip.top) || (yCurr >= rclClip.bottom))
  3014. ((ECLIPOBJ *) pco)->vFindScan(&rclClip, yCurr);
  3015. }
  3016. }