diff options
author | Benjamin Franzke <benjaminfranzke@googlemail.com> | 2013-01-15 08:46:13 +0100 |
---|---|---|
committer | Benjamin Franzke <benjaminfranzke@googlemail.com> | 2013-01-15 08:46:13 +0100 |
commit | 7fe60435bce6595a9c58a9bfd8244d74b5320e96 (patch) | |
tree | 1ac714a916e02fc90901ddac8bc2a3c6d051d28c /Source/DirectFB/src/gfx/generic/template_colorkey_16.h | |
download | directfb-voodoo-7fe60435bce6595a9c58a9bfd8244d74b5320e96.tar.gz directfb-voodoo-7fe60435bce6595a9c58a9bfd8244d74b5320e96.tar.bz2 directfb-voodoo-7fe60435bce6595a9c58a9bfd8244d74b5320e96.zip |
Import DirectFB141_2k11R3_beta5
Diffstat (limited to 'Source/DirectFB/src/gfx/generic/template_colorkey_16.h')
-rwxr-xr-x | Source/DirectFB/src/gfx/generic/template_colorkey_16.h | 369 |
1 files changed, 369 insertions, 0 deletions
diff --git a/Source/DirectFB/src/gfx/generic/template_colorkey_16.h b/Source/DirectFB/src/gfx/generic/template_colorkey_16.h new file mode 100755 index 0000000..542dad2 --- /dev/null +++ b/Source/DirectFB/src/gfx/generic/template_colorkey_16.h @@ -0,0 +1,369 @@ +/* + (c) Copyright 2001-2009 The world wide DirectFB Open Source Community (directfb.org) + (c) Copyright 2000-2004 Convergence (integrated media) GmbH + + All rights reserved. + + Written by Denis Oliver Kropp <dok@directfb.org>, + Andreas Hundt <andi@fischlustig.de>, + Sven Neumann <neo@directfb.org>, + Ville Syrjälä <syrjala@sci.fi> and + Claudio Ciccani <klan@users.sf.net>. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the + Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. +*/ + +/* + * Example: + * #define RGB_MASK 0x7fff + * #define Cop_OP_Aop_PFI( op ) Cop_##op##_Aop_15 + * #define Bop_PFI_OP_Aop_PFI( op ) Bop_15_##op##_Aop_15 + * #include "template_ckey_16.h" + */ + +#if RGB_MASK == 0xffff +#define MASK_RGB( p ) (p) +#else +#define MASK_RGB( p ) ((p) & RGB_MASK) +#endif + +#define MASK_RGB_L( p ) ((p) & RGB_MASK) +#define MASK_RGB_H( p ) ((p) & (RGB_MASK << 16)) +#define MASK_RGB_32( p ) ((p) & (RGB_MASK << 16 | RGB_MASK)) + +/********************************* Cop_toK_Aop_PFI ****************************/ + +static void Cop_OP_Aop_PFI(toK)( GenefxState *gfxs ) +{ + int l = gfxs->length; + u16 *D = gfxs->Aop[0]; + u16 Dkey = gfxs->Dkey; + u16 Cop = gfxs->Cop; + + while (l--) { + if (MASK_RGB( *D ) == Dkey) + *D = Cop; + + D++; + } +} + +/********************************* Bop_PFI_Kto_Aop_PFI ************************/ + +static void Bop_PFI_OP_Aop_PFI(Kto)( GenefxState *gfxs ) +{ + int w, l = gfxs->length; + int Ostep = gfxs->Ostep; + u16 *S = gfxs->Bop[0]; + u16 *D = gfxs->Aop[0]; + u16 Skey = gfxs->Skey; + u32 SkeyH = gfxs->Skey << 16; + + /* blit direction */ + if (Ostep < 0) { + S += gfxs->length - 1; + D += gfxs->length - 1; + } + + if (((long)S & 2) != ((long)D & 2)) { + /* source and destination misaligned */ + while (l--) { + u16 s = *S; + + if (MASK_RGB( s ) != Skey) + *D = s; + + S += Ostep; + D += Ostep; + } + + return; + } + + /* fix alignment */ + if (Ostep > 0) { + if ((long)D & 2) { + /* align / leftmost pixel */ + u16 s = *S; + + if (MASK_RGB( s ) != Skey) + *D = s; + + S++; + D++; + l--; + } + } else { /* Ostep < 0 */ + if ((long)D & 2) { + /* align */ + S--; + D--; + } else { + /* rightmost pixel */ + u16 s = *S; + + if (MASK_RGB( s ) != Skey) + *D = s; + + S -= 2; + D -= 2; + l--; + } + } + + /* blit */ + Ostep <<= 1; + w = l >> 1; + while (w--) { + u32 s = *(u32 *) S; + + if (MASK_RGB_L( s ) != Skey) { + if (MASK_RGB_H( s ) != SkeyH) { + *(u32 *) D = s; + } else { +#ifdef WORDS_BIGENDIAN + D[1] = (u16) s; +#else + D[0] = (u16) s; +#endif + } + } else if (MASK_RGB_H( s ) != SkeyH) { +#ifdef WORDS_BIGENDIAN + D[0] = (u16) (s >> 16); +#else + D[1] = (u16) (s >> 16); +#endif + } + + S += Ostep; + D += Ostep; + } + + /* last potential pixel */ + if (l & 1) { + u16 s; + + if (Ostep < 0) { + S++; + D++; + } + + s = *S; + if (MASK_RGB( s ) != Skey) + *D = s; + } +} + +/********************************* Bop_PFI_toK_Aop_PFI ************************/ + +static void Bop_PFI_OP_Aop_PFI(toK)( GenefxState *gfxs ) +{ + int w, l = gfxs->length; + int Ostep = gfxs->Ostep; + u16 *S = gfxs->Bop[0]; + u16 *D = gfxs->Aop[0]; + u16 Dkey = gfxs->Dkey; + u32 DkeyH = gfxs->Dkey << 16; + + /* blit direction */ + if (Ostep < 0) { + S += gfxs->length - 1; + D += gfxs->length - 1; + } + + if (((long)S & 2) != ((long)D & 2)) { + /* source and destination misaligned */ + while (l--) { + if (MASK_RGB( *D ) == Dkey) + *D = *S; + + S += Ostep; + D += Ostep; + } + + return; + } + + /* fix alignment */ + if ((Ostep > 0)) { + if ((long)D & 2) { + /* align / leftmost pixel */ + if (MASK_RGB( *D ) == Dkey) + *D = *S; + + S++; + D++; + l--; + } + } else { /* Ostep < 0 */ + if ((long)D & 2) { + /* align */ + S--; + D--; + } else { + /* rightmost pixel */ + if (MASK_RGB( *D ) == Dkey) + *D = *S; + + S -= 2; + D -= 2; + l--; + } + } + + /* blit */ + Ostep <<= 1; + w = l >> 1; + while (w--) { + u32 d = *(u32 *) D; + + if (MASK_RGB_32( d ) == (DkeyH | Dkey)) { + *(u32 *) D = *(u32 *) S; + } else { + if (MASK_RGB_L( d ) == Dkey) { +#ifdef WORDS_BIGENDIAN + D[0] = S[0]; +#else + D[1] = S[1]; +#endif + } else + if (MASK_RGB_H( d ) == DkeyH) { +#ifdef WORDS_BIGENDIAN + D[1] = S[1]; +#else + D[0] = S[0]; +#endif + } + } + + S += Ostep; + D += Ostep; + } + + /* last potential pixel */ + if (l & 1) { + if (Ostep < 0) { + S++; + D++; + } + + if (MASK_RGB( *D ) == Dkey) + *D = *S; + } +} + +/********************************* Bop_PFI_KtoK_Aop_PFI ***********************/ + +static void Bop_PFI_OP_Aop_PFI(KtoK)( GenefxState *gfxs ) +{ + int l = gfxs->length; + int Ostep = gfxs->Ostep; + u16 *S = gfxs->Bop[0]; + u16 *D = gfxs->Aop[0]; + u16 Skey = gfxs->Skey; + u16 Dkey = gfxs->Dkey; + + if (Ostep < 0) { + S += gfxs->length - 1; + D += gfxs->length - 1; + } + + while (l--) { + u16 s = *S; + + if (MASK_RGB( s ) != Skey && MASK_RGB( *D ) == Dkey) + *D = s; + + S += Ostep; + D += Ostep; + } +} + +/********************************* Bop_PFI_SKto_Aop_PFI ***********************/ + +static void Bop_PFI_OP_Aop_PFI(SKto)( GenefxState *gfxs ) +{ + int l = gfxs->length; + int i = gfxs->Xphase; + int SperD = gfxs->SperD; + u16 *S = gfxs->Bop[0]; + u16 *D = gfxs->Aop[0]; + u16 Skey = gfxs->Skey; + + while (l--) { + u16 s = S[i>>16]; + + if (MASK_RGB( s ) != Skey) + *D = s; + + D++; + i += SperD; + } +} + +/********************************* Bop_PFI_StoK_Aop_PFI ***********************/ + +static void Bop_PFI_OP_Aop_PFI(StoK)( GenefxState *gfxs ) +{ + int l = gfxs->length; + int i = gfxs->Xphase; + int SperD = gfxs->SperD; + u16 *S = gfxs->Bop[0]; + u16 *D = gfxs->Aop[0]; + u16 Dkey = gfxs->Dkey; + + while (l--) { + if (MASK_RGB( *D ) != Dkey) + *D = S[i>>16]; + + D++; + i += SperD; + } +} + +/********************************* Bop_PFI_SKtoK_Aop_PFI **********************/ + +static void Bop_PFI_OP_Aop_PFI(SKtoK)( GenefxState *gfxs ) +{ + int l = gfxs->length; + int i = gfxs->Xphase; + int SperD = gfxs->SperD; + u16 *S = gfxs->Bop[0]; + u16 *D = gfxs->Aop[0]; + u16 Skey = gfxs->Skey; + u16 Dkey = gfxs->Dkey; + + while (l--) { + u16 s = S[i>>16]; + + if (MASK_RGB( s ) != Skey && MASK_RGB( *D ) == Dkey) + *D = s; + + D++; + i += SperD; + } +} + +/******************************************************************************/ + +#undef MASK_RGB +#undef MASK_RGB_L +#undef MASK_RGB_H +#undef MASK_RGB_32 + +#undef RGB_MASK +#undef Cop_OP_Aop_PFI +#undef Bop_PFI_OP_Aop_PFI |