fbrop.h revision a5e7ae69e440f6816420fc99599f044e79e716b6
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * Copyright © 1998 Keith Packard
3e14f97f673e8a630f076077de35afdd43dc1587Roger A. Faulkner * Permission to use, copy, modify, distribute, and sell this software and its
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * documentation for any purpose is hereby granted without fee, provided that
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * the above copyright notice appear in all copies and that both that
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin * copyright notice and this permission notice appear in supporting
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * documentation, and that the name of Keith Packard not be used in
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * advertising or publicity pertaining to distribution of the software without
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * specific, written prior permission. Keith Packard makes no
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * representations about the suitability of this software for any purpose. It
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * is provided "as is" without express or implied warranty.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * PERFORMANCE OF THIS SOFTWARE.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chintypedef struct _mergeRopBits {
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinextern _X_EXPORT const FbMergeRopRec FbMergeRopBits[16];
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#define FbDeclareMergeRop() FbBits _ca1, _cx1, _ca2, _cx2;
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#define FbDestInvarientRop(alu,pm) ((pm) == FB_ALLONES && \
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#define FbDestInvarientMergeRop() (_ca1 == 0 && _cx1 == 0)
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin/* AND has higher precedence than XOR */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin (((dst) & (((src) & _ca1) ^ _cx1)) ^ (((src) & _ca2) ^ _cx2))
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#define FbDoDestInvarientMergeRop(src) (((src) & _ca2) ^ _cx2)
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin (((dst) & ((((src) & _ca1) ^ _cx1) | ~(mask))) ^ ((((src) & _ca2) ^ _cx2) & (mask)))
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin FbDoLeftMaskByteRRop(dst,lb,l,((src) & _ca1) ^ _cx1,__xor); \
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin FbDoRightMaskByteRRop(dst,rb,r,((src) & _ca1) ^ _cx1,__xor); \
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#define FbDoRRop(dst, and, xor) (((dst) & (and)) ^ (xor))
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * Take a single bit (0 or 1) and generate a full mask
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#define fbXorT(rop,fg,pm,t) ((((fg) & fbFillFromBit((rop) >> 1,t)) | \
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#define fbAndT(rop,fg,pm,t) ((((fg) & fbFillFromBit (rop ^ (rop>>1),t)) | \
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * Stippling operations;
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin (FbDoRRop(dst, fa, fx) & b) | (FbDoRRop(dst, ba, bx) & ~b)
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin (FbDoMaskRRop(dst, fa, fx, m) & (b)) | (FbDoMaskRRop(dst, ba, bx, m) & ~(b))
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#define FbDoLeftMaskByteStippleRRop(dst, b, fa, fx, ba, bx, lb, l) { \
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin FbDoLeftMaskByteRRop(dst, lb, l, ((fa) & (b)) | ((ba) & ~(b)), __xor); \
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#define FbDoRightMaskByteStippleRRop(dst, b, fa, fx, ba, bx, rb, r) { \
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin FbDoRightMaskByteRRop(dst, rb, r, ((fa) & (b)) | ((ba) & ~(b)), __xor); \
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#define FbOpaqueStipple(b, fg, bg) (((fg) & (b)) | ((bg) & ~(b)))
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * Compute rop for using tile code for 1-bit dest stipples; modifies
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * existing rop to flip depending on pixel values
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#define FbStipple1RopPick(alu,b) (((alu) >> (2 - (((b) & 1) << 1))) & 3)
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#define FbOpaqueStipple1Rop(alu,fg,bg) (FbStipple1RopPick(alu,fg) | \
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#define FbStipple1Rop(alu,fg) (FbStipple1RopPick(alu,fg) | 4)