10 #ifndef BLITTER_FACTORY_HPP 11 #define BLITTER_FACTORY_HPP 15 #include "../string_func.h" 16 #include "../core/string_compare_type.hpp" 19 #if defined(WITH_COCOA) 20 bool QZ_CanDisplay8bpp();
31 typedef std::map<const char *, BlitterFactory *, StringCompare>
Blitters;
39 static Blitters &s_blitters = *
new Blitters();
49 static Blitter *s_blitter =
nullptr;
63 BlitterFactory(
const char *name,
const char *description,
bool usable =
true) :
72 std::pair<Blitters::iterator, bool> P =
GetBlitters().insert(Blitters::value_type(this->name,
this));
75 DEBUG(driver, 1,
"Not registering blitter %s as it is not usable", name);
86 free(this->description);
97 if (b ==
nullptr)
return nullptr;
103 DEBUG(driver, 1,
"Successfully %s blitter '%s'",
StrEmpty(name) ?
"probed" :
"loaded", newb->
GetName());
114 #if defined(DEDICATED) 115 const char *default_blitter =
"null";
117 const char *default_blitter =
"8bpp-optimized";
119 #if defined(WITH_COCOA) 122 if (!QZ_CanDisplay8bpp()) {
125 default_blitter =
"32bpp-anim";
130 const char *bname = (
StrEmpty(name)) ? default_blitter : name;
135 if (strcasecmp(bname, b->
name) == 0) {
158 p +=
seprintf(p, last,
"List of blitters:\n");
bool _blitter_autodetected
Was the blitter autodetected or specified by the user?
int CDECL seprintf(char *str, const char *last, const char *format,...)
Safer implementation of snprintf; same as snprintf except:
const char * GetName() const
Get the long, human readable, name for the Blitter-class.
virtual Blitter * CreateInstance()=0
Create an instance of this Blitter-class.
How all blitters should look like.
const char * GetDescription() const
Get a nice description of the blitter-class.
virtual const char * GetName()=0
Get the name of the blitter, the same as the Factory-instance returns.
static char * GetBlittersInfo(char *p, const char *last)
Fill a buffer with information about the blitters.
char * _ini_blitter
The blitter as stored in the configuration file.
BlitterFactory(const char *name, const char *description, bool usable=true)
Construct the blitter, and register it.
static Blitter * SelectBlitter(const char *name)
Find the requested blitter and return his class.
char * stredup(const char *s, const char *last)
Create a duplicate of the given string.
std::map< const char *, BlitterFactory *, StringCompare > Blitters
Map of blitter factories.
static Blitter * GetCurrentBlitter()
Get the current active blitter (always set by calling SelectBlitter).
const char * description
The description of the blitter.
#define DEBUG(name, level,...)
Output a line of debugging information.
static bool StrEmpty(const char *s)
Check if a string buffer is empty.
static Blitter ** GetActiveBlitter()
Get the currently active blitter.
static void free(const void *ptr)
Version of the standard free that accepts const pointers.
static BlitterFactory * GetBlitterFactory(const char *name)
Get the blitter factory with the given name.
The base factory, keeping track of all blitters.
const char * name
The name of the blitter factory.
static Blitters & GetBlitters()
Get the map with currently known blitters.