using new timer command
This commit is contained in:
parent
af93496614
commit
2e4b09e37c
2 changed files with 13 additions and 10 deletions
|
@ -22,12 +22,13 @@
|
|||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
|
||||
// $Id: ImageControl.cc,v 1.2 2003/07/12 21:50:15 fluxgen Exp $
|
||||
// $Id: ImageControl.cc,v 1.3 2003/08/11 15:59:49 fluxgen Exp $
|
||||
|
||||
#include "ImageControl.hh"
|
||||
|
||||
#include "TextureRender.hh"
|
||||
#include "App.hh"
|
||||
#include "SimpleCommand.hh"
|
||||
|
||||
//use GNU extensions
|
||||
#ifndef _GNU_SOURCE
|
||||
|
@ -82,7 +83,6 @@ unsigned long bsqrt(unsigned long x) {
|
|||
ImageControl::ImageControl(int screen_num, bool dither,
|
||||
int cpc, unsigned long cache_timeout, unsigned long cmax):
|
||||
m_dither(dither),
|
||||
m_timer(this),
|
||||
m_colors(0),
|
||||
m_num_colors(0),
|
||||
m_colors_per_channel(cpc) {
|
||||
|
@ -99,6 +99,8 @@ ImageControl::ImageControl(int screen_num, bool dither,
|
|||
#ifdef TIMEDCACHE
|
||||
if (cache_timeout) {
|
||||
m_timer.setTimeout(cache_timeout);
|
||||
RefCount<Command> clean_cache(new SimpleCommand<ImageControl>(*this, &ImageControl::cleanCache));
|
||||
m_timer.setCommand(clean_cache);
|
||||
m_timer.start();
|
||||
}
|
||||
#endif // TIMEDCACHE
|
||||
|
@ -212,7 +214,7 @@ Pixmap ImageControl::renderImage(unsigned int width, unsigned int height,
|
|||
#ifdef DEBUG
|
||||
cerr<<"FbTk::ImageControl::renderImage(): cache is large, forcing cleanout"<<endl;
|
||||
#endif // DEBUG
|
||||
timeout();
|
||||
cleanCache();
|
||||
}
|
||||
|
||||
return pixmap;
|
||||
|
@ -234,9 +236,10 @@ void ImageControl::removeImage(Pixmap pixmap) {
|
|||
(*it)->count--;
|
||||
|
||||
#ifdef TIMEDCACHE
|
||||
timeout();
|
||||
cleanCache();
|
||||
#else // !TIMEDCACHE
|
||||
if (! (*it)->count) timeout();
|
||||
if (! (*it)->count)
|
||||
cleanCache()
|
||||
#endif // TIMEDCACHE
|
||||
}
|
||||
|
||||
|
@ -349,7 +352,7 @@ unsigned long ImageControl::getSqrt(unsigned int x) const {
|
|||
return (*(sqrt_table + x));
|
||||
}
|
||||
|
||||
void ImageControl::timeout() {
|
||||
void ImageControl::cleanCache() {
|
||||
Display *disp = FbTk::App::instance()->display();
|
||||
CacheList::iterator it = cache.begin();
|
||||
CacheList::iterator it_end = cache.end();
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
|
||||
// $Id: ImageControl.hh,v 1.2 2003/05/16 00:19:51 fluxgen Exp $
|
||||
// $Id: ImageControl.hh,v 1.3 2003/08/11 15:59:49 fluxgen Exp $
|
||||
|
||||
#ifndef FBTK_IMAGECONTROL_HH
|
||||
#define FBTK_IMAGECONTROL_HH
|
||||
|
@ -37,8 +37,8 @@
|
|||
|
||||
namespace FbTk {
|
||||
|
||||
/// Holds screen info, color tables and caches textures
|
||||
class ImageControl : public TimeoutHandler, private NotCopyable {
|
||||
/// Holds screen info, color tables and caches textures
|
||||
class ImageControl: private NotCopyable {
|
||||
public:
|
||||
ImageControl(int screen_num, bool dither = false, int colors_per_channel = 4,
|
||||
unsigned long cache_timeout = 300000l, unsigned long cache_max = 200l);
|
||||
|
@ -72,7 +72,7 @@ public:
|
|||
void setDither(bool d) { m_dither = d; }
|
||||
void setColorsPerChannel(int cpc);
|
||||
|
||||
virtual void timeout();
|
||||
void cleanCache();
|
||||
|
||||
private:
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue