3 * Copyright © 1998 Keith Packard
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.
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.
31 #include "scrnintstr.h"
33 #include "pixmapstr.h"
37 #include "miscstruct.h"
39 #include "windowstr.h"
44 #include "picturestr.h"
49 #ifdef FB_ACCESS_WRAPPER
51 #include "wfbrename.h"
52 #define FBPREFIX(x) wfb##x
53 #define WRITE(ptr, val) ((*wfbWriteMemory)((ptr), (val), sizeof(*(ptr))))
54 #define READ(ptr) ((*wfbReadMemory)((ptr), sizeof(*(ptr))))
56 #define MEMCPY_WRAPPED(dst, src, size) do { \
58 CARD8 *_dst = (CARD8*)(dst), *_src = (CARD8*)(src); \
59 for(_i = 0; _i < size; _i++) { \
60 WRITE(_dst +_i, READ(_src + _i)); \
64 #define MEMSET_WRAPPED(dst, val, size) do { \
66 CARD8 *_dst = (CARD8*)(dst); \
67 for(_i = 0; _i < size; _i++) { \
68 WRITE(_dst +_i, (val)); \
74 #define FBPREFIX(x) fb##x
75 #define WRITE(ptr, val) (*(ptr) = (val))
76 #define READ(ptr) (*(ptr))
77 #define MEMCPY_WRAPPED(dst, src, size) memcpy((dst), (src), (size))
78 #define MEMSET_WRAPPED(dst, val, size) memset((dst), (val), (size))
83 * This single define controls the basic size of data manipulated
84 * by this software; it must be log2(sizeof (FbBits) * 8)
88 #define FB_SHIFT LOG2_BITMAP_PAD
91 #if FB_SHIFT < LOG2_BITMAP_PAD
92 error FB_SHIFT must be
>= LOG2_BITMAP_PAD
95 #define FB_UNIT (1 << FB_SHIFT)
96 #define FB_HALFUNIT (1 << (FB_SHIFT-1))
97 #define FB_MASK (FB_UNIT - 1)
98 #define FB_ALLONES ((FbBits) -1)
100 #if GLYPHPADBYTES != 4
101 #error "GLYPHPADBYTES must be 4"
103 #if GETLEFTBITS_ALIGNMENT != 1
104 #error "GETLEFTBITS_ALIGNMENT must be 1"
106 /* whether to bother to include 24bpp support */
112 * Unless otherwise instructed, fb includes code to advertise 24bpp
113 * windows with 32bpp image format for application compatibility
122 #define FB_STIP_SHIFT LOG2_BITMAP_PAD
123 #define FB_STIP_UNIT (1 << FB_STIP_SHIFT)
124 #define FB_STIP_MASK (FB_STIP_UNIT - 1)
125 #define FB_STIP_ALLONES ((FbStip) -1)
127 #define FB_STIP_ODDSTRIDE(s) (((s) & (FB_MASK >> FB_STIP_SHIFT)) != 0)
128 #define FB_STIP_ODDPTR(p) ((((long) (p)) & (FB_MASK >> 3)) != 0)
130 #define FbStipStrideToBitsStride(s) (((s) >> (FB_SHIFT - FB_STIP_SHIFT)))
131 #define FbBitsStrideToStipStride(s) (((s) << (FB_SHIFT - FB_STIP_SHIFT)))
133 #define FbFullMask(n) ((n) == FB_UNIT ? FB_ALLONES : ((((FbBits) 1) << n) - 1))
137 typedef unsigned __int64 FbBits
;
139 # if defined(__alpha__) || defined(__alpha) || \
140 defined(ia64) || defined(__ia64__) || \
141 defined(__sparc64__) || defined(_LP64) || \
142 defined(__s390x__) || \
143 defined(amd64) || defined (__amd64__) || \
144 defined (__powerpc64__) || \
145 (defined(sgi) && (_MIPS_SZLONG == 64))
146 typedef unsigned long FbBits
;
148 typedef unsigned long long FbBits
;
154 typedef CARD32 FbBits
;
158 typedef CARD16 FbBits
;
161 #if LOG2_BITMAP_PAD == FB_SHIFT
162 typedef FbBits FbStip
;
164 # if LOG2_BITMAP_PAD == 5
165 typedef CARD32 FbStip
;
169 typedef int FbStride
;
173 extern void fbValidateDrawable(DrawablePtr d
);
174 extern void fbInitializeDrawable(DrawablePtr d
);
175 extern void fbSetBits (FbStip
*bits
, int stride
, FbStip data
);
176 #define FB_HEAD_BITS (FbStip) (0xbaadf00d)
177 #define FB_TAIL_BITS (FbStip) (0xbaddf0ad)
179 #define fbValidateDrawable(d)
180 #define fdInitializeDrawable(d)
185 #if BITMAP_BIT_ORDER == LSBFirst
186 #define FbScrLeft(x,n) ((x) >> (n))
187 #define FbScrRight(x,n) ((x) << (n))
188 /* #define FbLeftBits(x,n) ((x) & ((((FbBits) 1) << (n)) - 1)) */
189 #define FbLeftStipBits(x,n) ((x) & ((((FbStip) 1) << (n)) - 1))
190 #define FbStipMoveLsb(x,s,n) (FbStipRight (x,(s)-(n)))
191 #define FbPatternOffsetBits 0
193 #define FbScrLeft(x,n) ((x) << (n))
194 #define FbScrRight(x,n) ((x) >> (n))
195 /* #define FbLeftBits(x,n) ((x) >> (FB_UNIT - (n))) */
196 #define FbLeftStipBits(x,n) ((x) >> (FB_STIP_UNIT - (n)))
197 #define FbStipMoveLsb(x,s,n) (x)
198 #define FbPatternOffsetBits (sizeof (FbBits) - 1)
203 #define FbStipLeft(x,n) FbScrLeft(x,n)
204 #define FbStipRight(x,n) FbScrRight(x,n)
206 #define FbRotLeft(x,n) FbScrLeft(x,n) | (n ? FbScrRight(x,FB_UNIT-n) : 0)
207 #define FbRotRight(x,n) FbScrRight(x,n) | (n ? FbScrLeft(x,FB_UNIT-n) : 0)
209 #define FbRotStipLeft(x,n) FbStipLeft(x,n) | (n ? FbStipRight(x,FB_STIP_UNIT-n) : 0)
210 #define FbRotStipRight(x,n) FbStipRight(x,n) | (n ? FbStipLeft(x,FB_STIP_UNIT-n) : 0)
212 #define FbLeftMask(x) ( ((x) & FB_MASK) ? \
213 FbScrRight(FB_ALLONES,(x) & FB_MASK) : 0)
214 #define FbRightMask(x) ( ((FB_UNIT - (x)) & FB_MASK) ? \
215 FbScrLeft(FB_ALLONES,(FB_UNIT - (x)) & FB_MASK) : 0)
217 #define FbLeftStipMask(x) ( ((x) & FB_STIP_MASK) ? \
218 FbStipRight(FB_STIP_ALLONES,(x) & FB_STIP_MASK) : 0)
219 #define FbRightStipMask(x) ( ((FB_STIP_UNIT - (x)) & FB_STIP_MASK) ? \
220 FbScrLeft(FB_STIP_ALLONES,(FB_STIP_UNIT - (x)) & FB_STIP_MASK) : 0)
222 #define FbBitsMask(x,w) (FbScrRight(FB_ALLONES,(x) & FB_MASK) & \
223 FbScrLeft(FB_ALLONES,(FB_UNIT - ((x) + (w))) & FB_MASK))
225 #define FbStipMask(x,w) (FbStipRight(FB_STIP_ALLONES,(x) & FB_STIP_MASK) & \
226 FbStipLeft(FB_STIP_ALLONES,(FB_STIP_UNIT - ((x)+(w))) & FB_STIP_MASK))
229 #define FbMaskBits(x,w,l,n,r) { \
231 r = FbRightMask((x)+n); \
234 n -= FB_UNIT - ((x) & FB_MASK); \
245 #define FbMaskBitsBytes(x,w,copy,l,lb,n,r,rb) FbMaskBits(x,w,l,n,r)
246 #define FbDoLeftMaskByteRRop(dst,lb,l,and,xor) { \
247 *dst = FbDoMaskRRop(*dst,and,xor,l); \
249 #define FbDoRightMaskByteRRop(dst,rb,r,and,xor) { \
250 *dst = FbDoMaskRRop(*dst,and,xor,r); \
254 #define FbByteMaskInvalid 0x10
256 #define FbPatternOffset(o,t) ((o) ^ (FbPatternOffsetBits & ~(sizeof (t) - 1)))
258 #define FbPtrOffset(p,o,t) ((t *) ((CARD8 *) (p) + (o)))
259 #define FbSelectPatternPart(xor,o,t) ((xor) >> (FbPatternOffset (o,t) << 3))
260 #define FbStorePart(dst,off,t,xor) (WRITE(FbPtrOffset(dst,off,t), \
261 FbSelectPart(xor,off,t)))
263 #define FbSelectPart(x,o,t) FbSelectPatternPart(x,o,t)
266 #define FbMaskBitsBytes(x,w,copy,l,lb,n,r,rb) { \
270 r = FbRightMask((x)+n); \
272 /* compute right byte length */ \
273 if ((copy) && (((x) + n) & 7) == 0) { \
274 rb = (((x) + n) & FB_MASK) >> 3; \
276 rb = FbByteMaskInvalid; \
281 /* compute left byte length */ \
282 if ((copy) && ((x) & 7) == 0) { \
283 lb = ((x) & FB_MASK) >> 3; \
285 lb = FbByteMaskInvalid; \
287 /* subtract out the portion painted by leftMask */ \
288 n -= FB_UNIT - ((x) & FB_MASK); \
290 if (lb != FbByteMaskInvalid) { \
291 if (rb == FbByteMaskInvalid) { \
292 lb = FbByteMaskInvalid; \
294 lb |= (rb - lb) << (FB_SHIFT - 3); \
307 #define FbDoLeftMaskByteRRop6Cases(dst,xor) \
308 case (sizeof (FbBits) - 7) | (1 << (FB_SHIFT - 3)): \
309 FbStorePart(dst,sizeof (FbBits) - 7,CARD8,xor); \
311 case (sizeof (FbBits) - 7) | (2 << (FB_SHIFT - 3)): \
312 FbStorePart(dst,sizeof (FbBits) - 7,CARD8,xor); \
313 FbStorePart(dst,sizeof (FbBits) - 6,CARD8,xor); \
315 case (sizeof (FbBits) - 7) | (3 << (FB_SHIFT - 3)): \
316 FbStorePart(dst,sizeof (FbBits) - 7,CARD8,xor); \
317 FbStorePart(dst,sizeof (FbBits) - 6,CARD16,xor); \
319 case (sizeof (FbBits) - 7) | (4 << (FB_SHIFT - 3)): \
320 FbStorePart(dst,sizeof (FbBits) - 7,CARD8,xor); \
321 FbStorePart(dst,sizeof (FbBits) - 6,CARD16,xor); \
322 FbStorePart(dst,sizeof (FbBits) - 4,CARD8,xor); \
324 case (sizeof (FbBits) - 7) | (5 << (FB_SHIFT - 3)): \
325 FbStorePart(dst,sizeof (FbBits) - 7,CARD8,xor); \
326 FbStorePart(dst,sizeof (FbBits) - 6,CARD16,xor); \
327 FbStorePart(dst,sizeof (FbBits) - 4,CARD16,xor); \
329 case (sizeof (FbBits) - 7) | (6 << (FB_SHIFT - 3)): \
330 FbStorePart(dst,sizeof (FbBits) - 7,CARD8,xor); \
331 FbStorePart(dst,sizeof (FbBits) - 6,CARD16,xor); \
332 FbStorePart(dst,sizeof (FbBits) - 4,CARD16,xor); \
333 FbStorePart(dst,sizeof (FbBits) - 2,CARD8,xor); \
335 case (sizeof (FbBits) - 7): \
336 FbStorePart(dst,sizeof (FbBits) - 7,CARD8,xor); \
337 FbStorePart(dst,sizeof (FbBits) - 6,CARD16,xor); \
338 FbStorePart(dst,sizeof (FbBits) - 4,CARD32,xor); \
340 case (sizeof (FbBits) - 6) | (1 << (FB_SHIFT - 3)): \
341 FbStorePart(dst,sizeof (FbBits) - 6,CARD8,xor); \
343 case (sizeof (FbBits) - 6) | (2 << (FB_SHIFT - 3)): \
344 FbStorePart(dst,sizeof (FbBits) - 6,CARD16,xor); \
346 case (sizeof (FbBits) - 6) | (3 << (FB_SHIFT - 3)): \
347 FbStorePart(dst,sizeof (FbBits) - 6,CARD16,xor); \
348 FbStorePart(dst,sizeof (FbBits) - 4,CARD8,xor); \
350 case (sizeof (FbBits) - 6) | (4 << (FB_SHIFT - 3)): \
351 FbStorePart(dst,sizeof (FbBits) - 6,CARD16,xor); \
352 FbStorePart(dst,sizeof (FbBits) - 4,CARD16,xor); \
354 case (sizeof (FbBits) - 6) | (5 << (FB_SHIFT - 3)): \
355 FbStorePart(dst,sizeof (FbBits) - 6,CARD16,xor); \
356 FbStorePart(dst,sizeof (FbBits) - 4,CARD16,xor); \
357 FbStorePart(dst,sizeof (FbBits) - 2,CARD8,xor); \
359 case (sizeof (FbBits) - 6): \
360 FbStorePart(dst,sizeof (FbBits) - 6,CARD16,xor); \
361 FbStorePart(dst,sizeof (FbBits) - 4,CARD32,xor); \
363 case (sizeof (FbBits) - 5) | (1 << (FB_SHIFT - 3)): \
364 FbStorePart(dst,sizeof (FbBits) - 5,CARD8,xor); \
366 case (sizeof (FbBits) - 5) | (2 << (FB_SHIFT - 3)): \
367 FbStorePart(dst,sizeof (FbBits) - 5,CARD8,xor); \
368 FbStorePart(dst,sizeof (FbBits) - 4,CARD8,xor); \
370 case (sizeof (FbBits) - 5) | (3 << (FB_SHIFT - 3)): \
371 FbStorePart(dst,sizeof (FbBits) - 5,CARD8,xor); \
372 FbStorePart(dst,sizeof (FbBits) - 4,CARD16,xor); \
374 case (sizeof (FbBits) - 5) | (4 << (FB_SHIFT - 3)): \
375 FbStorePart(dst,sizeof (FbBits) - 5,CARD8,xor); \
376 FbStorePart(dst,sizeof (FbBits) - 4,CARD16,xor); \
377 FbStorePart(dst,sizeof (FbBits) - 2,CARD8,xor); \
379 case (sizeof (FbBits) - 5): \
380 FbStorePart(dst,sizeof (FbBits) - 5,CARD8,xor); \
381 FbStorePart(dst,sizeof (FbBits) - 4,CARD32,xor); \
383 case (sizeof (FbBits) - 4) | (1 << (FB_SHIFT - 3)): \
384 FbStorePart(dst,sizeof (FbBits) - 4,CARD8,xor); \
386 case (sizeof (FbBits) - 4) | (2 << (FB_SHIFT - 3)): \
387 FbStorePart(dst,sizeof (FbBits) - 4,CARD16,xor); \
389 case (sizeof (FbBits) - 4) | (3 << (FB_SHIFT - 3)): \
390 FbStorePart(dst,sizeof (FbBits) - 4,CARD16,xor); \
391 FbStorePart(dst,sizeof (FbBits) - 2,CARD8,xor); \
393 case (sizeof (FbBits) - 4): \
394 FbStorePart(dst,sizeof (FbBits) - 4,CARD32,xor); \
397 #define FbDoRightMaskByteRRop6Cases(dst,xor) \
399 FbStorePart(dst,0,CARD32,xor); \
402 FbStorePart(dst,0,CARD32,xor); \
403 FbStorePart(dst,4,CARD8,xor); \
406 FbStorePart(dst,0,CARD32,xor); \
407 FbStorePart(dst,4,CARD16,xor); \
410 FbStorePart(dst,0,CARD32,xor); \
411 FbStorePart(dst,4,CARD16,xor); \
412 FbStorePart(dst,6,CARD8,xor); \
415 #define FbDoLeftMaskByteRRop6Cases(dst,xor)
416 #define FbDoRightMaskByteRRop6Cases(dst,xor)
419 #define FbDoLeftMaskByteRRop(dst,lb,l,and,xor) { \
421 FbDoLeftMaskByteRRop6Cases(dst,xor) \
422 case (sizeof (FbBits) - 3) | (1 << (FB_SHIFT - 3)): \
423 FbStorePart(dst,sizeof (FbBits) - 3,CARD8,xor); \
425 case (sizeof (FbBits) - 3) | (2 << (FB_SHIFT - 3)): \
426 FbStorePart(dst,sizeof (FbBits) - 3,CARD8,xor); \
427 FbStorePart(dst,sizeof (FbBits) - 2,CARD8,xor); \
429 case (sizeof (FbBits) - 2) | (1 << (FB_SHIFT - 3)): \
430 FbStorePart(dst,sizeof (FbBits) - 2,CARD8,xor); \
432 case sizeof (FbBits) - 3: \
433 FbStorePart(dst,sizeof (FbBits) - 3,CARD8,xor); \
434 case sizeof (FbBits) - 2: \
435 FbStorePart(dst,sizeof (FbBits) - 2,CARD16,xor); \
437 case sizeof (FbBits) - 1: \
438 FbStorePart(dst,sizeof (FbBits) - 1,CARD8,xor); \
441 WRITE(dst, FbDoMaskRRop(READ(dst), and, xor, l)); \
447 #define FbDoRightMaskByteRRop(dst,rb,r,and,xor) { \
450 FbStorePart(dst,0,CARD8,xor); \
453 FbStorePart(dst,0,CARD16,xor); \
456 FbStorePart(dst,0,CARD16,xor); \
457 FbStorePart(dst,2,CARD8,xor); \
459 FbDoRightMaskByteRRop6Cases(dst,xor) \
461 WRITE(dst, FbDoMaskRRop (READ(dst), and, xor, r)); \
466 #define FbMaskStip(x,w,l,n,r) { \
468 r = FbRightStipMask((x)+n); \
469 l = FbLeftStipMask(x); \
471 n -= FB_STIP_UNIT - ((x) & FB_STIP_MASK); \
478 n >>= FB_STIP_SHIFT; \
482 * These macros are used to transparently stipple
483 * in copy mode; the expected usage is with 'n' constant
484 * so all of the conditional parts collapse into a minimal
485 * sequence of partial word writes
487 * 'n' is the bytemask of which bytes to store, 'a' is the address
488 * of the FbBits base unit, 'o' is the offset within that unit
490 * The term "lane" comes from the hardware term "byte-lane" which
493 #define FbLaneCase1(n,a,o) ((n) == 0x01 ? (void) \
494 WRITE((CARD8 *) ((a)+FbPatternOffset(o,CARD8)), \
496 #define FbLaneCase2(n,a,o) ((n) == 0x03 ? (void) \
497 WRITE((CARD16 *) ((a)+FbPatternOffset(o,CARD16)), \
499 ((void)FbLaneCase1((n)&1,a,o), \
500 FbLaneCase1((n)>>1,a,(o)+1)))
501 #define FbLaneCase4(n,a,o) ((n) == 0x0f ? (void) \
502 WRITE((CARD32 *) ((a)+FbPatternOffset(o,CARD32)), \
504 ((void)FbLaneCase2((n)&3,a,o), \
505 FbLaneCase2((n)>>2,a,(o)+2)))
506 #define FbLaneCase8(n,a,o) ((n) == 0x0ff ? (void) (*(FbBits *) ((a)+(o)) = fgxor) : \
507 ((void)FbLaneCase4((n)&15,a,o), \
508 FbLaneCase4((n)>>4,a,(o)+4)))
511 #define FbLaneCase(n,a) FbLaneCase8(n,(CARD8 *) (a),0)
515 #define FbLaneCase(n,a) FbLaneCase4(n,(CARD8 *) (a),0)
518 /* Rotate a filled pixel value to the specified alignement */
519 #define FbRot24(p,b) (FbScrRight(p,b) | FbScrLeft(p,24-(b)))
520 #define FbRot24Stip(p,b) (FbStipRight(p,b) | FbStipLeft(p,24-(b)))
522 /* step a filled pixel value to the next/previous FB_UNIT alignment */
523 #define FbNext24Pix(p) (FbRot24(p,(24-FB_UNIT%24)))
524 #define FbPrev24Pix(p) (FbRot24(p,FB_UNIT%24))
525 #define FbNext24Stip(p) (FbRot24(p,(24-FB_STIP_UNIT%24)))
526 #define FbPrev24Stip(p) (FbRot24(p,FB_STIP_UNIT%24))
528 /* step a rotation value to the next/previous rotation value */
530 #define FbNext24Rot(r) ((r) == 16 ? 0 : (r) + 8)
531 #define FbPrev24Rot(r) ((r) == 0 ? 16 : (r) - 8)
533 #if IMAGE_BYTE_ORDER == MSBFirst
534 #define FbFirst24Rot(x) (((x) + 8) % 24)
536 #define FbFirst24Rot(x) ((x) % 24)
542 #define FbNext24Rot(r) ((r) == 0 ? 16 : (r) - 8)
543 #define FbPrev24Rot(r) ((r) == 16 ? 0 : (r) + 8)
545 #if IMAGE_BYTE_ORDER == MSBFirst
546 #define FbFirst24Rot(x) (((x) + 16) % 24)
548 #define FbFirst24Rot(x) ((x) % 24)
552 #define FbNext24RotStip(r) ((r) == 0 ? 16 : (r) - 8)
553 #define FbPrev24RotStip(r) ((r) == 16 ? 0 : (r) + 8)
555 /* Whether 24-bit specific code is needed for this filled pixel value */
556 #define FbCheck24Pix(p) ((p) == FbNext24Pix(p))
558 /* Macros for dealing with dashing */
560 #define FbDashDeclare \
561 unsigned char *__dash, *__firstDash, *__lastDash
563 #define FbDashInit(pGC,pPriv,dashOffset,dashlen,even) { \
565 __firstDash = (pGC)->dash; \
566 __lastDash = __firstDash + (pGC)->numInDashList; \
567 (dashOffset) %= (pPriv)->dashLength; \
569 __dash = __firstDash; \
570 while ((dashOffset) >= ((dashlen) = *__dash)) \
572 (dashOffset) -= (dashlen); \
574 if (++__dash == __lastDash) \
575 __dash = __firstDash; \
577 (dashlen) -= (dashOffset); \
580 #define FbDashNext(dashlen) { \
581 if (++__dash == __lastDash) \
582 __dash = __firstDash; \
583 (dashlen) = *__dash; \
586 /* as numInDashList is always even, this case can skip a test */
588 #define FbDashNextEven(dashlen) { \
589 (dashlen) = *++__dash; \
592 #define FbDashNextOdd(dashlen) FbDashNext(dashlen)
594 #define FbDashStep(dashlen,even) { \
595 if (!--(dashlen)) { \
596 FbDashNext(dashlen); \
601 /* XXX fb*PrivateIndex should be static, but it breaks the ABI */
603 extern int fbGCPrivateIndex
;
604 extern int fbGetGCPrivateIndex(void);
605 #ifndef FB_NO_WINDOW_PIXMAPS
606 extern int fbWinPrivateIndex
;
607 extern int fbGetWinPrivateIndex(void);
609 extern const GCOps fbGCOps
;
610 extern const GCFuncs fbGCFuncs
;
613 #define FB_SCREEN_PRIVATE
616 /* Framebuffer access wrapper */
617 typedef FbBits (*ReadMemoryProcPtr
)(const void *src
, int size
);
618 typedef void (*WriteMemoryProcPtr
)(void *dst
, FbBits value
, int size
);
619 typedef void (*SetupWrapProcPtr
)(ReadMemoryProcPtr
*pRead
,
620 WriteMemoryProcPtr
*pWrite
,
622 typedef void (*FinishWrapProcPtr
)(DrawablePtr pDraw
);
624 #ifdef FB_ACCESS_WRAPPER
626 #define fbPrepareAccess(pDraw) \
627 fbGetScreenPrivate((pDraw)->pScreen)->setupWrap( \
631 #define fbFinishAccess(pDraw) \
632 fbGetScreenPrivate((pDraw)->pScreen)->finishWrap(pDraw)
636 #define fbPrepareAccess(pPix)
637 #define fbFinishAccess(pDraw)
642 #ifdef FB_SCREEN_PRIVATE
643 extern int fbScreenPrivateIndex
;
644 extern int fbGetScreenPrivateIndex(void);
646 /* private field of a screen */
648 unsigned char win32bpp
; /* window bpp for 32-bpp images */
649 unsigned char pix32bpp
; /* pixmap bpp for 32-bpp images */
650 #ifdef FB_ACCESS_WRAPPER
651 SetupWrapProcPtr setupWrap
; /* driver hook to set pixmap access wrapping */
652 FinishWrapProcPtr finishWrap
; /* driver hook to clean up pixmap access wrapping */
654 } FbScreenPrivRec
, *FbScreenPrivPtr
;
656 #define fbGetScreenPrivate(pScreen) ((FbScreenPrivPtr) \
657 (pScreen)->devPrivates[fbGetScreenPrivateIndex()].ptr)
660 /* private field of GC */
662 FbBits
and, xor; /* reduced rop values */
663 FbBits bgand
, bgxor
; /* for stipples */
664 FbBits fg
, bg
, pm
; /* expanded and filled */
665 unsigned int dashLength
; /* total of all dash elements */
666 unsigned char oneRect
; /* clip list is single rectangle */
667 unsigned char evenStipple
; /* stipple is even */
668 unsigned char bpp
; /* current drawable bpp */
669 } FbGCPrivRec
, *FbGCPrivPtr
;
671 #define fbGetGCPrivate(pGC) ((FbGCPrivPtr)\
672 (pGC)->devPrivates[fbGetGCPrivateIndex()].ptr)
674 #define fbGetCompositeClip(pGC) ((pGC)->pCompositeClip)
675 #define fbGetExpose(pGC) ((pGC)->fExpose)
676 #define fbGetFreeCompClip(pGC) ((pGC)->freeCompClip)
677 #define fbGetRotatedPixmap(pGC) ((pGC)->pRotatedPixmap)
679 #define fbGetScreenPixmap(s) ((PixmapPtr) (s)->devPrivate)
680 #ifdef FB_NO_WINDOW_PIXMAPS
681 #define fbGetWindowPixmap(d) fbGetScreenPixmap(((DrawablePtr) (d))->pScreen)
683 #define fbGetWindowPixmap(pWin) ((PixmapPtr)\
684 ((WindowPtr) (pWin))->devPrivates[fbGetWinPrivateIndex()].ptr)
688 #define __fbPixDrawableX(pPix) ((pPix)->drawable.x)
689 #define __fbPixDrawableY(pPix) ((pPix)->drawable.y)
691 #define __fbPixDrawableX(pPix) 0
692 #define __fbPixDrawableY(pPix) 0
696 #define __fbPixOffXWin(pPix) (__fbPixDrawableX(pPix) - (pPix)->screen_x)
697 #define __fbPixOffYWin(pPix) (__fbPixDrawableY(pPix) - (pPix)->screen_y)
699 #define __fbPixOffXWin(pPix) (__fbPixDrawableX(pPix))
700 #define __fbPixOffYWin(pPix) (__fbPixDrawableY(pPix))
702 #define __fbPixOffXPix(pPix) (__fbPixDrawableX(pPix))
703 #define __fbPixOffYPix(pPix) (__fbPixDrawableY(pPix))
705 #define fbGetDrawable(pDrawable, pointer, stride, bpp, xoff, yoff) { \
707 if ((pDrawable)->type != DRAWABLE_PIXMAP) { \
708 _pPix = fbGetWindowPixmap(pDrawable); \
709 (xoff) = __fbPixOffXWin(_pPix); \
710 (yoff) = __fbPixOffYWin(_pPix); \
712 _pPix = (PixmapPtr) (pDrawable); \
713 (xoff) = __fbPixOffXPix(_pPix); \
714 (yoff) = __fbPixOffYPix(_pPix); \
716 fbPrepareAccess(pDrawable); \
717 (pointer) = (FbBits *) _pPix->devPrivate.ptr; \
718 (stride) = ((int) _pPix->devKind) / sizeof (FbBits); (void)(stride); \
719 (bpp) = _pPix->drawable.bitsPerPixel; (void)(bpp); \
722 #define fbGetStipDrawable(pDrawable, pointer, stride, bpp, xoff, yoff) { \
724 if ((pDrawable)->type != DRAWABLE_PIXMAP) { \
725 _pPix = fbGetWindowPixmap(pDrawable); \
726 (xoff) = __fbPixOffXWin(_pPix); \
727 (yoff) = __fbPixOffYWin(_pPix); \
729 _pPix = (PixmapPtr) (pDrawable); \
730 (xoff) = __fbPixOffXPix(_pPix); \
731 (yoff) = __fbPixOffYPix(_pPix); \
733 fbPrepareAccess(pDrawable); \
734 (pointer) = (FbStip *) _pPix->devPrivate.ptr; \
735 (stride) = ((int) _pPix->devKind) / sizeof (FbStip); (void)(stride); \
736 (bpp) = _pPix->drawable.bitsPerPixel; (void)(bpp); \
740 * XFree86 empties the root BorderClip when the VT is inactive,
741 * here's a macro which uses that to disable GetImage and GetSpans
744 #define fbWindowEnabled(pWin) \
745 REGION_NOTEMPTY((pWin)->drawable.pScreen, \
746 &WindowTable[(pWin)->drawable.pScreen->myNum]->borderClip)
748 #define fbDrawableEnabled(pDrawable) \
749 ((pDrawable)->type == DRAWABLE_PIXMAP ? \
750 TRUE : fbWindowEnabled((WindowPtr) pDrawable))
752 #define FbPowerOfTwo(w) (((w) & ((w) - 1)) == 0)
754 * Accelerated tiles are power of 2 width <= FB_UNIT
756 #define FbEvenTile(w) ((w) <= FB_UNIT && FbPowerOfTwo(w))
758 * Accelerated stipples are power of 2 width and <= FB_UNIT/dstBpp
759 * with dstBpp a power of 2 as well
761 #define FbEvenStip(w,bpp) ((w) * (bpp) <= FB_UNIT && FbPowerOfTwo(w) && FbPowerOfTwo(bpp))
767 fb24_32GetSpans(DrawablePtr pDrawable
,
772 char *pchardstStart
);
775 fb24_32SetSpans (DrawablePtr pDrawable
,
784 fb24_32PutZImage (DrawablePtr pDrawable
,
796 fb24_32GetImage (DrawablePtr pDrawable
,
802 unsigned long planeMask
,
806 fb24_32CopyMtoN (DrawablePtr pSrcDrawable
,
807 DrawablePtr pDstDrawable
,
819 fb24_32ReformatTile(PixmapPtr pOldTile
, int bitsPerPixel
);
822 fb24_32CreateScreenResources(ScreenPtr pScreen
);
825 fb24_32ModifyPixmapHeader (PixmapPtr pPixmap
,
837 fbAllocatePrivates(ScreenPtr pScreen
, int *pGCIndex
);
844 fbPolyArc (DrawablePtr pDrawable
,
854 fbBresSolid8(DrawablePtr pDrawable
,
868 fbBresDash8 (DrawablePtr pDrawable
,
882 fbDots8 (FbBits
*dst
,
906 fbGlyph8 (FbBits
*dstLine
,
915 fbPolyline8 (DrawablePtr pDrawable
,
919 DDXPointPtr ptsOrig
);
922 fbPolySegment8 (DrawablePtr pDrawable
,
928 fbBresSolid16(DrawablePtr pDrawable
,
942 fbBresDash16(DrawablePtr pDrawable
,
956 fbDots16(FbBits
*dst
,
980 fbGlyph16(FbBits
*dstLine
,
989 fbPolyline16 (DrawablePtr pDrawable
,
993 DDXPointPtr ptsOrig
);
996 fbPolySegment16 (DrawablePtr pDrawable
,
1003 fbBresSolid24(DrawablePtr pDrawable
,
1017 fbBresDash24(DrawablePtr pDrawable
,
1031 fbDots24(FbBits
*dst
,
1045 fbArc24(FbBits
*dst
,
1055 fbGlyph24(FbBits
*dstLine
,
1064 fbPolyline24 (DrawablePtr pDrawable
,
1068 DDXPointPtr ptsOrig
);
1071 fbPolySegment24 (DrawablePtr pDrawable
,
1078 fbBresSolid32(DrawablePtr pDrawable
,
1092 fbBresDash32(DrawablePtr pDrawable
,
1106 fbDots32(FbBits
*dst
,
1120 fbArc32(FbBits
*dst
,
1130 fbGlyph32(FbBits
*dstLine
,
1138 fbPolyline32 (DrawablePtr pDrawable
,
1142 DDXPointPtr ptsOrig
);
1145 fbPolySegment32 (DrawablePtr pDrawable
,
1173 fbBlt24 (FbBits
*srcLine
,
1191 fbBltStip (FbStip
*src
,
1192 FbStride srcStride
, /* in FbStip units, not FbBits units */
1196 FbStride dstStride
, /* in FbStip units, not FbBits units */
1210 fbBltOne (FbStip
*src
,
1228 fbBltOne24 (FbStip
*src
,
1229 FbStride srcStride
, /* FbStip units per scanline */
1230 int srcX
, /* bit position of source */
1232 FbStride dstStride
, /* FbBits units per scanline */
1233 int dstX
, /* bit position of dest */
1234 int dstBpp
, /* bits per destination unit */
1236 int width
, /* width in bits of destination */
1237 int height
, /* height in scanlines */
1239 FbBits fgand
, /* rrop values */
1246 fbBltPlane (FbBits
*src
,
1268 fbSaveAreas(PixmapPtr pPixmap
,
1275 fbRestoreAreas(PixmapPtr pPixmap
,
1276 RegionPtr prgnRestore
,
1285 fbListInstalledColormaps(ScreenPtr pScreen
, Colormap
*pmaps
);
1288 fbInstallColormap(ColormapPtr pmap
);
1291 fbUninstallColormap(ColormapPtr pmap
);
1294 fbResolveColor(unsigned short *pred
,
1295 unsigned short *pgreen
,
1296 unsigned short *pblue
,
1300 fbInitializeColormap(ColormapPtr pmap
);
1303 fbExpandDirectColors (ColormapPtr pmap
,
1306 xColorItem
*outdefs
);
1309 fbCreateDefColormap(ScreenPtr pScreen
);
1312 fbClearVisualTypes(void);
1315 fbHasVisualTypes (int depth
);
1318 fbSetVisualTypes (int depth
, int visuals
, int bitsPerRGB
);
1321 fbSetVisualTypesAndMasks (int depth
, int visuals
, int bitsPerRGB
,
1322 Pixel redMask
, Pixel greenMask
, Pixel blueMask
);
1325 fbInitVisuals (VisualPtr
*visualp
,
1330 VisualID
*defaultVisp
,
1331 unsigned long sizes
,
1338 typedef void (*fbCopyProc
) (DrawablePtr pSrcDrawable
,
1339 DrawablePtr pDstDrawable
,
1351 fbCopyNtoN (DrawablePtr pSrcDrawable
,
1352 DrawablePtr pDstDrawable
,
1364 fbCopy1toN (DrawablePtr pSrcDrawable
,
1365 DrawablePtr pDstDrawable
,
1377 fbCopyNto1 (DrawablePtr pSrcDrawable
,
1378 DrawablePtr pDstDrawable
,
1390 fbCopyRegion (DrawablePtr pSrcDrawable
,
1391 DrawablePtr pDstDrawable
,
1393 RegionPtr pDstRegion
,
1396 fbCopyProc copyProc
,
1401 fbDoCopy (DrawablePtr pSrcDrawable
,
1402 DrawablePtr pDstDrawable
,
1410 fbCopyProc copyProc
,
1415 fbCopyArea (DrawablePtr pSrcDrawable
,
1416 DrawablePtr pDstDrawable
,
1426 fbCopyPlane (DrawablePtr pSrcDrawable
,
1427 DrawablePtr pDstDrawable
,
1435 unsigned long bitplane
);
1441 fbFill (DrawablePtr pDrawable
,
1449 fbSolidBoxClipped (DrawablePtr pDrawable
,
1462 fbPolyFillRect(DrawablePtr pDrawable
,
1465 xRectangle
*prectInit
);
1467 #define fbPolyFillArc miPolyFillArc
1469 #define fbFillPolygon miFillPolygon
1475 fbFillSpans (DrawablePtr pDrawable
,
1478 DDXPointPtr pptInit
,
1488 fbCreateGC(GCPtr pGC
);
1491 fbPadPixmap (PixmapPtr pPixmap
);
1494 fbValidateGC(GCPtr pGC
, unsigned long changes
, DrawablePtr pDrawable
);
1500 fbGetSpans(DrawablePtr pDrawable
,
1505 char *pchardstStart
);
1512 fbGlyphIn (RegionPtr pRegion
,
1519 fbPolyGlyphBlt (DrawablePtr pDrawable
,
1523 unsigned int nglyph
,
1525 pointer pglyphBase
);
1528 fbImageGlyphBlt (DrawablePtr pDrawable
,
1532 unsigned int nglyph
,
1534 pointer pglyphBase
);
1541 fbPutImage (DrawablePtr pDrawable
,
1553 fbPutZImage (DrawablePtr pDrawable
,
1562 FbStride srcStride
);
1565 fbPutXYImage (DrawablePtr pDrawable
,
1583 fbGetImage (DrawablePtr pDrawable
,
1588 unsigned int format
,
1589 unsigned long planeMask
,
1596 fbZeroLine (DrawablePtr pDrawable
,
1603 fbZeroSegment (DrawablePtr pDrawable
,
1609 fbPolyLine (DrawablePtr pDrawable
,
1616 fbFixCoordModePrevious (int npt
,
1620 fbPolySegment (DrawablePtr pDrawable
,
1625 #define fbPolyRectangle miPolyRectangle
1632 fbPictureInit (ScreenPtr pScreen
,
1633 PictFormatPtr formats
,
1641 fbCreatePixmapBpp (ScreenPtr pScreen
, int width
, int height
, int depth
, int bpp
);
1644 fbCreatePixmap (ScreenPtr pScreen
, int width
, int height
, int depth
);
1647 fbDestroyPixmap (PixmapPtr pPixmap
);
1650 fbPixmapToRegion(PixmapPtr pPix
);
1657 fbDots (FbBits
*dstOrig
,
1671 fbPolyPoint (DrawablePtr pDrawable
,
1681 fbPushPattern (DrawablePtr pDrawable
,
1695 fbPushFill (DrawablePtr pDrawable
,
1708 fbPush1toN (DrawablePtr pSrcDrawable
,
1709 DrawablePtr pDstDrawable
,
1721 fbPushImage (DrawablePtr pDrawable
,
1734 fbPushPixels (GCPtr pGC
,
1736 DrawablePtr pDrawable
,
1748 fbCloseScreen (int indx
, ScreenPtr pScreen
);
1751 fbRealizeFont(ScreenPtr pScreen
, FontPtr pFont
);
1754 fbUnrealizeFont(ScreenPtr pScreen
, FontPtr pFont
);
1757 fbQueryBestSize (int class,
1758 unsigned short *width
, unsigned short *height
,
1762 _fbGetWindowPixmap (WindowPtr pWindow
);
1765 _fbSetWindowPixmap (WindowPtr pWindow
, PixmapPtr pPixmap
);
1768 fbSetupScreen(ScreenPtr pScreen
,
1769 pointer pbits
, /* pointer to screen bitmap */
1770 int xsize
, /* in pixels */
1772 int dpix
, /* dots per inch */
1774 int width
, /* pixel width of frame buffer */
1775 int bpp
); /* bits per pixel of frame buffer */
1778 wfbFinishScreenInit(ScreenPtr pScreen
,
1786 SetupWrapProcPtr setupWrap
,
1787 FinishWrapProcPtr finishWrap
);
1790 wfbScreenInit(ScreenPtr pScreen
,
1798 SetupWrapProcPtr setupWrap
,
1799 FinishWrapProcPtr finishWrap
);
1802 fbFinishScreenInit(ScreenPtr pScreen
,
1812 fbScreenInit(ScreenPtr pScreen
,
1822 fbInitializeBackingStore (ScreenPtr pScreen
);
1827 typedef void FbBres (DrawablePtr pDrawable
,
1840 FbBres fbBresSolid
, fbBresDash
, fbBresFill
, fbBresFillDash
;
1846 fbSetSpans (DrawablePtr pDrawable
,
1855 fbSelectBres (DrawablePtr pDrawable
,
1859 fbBres (DrawablePtr pDrawable
,
1873 fbSegment (DrawablePtr pDrawable
,
1888 fbSolid (FbBits
*dst
,
1901 fbSolid24 (FbBits
*dst
,
1917 fbTransparentSpan (FbBits
*dst
,
1923 fbEvenStipple (FbBits
*dst
,
1932 FbStride stipStride
,
1944 fbOddStipple (FbBits
*dst
,
1953 FbStride stipStride
,
1966 fbStipple (FbBits
*dst
,
1975 FbStride stipStride
,
1993 fbEvenTile (FbBits
*dst
,
2001 FbStride tileStride
,
2010 fbOddTile (FbBits
*dst
,
2018 FbStride tileStride
,
2030 fbTile (FbBits
*dst
,
2038 FbStride tileStride
,
2053 fbReplicatePixel (Pixel p
, int bpp
);
2056 fbReduceRasterOp (int rop
, FbBits fg
, FbBits pm
, FbBits
*andp
, FbBits
*xorp
);
2058 #ifdef FB_ACCESS_WRAPPER
2059 extern ReadMemoryProcPtr wfbReadMemory
;
2060 extern WriteMemoryProcPtr wfbWriteMemory
;
2068 fbCreateWindow(WindowPtr pWin
);
2071 fbDestroyWindow(WindowPtr pWin
);
2074 fbMapWindow(WindowPtr pWindow
);
2077 fbPositionWindow(WindowPtr pWin
, int x
, int y
);
2080 fbUnmapWindow(WindowPtr pWindow
);
2083 fbCopyWindowProc (DrawablePtr pSrcDrawable
,
2084 DrawablePtr pDstDrawable
,
2096 fbCopyWindow(WindowPtr pWin
,
2097 DDXPointRec ptOldOrg
,
2101 fbChangeWindowAttributes(WindowPtr pWin
, unsigned long mask
);
2104 fbFillRegionSolid (DrawablePtr pDrawable
,
2110 fbFillRegionTiled (DrawablePtr pDrawable
,
2115 fbPaintWindow(WindowPtr pWin
, RegionPtr pRegion
, int what
);
2118 pixman_image_t
*image_from_pict (PicturePtr pict
,
2120 void free_pixman_pict (PicturePtr
, pixman_image_t
*);