Back to index

lightning-sunbird  0.9+nobinonly
icrop.h
Go to the documentation of this file.
00001 /*
00002  * Id: $
00003  *
00004  * Copyright © 1998 Keith Packard
00005  *
00006  * Permission to use, copy, modify, distribute, and sell this software and its
00007  * documentation for any purpose is hereby granted without fee, provided that
00008  * the above copyright notice appear in all copies and that both that
00009  * copyright notice and this permission notice appear in supporting
00010  * documentation, and that the name of Keith Packard not be used in
00011  * advertising or publicity pertaining to distribution of the software without
00012  * specific, written prior permission.  Keith Packard makes no
00013  * representations about the suitability of this software for any purpose.  It
00014  * is provided "as is" without express or implied warranty.
00015  *
00016  * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
00017  * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
00018  * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
00019  * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
00020  * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
00021  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
00022  * PERFORMANCE OF THIS SOFTWARE.
00023  */
00024 
00025 #ifndef _ICROP_H_
00026 #define _ICROP_H_
00027 
00028 typedef struct _mergeRopBits {
00029     FbBits   ca1, cx1, ca2, cx2;
00030 } FbMergeRopRec, *FbMergeRopPtr;
00031 
00032 extern const FbMergeRopRec FbMergeRopBits[16] pixman_private;
00033 
00034 #define FbDeclareMergeRop() FbBits   _ca1, _cx1, _ca2, _cx2;
00035 #define FbDeclarePrebuiltMergeRop()       FbBits _cca, _ccx;
00036 
00037 #define FbInitializeMergeRop(alu,pm) {\
00038     const FbMergeRopRec  *_bits; \
00039     _bits = &FbMergeRopBits[alu]; \
00040     _ca1 = _bits->ca1 &  pm; \
00041     _cx1 = _bits->cx1 | ~pm; \
00042     _ca2 = _bits->ca2 &  pm; \
00043     _cx2 = _bits->cx2 &  pm; \
00044 }
00045 
00046 #define FbDestInvarientRop(alu,pm)  ((pm) == FB_ALLONES && \
00047                                  (((alu) >> 1 & 5) == ((alu) & 5)))
00048 
00049 #define FbDestInvarientMergeRop()   (_ca1 == 0 && _cx1 == 0)
00050 
00051 /* AND has higher precedence than XOR */
00052 
00053 #define FbDoMergeRop(src, dst) \
00054     (((dst) & (((src) & _ca1) ^ _cx1)) ^ (((src) & _ca2) ^ _cx2))
00055 
00056 #define FbDoDestInvarientMergeRop(src)    (((src) & _ca2) ^ _cx2)
00057 
00058 #define FbDoMaskMergeRop(src, dst, mask) \
00059     (((dst) & ((((src) & _ca1) ^ _cx1) | ~(mask))) ^ ((((src) & _ca2) ^ _cx2) & (mask)))
00060 
00061 #define FbDoLeftMaskByteMergeRop(dst, src, lb, l) { \
00062     FbBits  __xor = ((src) & _ca2) ^ _cx2; \
00063     FbDoLeftMaskByteRRop(dst,lb,l,((src) & _ca1) ^ _cx1,__xor); \
00064 }
00065 
00066 #define FbDoRightMaskByteMergeRop(dst, src, rb, r) { \
00067     FbBits  __xor = ((src) & _ca2) ^ _cx2; \
00068     FbDoRightMaskByteRRop(dst,rb,r,((src) & _ca1) ^ _cx1,__xor); \
00069 }
00070 
00071 #define FbDoRRop(dst, and, xor)    (((dst) & (and)) ^ (xor))
00072 
00073 #define FbDoMaskRRop(dst, and, xor, mask) \
00074     (((dst) & ((and) | ~(mask))) ^ (xor & mask))
00075 
00076 /*
00077  * Take a single bit (0 or 1) and generate a full mask
00078  */
00079 #define fbFillFromBit(b,t)  (~((t) ((b) & 1)-1))
00080 
00081 #define fbXorT(rop,fg,pm,t) ((((fg) & fbFillFromBit((rop) >> 1,t)) | \
00082                            (~(fg) & fbFillFromBit((rop) >> 3,t))) & (pm))
00083 
00084 #define fbAndT(rop,fg,pm,t) ((((fg) & fbFillFromBit (rop ^ (rop>>1),t)) | \
00085                            (~(fg) & fbFillFromBit((rop>>2) ^ (rop>>3),t))) | \
00086                           ~(pm))
00087 
00088 #define fbXor(rop,fg,pm)    fbXorT(rop,fg,pm,FbBits)
00089 
00090 #define fbAnd(rop,fg,pm)    fbAndT(rop,fg,pm,FbBits)
00091 
00092 #define fbXorStip(rop,fg,pm)    fbXorT(rop,fg,pm,FbStip)
00093 
00094 #define fbAndStip(rop,fg,pm)       fbAndT(rop,fg,pm,FbStip)
00095 
00096 /*
00097  * Stippling operations; 
00098  */
00099 
00100 /* half of table */
00101 extern const pixman_bits_t fbStipple16Bits[256] pixman_private;
00102 #define FbStipple16Bits(b) \
00103     (fbStipple16Bits[(b)&0xff] | fbStipple16Bits[(b) >> 8] << FB_HALFUNIT)
00104 
00105 pixman_private const pixman_bits_t *
00106 fbStippleTable(int bits);
00107 
00108 #define FbStippleRRop(dst, b, fa, fx, ba, bx) \
00109     (FbDoRRop(dst, fa, fx) & b) | (FbDoRRop(dst, ba, bx) & ~b)
00110 
00111 #define FbStippleRRopMask(dst, b, fa, fx, ba, bx, m) \
00112     (FbDoMaskRRop(dst, fa, fx, m) & (b)) | (FbDoMaskRRop(dst, ba, bx, m) & ~(b))
00113                                                  
00114 #define FbDoLeftMaskByteStippleRRop(dst, b, fa, fx, ba, bx, lb, l) { \
00115     FbBits  __xor = ((fx) & (b)) | ((bx) & ~(b)); \
00116     FbDoLeftMaskByteRRop(dst, lb, l, ((fa) & (b)) | ((ba) & ~(b)), __xor); \
00117 }
00118 
00119 #define FbDoRightMaskByteStippleRRop(dst, b, fa, fx, ba, bx, rb, r) { \
00120     FbBits  __xor = ((fx) & (b)) | ((bx) & ~(b)); \
00121     FbDoRightMaskByteRRop(dst, rb, r, ((fa) & (b)) | ((ba) & ~(b)), __xor); \
00122 }
00123 
00124 #define FbOpaqueStipple(b, fg, bg) (((fg) & (b)) | ((bg) & ~(b)))
00125     
00126 /*
00127  * Compute rop for using tile code for 1-bit dest stipples; modifies
00128  * existing rop to flip depending on pixel values
00129  */
00130 #define FbStipple1RopPick(alu,b)    (((alu) >> (2 - (((b) & 1) << 1))) & 3)
00131 
00132 #define FbOpaqueStipple1Rop(alu,fg,bg)    (FbStipple1RopPick(alu,fg) | \
00133                                       (FbStipple1RopPick(alu,bg) << 2))
00134 
00135 #define FbStipple1Rop(alu,fg)          (FbStipple1RopPick(alu,fg) | 4)
00136 
00137 #endif