📄 icint.h
字号:
/* * Copyright © 2003 Carl Worth * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided that * the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the name of Carl Worth not be used in * advertising or publicity pertaining to distribution of the software without * specific, written prior permission. Carl Worth makes no * representations about the suitability of this software for any purpose. It * is provided "as is" without express or implied warranty. * * CARL WORTH DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO * EVENT SHALL CARL WORTH BE LIABLE FOR ANY SPECIAL, INDIRECT OR * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR * PERFORMANCE OF THIS SOFTWARE. */#ifndef _ICINT_H_#define _ICINT_H_#ifdef HAVE_CONFIG_H# include "config.h"#endif#include "pixman.h"#include <stdlib.h>#include <string.h>#include <limits.h>#include "slim_internal.h"#ifndef __GNUC__#define __inline#endif#if defined(__GNUC__)#define INLINE __inline__#else#define INLINE#endif#undef MIN#define MIN(a,b) ((a) < (b) ? (a) : (b))#undef MAX#define MAX(a,b) ((a) > (b) ? (a) : (b))/* C89 has implementation-defined behavior for % with negative operands. C99 has well-defined behavior which is that / with integers rounds toward zero and a%b is defined so that (a/b)*b + a%b == a. The C99 version gives negative remainders rather than the modulus in [0 .. b-1] that we want. This macro avoids using % with negative operands to avoid both problems. a and b are integers. b > 0.*/#define MOD(a, b) ((b) == 1 ? 0 : (a) >= 0 ? (a) % (b) : (b) - (-(a) - 1) % (b) - 1)typedef struct _FbPoint { int16_t x,y ;} FbPoint;typedef unsigned int Mask;#define GXcopy 0x3#define GXor 0x7#define ClipByChildren 0#define PolyEdgeSharp 0#define PolyModePrecise 0#define CPClipMask (1 << 6)#define CPLastBit 11/* Define any names that the server code will be expecting in * terms of libpixman names. */typedef uint8_t CARD8;typedef uint16_t CARD16;typedef uint32_t CARD32;typedef int16_t INT16;typedef int Bool;#define FALSE 0#define TRUE 1typedef pixman_bits_t FbBits;typedef pixman_image_t* PicturePtr;typedef pixman_box16_t BoxRec;typedef pixman_box16_t* BoxPtr;typedef pixman_point_fixed_t xPointFixed;typedef pixman_line_fixed_t xLineFixed;typedef pixman_trapezoid_t xTrapezoid;typedef pixman_triangle_t xTriangle;/* These few definitions avoid me needing to include servermd.h and misc.h from Xserver/include */#ifndef BITMAP_SCANLINE_PAD#define BITMAP_SCANLINE_PAD 32#define LOG2_BITMAP_PAD 5#define LOG2_BYTES_PER_SCANLINE_PAD 2#endif#define LSBFirst 0#define MSBFirst 1#ifdef WORDS_BIGENDIAN# define IMAGE_BYTE_ORDER MSBFirst# define BITMAP_BIT_ORDER MSBFirst#else# define IMAGE_BYTE_ORDER LSBFirst# define BITMAP_BIT_ORDER LSBFirst#endif#define MAXSHORT SHRT_MAX#define MINSHORT SHRT_MIN/* XXX: What do we need from here?#include "picture.h"*/#include "pixman.h"/* XXX: Most of this file is straight from fb.h and I imagine we can drop quite a bit of it. Once the real ic code starts to come together I can probably figure out what is not needed here. */#define FB_UNIT (1 << FB_SHIFT)#define FB_HALFUNIT (1 << (FB_SHIFT-1))#define FB_MASK (FB_UNIT - 1)#define FB_ALLONES ((pixman_bits_t) -1)/* whether to bother to include 24bpp support */#ifndef ICNO24BIT#define FB_24BIT#endif/* * Unless otherwise instructed, ic includes code to advertise 24bpp * windows with 32bpp image format for application compatibility */#ifdef FB_24BIT#ifndef ICNO24_32#define FB_24_32BIT#endif#endif#define FB_STIP_SHIFT LOG2_BITMAP_PAD#define FB_STIP_UNIT (1 << FB_STIP_SHIFT)#define FB_STIP_MASK (FB_STIP_UNIT - 1)#define FB_STIP_ALLONES ((FbStip) -1)#define FB_STIP_ODDSTRIDE(s) (((s) & (FB_MASK >> FB_STIP_SHIFT)) != 0)#define FB_STIP_ODDPTR(p) ((((long) (p)) & (FB_MASK >> 3)) != 0)#define FbStipStrideToBitsStride(s) (((s) >> (FB_SHIFT - FB_STIP_SHIFT)))#define FbBitsStrideToStipStride(s) (((s) << (FB_SHIFT - FB_STIP_SHIFT)))#define FbFullMask(n) ((n) == FB_UNIT ? FB_ALLONES : ((((FbBits) 1) << n) - 1))typedef uint32_t FbStip;typedef int FbStride;#ifdef FB_DEBUGextern void fbValidateDrawable(DrawablePtr d);extern void fbInitializeDrawable(DrawablePtr d);extern void fbSetBits (FbStip *bits, int stride, FbStip data);#define FB_HEAD_BITS (FbStip) (0xbaadf00d)#define FB_TAIL_BITS (FbStip) (0xbaddf0ad)#else#define fbValidateDrawable(d)#define fdInitializeDrawable(d)#endif#if BITMAP_BIT_ORDER == LSBFirst#define FbScrLeft(x,n) ((x) >> (n))#define FbScrRight(x,n) ((x) << (n))/* #define FbLeftBits(x,n) ((x) & ((((FbBits) 1) << (n)) - 1)) */#define FbLeftStipBits(x,n) ((x) & ((((FbStip) 1) << (n)) - 1))#define FbStipMoveLsb(x,s,n) (FbStipRight (x,(s)-(n)))#define FbPatternOffsetBits 0#else#define FbScrLeft(x,n) ((x) << (n))#define FbScrRight(x,n) ((x) >> (n))/* #define FbLeftBits(x,n) ((x) >> (FB_UNIT - (n))) */#define FbLeftStipBits(x,n) ((x) >> (FB_STIP_UNIT - (n)))#define FbStipMoveLsb(x,s,n) (x)#define FbPatternOffsetBits (sizeof (FbBits) - 1)#endif#define FbStipLeft(x,n) FbScrLeft(x,n)#define FbStipRight(x,n) FbScrRight(x,n)#define FbRotLeft(x,n) FbScrLeft(x,n) | (n ? FbScrRight(x,FB_UNIT-n) : 0)#define FbRotRight(x,n) FbScrRight(x,n) | (n ? FbScrLeft(x,FB_UNIT-n) : 0)#define FbRotStipLeft(x,n) FbStipLeft(x,n) | (n ? FbStipRight(x,FB_STIP_UNIT-n) : 0)#define FbRotStipRight(x,n) FbStipRight(x,n) | (n ? FbStipLeft(x,FB_STIP_UNIT-n) : 0)#define FbLeftMask(x) ( ((x) & FB_MASK) ? \ FbScrRight(FB_ALLONES,(x) & FB_MASK) : 0)#define FbRightMask(x) ( ((FB_UNIT - (x)) & FB_MASK) ? \ FbScrLeft(FB_ALLONES,(FB_UNIT - (x)) & FB_MASK) : 0)#define FbLeftStipMask(x) ( ((x) & FB_STIP_MASK) ? \ FbStipRight(FB_STIP_ALLONES,(x) & FB_STIP_MASK) : 0)#define FbRightStipMask(x) ( ((FB_STIP_UNIT - (x)) & FB_STIP_MASK) ? \ FbScrLeft(FB_STIP_ALLONES,(FB_STIP_UNIT - (x)) & FB_STIP_MASK) : 0)#define FbBitsMask(x,w) (FbScrRight(FB_ALLONES,(x) & FB_MASK) & \ FbScrLeft(FB_ALLONES,(FB_UNIT - ((x) + (w))) & FB_MASK))#define FbStipMask(x,w) (FbStipRight(FB_STIP_ALLONES,(x) & FB_STIP_MASK) & \ FbStipLeft(FB_STIP_ALLONES,(FB_STIP_UNIT - ((x)+(w))) & FB_STIP_MASK))#define FbMaskBits(x,w,l,n,r) { \ n = (w); \ r = FbRightMask((x)+n); \ l = FbLeftMask(x); \ if (l) { \ n -= FB_UNIT - ((x) & FB_MASK); \ if (n < 0) { \ n = 0; \ l &= r; \ r = 0; \ } \ } \ n >>= FB_SHIFT; \}#ifdef ICNOPIXADDR#define FbMaskBitsBytes(x,w,copy,l,lb,n,r,rb) FbMaskBits(x,w,l,n,r)#define FbDoLeftMaskByteRRop(dst,lb,l,and,xor) { \ *dst = FbDoMaskRRop(*dst,and,xor,l); \}#define FbDoRightMaskByteRRop(dst,rb,r,and,xor) { \ *dst = FbDoMaskRRop(*dst,and,xor,r); \}#else#define FbByteMaskInvalid 0x10#define FbPatternOffset(o,t) ((o) ^ (FbPatternOffsetBits & ~(sizeof (t) - 1)))#define FbPtrOffset(p,o,t) ((t *) ((CARD8 *) (p) + (o)))#define FbSelectPatternPart(xor,o,t) ((xor) >> (FbPatternOffset (o,t) << 3))#define FbStorePart(dst,off,t,xor) (*FbPtrOffset(dst,off,t) = \ FbSelectPart(xor,off,t))#ifndef FbSelectPart#define FbSelectPart(x,o,t) FbSelectPatternPart(x,o,t)#endif#define FbMaskBitsBytes(x,w,copy,l,lb,n,r,rb) { \ n = (w); \ lb = 0; \ rb = 0; \ r = FbRightMask((x)+n); \ if (r) { \ /* compute right byte length */ \ if ((copy) && (((x) + n) & 7) == 0) { \ rb = (((x) + n) & FB_MASK) >> 3; \ } else { \ rb = FbByteMaskInvalid; \ } \ } \ l = FbLeftMask(x); \ if (l) { \ /* compute left byte length */ \ if ((copy) && ((x) & 7) == 0) { \ lb = ((x) & FB_MASK) >> 3; \ } else { \ lb = FbByteMaskInvalid; \ } \ /* subtract out the portion painted by leftMask */ \ n -= FB_UNIT - ((x) & FB_MASK); \ if (n < 0) { \ if (lb != FbByteMaskInvalid) { \ if (rb == FbByteMaskInvalid) { \ lb = FbByteMaskInvalid; \ } else if (rb) { \ lb |= (rb - lb) << (FB_SHIFT - 3); \ rb = 0; \ } \ } \ n = 0; \ l &= r; \ r = 0; \ }\ } \ n >>= FB_SHIFT; \}#if FB_SHIFT == 6#define FbDoLeftMaskByteRRop6Cases(dst,xor) \ case (sizeof (FbBits) - 7) | (1 << (FB_SHIFT - 3)): \ FbStorePart(dst,sizeof (FbBits) - 7,CARD8,xor); \ break; \ case (sizeof (FbBits) - 7) | (2 << (FB_SHIFT - 3)): \ FbStorePart(dst,sizeof (FbBits) - 7,CARD8,xor); \ FbStorePart(dst,sizeof (FbBits) - 6,CARD8,xor); \ break; \ case (sizeof (FbBits) - 7) | (3 << (FB_SHIFT - 3)): \ FbStorePart(dst,sizeof (FbBits) - 7,CARD8,xor); \ FbStorePart(dst,sizeof (FbBits) - 6,CARD16,xor); \ break; \ case (sizeof (FbBits) - 7) | (4 << (FB_SHIFT - 3)): \ FbStorePart(dst,sizeof (FbBits) - 7,CARD8,xor); \ FbStorePart(dst,sizeof (FbBits) - 6,CARD16,xor); \ FbStorePart(dst,sizeof (FbBits) - 4,CARD8,xor); \ break; \ case (sizeof (FbBits) - 7) | (5 << (FB_SHIFT - 3)): \ FbStorePart(dst,sizeof (FbBits) - 7,CARD8,xor); \ FbStorePart(dst,sizeof (FbBits) - 6,CARD16,xor); \ FbStorePart(dst,sizeof (FbBits) - 4,CARD16,xor); \ break; \ case (sizeof (FbBits) - 7) | (6 << (FB_SHIFT - 3)): \ FbStorePart(dst,sizeof (FbBits) - 7,CARD8,xor); \ FbStorePart(dst,sizeof (FbBits) - 6,CARD16,xor); \ FbStorePart(dst,sizeof (FbBits) - 4,CARD16,xor); \ FbStorePart(dst,sizeof (FbBits) - 2,CARD8,xor); \ break; \ case (sizeof (FbBits) - 7): \ FbStorePart(dst,sizeof (FbBits) - 7,CARD8,xor); \ FbStorePart(dst,sizeof (FbBits) - 6,CARD16,xor); \ FbStorePart(dst,sizeof (FbBits) - 4,CARD32,xor); \ break; \ case (sizeof (FbBits) - 6) | (1 << (FB_SHIFT - 3)): \ FbStorePart(dst,sizeof (FbBits) - 6,CARD8,xor); \ break; \ case (sizeof (FbBits) - 6) | (2 << (FB_SHIFT - 3)): \ FbStorePart(dst,sizeof (FbBits) - 6,CARD16,xor); \ break; \ case (sizeof (FbBits) - 6) | (3 << (FB_SHIFT - 3)): \ FbStorePart(dst,sizeof (FbBits) - 6,CARD16,xor); \ FbStorePart(dst,sizeof (FbBits) - 4,CARD8,xor); \ break; \ case (sizeof (FbBits) - 6) | (4 << (FB_SHIFT - 3)): \ FbStorePart(dst,sizeof (FbBits) - 6,CARD16,xor); \ FbStorePart(dst,sizeof (FbBits) - 4,CARD16,xor); \ break; \ case (sizeof (FbBits) - 6) | (5 << (FB_SHIFT - 3)): \ FbStorePart(dst,sizeof (FbBits) - 6,CARD16,xor); \ FbStorePart(dst,sizeof (FbBits) - 4,CARD16,xor); \ FbStorePart(dst,sizeof (FbBits) - 2,CARD8,xor); \ break; \ case (sizeof (FbBits) - 6): \ FbStorePart(dst,sizeof (FbBits) - 6,CARD16,xor); \ FbStorePart(dst,sizeof (FbBits) - 4,CARD32,xor); \ break; \ case (sizeof (FbBits) - 5) | (1 << (FB_SHIFT - 3)): \ FbStorePart(dst,sizeof (FbBits) - 5,CARD8,xor); \ break; \ case (sizeof (FbBits) - 5) | (2 << (FB_SHIFT - 3)): \ FbStorePart(dst,sizeof (FbBits) - 5,CARD8,xor); \ FbStorePart(dst,sizeof (FbBits) - 4,CARD8,xor); \ break; \ case (sizeof (FbBits) - 5) | (3 << (FB_SHIFT - 3)): \ FbStorePart(dst,sizeof (FbBits) - 5,CARD8,xor); \ FbStorePart(dst,sizeof (FbBits) - 4,CARD16,xor); \ break; \ case (sizeof (FbBits) - 5) | (4 << (FB_SHIFT - 3)): \ FbStorePart(dst,sizeof (FbBits) - 5,CARD8,xor); \ FbStorePart(dst,sizeof (FbBits) - 4,CARD16,xor); \
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -