From 37001d3640be199948990b9633a531e617ec7452 Mon Sep 17 00:00:00 2001 From: Randy Heit Date: Fri, 11 May 2012 02:26:50 +0000 Subject: [PATCH] - Added new patch style "Overlay" for TEXTURES. This is the same as CopyAlpha, except it only copies the patch's alpha channel where it has a higher alpha than what's underneath. SVN r3638 (trunk) --- src/textures/bitmap.cpp | 2 ++ src/textures/bitmap.h | 8 ++++++++ src/textures/multipatchtexture.cpp | 2 +- 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/textures/bitmap.cpp b/src/textures/bitmap.cpp index cf419d70d..94b8ce774 100644 --- a/src/textures/bitmap.cpp +++ b/src/textures/bitmap.cpp @@ -206,6 +206,7 @@ static const CopyFunc copyfuncs[][9]={ COPY_FUNCS(bModulate), COPY_FUNCS(bCopyAlpha), COPY_FUNCS(bCopyNewAlpha), + COPY_FUNCS(bOverlay), COPY_FUNCS(bOverwrite) }; #undef COPY_FUNCS @@ -422,6 +423,7 @@ static const CopyPalettedFunc copypalettedfuncs[]= iCopyPaletted, iCopyPaletted, iCopyPaletted, + iCopyPaletted, iCopyPaletted }; diff --git a/src/textures/bitmap.h b/src/textures/bitmap.h index dc125bf87..ef57f562d 100644 --- a/src/textures/bitmap.h +++ b/src/textures/bitmap.h @@ -319,6 +319,7 @@ enum ECopyOp OP_MODULATE, OP_COPYALPHA, OP_COPYNEWALPHA, + OP_OVERLAY, OP_OVERWRITE }; @@ -359,6 +360,13 @@ struct bCopyAlpha static __forceinline bool ProcessAlpha0() { return false; } }; +struct bOverlay +{ + 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 = MAX(s,d); } + static __forceinline bool ProcessAlpha0() { return false; } +}; + struct bBlend { static __forceinline void OpC(BYTE &d, BYTE s, BYTE a, FCopyInfo *i) { d = (d*i->invalpha + s*i->alpha) >> FRACBITS; } diff --git a/src/textures/multipatchtexture.cpp b/src/textures/multipatchtexture.cpp index 5799ad04e..220a25a2f 100644 --- a/src/textures/multipatchtexture.cpp +++ b/src/textures/multipatchtexture.cpp @@ -1180,7 +1180,7 @@ void FMultiPatchTexture::ParsePatch(FScanner &sc, TexPart & part, bool silent, i } else if (sc.Compare("style")) { - static const char *styles[] = {"copy", "translucent", "add", "subtract", "reversesubtract", "modulate", "copyalpha", "copynewalpha", NULL }; + static const char *styles[] = {"copy", "translucent", "add", "subtract", "reversesubtract", "modulate", "copyalpha", "copynewalpha", "overlay", NULL }; sc.MustGetString(); part.op = sc.MustMatchString(styles); bComplex |= (part.op != OP_COPY);