fb.h 42 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566
  1. /*
  2. *
  3. * Copyright © 1998 Keith Packard
  4. *
  5. * Permission to use, copy, modify, distribute, and sell this software and its
  6. * documentation for any purpose is hereby granted without fee, provided that
  7. * the above copyright notice appear in all copies and that both that
  8. * copyright notice and this permission notice appear in supporting
  9. * documentation, and that the name of Keith Packard not be used in
  10. * advertising or publicity pertaining to distribution of the software without
  11. * specific, written prior permission. Keith Packard makes no
  12. * representations about the suitability of this software for any purpose. It
  13. * is provided "as is" without express or implied warranty.
  14. *
  15. * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  16. * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
  17. * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  18. * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  19. * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  20. * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  21. * PERFORMANCE OF THIS SOFTWARE.
  22. */
  23. #ifndef _FB_H_
  24. #define _FB_H_
  25. #include <X11/X.h>
  26. #include "scrnintstr.h"
  27. #include "pixmap.h"
  28. #include "pixmapstr.h"
  29. #include "region.h"
  30. #include "gcstruct.h"
  31. #include "colormap.h"
  32. #include "miscstruct.h"
  33. #include "servermd.h"
  34. #include "windowstr.h"
  35. #include "mi.h"
  36. #include "migc.h"
  37. #include "picturestr.h"
  38. /*
  39. * This single define controls the basic size of data manipulated
  40. * by this software; it must be log2(sizeof (FbBits) * 8)
  41. */
  42. #ifndef FB_SHIFT
  43. #define FB_SHIFT LOG2_BITMAP_PAD
  44. #endif
  45. #if FB_SHIFT < LOG2_BITMAP_PAD
  46. error FB_SHIFT must be >= LOG2_BITMAP_PAD
  47. #endif
  48. #define FB_UNIT (1 << FB_SHIFT)
  49. #define FB_HALFUNIT (1 << (FB_SHIFT-1))
  50. #define FB_MASK (FB_UNIT - 1)
  51. #define FB_ALLONES ((FbBits) -1)
  52. #if GLYPHPADBYTES != 4
  53. #error "GLYPHPADBYTES must be 4"
  54. #endif
  55. #define FB_STIP_SHIFT LOG2_BITMAP_PAD
  56. #define FB_STIP_UNIT (1 << FB_STIP_SHIFT)
  57. #define FB_STIP_MASK (FB_STIP_UNIT - 1)
  58. #define FB_STIP_ALLONES ((FbStip) -1)
  59. #define FB_STIP_ODDSTRIDE(s) (((s) & (FB_MASK >> FB_STIP_SHIFT)) != 0)
  60. #define FB_STIP_ODDPTR(p) ((((long) (p)) & (FB_MASK >> 3)) != 0)
  61. #define FbStipStrideToBitsStride(s) (((s) >> (FB_SHIFT - FB_STIP_SHIFT)))
  62. #define FbBitsStrideToStipStride(s) (((s) << (FB_SHIFT - FB_STIP_SHIFT)))
  63. #define FbFullMask(n) ((n) == FB_UNIT ? FB_ALLONES : ((((FbBits) 1) << n) - 1))
  64. #if FB_SHIFT == 6
  65. # if defined(__alpha__) || defined(__alpha) || \
  66. defined(ia64) || defined(__ia64__) || \
  67. defined(__sparc64__) || defined(_LP64) || \
  68. defined(__s390x__) || \
  69. defined(amd64) || defined (__amd64__) || \
  70. defined (__powerpc64__) || \
  71. (defined(sgi) && (_MIPS_SZLONG == 64))
  72. typedef unsigned long FbBits;
  73. # else
  74. typedef unsigned long long FbBits;
  75. # endif
  76. #endif
  77. #if FB_SHIFT == 5
  78. typedef CARD32 FbBits;
  79. #endif
  80. #if FB_SHIFT == 4
  81. typedef CARD16 FbBits;
  82. #endif
  83. #if LOG2_BITMAP_PAD == FB_SHIFT
  84. typedef FbBits FbStip;
  85. #else
  86. #if LOG2_BITMAP_PAD == 5
  87. typedef CARD32 FbStip;
  88. #endif
  89. #endif
  90. typedef int FbStride;
  91. #ifdef FB_DEBUG
  92. extern _X_EXPORT void fbValidateDrawable(DrawablePtr d);
  93. extern _X_EXPORT void fbInitializeDrawable(DrawablePtr d);
  94. extern _X_EXPORT void fbSetBits(FbStip * bits, int stride, FbStip data);
  95. #define FB_HEAD_BITS (FbStip) (0xbaadf00d)
  96. #define FB_TAIL_BITS (FbStip) (0xbaddf0ad)
  97. #else
  98. #define fbValidateDrawable(d)
  99. #define fdInitializeDrawable(d)
  100. #endif
  101. #include "fbrop.h"
  102. #if BITMAP_BIT_ORDER == LSBFirst
  103. #define FbScrLeft(x,n) ((x) >> (n))
  104. #define FbScrRight(x,n) ((x) << (n))
  105. /* #define FbLeftBits(x,n) ((x) & ((((FbBits) 1) << (n)) - 1)) */
  106. #define FbLeftStipBits(x,n) ((x) & ((((FbStip) 1) << (n)) - 1))
  107. #define FbStipMoveLsb(x,s,n) (FbStipRight (x,(s)-(n)))
  108. #define FbPatternOffsetBits 0
  109. #else
  110. #define FbScrLeft(x,n) ((x) << (n))
  111. #define FbScrRight(x,n) ((x) >> (n))
  112. /* #define FbLeftBits(x,n) ((x) >> (FB_UNIT - (n))) */
  113. #define FbLeftStipBits(x,n) ((x) >> (FB_STIP_UNIT - (n)))
  114. #define FbStipMoveLsb(x,s,n) (x)
  115. #define FbPatternOffsetBits (sizeof (FbBits) - 1)
  116. #endif
  117. #include "micoord.h"
  118. #define FbStipLeft(x,n) FbScrLeft(x,n)
  119. #define FbStipRight(x,n) FbScrRight(x,n)
  120. #define FbRotLeft(x,n) FbScrLeft(x,n) | (n ? FbScrRight(x,FB_UNIT-n) : 0)
  121. #define FbRotRight(x,n) FbScrRight(x,n) | (n ? FbScrLeft(x,FB_UNIT-n) : 0)
  122. #define FbRotStipLeft(x,n) FbStipLeft(x,n) | (n ? FbStipRight(x,FB_STIP_UNIT-n) : 0)
  123. #define FbRotStipRight(x,n) FbStipRight(x,n) | (n ? FbStipLeft(x,FB_STIP_UNIT-n) : 0)
  124. #define FbLeftMask(x) ( ((x) & FB_MASK) ? \
  125. FbScrRight(FB_ALLONES,(x) & FB_MASK) : 0)
  126. #define FbRightMask(x) ( ((FB_UNIT - (x)) & FB_MASK) ? \
  127. FbScrLeft(FB_ALLONES,(FB_UNIT - (x)) & FB_MASK) : 0)
  128. #define FbLeftStipMask(x) ( ((x) & FB_STIP_MASK) ? \
  129. FbStipRight(FB_STIP_ALLONES,(x) & FB_STIP_MASK) : 0)
  130. #define FbRightStipMask(x) ( ((FB_STIP_UNIT - (x)) & FB_STIP_MASK) ? \
  131. FbScrLeft(FB_STIP_ALLONES,(FB_STIP_UNIT - (x)) & FB_STIP_MASK) : 0)
  132. #define FbBitsMask(x,w) (FbScrRight(FB_ALLONES,(x) & FB_MASK) & \
  133. FbScrLeft(FB_ALLONES,(FB_UNIT - ((x) + (w))) & FB_MASK))
  134. #define FbStipMask(x,w) (FbStipRight(FB_STIP_ALLONES,(x) & FB_STIP_MASK) & \
  135. FbStipLeft(FB_STIP_ALLONES,(FB_STIP_UNIT - ((x)+(w))) & FB_STIP_MASK))
  136. #define FbMaskBits(x,w,l,n,r) { \
  137. n = (w); \
  138. r = FbRightMask((x)+n); \
  139. l = FbLeftMask(x); \
  140. if (l) { \
  141. n -= FB_UNIT - ((x) & FB_MASK); \
  142. if (n < 0) { \
  143. n = 0; \
  144. l &= r; \
  145. r = 0; \
  146. } \
  147. } \
  148. n >>= FB_SHIFT; \
  149. }
  150. #define FbByteMaskInvalid 0x10
  151. #define FbPatternOffset(o,t) ((o) ^ (FbPatternOffsetBits & ~(sizeof (t) - 1)))
  152. #define FbPtrOffset(p,o,t) ((t *) ((CARD8 *) (p) + (o)))
  153. #define FbSelectPatternPart(xor,o,t) ((xor) >> (FbPatternOffset (o,t) << 3))
  154. #define FbStorePart(dst,off,t,xor) (*FbPtrOffset(dst,off,t) = \
  155. FbSelectPart(xor,off,t))
  156. #ifndef FbSelectPart
  157. #define FbSelectPart(x,o,t) FbSelectPatternPart(x,o,t)
  158. #endif
  159. #define FbMaskBitsBytes(x,w,copy,l,lb,n,r,rb) { \
  160. n = (w); \
  161. lb = 0; \
  162. rb = 0; \
  163. r = FbRightMask((x)+n); \
  164. if (r) { \
  165. /* compute right byte length */ \
  166. if ((copy) && (((x) + n) & 7) == 0) { \
  167. rb = (((x) + n) & FB_MASK) >> 3; \
  168. } else { \
  169. rb = FbByteMaskInvalid; \
  170. } \
  171. } \
  172. l = FbLeftMask(x); \
  173. if (l) { \
  174. /* compute left byte length */ \
  175. if ((copy) && ((x) & 7) == 0) { \
  176. lb = ((x) & FB_MASK) >> 3; \
  177. } else { \
  178. lb = FbByteMaskInvalid; \
  179. } \
  180. /* subtract out the portion painted by leftMask */ \
  181. n -= FB_UNIT - ((x) & FB_MASK); \
  182. if (n < 0) { \
  183. if (lb != FbByteMaskInvalid) { \
  184. if (rb == FbByteMaskInvalid) { \
  185. lb = FbByteMaskInvalid; \
  186. } else if (rb) { \
  187. lb |= (rb - lb) << (FB_SHIFT - 3); \
  188. rb = 0; \
  189. } \
  190. } \
  191. n = 0; \
  192. l &= r; \
  193. r = 0; \
  194. }\
  195. } \
  196. n >>= FB_SHIFT; \
  197. }
  198. #if FB_SHIFT == 6
  199. #define FbDoLeftMaskByteRRop6Cases(dst,xor) \
  200. case (sizeof (FbBits) - 7) | (1 << (FB_SHIFT - 3)): \
  201. FbStorePart(dst,sizeof (FbBits) - 7,CARD8,xor); \
  202. break; \
  203. case (sizeof (FbBits) - 7) | (2 << (FB_SHIFT - 3)): \
  204. FbStorePart(dst,sizeof (FbBits) - 7,CARD8,xor); \
  205. FbStorePart(dst,sizeof (FbBits) - 6,CARD8,xor); \
  206. break; \
  207. case (sizeof (FbBits) - 7) | (3 << (FB_SHIFT - 3)): \
  208. FbStorePart(dst,sizeof (FbBits) - 7,CARD8,xor); \
  209. FbStorePart(dst,sizeof (FbBits) - 6,CARD16,xor); \
  210. break; \
  211. case (sizeof (FbBits) - 7) | (4 << (FB_SHIFT - 3)): \
  212. FbStorePart(dst,sizeof (FbBits) - 7,CARD8,xor); \
  213. FbStorePart(dst,sizeof (FbBits) - 6,CARD16,xor); \
  214. FbStorePart(dst,sizeof (FbBits) - 4,CARD8,xor); \
  215. break; \
  216. case (sizeof (FbBits) - 7) | (5 << (FB_SHIFT - 3)): \
  217. FbStorePart(dst,sizeof (FbBits) - 7,CARD8,xor); \
  218. FbStorePart(dst,sizeof (FbBits) - 6,CARD16,xor); \
  219. FbStorePart(dst,sizeof (FbBits) - 4,CARD16,xor); \
  220. break; \
  221. case (sizeof (FbBits) - 7) | (6 << (FB_SHIFT - 3)): \
  222. FbStorePart(dst,sizeof (FbBits) - 7,CARD8,xor); \
  223. FbStorePart(dst,sizeof (FbBits) - 6,CARD16,xor); \
  224. FbStorePart(dst,sizeof (FbBits) - 4,CARD16,xor); \
  225. FbStorePart(dst,sizeof (FbBits) - 2,CARD8,xor); \
  226. break; \
  227. case (sizeof (FbBits) - 7): \
  228. FbStorePart(dst,sizeof (FbBits) - 7,CARD8,xor); \
  229. FbStorePart(dst,sizeof (FbBits) - 6,CARD16,xor); \
  230. FbStorePart(dst,sizeof (FbBits) - 4,CARD32,xor); \
  231. break; \
  232. case (sizeof (FbBits) - 6) | (1 << (FB_SHIFT - 3)): \
  233. FbStorePart(dst,sizeof (FbBits) - 6,CARD8,xor); \
  234. break; \
  235. case (sizeof (FbBits) - 6) | (2 << (FB_SHIFT - 3)): \
  236. FbStorePart(dst,sizeof (FbBits) - 6,CARD16,xor); \
  237. break; \
  238. case (sizeof (FbBits) - 6) | (3 << (FB_SHIFT - 3)): \
  239. FbStorePart(dst,sizeof (FbBits) - 6,CARD16,xor); \
  240. FbStorePart(dst,sizeof (FbBits) - 4,CARD8,xor); \
  241. break; \
  242. case (sizeof (FbBits) - 6) | (4 << (FB_SHIFT - 3)): \
  243. FbStorePart(dst,sizeof (FbBits) - 6,CARD16,xor); \
  244. FbStorePart(dst,sizeof (FbBits) - 4,CARD16,xor); \
  245. break; \
  246. case (sizeof (FbBits) - 6) | (5 << (FB_SHIFT - 3)): \
  247. FbStorePart(dst,sizeof (FbBits) - 6,CARD16,xor); \
  248. FbStorePart(dst,sizeof (FbBits) - 4,CARD16,xor); \
  249. FbStorePart(dst,sizeof (FbBits) - 2,CARD8,xor); \
  250. break; \
  251. case (sizeof (FbBits) - 6): \
  252. FbStorePart(dst,sizeof (FbBits) - 6,CARD16,xor); \
  253. FbStorePart(dst,sizeof (FbBits) - 4,CARD32,xor); \
  254. break; \
  255. case (sizeof (FbBits) - 5) | (1 << (FB_SHIFT - 3)): \
  256. FbStorePart(dst,sizeof (FbBits) - 5,CARD8,xor); \
  257. break; \
  258. case (sizeof (FbBits) - 5) | (2 << (FB_SHIFT - 3)): \
  259. FbStorePart(dst,sizeof (FbBits) - 5,CARD8,xor); \
  260. FbStorePart(dst,sizeof (FbBits) - 4,CARD8,xor); \
  261. break; \
  262. case (sizeof (FbBits) - 5) | (3 << (FB_SHIFT - 3)): \
  263. FbStorePart(dst,sizeof (FbBits) - 5,CARD8,xor); \
  264. FbStorePart(dst,sizeof (FbBits) - 4,CARD16,xor); \
  265. break; \
  266. case (sizeof (FbBits) - 5) | (4 << (FB_SHIFT - 3)): \
  267. FbStorePart(dst,sizeof (FbBits) - 5,CARD8,xor); \
  268. FbStorePart(dst,sizeof (FbBits) - 4,CARD16,xor); \
  269. FbStorePart(dst,sizeof (FbBits) - 2,CARD8,xor); \
  270. break; \
  271. case (sizeof (FbBits) - 5): \
  272. FbStorePart(dst,sizeof (FbBits) - 5,CARD8,xor); \
  273. FbStorePart(dst,sizeof (FbBits) - 4,CARD32,xor); \
  274. break; \
  275. case (sizeof (FbBits) - 4) | (1 << (FB_SHIFT - 3)): \
  276. FbStorePart(dst,sizeof (FbBits) - 4,CARD8,xor); \
  277. break; \
  278. case (sizeof (FbBits) - 4) | (2 << (FB_SHIFT - 3)): \
  279. FbStorePart(dst,sizeof (FbBits) - 4,CARD16,xor); \
  280. break; \
  281. case (sizeof (FbBits) - 4) | (3 << (FB_SHIFT - 3)): \
  282. FbStorePart(dst,sizeof (FbBits) - 4,CARD16,xor); \
  283. FbStorePart(dst,sizeof (FbBits) - 2,CARD8,xor); \
  284. break; \
  285. case (sizeof (FbBits) - 4): \
  286. FbStorePart(dst,sizeof (FbBits) - 4,CARD32,xor); \
  287. break;
  288. #define FbDoRightMaskByteRRop6Cases(dst,xor) \
  289. case 4: \
  290. FbStorePart(dst,0,CARD32,xor); \
  291. break; \
  292. case 5: \
  293. FbStorePart(dst,0,CARD32,xor); \
  294. FbStorePart(dst,4,CARD8,xor); \
  295. break; \
  296. case 6: \
  297. FbStorePart(dst,0,CARD32,xor); \
  298. FbStorePart(dst,4,CARD16,xor); \
  299. break; \
  300. case 7: \
  301. FbStorePart(dst,0,CARD32,xor); \
  302. FbStorePart(dst,4,CARD16,xor); \
  303. FbStorePart(dst,6,CARD8,xor); \
  304. break;
  305. #else
  306. #define FbDoLeftMaskByteRRop6Cases(dst,xor)
  307. #define FbDoRightMaskByteRRop6Cases(dst,xor)
  308. #endif
  309. #define FbDoLeftMaskByteRRop(dst,lb,l,and,xor) { \
  310. switch (lb) { \
  311. FbDoLeftMaskByteRRop6Cases(dst,xor) \
  312. case (sizeof (FbBits) - 3) | (1 << (FB_SHIFT - 3)): \
  313. FbStorePart(dst,sizeof (FbBits) - 3,CARD8,xor); \
  314. break; \
  315. case (sizeof (FbBits) - 3) | (2 << (FB_SHIFT - 3)): \
  316. FbStorePart(dst,sizeof (FbBits) - 3,CARD8,xor); \
  317. FbStorePart(dst,sizeof (FbBits) - 2,CARD8,xor); \
  318. break; \
  319. case (sizeof (FbBits) - 2) | (1 << (FB_SHIFT - 3)): \
  320. FbStorePart(dst,sizeof (FbBits) - 2,CARD8,xor); \
  321. break; \
  322. case sizeof (FbBits) - 3: \
  323. FbStorePart(dst,sizeof (FbBits) - 3,CARD8,xor); \
  324. case sizeof (FbBits) - 2: \
  325. FbStorePart(dst,sizeof (FbBits) - 2,CARD16,xor); \
  326. break; \
  327. case sizeof (FbBits) - 1: \
  328. FbStorePart(dst,sizeof (FbBits) - 1,CARD8,xor); \
  329. break; \
  330. default: \
  331. *dst = FbDoMaskRRop(*dst, and, xor, l); \
  332. break; \
  333. } \
  334. }
  335. #define FbDoRightMaskByteRRop(dst,rb,r,and,xor) { \
  336. switch (rb) { \
  337. case 1: \
  338. FbStorePart(dst,0,CARD8,xor); \
  339. break; \
  340. case 2: \
  341. FbStorePart(dst,0,CARD16,xor); \
  342. break; \
  343. case 3: \
  344. FbStorePart(dst,0,CARD16,xor); \
  345. FbStorePart(dst,2,CARD8,xor); \
  346. break; \
  347. FbDoRightMaskByteRRop6Cases(dst,xor) \
  348. default: \
  349. *dst = FbDoMaskRRop (*dst, and, xor, r); \
  350. } \
  351. }
  352. #define FbMaskStip(x,w,l,n,r) { \
  353. n = (w); \
  354. r = FbRightStipMask((x)+n); \
  355. l = FbLeftStipMask(x); \
  356. if (l) { \
  357. n -= FB_STIP_UNIT - ((x) & FB_STIP_MASK); \
  358. if (n < 0) { \
  359. n = 0; \
  360. l &= r; \
  361. r = 0; \
  362. } \
  363. } \
  364. n >>= FB_STIP_SHIFT; \
  365. }
  366. /*
  367. * These macros are used to transparently stipple
  368. * in copy mode; the expected usage is with 'n' constant
  369. * so all of the conditional parts collapse into a minimal
  370. * sequence of partial word writes
  371. *
  372. * 'n' is the bytemask of which bytes to store, 'a' is the address
  373. * of the FbBits base unit, 'o' is the offset within that unit
  374. *
  375. * The term "lane" comes from the hardware term "byte-lane" which
  376. */
  377. #define FbLaneCase1(n,a,o) ((n) == 0x01 ? \
  378. (*(CARD8 *) ((a)+FbPatternOffset(o,CARD8)) = \
  379. fgxor) : 0)
  380. #define FbLaneCase2(n,a,o) ((n) == 0x03 ? \
  381. (*(CARD16 *) ((a)+FbPatternOffset(o,CARD16)) = \
  382. fgxor) : \
  383. ((void)FbLaneCase1((n)&1,a,o), \
  384. FbLaneCase1((n)>>1,a,(o)+1)))
  385. #define FbLaneCase4(n,a,o) ((n) == 0x0f ? \
  386. (*(CARD32 *) ((a)+FbPatternOffset(o,CARD32)) = \
  387. fgxor) : \
  388. ((void)FbLaneCase2((n)&3,a,o), \
  389. FbLaneCase2((n)>>2,a,(o)+2)))
  390. #define FbLaneCase8(n,a,o) ((n) == 0x0ff ? (*(FbBits *) ((a)+(o)) = fgxor) : \
  391. ((void)FbLaneCase4((n)&15,a,o), \
  392. FbLaneCase4((n)>>4,a,(o)+4)))
  393. #if FB_SHIFT == 6
  394. #define FbLaneCase(n,a) FbLaneCase8(n,(CARD8 *) (a),0)
  395. #endif
  396. #if FB_SHIFT == 5
  397. #define FbLaneCase(n,a) FbLaneCase4(n,(CARD8 *) (a),0)
  398. #endif
  399. /* Rotate a filled pixel value to the specified alignement */
  400. #define FbRot24(p,b) (FbScrRight(p,b) | FbScrLeft(p,24-(b)))
  401. #define FbRot24Stip(p,b) (FbStipRight(p,b) | FbStipLeft(p,24-(b)))
  402. /* step a filled pixel value to the next/previous FB_UNIT alignment */
  403. #define FbNext24Pix(p) (FbRot24(p,(24-FB_UNIT%24)))
  404. #define FbPrev24Pix(p) (FbRot24(p,FB_UNIT%24))
  405. #define FbNext24Stip(p) (FbRot24(p,(24-FB_STIP_UNIT%24)))
  406. #define FbPrev24Stip(p) (FbRot24(p,FB_STIP_UNIT%24))
  407. /* step a rotation value to the next/previous rotation value */
  408. #if FB_UNIT == 64
  409. #define FbNext24Rot(r) ((r) == 16 ? 0 : (r) + 8)
  410. #define FbPrev24Rot(r) ((r) == 0 ? 16 : (r) - 8)
  411. #if IMAGE_BYTE_ORDER == MSBFirst
  412. #define FbFirst24Rot(x) (((x) + 8) % 24)
  413. #else
  414. #define FbFirst24Rot(x) ((x) % 24)
  415. #endif
  416. #endif
  417. #if FB_UNIT == 32
  418. #define FbNext24Rot(r) ((r) == 0 ? 16 : (r) - 8)
  419. #define FbPrev24Rot(r) ((r) == 16 ? 0 : (r) + 8)
  420. #if IMAGE_BYTE_ORDER == MSBFirst
  421. #define FbFirst24Rot(x) (((x) + 16) % 24)
  422. #else
  423. #define FbFirst24Rot(x) ((x) % 24)
  424. #endif
  425. #endif
  426. #define FbNext24RotStip(r) ((r) == 0 ? 16 : (r) - 8)
  427. #define FbPrev24RotStip(r) ((r) == 16 ? 0 : (r) + 8)
  428. /* Whether 24-bit specific code is needed for this filled pixel value */
  429. #define FbCheck24Pix(p) ((p) == FbNext24Pix(p))
  430. /* Macros for dealing with dashing */
  431. #define FbDashDeclare \
  432. unsigned char *__dash, *__firstDash, *__lastDash
  433. #define FbDashInit(pGC,pPriv,dashOffset,dashlen,even) { \
  434. (even) = TRUE; \
  435. __firstDash = (pGC)->dash; \
  436. __lastDash = __firstDash + (pGC)->numInDashList; \
  437. (dashOffset) %= (pPriv)->dashLength; \
  438. \
  439. __dash = __firstDash; \
  440. while ((dashOffset) >= ((dashlen) = *__dash)) \
  441. { \
  442. (dashOffset) -= (dashlen); \
  443. (even) = 1-(even); \
  444. if (++__dash == __lastDash) \
  445. __dash = __firstDash; \
  446. } \
  447. (dashlen) -= (dashOffset); \
  448. }
  449. #define FbDashNext(dashlen) { \
  450. if (++__dash == __lastDash) \
  451. __dash = __firstDash; \
  452. (dashlen) = *__dash; \
  453. }
  454. /* as numInDashList is always even, this case can skip a test */
  455. #define FbDashNextEven(dashlen) { \
  456. (dashlen) = *++__dash; \
  457. }
  458. #define FbDashNextOdd(dashlen) FbDashNext(dashlen)
  459. #define FbDashStep(dashlen,even) { \
  460. if (!--(dashlen)) { \
  461. FbDashNext(dashlen); \
  462. (even) = 1-(even); \
  463. } \
  464. }
  465. /* XXX fb*PrivateIndex should be static, but it breaks the ABI */
  466. extern int fbGCPrivateIndex;
  467. extern int fbGetGCPrivateIndex(void);
  468. extern int fbWinPrivateIndex;
  469. extern int fbGetWinPrivateIndex(void);
  470. extern const GCOps fbGCOps;
  471. extern const GCFuncs fbGCFuncs;
  472. extern int fbScreenPrivateIndex;
  473. extern int fbGetScreenPrivateIndex(void);
  474. /* private field of a screen */
  475. typedef struct {
  476. unsigned char win32bpp; /* window bpp for 32-bpp images */
  477. unsigned char pix32bpp; /* pixmap bpp for 32-bpp images */
  478. } FbScreenPrivRec, *FbScreenPrivPtr;
  479. #define fbGetScreenPrivate(pScreen) ((FbScreenPrivPtr) \
  480. (pScreen)->devPrivates[fbGetScreenPrivateIndex()].ptr)
  481. /* private field of GC */
  482. typedef struct {
  483. FbBits and, xor; /* reduced rop values */
  484. FbBits bgand, bgxor; /* for stipples */
  485. FbBits fg, bg, pm; /* expanded and filled */
  486. unsigned int dashLength; /* total of all dash elements */
  487. unsigned char oneRect; /* clip list is single rectangle */
  488. unsigned char evenStipple; /* stipple is even */
  489. unsigned char bpp; /* current drawable bpp */
  490. } FbGCPrivRec, *FbGCPrivPtr;
  491. #define fbGetGCPrivate(pGC) ((FbGCPrivPtr)\
  492. (pGC)->devPrivates[fbGetGCPrivateIndex()].ptr)
  493. #define fbGetCompositeClip(pGC) ((pGC)->pCompositeClip)
  494. #define fbGetExpose(pGC) ((pGC)->fExpose)
  495. #define fbGetFreeCompClip(pGC) ((pGC)->freeCompClip)
  496. #define fbGetRotatedPixmap(pGC) ((pGC)->pRotatedPixmap)
  497. #define fbGetScreenPixmap(s) ((PixmapPtr) (s)->devPrivate)
  498. #define fbGetWindowPixmap(pWin) ((PixmapPtr)\
  499. ((WindowPtr) (pWin))->devPrivates[fbGetWinPrivateIndex()].ptr)
  500. #define __fbPixDrawableX(pPix) 0
  501. #define __fbPixDrawableY(pPix) 0
  502. #define __fbPixOffXWin(pPix) (__fbPixDrawableX(pPix))
  503. #define __fbPixOffYWin(pPix) (__fbPixDrawableY(pPix))
  504. #define __fbPixOffXPix(pPix) (__fbPixDrawableX(pPix))
  505. #define __fbPixOffYPix(pPix) (__fbPixDrawableY(pPix))
  506. #define fbGetDrawable(pDrawable, pointer, stride, bpp, xoff, yoff) { \
  507. PixmapPtr _pPix; \
  508. if ((pDrawable)->type != DRAWABLE_PIXMAP) { \
  509. _pPix = fbGetWindowPixmap(pDrawable); \
  510. (xoff) = __fbPixOffXWin(_pPix); \
  511. (yoff) = __fbPixOffYWin(_pPix); \
  512. } else { \
  513. _pPix = (PixmapPtr) (pDrawable); \
  514. (xoff) = __fbPixOffXPix(_pPix); \
  515. (yoff) = __fbPixOffYPix(_pPix); \
  516. } \
  517. (pointer) = (FbBits *) _pPix->devPrivate.ptr; \
  518. (stride) = ((int) _pPix->devKind) / sizeof (FbBits); (void)(stride); \
  519. (bpp) = _pPix->drawable.bitsPerPixel; (void)(bpp); \
  520. }
  521. #define fbGetStipDrawable(pDrawable, pointer, stride, bpp, xoff, yoff) { \
  522. PixmapPtr _pPix; \
  523. if ((pDrawable)->type != DRAWABLE_PIXMAP) { \
  524. _pPix = fbGetWindowPixmap(pDrawable); \
  525. (xoff) = __fbPixOffXWin(_pPix); \
  526. (yoff) = __fbPixOffYWin(_pPix); \
  527. } else { \
  528. _pPix = (PixmapPtr) (pDrawable); \
  529. (xoff) = __fbPixOffXPix(_pPix); \
  530. (yoff) = __fbPixOffYPix(_pPix); \
  531. } \
  532. (pointer) = (FbStip *) _pPix->devPrivate.ptr; \
  533. (stride) = ((int) _pPix->devKind) / sizeof (FbStip); (void)(stride); \
  534. (bpp) = _pPix->drawable.bitsPerPixel; (void)(bpp); \
  535. }
  536. /*
  537. * XFree86 empties the root BorderClip when the VT is inactive,
  538. * here's a macro which uses that to disable GetImage and GetSpans
  539. */
  540. #define fbWindowEnabled(pWin) \
  541. REGION_NOTEMPTY(\
  542. &WindowTable[(pWin)->drawable.pScreen->myNum]->borderClip)
  543. #define fbDrawableEnabled(pDrawable) \
  544. ((pDrawable)->type == DRAWABLE_PIXMAP ? \
  545. TRUE : fbWindowEnabled((WindowPtr) pDrawable))
  546. #define FbPowerOfTwo(w) (((w) & ((w) - 1)) == 0)
  547. /*
  548. * Accelerated tiles are power of 2 width <= FB_UNIT
  549. */
  550. #define FbEvenTile(w) ((w) <= FB_UNIT && FbPowerOfTwo(w))
  551. /*
  552. * Accelerated stipples are power of 2 width and <= FB_UNIT/dstBpp
  553. * with dstBpp a power of 2 as well
  554. */
  555. #define FbEvenStip(w,bpp) ((w) * (bpp) <= FB_UNIT && FbPowerOfTwo(w) && FbPowerOfTwo(bpp))
  556. /*
  557. * fb24_32.c
  558. */
  559. extern _X_EXPORT void
  560. fb24_32GetSpans(DrawablePtr pDrawable,
  561. int wMax,
  562. DDXPointPtr ppt, int *pwidth, int nspans, char *pchardstStart);
  563. extern _X_EXPORT void
  564. fb24_32SetSpans(DrawablePtr pDrawable,
  565. GCPtr pGC,
  566. char *src,
  567. DDXPointPtr ppt, int *pwidth, int nspans, int fSorted);
  568. extern _X_EXPORT void
  569. fb24_32PutZImage(DrawablePtr pDrawable,
  570. RegionPtr pClip,
  571. int alu,
  572. FbBits pm,
  573. int x,
  574. int y, int width, int height, CARD8 *src, FbStride srcStride);
  575. extern _X_EXPORT void
  576. fb24_32GetImage(DrawablePtr pDrawable,
  577. int x,
  578. int y,
  579. int w,
  580. int h, unsigned int format, unsigned long planeMask, char *d);
  581. extern _X_EXPORT void
  582. fb24_32CopyMtoN(DrawablePtr pSrcDrawable,
  583. DrawablePtr pDstDrawable,
  584. GCPtr pGC,
  585. BoxPtr pbox,
  586. int nbox,
  587. int dx,
  588. int dy,
  589. Bool reverse, Bool upsidedown, Pixel bitplane, void *closure);
  590. extern _X_EXPORT PixmapPtr
  591. fb24_32ReformatTile(PixmapPtr pOldTile, int bitsPerPixel);
  592. extern _X_EXPORT Bool
  593. fb24_32CreateScreenResources(ScreenPtr pScreen);
  594. extern _X_EXPORT Bool
  595. fb24_32ModifyPixmapHeader(PixmapPtr pPixmap,
  596. int width,
  597. int height,
  598. int depth,
  599. int bitsPerPixel, int devKind, pointer pPixData);
  600. /*
  601. * fballpriv.c
  602. */
  603. extern _X_EXPORT Bool
  604. fbAllocatePrivates(ScreenPtr pScreen, int *pGCIndex);
  605. /*
  606. * fbarc.c
  607. */
  608. extern _X_EXPORT void
  609. fbPolyArc(DrawablePtr pDrawable, GCPtr pGC, int narcs, xArc * parcs);
  610. /*
  611. * fbbits.c
  612. */
  613. extern _X_EXPORT void
  614. fbBresSolid8(DrawablePtr pDrawable,
  615. GCPtr pGC,
  616. int dashOffset,
  617. int signdx,
  618. int signdy,
  619. int axis, int x, int y, int e, int e1, int e3, int len);
  620. extern _X_EXPORT void
  621. fbBresDash8(DrawablePtr pDrawable,
  622. GCPtr pGC,
  623. int dashOffset,
  624. int signdx,
  625. int signdy, int axis, int x, int y, int e, int e1, int e3, int len);
  626. extern _X_EXPORT void
  627. fbDots8(FbBits * dst,
  628. FbStride dstStride,
  629. int dstBpp,
  630. BoxPtr pBox,
  631. xPoint * pts,
  632. int npt,
  633. int xorg, int yorg, int xoff, int yoff, FbBits and, FbBits xor);
  634. extern _X_EXPORT void
  635. fbArc8(FbBits * dst,
  636. FbStride dstStride,
  637. int dstBpp, xArc * arc, int dx, int dy, FbBits and, FbBits xor);
  638. extern _X_EXPORT void
  639. fbGlyph8(FbBits * dstLine,
  640. FbStride dstStride,
  641. int dstBpp, FbStip * stipple, FbBits fg, int height, int shift);
  642. extern _X_EXPORT void
  643. fbPolyline8(DrawablePtr pDrawable,
  644. GCPtr pGC, int mode, int npt, DDXPointPtr ptsOrig);
  645. extern _X_EXPORT void
  646. fbPolySegment8(DrawablePtr pDrawable, GCPtr pGC, int nseg, xSegment * pseg);
  647. extern _X_EXPORT void
  648. fbBresSolid16(DrawablePtr pDrawable,
  649. GCPtr pGC,
  650. int dashOffset,
  651. int signdx,
  652. int signdy,
  653. int axis, int x, int y, int e, int e1, int e3, int len);
  654. extern _X_EXPORT void
  655. fbBresDash16(DrawablePtr pDrawable,
  656. GCPtr pGC,
  657. int dashOffset,
  658. int signdx,
  659. int signdy,
  660. int axis, int x, int y, int e, int e1, int e3, int len);
  661. extern _X_EXPORT void
  662. fbDots16(FbBits * dst,
  663. FbStride dstStride,
  664. int dstBpp,
  665. BoxPtr pBox,
  666. xPoint * pts,
  667. int npt,
  668. int xorg, int yorg, int xoff, int yoff, FbBits and, FbBits xor);
  669. extern _X_EXPORT void
  670. fbArc16(FbBits * dst,
  671. FbStride dstStride,
  672. int dstBpp, xArc * arc, int dx, int dy, FbBits and, FbBits xor);
  673. extern _X_EXPORT void
  674. fbGlyph16(FbBits * dstLine,
  675. FbStride dstStride,
  676. int dstBpp, FbStip * stipple, FbBits fg, int height, int shift);
  677. extern _X_EXPORT void
  678. fbPolyline16(DrawablePtr pDrawable,
  679. GCPtr pGC, int mode, int npt, DDXPointPtr ptsOrig);
  680. extern _X_EXPORT void
  681. fbPolySegment16(DrawablePtr pDrawable, GCPtr pGC, int nseg, xSegment * pseg);
  682. extern _X_EXPORT void
  683. fbBresSolid24(DrawablePtr pDrawable,
  684. GCPtr pGC,
  685. int dashOffset,
  686. int signdx,
  687. int signdy,
  688. int axis, int x, int y, int e, int e1, int e3, int len);
  689. extern _X_EXPORT void
  690. fbBresDash24(DrawablePtr pDrawable,
  691. GCPtr pGC,
  692. int dashOffset,
  693. int signdx,
  694. int signdy,
  695. int axis, int x, int y, int e, int e1, int e3, int len);
  696. extern _X_EXPORT void
  697. fbDots24(FbBits * dst,
  698. FbStride dstStride,
  699. int dstBpp,
  700. BoxPtr pBox,
  701. xPoint * pts,
  702. int npt,
  703. int xorg, int yorg, int xoff, int yoff, FbBits and, FbBits xor);
  704. extern _X_EXPORT void
  705. fbArc24(FbBits * dst,
  706. FbStride dstStride,
  707. int dstBpp, xArc * arc, int dx, int dy, FbBits and, FbBits xor);
  708. extern _X_EXPORT void
  709. fbGlyph24(FbBits * dstLine,
  710. FbStride dstStride,
  711. int dstBpp, FbStip * stipple, FbBits fg, int height, int shift);
  712. extern _X_EXPORT void
  713. fbPolyline24(DrawablePtr pDrawable,
  714. GCPtr pGC, int mode, int npt, DDXPointPtr ptsOrig);
  715. extern _X_EXPORT void
  716. fbPolySegment24(DrawablePtr pDrawable, GCPtr pGC, int nseg, xSegment * pseg);
  717. extern _X_EXPORT void
  718. fbBresSolid32(DrawablePtr pDrawable,
  719. GCPtr pGC,
  720. int dashOffset,
  721. int signdx,
  722. int signdy,
  723. int axis, int x, int y, int e, int e1, int e3, int len);
  724. extern _X_EXPORT void
  725. fbBresDash32(DrawablePtr pDrawable,
  726. GCPtr pGC,
  727. int dashOffset,
  728. int signdx,
  729. int signdy,
  730. int axis, int x, int y, int e, int e1, int e3, int len);
  731. extern _X_EXPORT void
  732. fbDots32(FbBits * dst,
  733. FbStride dstStride,
  734. int dstBpp,
  735. BoxPtr pBox,
  736. xPoint * pts,
  737. int npt,
  738. int xorg, int yorg, int xoff, int yoff, FbBits and, FbBits xor);
  739. extern _X_EXPORT void
  740. fbArc32(FbBits * dst,
  741. FbStride dstStride,
  742. int dstBpp, xArc * arc, int dx, int dy, FbBits and, FbBits xor);
  743. extern _X_EXPORT void
  744. fbGlyph32(FbBits * dstLine,
  745. FbStride dstStride,
  746. int dstBpp, FbStip * stipple, FbBits fg, int height, int shift);
  747. extern _X_EXPORT void
  748. fbPolyline32(DrawablePtr pDrawable,
  749. GCPtr pGC, int mode, int npt, DDXPointPtr ptsOrig);
  750. extern _X_EXPORT void
  751. fbPolySegment32(DrawablePtr pDrawable, GCPtr pGC, int nseg, xSegment * pseg);
  752. /*
  753. * fbblt.c
  754. */
  755. extern _X_EXPORT void
  756. fbBlt(FbBits * src,
  757. FbStride srcStride,
  758. int srcX,
  759. FbBits * dst,
  760. FbStride dstStride,
  761. int dstX,
  762. int width,
  763. int height, int alu, FbBits pm, int bpp, Bool reverse, Bool upsidedown);
  764. extern _X_EXPORT void
  765. fbBlt24(FbBits * srcLine,
  766. FbStride srcStride,
  767. int srcX,
  768. FbBits * dstLine,
  769. FbStride dstStride,
  770. int dstX,
  771. int width,
  772. int height, int alu, FbBits pm, Bool reverse, Bool upsidedown);
  773. extern _X_EXPORT void
  774. fbBltStip(FbStip * src, FbStride srcStride, /* in FbStip units, not FbBits units */
  775. int srcX, FbStip * dst, FbStride dstStride, /* in FbStip units, not FbBits units */
  776. int dstX, int width, int height, int alu, FbBits pm, int bpp);
  777. /*
  778. * fbbltone.c
  779. */
  780. extern _X_EXPORT void
  781. fbBltOne(FbStip * src,
  782. FbStride srcStride,
  783. int srcX,
  784. FbBits * dst,
  785. FbStride dstStride,
  786. int dstX,
  787. int dstBpp,
  788. int width,
  789. int height, FbBits fgand, FbBits fbxor, FbBits bgand, FbBits bgxor);
  790. extern _X_EXPORT void
  791. fbBltOne24(FbStip * src, FbStride srcStride, /* FbStip units per scanline */
  792. int srcX, /* bit position of source */
  793. FbBits * dst, FbStride dstStride, /* FbBits units per scanline */
  794. int dstX, /* bit position of dest */
  795. int dstBpp, /* bits per destination unit */
  796. int width, /* width in bits of destination */
  797. int height, /* height in scanlines */
  798. FbBits fgand, /* rrop values */
  799. FbBits fgxor, FbBits bgand, FbBits bgxor);
  800. extern _X_EXPORT void
  801. fbBltPlane(FbBits * src,
  802. FbStride srcStride,
  803. int srcX,
  804. int srcBpp,
  805. FbStip * dst,
  806. FbStride dstStride,
  807. int dstX,
  808. int width,
  809. int height,
  810. FbStip fgand,
  811. FbStip fgxor, FbStip bgand, FbStip bgxor, Pixel planeMask);
  812. /*
  813. * fbcmap.c
  814. */
  815. int
  816. fbListInstalledColormaps(ScreenPtr pScreen, Colormap * pmaps);
  817. extern _X_EXPORT void
  818. fbInstallColormap(ColormapPtr pmap);
  819. extern _X_EXPORT void
  820. fbUninstallColormap(ColormapPtr pmap);
  821. extern _X_EXPORT void
  822. fbResolveColor(unsigned short *pred,
  823. unsigned short *pgreen,
  824. unsigned short *pblue, VisualPtr pVisual);
  825. extern _X_EXPORT Bool
  826. fbInitializeColormap(ColormapPtr pmap);
  827. extern _X_EXPORT int
  828. fbExpandDirectColors(ColormapPtr pmap,
  829. int ndef, xColorItem * indefs, xColorItem * outdefs);
  830. extern _X_EXPORT Bool
  831. fbCreateDefColormap(ScreenPtr pScreen);
  832. extern _X_EXPORT void
  833. fbClearVisualTypes(void);
  834. Bool
  835. fbSetVisualTypes(int depth, int visuals, int bitsPerRGB);
  836. extern _X_EXPORT Bool
  837. fbSetVisualTypesAndMasks(int depth, int visuals, int bitsPerRGB,
  838. Pixel redMask, Pixel greenMask, Pixel blueMask);
  839. extern _X_EXPORT Bool
  840. fbInitVisuals(VisualPtr * visualp,
  841. DepthPtr * depthp,
  842. int *nvisualp,
  843. int *ndepthp,
  844. int *rootDepthp,
  845. VisualID * defaultVisp, unsigned long sizes, int bitsPerRGB);
  846. /*
  847. * fbcopy.c
  848. */
  849. typedef void (*fbCopyProc) (DrawablePtr pSrcDrawable,
  850. DrawablePtr pDstDrawable,
  851. GCPtr pGC,
  852. BoxPtr pDstBox,
  853. int nbox,
  854. int dx,
  855. int dy,
  856. Bool reverse,
  857. Bool upsidedown, Pixel bitplane, void *closure);
  858. void
  859. fbCopyNtoN(DrawablePtr pSrcDrawable,
  860. DrawablePtr pDstDrawable,
  861. GCPtr pGC,
  862. BoxPtr pbox,
  863. int nbox,
  864. int dx,
  865. int dy,
  866. Bool reverse, Bool upsidedown, Pixel bitplane, void *closure);
  867. extern _X_EXPORT void
  868. fbCopy1toN(DrawablePtr pSrcDrawable,
  869. DrawablePtr pDstDrawable,
  870. GCPtr pGC,
  871. BoxPtr pbox,
  872. int nbox,
  873. int dx,
  874. int dy,
  875. Bool reverse, Bool upsidedown, Pixel bitplane, void *closure);
  876. extern _X_EXPORT void
  877. fbCopyNto1(DrawablePtr pSrcDrawable,
  878. DrawablePtr pDstDrawable,
  879. GCPtr pGC,
  880. BoxPtr pbox,
  881. int nbox,
  882. int dx,
  883. int dy,
  884. Bool reverse, Bool upsidedown, Pixel bitplane, void *closure);
  885. void
  886. fbCopyRegion(DrawablePtr pSrcDrawable,
  887. DrawablePtr pDstDrawable,
  888. GCPtr pGC,
  889. RegionPtr pDstRegion,
  890. int dx,
  891. int dy, fbCopyProc copyProc, Pixel bitPlane, void *closure);
  892. RegionPtr
  893. fbDoCopy(DrawablePtr pSrcDrawable,
  894. DrawablePtr pDstDrawable,
  895. GCPtr pGC,
  896. int xIn,
  897. int yIn,
  898. int widthSrc,
  899. int heightSrc,
  900. int xOut,
  901. int yOut, fbCopyProc copyProc, Pixel bitplane, void *closure);
  902. RegionPtr
  903. fbCopyArea(DrawablePtr pSrcDrawable,
  904. DrawablePtr pDstDrawable,
  905. GCPtr pGC,
  906. int xIn, int yIn, int widthSrc, int heightSrc, int xOut, int yOut);
  907. RegionPtr
  908. fbCopyPlane(DrawablePtr pSrcDrawable,
  909. DrawablePtr pDstDrawable,
  910. GCPtr pGC,
  911. int xIn,
  912. int yIn,
  913. int widthSrc,
  914. int heightSrc, int xOut, int yOut, unsigned long bitplane);
  915. /*
  916. * fbfill.c
  917. */
  918. extern _X_EXPORT void
  919. fbFill(DrawablePtr pDrawable, GCPtr pGC, int x, int y, int width, int height);
  920. extern _X_EXPORT void
  921. fbSolidBoxClipped(DrawablePtr pDrawable,
  922. RegionPtr pClip,
  923. int xa, int ya, int xb, int yb, FbBits and, FbBits xor);
  924. /*
  925. * fbfillrect.c
  926. */
  927. extern _X_EXPORT void
  928. fbPolyFillRect(DrawablePtr pDrawable,
  929. GCPtr pGC, int nrectInit, xRectangle *prectInit);
  930. #define fbPolyFillArc miPolyFillArc
  931. #define fbFillPolygon miFillPolygon
  932. /*
  933. * fbfillsp.c
  934. */
  935. extern _X_EXPORT void
  936. fbFillSpans(DrawablePtr pDrawable,
  937. GCPtr pGC,
  938. int nInit, DDXPointPtr pptInit, int *pwidthInit, int fSorted);
  939. /*
  940. * fbgc.c
  941. */
  942. extern _X_EXPORT Bool
  943. fbCreateGC(GCPtr pGC);
  944. extern _X_EXPORT void
  945. fbPadPixmap(PixmapPtr pPixmap);
  946. extern _X_EXPORT void
  947. fbValidateGC(GCPtr pGC, unsigned long changes, DrawablePtr pDrawable);
  948. /*
  949. * fbgetsp.c
  950. */
  951. extern _X_EXPORT void
  952. fbGetSpans(DrawablePtr pDrawable,
  953. int wMax,
  954. DDXPointPtr ppt, int *pwidth, int nspans, char *pchardstStart);
  955. /*
  956. * fbglyph.c
  957. */
  958. extern _X_EXPORT Bool
  959. fbGlyphIn(RegionPtr pRegion, int x, int y, int width, int height);
  960. extern _X_EXPORT void
  961. fbPolyGlyphBlt(DrawablePtr pDrawable,
  962. GCPtr pGC,
  963. int x,
  964. int y,
  965. unsigned int nglyph, CharInfoPtr * ppci, pointer pglyphBase);
  966. extern _X_EXPORT void
  967. fbImageGlyphBlt(DrawablePtr pDrawable,
  968. GCPtr pGC,
  969. int x,
  970. int y,
  971. unsigned int nglyph, CharInfoPtr * ppci, pointer pglyphBase);
  972. /*
  973. * fbimage.c
  974. */
  975. extern _X_EXPORT void
  976. fbPutImage(DrawablePtr pDrawable,
  977. GCPtr pGC,
  978. int depth,
  979. int x, int y, int w, int h, int leftPad, int format, char *pImage);
  980. extern _X_EXPORT void
  981. fbPutZImage(DrawablePtr pDrawable,
  982. RegionPtr pClip,
  983. int alu,
  984. FbBits pm,
  985. int x,
  986. int y, int width, int height, FbStip * src, FbStride srcStride);
  987. extern _X_EXPORT void
  988. fbPutXYImage(DrawablePtr pDrawable,
  989. RegionPtr pClip,
  990. FbBits fg,
  991. FbBits bg,
  992. FbBits pm,
  993. int alu,
  994. Bool opaque,
  995. int x,
  996. int y,
  997. int width, int height, FbStip * src, FbStride srcStride, int srcX);
  998. extern _X_EXPORT void
  999. fbGetImage(DrawablePtr pDrawable,
  1000. int x,
  1001. int y,
  1002. int w, int h, unsigned int format, unsigned long planeMask, char *d);
  1003. /*
  1004. * fbline.c
  1005. */
  1006. extern _X_EXPORT void
  1007. fbZeroLine(DrawablePtr pDrawable,
  1008. GCPtr pGC, int mode, int npt, DDXPointPtr ppt);
  1009. extern _X_EXPORT void
  1010. fbZeroSegment(DrawablePtr pDrawable, GCPtr pGC, int nseg, xSegment * pSegs);
  1011. extern _X_EXPORT void
  1012. fbPolyLine(DrawablePtr pDrawable,
  1013. GCPtr pGC, int mode, int npt, DDXPointPtr ppt);
  1014. extern _X_EXPORT void
  1015. fbFixCoordModePrevious(int npt, DDXPointPtr ppt);
  1016. extern _X_EXPORT void
  1017. fbPolySegment(DrawablePtr pDrawable, GCPtr pGC, int nseg, xSegment * pseg);
  1018. #define fbPolyRectangle miPolyRectangle
  1019. /*
  1020. * fbpict.c
  1021. */
  1022. Bool
  1023. fbPictureInit(ScreenPtr pScreen, PictFormatPtr formats, int nformats);
  1024. /*
  1025. * fbpixmap.c
  1026. */
  1027. PixmapPtr
  1028. fbCreatePixmapBpp(ScreenPtr pScreen, int width, int height, int depth, int bpp);
  1029. PixmapPtr
  1030. fbCreatePixmap(ScreenPtr pScreen, int width, int height, int depth);
  1031. Bool
  1032. fbDestroyPixmap(PixmapPtr pPixmap);
  1033. RegionPtr
  1034. fbPixmapToRegion(PixmapPtr pPix);
  1035. /*
  1036. * fbpoint.c
  1037. */
  1038. void
  1039. fbDots(FbBits * dstOrig,
  1040. FbStride dstStride,
  1041. int dstBpp,
  1042. BoxPtr pBox,
  1043. xPoint * pts,
  1044. int npt,
  1045. int xorg, int yorg, int xoff, int yoff, FbBits andOrig, FbBits xorOrig);
  1046. extern _X_EXPORT void
  1047. fbPolyPoint(DrawablePtr pDrawable,
  1048. GCPtr pGC, int mode, int npt, xPoint * pptInit);
  1049. /*
  1050. * fbpush.c
  1051. */
  1052. extern _X_EXPORT void
  1053. fbPushPattern(DrawablePtr pDrawable,
  1054. GCPtr pGC,
  1055. FbStip * src,
  1056. FbStride srcStride,
  1057. int srcX, int x, int y, int width, int height);
  1058. void
  1059. fbPushFill(DrawablePtr pDrawable,
  1060. GCPtr pGC,
  1061. FbStip * src,
  1062. FbStride srcStride, int srcX, int x, int y, int width, int height);
  1063. void
  1064. fbPush1toN(DrawablePtr pSrcDrawable,
  1065. DrawablePtr pDstDrawable,
  1066. GCPtr pGC,
  1067. BoxPtr pbox,
  1068. int nbox,
  1069. int dx,
  1070. int dy,
  1071. Bool reverse, Bool upsidedown, Pixel bitplane, void *closure);
  1072. void
  1073. fbPushImage(DrawablePtr pDrawable,
  1074. GCPtr pGC,
  1075. FbStip * src,
  1076. FbStride srcStride, int srcX, int x, int y, int width, int height);
  1077. void
  1078. fbPushPixels(GCPtr pGC,
  1079. PixmapPtr pBitmap,
  1080. DrawablePtr pDrawable, int dx, int dy, int xOrg, int yOrg);
  1081. /*
  1082. * fbscreen.c
  1083. */
  1084. Bool
  1085. fbCloseScreen(int indx, ScreenPtr pScreen);
  1086. Bool
  1087. fbRealizeFont(ScreenPtr pScreen, FontPtr pFont);
  1088. Bool
  1089. fbUnrealizeFont(ScreenPtr pScreen, FontPtr pFont);
  1090. void
  1091. fbQueryBestSize(int class,
  1092. unsigned short *width, unsigned short *height,
  1093. ScreenPtr pScreen);
  1094. PixmapPtr
  1095. _fbGetWindowPixmap(WindowPtr pWindow);
  1096. void
  1097. _fbSetWindowPixmap(WindowPtr pWindow, PixmapPtr pPixmap);
  1098. Bool
  1099. fbSetupScreen(ScreenPtr pScreen, pointer pbits, /* pointer to screen bitmap */
  1100. int xsize, /* in pixels */
  1101. int ysize, int dpix, /* dots per inch */
  1102. int dpiy, int width, /* pixel width of frame buffer */
  1103. int bpp); /* bits per pixel of frame buffer */
  1104. Bool
  1105. fbFinishScreenInit(ScreenPtr pScreen,
  1106. pointer pbits,
  1107. int xsize,
  1108. int ysize, int dpix, int dpiy, int width, int bpp);
  1109. /*
  1110. * fbseg.c
  1111. */
  1112. typedef void FbBres(DrawablePtr pDrawable,
  1113. GCPtr pGC,
  1114. int dashOffset,
  1115. int signdx,
  1116. int signdy,
  1117. int axis, int x, int y, int e, int e1, int e3, int len);
  1118. FbBres fbBresSolid, fbBresDash, fbBresFill, fbBresFillDash;
  1119. /*
  1120. * fbsetsp.c
  1121. */
  1122. void
  1123. fbSetSpans(DrawablePtr pDrawable,
  1124. GCPtr pGC,
  1125. char *src, DDXPointPtr ppt, int *pwidth, int nspans, int fSorted);
  1126. FbBres *fbSelectBres(DrawablePtr pDrawable, GCPtr pGC);
  1127. void
  1128. fbBres(DrawablePtr pDrawable,
  1129. GCPtr pGC,
  1130. int dashOffset,
  1131. int signdx,
  1132. int signdy, int axis, int x, int y, int e, int e1, int e3, int len);
  1133. extern _X_EXPORT void
  1134. fbSegment(DrawablePtr pDrawable,
  1135. GCPtr pGC,
  1136. int xa, int ya, int xb, int yb, Bool drawLast, int *dashOffset);
  1137. /*
  1138. * fbsolid.c
  1139. */
  1140. extern _X_EXPORT void
  1141. fbSolid(FbBits * dst,
  1142. FbStride dstStride,
  1143. int dstX, int bpp, int width, int height, FbBits and, FbBits xor);
  1144. extern _X_EXPORT void
  1145. fbSolid24(FbBits * dst,
  1146. FbStride dstStride,
  1147. int dstX, int width, int height, FbBits and, FbBits xor);
  1148. /*
  1149. * fbstipple.c
  1150. */
  1151. extern _X_EXPORT void
  1152. fbTransparentSpan(FbBits * dst, FbBits stip, FbBits fgxor, int n);
  1153. extern _X_EXPORT void
  1154. fbEvenStipple(FbBits * dst,
  1155. FbStride dstStride,
  1156. int dstX,
  1157. int dstBpp,
  1158. int width,
  1159. int height,
  1160. FbStip * stip,
  1161. FbStride stipStride,
  1162. int stipHeight,
  1163. FbBits fgand,
  1164. FbBits fgxor, FbBits bgand, FbBits bgxor, int xRot, int yRot);
  1165. extern _X_EXPORT void
  1166. fbOddStipple(FbBits * dst,
  1167. FbStride dstStride,
  1168. int dstX,
  1169. int dstBpp,
  1170. int width,
  1171. int height,
  1172. FbStip * stip,
  1173. FbStride stipStride,
  1174. int stipWidth,
  1175. int stipHeight,
  1176. FbBits fgand,
  1177. FbBits fgxor, FbBits bgand, FbBits bgxor, int xRot, int yRot);
  1178. extern _X_EXPORT void
  1179. fbStipple(FbBits * dst,
  1180. FbStride dstStride,
  1181. int dstX,
  1182. int dstBpp,
  1183. int width,
  1184. int height,
  1185. FbStip * stip,
  1186. FbStride stipStride,
  1187. int stipWidth,
  1188. int stipHeight,
  1189. Bool even,
  1190. FbBits fgand,
  1191. FbBits fgxor, FbBits bgand, FbBits bgxor, int xRot, int yRot);
  1192. /*
  1193. * fbtile.c
  1194. */
  1195. extern _X_EXPORT void
  1196. fbEvenTile(FbBits * dst,
  1197. FbStride dstStride,
  1198. int dstX,
  1199. int width,
  1200. int height,
  1201. FbBits * tile,
  1202. int tileHeight, int alu, FbBits pm, int xRot, int yRot);
  1203. void
  1204. fbOddTile(FbBits * dst,
  1205. FbStride dstStride,
  1206. int dstX,
  1207. int width,
  1208. int height,
  1209. FbBits * tile,
  1210. FbStride tileStride,
  1211. int tileWidth,
  1212. int tileHeight, int alu, FbBits pm, int bpp, int xRot, int yRot);
  1213. extern _X_EXPORT void
  1214. fbTile(FbBits * dst,
  1215. FbStride dstStride,
  1216. int dstX,
  1217. int width,
  1218. int height,
  1219. FbBits * tile,
  1220. FbStride tileStride,
  1221. int tileWidth,
  1222. int tileHeight, int alu, FbBits pm, int bpp, int xRot, int yRot);
  1223. /*
  1224. * fbutil.c
  1225. */
  1226. FbBits fbReplicatePixel(Pixel p, int bpp);
  1227. /*
  1228. * fbwindow.c
  1229. */
  1230. Bool
  1231. fbCreateWindow(WindowPtr pWin);
  1232. Bool
  1233. fbDestroyWindow(WindowPtr pWin);
  1234. Bool
  1235. fbMapWindow(WindowPtr pWindow);
  1236. Bool
  1237. fbPositionWindow(WindowPtr pWin, int x, int y);
  1238. Bool
  1239. fbUnmapWindow(WindowPtr pWindow);
  1240. void
  1241. fbCopyWindowProc(DrawablePtr pSrcDrawable,
  1242. DrawablePtr pDstDrawable,
  1243. GCPtr pGC,
  1244. BoxPtr pbox,
  1245. int nbox,
  1246. int dx,
  1247. int dy,
  1248. Bool reverse, Bool upsidedown, Pixel bitplane, void *closure);
  1249. void
  1250. fbCopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc);
  1251. Bool
  1252. fbChangeWindowAttributes(WindowPtr pWin, unsigned long mask);
  1253. void
  1254. fbFillRegionSolid(DrawablePtr pDrawable,
  1255. RegionPtr pRegion, FbBits and, FbBits xor);
  1256. void
  1257. fbFillRegionTiled(DrawablePtr pDrawable, RegionPtr pRegion, PixmapPtr pTile);
  1258. void
  1259. fbPaintWindow(WindowPtr pWin, RegionPtr pRegion, int what);
  1260. #endif /* _FB_H_ */