(svn r26217) -Change: blitter autoselection based on full animation state, so the non-animated optimizations can actually be used in an easy manner (based on patch by MJP)

pull/155/head
rubidium 11 years ago
parent 6f4078a379
commit 59ab35bd4c

@ -137,6 +137,7 @@ void SetDirtyBlocks(int left, int top, int right, int bottom);
void MarkWholeScreenDirty();
void GfxInitPalettes();
void CheckBlitter();
bool FillDrawPixelInfo(DrawPixelInfo *n, int left, int top, int width, int height);

@ -15,6 +15,7 @@
#include "3rdparty/md5/md5.h"
#include "fontcache.h"
#include "gfx_func.h"
#include "transparency.h"
#include "blitter/factory.hpp"
#include "video/video_driver.hpp"
@ -225,14 +226,15 @@ static void LoadSpriteTables()
/**
* Check blitter needed by NewGRF config and switch if needed.
* @return False when nothing changed, true otherwise.
*/
static void SwitchNewGRFBlitter()
static bool SwitchNewGRFBlitter()
{
/* Never switch if the blitter was specified by the user. */
if (!_blitter_autodetected) return;
if (!_blitter_autodetected) return false;
/* Null driver => dedicated server => do nothing. */
if (BlitterFactory::GetCurrentBlitter()->GetScreenDepth() == 0) return;
if (BlitterFactory::GetCurrentBlitter()->GetScreenDepth() == 0) return false;
/* Get preferred depth. */
uint depth_wanted_by_base = BaseGraphics::GetUsedSet()->blitter == BLT_32BPP ? 32 : 8;
@ -245,23 +247,32 @@ static void SwitchNewGRFBlitter()
/* Search the best blitter. */
struct {
const char *name;
uint animation; ///< 0: no support, 1: do support, 2: both
uint min_base_depth, max_base_depth, min_grf_depth, max_grf_depth;
} replacement_blitters[] = {
#ifdef WITH_SSE
{ "32bpp-sse4-anim", 32, 32, 8, 32 },
{ "32bpp-sse4", 0, 32, 32, 8, 32 },
{ "32bpp-ssse3", 0, 32, 32, 8, 32 },
{ "32bpp-sse2", 0, 32, 32, 8, 32 },
{ "32bpp-sse4-anim", 1, 32, 32, 8, 32 },
#endif
{ "8bpp-optimized", 8, 8, 8, 8 },
{ "32bpp-anim", 8, 32, 8, 32 },
{ "8bpp-optimized", 2, 8, 8, 8, 8 },
{ "32bpp-optimized", 0, 8, 32, 8, 32 },
{ "32bpp-anim", 1, 8, 32, 8, 32 },
};
const bool animation_wanted = HasBit(_display_opt, DO_FULL_ANIMATION);
const char *cur_blitter = BlitterFactory::GetCurrentBlitter()->GetName();
for (uint i = 0; i < lengthof(replacement_blitters); i++) {
if (animation_wanted && (replacement_blitters[i].animation == 0)) continue;
if (!animation_wanted && (replacement_blitters[i].animation == 1)) continue;
if (!IsInsideMM(depth_wanted_by_base, replacement_blitters[i].min_base_depth, replacement_blitters[i].max_base_depth + 1)) continue;
if (!IsInsideMM(depth_wanted_by_grf, replacement_blitters[i].min_grf_depth, replacement_blitters[i].max_grf_depth + 1)) continue;
const char *repl_blitter = replacement_blitters[i].name;
if (strcmp(repl_blitter, cur_blitter) == 0) return;
if (strcmp(repl_blitter, cur_blitter) == 0) return false;
if (BlitterFactory::GetBlitterFactory(repl_blitter) == NULL) continue;
DEBUG(misc, 1, "Switching blitter from '%s' to '%s'... ", cur_blitter, repl_blitter);
@ -275,6 +286,17 @@ static void SwitchNewGRFBlitter()
/* Failed to switch blitter, let's hope we can return to the old one. */
if (BlitterFactory::SelectBlitter(cur_blitter) == NULL || !_video_driver->AfterBlitterChange()) usererror("Failed to reinitialize video driver. Specify a fixed blitter in the config");
}
return true;
}
/** Check whether we still use the right blitter, or use another (better) one. */
void CheckBlitter()
{
if (!SwitchNewGRFBlitter()) return;
ClearFontCache();
GfxClearSpriteCache();
}
/** Initialise and load all the sprites. */

@ -351,7 +351,7 @@ static CallBackFunction MenuClickSettings(int index)
ToggleBit(_display_opt, DO_SHOW_COMPETITOR_SIGNS);
InvalidateWindowClassesData(WC_SIGN_LIST, -1);
break;
case OME_FULL_ANIMATION: ToggleBit(_display_opt, DO_FULL_ANIMATION); break;
case OME_FULL_ANIMATION: ToggleBit(_display_opt, DO_FULL_ANIMATION); CheckBlitter(); break;
case OME_FULL_DETAILS: ToggleBit(_display_opt, DO_FULL_DETAIL); break;
case OME_TRANSPARENTBUILDINGS: ToggleTransparency(TO_HOUSES); break;
case OME_SHOW_STATIONSIGNS: ToggleTransparency(TO_SIGNS); break;

Loading…
Cancel
Save