Change: Support custom transparency remaps with 32bpp blitters.
This closes a 15 year old TODO...
This commit is contained in:
committed by
Peter Nelson
parent
0bc22dd310
commit
9ce1626bb4
@@ -11,6 +11,7 @@
|
||||
#include "../zoom_func.h"
|
||||
#include "../settings_type.h"
|
||||
#include "../video/video_driver.hpp"
|
||||
#include "../palette_func.h"
|
||||
#include "40bpp_anim.hpp"
|
||||
#include "common.hpp"
|
||||
|
||||
@@ -234,10 +235,6 @@ inline void Blitter_40bppAnim::Draw(const Blitter::BlitterParams *bp, ZoomLevel
|
||||
break;
|
||||
|
||||
case BM_TRANSPARENT:
|
||||
/* TODO -- We make an assumption here that the remap in fact is transparency, not some colour.
|
||||
* This is never a problem with the code we produce, but newgrfs can make it fail... or at least:
|
||||
* we produce a result the newgrf maker didn't expect ;) */
|
||||
|
||||
/* Make the current colour a bit more black, so it looks like this image is transparent */
|
||||
src_n += n;
|
||||
if (src_px->a == 255) {
|
||||
@@ -263,6 +260,28 @@ inline void Blitter_40bppAnim::Draw(const Blitter::BlitterParams *bp, ZoomLevel
|
||||
}
|
||||
break;
|
||||
|
||||
case BM_TRANSPARENT_REMAP:
|
||||
/* Apply custom transparency remap. */
|
||||
src_n += n;
|
||||
if (src_px->a != 0) {
|
||||
src_px += n;
|
||||
do {
|
||||
if (*anim != 0) {
|
||||
*anim = bp->remap[*anim];
|
||||
} else {
|
||||
*dst = this->LookupColourInPalette(bp->remap[GetNearestColourIndex(*dst)]);
|
||||
*anim = 0;
|
||||
}
|
||||
anim++;
|
||||
dst++;
|
||||
} while (--n != 0);
|
||||
} else {
|
||||
dst += n;
|
||||
anim += n;
|
||||
src_px += n;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
if (src_px->a == 255) {
|
||||
do {
|
||||
@@ -323,6 +342,7 @@ void Blitter_40bppAnim::Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomL
|
||||
case BM_NORMAL: Draw<BM_NORMAL> (bp, zoom); return;
|
||||
case BM_COLOUR_REMAP: Draw<BM_COLOUR_REMAP>(bp, zoom); return;
|
||||
case BM_TRANSPARENT: Draw<BM_TRANSPARENT> (bp, zoom); return;
|
||||
case BM_TRANSPARENT_REMAP: Draw<BM_TRANSPARENT_REMAP>(bp, zoom); return;
|
||||
case BM_CRASH_REMAP: Draw<BM_CRASH_REMAP> (bp, zoom); return;
|
||||
case BM_BLACK_REMAP: Draw<BM_BLACK_REMAP> (bp, zoom); return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user