|
@@ -287,21 +287,26 @@ static bool SwitchNewGRFBlitter()
|
|
|
{ "32bpp-anim", 1, 8, 32, 8, 32 },
|
|
|
};
|
|
|
|
|
|
const bool animation_wanted = HasBit(_display_opt, DO_FULL_ANIMATION);
|
|
|
const char *cur_blitter = BlitterFactory::GetCurrentBlitter()->GetName();
|
|
|
|
|
|
VideoDriver::GetInstance()->AcquireBlitterLock();
|
|
|
|
|
|
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 false;
|
|
|
if (strcmp(repl_blitter, cur_blitter) == 0) {
|
|
|
VideoDriver::GetInstance()->ReleaseBlitterLock();
|
|
|
return false;
|
|
|
}
|
|
|
if (BlitterFactory::GetBlitterFactory(repl_blitter) == NULL) continue;
|
|
|
|
|
|
DEBUG(misc, 1, "Switching blitter from '%s' to '%s'... ", cur_blitter, repl_blitter);
|
|
|
Blitter *new_blitter = BlitterFactory::SelectBlitter(repl_blitter);
|
|
|
if (new_blitter == NULL) NOT_REACHED();
|
|
|
DEBUG(misc, 1, "Successfully switched to %s.", repl_blitter);
|
|
@@ -310,12 +315,14 @@ static bool SwitchNewGRFBlitter()
|
|
|
|
|
|
if (!VideoDriver::GetInstance()->AfterBlitterChange()) {
|
|
|
/* Failed to switch blitter, let's hope we can return to the old one. */
|
|
|
if (BlitterFactory::SelectBlitter(cur_blitter) == NULL || !VideoDriver::GetInstance()->AfterBlitterChange()) usererror("Failed to reinitialize video driver. Specify a fixed blitter in the config");
|
|
|
}
|
|
|
|
|
|
VideoDriver::GetInstance()->ReleaseBlitterLock();
|
|
|
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
/** Check whether we still use the right blitter, or use another (better) one. */
|
|
|
void CheckBlitter()
|
|
|
{
|