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.

418 lines
11 KiB

  1. /******************************Module*Header*******************************\
  2. * Module Name: textxlg.c
  3. *
  4. *
  5. * Copyright (c) 1995-1999 Microsoft Corporation
  6. \**************************************************************************/
  7. #if 0
  8. The following code assumes that the gray glyphs comming from the
  9. font driver have DWORD aligned scans.....
  10. /******************************Public*Routine******************************\
  11. *
  12. * Routine Name
  13. *
  14. * draw_gray_nf_ntb_o_to_temp_start
  15. *
  16. * Routine Description:
  17. *
  18. * The input glyphs are 4-bpp gray scale bitmaps that are DWORD aligned.
  19. * Specialized glyph dispatch routine for non-fixed pitch, top and
  20. * bottom not aligned glyphs that do overlap. This routine calculates
  21. * the glyph's position on the temp buffer, then determines the correct
  22. * highly specialized routine to be used to draw each glyph based on
  23. * the glyph width, alignment and rotation
  24. *
  25. * Arguments:
  26. *
  27. * pGlyphPos - Pointer to first in list of GLYPHPOS structs
  28. * cGlyph - Number of glyphs to draw
  29. * pjDst - Pointer to temp 4Bpp buffer to draw into
  30. * ulLeftEdge - left edge of TextRect & 0xfffffff8
  31. * This is equal to the position of the left
  32. * edge rounded down to the nearest 32-bit
  33. * aligned boundary (8 pixels / DWORD)
  34. * dpDst - Scan line Delta for TempBuffer (always pos)
  35. *
  36. * Return Value:
  37. *
  38. * None
  39. *
  40. \**************************************************************************/
  41. VOID
  42. draw_gray_nf_ntb_o_to_temp_start(
  43. PGLYPHPOS pGlyphPos,
  44. ULONG cGlyphs,
  45. PUCHAR pjDst,
  46. ULONG ulLeftEdge,
  47. ULONG dpDst,
  48. ULONG ulCharInc,
  49. ULONG ulTempTop
  50. )
  51. {
  52. GLYPHBITS *pgb; // pointer to current GLYPHBITS
  53. int x; // pixel offset of the left edge of the glyph bitmap
  54. // from the left edge of the output (4-bpp) bitmap
  55. int y; // the pixel offset of the top edge of the glyph
  56. // bitmap from the top edge of the output bitmap.
  57. GLYPHPOS *pgpOut; // sentinel for loop
  58. void (*apfnGray[8])(ULONG*,ptrdiff_t,ULONG*,ULONG*,ptrdiff_t);
  59. /**/DbgPrint(
  60. /**/ "draw_gray_nf_ntb_o_to_temp_start(\n"
  61. /**/ " PGLYPHPOS pGlyphPos = %-#x\n"
  62. /**/ " ULONG cGlyphs = %u\n"
  63. /**/ " PUCHAR pjDst = %-#x\n"
  64. /**/ " ULONG ulLeftEdge = %u\n"
  65. /**/ " ULONG dpDst = %-#x\n"
  66. /**/ " ULONG ulCharInc = %u\n"
  67. /**/ " ULONG ulTempTop = %u\n"
  68. /**/ " )\n"
  69. /**/);
  70. /**/DbgBreakPoint();
  71. for (pgpOut = pGlyphPos + cGlyphs; pGlyphPos < pgpOut; pGlyphPos++)
  72. {
  73. ULONG *pulSrcScan;
  74. ptrdiff_t dpulSrcScan;
  75. pgb = pGlyphPos->pgdf->pgb;
  76. x = pGlyphPos->ptl.x + pgb->ptlOrigin.x - ulLeftEdge;
  77. y = pGlyphPos->ptl.y + pgb->ptlOrigin.y - ulTempTop ;
  78. pulSrcScan = (ULONG*) &(pgb->aj[0]);
  79. dpulSrcScan = (ptrdiff_t) (pgb->sizlBitmap.cx + 7)/8;
  80. //
  81. // dispatch to the appropriate function
  82. //
  83. /**/ DbgPrint(
  84. /**/ "pgb = %-#x\n"
  85. /**/ "x = %d\n"
  86. /**/ "y = %d\n"
  87. /**/ "pulSrcScan = %-#x\n"
  88. /**/ "dpulSrcScan = %u = %-#x\n"
  89. /**/ , pgb
  90. /**/ , x
  91. /**/ , y
  92. /**/ , pulSrcScan
  93. /**/ , dpulSrcScan
  94. /**/ );
  95. /**/ DbgBreakPoint();
  96. (*apfnGray[x & 0x07]) (
  97. pulSrcScan ,
  98. dpulSrcScan ,
  99. pulSrcScan + dpulSrcScan * (unsigned) pgb->sizlBitmap.cy ,
  100. (ULONG*) (pjDst + y * dpDst) + ( x / 8) ,
  101. (ptrdiff_t) dpDst / sizeof(ULONG)
  102. );
  103. }
  104. }
  105. void
  106. vOrShiftGrayGlyph0(
  107. ULONG *pulSrcScan
  108. , ptrdiff_t dpulSrcScan
  109. , ULONG *pulSrcScanOut
  110. , ULONG *pulDstScan
  111. , ptrdiff_t dpulDstScan
  112. )
  113. {
  114. for (
  115. ; pulSrcScan < pulSrcScanOut
  116. ; pulDstScan += dpulDstScan,
  117. pulSrcScan += dpulSrcScan
  118. )
  119. {
  120. ULONG *pulSrc, *pulDst, *pulSrcOut;
  121. for (
  122. pulDst = pulDstScan,
  123. pulSrc = pulSrcScan,
  124. pulSrcOut = pulSrcScan + dpulSrcScan
  125. ; pulSrc < pulSrcOut
  126. ; pulDst++,
  127. pulSrc++
  128. )
  129. {
  130. *pulDst |= *pulSrc;
  131. }
  132. }
  133. }
  134. void
  135. vOrShiftGrayGlyph2(
  136. ULONG *pulSrcScan
  137. , ptrdiff_t dpulSrcScan
  138. , ULONG *pulSrcScanOut
  139. , ULONG *pulDstScan
  140. , ptrdiff_t dpulDstScan
  141. )
  142. {
  143. for (
  144. ; pulSrcScan < pulSrcScanOut
  145. ; pulDstScan += dpulDstScan,
  146. pulSrcScan += dpulSrcScan
  147. )
  148. {
  149. ULONG *pulSrc, *pulDst, *pulSrcOut;
  150. ULONG b = 0;
  151. for (
  152. pulDst = pulDstScan,
  153. pulSrc = pulSrcScan,
  154. pulSrcOut = pulSrcScan + dpulSrcScan
  155. ; pulSrc < pulSrcOut
  156. ; pulDst++,
  157. pulSrc++
  158. )
  159. {
  160. ULONG a = *pulSrc;
  161. *pulDst |= (a << 4*2) + (b >> (32-4*2));
  162. b = a;
  163. }
  164. }
  165. }
  166. void
  167. vOrShiftGrayGlyph4(
  168. ULONG *pulSrcScan
  169. , ptrdiff_t dpulSrcScan
  170. , ULONG *pulSrcScanOut
  171. , ULONG *pulDstScan
  172. , ptrdiff_t dpulDstScan
  173. )
  174. {
  175. for (
  176. ; pulSrcScan < pulSrcScanOut
  177. ; pulDstScan += dpulDstScan,
  178. pulSrcScan += dpulSrcScan
  179. )
  180. {
  181. ULONG *pulSrc, *pulDst, *pulSrcOut;
  182. ULONG b = 0;
  183. for (
  184. pulDst = pulDstScan,
  185. pulSrc = pulSrcScan,
  186. pulSrcOut = pulSrcScan + dpulSrcScan
  187. ; pulSrc < pulSrcOut
  188. ; pulDst++,
  189. pulSrc++
  190. )
  191. {
  192. ULONG a = *pulSrc;
  193. *pulDst |= (a << 4*4) + (b >> (32-4*4));
  194. b = a;
  195. }
  196. }
  197. }
  198. void
  199. vOrShiftGrayGlyph6(
  200. ULONG *pulSrcScan
  201. , ptrdiff_t dpulSrcScan
  202. , ULONG *pulSrcScanOut
  203. , ULONG *pulDstScan
  204. , ptrdiff_t dpulDstScan
  205. )
  206. {
  207. for (
  208. ; pulSrcScan < pulSrcScanOut
  209. ; pulDstScan += dpulDstScan,
  210. pulSrcScan += dpulSrcScan
  211. )
  212. {
  213. ULONG *pulSrc, *pulDst, *pulSrcOut;
  214. ULONG b = 0;
  215. for (
  216. pulDst = pulDstScan,
  217. pulSrc = pulSrcScan,
  218. pulSrcOut = pulSrcScan + dpulSrcScan
  219. ; pulSrc < pulSrcOut
  220. ; pulDst++,
  221. pulSrc++
  222. )
  223. {
  224. ULONG a = *pulSrc;
  225. *pulDst |= (a << 4*6) + (b >> (32-4*6));
  226. b = a;
  227. }
  228. }
  229. }
  230. #define MASK_0 0x0f0f0f0f
  231. #define MASK_1 0xf0f0f0f0
  232. void
  233. vOrShiftGrayGlyph1(
  234. ULONG *pulSrcScan
  235. , ptrdiff_t dpulSrcScan
  236. , ULONG *pulSrcScanOut
  237. , ULONG *pulDstScan
  238. , ptrdiff_t dpulDstScan
  239. )
  240. {
  241. for (
  242. ; pulSrcScan < pulSrcScanOut
  243. ; pulDstScan += dpulDstScan,
  244. pulSrcScan += dpulSrcScan
  245. )
  246. {
  247. ULONG *pulSrc, *pulDst, *pulSrcOut;
  248. ULONG b = 0;
  249. for (
  250. pulDst = pulDstScan,
  251. pulSrc = pulSrcScan,
  252. pulSrcOut = pulSrcScan + dpulSrcScan
  253. ; pulSrc < pulSrcOut
  254. ; pulDst++,
  255. pulSrc++
  256. )
  257. {
  258. ULONG u;
  259. ULONG a = *pulSrc;
  260. u = (a & MASK_0) << 12;
  261. u |= (b & MASK_0) >> 20;
  262. u |= (a & MASK_1) >> 4;
  263. u |= (b & MASK_1) << 28;
  264. *pulDst = u;
  265. b = a;
  266. }
  267. }
  268. }
  269. void
  270. vOrShiftGrayGlyph3(
  271. ULONG *pulSrcScan
  272. , ptrdiff_t dpulSrcScan
  273. , ULONG *pulSrcScanOut
  274. , ULONG *pulDstScan
  275. , ptrdiff_t dpulDstScan
  276. )
  277. {
  278. for (
  279. ; pulSrcScan < pulSrcScanOut
  280. ; pulDstScan += dpulDstScan,
  281. pulSrcScan += dpulSrcScan
  282. )
  283. {
  284. ULONG *pulSrc, *pulDst, *pulSrcOut;
  285. ULONG b = 0;
  286. for (
  287. pulDst = pulDstScan,
  288. pulSrc = pulSrcScan,
  289. pulSrcOut = pulSrcScan + dpulSrcScan
  290. ; pulSrc < pulSrcOut
  291. ; pulDst++,
  292. pulSrc++
  293. )
  294. {
  295. ULONG u;
  296. ULONG a = *pulSrc;
  297. u = (a & MASK_0) << 20;
  298. u |= (b & MASK_0) >> 12;
  299. u |= (a & 0x00f0f0f0) << 4;
  300. u |= (b & MASK_1) >> 28;
  301. *pulDst = u;
  302. b = a;
  303. }
  304. }
  305. }
  306. void
  307. vOrShiftGrayGlyph5(
  308. ULONG *pulSrcScan
  309. , ptrdiff_t dpulSrcScan
  310. , ULONG *pulSrcScanOut
  311. , ULONG *pulDstScan
  312. , ptrdiff_t dpulDstScan
  313. )
  314. {
  315. for (
  316. ; pulSrcScan < pulSrcScanOut
  317. ; pulDstScan += dpulDstScan,
  318. pulSrcScan += dpulSrcScan
  319. )
  320. {
  321. ULONG *pulSrc, *pulDst, *pulSrcOut;
  322. ULONG b = 0;
  323. for (
  324. pulDst = pulDstScan,
  325. pulSrc = pulSrcScan,
  326. pulSrcOut = pulSrcScan + dpulSrcScan
  327. ; pulSrc < pulSrcOut
  328. ; pulDst++,
  329. pulSrc++
  330. )
  331. {
  332. ULONG u;
  333. ULONG a = *pulSrc;
  334. u = (a & MASK_0) << 28;
  335. u |= (b & MASK_0) >> 4;
  336. u |= (a & MASK_1) << 4;
  337. u |= (b & MASK_1) >> 28;
  338. *pulDst = u;
  339. b = a;
  340. }
  341. }
  342. }
  343. void
  344. vOrShiftGrayGlyph7(
  345. ULONG *pulSrcScan
  346. , ptrdiff_t dpulSrcScan
  347. , ULONG *pulSrcScanOut
  348. , ULONG *pulDstScan
  349. , ptrdiff_t dpulDstScan
  350. )
  351. {
  352. for (
  353. ; pulSrcScan < pulSrcScanOut
  354. ; pulDstScan += dpulDstScan,
  355. pulSrcScan += dpulSrcScan
  356. )
  357. {
  358. ULONG *pulSrc, *pulDst, *pulSrcOut;
  359. ULONG b = 0;
  360. for (
  361. pulDst = pulDstScan,
  362. pulSrc = pulSrcScan,
  363. pulSrcOut = pulSrcScan + dpulSrcScan
  364. ; pulSrc < pulSrcOut
  365. ; pulDst++,
  366. pulSrc++
  367. )
  368. {
  369. ULONG u;
  370. ULONG a = *pulSrc;
  371. u = (a & MASK_0) >> 28;
  372. u |= (b & MASK_0) << 4;
  373. u |= (a & MASK_1) << 20;
  374. u |= (b & MASK_1) >> 12;
  375. *pulDst = u;
  376. b = a;
  377. }
  378. }
  379. }
  380. void (*apfnGray[8])(ULONG*,ptrdiff_t,ULONG*,ULONG*,ptrdiff_t) =
  381. {
  382. vOrShiftGrayGlyph0
  383. ,vOrShiftGrayGlyph1
  384. ,vOrShiftGrayGlyph2
  385. ,vOrShiftGrayGlyph3
  386. ,vOrShiftGrayGlyph4
  387. ,vOrShiftGrayGlyph5
  388. ,vOrShiftGrayGlyph6
  389. ,vOrShiftGrayGlyph7
  390. };
  391. #endif