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.

2248 lines
64 KiB

  1. /*++
  2. Copyright (c) 1990-1991 Microsoft Corporation
  3. Module Name:
  4. htsetbmp.c
  5. Abstract:
  6. This module is used to provide set of functions to set the bits into the
  7. final destination bitmap.
  8. Author:
  9. 11-Nov-1998 Wed 09:27:34 updated -by- Daniel Chou (danielc)
  10. Re-write for anti-aliasing
  11. 28-Mar-1992 Sat 20:59:29 updated -by- Daniel Chou (danielc)
  12. Add Support for VGA16, and also make output only 1 destinaiton pointer
  13. for 3 planer.
  14. 03-Apr-1991 Wed 10:28:50 created -by- Daniel Chou (danielc)
  15. [Environment:]
  16. Printer Driver.
  17. [Notes:]
  18. Revision History:
  19. 11-Jan-1999 Mon 16:07:37 updated -by- Daniel Chou (danielc)
  20. re-structure
  21. --*/
  22. #define DBGP_VARNAME dbgpHTSetBmp
  23. #include "htp.h"
  24. #include "htmapclr.h"
  25. #include "htrender.h"
  26. #include "htpat.h"
  27. #include "htdebug.h"
  28. #include "htalias.h"
  29. #include "htstret.h"
  30. #include "htsetbmp.h"
  31. #define DBGP_VGA256XLATE 0x00000001
  32. #define DBGP_BRUSH 0x00000002
  33. DEF_DBGPVAR(BIT_IF(DBGP_VGA256XLATE, 0) |
  34. BIT_IF(DBGP_BRUSH, 0))
  35. CONST BYTE VGA16Xlate[120] = {
  36. 0xff,0xfe,0xfd,0xfc,0xfb,0xfa,0xf9,0xf0,
  37. 0xff,0xfe,0xfd,0xfc,0xfb,0xfa,0xf9,0xf8,
  38. 0xef,0xee,0xed,0xec,0xeb,0xea,0xe9,0xe0,
  39. 0xef,0xee,0xed,0xec,0xeb,0xea,0xe9,0xe8,
  40. 0xdf,0xde,0xdd,0xdc,0xdb,0xda,0xd9,0xd0,
  41. 0xdf,0xde,0xdd,0xdc,0xdb,0xda,0xd9,0xd8,
  42. 0xcf,0xce,0xcd,0xcc,0xcb,0xca,0xc9,0xc0,
  43. 0xcf,0xce,0xcd,0xcc,0xcb,0xca,0xc9,0xc8,
  44. 0xbf,0xbe,0xbd,0xbc,0xbb,0xba,0xb9,0xb0,
  45. 0xbf,0xbe,0xbd,0xbc,0xbb,0xba,0xb9,0xb8,
  46. 0xaf,0xae,0xad,0xac,0xab,0xaa,0xa9,0xa0,
  47. 0xaf,0xae,0xad,0xac,0xab,0xaa,0xa9,0xa8,
  48. 0x9f,0x9e,0x9d,0x9c,0x9b,0x9a,0x99,0x90,
  49. 0x9f,0x9e,0x9d,0x9c,0x9b,0x9a,0x99,0x98,
  50. 0x0f,0x0e,0x0d,0x0c,0x0b,0x0a,0x09,0x00
  51. };
  52. //
  53. // Xlate table has 3 bits for each of C=6-8, M=3-5, Y=0-2
  54. //
  55. // For 5:5:5, 1 0010 0100 = 0x124 = 0-292 (293 Entries)
  56. // for 6:6:6, 1 0110 1101 = 0x169 = 0-365 (366 Entries)
  57. //
  58. CONST BYTE VGA256Xlate[SIZE_XLATE_666] = {
  59. 215,214,213,212,211,210,210,210,209,208,207,206,205,204,204,204,
  60. 203,202,201,200,199,198,198,198,197,196,195,194,193,192,192,192,
  61. 191,190,189,188,187,186,186,186,185,184,183,182,181,180,180,180,
  62. 185,184,183,182,181,180,180,180,185,184,183,182,181,180,180,180,
  63. 179,178,177,176,175,174,174,174,173,172,171,170,169,168,168,168,
  64. 167,166,165,164,163,162,162,162,161,160,159,158,157,156,156,156,
  65. 155,154,153,152,151,150,150,150,149,148,147,146,145,144,144,144,
  66. 149,148,147,146,145,144,144,144,149,148,147,146,145,144,144,144,
  67. 143,142,141,140,139,138,138,138,137,136,135,134,133,132,132,132,
  68. 131,130,129,128,127,126,126,126,125,124,123,122,121,120,120,120,
  69. 119,118,117,116,115,114,114,114,113,112,111,110,109,108,108,108,
  70. 113,112,111,110,109,108,108,108,113,112,111,110,109,108,108,108,
  71. 107,106,105,104,103,102,102,102,101,100, 99, 98, 97, 96, 96, 96,
  72. 95, 94, 93, 92, 91, 90, 90, 90, 89, 88, 87, 86, 85, 84, 84, 84,
  73. 83, 82, 81, 80, 79, 78, 78, 78, 77, 76, 75, 74, 73, 72, 72, 72,
  74. 77, 76, 75, 74, 73, 72, 72, 72, 77, 76, 75, 74, 73, 72, 72, 72,
  75. 71, 70, 69, 68, 67, 66, 66, 66, 65, 64, 63, 62, 61, 60, 60, 60,
  76. 59, 58, 57, 56, 55, 54, 54, 54, 53, 52, 51, 50, 49, 48, 48, 48,
  77. 47, 46, 45, 44, 43, 42, 42, 42, 41, 40, 39, 38, 37, 36, 36, 36,
  78. 41, 40, 39, 38, 37, 36, 36, 36, 41, 40, 39, 38, 37, 36, 36, 36,
  79. 35, 34, 33, 32, 31, 30, 30, 30, 29, 28, 27, 26, 25, 24, 24, 24,
  80. 23, 22, 21, 20, 19, 18, 18, 18, 17, 16, 15, 14, 13, 12, 12, 12,
  81. 11, 10, 9, 8, 7, 6, 6, 6, 5, 4, 3, 2, 1, 0
  82. };
  83. CONST BYTE CMY555Xlate[SIZE_XLATE_555] = {
  84. 0, 1, 2, 3, 4, 4, 4, 4, 5, 6, 7, 8, 9, 9, 9, 9,
  85. 10, 11, 12, 13, 14, 14, 14, 14, 15, 16, 17, 18, 19, 19, 19, 19,
  86. 20, 21, 22, 23, 24, 24, 24, 24, 20, 21, 22, 23, 24, 24, 24, 24,
  87. 20, 21, 22, 23, 24, 24, 24, 24, 20, 21, 22, 23, 24, 24, 24, 24,
  88. 25, 26, 27, 28, 29, 29, 29, 29, 30, 31, 32, 33, 34, 34, 34, 34,
  89. 35, 36, 37, 38, 39, 39, 39, 39, 40, 41, 42, 43, 44, 44, 44, 44,
  90. 45, 46, 47, 48, 49, 49, 49, 49, 45, 46, 47, 48, 49, 49, 49, 49,
  91. 45, 46, 47, 48, 49, 49, 49, 49, 45, 46, 47, 48, 49, 49, 49, 49,
  92. 50, 51, 52, 53, 54, 54, 54, 54, 55, 56, 57, 58, 59, 59, 59, 59,
  93. 60, 61, 62, 63, 64, 64, 64, 64, 65, 66, 67, 68, 69, 69, 69, 69,
  94. 70, 71, 72, 73, 74, 74, 74, 74, 70, 71, 72, 73, 74, 74, 74, 74,
  95. 70, 71, 72, 73, 74, 74, 74, 74, 70, 71, 72, 73, 74, 74, 74, 74,
  96. 75, 76, 77, 78, 79, 79, 79, 79, 80, 81, 82, 83, 84, 84, 84, 84,
  97. 85, 86, 87, 88, 89, 89, 89, 89, 90, 91, 92, 93, 94, 94, 94, 94,
  98. 95, 96, 97, 98, 99, 99, 99, 99, 95, 96, 97, 98, 99, 99, 99, 99,
  99. 95, 96, 97, 98, 99, 99, 99, 99, 95, 96, 97, 98, 99, 99, 99, 99,
  100. 100,101,102,103,104,104,104,104,105,106,107,108,109,109,109,109,
  101. 110,111,112,113,114,114,114,114,115,116,117,118,119,119,119,119,
  102. 120,121,122,123,124
  103. };
  104. CONST BYTE RGB555Xlate[SIZE_XLATE_555] = {
  105. 190,189,188,187,186,186,186,186,185,184,183,182,181,181,181,181,
  106. 180,179,178,177,176,176,176,176,175,174,173,172,171,171,171,171,
  107. 170,169,168,167,166,166,166,166,170,169,168,167,166,166,166,166,
  108. 170,169,168,167,166,166,166,166,170,169,168,167,166,166,166,166,
  109. 165,164,163,162,161,161,161,161,160,159,158,157,156,156,156,156,
  110. 155,154,153,152,151,151,151,151,150,149,148,147,146,146,146,146,
  111. 145,144,143,142,141,141,141,141,145,144,143,142,141,141,141,141,
  112. 145,144,143,142,141,141,141,141,145,144,143,142,141,141,141,141,
  113. 140,139,138,137,136,136,136,136,135,134,133,132,131,131,131,131,
  114. 130,129,127,126,125,125,125,125,124,123,122,121,120,120,120,120,
  115. 119,118,117,116,115,115,115,115,119,118,117,116,115,115,115,115,
  116. 119,118,117,116,115,115,115,115,119,118,117,116,115,115,115,115,
  117. 114,113,112,111,110,110,110,110,109,108,107,106,105,105,105,105,
  118. 104,103,102,101,100,100,100,100, 99, 98, 97, 96, 95, 95, 95, 95,
  119. 94, 93, 92, 91, 90, 90, 90, 90, 94, 93, 92, 91, 90, 90, 90, 90,
  120. 94, 93, 92, 91, 90, 90, 90, 90, 94, 93, 92, 91, 90, 90, 90, 90,
  121. 89, 88, 87, 86, 85, 85, 85, 85, 84, 83, 82, 81, 80, 80, 80, 80,
  122. 79, 78, 77, 76, 75, 75, 75, 75, 74, 73, 72, 71, 70, 70, 70, 70,
  123. 69, 68, 67, 66, 65
  124. };
  125. CONST BYTE CMY666Xlate[SIZE_XLATE_666] = {
  126. 0, 1, 2, 3, 4, 5, 5, 5, 6, 7, 8, 9, 10, 11, 11, 11,
  127. 12, 13, 14, 15, 16, 17, 17, 17, 18, 19, 20, 21, 22, 23, 23, 23,
  128. 24, 25, 26, 27, 28, 29, 29, 29, 30, 31, 32, 33, 34, 35, 35, 35,
  129. 30, 31, 32, 33, 34, 35, 35, 35, 30, 31, 32, 33, 34, 35, 35, 35,
  130. 36, 37, 38, 39, 40, 41, 41, 41, 42, 43, 44, 45, 46, 47, 47, 47,
  131. 48, 49, 50, 51, 52, 53, 53, 53, 54, 55, 56, 57, 58, 59, 59, 59,
  132. 60, 61, 62, 63, 64, 65, 65, 65, 66, 67, 68, 69, 70, 71, 71, 71,
  133. 66, 67, 68, 69, 70, 71, 71, 71, 66, 67, 68, 69, 70, 71, 71, 71,
  134. 72, 73, 74, 75, 76, 77, 77, 77, 78, 79, 80, 81, 82, 83, 83, 83,
  135. 84, 85, 86, 87, 88, 89, 89, 89, 90, 91, 92, 93, 94, 95, 95, 95,
  136. 96, 97, 98, 99,100,101,101,101,102,103,104,105,106,107,107,107,
  137. 102,103,104,105,106,107,107,107,102,103,104,105,106,107,107,107,
  138. 108,109,110,111,112,113,113,113,114,115,116,117,118,119,119,119,
  139. 120,121,122,123,124,125,125,125,126,127,128,129,130,131,131,131,
  140. 132,133,134,135,136,137,137,137,138,139,140,141,142,143,143,143,
  141. 138,139,140,141,142,143,143,143,138,139,140,141,142,143,143,143,
  142. 144,145,146,147,148,149,149,149,150,151,152,153,154,155,155,155,
  143. 156,157,158,159,160,161,161,161,162,163,164,165,166,167,167,167,
  144. 168,169,170,171,172,173,173,173,174,175,176,177,178,179,179,179,
  145. 174,175,176,177,178,179,179,179,174,175,176,177,178,179,179,179,
  146. 180,181,182,183,184,185,185,185,186,187,188,189,190,191,191,191,
  147. 192,193,194,195,196,197,197,197,198,199,200,201,202,203,203,203,
  148. 204,205,206,207,208,209,209,209,210,211,212,213,214,215
  149. };
  150. CONST BYTE RGB666Xlate[SIZE_XLATE_666] = {
  151. 235,234,233,232,231,230,230,230,229,228,227,226,225,224,224,224,
  152. 223,222,221,220,219,218,218,218,217,216,215,214,213,212,212,212,
  153. 211,210,209,208,207,206,206,206,205,204,203,202,201,200,200,200,
  154. 205,204,203,202,201,200,200,200,205,204,203,202,201,200,200,200,
  155. 199,198,197,196,195,194,194,194,193,192,191,190,189,188,188,188,
  156. 187,186,185,184,183,182,182,182,181,180,179,178,177,176,176,176,
  157. 175,174,173,172,171,170,170,170,169,168,167,166,165,164,164,164,
  158. 169,168,167,166,165,164,164,164,169,168,167,166,165,164,164,164,
  159. 163,162,161,160,159,158,158,158,157,156,155,154,153,152,152,152,
  160. 151,150,149,148,147,146,146,146,145,144,143,142,141,140,140,140,
  161. 139,138,137,136,135,134,134,134,133,132,131,130,129,128,128,128,
  162. 133,132,131,130,129,128,128,128,133,132,131,130,129,128,128,128,
  163. 127,126,125,124,123,122,122,122,121,120,119,118,117,116,116,116,
  164. 115,114,113,112,111,110,110,110,109,108,107,106,105,104,104,104,
  165. 103,102,101,100, 99, 98, 98, 98, 97, 96, 95, 94, 93, 92, 92, 92,
  166. 97, 96, 95, 94, 93, 92, 92, 92, 97, 96, 95, 94, 93, 92, 92, 92,
  167. 91, 90, 89, 88, 87, 86, 86, 86, 85, 84, 83, 82, 81, 80, 80, 80,
  168. 79, 78, 77, 76, 75, 74, 74, 74, 73, 72, 71, 70, 69, 68, 68, 68,
  169. 67, 66, 65, 64, 63, 62, 62, 62, 61, 60, 59, 58, 57, 56, 56, 56,
  170. 61, 60, 59, 58, 57, 56, 56, 56, 61, 60, 59, 58, 57, 56, 56, 56,
  171. 55, 54, 53, 52, 51, 50, 50, 50, 49, 48, 47, 46, 45, 44, 44, 44,
  172. 43, 42, 41, 40, 39, 38, 38, 38, 37, 36, 35, 34, 33, 32, 32, 32,
  173. 31, 30, 29, 28, 27, 26, 26, 26, 25, 24, 23, 22, 21, 20
  174. };
  175. CONST LPBYTE p8BPPXlate[] = { (LPBYTE)CMY555Xlate, // 00
  176. (LPBYTE)CMY666Xlate, // 01
  177. (LPBYTE)RGB555Xlate, // 10
  178. (LPBYTE)RGB666Xlate }; // 11
  179. CONST DWORD dwGrayIdxHB[] = {
  180. 0x0ff010,0x0fe020,0x0fd030,0x0fc040,0x0fb050,0x0fa060,0x0f9070,0x0f8080,
  181. 0x0f7090,0x0f60a0,0x0f50b0,0x0f40c0,0x0f30d0,0x0f20e0,0x0f10f0,0x0f0100,
  182. 0x0ef110,0x0ee120,0x0ed130,0x0ec140,0x0eb150,0x0ea160,0x0e9170,0x0e8180,
  183. 0x0e7190,0x0e61a0,0x0e51b0,0x0e41c0,0x0e31d0,0x0e21e0,0x0e11f0,0x0e0200,
  184. 0x0df210,0x0de220,0x0dd230,0x0dc240,0x0db250,0x0da260,0x0d9270,0x0d8280,
  185. 0x0d7290,0x0d62a0,0x0d52b0,0x0d42c0,0x0d32d0,0x0d22e0,0x0d12f0,0x0d0300,
  186. 0x0cf310,0x0ce320,0x0cd330,0x0cc340,0x0cb350,0x0ca360,0x0c9370,0x0c8380,
  187. 0x0c7390,0x0c63a0,0x0c53b0,0x0c43c0,0x0c33d0,0x0c23e0,0x0c13f0,0x0c0400,
  188. 0x0bf410,0x0be420,0x0bd430,0x0bc440,0x0bb450,0x0ba460,0x0b9470,0x0b8480,
  189. 0x0b7490,0x0b64a0,0x0b54b0,0x0b44c0,0x0b34d0,0x0b24e0,0x0b14f0,0x0b0500,
  190. 0x0af510,0x0ae520,0x0ad530,0x0ac540,0x0ab550,0x0aa560,0x0a9570,0x0a8580,
  191. 0x0a7590,0x0a65a0,0x0a55b0,0x0a45c0,0x0a35d0,0x0a25e0,0x0a15f0,0x0a0600,
  192. 0x09f610,0x09e620,0x09d630,0x09c640,0x09b650,0x09a660,0x099670,0x098680,
  193. 0x097690,0x0966a0,0x0956b0,0x0946c0,0x0936d0,0x0926e0,0x0916f0,0x090700,
  194. 0x08f710,0x08e720,0x08d730,0x08c740,0x08b750,0x08a760,0x089770,0x088780,
  195. 0x087790,0x0867a0,0x0857b0,0x0847c0,0x0837d0,0x0827e0,0x0817f0,0x080800,
  196. 0x07f810,0x07e820,0x07d830,0x07c840,0x07b850,0x07a860,0x079870,0x078880,
  197. 0x077890,0x0768a0,0x0758b0,0x0748c0,0x0738d0,0x0728e0,0x0718f0,0x070900,
  198. 0x06f910,0x06e920,0x06d930,0x06c940,0x06b950,0x06a960,0x069970,0x068980,
  199. 0x067990,0x0669a0,0x0659b0,0x0649c0,0x0639d0,0x0629e0,0x0619f0,0x060a00,
  200. 0x05fa10,0x05ea20,0x05da30,0x05ca40,0x05ba50,0x05aa60,0x059a70,0x058a80,
  201. 0x057a90,0x056aa0,0x055ab0,0x054ac0,0x053ad0,0x052ae0,0x051af0,0x050b00,
  202. 0x04fb10,0x04eb20,0x04db30,0x04cb40,0x04bb50,0x04ab60,0x049b70,0x048b80,
  203. 0x047b90,0x046ba0,0x045bb0,0x044bc0,0x043bd0,0x042be0,0x041bf0,0x040c00,
  204. 0x03fc10,0x03ec20,0x03dc30,0x03cc40,0x03bc50,0x03ac60,0x039c70,0x038c80,
  205. 0x037c90,0x036ca0,0x035cb0,0x034cc0,0x033cd0,0x032ce0,0x031cf0,0x030d00,
  206. 0x02fd10,0x02ed20,0x02dd30,0x02cd40,0x02bd50,0x02ad60,0x029d70,0x028d80,
  207. 0x027d90,0x026da0,0x025db0,0x024dc0,0x023dd0,0x022de0,0x021df0,0x020e00,
  208. 0x01fe10,0x01ee20,0x01de30,0x01ce40,0x01be50,0x01ae60,0x019e70,0x018e80,
  209. 0x017e90,0x016ea0,0x015eb0,0x014ec0,0x013ed0,0x012ee0,0x011ef0,0x010f00,
  210. 0x00ff10,0x00ef20,0x00df30,0x00cf40,0x00bf50,0x00af60,0x009f70,0x008f80,
  211. 0x007f90,0x006fa0,0x005fb0,0x004fc0,0x003fd0,0x002fe0,0x001ff0,0x001000
  212. };
  213. CONST WORD wGrayIdxLB[] = {
  214. 0x0fef,0x0fdf,0x0fcf,0x0fbf,0x0faf,0x0f9f,0x0f8f,0x0f7f,
  215. 0x0f6f,0x0f5f,0x0f4f,0x0f3f,0x0f2f,0x0f1f,0x0f0f,0x0eff,
  216. 0x0eef,0x0edf,0x0ecf,0x0ebf,0x0eaf,0x0e9f,0x0e8f,0x0e7f,
  217. 0x0e6f,0x0e5f,0x0e4f,0x0e3f,0x0e2f,0x0e1f,0x0e0f,0x0dff,
  218. 0x0def,0x0ddf,0x0dcf,0x0dbf,0x0daf,0x0d9f,0x0d8f,0x0d7f,
  219. 0x0d6f,0x0d5f,0x0d4f,0x0d3f,0x0d2f,0x0d1f,0x0d0f,0x0cff,
  220. 0x0cef,0x0cdf,0x0ccf,0x0cbf,0x0caf,0x0c9f,0x0c8f,0x0c7f,
  221. 0x0c6f,0x0c5f,0x0c4f,0x0c3f,0x0c2f,0x0c1f,0x0c0f,0x0bff,
  222. 0x0bef,0x0bdf,0x0bcf,0x0bbf,0x0baf,0x0b9f,0x0b8f,0x0b7f,
  223. 0x0b6f,0x0b5f,0x0b4f,0x0b3f,0x0b2f,0x0b1f,0x0b0f,0x0aff,
  224. 0x0aef,0x0adf,0x0acf,0x0abf,0x0aaf,0x0a9f,0x0a8f,0x0a7f,
  225. 0x0a6f,0x0a5f,0x0a4f,0x0a3f,0x0a2f,0x0a1f,0x0a0f,0x09ff,
  226. 0x09ef,0x09df,0x09cf,0x09bf,0x09af,0x099f,0x098f,0x097f,
  227. 0x096f,0x095f,0x094f,0x093f,0x092f,0x091f,0x090f,0x08ff,
  228. 0x08ef,0x08df,0x08cf,0x08bf,0x08af,0x089f,0x088f,0x087f,
  229. 0x086f,0x085f,0x084f,0x083f,0x082f,0x081f,0x080f,0x07ff,
  230. 0x07f0,0x07e0,0x07d0,0x07c0,0x07b0,0x07a0,0x0790,0x0780,
  231. 0x0770,0x0760,0x0750,0x0740,0x0730,0x0720,0x0710,0x0700,
  232. 0x06f0,0x06e0,0x06d0,0x06c0,0x06b0,0x06a0,0x0690,0x0680,
  233. 0x0670,0x0660,0x0650,0x0640,0x0630,0x0620,0x0610,0x0600,
  234. 0x05f0,0x05e0,0x05d0,0x05c0,0x05b0,0x05a0,0x0590,0x0580,
  235. 0x0570,0x0560,0x0550,0x0540,0x0530,0x0520,0x0510,0x0500,
  236. 0x04f0,0x04e0,0x04d0,0x04c0,0x04b0,0x04a0,0x0490,0x0480,
  237. 0x0470,0x0460,0x0450,0x0440,0x0430,0x0420,0x0410,0x0400,
  238. 0x03f0,0x03e0,0x03d0,0x03c0,0x03b0,0x03a0,0x0390,0x0380,
  239. 0x0370,0x0360,0x0350,0x0340,0x0330,0x0320,0x0310,0x0300,
  240. 0x02f0,0x02e0,0x02d0,0x02c0,0x02b0,0x02a0,0x0290,0x0280,
  241. 0x0270,0x0260,0x0250,0x0240,0x0230,0x0220,0x0210,0x0200,
  242. 0x01f0,0x01e0,0x01d0,0x01c0,0x01b0,0x01a0,0x0190,0x0180,
  243. 0x0170,0x0160,0x0150,0x0140,0x0130,0x0120,0x0110,0x0100,
  244. 0x00f0,0x00e0,0x00d0,0x00c0,0x00b0,0x00a0,0x0090,0x0080,
  245. 0x0070,0x0060,0x0050,0x0040,0x0030,0x0020,0x0010,0x0000
  246. };
  247. extern CONST WORD GrayIdxWORD[];
  248. #define GRAY_W2DW(l, h) (dwGrayIdxHB[h] + (DWORD)wGrayIdxLB[l])
  249. #define PBGRF_2_GRAYDW(pbgrf) GRAY_W2DW((pbgrf)->b, (pbgrf)->g)
  250. //
  251. //**************************************************************************
  252. // Monochrome 1BPP Output Functions
  253. //**************************************************************************
  254. VOID
  255. HTENTRY
  256. OutputAATo1BPP(
  257. PAAHEADER pAAHdr,
  258. PGRAYF pbgrf,
  259. PGRAYF pInEnd,
  260. LPBYTE pbDst,
  261. LPDWORD pIdxBGR,
  262. LPBYTE pbPat,
  263. LPBYTE pbPatEnd,
  264. LONG cbWrapBGR,
  265. AAOUTPUTINFO AAOutputInfo
  266. )
  267. {
  268. UINT Loop;
  269. DW2W4B Dst;
  270. #define XorMask (AAOutputInfo.bm.XorMask)
  271. if (Loop = (UINT)AAOutputInfo.bm.cFirst) {
  272. Dst.dw = 0;
  273. while (Loop--) {
  274. Dst.b[0] = (++pbgrf)->f;
  275. Dst.dw = GRAY_1BPP_COPY(pbPat, 0x010000) | (Dst.dw << 1);
  276. PPAT_NEXT_CONTINUE(pbPat, pbPatEnd, SIZE_PER_PAT, cbWrapBGR);
  277. }
  278. //
  279. // Dst.b[1] = Destination mask (1) for wanted bits
  280. // Dst.b[2] = Destination bits
  281. //
  282. // Shift left for LeftShift is in case that we only have 1 byte and
  283. // the last bit not at bit 0
  284. //
  285. Dst.b[0] = 0;
  286. Dst.dw <<= AAOutputInfo.bm.LSFirst;
  287. *pbDst++ = (*pbDst & ~Dst.b[1]) | ((Dst.b[2] ^ XorMask) & Dst.b[1]);
  288. }
  289. pbgrf -= 7;
  290. if (pAAHdr->Flags & AAHF_HAS_MASK) {
  291. #if defined(_X86_)
  292. _asm {
  293. cld
  294. mov ebx, pbgrf
  295. mov esi, pbPat
  296. mov edi, pbDst
  297. mov ecx, pbPatEnd
  298. mov ch, XorMask
  299. BYTELoopMask:
  300. add ebx, 32
  301. cmp ebx, pInEnd
  302. jae DoneLoopMask
  303. xor ax, ax
  304. cmp BYTE PTR [ebx + 3], 0
  305. jz BIT1
  306. or ah, 0x80
  307. mov dx, WORD PTR [ebx + 0]
  308. not dx
  309. shr dx, 4
  310. cmp dx, WORD PTR [esi + 2 + 0]
  311. BIT1:
  312. rcl al, 1
  313. cmp BYTE PTR [ebx + 4 + 3], 0
  314. jz BIT2
  315. or ah, 0x40
  316. mov dx, WORD PTR [ebx + 4]
  317. not dx
  318. shr dx, 4
  319. cmp dx, WORD PTR [esi + 2 + 6]
  320. BIT2:
  321. rcl al, 1
  322. cmp BYTE PTR [ebx + 8 + 3], 0
  323. jz BIT3
  324. or ah, 0x20
  325. mov dx, WORD PTR [ebx + 8]
  326. not dx
  327. shr dx, 4
  328. cmp dx, WORD PTR [esi + 2 + 12]
  329. BIT3:
  330. rcl al, 1
  331. cmp BYTE PTR [ebx + 12 + 3], 0
  332. jz BIT4
  333. or ah, 0x10
  334. mov dx, WORD PTR [ebx + 12]
  335. not dx
  336. shr dx, 4
  337. cmp dx, WORD PTR [esi + 2 + 18]
  338. BIT4:
  339. rcl al, 1
  340. cmp BYTE PTR [ebx + 16 + 3], 0
  341. jz BIT5
  342. or ah, 0x08
  343. mov dx, WORD PTR [ebx + 16]
  344. not dx
  345. shr dx, 4
  346. cmp dx, WORD PTR [esi + 2 + 24]
  347. BIT5:
  348. rcl al, 1
  349. cmp BYTE PTR [ebx + 20 + 3], 0
  350. jz BIT6
  351. or ah, 0x04
  352. mov dx, WORD PTR [ebx + 20]
  353. not dx
  354. shr dx, 4
  355. cmp dx, WORD PTR [esi + 2 + 30]
  356. BIT6:
  357. rcl al, 1
  358. cmp BYTE PTR [ebx + 24 + 3], 0
  359. jz BIT7
  360. or ah, 0x02
  361. mov dx, WORD PTR [ebx + 24]
  362. not dx
  363. shr dx, 4
  364. cmp dx, WORD PTR [esi + 2 + 36]
  365. BIT7:
  366. rcl al, 1
  367. cmp BYTE PTR [ebx + 28 + 3], 0
  368. jz BIT8
  369. or ah, 0x01
  370. mov dx, WORD PTR [ebx + 28]
  371. not dx
  372. shr dx, 4
  373. cmp dx, WORD PTR [esi + 2 + 42]
  374. BIT8:
  375. rcl al, 1
  376. xor al, ch ;; do xor mask
  377. and al, ah ;; mask out src 0 bits
  378. not ah ;; invert
  379. and BYTE PTR [edi], ah ;; mask out dst 0 bits
  380. or BYTE PTR [edi], al
  381. inc edi
  382. add esi, 48
  383. cmp esi, pbPatEnd
  384. jb BYTELoopMask
  385. add esi, cbWrapBGR
  386. jmp BYTELoopMask
  387. DoneLoopMask:
  388. mov pbgrf, ebx
  389. mov pbPat, esi
  390. mov pbDst, edi
  391. }
  392. #else
  393. while ((pbgrf += 8) < pInEnd) {
  394. Dst.b[0] = GET_1BPP_MASK_BYTE(pbgrf);
  395. *pbDst++ = (*pbDst & ~Dst.b[0]) |
  396. ((GRAY_1BPP_COPY_BYTE(pbPat) ^ XorMask) & Dst.b[0]);
  397. PPAT_NEXT_CONTINUE(pbPat, pbPatEnd, (SIZE_PER_PAT * 8), cbWrapBGR);
  398. }
  399. #endif
  400. } else {
  401. #if defined(_X86_)
  402. _asm {
  403. cld
  404. mov ebx, pbgrf
  405. mov esi, pbPat
  406. mov edi, pbDst
  407. mov ecx, pbPatEnd
  408. mov ah, XorMask
  409. BYTELoop:
  410. add ebx, 32
  411. cmp ebx, pInEnd
  412. jae DoneLoop
  413. xor al, al
  414. mov dx, WORD PTR [ebx + 0]
  415. not dx
  416. shr dx, 4
  417. cmp dx, WORD PTR [esi + 2 + 0]
  418. rcl al, 1
  419. mov dx, WORD PTR [ebx + 4]
  420. not dx
  421. shr dx, 4
  422. cmp dx, WORD PTR [esi + 2 + 6]
  423. rcl al, 1
  424. mov dx, WORD PTR [ebx + 8]
  425. not dx
  426. shr dx, 4
  427. cmp dx, WORD PTR [esi + 2 + 12]
  428. rcl al, 1
  429. mov dx, WORD PTR [ebx + 12]
  430. not dx
  431. shr dx, 4
  432. cmp dx, WORD PTR [esi + 2 + 18]
  433. rcl al, 1
  434. mov dx, WORD PTR [ebx + 16]
  435. not dx
  436. shr dx, 4
  437. cmp dx, WORD PTR [esi + 2 + 24]
  438. rcl al, 1
  439. mov dx, WORD PTR [ebx + 20]
  440. not dx
  441. shr dx, 4
  442. cmp dx, WORD PTR [esi + 2 + 30]
  443. rcl al, 1
  444. mov dx, WORD PTR [ebx + 24]
  445. not dx
  446. shr dx, 4
  447. cmp dx, WORD PTR [esi + 2 + 36]
  448. rcl al, 1
  449. mov dx, WORD PTR [ebx + 28]
  450. not dx
  451. shr dx, 4
  452. cmp dx, WORD PTR [esi + 2 + 42]
  453. rcl al, 1
  454. xor al, ah
  455. stosb
  456. add esi, 48
  457. cmp esi, ecx
  458. jb BYTELoop
  459. add esi, cbWrapBGR
  460. jmp BYTELoop
  461. DoneLoop:
  462. mov pbgrf, ebx
  463. mov pbPat, esi
  464. mov pbDst, edi
  465. }
  466. #else
  467. while ((pbgrf += 8) < pInEnd) {
  468. *pbDst++ = GRAY_1BPP_COPY_BYTE(pbPat) ^ XorMask;
  469. PPAT_NEXT_CONTINUE(pbPat, pbPatEnd, (SIZE_PER_PAT * 8), cbWrapBGR);
  470. }
  471. #endif
  472. }
  473. if (Loop = (UINT)AAOutputInfo.bm.cLast) {
  474. Dst.dw = 0;
  475. AAOutputInfo.bm.LSFirst = (BYTE)(8 - Loop);
  476. while (Loop--) {
  477. Dst.b[0] = pbgrf->f;
  478. Dst.dw = GRAY_1BPP_COPY(pbPat, 0x010000) | (Dst.dw << 1);
  479. ++pbgrf;
  480. PPAT_NEXT_CONTINUE(pbPat, pbPatEnd, SIZE_PER_PAT, cbWrapBGR);
  481. }
  482. //
  483. // Dst.b[1] = Destination mask (1) for wanted bits
  484. // Dst.b[2] = Destination bits
  485. //
  486. // Shift left for (LeftShift) is for the last un-make bits
  487. //
  488. Dst.b[0] = 0;
  489. Dst.dw <<= AAOutputInfo.bm.LSFirst;
  490. *pbDst = (*pbDst & ~Dst.b[1]) | ((Dst.b[2] ^ XorMask) & Dst.b[1]);
  491. }
  492. #undef XorMask
  493. }
  494. //
  495. //**************************************************************************
  496. // Standard 4BPP (RGB/CMY) Output Functions
  497. //**************************************************************************
  498. VOID
  499. HTENTRY
  500. OutputAATo4BPP(
  501. PAAHEADER pAAHdr,
  502. PBGRF pbgrf,
  503. PBGRF pInEnd,
  504. LPBYTE pbDst,
  505. LPDWORD pIdxBGR,
  506. LPBYTE pbPat,
  507. LPBYTE pbPatEnd,
  508. LONG cbWrapBGR,
  509. AAOUTPUTINFO AAOutputInfo
  510. )
  511. {
  512. DW2W4B dw4b;
  513. DEF_COPY_LUTAAHDR;
  514. dw4b.dw = 0;
  515. if (AAOutputInfo.bm.XorMask) {
  516. dw4b.dw = 0x77700777;
  517. }
  518. if (AAOutputInfo.bm.cFirst) {
  519. if (PBGRF_HAS_MASK(++pbgrf)) {
  520. GET_4BPP_CLR_COPY_LIDX(pbDst, pbPat, pbgrf, dw4b.b[1]);
  521. }
  522. ++pbDst;
  523. PPAT_NEXT(pbPat, pbPatEnd, cbWrapBGR);
  524. }
  525. --pbgrf;
  526. if (pAAHdr->Flags & AAHF_HAS_MASK) {
  527. while ((pbgrf += 2) < pInEnd) {
  528. switch (((pbgrf->f) & 0x02) | ((pbgrf + 1)->f & 0x01)) {
  529. case 0:
  530. break;
  531. case 1:
  532. GET_4BPP_CLR_COPY_LIDX(pbDst, pbPat, pbgrf + 1, dw4b.b[1]);
  533. break;
  534. case 2:
  535. GET_4BPP_CLR_COPY_HIDX(pbDst, pbPat, pbgrf, dw4b.b[2]);
  536. break;
  537. case 3:
  538. default:
  539. GET_4BPP_CLR_COPY_BYTE(pbDst, pbPat, dw4b.b[0]);
  540. break;
  541. }
  542. ++pbDst;
  543. PPAT_NEXT_CONTINUE(pbPat, pbPatEnd, SIZE_PER_PAT*2, cbWrapBGR);
  544. }
  545. } else {
  546. while ((pbgrf += 2) < pInEnd) {
  547. GET_4BPP_CLR_COPY_BYTE(pbDst++, pbPat, dw4b.b[0]);
  548. PPAT_NEXT_CONTINUE(pbPat, pbPatEnd, SIZE_PER_PAT*2, cbWrapBGR);
  549. }
  550. }
  551. if ((AAOutputInfo.bm.cLast) && (PBGRF_HAS_MASK(pbgrf))) {
  552. GET_4BPP_CLR_COPY_HIDX(pbDst, pbPat, pbgrf, dw4b.b[2]);
  553. }
  554. }
  555. //
  556. //**************************************************************************
  557. // VGA16 4BPP Output Functions
  558. //**************************************************************************
  559. VOID
  560. HTENTRY
  561. OutputAAToVGA16(
  562. PAAHEADER pAAHdr,
  563. PBGRF pbgrf,
  564. PBGRF pInEnd,
  565. LPBYTE pbDst,
  566. LPDWORD pIdxBGR,
  567. LPBYTE pbPat,
  568. LPBYTE pbPatEnd,
  569. LONG cbWrapBGR,
  570. AAOUTPUTINFO AAOutputInfo
  571. )
  572. {
  573. DW2W4B dw4b;
  574. DEF_COPY_LUTAAHDR;
  575. dw4b.dw = 0;
  576. if (AAOutputInfo.bm.cFirst) {
  577. if (PBGRF_HAS_MASK(++pbgrf)) {
  578. GET_VGA16_CLR_COPY_LIDX(pbDst, pbPat, pbgrf, 0x07);
  579. }
  580. ++pbDst;
  581. PPAT_NEXT(pbPat, pbPatEnd, cbWrapBGR);
  582. }
  583. --pbgrf;
  584. if (pAAHdr->Flags & AAHF_HAS_MASK) {
  585. while ((pbgrf += 2) < pInEnd) {
  586. switch (((pbgrf->f) & 0x02) | ((pbgrf + 1)->f & 0x01)) {
  587. case 0:
  588. break;
  589. case 1:
  590. GET_VGA16_CLR_COPY_LIDX(pbDst, pbPat, pbgrf + 1, 0x07);
  591. break;
  592. case 2:
  593. GET_VGA16_CLR_COPY_HIDX(pbDst, pbPat, pbgrf, 0x70);
  594. break;
  595. case 3:
  596. default:
  597. GET_VGA16_CLR_COPY_BYTE(pbDst, pbPat, 0x77);
  598. break;
  599. }
  600. ++pbDst;
  601. PPAT_NEXT_CONTINUE(pbPat, pbPatEnd, SIZE_PER_PAT*2, cbWrapBGR);
  602. }
  603. } else {
  604. while ((pbgrf += 2) < pInEnd) {
  605. GET_VGA16_CLR_COPY_BYTE(pbDst++, pbPat, 0x77);
  606. PPAT_NEXT_CONTINUE(pbPat, pbPatEnd, SIZE_PER_PAT*2, cbWrapBGR);
  607. }
  608. }
  609. if ((AAOutputInfo.bm.cLast) && (PBGRF_HAS_MASK(pbgrf))) {
  610. GET_VGA16_CLR_COPY_HIDX(pbDst, pbPat, pbgrf, 0x70);
  611. }
  612. }
  613. //
  614. //**************************************************************************
  615. // VGA 256 8BPP Output Functions
  616. //**************************************************************************
  617. LPBYTE
  618. HTENTRY
  619. BuildVGA256Xlate(
  620. LPBYTE pXlate,
  621. LPBYTE pNewXlate
  622. )
  623. /*++
  624. Routine Description:
  625. Arguments:
  626. Return Value:
  627. Author:
  628. 13-May-1998 Wed 14:02:56 created -by- Daniel Chou (danielc)
  629. Revision History:
  630. --*/
  631. {
  632. if (pXlate) {
  633. UINT i;
  634. LPBYTE pVGA256Xlate;
  635. LPBYTE pRet;
  636. ASSERTMSG("Has pXlate8BPP but buffer is NULL", pNewXlate);
  637. DBGP_IF(DBGP_VGA256XLATE, DBGP("Build New Xlate 256"));
  638. if (pRet = pNewXlate) {
  639. pVGA256Xlate = (LPBYTE)VGA256Xlate;
  640. i = sizeof(VGA256Xlate);
  641. while (i--) {
  642. DBGP_IF(DBGP_VGA256XLATE,
  643. DBGP("Xlate8BPP (%3ld) ---> %3ld --> %3ld"
  644. ARGDW(i) ARGDW(pXlate[i])
  645. ARGDW(pXlate[*pVGA256Xlate])));
  646. *pNewXlate++ = pXlate[*pVGA256Xlate++];
  647. }
  648. }
  649. return(pRet);
  650. } else {
  651. ASSERTMSG("No pXlate8BPP but buffer is Not NULL", pNewXlate==NULL);
  652. DBGP_IF(DBGP_VGA256XLATE, DBGP("Use Default VGA256Xlate"));
  653. return((LPBYTE)VGA256Xlate);
  654. }
  655. }
  656. VOID
  657. HTENTRY
  658. OutputAAToVGA256(
  659. PAAHEADER pAAHdr,
  660. PBGRF pbgrf,
  661. PBGRF pInEnd,
  662. LPBYTE pbDst,
  663. PLONG pIdxBGR,
  664. LPBYTE pbPat,
  665. LPBYTE pbPatEnd,
  666. LONG cbWrapBGR,
  667. AAOUTPUTINFO AAOutputInfo
  668. )
  669. {
  670. if (pAAHdr->Flags & AAHF_HAS_MASK) {
  671. while (++pbgrf < pInEnd) {
  672. if (PBGRF_HAS_MASK(pbgrf)) {
  673. *pbDst = GET_VGA256_CLR_COPY_XLATE(pbPat,
  674. AAOutputInfo.pXlate8BPP);
  675. }
  676. ++pbDst;
  677. PPAT_NEXT_CONTINUE(pbPat, pbPatEnd, SIZE_PER_PAT, cbWrapBGR);
  678. }
  679. } else {
  680. while (++pbgrf < pInEnd) {
  681. *pbDst++ = GET_VGA256_CLR_COPY_XLATE(pbPat,
  682. AAOutputInfo.pXlate8BPP);
  683. PPAT_NEXT_CONTINUE(pbPat, pbPatEnd, SIZE_PER_PAT, cbWrapBGR);
  684. }
  685. }
  686. }
  687. //
  688. //**************************************************************************
  689. // Mask 8BPP Output Functions
  690. //**************************************************************************
  691. #define bm8i (*(PBM8BPPINFO)&ExtBGR[3])
  692. VOID
  693. HTENTRY
  694. OutputAATo8BPP_B332(
  695. PAAHEADER pAAHdr,
  696. PBGRF pbgrf,
  697. PBGRF pInEnd,
  698. LPBYTE pbDst,
  699. PLONG pIdxBGR,
  700. LPBYTE pbPat,
  701. LPBYTE pbPatEnd,
  702. LONG cbWrapBGR,
  703. AAOUTPUTINFO AAOutputInfo
  704. )
  705. {
  706. DEF_COPY_LUTAAHDR;
  707. while (++pbgrf < pInEnd) {
  708. if (PBGRF_HAS_MASK(pbgrf)) {
  709. GET_MASK8BPP(pbDst,
  710. pbPat,
  711. _GET_MASK8BPP_332,
  712. NULL);
  713. }
  714. ++pbDst;
  715. PPAT_NEXT_CONTINUE(pbPat, pbPatEnd, SIZE_PER_PAT, cbWrapBGR);
  716. }
  717. }
  718. VOID
  719. HTENTRY
  720. OutputAATo8BPP_K_B332(
  721. PAAHEADER pAAHdr,
  722. PBGRF pbgrf,
  723. PBGRF pInEnd,
  724. LPBYTE pbDst,
  725. PLONG pIdxBGR,
  726. LPBYTE pbPat,
  727. LPBYTE pbPatEnd,
  728. LONG cbWrapBGR,
  729. AAOUTPUTINFO AAOutputInfo
  730. )
  731. {
  732. DEF_COPY_LUTAAHDR;
  733. while (++pbgrf < pInEnd) {
  734. if (PBGRF_HAS_MASK(pbgrf)) {
  735. GET_MASK8BPP_REP_K(pbDst,
  736. pbPat,
  737. _GET_MASK8BPP_K_332,
  738. NULL);
  739. }
  740. ++pbDst;
  741. PPAT_NEXT_CONTINUE(pbPat, pbPatEnd, SIZE_PER_PAT, cbWrapBGR);
  742. }
  743. }
  744. VOID
  745. HTENTRY
  746. OutputAATo8BPP_B332_XLATE(
  747. PAAHEADER pAAHdr,
  748. PBGRF pbgrf,
  749. PBGRF pInEnd,
  750. LPBYTE pbDst,
  751. PLONG pIdxBGR,
  752. LPBYTE pbPat,
  753. LPBYTE pbPatEnd,
  754. LONG cbWrapBGR,
  755. AAOUTPUTINFO AAOutputInfo
  756. )
  757. {
  758. DEF_COPY_LUTAAHDR;
  759. while (++pbgrf < pInEnd) {
  760. if (PBGRF_HAS_MASK(pbgrf)) {
  761. GET_MASK8BPP(pbDst,
  762. pbPat,
  763. _GET_MASK8BPP_332_XLATE,
  764. AAOutputInfo.pXlate8BPP);
  765. }
  766. ++pbDst;
  767. PPAT_NEXT_CONTINUE(pbPat, pbPatEnd, SIZE_PER_PAT, cbWrapBGR);
  768. }
  769. }
  770. VOID
  771. HTENTRY
  772. OutputAATo8BPP_K_B332_XLATE(
  773. PAAHEADER pAAHdr,
  774. PBGRF pbgrf,
  775. PBGRF pInEnd,
  776. LPBYTE pbDst,
  777. PLONG pIdxBGR,
  778. LPBYTE pbPat,
  779. LPBYTE pbPatEnd,
  780. LONG cbWrapBGR,
  781. AAOUTPUTINFO AAOutputInfo
  782. )
  783. {
  784. DEF_COPY_LUTAAHDR;
  785. while (++pbgrf < pInEnd) {
  786. if (PBGRF_HAS_MASK(pbgrf)) {
  787. GET_MASK8BPP_REP_K(pbDst,
  788. pbPat,
  789. _GET_MASK8BPP_K_332_XLATE,
  790. AAOutputInfo.pXlate8BPP);
  791. }
  792. ++pbDst;
  793. PPAT_NEXT_CONTINUE(pbPat, pbPatEnd, SIZE_PER_PAT, cbWrapBGR);
  794. }
  795. }
  796. VOID
  797. HTENTRY
  798. OutputAATo8BPP_XLATE(
  799. PAAHEADER pAAHdr,
  800. PBGRF pbgrf,
  801. PBGRF pInEnd,
  802. LPBYTE pbDst,
  803. PLONG pIdxBGR,
  804. LPBYTE pbPat,
  805. LPBYTE pbPatEnd,
  806. LONG cbWrapBGR,
  807. AAOUTPUTINFO AAOutputInfo
  808. )
  809. {
  810. DEF_COPY_LUTAAHDR;
  811. while (++pbgrf < pInEnd) {
  812. if (PBGRF_HAS_MASK(pbgrf)) {
  813. GET_MASK8BPP(pbDst,
  814. pbPat,
  815. _GET_MASK8BPP_XLATE,
  816. AAOutputInfo.pXlate8BPP);
  817. }
  818. ++pbDst;
  819. PPAT_NEXT_CONTINUE(pbPat, pbPatEnd, SIZE_PER_PAT, cbWrapBGR);
  820. }
  821. }
  822. VOID
  823. HTENTRY
  824. OutputAATo8BPP_K_XLATE(
  825. PAAHEADER pAAHdr,
  826. PBGRF pbgrf,
  827. PBGRF pInEnd,
  828. LPBYTE pbDst,
  829. PLONG pIdxBGR,
  830. LPBYTE pbPat,
  831. LPBYTE pbPatEnd,
  832. LONG cbWrapBGR,
  833. AAOUTPUTINFO AAOutputInfo
  834. )
  835. {
  836. DEF_COPY_LUTAAHDR;
  837. while (++pbgrf < pInEnd) {
  838. if (PBGRF_HAS_MASK(pbgrf)) {
  839. GET_MASK8BPP_REP_K(pbDst,
  840. pbPat,
  841. _GET_MASK8BPP_K_XLATE,
  842. AAOutputInfo.pXlate8BPP);
  843. }
  844. ++pbDst;
  845. PPAT_NEXT_CONTINUE(pbPat, pbPatEnd, SIZE_PER_PAT, cbWrapBGR);
  846. }
  847. }
  848. #undef bm8i
  849. VOID
  850. HTENTRY
  851. OutputAATo8BPP_MONO(
  852. PAAHEADER pAAHdr,
  853. PBGRF pbgrf,
  854. PBGRF pInEnd,
  855. LPBYTE pbDst,
  856. PLONG pIdxBGR,
  857. LPBYTE pbPat,
  858. LPBYTE pbPatEnd,
  859. LONG cbWrapBGR,
  860. AAOUTPUTINFO AAOutputInfo
  861. )
  862. {
  863. if (pAAHdr->Flags & AAHF_HAS_MASK) {
  864. while (++pbgrf < pInEnd) {
  865. if (PBGRF_HAS_MASK(pbgrf)) {
  866. GET_MASK8BPP_MONO(pbDst,
  867. pbPat,
  868. PBGRF_2_GRAYDW(pbgrf),
  869. AAOutputInfo.bm.XorMask);
  870. }
  871. ++pbDst;
  872. PPAT_NEXT_CONTINUE(pbPat, pbPatEnd, SIZE_PER_PAT, cbWrapBGR);
  873. }
  874. } else {
  875. while (++pbgrf < pInEnd) {
  876. GET_MASK8BPP_MONO(pbDst,
  877. pbPat,
  878. PBGRF_2_GRAYDW(pbgrf),
  879. AAOutputInfo.bm.XorMask);
  880. ++pbDst;
  881. PPAT_NEXT_CONTINUE(pbPat, pbPatEnd, SIZE_PER_PAT, cbWrapBGR);
  882. }
  883. }
  884. }
  885. //
  886. //**************************************************************************
  887. // 16BPP_555/16BPP_565 Output Functions
  888. //**************************************************************************
  889. #define OUTPUTAATO16BPP_MASK(BM, GM, RM, XorM) \
  890. { \
  891. if (AAOutputInfo.bm.cFirst) { \
  892. \
  893. if (PBGRF_HAS_MASK(++pbgrf)) { \
  894. \
  895. *pwDst = GET_16BPP_COPY_W_MASK(pbPat, BM, GM, RM, XorM); \
  896. } \
  897. \
  898. ++pwDst; \
  899. \
  900. PPAT_NEXT(pbPat, pbPatEnd, cbWrapBGR); \
  901. } \
  902. \
  903. if (pAAHdr->Flags & AAHF_HAS_MASK) { \
  904. \
  905. while (++pbgrf < pInEnd) { \
  906. \
  907. if (PBGRF_HAS_MASK(pbgrf)) { \
  908. \
  909. *pwDst = GET_16BPP_COPY_W_MASK(pbPat, BM, GM, RM, XorM); \
  910. } \
  911. \
  912. ++pwDst; \
  913. \
  914. PPAT_NEXT_CONTINUE(pbPat, pbPatEnd, SIZE_PER_PAT, cbWrapBGR); \
  915. } \
  916. \
  917. } else { \
  918. \
  919. --pbgrf; \
  920. \
  921. while ((pbgrf += 2) < pInEnd) { \
  922. \
  923. *((LPDWORD)pwDst)++ = GET_16BPP_COPY_DW_MASK(pbPat, \
  924. BM, \
  925. GM, \
  926. RM, \
  927. XorM); \
  928. \
  929. PPAT_NEXT_CONTINUE(pbPat, pbPatEnd, SIZE_PER_PAT*2, cbWrapBGR); \
  930. } \
  931. } \
  932. \
  933. if ((AAOutputInfo.bm.cLast) && (PBGRF_HAS_MASK(pbgrf))) { \
  934. \
  935. *pwDst = GET_16BPP_COPY_W_MASK(pbPat, BM, GM, RM, XorM); \
  936. } \
  937. }
  938. VOID
  939. HTENTRY
  940. OutputAATo16BPP_ExtBGR(
  941. PAAHEADER pAAHdr,
  942. PBGRF pbgrf,
  943. PBGRF pInEnd,
  944. LPWORD pwDst,
  945. PLONG pIdxBGR,
  946. LPBYTE pbPat,
  947. LPBYTE pbPatEnd,
  948. LONG cbWrapBGR,
  949. AAOUTPUTINFO AAOutputInfo
  950. )
  951. {
  952. DEF_COPY_LUTAAHDR;
  953. OUTPUTAATO16BPP_MASK(ExtBGR[0], ExtBGR[1], ExtBGR[2], ExtBGR[3]);
  954. }
  955. VOID
  956. HTENTRY
  957. OutputAATo16BPP_555_RGB(
  958. PAAHEADER pAAHdr,
  959. PBGRF pbgrf,
  960. PBGRF pInEnd,
  961. LPWORD pwDst,
  962. PLONG pIdxBGR,
  963. LPBYTE pbPat,
  964. LPBYTE pbPatEnd,
  965. LONG cbWrapBGR,
  966. AAOUTPUTINFO AAOutputInfo
  967. )
  968. {
  969. OUTPUTAATO16BPP_MASK(0x001F0000, 0x03e00000, 0x7c000000, 0x7FFF7FFF);
  970. }
  971. VOID
  972. HTENTRY
  973. OutputAATo16BPP_555_BGR(
  974. PAAHEADER pAAHdr,
  975. PBGRF pbgrf,
  976. PBGRF pInEnd,
  977. LPWORD pwDst,
  978. PLONG pIdxBGR,
  979. LPBYTE pbPat,
  980. LPBYTE pbPatEnd,
  981. LONG cbWrapBGR,
  982. AAOUTPUTINFO AAOutputInfo
  983. )
  984. {
  985. OUTPUTAATO16BPP_MASK(0x7c000000, 0x03e00000, 0x001F0000, 0x7FFF7FFF);
  986. }
  987. VOID
  988. HTENTRY
  989. OutputAATo16BPP_565_RGB(
  990. PAAHEADER pAAHdr,
  991. PBGRF pbgrf,
  992. PBGRF pInEnd,
  993. LPWORD pwDst,
  994. PLONG pIdxBGR,
  995. LPBYTE pbPat,
  996. LPBYTE pbPatEnd,
  997. LONG cbWrapBGR,
  998. AAOUTPUTINFO AAOutputInfo
  999. )
  1000. {
  1001. OUTPUTAATO16BPP_MASK(0x001F0000, 0x07e00000, 0xF8000000, 0xFFFFFFFF);
  1002. }
  1003. VOID
  1004. HTENTRY
  1005. OutputAATo16BPP_565_BGR(
  1006. PAAHEADER pAAHdr,
  1007. PBGRF pbgrf,
  1008. PBGRF pInEnd,
  1009. LPWORD pwDst,
  1010. PLONG pIdxBGR,
  1011. LPBYTE pbPat,
  1012. LPBYTE pbPatEnd,
  1013. LONG cbWrapBGR,
  1014. AAOUTPUTINFO AAOutputInfo
  1015. )
  1016. {
  1017. OUTPUTAATO16BPP_MASK(0xF8000000, 0x07e00000, 0x001F0000, 0xFFFFFFFF);
  1018. }
  1019. //
  1020. //**************************************************************************
  1021. // 24BPP/32 Output Functions
  1022. //**************************************************************************
  1023. #define OUTPUTAATO24_32BPP(iR, iG, iB, cbNext) \
  1024. { \
  1025. if (pAAHdr->Flags & AAHF_HAS_MASK) { \
  1026. \
  1027. while (++pbgrf < pInEnd) { \
  1028. \
  1029. if (PBGRF_HAS_MASK(pbgrf)) { \
  1030. \
  1031. pbDst[iR] = ~(BYTE)_GET_R_CLR(pbgrf); \
  1032. pbDst[iG] = ~(BYTE)_GET_G_CLR(pbgrf); \
  1033. pbDst[iB] = ~(BYTE)_GET_B_CLR(pbgrf); \
  1034. } \
  1035. \
  1036. pbDst += cbNext; \
  1037. } \
  1038. \
  1039. } else { \
  1040. \
  1041. while (++pbgrf < pInEnd) { \
  1042. \
  1043. pbDst[iR] = ~(BYTE)_GET_R_CLR(pbgrf); \
  1044. pbDst[iG] = ~(BYTE)_GET_G_CLR(pbgrf); \
  1045. pbDst[iB] = ~(BYTE)_GET_B_CLR(pbgrf); \
  1046. pbDst += cbNext; \
  1047. } \
  1048. } \
  1049. }
  1050. VOID
  1051. HTENTRY
  1052. OutputAATo24BPP_RGB(
  1053. PAAHEADER pAAHdr,
  1054. PBGRF pbgrf,
  1055. PBGRF pInEnd,
  1056. LPBYTE pbDst,
  1057. PLONG pIdxBGR,
  1058. LPBYTE pbPat,
  1059. LPBYTE pbPatEnd,
  1060. LONG cbWrapBGR,
  1061. AAOUTPUTINFO AAOutputInfo
  1062. )
  1063. {
  1064. OUTPUTAATO24_32BPP(2, 1, 0, 3);
  1065. }
  1066. VOID
  1067. HTENTRY
  1068. OutputAATo24BPP_BGR(
  1069. PAAHEADER pAAHdr,
  1070. PBGRF pbgrf,
  1071. PBGRF pInEnd,
  1072. LPBYTE pbDst,
  1073. PLONG pIdxBGR,
  1074. LPBYTE pbPat,
  1075. LPBYTE pbPatEnd,
  1076. LONG cbWrapBGR,
  1077. AAOUTPUTINFO AAOutputInfo
  1078. )
  1079. {
  1080. OUTPUTAATO24_32BPP(0, 1, 2, 3);
  1081. }
  1082. VOID
  1083. HTENTRY
  1084. OutputAATo24BPP_ORDER(
  1085. PAAHEADER pAAHdr,
  1086. PBGRF pbgrf,
  1087. PBGRF pInEnd,
  1088. LPBYTE pbDst,
  1089. PLONG pIdxBGR,
  1090. LPBYTE pbPat,
  1091. LPBYTE pbPatEnd,
  1092. LONG cbWrapBGR,
  1093. AAOUTPUTINFO AAOutputInfo
  1094. )
  1095. {
  1096. UINT iR;
  1097. UINT iG;
  1098. UINT iB;
  1099. iR = (UINT)AAOutputInfo.bgri.iR;
  1100. iG = (UINT)AAOutputInfo.bgri.iG;
  1101. iB = (UINT)AAOutputInfo.bgri.iB;
  1102. OUTPUTAATO24_32BPP(iR, iG, iB, 3);
  1103. }
  1104. VOID
  1105. HTENTRY
  1106. OutputAATo32BPP_RGB(
  1107. PAAHEADER pAAHdr,
  1108. PBGRF pbgrf,
  1109. PBGRF pInEnd,
  1110. LPBYTE pbDst,
  1111. PLONG pIdxBGR,
  1112. LPBYTE pbPat,
  1113. LPBYTE pbPatEnd,
  1114. LONG cbWrapBGR,
  1115. AAOUTPUTINFO AAOutputInfo
  1116. )
  1117. {
  1118. OUTPUTAATO24_32BPP(2, 1, 0, 4);
  1119. }
  1120. VOID
  1121. HTENTRY
  1122. OutputAATo32BPP_BGR(
  1123. PAAHEADER pAAHdr,
  1124. PBGRF pbgrf,
  1125. PBGRF pInEnd,
  1126. LPBYTE pbDst,
  1127. PLONG pIdxBGR,
  1128. LPBYTE pbPat,
  1129. LPBYTE pbPatEnd,
  1130. LONG cbWrapBGR,
  1131. AAOUTPUTINFO AAOutputInfo
  1132. )
  1133. {
  1134. OUTPUTAATO24_32BPP(0, 1, 2, 4);
  1135. }
  1136. VOID
  1137. HTENTRY
  1138. OutputAATo32BPP_ORDER(
  1139. PAAHEADER pAAHdr,
  1140. PBGRF pbgrf,
  1141. PBGRF pInEnd,
  1142. LPBYTE pbDst,
  1143. PLONG pIdxBGR,
  1144. LPBYTE pbPat,
  1145. LPBYTE pbPatEnd,
  1146. LONG cbWrapBGR,
  1147. AAOUTPUTINFO AAOutputInfo
  1148. )
  1149. {
  1150. UINT iR;
  1151. UINT iG;
  1152. UINT iB;
  1153. iR = (UINT)AAOutputInfo.bgri.iR;
  1154. iG = (UINT)AAOutputInfo.bgri.iG;
  1155. iB = (UINT)AAOutputInfo.bgri.iB;
  1156. OUTPUTAATO24_32BPP(iR, iG, iB, 4);
  1157. }
  1158. //
  1159. //****************************************************************************
  1160. // BRUSH Generation FUNCTION
  1161. //****************************************************************************
  1162. //
  1163. LONG
  1164. HTENTRY
  1165. CreateHalftoneBrushPat(
  1166. PDEVICECOLORINFO pDCI,
  1167. PCOLORTRIAD pColorTriad,
  1168. PDEVCLRADJ pDevClrAdj,
  1169. LPBYTE pDest,
  1170. LONG cbDestNext
  1171. )
  1172. /*++
  1173. Routine Description:
  1174. Arguments:
  1175. Return Value:
  1176. Author:
  1177. 26-Feb-1997 Wed 13:23:52 created -by- Daniel Chou (danielc)
  1178. Revision History:
  1179. --*/
  1180. {
  1181. LPBYTE pPat;
  1182. LPBYTE pB;
  1183. PLONG pIdxBGR;
  1184. LPBYTE pXlate8BPP;
  1185. AAPATINFO AAPI;
  1186. DW2W4B dw4b;
  1187. DWORD dwB;
  1188. DWORD dwG;
  1189. DWORD dwR;
  1190. DWORD DCAFlags;
  1191. LONG Result;
  1192. BGR8 bgr;
  1193. UINT cCX;
  1194. UINT cCY;
  1195. UINT Count;
  1196. UINT uTmp;
  1197. BYTE XorMask;
  1198. BYTE DestFormat;
  1199. _DEF_LUTAAHDR;
  1200. #define pW ((LPWORD)pB)
  1201. #define pDW ((LPDWORD)pB)
  1202. #define bm8i (*(PBM8BPPINFO)&ExtBGR[3])
  1203. //
  1204. // Compute the rgbLUTAA then compute the BGR
  1205. //
  1206. ComputeRGBLUTAA(pDCI, pDevClrAdj, &(pDCI->rgbLUTPat));
  1207. Result = INTERR_INVALID_DEVRGB_SIZE;
  1208. if ((ComputeBGRMappingTable(pDCI, pDevClrAdj, pColorTriad, &bgr) != 1) ||
  1209. ((Result = CachedHalftonePattern(pDCI,
  1210. pDevClrAdj,
  1211. &AAPI,
  1212. 0,
  1213. 0,
  1214. FALSE)) <= 0)) {
  1215. //-------------------------------------------------------------
  1216. // Release the semaphore and return error
  1217. //-------------------------------------------------------------
  1218. RELEASE_HTMUTEX(pDCI->HTMutex);
  1219. return(Result);
  1220. }
  1221. //
  1222. // Copy down the ExtBGR and release the semaphore now
  1223. //
  1224. cCX = (UINT)pDCI->HTCell.cxReal;
  1225. cCY = (UINT)pDCI->HTCell.Height;
  1226. pIdxBGR = pDCI->rgbLUTPat.IdxBGR;
  1227. //
  1228. // Copy down the necessary infomation
  1229. //
  1230. GET_LUTAAHDR(ExtBGR, pIdxBGR);
  1231. DestFormat = pDevClrAdj->DMI.CTSTDInfo.BMFDest;
  1232. if ((DCAFlags = pDevClrAdj->PrimAdj.Flags) & DCA_XLATE_555_666) {
  1233. GET_P8BPPXLATE(pXlate8BPP, bm8i);
  1234. }
  1235. if (DCAFlags & DCA_XLATE_332) {
  1236. pXlate8BPP = pDCI->CMY8BPPMask.bXlate;
  1237. }
  1238. dwB = _GET_B_CLR(&bgr);
  1239. dwG = _GET_G_CLR(&bgr);
  1240. dwR = _GET_R_CLR(&bgr);
  1241. //----------------------------------------------------------------------
  1242. // Release Semaphore now before we compose the pattern brush
  1243. //----------------------------------------------------------------------
  1244. RELEASE_HTMUTEX(pDCI->HTMutex);
  1245. DBGP_IF(DBGP_BRUSH,
  1246. DBGP("DstOrder=%ld [%ld:%ld:%ld], bgr=%08lx:%08lx:%08lx, ExtBGR=%08lx:%08lx:%08lx %08lx:%08lx:%08lx"
  1247. ARGDW(AAPI.DstOrder.Index)
  1248. ARGDW(AAPI.DstOrder.Order[0])
  1249. ARGDW(AAPI.DstOrder.Order[1])
  1250. ARGDW(AAPI.DstOrder.Order[2])
  1251. ARGDW(dwB) ARGDW(dwG) ARGDW(dwR)
  1252. ARGDW(ExtBGR[0]) ARGDW(ExtBGR[1]) ARGDW(ExtBGR[2])
  1253. ARGDW(ExtBGR[3]) ARGDW(ExtBGR[4]) ARGDW(ExtBGR[5])));
  1254. switch (DestFormat = pDevClrAdj->DMI.CTSTDInfo.BMFDest) {
  1255. case BMF_1BPP:
  1256. //
  1257. // Use only Green/Magenta Pattern
  1258. //
  1259. dwB = ((dwR + dwG + dwB) ^ GRAY_MAX_IDX) >> 4;
  1260. XorMask = (DCAFlags & DCA_USE_ADDITIVE_PRIMS) ? 0x00 : 0xFF;
  1261. #if defined(_X86_)
  1262. _asm {
  1263. mov esi, AAPI.pbPatBGR
  1264. mov edi, pDest
  1265. cld
  1266. mov edx, dwB
  1267. mov ah, XorMask
  1268. CYLoop:
  1269. push esi
  1270. push edi
  1271. mov ebx, cCX
  1272. mov ecx, ebx
  1273. shr ecx, 3
  1274. jz DoBIT
  1275. BYTELoop:
  1276. xor al, al
  1277. cmp dx, WORD PTR [esi + 2 + 0]
  1278. rcl al, 1
  1279. cmp dx, WORD PTR [esi + 2 + 6]
  1280. rcl al, 1
  1281. cmp dx, WORD PTR [esi + 2 + 12]
  1282. rcl al, 1
  1283. cmp dx, WORD PTR [esi + 2 + 18]
  1284. rcl al, 1
  1285. cmp dx, WORD PTR [esi + 2 + 24]
  1286. rcl al, 1
  1287. cmp dx, WORD PTR [esi + 2 + 30]
  1288. rcl al, 1
  1289. cmp dx, WORD PTR [esi + 2 + 36]
  1290. rcl al, 1
  1291. cmp dx, WORD PTR [esi + 2 + 42]
  1292. rcl al, 1
  1293. xor al, ah
  1294. stosb
  1295. add esi, 48
  1296. dec ecx
  1297. jnz BYTELoop
  1298. DoBIT:
  1299. and ebx, 7
  1300. jz DoneLoop
  1301. mov ecx, 8
  1302. sub ecx, ebx
  1303. xor al, al
  1304. BITLoop:
  1305. cmp dx, WORD PTR [esi + 2]
  1306. rcl al, 1
  1307. add esi, 6
  1308. dec ebx
  1309. jnz BITLoop
  1310. xor al, ah
  1311. shl al, cl
  1312. stosb
  1313. DoneLoop:
  1314. pop edi
  1315. pop esi
  1316. add esi, AAPI.cyNextBGR
  1317. add edi, cbDestNext
  1318. dec cCY
  1319. jnz CYLoop
  1320. }
  1321. #else
  1322. while (cCY--) {
  1323. pPat = AAPI.pbPatBGR;
  1324. AAPI.pbPatBGR += AAPI.cyNextBGR;
  1325. pB = pDest;
  1326. pDest += cbDestNext;
  1327. Count = cCX >> 3;
  1328. while (Count--) {
  1329. *pB++ = (BYTE)((((dwB - GETMONOPAT(pPat, 0)) & 0x800000) |
  1330. ((dwB - GETMONOPAT(pPat, 1)) & 0x400000) |
  1331. ((dwB - GETMONOPAT(pPat, 2)) & 0x200000) |
  1332. ((dwB - GETMONOPAT(pPat, 3)) & 0x100000) |
  1333. ((dwB - GETMONOPAT(pPat, 4)) & 0x080000) |
  1334. ((dwB - GETMONOPAT(pPat, 5)) & 0x040000) |
  1335. ((dwB - GETMONOPAT(pPat, 6)) & 0x020000) |
  1336. ((dwB - GETMONOPAT(pPat, 7)) & 0x010000))
  1337. >> 16) ^ XorMask;
  1338. INC_PPAT(pPat, 8);
  1339. }
  1340. if (Count = cCX & 0x07) {
  1341. dw4b.dw = 0;
  1342. uTmp = 8 - Count;
  1343. while (Count--) {
  1344. dw4b.dw = ((dwB - GETMONOPAT(pPat, 0)) & 0x10000) |
  1345. (dw4b.dw << 1);
  1346. INC_PPAT(pPat, 1);
  1347. }
  1348. dw4b.b[2] ^= XorMask;
  1349. dw4b.dw <<= uTmp;
  1350. *pB = dw4b.b[2];
  1351. }
  1352. }
  1353. #endif
  1354. break;
  1355. case BMF_4BPP:
  1356. XorMask = (DCAFlags & DCA_USE_ADDITIVE_PRIMS) ? 0x00 : 0x77;
  1357. while (cCY--) {
  1358. pPat = AAPI.pbPatBGR;
  1359. AAPI.pbPatBGR += AAPI.cyNextBGR;
  1360. pB = pDest;
  1361. pDest += cbDestNext;
  1362. Count = cCX >> 1;
  1363. while (Count--) {
  1364. *pB++ = _GET_4BPP_CLR_COPY_BYTE(pPat,
  1365. dwB, dwG, dwR, dwB, dwG, dwR,
  1366. XorMask);
  1367. INC_PPAT(pPat, 2);
  1368. }
  1369. if (cCX & 0x01) {
  1370. *pB = _GET_4BPP_CLR_COPY_NIBBLE(pPat, dwB, dwG, dwR,
  1371. 0, 1, 2, XorMask);
  1372. }
  1373. }
  1374. break;
  1375. case BMF_4BPP_VGA16:
  1376. while (cCY--) {
  1377. pPat = AAPI.pbPatBGR;
  1378. AAPI.pbPatBGR += AAPI.cyNextBGR;
  1379. pB = pDest;
  1380. pDest += cbDestNext;
  1381. Count = cCX >> 1;
  1382. while (Count--) {
  1383. *pB++ = _GET_VGA16_CLR_COPY_BYTE(pPat,
  1384. dwB, dwG, dwR, dwB, dwG, dwR,
  1385. 0x77);
  1386. INC_PPAT(pPat, 2);
  1387. }
  1388. if (cCX & 0x01) {
  1389. *pB = _GET_VGA16_CLR_COPY_NIBBLE(pPat, dwB, dwG, dwR,
  1390. 0, 1, 2, 0x70);
  1391. }
  1392. }
  1393. break;
  1394. case BMF_8BPP_MONO:
  1395. dw4b.dw = dwB + dwR + dwG;
  1396. dwB = GRAY_W2DW(dw4b.b[0], dw4b.b[1]);
  1397. while (cCY--) {
  1398. pPat = AAPI.pbPatBGR;
  1399. AAPI.pbPatBGR += AAPI.cyNextBGR;
  1400. pB = pDest;
  1401. pDest += cbDestNext;
  1402. Count = cCX;
  1403. while (Count--) {
  1404. GET_MASK8BPP_MONO(pB, pPat, dwB, bm8i.Data.bXor);
  1405. ++pB;
  1406. INC_PPAT(pPat, 1);
  1407. }
  1408. }
  1409. break;
  1410. case BMF_8BPP_B332:
  1411. if (DCAFlags & DCA_XLATE_332) {
  1412. while (cCY--) {
  1413. pPat = AAPI.pbPatBGR;
  1414. AAPI.pbPatBGR += AAPI.cyNextBGR;
  1415. pB = pDest;
  1416. pDest += cbDestNext;
  1417. Count = cCX;
  1418. while (Count--) {
  1419. _GET_MASK8BPP_332_XLATE(pB, pPat, dwB,dwG,dwR, pXlate8BPP);
  1420. ++pB;
  1421. INC_PPAT(pPat, 1);
  1422. }
  1423. }
  1424. } else {
  1425. while (cCY--) {
  1426. pPat = AAPI.pbPatBGR;
  1427. AAPI.pbPatBGR += AAPI.cyNextBGR;
  1428. pB = pDest;
  1429. pDest += cbDestNext;
  1430. Count = cCX;
  1431. while (Count--) {
  1432. _GET_MASK8BPP_332(pB, pPat, dwB, dwG, dwR, NULL);
  1433. ++pB;
  1434. INC_PPAT(pPat, 1);
  1435. }
  1436. }
  1437. }
  1438. break;
  1439. case BMF_8BPP_K_B332:
  1440. if (DCAFlags & DCA_XLATE_332) {
  1441. while (cCY--) {
  1442. pPat = AAPI.pbPatBGR;
  1443. AAPI.pbPatBGR += AAPI.cyNextBGR;
  1444. pB = pDest;
  1445. pDest += cbDestNext;
  1446. Count = cCX;
  1447. while (Count--) {
  1448. _GET_MASK8BPP_REP_K(pB,
  1449. pPat,
  1450. dwB,
  1451. dwG,
  1452. dwR,
  1453. _GET_MASK8BPP_K_332_XLATE,
  1454. pXlate8BPP);
  1455. ++pB;
  1456. INC_PPAT(pPat, 1);
  1457. }
  1458. }
  1459. } else {
  1460. while (cCY--) {
  1461. pPat = AAPI.pbPatBGR;
  1462. AAPI.pbPatBGR += AAPI.cyNextBGR;
  1463. pB = pDest;
  1464. pDest += cbDestNext;
  1465. Count = cCX;
  1466. while (Count--) {
  1467. _GET_MASK8BPP_REP_K(pB,
  1468. pPat,
  1469. dwB,
  1470. dwG,
  1471. dwR,
  1472. _GET_MASK8BPP_K_332,
  1473. NULL);
  1474. ++pB;
  1475. INC_PPAT(pPat, 1);
  1476. }
  1477. }
  1478. }
  1479. break;
  1480. case BMF_8BPP_L555:
  1481. case BMF_8BPP_L666:
  1482. while (cCY--) {
  1483. pPat = AAPI.pbPatBGR;
  1484. AAPI.pbPatBGR += AAPI.cyNextBGR;
  1485. pB = pDest;
  1486. pDest += cbDestNext;
  1487. Count = cCX;
  1488. while (Count--) {
  1489. _GET_MASK8BPP_XLATE(pB, pPat, dwB, dwG, dwR, pXlate8BPP);
  1490. ++pB;
  1491. INC_PPAT(pPat, 1);
  1492. }
  1493. }
  1494. break;
  1495. case BMF_8BPP_K_L555:
  1496. case BMF_8BPP_K_L666:
  1497. while (cCY--) {
  1498. pPat = AAPI.pbPatBGR;
  1499. AAPI.pbPatBGR += AAPI.cyNextBGR;
  1500. pB = pDest;
  1501. pDest += cbDestNext;
  1502. Count = cCX;
  1503. while (Count--) {
  1504. _GET_MASK8BPP_REP_K(pB,
  1505. pPat,
  1506. dwB,
  1507. dwG,
  1508. dwR,
  1509. _GET_MASK8BPP_K_XLATE,
  1510. pXlate8BPP);
  1511. ++pB;
  1512. INC_PPAT(pPat, 1);
  1513. }
  1514. }
  1515. break;
  1516. case BMF_8BPP_VGA256:
  1517. while (cCY--) {
  1518. pPat = AAPI.pbPatBGR;
  1519. AAPI.pbPatBGR += AAPI.cyNextBGR;
  1520. pB = pDest;
  1521. pDest += cbDestNext;
  1522. Count = cCX;
  1523. while (Count--) {
  1524. *pB++ = _GET_VGA256_CLR_COPY_XLATE(pPat,
  1525. VGA256Xlate,
  1526. dwB,
  1527. dwG,
  1528. dwR);
  1529. INC_PPAT(pPat, 1);
  1530. }
  1531. }
  1532. break;
  1533. case BMF_16BPP_555:
  1534. case BMF_16BPP_565:
  1535. while (cCY--) {
  1536. pPat = AAPI.pbPatBGR;
  1537. AAPI.pbPatBGR += AAPI.cyNextBGR;
  1538. pDW = (LPDWORD)pDest;
  1539. pDest += cbDestNext;
  1540. Count = cCX >> 1;
  1541. while (Count--) {
  1542. *pDW++ = _GET_16BPP_COPY_DW_MASK(pPat,
  1543. dwB, dwG, dwR,
  1544. dwB, dwG, dwR,
  1545. ExtBGR[0],
  1546. ExtBGR[1],
  1547. ExtBGR[2],
  1548. ExtBGR[3]);
  1549. INC_PPAT(pPat, 2);
  1550. }
  1551. if (cCX & 0x01) {
  1552. *pW = _GET_16BPP_COPY_W_MASK(pPat,
  1553. dwB, dwG, dwR,
  1554. ExtBGR[0],
  1555. ExtBGR[1],
  1556. ExtBGR[2],
  1557. ExtBGR[3]);
  1558. }
  1559. }
  1560. break;
  1561. case BMF_24BPP:
  1562. case BMF_32BPP:
  1563. pB = pDest;
  1564. pB[AAPI.DstOrder.Order[0]] = ~(BYTE)dwR;
  1565. pB[AAPI.DstOrder.Order[1]] = ~(BYTE)dwG;
  1566. pB[AAPI.DstOrder.Order[2]] = ~(BYTE)dwB;
  1567. if (DestFormat == BMF_24BPP) {
  1568. dwB = 3;
  1569. dwG = (cCX << 1) + cCX;
  1570. } else {
  1571. dwB = 4;
  1572. dwG = (cCX << 2);
  1573. pB[3] = 0;
  1574. }
  1575. pB += (uTmp = dwB);
  1576. Count = dwG;
  1577. while (Count -= uTmp) {
  1578. if ((uTmp = dwB) > Count) {
  1579. uTmp = Count;
  1580. }
  1581. CopyMemory(pB, pDest, uTmp);
  1582. pB += uTmp;
  1583. dwB += uTmp;
  1584. }
  1585. //
  1586. // Now copy down the remaining scanlines from first scanline
  1587. //
  1588. pB = pDest;
  1589. while (--cCY) {
  1590. CopyMemory(pDest += cbDestNext, pB, dwG);
  1591. }
  1592. break;
  1593. default:
  1594. return(HTERR_INVALID_DEST_FORMAT);
  1595. }
  1596. return(Result);
  1597. #undef bm8i
  1598. #undef pW
  1599. #undef pDW
  1600. }
  1601. #if DBG
  1602. LPSTR
  1603. GetAAOutputFuncName(
  1604. AAOUTPUTFUNC AAOutputFunc
  1605. )
  1606. /*++
  1607. Routine Description:
  1608. Arguments:
  1609. Return Value:
  1610. Author:
  1611. 06-Jan-1999 Wed 19:11:27 created -by- Daniel Chou (danielc)
  1612. Revision History:
  1613. --*/
  1614. {
  1615. if (AAOutputFunc == (AAOUTPUTFUNC)OutputAATo1BPP) {
  1616. return("OutputAATo1BPP");
  1617. } else if (AAOutputFunc == (AAOUTPUTFUNC)OutputAATo4BPP) {
  1618. return("OutputAATo4BPP");
  1619. } else if (AAOutputFunc == (AAOUTPUTFUNC)OutputAAToVGA16) {
  1620. return("OutputAAToVGA16");
  1621. } else if (AAOutputFunc == (AAOUTPUTFUNC)OutputAAToVGA256) {
  1622. return("OutputAAToVGA256");
  1623. } else if (AAOutputFunc == (AAOUTPUTFUNC)OutputAATo8BPP_B332) {
  1624. return("OutputAATo8BPP_B332");
  1625. } else if (AAOutputFunc == (AAOUTPUTFUNC)OutputAATo8BPP_B332_XLATE) {
  1626. return("OutputAATo8BPP_B332_XLATE");
  1627. } else if (AAOutputFunc == (AAOUTPUTFUNC)OutputAATo8BPP_XLATE) {
  1628. return("OutputAATo8BPP_XLATE");
  1629. } else if (AAOutputFunc == (AAOUTPUTFUNC)OutputAATo8BPP_K_XLATE) {
  1630. return("OutputAATo8BPP_K_XLATE");
  1631. } else if (AAOutputFunc == (AAOUTPUTFUNC)OutputAATo8BPP_K_B332) {
  1632. return("OutputAATo8BPP_K_B332");
  1633. } else if (AAOutputFunc == (AAOUTPUTFUNC)OutputAATo8BPP_K_B332_XLATE) {
  1634. return("OutputAATo8BPP_K_B332_XLATE");
  1635. } else if (AAOutputFunc == (AAOUTPUTFUNC)OutputAATo8BPP_MONO) {
  1636. return("OutputAATo8BPP_MONO");
  1637. } else if (AAOutputFunc == (AAOUTPUTFUNC)OutputAATo16BPP_ExtBGR) {
  1638. return("OutputAATo16BPP_ExtBGR");
  1639. } else if (AAOutputFunc == (AAOUTPUTFUNC)OutputAATo16BPP_555_RGB) {
  1640. return("OutputAATo16BPP_555_RGB");
  1641. } else if (AAOutputFunc == (AAOUTPUTFUNC)OutputAATo16BPP_555_BGR) {
  1642. return("OutputAATo16BPP_555_BGR");
  1643. } else if (AAOutputFunc == (AAOUTPUTFUNC)OutputAATo16BPP_565_RGB) {
  1644. return("OutputAATo16BPP_565_RGB");
  1645. } else if (AAOutputFunc == (AAOUTPUTFUNC)OutputAATo16BPP_565_BGR) {
  1646. return("OutputAATo16BPP_565_BGR");
  1647. } else if (AAOutputFunc == (AAOUTPUTFUNC)OutputAATo24BPP_RGB) {
  1648. return("OutputAATo24BPP_RGB");
  1649. } else if (AAOutputFunc == (AAOUTPUTFUNC)OutputAATo24BPP_BGR) {
  1650. return("OutputAATo24BPP_BGR");
  1651. } else if (AAOutputFunc == (AAOUTPUTFUNC)OutputAATo24BPP_ORDER) {
  1652. return("OutputAATo24BPP_ORDER");
  1653. } else if (AAOutputFunc == (AAOUTPUTFUNC)OutputAATo32BPP_RGB) {
  1654. return("OutputAATo32BPP_RGB");
  1655. } else if (AAOutputFunc == (AAOUTPUTFUNC)OutputAATo32BPP_BGR) {
  1656. return("OutputAATo32BPP_BGR");
  1657. } else if (AAOutputFunc == (AAOUTPUTFUNC)OutputAATo32BPP_ORDER) {
  1658. return("OutputAATo32BPP_ORDER");
  1659. } else {
  1660. return("ERROR: Unknow Function");
  1661. }
  1662. }
  1663. #endif