From 2e4b09e37c320ec83857d60d3ee64eb90ca2f53e Mon Sep 17 00:00:00 2001 From: fluxgen Date: Mon, 11 Aug 2003 15:59:49 +0000 Subject: using new timer command --- src/FbTk/ImageControl.cc | 15 +++++++++------ src/FbTk/ImageControl.hh | 8 ++++---- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/src/FbTk/ImageControl.cc b/src/FbTk/ImageControl.cc index f372d8e..4c08799 100644 --- a/src/FbTk/ImageControl.cc +++ b/src/FbTk/ImageControl.cc @@ -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 clean_cache(new SimpleCommand(*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"<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(); diff --git a/src/FbTk/ImageControl.hh b/src/FbTk/ImageControl.hh index 850e814..9fe0a0a 100644 --- a/src/FbTk/ImageControl.hh +++ b/src/FbTk/ImageControl.hh @@ -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: /** -- cgit v0.11.2