summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2014-01-03 08:51:49 +0000
committerrubidium <rubidium@openttd.org>2014-01-03 08:51:49 +0000
commitf480c5a62368288fd3899dd7c9258bff762803d2 (patch)
tree24e36e0829f0194df170b099016eb747f10b14f3 /src
parent1d4565a666f73cd9c7c88d29d9d651e1d1618910 (diff)
downloadopenttd-f480c5a62368288fd3899dd7c9258bff762803d2.tar.xz
(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)
Diffstat (limited to 'src')
-rw-r--r--src/gfx_func.h1
-rw-r--r--src/gfxinit.cpp36
-rw-r--r--src/toolbar_gui.cpp2
3 files changed, 31 insertions, 8 deletions
diff --git a/src/gfx_func.h b/src/gfx_func.h
index 69d2e4570..38c9ea5e3 100644
--- a/src/gfx_func.h
+++ b/src/gfx_func.h
@@ -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);
diff --git a/src/gfxinit.cpp b/src/gfxinit.cpp
index 4a830d7a8..109db2e08 100644
--- a/src/gfxinit.cpp
+++ b/src/gfxinit.cpp
@@ -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. */
diff --git a/src/toolbar_gui.cpp b/src/toolbar_gui.cpp
index f4cb584b1..c14045600 100644
--- a/src/toolbar_gui.cpp
+++ b/src/toolbar_gui.cpp
@@ -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;