Changeset - r21823:934ee4e81d60
[Not reviewed]
master
0 9 0
rubidium - 10 years ago 2014-10-06 18:45:51
rubidium@openttd.org
(svn r26969) -Fix (r26869): black palette didn't work very well with unmasked 32bpp sprites
9 files changed with 82 insertions and 3 deletions:
0 comments (0 inline, 0 general)
src/blitter/32bpp_anim.cpp
Show inline comments
 
@@ -175,6 +175,16 @@ inline void Blitter_32bppAnim::Draw(cons
 
					}
 
					break;
 

	
 

	
 
				case BM_BLACK_REMAP:
 
					do {
 
						*dst++ = Colour(0, 0, 0);
 
						*anim++ = 0;
 
						anim++;
 
						dst++;
 
					} while (--n != 0);
 
					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:
 
@@ -251,6 +261,7 @@ void Blitter_32bppAnim::Draw(Blitter::Bl
 
		case BM_COLOUR_REMAP: Draw<BM_COLOUR_REMAP>(bp, zoom); return;
 
		case BM_TRANSPARENT:  Draw<BM_TRANSPARENT> (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;
 
	}
 
}
 

	
src/blitter/32bpp_anim_sse4.cpp
Show inline comments
 
@@ -334,6 +334,19 @@ bmcr_alpha_blend_single:
 
					anim++;
 
				}
 
				break;
 

	
 
			case BM_BLACK_REMAP:
 
				for (uint x = (uint) bp->width; x > 0; x--) {
 
					if (src->a != 0) {
 
						*dst = Colour(0, 0, 0);
 
						*anim = 0;
 
					}
 
					src_mv++;
 
					dst++;
 
					src++;
 
					anim++;
 
				}
 
				break;
 
		}
 

	
 
next_line:
 
@@ -395,6 +408,7 @@ bm_normal:
 
			break;
 
		case BM_TRANSPARENT:  Draw<BM_TRANSPARENT, RM_NONE, BT_NONE, true, true>(bp, zoom); return;
 
		case BM_CRASH_REMAP:  Draw<BM_CRASH_REMAP, RM_NONE, BT_NONE, true, true>(bp, zoom); return;
 
		case BM_BLACK_REMAP:  Draw<BM_BLACK_REMAP, RM_NONE, BT_NONE, true, true>(bp, zoom); return;
 
	}
 
}
 

	
src/blitter/32bpp_optimized.cpp
Show inline comments
 
@@ -177,6 +177,15 @@ inline void Blitter_32bppOptimized::Draw
 
					}
 
					break;
 

	
 
				case BM_BLACK_REMAP:
 
					do {
 
						*dst = Colour(0, 0, 0);
 
						dst++;
 
						src_px++;
 
						src_n++;
 
					} while (--n != 0);
 
					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:
 
@@ -241,6 +250,7 @@ void Blitter_32bppOptimized::Draw(Blitte
 
		case BM_COLOUR_REMAP: Draw<BM_COLOUR_REMAP>(bp, zoom); return;
 
		case BM_TRANSPARENT:  Draw<BM_TRANSPARENT> (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;
 
	}
 
}
 

	
src/blitter/32bpp_simple.cpp
Show inline comments
 
@@ -58,6 +58,12 @@ void Blitter_32bppSimple::Draw(Blitter::
 
					}
 
					break;
 

	
 
				case BM_BLACK_REMAP:
 
					if (src->a != 0) {
 
						*dst = Colour(0, 0, 0);
 
					}
 
					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:
src/blitter/32bpp_sse_func.hpp
Show inline comments
 
@@ -394,6 +394,17 @@ bmcr_alpha_blend_single:
 
					src++;
 
				}
 
				break;
 

	
 
			case BM_BLACK_REMAP:
 
				for (uint x = (uint) bp->width; x > 0; x--) {
 
					if (src->a != 0) {
 
						*dst = Colour(0, 0, 0);
 
					}
 
					src_mv++;
 
					dst++;
 
					src++;
 
				}
 
				break;
 
		}
 

	
 
next_line:
 
@@ -447,6 +458,7 @@ bm_normal:
 
			}
 
		case BM_TRANSPARENT:  Draw<BM_TRANSPARENT, RM_NONE, BT_NONE, true>(bp, zoom); return;
 
		case BM_CRASH_REMAP:  Draw<BM_CRASH_REMAP, RM_NONE, BT_NONE, true>(bp, zoom); return;
 
		case BM_BLACK_REMAP:  Draw<BM_BLACK_REMAP, RM_NONE, BT_NONE, true>(bp, zoom); return;
 
	}
 
}
 
#endif /* FULL_ANIMATION */
src/blitter/8bpp_optimized.cpp
Show inline comments
 
@@ -13,6 +13,7 @@
 
#include "../zoom_func.h"
 
#include "../settings_type.h"
 
#include "../core/math_func.hpp"
 
#include "../core/mem_func.hpp"
 
#include "8bpp_optimized.hpp"
 

	
 
#include "../safeguards.h"
 
@@ -96,6 +97,11 @@ void Blitter_8bppOptimized::Draw(Blitter
 
					break;
 
				}
 

	
 
				case BM_BLACK_REMAP:
 
					MemSetT(dst, 0, pixels);
 
					dst += pixels;
 
					break;
 

	
 
				case BM_TRANSPARENT: {
 
					const uint8 *remap = bp->remap;
 
					src += pixels;
 
@@ -107,7 +113,7 @@ void Blitter_8bppOptimized::Draw(Blitter
 
				}
 

	
 
				default:
 
					memcpy(dst, src, pixels);
 
					MemCpyT(dst, src, pixels);
 
					dst += pixels; src += pixels;
 
					break;
 
			}
src/blitter/8bpp_simple.cpp
Show inline comments
 
@@ -47,6 +47,10 @@ void Blitter_8bppSimple::Draw(Blitter::B
 
					if (*src != 0) colour = bp->remap[*dst];
 
					break;
 

	
 
				case BM_BLACK_REMAP:
 
					colour = 0;
 
					break;
 

	
 
				default:
 
					colour = *src;
 
					break;
src/blitter/base.hpp
Show inline comments
 
@@ -21,6 +21,7 @@ enum BlitterMode {
 
	BM_COLOUR_REMAP, ///< Perform a colour remapping.
 
	BM_TRANSPARENT,  ///< Perform transparency colour remapping.
 
	BM_CRASH_REMAP,  ///< Perform a crash remapping.
 
	BM_BLACK_REMAP,  ///< Perform remapping to a completely blackened sprite
 
};
 

	
 
/**
src/gfx.cpp
Show inline comments
 
@@ -783,6 +783,21 @@ Dimension GetSpriteSize(SpriteID sprid, 
 
}
 

	
 
/**
 
 * Helper function to get the blitter mode for different types of palettes.
 
 * @param pal The palette to get the blitter mode for.
 
 * @return The blitter mode associated with the palette.
 
 */
 
static BlitterMode GetBlitterMode(PaletteID pal)
 
{
 
	switch (pal) {
 
		case PAL_NONE:          return BM_NORMAL;
 
		case PALETTE_CRASH:     return BM_CRASH_REMAP;
 
		case PALETTE_ALL_BLACK: return BM_BLACK_REMAP;
 
		default:                return BM_COLOUR_REMAP;
 
	}
 
}
 

	
 
/**
 
 * Draw a sprite in a viewport.
 
 * @param img  Image number to draw
 
 * @param pal  Palette to use.
 
@@ -802,7 +817,7 @@ void DrawSpriteViewport(SpriteID img, Pa
 
		} else {
 
			_colour_remap_ptr = GetNonSprite(GB(pal, 0, PALETTE_WIDTH), ST_RECOLOUR) + 1;
 
		}
 
		GfxMainBlitterViewport(GetSprite(real_sprite, ST_NORMAL), x, y, pal == PALETTE_CRASH ? BM_CRASH_REMAP : BM_COLOUR_REMAP, sub, real_sprite);
 
		GfxMainBlitterViewport(GetSprite(real_sprite, ST_NORMAL), x, y, GetBlitterMode(pal), sub, real_sprite);
 
	} else {
 
		GfxMainBlitterViewport(GetSprite(real_sprite, ST_NORMAL), x, y, BM_NORMAL, sub, real_sprite);
 
	}
 
@@ -829,7 +844,7 @@ void DrawSprite(SpriteID img, PaletteID 
 
		} else {
 
			_colour_remap_ptr = GetNonSprite(GB(pal, 0, PALETTE_WIDTH), ST_RECOLOUR) + 1;
 
		}
 
		GfxMainBlitter(GetSprite(real_sprite, ST_NORMAL), x, y, pal == PALETTE_CRASH ? BM_CRASH_REMAP : BM_COLOUR_REMAP, sub, real_sprite, zoom);
 
		GfxMainBlitter(GetSprite(real_sprite, ST_NORMAL), x, y, GetBlitterMode(pal), sub, real_sprite, zoom);
 
	} else {
 
		GfxMainBlitter(GetSprite(real_sprite, ST_NORMAL), x, y, BM_NORMAL, sub, real_sprite, zoom);
 
	}
0 comments (0 inline, 0 general)