2
* $XFree86: xc/programs/Xserver/fb/fb.h,v 1.36tsi Exp $
4
* Copyright © 1998 Keith Packard
6
* Permission to use, copy, modify, distribute, and sell this software and its
7
* documentation for any purpose is hereby granted without fee, provided that
8
* the above copyright notice appear in all copies and that both that
9
* copyright notice and this permission notice appear in supporting
10
* documentation, and that the name of Keith Packard not be used in
11
* advertising or publicity pertaining to distribution of the software without
12
* specific, written prior permission. Keith Packard makes no
13
* representations about the suitability of this software for any purpose. It
14
* is provided "as is" without express or implied warranty.
16
* KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
17
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
18
* EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
19
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
20
* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
21
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
22
* PERFORMANCE OF THIS SOFTWARE.
25
/* $XdotOrg: xc/programs/Xserver/fb/fb.h,v 1.12 2005/08/24 11:18:33 daniels Exp $ */
31
#include "scrnintstr.h"
33
#include "pixmapstr.h"
37
#include "miscstruct.h"
39
#include "windowstr.h"
44
#include "picturestr.h"
50
* This single define controls the basic size of data manipulated
51
* by this software; it must be log2(sizeof (FbBits) * 8)
55
#define FB_SHIFT LOG2_BITMAP_PAD
58
#if FB_SHIFT < LOG2_BITMAP_PAD
59
error FB_SHIFT must be >= LOG2_BITMAP_PAD
62
#define FB_UNIT (1 << FB_SHIFT)
63
#define FB_HALFUNIT (1 << (FB_SHIFT-1))
64
#define FB_MASK (FB_UNIT - 1)
65
#define FB_ALLONES ((FbBits) -1)
67
#if GLYPHPADBYTES != 4
68
#error "GLYPHPADBYTES must be 4"
70
#if GETLEFTBITS_ALIGNMENT != 1
71
#error "GETLEFTBITS_ALIGNMENT must be 1"
73
/* whether to bother to include 24bpp support */
79
* Unless otherwise instructed, fb includes code to advertise 24bpp
80
* windows with 32bpp image format for application compatibility
89
#define FB_STIP_SHIFT LOG2_BITMAP_PAD
90
#define FB_STIP_UNIT (1 << FB_STIP_SHIFT)
91
#define FB_STIP_MASK (FB_STIP_UNIT - 1)
92
#define FB_STIP_ALLONES ((FbStip) -1)
94
#define FB_STIP_ODDSTRIDE(s) (((s) & (FB_MASK >> FB_STIP_SHIFT)) != 0)
95
#define FB_STIP_ODDPTR(p) ((((long) (p)) & (FB_MASK >> 3)) != 0)
97
#define FbStipStrideToBitsStride(s) (((s) >> (FB_SHIFT - FB_STIP_SHIFT)))
98
#define FbBitsStrideToStipStride(s) (((s) << (FB_SHIFT - FB_STIP_SHIFT)))
100
#define FbFullMask(n) ((n) == FB_UNIT ? FB_ALLONES : ((((FbBits) 1) << n) - 1))
104
typedef unsigned __int64 FbBits;
106
# if defined(__alpha__) || defined(__alpha) || \
107
defined(ia64) || defined(__ia64__) || \
108
defined(__sparc64__) || defined(_LP64) || \
109
defined(__s390x__) || \
110
defined(amd64) || defined (__amd64__) || \
111
defined (__powerpc64__) || \
112
(defined(sgi) && (_MIPS_SZLONG == 64))
113
typedef unsigned long FbBits;
115
typedef unsigned long long FbBits;
121
typedef CARD32 FbBits;
125
typedef CARD16 FbBits;
128
#if LOG2_BITMAP_PAD == FB_SHIFT
129
typedef FbBits FbStip;
131
# if LOG2_BITMAP_PAD == 5
132
typedef CARD32 FbStip;
136
typedef int FbStride;
140
extern void fbValidateDrawable(DrawablePtr d);
141
extern void fbInitializeDrawable(DrawablePtr d);
142
extern void fbSetBits (FbStip *bits, int stride, FbStip data);
143
#define FB_HEAD_BITS (FbStip) (0xbaadf00d)
144
#define FB_TAIL_BITS (FbStip) (0xbaddf0ad)
146
#define fbValidateDrawable(d)
147
#define fdInitializeDrawable(d)
152
#if BITMAP_BIT_ORDER == LSBFirst
153
#define FbScrLeft(x,n) ((x) >> (n))
154
#define FbScrRight(x,n) ((x) << (n))
155
/* #define FbLeftBits(x,n) ((x) & ((((FbBits) 1) << (n)) - 1)) */
156
#define FbLeftStipBits(x,n) ((x) & ((((FbStip) 1) << (n)) - 1))
157
#define FbStipMoveLsb(x,s,n) (FbStipRight (x,(s)-(n)))
158
#define FbPatternOffsetBits 0
160
#define FbScrLeft(x,n) ((x) << (n))
161
#define FbScrRight(x,n) ((x) >> (n))
162
/* #define FbLeftBits(x,n) ((x) >> (FB_UNIT - (n))) */
163
#define FbLeftStipBits(x,n) ((x) >> (FB_STIP_UNIT - (n)))
164
#define FbStipMoveLsb(x,s,n) (x)
165
#define FbPatternOffsetBits (sizeof (FbBits) - 1)
170
#define FbStipLeft(x,n) FbScrLeft(x,n)
171
#define FbStipRight(x,n) FbScrRight(x,n)
173
#define FbRotLeft(x,n) FbScrLeft(x,n) | (n ? FbScrRight(x,FB_UNIT-n) : 0)
174
#define FbRotRight(x,n) FbScrRight(x,n) | (n ? FbScrLeft(x,FB_UNIT-n) : 0)
176
#define FbRotStipLeft(x,n) FbStipLeft(x,n) | (n ? FbStipRight(x,FB_STIP_UNIT-n) : 0)
177
#define FbRotStipRight(x,n) FbStipRight(x,n) | (n ? FbStipLeft(x,FB_STIP_UNIT-n) : 0)
179
#define FbLeftMask(x) ( ((x) & FB_MASK) ? \
180
FbScrRight(FB_ALLONES,(x) & FB_MASK) : 0)
181
#define FbRightMask(x) ( ((FB_UNIT - (x)) & FB_MASK) ? \
182
FbScrLeft(FB_ALLONES,(FB_UNIT - (x)) & FB_MASK) : 0)
184
#define FbLeftStipMask(x) ( ((x) & FB_STIP_MASK) ? \
185
FbStipRight(FB_STIP_ALLONES,(x) & FB_STIP_MASK) : 0)
186
#define FbRightStipMask(x) ( ((FB_STIP_UNIT - (x)) & FB_STIP_MASK) ? \
187
FbScrLeft(FB_STIP_ALLONES,(FB_STIP_UNIT - (x)) & FB_STIP_MASK) : 0)
189
#define FbBitsMask(x,w) (FbScrRight(FB_ALLONES,(x) & FB_MASK) & \
190
FbScrLeft(FB_ALLONES,(FB_UNIT - ((x) + (w))) & FB_MASK))
192
#define FbStipMask(x,w) (FbStipRight(FB_STIP_ALLONES,(x) & FB_STIP_MASK) & \
193
FbStipLeft(FB_STIP_ALLONES,(FB_STIP_UNIT - ((x)+(w))) & FB_STIP_MASK))
196
#define FbMaskBits(x,w,l,n,r) { \
198
r = FbRightMask((x)+n); \
201
n -= FB_UNIT - ((x) & FB_MASK); \
212
#define FbMaskBitsBytes(x,w,copy,l,lb,n,r,rb) FbMaskBits(x,w,l,n,r)
213
#define FbDoLeftMaskByteRRop(dst,lb,l,and,xor) { \
214
*dst = FbDoMaskRRop(*dst,and,xor,l); \
216
#define FbDoRightMaskByteRRop(dst,rb,r,and,xor) { \
217
*dst = FbDoMaskRRop(*dst,and,xor,r); \
221
#define FbByteMaskInvalid 0x10
223
#define FbPatternOffset(o,t) ((o) ^ (FbPatternOffsetBits & ~(sizeof (t) - 1)))
225
#define FbPtrOffset(p,o,t) ((t *) ((CARD8 *) (p) + (o)))
226
#define FbSelectPatternPart(xor,o,t) ((xor) >> (FbPatternOffset (o,t) << 3))
227
#define FbStorePart(dst,off,t,xor) (*FbPtrOffset(dst,off,t) = \
228
FbSelectPart(xor,off,t))
230
#define FbSelectPart(x,o,t) FbSelectPatternPart(x,o,t)
233
#define FbMaskBitsBytes(x,w,copy,l,lb,n,r,rb) { \
237
r = FbRightMask((x)+n); \
239
/* compute right byte length */ \
240
if ((copy) && (((x) + n) & 7) == 0) { \
241
rb = (((x) + n) & FB_MASK) >> 3; \
243
rb = FbByteMaskInvalid; \
248
/* compute left byte length */ \
249
if ((copy) && ((x) & 7) == 0) { \
250
lb = ((x) & FB_MASK) >> 3; \
252
lb = FbByteMaskInvalid; \
254
/* subtract out the portion painted by leftMask */ \
255
n -= FB_UNIT - ((x) & FB_MASK); \
257
if (lb != FbByteMaskInvalid) { \
258
if (rb == FbByteMaskInvalid) { \
259
lb = FbByteMaskInvalid; \
261
lb |= (rb - lb) << (FB_SHIFT - 3); \
274
#define FbDoLeftMaskByteRRop6Cases(dst,xor) \
275
case (sizeof (FbBits) - 7) | (1 << (FB_SHIFT - 3)): \
276
FbStorePart(dst,sizeof (FbBits) - 7,CARD8,xor); \
278
case (sizeof (FbBits) - 7) | (2 << (FB_SHIFT - 3)): \
279
FbStorePart(dst,sizeof (FbBits) - 7,CARD8,xor); \
280
FbStorePart(dst,sizeof (FbBits) - 6,CARD8,xor); \
282
case (sizeof (FbBits) - 7) | (3 << (FB_SHIFT - 3)): \
283
FbStorePart(dst,sizeof (FbBits) - 7,CARD8,xor); \
284
FbStorePart(dst,sizeof (FbBits) - 6,CARD16,xor); \
286
case (sizeof (FbBits) - 7) | (4 << (FB_SHIFT - 3)): \
287
FbStorePart(dst,sizeof (FbBits) - 7,CARD8,xor); \
288
FbStorePart(dst,sizeof (FbBits) - 6,CARD16,xor); \
289
FbStorePart(dst,sizeof (FbBits) - 4,CARD8,xor); \
291
case (sizeof (FbBits) - 7) | (5 << (FB_SHIFT - 3)): \
292
FbStorePart(dst,sizeof (FbBits) - 7,CARD8,xor); \
293
FbStorePart(dst,sizeof (FbBits) - 6,CARD16,xor); \
294
FbStorePart(dst,sizeof (FbBits) - 4,CARD16,xor); \
296
case (sizeof (FbBits) - 7) | (6 << (FB_SHIFT - 3)): \
297
FbStorePart(dst,sizeof (FbBits) - 7,CARD8,xor); \
298
FbStorePart(dst,sizeof (FbBits) - 6,CARD16,xor); \
299
FbStorePart(dst,sizeof (FbBits) - 4,CARD16,xor); \
300
FbStorePart(dst,sizeof (FbBits) - 2,CARD8,xor); \
302
case (sizeof (FbBits) - 7): \
303
FbStorePart(dst,sizeof (FbBits) - 7,CARD8,xor); \
304
FbStorePart(dst,sizeof (FbBits) - 6,CARD16,xor); \
305
FbStorePart(dst,sizeof (FbBits) - 4,CARD32,xor); \
307
case (sizeof (FbBits) - 6) | (1 << (FB_SHIFT - 3)): \
308
FbStorePart(dst,sizeof (FbBits) - 6,CARD8,xor); \
310
case (sizeof (FbBits) - 6) | (2 << (FB_SHIFT - 3)): \
311
FbStorePart(dst,sizeof (FbBits) - 6,CARD16,xor); \
313
case (sizeof (FbBits) - 6) | (3 << (FB_SHIFT - 3)): \
314
FbStorePart(dst,sizeof (FbBits) - 6,CARD16,xor); \
315
FbStorePart(dst,sizeof (FbBits) - 4,CARD8,xor); \
317
case (sizeof (FbBits) - 6) | (4 << (FB_SHIFT - 3)): \
318
FbStorePart(dst,sizeof (FbBits) - 6,CARD16,xor); \
319
FbStorePart(dst,sizeof (FbBits) - 4,CARD16,xor); \
321
case (sizeof (FbBits) - 6) | (5 << (FB_SHIFT - 3)): \
322
FbStorePart(dst,sizeof (FbBits) - 6,CARD16,xor); \
323
FbStorePart(dst,sizeof (FbBits) - 4,CARD16,xor); \
324
FbStorePart(dst,sizeof (FbBits) - 2,CARD8,xor); \
326
case (sizeof (FbBits) - 6): \
327
FbStorePart(dst,sizeof (FbBits) - 6,CARD16,xor); \
328
FbStorePart(dst,sizeof (FbBits) - 4,CARD32,xor); \
330
case (sizeof (FbBits) - 5) | (1 << (FB_SHIFT - 3)): \
331
FbStorePart(dst,sizeof (FbBits) - 5,CARD8,xor); \
333
case (sizeof (FbBits) - 5) | (2 << (FB_SHIFT - 3)): \
334
FbStorePart(dst,sizeof (FbBits) - 5,CARD8,xor); \
335
FbStorePart(dst,sizeof (FbBits) - 4,CARD8,xor); \
337
case (sizeof (FbBits) - 5) | (3 << (FB_SHIFT - 3)): \
338
FbStorePart(dst,sizeof (FbBits) - 5,CARD8,xor); \
339
FbStorePart(dst,sizeof (FbBits) - 4,CARD16,xor); \
341
case (sizeof (FbBits) - 5) | (4 << (FB_SHIFT - 3)): \
342
FbStorePart(dst,sizeof (FbBits) - 5,CARD8,xor); \
343
FbStorePart(dst,sizeof (FbBits) - 4,CARD16,xor); \
344
FbStorePart(dst,sizeof (FbBits) - 2,CARD8,xor); \
346
case (sizeof (FbBits) - 5): \
347
FbStorePart(dst,sizeof (FbBits) - 5,CARD8,xor); \
348
FbStorePart(dst,sizeof (FbBits) - 4,CARD32,xor); \
350
case (sizeof (FbBits) - 4) | (1 << (FB_SHIFT - 3)): \
351
FbStorePart(dst,sizeof (FbBits) - 4,CARD8,xor); \
353
case (sizeof (FbBits) - 4) | (2 << (FB_SHIFT - 3)): \
354
FbStorePart(dst,sizeof (FbBits) - 4,CARD16,xor); \
356
case (sizeof (FbBits) - 4) | (3 << (FB_SHIFT - 3)): \
357
FbStorePart(dst,sizeof (FbBits) - 4,CARD16,xor); \
358
FbStorePart(dst,sizeof (FbBits) - 2,CARD8,xor); \
360
case (sizeof (FbBits) - 4): \
361
FbStorePart(dst,sizeof (FbBits) - 4,CARD32,xor); \
364
#define FbDoRightMaskByteRRop6Cases(dst,xor) \
366
FbStorePart(dst,0,CARD32,xor); \
369
FbStorePart(dst,0,CARD32,xor); \
370
FbStorePart(dst,4,CARD8,xor); \
373
FbStorePart(dst,0,CARD32,xor); \
374
FbStorePart(dst,4,CARD16,xor); \
377
FbStorePart(dst,0,CARD32,xor); \
378
FbStorePart(dst,4,CARD16,xor); \
379
FbStorePart(dst,6,CARD8,xor); \
382
#define FbDoLeftMaskByteRRop6Cases(dst,xor)
383
#define FbDoRightMaskByteRRop6Cases(dst,xor)
386
#define FbDoLeftMaskByteRRop(dst,lb,l,and,xor) { \
388
FbDoLeftMaskByteRRop6Cases(dst,xor) \
389
case (sizeof (FbBits) - 3) | (1 << (FB_SHIFT - 3)): \
390
FbStorePart(dst,sizeof (FbBits) - 3,CARD8,xor); \
392
case (sizeof (FbBits) - 3) | (2 << (FB_SHIFT - 3)): \
393
FbStorePart(dst,sizeof (FbBits) - 3,CARD8,xor); \
394
FbStorePart(dst,sizeof (FbBits) - 2,CARD8,xor); \
396
case (sizeof (FbBits) - 2) | (1 << (FB_SHIFT - 3)): \
397
FbStorePart(dst,sizeof (FbBits) - 2,CARD8,xor); \
399
case sizeof (FbBits) - 3: \
400
FbStorePart(dst,sizeof (FbBits) - 3,CARD8,xor); \
401
case sizeof (FbBits) - 2: \
402
FbStorePart(dst,sizeof (FbBits) - 2,CARD16,xor); \
404
case sizeof (FbBits) - 1: \
405
FbStorePart(dst,sizeof (FbBits) - 1,CARD8,xor); \
408
*dst = FbDoMaskRRop(*dst, and, xor, l); \
414
#define FbDoRightMaskByteRRop(dst,rb,r,and,xor) { \
417
FbStorePart(dst,0,CARD8,xor); \
420
FbStorePart(dst,0,CARD16,xor); \
423
FbStorePart(dst,0,CARD16,xor); \
424
FbStorePart(dst,2,CARD8,xor); \
426
FbDoRightMaskByteRRop6Cases(dst,xor) \
428
*dst = FbDoMaskRRop (*dst, and, xor, r); \
433
#define FbMaskStip(x,w,l,n,r) { \
435
r = FbRightStipMask((x)+n); \
436
l = FbLeftStipMask(x); \
438
n -= FB_STIP_UNIT - ((x) & FB_STIP_MASK); \
445
n >>= FB_STIP_SHIFT; \
449
* These macros are used to transparently stipple
450
* in copy mode; the expected usage is with 'n' constant
451
* so all of the conditional parts collapse into a minimal
452
* sequence of partial word writes
454
* 'n' is the bytemask of which bytes to store, 'a' is the address
455
* of the FbBits base unit, 'o' is the offset within that unit
457
* The term "lane" comes from the hardware term "byte-lane" which
460
#define FbLaneCase1(n,a,o) ((n) == 0x01 ? \
461
(*(CARD8 *) ((a)+FbPatternOffset(o,CARD8)) = \
463
#define FbLaneCase2(n,a,o) ((n) == 0x03 ? \
464
(*(CARD16 *) ((a)+FbPatternOffset(o,CARD16)) = \
466
((void)FbLaneCase1((n)&1,a,o), \
467
FbLaneCase1((n)>>1,a,(o)+1)))
468
#define FbLaneCase4(n,a,o) ((n) == 0x0f ? \
469
(*(CARD32 *) ((a)+FbPatternOffset(o,CARD32)) = \
471
((void)FbLaneCase2((n)&3,a,o), \
472
FbLaneCase2((n)>>2,a,(o)+2)))
473
#define FbLaneCase8(n,a,o) ((n) == 0x0ff ? (*(FbBits *) ((a)+(o)) = fgxor) : \
474
((void)FbLaneCase4((n)&15,a,o), \
475
FbLaneCase4((n)>>4,a,(o)+4)))
478
#define FbLaneCase(n,a) FbLaneCase8(n,(CARD8 *) (a),0)
482
#define FbLaneCase(n,a) FbLaneCase4(n,(CARD8 *) (a),0)
485
/* Rotate a filled pixel value to the specified alignement */
486
#define FbRot24(p,b) (FbScrRight(p,b) | FbScrLeft(p,24-(b)))
487
#define FbRot24Stip(p,b) (FbStipRight(p,b) | FbStipLeft(p,24-(b)))
489
/* step a filled pixel value to the next/previous FB_UNIT alignment */
490
#define FbNext24Pix(p) (FbRot24(p,(24-FB_UNIT%24)))
491
#define FbPrev24Pix(p) (FbRot24(p,FB_UNIT%24))
492
#define FbNext24Stip(p) (FbRot24(p,(24-FB_STIP_UNIT%24)))
493
#define FbPrev24Stip(p) (FbRot24(p,FB_STIP_UNIT%24))
495
/* step a rotation value to the next/previous rotation value */
497
#define FbNext24Rot(r) ((r) == 16 ? 0 : (r) + 8)
498
#define FbPrev24Rot(r) ((r) == 0 ? 16 : (r) - 8)
500
#if IMAGE_BYTE_ORDER == MSBFirst
501
#define FbFirst24Rot(x) (((x) + 8) % 24)
503
#define FbFirst24Rot(x) ((x) % 24)
509
#define FbNext24Rot(r) ((r) == 0 ? 16 : (r) - 8)
510
#define FbPrev24Rot(r) ((r) == 16 ? 0 : (r) + 8)
512
#if IMAGE_BYTE_ORDER == MSBFirst
513
#define FbFirst24Rot(x) (((x) + 16) % 24)
515
#define FbFirst24Rot(x) ((x) % 24)
519
#define FbNext24RotStip(r) ((r) == 0 ? 16 : (r) - 8)
520
#define FbPrev24RotStip(r) ((r) == 16 ? 0 : (r) + 8)
522
/* Whether 24-bit specific code is needed for this filled pixel value */
523
#define FbCheck24Pix(p) ((p) == FbNext24Pix(p))
525
/* Macros for dealing with dashing */
527
#define FbDashDeclare \
528
unsigned char *__dash, *__firstDash, *__lastDash
530
#define FbDashInit(pGC,pPriv,dashOffset,dashlen,even) { \
532
__firstDash = (pGC)->dash; \
533
__lastDash = __firstDash + (pGC)->numInDashList; \
534
(dashOffset) %= (pPriv)->dashLength; \
536
__dash = __firstDash; \
537
while ((dashOffset) >= ((dashlen) = *__dash)) \
539
(dashOffset) -= (dashlen); \
541
if (++__dash == __lastDash) \
542
__dash = __firstDash; \
544
(dashlen) -= (dashOffset); \
547
#define FbDashNext(dashlen) { \
548
if (++__dash == __lastDash) \
549
__dash = __firstDash; \
550
(dashlen) = *__dash; \
553
/* as numInDashList is always even, this case can skip a test */
555
#define FbDashNextEven(dashlen) { \
556
(dashlen) = *++__dash; \
559
#define FbDashNextOdd(dashlen) FbDashNext(dashlen)
561
#define FbDashStep(dashlen,even) { \
562
if (!--(dashlen)) { \
563
FbDashNext(dashlen); \
568
/* XXX fb*PrivateIndex should be static, but it breaks the ABI */
570
extern int fbGCPrivateIndex;
571
extern int fbGetGCPrivateIndex(void);
572
#ifndef FB_NO_WINDOW_PIXMAPS
573
extern int fbWinPrivateIndex;
574
extern int fbGetWinPrivateIndex(void);
576
extern const GCOps fbGCOps;
577
extern const GCFuncs fbGCFuncs;
581
#define FB_OLD_SCREEN
585
# define FB_OLD_MISCREENINIT /* miScreenInit requires 14 args, not 13 */
586
extern WindowPtr *WindowTable;
590
#define FB_SCREEN_PRIVATE
593
#ifdef FB_SCREEN_PRIVATE
594
extern int fbScreenPrivateIndex;
595
extern int fbGetScreenPrivateIndex(void);
597
/* private field of a screen */
599
unsigned char win32bpp; /* window bpp for 32-bpp images */
600
unsigned char pix32bpp; /* pixmap bpp for 32-bpp images */
601
} FbScreenPrivRec, *FbScreenPrivPtr;
603
#define fbGetScreenPrivate(pScreen) ((FbScreenPrivPtr) \
604
(pScreen)->devPrivates[fbGetScreenPrivateIndex()].ptr)
607
/* private field of GC */
614
unsigned freeCompClip:1;
615
PixmapPtr pRotatedPixmap;
616
RegionPtr pCompositeClip;
618
FbBits and, xor; /* reduced rop values */
619
FbBits bgand, bgxor; /* for stipples */
620
FbBits fg, bg, pm; /* expanded and filled */
621
unsigned int dashLength; /* total of all dash elements */
622
unsigned char oneRect; /* clip list is single rectangle */
623
unsigned char evenStipple; /* stipple is even */
624
unsigned char bpp; /* current drawable bpp */
625
} FbGCPrivRec, *FbGCPrivPtr;
627
#define fbGetGCPrivate(pGC) ((FbGCPrivPtr)\
628
(pGC)->devPrivates[fbGetGCPrivateIndex()].ptr)
631
#define fbGetCompositeClip(pGC) (fbGetGCPrivate(pGC)->pCompositeClip)
632
#define fbGetExpose(pGC) (fbGetGCPrivate(pGC)->fExpose)
633
#define fbGetFreeCompClip(pGC) (fbGetGCPrivate(pGC)->freeCompClip)
634
#define fbGetRotatedPixmap(pGC) (fbGetGCPrivate(pGC)->pRotatedPixmap)
636
#define fbGetCompositeClip(pGC) ((pGC)->pCompositeClip)
637
#define fbGetExpose(pGC) ((pGC)->fExpose)
638
#define fbGetFreeCompClip(pGC) ((pGC)->freeCompClip)
639
#define fbGetRotatedPixmap(pGC) ((pGC)->pRotatedPixmap)
642
#define fbGetScreenPixmap(s) ((PixmapPtr) (s)->devPrivate)
643
#ifdef FB_NO_WINDOW_PIXMAPS
644
#define fbGetWindowPixmap(d) fbGetScreenPixmap(((DrawablePtr) (d))->pScreen)
646
#define fbGetWindowPixmap(pWin) ((PixmapPtr)\
647
((WindowPtr) (pWin))->devPrivates[fbGetWinPrivateIndex()].ptr)
651
#define __fbPixDrawableX(pPix) ((pPix)->drawable.x)
652
#define __fbPixDrawableY(pPix) ((pPix)->drawable.y)
654
#define __fbPixDrawableX(pPix) 0
655
#define __fbPixDrawableY(pPix) 0
659
#define __fbPixOffXWin(pPix) (__fbPixDrawableX(pPix) - (pPix)->screen_x)
660
#define __fbPixOffYWin(pPix) (__fbPixDrawableY(pPix) - (pPix)->screen_y)
662
#define __fbPixOffXWin(pPix) (__fbPixDrawableX(pPix))
663
#define __fbPixOffYWin(pPix) (__fbPixDrawableY(pPix))
665
#define __fbPixOffXPix(pPix) (__fbPixDrawableX(pPix))
666
#define __fbPixOffYPix(pPix) (__fbPixDrawableY(pPix))
668
#define fbGetDrawable(pDrawable, pointer, stride, bpp, xoff, yoff) { \
670
if ((pDrawable)->type != DRAWABLE_PIXMAP) { \
671
_pPix = fbGetWindowPixmap(pDrawable); \
672
(xoff) = __fbPixOffXWin(_pPix); \
673
(yoff) = __fbPixOffYWin(_pPix); \
675
_pPix = (PixmapPtr) (pDrawable); \
676
(xoff) = __fbPixOffXPix(_pPix); \
677
(yoff) = __fbPixOffYPix(_pPix); \
679
(pointer) = (FbBits *) _pPix->devPrivate.ptr; \
680
(stride) = ((int) _pPix->devKind) / sizeof (FbBits); (void)(stride); \
681
(bpp) = _pPix->drawable.bitsPerPixel; (void)(bpp); \
684
#define fbGetStipDrawable(pDrawable, pointer, stride, bpp, xoff, yoff) { \
686
if ((pDrawable)->type != DRAWABLE_PIXMAP) { \
687
_pPix = fbGetWindowPixmap(pDrawable); \
688
(xoff) = __fbPixOffXWin(_pPix); \
689
(yoff) = __fbPixOffYWin(_pPix); \
691
_pPix = (PixmapPtr) (pDrawable); \
692
(xoff) = __fbPixOffXPix(_pPix); \
693
(yoff) = __fbPixOffYPix(_pPix); \
695
(pointer) = (FbStip *) _pPix->devPrivate.ptr; \
696
(stride) = ((int) _pPix->devKind) / sizeof (FbStip); (void)(stride); \
697
(bpp) = _pPix->drawable.bitsPerPixel; (void)(bpp); \
701
* XFree86 empties the root BorderClip when the VT is inactive,
702
* here's a macro which uses that to disable GetImage and GetSpans
705
#define fbWindowEnabled(pWin) \
706
REGION_NOTEMPTY((pWin)->drawable.pScreen, \
707
&WindowTable[(pWin)->drawable.pScreen->myNum]->borderClip)
709
#define fbDrawableEnabled(pDrawable) \
710
((pDrawable)->type == DRAWABLE_PIXMAP ? \
711
TRUE : fbWindowEnabled((WindowPtr) pDrawable))
714
#define BitsPerPixel(d) (\
715
((1 << PixmapWidthPaddingInfo[d].padBytesLog2) * 8 / \
716
(PixmapWidthPaddingInfo[d].padRoundUp+1)))
719
#define FbPowerOfTwo(w) (((w) & ((w) - 1)) == 0)
721
* Accelerated tiles are power of 2 width <= FB_UNIT
723
#define FbEvenTile(w) ((w) <= FB_UNIT && FbPowerOfTwo(w))
725
* Accelerated stipples are power of 2 width and <= FB_UNIT/dstBpp
726
* with dstBpp a power of 2 as well
728
#define FbEvenStip(w,bpp) ((w) * (bpp) <= FB_UNIT && FbPowerOfTwo(w) && FbPowerOfTwo(bpp))
734
fb24_32GetSpans(DrawablePtr pDrawable,
739
char *pchardstStart);
742
fb24_32SetSpans (DrawablePtr pDrawable,
751
fb24_32PutZImage (DrawablePtr pDrawable,
763
fb24_32GetImage (DrawablePtr pDrawable,
769
unsigned long planeMask,
773
fb24_32CopyMtoN (DrawablePtr pSrcDrawable,
774
DrawablePtr pDstDrawable,
786
fb24_32ReformatTile(PixmapPtr pOldTile, int bitsPerPixel);
789
fb24_32CreateScreenResources(ScreenPtr pScreen);
792
fb24_32ModifyPixmapHeader (PixmapPtr pPixmap,
804
fbAllocatePrivates(ScreenPtr pScreen, int *pGCIndex);
811
fbPolyArc (DrawablePtr pDrawable,
821
fbBresSolid8(DrawablePtr pDrawable,
835
fbBresDash8 (DrawablePtr pDrawable,
849
fbDots8 (FbBits *dst,
873
fbGlyph8 (FbBits *dstLine,
882
fbPolyline8 (DrawablePtr pDrawable,
886
DDXPointPtr ptsOrig);
889
fbPolySegment8 (DrawablePtr pDrawable,
895
fbBresSolid16(DrawablePtr pDrawable,
909
fbBresDash16(DrawablePtr pDrawable,
923
fbDots16(FbBits *dst,
947
fbGlyph16(FbBits *dstLine,
956
fbPolyline16 (DrawablePtr pDrawable,
960
DDXPointPtr ptsOrig);
963
fbPolySegment16 (DrawablePtr pDrawable,
970
fbBresSolid24(DrawablePtr pDrawable,
984
fbBresDash24(DrawablePtr pDrawable,
998
fbDots24(FbBits *dst,
1012
fbArc24(FbBits *dst,
1022
fbGlyph24(FbBits *dstLine,
1031
fbPolyline24 (DrawablePtr pDrawable,
1035
DDXPointPtr ptsOrig);
1038
fbPolySegment24 (DrawablePtr pDrawable,
1045
fbBresSolid32(DrawablePtr pDrawable,
1059
fbBresDash32(DrawablePtr pDrawable,
1073
fbDots32(FbBits *dst,
1087
fbArc32(FbBits *dst,
1097
fbGlyph32(FbBits *dstLine,
1105
fbPolyline32 (DrawablePtr pDrawable,
1109
DDXPointPtr ptsOrig);
1112
fbPolySegment32 (DrawablePtr pDrawable,
1140
fbBlt24 (FbBits *srcLine,
1158
fbBltStip (FbStip *src,
1159
FbStride srcStride, /* in FbStip units, not FbBits units */
1163
FbStride dstStride, /* in FbStip units, not FbBits units */
1177
fbBltOne (FbStip *src,
1195
fbBltOne24 (FbStip *src,
1196
FbStride srcStride, /* FbStip units per scanline */
1197
int srcX, /* bit position of source */
1199
FbStride dstStride, /* FbBits units per scanline */
1200
int dstX, /* bit position of dest */
1201
int dstBpp, /* bits per destination unit */
1203
int width, /* width in bits of destination */
1204
int height, /* height in scanlines */
1206
FbBits fgand, /* rrop values */
1213
fbBltPlane (FbBits *src,
1235
fbSaveAreas(PixmapPtr pPixmap,
1242
fbRestoreAreas(PixmapPtr pPixmap,
1243
RegionPtr prgnRestore,
1252
fbListInstalledColormaps(ScreenPtr pScreen, Colormap *pmaps);
1255
fbInstallColormap(ColormapPtr pmap);
1258
fbUninstallColormap(ColormapPtr pmap);
1261
fbResolveColor(unsigned short *pred,
1262
unsigned short *pgreen,
1263
unsigned short *pblue,
1267
fbInitializeColormap(ColormapPtr pmap);
1270
fbExpandDirectColors (ColormapPtr pmap,
1273
xColorItem *outdefs);
1276
fbCreateDefColormap(ScreenPtr pScreen);
1279
fbClearVisualTypes(void);
1282
fbSetVisualTypes (int depth, int visuals, int bitsPerRGB);
1285
fbSetVisualTypesAndMasks (int depth, int visuals, int bitsPerRGB,
1286
Pixel redMask, Pixel greenMask, Pixel blueMask);
1289
fbInitVisuals (VisualPtr *visualp,
1294
VisualID *defaultVisp,
1295
unsigned long sizes,
1302
typedef void (*fbCopyProc) (DrawablePtr pSrcDrawable,
1303
DrawablePtr pDstDrawable,
1315
fbCopyNtoN (DrawablePtr pSrcDrawable,
1316
DrawablePtr pDstDrawable,
1328
fbCopy1toN (DrawablePtr pSrcDrawable,
1329
DrawablePtr pDstDrawable,
1341
fbCopyNto1 (DrawablePtr pSrcDrawable,
1342
DrawablePtr pDstDrawable,
1354
fbCopyRegion (DrawablePtr pSrcDrawable,
1355
DrawablePtr pDstDrawable,
1357
RegionPtr pDstRegion,
1360
fbCopyProc copyProc,
1365
fbDoCopy (DrawablePtr pSrcDrawable,
1366
DrawablePtr pDstDrawable,
1374
fbCopyProc copyProc,
1379
fbCopyArea (DrawablePtr pSrcDrawable,
1380
DrawablePtr pDstDrawable,
1390
fbCopyPlane (DrawablePtr pSrcDrawable,
1391
DrawablePtr pDstDrawable,
1399
unsigned long bitplane);
1405
fbFill (DrawablePtr pDrawable,
1413
fbSolidBoxClipped (DrawablePtr pDrawable,
1426
fbPolyFillRect(DrawablePtr pDrawable,
1429
xRectangle *prectInit);
1431
#define fbPolyFillArc miPolyFillArc
1433
#define fbFillPolygon miFillPolygon
1439
fbFillSpans (DrawablePtr pDrawable,
1442
DDXPointPtr pptInit,
1452
fbCreateGC(GCPtr pGC);
1455
fbPadPixmap (PixmapPtr pPixmap);
1458
fbValidateGC(GCPtr pGC, unsigned long changes, DrawablePtr pDrawable);
1464
fbGetSpans(DrawablePtr pDrawable,
1469
char *pchardstStart);
1476
fbGlyphIn (RegionPtr pRegion,
1483
fbPolyGlyphBlt (DrawablePtr pDrawable,
1487
unsigned int nglyph,
1489
pointer pglyphBase);
1492
fbImageGlyphBlt (DrawablePtr pDrawable,
1496
unsigned int nglyph,
1498
pointer pglyphBase);
1505
fbPutImage (DrawablePtr pDrawable,
1517
fbPutZImage (DrawablePtr pDrawable,
1526
FbStride srcStride);
1529
fbPutXYImage (DrawablePtr pDrawable,
1547
fbGetImage (DrawablePtr pDrawable,
1552
unsigned int format,
1553
unsigned long planeMask,
1560
fbZeroLine (DrawablePtr pDrawable,
1567
fbZeroSegment (DrawablePtr pDrawable,
1573
fbPolyLine (DrawablePtr pDrawable,
1580
fbFixCoordModePrevious (int npt,
1584
fbPolySegment (DrawablePtr pDrawable,
1589
#define fbPolyRectangle miPolyRectangle
1596
fbPictureInit (ScreenPtr pScreen,
1597
PictFormatPtr formats,
1605
fbCreatePixmapBpp (ScreenPtr pScreen, int width, int height, int depth, int bpp);
1608
fbCreatePixmap (ScreenPtr pScreen, int width, int height, int depth);
1611
fbDestroyPixmap (PixmapPtr pPixmap);
1614
fbPixmapToRegion(PixmapPtr pPix);
1621
fbDots (FbBits *dstOrig,
1635
fbPolyPoint (DrawablePtr pDrawable,
1645
fbPushPattern (DrawablePtr pDrawable,
1659
fbPushFill (DrawablePtr pDrawable,
1672
fbPush1toN (DrawablePtr pSrcDrawable,
1673
DrawablePtr pDstDrawable,
1685
fbPushImage (DrawablePtr pDrawable,
1698
fbPushPixels (GCPtr pGC,
1700
DrawablePtr pDrawable,
1712
fbCloseScreen (int indx, ScreenPtr pScreen);
1715
fbRealizeFont(ScreenPtr pScreen, FontPtr pFont);
1718
fbUnrealizeFont(ScreenPtr pScreen, FontPtr pFont);
1721
fbQueryBestSize (int class,
1722
unsigned short *width, unsigned short *height,
1725
#ifndef FB_OLD_SCREEN
1727
_fbGetWindowPixmap (WindowPtr pWindow);
1730
_fbSetWindowPixmap (WindowPtr pWindow, PixmapPtr pPixmap);
1734
fbSetupScreen(ScreenPtr pScreen,
1735
pointer pbits, /* pointer to screen bitmap */
1736
int xsize, /* in pixels */
1738
int dpix, /* dots per inch */
1740
int width, /* pixel width of frame buffer */
1741
int bpp); /* bits per pixel of frame buffer */
1744
fbFinishScreenInit(ScreenPtr pScreen,
1754
fbScreenInit(ScreenPtr pScreen,
1764
fbInitializeBackingStore (ScreenPtr pScreen);
1769
typedef void FbBres (DrawablePtr pDrawable,
1782
FbBres fbBresSolid, fbBresDash, fbBresFill, fbBresFillDash;
1788
fbSetSpans (DrawablePtr pDrawable,
1797
fbSelectBres (DrawablePtr pDrawable,
1801
fbBres (DrawablePtr pDrawable,
1815
fbSegment (DrawablePtr pDrawable,
1830
fbSolid (FbBits *dst,
1843
fbSolid24 (FbBits *dst,
1859
fbTransparentSpan (FbBits *dst,
1865
fbEvenStipple (FbBits *dst,
1874
FbStride stipStride,
1886
fbOddStipple (FbBits *dst,
1895
FbStride stipStride,
1908
fbStipple (FbBits *dst,
1917
FbStride stipStride,
1935
fbEvenTile (FbBits *dst,
1951
fbOddTile (FbBits *dst,
1959
FbStride tileStride,
1971
fbTile (FbBits *dst,
1979
FbStride tileStride,
1994
fbReplicatePixel (Pixel p, int bpp);
1997
fbReduceRasterOp (int rop, FbBits fg, FbBits pm, FbBits *andp, FbBits *xorp);
2004
fbCreateWindow(WindowPtr pWin);
2007
fbDestroyWindow(WindowPtr pWin);
2010
fbMapWindow(WindowPtr pWindow);
2013
fbPositionWindow(WindowPtr pWin, int x, int y);
2016
fbUnmapWindow(WindowPtr pWindow);
2019
fbCopyWindowProc (DrawablePtr pSrcDrawable,
2020
DrawablePtr pDstDrawable,
2032
fbCopyWindow(WindowPtr pWin,
2033
DDXPointRec ptOldOrg,
2037
fbChangeWindowAttributes(WindowPtr pWin, unsigned long mask);
2040
fbFillRegionSolid (DrawablePtr pDrawable,
2046
fbFillRegionTiled (DrawablePtr pDrawable,
2051
fbPaintWindow(WindowPtr pWin, RegionPtr pRegion, int what);