⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 fbcompose.c

📁 按照官方的说法:Cairo is a vector graphics library with cross-device output support. 翻译过来
💻 C
📖 第 1 页 / 共 5 页
字号:
        *pixel = (*pixel & ~mask) | v;    }}static storeProc storeProcForPicture (PicturePtr pict){    switch(pict->format_code) {    case PICT_a8r8g8b8: return fbStore_a8r8g8b8;    case PICT_x8r8g8b8: return fbStore_x8r8g8b8;    case PICT_a8b8g8r8: return fbStore_a8b8g8r8;    case PICT_x8b8g8r8: return fbStore_x8b8g8r8;        /* 24bpp formats */    case PICT_r8g8b8: return fbStore_r8g8b8;    case PICT_b8g8r8: return fbStore_b8g8r8;        /* 16bpp formats */    case PICT_r5g6b5: return fbStore_r5g6b5;    case PICT_b5g6r5: return fbStore_b5g6r5;    case PICT_a1r5g5b5: return fbStore_a1r5g5b5;    case PICT_x1r5g5b5: return fbStore_x1r5g5b5;    case PICT_a1b5g5r5: return fbStore_a1b5g5r5;    case PICT_x1b5g5r5: return fbStore_x1b5g5r5;    case PICT_a4r4g4b4: return fbStore_a4r4g4b4;    case PICT_x4r4g4b4: return fbStore_x4r4g4b4;    case PICT_a4b4g4r4: return fbStore_a4b4g4r4;    case PICT_x4b4g4r4: return fbStore_x4b4g4r4;        /* 8bpp formats */    case PICT_a8: return  fbStore_a8;    case PICT_r3g3b2: return fbStore_r3g3b2;    case PICT_b2g3r3: return fbStore_b2g3r3;    case PICT_a2r2g2b2: return fbStore_a2r2g2b2;    case PICT_c8: return  fbStore_c8;    case PICT_g8: return  fbStore_c8;        /* 4bpp formats */    case PICT_a4: return  fbStore_a4;    case PICT_r1g2b1: return fbStore_r1g2b1;    case PICT_b1g2r1: return fbStore_b1g2r1;    case PICT_a1r1g1b1: return fbStore_a1r1g1b1;    case PICT_a1b1g1r1: return fbStore_a1b1g1r1;    case PICT_c4: return  fbStore_c4;    case PICT_g4: return  fbStore_c4;        /* 1bpp formats */    case PICT_a1: return  fbStore_a1;    case PICT_g1: return  fbStore_g1;    default:        return NULL;    }}/* * Combine src and mask */static FASTCALL voidfbCombineMaskU (CARD32 *src, const CARD32 *mask, int width){    int i;    for (i = 0; i < width; ++i) {        CARD32 a = mask[i] >> 24;        CARD32 s = src[i];        FbByteMul(s, a);        src[i] = s;    }}/* * All of the composing functions */static FASTCALL voidfbCombineClear (CARD32 *dest, const CARD32 *src, int width){    memset(dest, 0, width*sizeof(CARD32));}static FASTCALL voidfbCombineSrcU (CARD32 *dest, const CARD32 *src, int width){    memcpy(dest, src, width*sizeof(CARD32));}static FASTCALL voidfbCombineOverU (CARD32 *dest, const CARD32 *src, int width){    int i;    for (i = 0; i < width; ++i) {        CARD32 s = src[i];        CARD32 d = dest[i];        CARD32 ia = Alpha(~s);        FbByteMulAdd(d, ia, s);        dest[i] = d;    }}static FASTCALL voidfbCombineOverReverseU (CARD32 *dest, const CARD32 *src, int width){    int i;    for (i = 0; i < width; ++i) {        CARD32 s = src[i];        CARD32 d = dest[i];        CARD32 ia = Alpha(~dest[i]);        FbByteMulAdd(s, ia, d);        dest[i] = s;    }}static FASTCALL voidfbCombineInU (CARD32 *dest, const CARD32 *src, int width){    int i;    for (i = 0; i < width; ++i) {        CARD32 s = src[i];        CARD32 a = Alpha(dest[i]);        FbByteMul(s, a);        dest[i] = s;    }}static FASTCALL voidfbCombineInReverseU (CARD32 *dest, const CARD32 *src, int width){    int i;    for (i = 0; i < width; ++i) {        CARD32 d = dest[i];        CARD32 a = Alpha(src[i]);        FbByteMul(d, a);        dest[i] = d;    }}static FASTCALL voidfbCombineOutU (CARD32 *dest, const CARD32 *src, int width){    int i;    for (i = 0; i < width; ++i) {        CARD32 s = src[i];        CARD32 a = Alpha(~dest[i]);        FbByteMul(s, a);        dest[i] = s;    }}static FASTCALL voidfbCombineOutReverseU (CARD32 *dest, const CARD32 *src, int width){    int i;    for (i = 0; i < width; ++i) {        CARD32 d = dest[i];        CARD32 a = Alpha(~src[i]);        FbByteMul(d, a);        dest[i] = d;    }}static FASTCALL voidfbCombineAtopU (CARD32 *dest, const CARD32 *src, int width){    int i;    for (i = 0; i < width; ++i) {        CARD32 s = src[i];        CARD32 d = dest[i];        CARD32 dest_a = Alpha(d);        CARD32 src_ia = Alpha(~s);        FbByteAddMul(s, dest_a, d, src_ia);        dest[i] = s;    }}static FASTCALL voidfbCombineAtopReverseU (CARD32 *dest, const CARD32 *src, int width){    int i;    for (i = 0; i < width; ++i) {        CARD32 s = src[i];        CARD32 d = dest[i];        CARD32 src_a = Alpha(s);        CARD32 dest_ia = Alpha(~d);        FbByteAddMul(s, dest_ia, d, src_a);        dest[i] = s;    }}static FASTCALL voidfbCombineXorU (CARD32 *dest, const CARD32 *src, int width){    int i;    for (i = 0; i < width; ++i) {        CARD32 s = src[i];        CARD32 d = dest[i];        CARD32 src_ia = Alpha(~s);        CARD32 dest_ia = Alpha(~d);        FbByteAddMul(s, dest_ia, d, src_ia);        dest[i] = s;    }}static FASTCALL voidfbCombineAddU (CARD32 *dest, const CARD32 *src, int width){    int i;    for (i = 0; i < width; ++i) {        CARD32 s = src[i];        CARD32 d = dest[i];        FbByteAdd(d, s);        dest[i] = d;    }}static FASTCALL voidfbCombineSaturateU (CARD32 *dest, const CARD32 *src, int width){    int i;    for (i = 0; i < width; ++i) {        CARD32  s = src[i];        CARD32 d = dest[i];        CARD16  sa, da;        sa = s >> 24;        da = ~d >> 24;        if (sa > da)        {            sa = FbIntDiv(da, sa);            FbByteMul(s, sa);        }        FbByteAdd(d, s);        dest[i] = d;    }}/* * All of the disjoint composing functions The four entries in the first column indicate what source contributions come from each of the four areas of the picture -- areas covered by neither A nor B, areas covered only by A, areas covered only by B and finally areas covered by both A and B.		Disjoint			Conjoint		Fa		Fb		Fa		Fb(0,0,0,0)	0		0		0		0(0,A,0,A)	1		0		1		0(0,0,B,B)	0		1		0		1(0,A,B,A)	1		min((1-a)/b,1)	1		max(1-a/b,0)(0,A,B,B)	min((1-b)/a,1)	1		max(1-b/a,0)	1(0,0,0,A)	max(1-(1-b)/a,0) 0		min(1,b/a)	0(0,0,0,B)	0		max(1-(1-a)/b,0) 0		min(a/b,1)(0,A,0,0)	min(1,(1-b)/a)	0		max(1-b/a,0)	0(0,0,B,0)	0		min(1,(1-a)/b)	0		max(1-a/b,0)(0,0,B,A)	max(1-(1-b)/a,0) min(1,(1-a)/b)	 min(1,b/a)	max(1-a/b,0)(0,A,0,B)	min(1,(1-b)/a)	max(1-(1-a)/b,0) max(1-b/a,0)	min(1,a/b)(0,A,B,0)	min(1,(1-b)/a)	min(1,(1-a)/b)	max(1-b/a,0)	max(1-a/b,0) */#define CombineAOut 1#define CombineAIn  2#define CombineBOut 4#define CombineBIn  8#define CombineClear	0#define CombineA	(CombineAOut|CombineAIn)#define CombineB	(CombineBOut|CombineBIn)#define CombineAOver	(CombineAOut|CombineBOut|CombineAIn)#define CombineBOver	(CombineAOut|CombineBOut|CombineBIn)#define CombineAAtop	(CombineBOut|CombineAIn)#define CombineBAtop	(CombineAOut|CombineBIn)#define CombineXor	(CombineAOut|CombineBOut)/* portion covered by a but not b */static INLINE CARD8fbCombineDisjointOutPart (CARD8 a, CARD8 b){    /* min (1, (1-b) / a) */    b = ~b;		    /* 1 - b */    if (b >= a)		    /* 1 - b >= a -> (1-b)/a >= 1 */	return 0xff;	    /* 1 */    return FbIntDiv(b,a);   /* (1-b) / a */}/* portion covered by both a and b */static INLINE CARD8fbCombineDisjointInPart (CARD8 a, CARD8 b){    /* max (1-(1-b)/a,0) */    /*  = - min ((1-b)/a - 1, 0) */    /*  = 1 - min (1, (1-b)/a) */    b = ~b;		    /* 1 - b */    if (b >= a)		    /* 1 - b >= a -> (1-b)/a >= 1 */	return 0;	    /* 1 - 1 */    return ~FbIntDiv(b,a);  /* 1 - (1-b) / a */}static FASTCALL voidfbCombineDisjointGeneralU (CARD32 *dest, const CARD32 *src, int width, CARD8 combine){    int i;    for (i = 0; i < width; ++i) {        CARD32 s = src[i];        CARD32 d = dest[i];        CARD32 m,n,o,p;        CARD16 Fa, Fb, t, u, v;        CARD8 sa = s >> 24;        CARD8 da = d >> 24;        switch (combine & CombineA) {        default:            Fa = 0;            break;        case CombineAOut:            Fa = fbCombineDisjointOutPart (sa, da);            break;        case CombineAIn:            Fa = fbCombineDisjointInPart (sa, da);            break;        case CombineA:            Fa = 0xff;            break;        }        switch (combine & CombineB) {        default:            Fb = 0;            break;        case CombineBOut:            Fb = fbCombineDisjointOutPart (da, sa);            break;        case CombineBIn:            Fb = fbCombineDisjointInPart (da, sa);            break;        case CombineB:            Fb = 0xff;            break;        }        m = FbGen (s,d,0,Fa,Fb,t, u, v);        n = FbGen (s,d,8,Fa,Fb,t, u, v);        o = FbGen (s,d,16,Fa,Fb,t, u, v);        p = FbGen (s,d,24,Fa,Fb,t, u, v);        s = m|n|o|p;        dest[i] = s;    }}static FASTCALL voidfbCombineDisjointOverU (CARD32 *dest, const CARD32 *src, int width){    int i;    for (i = 0; i < width; ++i) {        CARD32  s = src[i];        CARD16  a = s >> 24;        if (a != 0x00)        {            if (a != 0xff)            {                CARD32 d = dest[i];                a = fbCombineDisjointOutPart (d >> 24, a);                FbByteMulAdd(d, a, s);                s = d;            }            dest[i] = s;        }    }}static FASTCALL voidfbCombineDisjointInU (CARD32 *dest, const CARD32 *src, int width){    fbCombineDisjointGeneralU (dest, src, width, CombineAIn);}static FASTCALL voidfbCombineDisjointInReverseU (CARD32 *dest, const CARD32 *src, int width){    fbCombineDisjointGeneralU (dest, src, width, CombineBIn);}static FASTCALL voidfbCombineDisjointOutU (CARD32 *dest, const CARD32 *src, int width){    fbCombineDisjointGeneralU (dest, src, width, CombineAOut);}static FASTCALL voidfbCombineDisjointOutReverseU (CARD32 *dest, const CARD32 *src, int width){    fbCombineDisjointGeneralU (dest, src, width, CombineBOut);}static FASTCALL voidfbCombineDisjointAtopU (CARD32 *dest, const CARD32 *src, int width){    fbCombineDisjointGeneralU (dest, src, width, CombineAAtop);}static FASTCALL voidfbCombineDisjointAtopReverseU (CARD32 *dest, const CARD32 *src, int width){    fbCombineDisjointGeneralU (dest, src, width, CombineBAtop);}static FASTCALL voidfbCombineDisjointXorU (CARD32 *dest, const CARD32 *src, int width){    fbCombineDisjointGeneralU (dest, src, width, CombineXor);}/* portion covered by a but not b */static INLINE CARD8fbCombineConjointOutPart (CARD8 a, CARD8 b){    /* max (1-b/a,0) */    /* = 1-min(b/a,1) */    /* min (1, (1-b) / a) */    if (b >= a)		    /* b >= a -> b/a >= 1 */	return 0x00;	    /* 0 */    return ~FbIntDiv(b,a);   /* 1 - b/a */}/* portion covered by both a and b */static INLINE CARD8fbCombineConjointInPart (CARD8 a, CARD8 b){    /* min (1,b/a) */    if (b >= a)		    /* b >= a -> b/a >= 1 */	return 0xff;	    /* 1 */    return FbIntDiv(b,a);   /* b/a */}static FASTCALL voidfbCombineConjointGeneralU (CARD32 *dest, const CARD32 *src, int width, CARD8 combine){    int i;    for (i = 0; i < width; ++i) {        CARD32  s = src[i];        CARD32 d = dest[i];        CARD32  m,n,o,p;        CARD16  Fa, Fb, t, u, v;        CARD8 sa = s >> 24;        CARD8 da = d >> 24;        switch (combine & CombineA) {        default:            Fa = 0;            break;        case CombineAOut:            Fa = fbCombineConjointOutPart (sa, da);            break;        case CombineAIn:            Fa = fbCombineConjointInPart (sa, da);            break;        case CombineA:            Fa = 0xff;            break;        }        switch (combine & CombineB) {        default:            Fb = 0;            break;        case CombineBOut:            Fb = fbCombineConjointOutPart (da, sa);            break;        case CombineBIn:            Fb = fbCombineConjointInPart (da, sa);            break;        case CombineB:            Fb = 0xff;            break;        }        m = FbGen (s,d,0,Fa,Fb,t, u, v);        n = FbGen (s,d,8,Fa,Fb,t, u, v);        o = FbGen (s,d,16,Fa,Fb,t, u, v);        p = FbGen (s,d,24,Fa,Fb,t, u, v);        s = m|n|o|p;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -