- Added a new patch style: CopyNewAlpha. This works just like Copy except it multiplies each

pixel's alpha channel by the specified Alpha property.

SVN r3637 (trunk)
This commit is contained in:
Randy Heit 2012-05-11 02:05:24 +00:00
parent b5a731f3a6
commit b9c3f8db4f
3 changed files with 41 additions and 99 deletions

View file

@ -185,96 +185,30 @@ void iCopyColors(BYTE *pout, const BYTE *pin, int count, int step, FCopyInfo *in
typedef void (*CopyFunc)(BYTE *pout, const BYTE *pin, int count, int step, FCopyInfo *inf); typedef void (*CopyFunc)(BYTE *pout, const BYTE *pin, int count, int step, FCopyInfo *inf);
#define COPY_FUNCS(op) \
{ \
iCopyColors<cRGB, cBGRA, op>, \
iCopyColors<cRGBA, cBGRA, op>, \
iCopyColors<cIA, cBGRA, op>, \
iCopyColors<cCMYK, cBGRA, op>, \
iCopyColors<cBGR, cBGRA, op>, \
iCopyColors<cBGRA, cBGRA, op>, \
iCopyColors<cI16, cBGRA, op>, \
iCopyColors<cRGB555, cBGRA, op>, \
iCopyColors<cPalEntry, cBGRA, op> \
}
static const CopyFunc copyfuncs[][9]={ static const CopyFunc copyfuncs[][9]={
{ COPY_FUNCS(bCopy),
iCopyColors<cRGB, cBGRA, bCopy>, COPY_FUNCS(bBlend),
iCopyColors<cRGBA, cBGRA, bCopy>, COPY_FUNCS(bAdd),
iCopyColors<cIA, cBGRA, bCopy>, COPY_FUNCS(bSubtract),
iCopyColors<cCMYK, cBGRA, bCopy>, COPY_FUNCS(bReverseSubtract),
iCopyColors<cBGR, cBGRA, bCopy>, COPY_FUNCS(bModulate),
iCopyColors<cBGRA, cBGRA, bCopy>, COPY_FUNCS(bCopyAlpha),
iCopyColors<cI16, cBGRA, bCopy>, COPY_FUNCS(bCopyNewAlpha),
iCopyColors<cRGB555, cBGRA, bCopy>, COPY_FUNCS(bOverwrite)
iCopyColors<cPalEntry, cBGRA, bCopy>
},
{
iCopyColors<cRGB, cBGRA, bBlend>,
iCopyColors<cRGBA, cBGRA, bBlend>,
iCopyColors<cIA, cBGRA, bBlend>,
iCopyColors<cCMYK, cBGRA, bBlend>,
iCopyColors<cBGR, cBGRA, bBlend>,
iCopyColors<cBGRA, cBGRA, bBlend>,
iCopyColors<cI16, cBGRA, bBlend>,
iCopyColors<cRGB555, cBGRA, bBlend>,
iCopyColors<cPalEntry, cBGRA, bBlend>
},
{
iCopyColors<cRGB, cBGRA, bAdd>,
iCopyColors<cRGBA, cBGRA, bAdd>,
iCopyColors<cIA, cBGRA, bAdd>,
iCopyColors<cCMYK, cBGRA, bAdd>,
iCopyColors<cBGR, cBGRA, bAdd>,
iCopyColors<cBGRA, cBGRA, bAdd>,
iCopyColors<cI16, cBGRA, bAdd>,
iCopyColors<cRGB555, cBGRA, bAdd>,
iCopyColors<cPalEntry, cBGRA, bAdd>
},
{
iCopyColors<cRGB, cBGRA, bSubtract>,
iCopyColors<cRGBA, cBGRA, bSubtract>,
iCopyColors<cIA, cBGRA, bSubtract>,
iCopyColors<cCMYK, cBGRA, bSubtract>,
iCopyColors<cBGR, cBGRA, bSubtract>,
iCopyColors<cBGRA, cBGRA, bSubtract>,
iCopyColors<cI16, cBGRA, bSubtract>,
iCopyColors<cRGB555, cBGRA, bSubtract>,
iCopyColors<cPalEntry, cBGRA, bSubtract>
},
{
iCopyColors<cRGB, cBGRA, bReverseSubtract>,
iCopyColors<cRGBA, cBGRA, bReverseSubtract>,
iCopyColors<cIA, cBGRA, bReverseSubtract>,
iCopyColors<cCMYK, cBGRA, bReverseSubtract>,
iCopyColors<cBGR, cBGRA, bReverseSubtract>,
iCopyColors<cBGRA, cBGRA, bReverseSubtract>,
iCopyColors<cI16, cBGRA, bReverseSubtract>,
iCopyColors<cRGB555, cBGRA, bReverseSubtract>,
iCopyColors<cPalEntry, cBGRA, bReverseSubtract>
},
{
iCopyColors<cRGB, cBGRA, bModulate>,
iCopyColors<cRGBA, cBGRA, bModulate>,
iCopyColors<cIA, cBGRA, bModulate>,
iCopyColors<cCMYK, cBGRA, bModulate>,
iCopyColors<cBGR, cBGRA, bModulate>,
iCopyColors<cBGRA, cBGRA, bModulate>,
iCopyColors<cI16, cBGRA, bModulate>,
iCopyColors<cRGB555, cBGRA, bModulate>,
iCopyColors<cPalEntry, cBGRA, bModulate>
},
{
iCopyColors<cRGB, cBGRA, bCopyAlpha>,
iCopyColors<cRGBA, cBGRA, bCopyAlpha>,
iCopyColors<cIA, cBGRA, bCopyAlpha>,
iCopyColors<cCMYK, cBGRA, bCopyAlpha>,
iCopyColors<cBGR, cBGRA, bCopyAlpha>,
iCopyColors<cBGRA, cBGRA, bCopyAlpha>,
iCopyColors<cI16, cBGRA, bCopyAlpha>,
iCopyColors<cRGB555, cBGRA, bCopyAlpha>,
iCopyColors<cPalEntry, cBGRA, bCopyAlpha>
},
{
iCopyColors<cRGB, cBGRA, bOverwrite>,
iCopyColors<cRGBA, cBGRA, bOverwrite>,
iCopyColors<cIA, cBGRA, bOverwrite>,
iCopyColors<cCMYK, cBGRA, bOverwrite>,
iCopyColors<cBGR, cBGRA, bOverwrite>,
iCopyColors<cBGRA, cBGRA, bOverwrite>,
iCopyColors<cI16, cBGRA, bOverwrite>,
iCopyColors<cRGB555, cBGRA, bOverwrite>,
iCopyColors<cPalEntry, cBGRA, bOverwrite>
},
}; };
#undef COPY_FUNCS
//=========================================================================== //===========================================================================
// //
@ -487,6 +421,7 @@ static const CopyPalettedFunc copypalettedfuncs[]=
iCopyPaletted<cBGRA, bReverseSubtract>, iCopyPaletted<cBGRA, bReverseSubtract>,
iCopyPaletted<cBGRA, bModulate>, iCopyPaletted<cBGRA, bModulate>,
iCopyPaletted<cBGRA, bCopyAlpha>, iCopyPaletted<cBGRA, bCopyAlpha>,
iCopyPaletted<cBGRA, bCopyNewAlpha>,
iCopyPaletted<cBGRA, bOverwrite> iCopyPaletted<cBGRA, bOverwrite>
}; };

View file

@ -318,6 +318,7 @@ enum ECopyOp
OP_REVERSESUBTRACT, OP_REVERSESUBTRACT,
OP_MODULATE, OP_MODULATE,
OP_COPYALPHA, OP_COPYALPHA,
OP_COPYNEWALPHA,
OP_OVERWRITE OP_OVERWRITE
}; };
@ -330,6 +331,13 @@ struct FCopyInfo
fixed_t invalpha; fixed_t invalpha;
}; };
struct bOverwrite
{
static __forceinline void OpC(BYTE &d, BYTE s, BYTE a, FCopyInfo *i) { d = s; }
static __forceinline void OpA(BYTE &d, BYTE s, FCopyInfo *i) { d = s; }
static __forceinline bool ProcessAlpha0() { return true; }
};
struct bCopy struct bCopy
{ {
static __forceinline void OpC(BYTE &d, BYTE s, BYTE a, FCopyInfo *i) { d = s; } static __forceinline void OpC(BYTE &d, BYTE s, BYTE a, FCopyInfo *i) { d = s; }
@ -337,11 +345,18 @@ struct bCopy
static __forceinline bool ProcessAlpha0() { return false; } static __forceinline bool ProcessAlpha0() { return false; }
}; };
struct bOverwrite struct bCopyNewAlpha
{ {
static __forceinline void OpC(BYTE &d, BYTE s, BYTE a, FCopyInfo *i) { d = s; } static __forceinline void OpC(BYTE &d, BYTE s, BYTE a, FCopyInfo *i) { d = s; }
static __forceinline void OpA(BYTE &d, BYTE s, FCopyInfo *i) { d = (s*i->alpha) >> FRACBITS; }
static __forceinline bool ProcessAlpha0() { return false; }
};
struct bCopyAlpha
{
static __forceinline void OpC(BYTE &d, BYTE s, BYTE a, FCopyInfo *i) { d = (s*a + d*(255-a))/255; }
static __forceinline void OpA(BYTE &d, BYTE s, FCopyInfo *i) { d = s; } static __forceinline void OpA(BYTE &d, BYTE s, FCopyInfo *i) { d = s; }
static __forceinline bool ProcessAlpha0() { return true; } static __forceinline bool ProcessAlpha0() { return false; }
}; };
struct bBlend struct bBlend
@ -379,13 +394,5 @@ struct bModulate
static __forceinline bool ProcessAlpha0() { return false; } static __forceinline bool ProcessAlpha0() { return false; }
}; };
struct bCopyAlpha
{
static __forceinline void OpC(BYTE &d, BYTE s, BYTE a, FCopyInfo *i) { d = (s*a + d*(255-a))/255; }
static __forceinline void OpA(BYTE &d, BYTE s, FCopyInfo *i) { d = s; }
static __forceinline bool ProcessAlpha0() { return false; }
};
#endif #endif

View file

@ -1180,7 +1180,7 @@ void FMultiPatchTexture::ParsePatch(FScanner &sc, TexPart & part, bool silent, i
} }
else if (sc.Compare("style")) else if (sc.Compare("style"))
{ {
static const char *styles[] = {"copy", "translucent", "add", "subtract", "reversesubtract", "modulate", "copyalpha", NULL }; static const char *styles[] = {"copy", "translucent", "add", "subtract", "reversesubtract", "modulate", "copyalpha", "copynewalpha", NULL };
sc.MustGetString(); sc.MustGetString();
part.op = sc.MustMatchString(styles); part.op = sc.MustMatchString(styles);
bComplex |= (part.op != OP_COPY); bComplex |= (part.op != OP_COPY);