summaryrefslogtreecommitdiff
path: root/src/blitter/factory.hpp
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2014-01-02 22:48:32 +0000
committerrubidium <rubidium@openttd.org>2014-01-02 22:48:32 +0000
commit899c0f9cd230bc36fc006e54bf88f598ab725257 (patch)
tree2846c84441c0e1f273efeca3a614edd9d0620218 /src/blitter/factory.hpp
parent2618d960e30882c097ba8b68249bbae974700ac8 (diff)
downloadopenttd-899c0f9cd230bc36fc006e54bf88f598ab725257.tar.xz
(svn r26210) -Codechange: add infrastructure for not registering a blitter
Diffstat (limited to 'src/blitter/factory.hpp')
-rw-r--r--src/blitter/factory.hpp16
1 files changed, 13 insertions, 3 deletions
diff --git a/src/blitter/factory.hpp b/src/blitter/factory.hpp
index 7fe498a67..83edd99aa 100644
--- a/src/blitter/factory.hpp
+++ b/src/blitter/factory.hpp
@@ -57,15 +57,25 @@ protected:
* Construct the blitter, and register it.
* @param name The name of the blitter.
* @param description A longer description for the blitter.
+ * @param usable Whether the blitter is usable (on the current computer). For example for disabling SSE blitters when the CPU can't handle them.
* @pre name != NULL.
* @pre description != NULL.
* @pre There is no blitter registered with this name.
*/
- BlitterFactory(const char *name, const char *description) :
+ BlitterFactory(const char *name, const char *description, bool usable = true) :
name(strdup(name)), description(strdup(description))
{
- std::pair<Blitters::iterator, bool> P = GetBlitters().insert(Blitters::value_type(this->name, this));
- assert(P.second);
+ if (usable) {
+ /*
+ * Only add when the blitter is usable. Do not bail out or
+ * do more special things since the blitters are always
+ * instantiated upon start anyhow and freed upon shutdown.
+ */
+ std::pair<Blitters::iterator, bool> P = GetBlitters().insert(Blitters::value_type(this->name, this));
+ assert(P.second);
+ } else {
+ DEBUG(driver, 1, "Not registering blitter %s as it is not usable", name);
+ }
}
public: