Merge branch 'master' into jgrpp

# Conflicts:
#	src/blitter/32bpp_anim.cpp
#	src/blitter/8bpp_optimized.cpp
#	src/gfx.cpp
#	src/gfx_func.h
#	src/gfxinit.cpp
#	src/network/core/os_abstraction.cpp
#	src/spritecache.cpp
This commit is contained in:
Jonathan G Rennison
2023-12-28 16:01:08 +00:00
48 changed files with 852 additions and 371 deletions

View File

@@ -9,6 +9,7 @@
#include "../stdafx.h"
#include "../video/video_driver.hpp"
#include "../palette_func.h"
#include "../zoom_func.h"
#include "32bpp_anim.hpp"
#include "common.hpp"
@@ -220,10 +221,6 @@ inline void Blitter_32bppAnim::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) {
@@ -245,6 +242,24 @@ inline void Blitter_32bppAnim::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 {
*dst = this->LookupColourInPalette(remap[GetNearestColourIndex(*dst)]);
*anim = 0;
anim++;
dst++;
} while (--n != 0);
} else {
dst += n;
anim += n;
src_px += n;
}
break;
default:
if (fast_path || (src_px->a == 255 && (sprite_flags & BSF_NO_ANIM))) {
do {
@@ -343,6 +358,7 @@ void Blitter_32bppAnim::Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomL
return;
case BM_TRANSPARENT: Draw<BM_TRANSPARENT, false> (bp, zoom); return;
case BM_TRANSPARENT_REMAP: Draw<BM_TRANSPARENT_REMAP, false> (bp, zoom); return;
case BM_CRASH_REMAP: Draw<BM_CRASH_REMAP, false> (bp, zoom); return;
case BM_BLACK_REMAP: Draw<BM_BLACK_REMAP, false> (bp, zoom); return;
}

View File

@@ -12,6 +12,7 @@
#include "../stdafx.h"
#include "../video/video_driver.hpp"
#include "../table/sprites.h"
#include "../palette_func.h"
#include "32bpp_anim_sse4.hpp"
#include "32bpp_sse_func.hpp"
@@ -317,6 +318,21 @@ bmcr_alpha_blend_single:
}
break;
case BM_TRANSPARENT_REMAP:
/* Apply custom transparency remap. */
for (uint x = (uint) bp->width; x > 0; x--) {
if (src->a != 0) {
*dst = this->LookupColourInPalette(remap[GetNearestColourIndex(*dst)]);
*anim = 0;
}
src_mv++;
dst++;
src++;
anim++;
}
break;
case BM_CRASH_REMAP:
for (uint x = (uint) bp->width; x > 0; x--) {
if (src_mv->m == 0) {
@@ -420,7 +436,7 @@ bmcr_alpha_blend_single_brightness:
}
next_line:
if (mode != BM_TRANSPARENT) src_mv_line += si->sprite_width;
if (mode != BM_TRANSPARENT && mode != BM_TRANSPARENT_REMAP) src_mv_line += si->sprite_width;
src_rgba_line = (const Colour*) ((const byte*) src_rgba_line + si->sprite_line_size);
dst_line += bp->pitch;
anim_line += this->anim_buf_pitch;
@@ -483,6 +499,7 @@ bm_normal:
}
break;
case BM_TRANSPARENT: Draw<BM_TRANSPARENT, RM_NONE, BT_NONE, true, true>(bp, zoom); return;
case BM_TRANSPARENT_REMAP: Draw<BM_TRANSPARENT_REMAP, 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;

View File

@@ -10,6 +10,7 @@
#include "../stdafx.h"
#include "../zoom_func.h"
#include "../settings_type.h"
#include "../palette_func.h"
#include "32bpp_optimized.hpp"
#include "common.hpp"
@@ -189,10 +190,6 @@ inline void Blitter_32bppOptimized::Draw(const Blitter::BlitterParams *bp, ZoomL
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) {
@@ -210,6 +207,21 @@ inline void Blitter_32bppOptimized::Draw(const Blitter::BlitterParams *bp, ZoomL
}
break;
case BM_TRANSPARENT_REMAP:
/* Apply custom transparency remap. */
src_n += n;
if (src_px->a != 0) {
src_px += n;
do {
*dst = this->LookupColourInPalette(remap[GetNearestColourIndex(*dst)]);
dst++;
} while (--n != 0);
} else {
dst += n;
src_px += n;
}
break;
default:
if (src_px->a == 255) {
/* faster than memcpy(), n is usually low */
@@ -260,6 +272,7 @@ void Blitter_32bppOptimized::Draw(Blitter::BlitterParams *bp, BlitterMode mode,
case BM_NORMAL: Draw<BM_NORMAL, Tpal_to_rgb>(bp, zoom); return;
case BM_COLOUR_REMAP: Draw<BM_COLOUR_REMAP, Tpal_to_rgb>(bp, zoom); return;
case BM_TRANSPARENT: Draw<BM_TRANSPARENT, Tpal_to_rgb>(bp, zoom); return;
case BM_TRANSPARENT_REMAP: Draw<BM_TRANSPARENT_REMAP, Tpal_to_rgb>(bp, zoom); return;
case BM_CRASH_REMAP: Draw<BM_CRASH_REMAP, Tpal_to_rgb>(bp, zoom); return;
case BM_BLACK_REMAP: Draw<BM_BLACK_REMAP, Tpal_to_rgb>(bp, zoom); return;
case BM_NORMAL_WITH_BRIGHTNESS: Draw<BM_NORMAL_WITH_BRIGHTNESS, Tpal_to_rgb>(bp, zoom); return;

View File

@@ -9,6 +9,7 @@
#include "../stdafx.h"
#include "../zoom_func.h"
#include "../palette_func.h"
#include "32bpp_simple.hpp"
#include "../table/sprites.h"
@@ -75,12 +76,17 @@ void Blitter_32bppSimple::Draw(Blitter::BlitterParams *bp, BlitterMode mode, Zoo
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 */
if (src->a != 0) *dst = MakeTransparent(*dst, 192);
if (src->a != 0) {
*dst = MakeTransparent(*dst, 192);
}
break;
case BM_TRANSPARENT_REMAP:
/* Apply custom transparency remap. */
if (src->a != 0) {
*dst = this->LookupColourInPalette(bp->remap[GetNearestColourIndex(*dst)]);
}
break;
case BM_NORMAL_WITH_BRIGHTNESS:

View File

@@ -398,6 +398,18 @@ bmcr_alpha_blend_single:
}
break;
case BM_TRANSPARENT_REMAP:
/* Apply custom transparency remap. */
for (uint x = (uint) bp->width; x > 0; x--) {
if (src->a != 0) {
*dst = this->LookupColourInPalette(remap[GetNearestColourIndex(*dst)]);
}
src_mv++;
dst++;
src++;
}
break;
case BM_CRASH_REMAP:
for (uint x = (uint) bp->width; x > 0; x--) {
if (src_mv->m == 0) {
@@ -532,6 +544,7 @@ bm_normal:
Draw<BM_COLOUR_REMAP, RM_WITH_MARGIN, BT_NONE, true>(bp, zoom); return;
}
case BM_TRANSPARENT: Draw<BM_TRANSPARENT, RM_NONE, BT_NONE, true>(bp, zoom); return;
case BM_TRANSPARENT_REMAP: Draw<BM_TRANSPARENT_REMAP, 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;

View File

@@ -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"
@@ -288,10 +289,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) {
@@ -317,6 +314,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 = remap[*anim];
} else {
*dst = this->LookupColourInPalette(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 {
@@ -389,6 +408,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;
case BM_NORMAL_WITH_BRIGHTNESS: Draw<BM_NORMAL_WITH_BRIGHTNESS> (bp, zoom); return;

View File

@@ -101,8 +101,9 @@ void Blitter_8bppOptimized::Draw(Blitter::BlitterParams *bp, BlitterMode mode, Z
dst += pixels;
break;
case BM_TRANSPARENT: {
const uint8 *remap = bp->remap;
case BM_TRANSPARENT:
case BM_TRANSPARENT_REMAP: {
const uint8_t *remap = bp->remap;
src += pixels;
do {
*dst = remap[*dst];

View File

@@ -43,6 +43,7 @@ void Blitter_8bppSimple::Draw(Blitter::BlitterParams *bp, BlitterMode mode, Zoom
break;
case BM_TRANSPARENT:
case BM_TRANSPARENT_REMAP:
if (*src != 0) colour = bp->remap[*dst];
break;

View File

@@ -20,7 +20,8 @@
enum BlitterMode {
BM_NORMAL, ///< Perform the simple blitting.
BM_COLOUR_REMAP, ///< Perform a colour remapping.
BM_TRANSPARENT, ///< Perform transparency colour remapping.
BM_TRANSPARENT, ///< Perform transparency darkening remapping.
BM_TRANSPARENT_REMAP, ///< Perform transparency colour remapping.
BM_CRASH_REMAP, ///< Perform a crash remapping.
BM_BLACK_REMAP, ///< Perform remapping to a completely blackened sprite
BM_NORMAL_WITH_BRIGHTNESS, ///< Perform a simple blitting with brightness adjustment