fb.h 45 KB

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