12 #ifndef BLITTER_FACTORY_HPP 13 #define BLITTER_FACTORY_HPP 17 #include "../string_func.h" 18 #include "../core/string_compare_type.hpp" 21 #if defined(WITH_COCOA) 22 bool QZ_CanDisplay8bpp();
33 typedef std::map<const char *, BlitterFactory *, StringCompare>
Blitters;
41 static Blitters &s_blitters = *
new Blitters();
51 static Blitter *s_blitter = NULL;
65 BlitterFactory(
const char *name,
const char *description,
bool usable =
true) :
74 std::pair<Blitters::iterator, bool> P =
GetBlitters().insert(Blitters::value_type(this->name,
this));
77 DEBUG(driver, 1,
"Not registering blitter %s as it is not usable", name);
88 free(this->description);
99 if (b == NULL)
return NULL;
105 DEBUG(driver, 1,
"Successfully %s blitter '%s'",
StrEmpty(name) ?
"probed" :
"loaded", newb->
GetName());
116 #if defined(DEDICATED) 117 const char *default_blitter =
"null";
119 const char *default_blitter =
"8bpp-optimized";
121 #if defined(WITH_COCOA) 124 if (!QZ_CanDisplay8bpp()) {
127 default_blitter =
"32bpp-anim";
132 const char *bname = (
StrEmpty(name)) ? default_blitter : name;
137 if (strcasecmp(bname, b->
name) == 0) {
160 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.