FIFE
be64c707dea6b3250bd4355bf5c825d25920087d
|
Generic pool for rendered text Caches a number of Images with text, as rendered by a Font. More...
#include <textrenderpool.h>
Classes | |
struct | s_pool_entry |
Public Member Functions | |
TextRenderPool (size_t poolSize=200) | |
Constructor Constructs a pool with a maximum of poolSize entries. More... | |
~TextRenderPool () | |
Destructor. More... | |
void | invalidateCachedText () |
Invalidates all cached text images. More... | |
Image * | getRenderedText (FontBase *fontbase, const std::string &text) |
Get a string image. More... | |
void | addRenderedText (FontBase *fontbase, const std::string &text, Image *image) |
Add a string image. More... | |
void | removeOldEntries () |
Remove entries not used since a minute Is a timer callback. More... | |
Protected Types | |
typedef std::list< s_pool_entry > | type_pool |
Protected Attributes | |
type_pool | m_pool |
size_t | m_poolSize |
size_t | m_poolMaxSize |
Timer | m_collectTimer |
Generic pool for rendered text Caches a number of Images with text, as rendered by a Font.
Makes sure no more than a maximum number of strings is pooled at a time. Automatically removes pooled strings not used for a minute. Doesn't use resources (apart from a minimum) if not used after a while.
Definition at line 53 of file textrenderpool.h.
|
protected |
Definition at line 93 of file textrenderpool.h.
FIFE::TextRenderPool::TextRenderPool | ( | size_t | poolSize = 200 | ) |
Constructor Constructs a pool with a maximum of poolSize entries.
Definition at line 41 of file textrenderpool.cpp.
References m_collectTimer, m_poolMaxSize, m_poolSize, removeOldEntries(), FIFE::Timer::setCallback(), and FIFE::Timer::setInterval().
FIFE::TextRenderPool::~TextRenderPool | ( | ) |
void FIFE::TextRenderPool::addRenderedText | ( | FontBase * | fontbase, |
const std::string & | text, | ||
Image * | image | ||
) |
Add a string image.
Definition at line 86 of file textrenderpool.cpp.
References FIFE::TextRenderPool::s_pool_entry::antialias, FIFE::TextRenderPool::s_pool_entry::color, FIFE::FontBase::getColor(), FIFE::FontBase::getGlyphSpacing(), FIFE::FontBase::getRowSpacing(), FIFE::TimeManager::getTime(), FIFE::TextRenderPool::s_pool_entry::glyph_spacing, FIFE::TextRenderPool::s_pool_entry::image, FIFE::DynamicSingleton< TimeManager >::instance(), FIFE::FontBase::isAntiAlias(), m_collectTimer, m_pool, m_poolMaxSize, m_poolSize, FIFE::TextRenderPool::s_pool_entry::row_spacing, FIFE::Timer::start(), FIFE::TextRenderPool::s_pool_entry::text, and FIFE::TextRenderPool::s_pool_entry::timestamp.
Referenced by FIFE::FontBase::getAsImage(), and FIFE::FontBase::getAsImageMultiline().
Get a string image.
Definition at line 56 of file textrenderpool.cpp.
References FIFE::FontBase::getColor(), FIFE::FontBase::getGlyphSpacing(), FIFE::FontBase::getRowSpacing(), FIFE::TimeManager::getTime(), FIFE::DynamicSingleton< TimeManager >::instance(), FIFE::FontBase::isAntiAlias(), and m_pool.
Referenced by FIFE::FontBase::getAsImage(), and FIFE::FontBase::getAsImageMultiline().
void FIFE::TextRenderPool::invalidateCachedText | ( | ) |
Invalidates all cached text images.
Definition at line 133 of file textrenderpool.cpp.
References m_pool.
Referenced by FIFE::FontBase::invalidate().
void FIFE::TextRenderPool::removeOldEntries | ( | ) |
Remove entries not used since a minute Is a timer callback.
Definition at line 113 of file textrenderpool.cpp.
References FIFE::TimeManager::getTime(), FIFE::DynamicSingleton< TimeManager >::instance(), m_collectTimer, m_pool, m_poolSize, and FIFE::Timer::stop().
Referenced by TextRenderPool().
|
protected |
Definition at line 98 of file textrenderpool.h.
Referenced by addRenderedText(), removeOldEntries(), and TextRenderPool().
|
protected |
Definition at line 94 of file textrenderpool.h.
Referenced by addRenderedText(), getRenderedText(), invalidateCachedText(), removeOldEntries(), and ~TextRenderPool().
|
protected |
Definition at line 96 of file textrenderpool.h.
Referenced by addRenderedText(), and TextRenderPool().
|
protected |
Definition at line 95 of file textrenderpool.h.
Referenced by addRenderedText(), removeOldEntries(), and TextRenderPool().