using new timer command
fluxgen fluxgen
2 files changed,
13 insertions(+),
10 deletions(-)
M
src/FbTk/ImageControl.cc
→
src/FbTk/ImageControl.cc
@@ -22,12 +22,13 @@ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// 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 @@
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 @@ cache_max = cmax;
#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 @@ if ((unsigned) cache.size() > cache_max) {
#ifdef DEBUG cerr<<"FbTk::ImageControl::renderImage(): cache is large, forcing cleanout"<<endl; #endif // DEBUG - timeout(); + cleanCache(); } return pixmap;@@ -234,9 +236,10 @@ if ((*it)->count) {
(*it)->count--; #ifdef TIMEDCACHE - timeout(); + cleanCache(); #else // !TIMEDCACHE - if (! (*it)->count) timeout(); + if (! (*it)->count) + cleanCache() #endif // TIMEDCACHE }@@ -349,7 +352,7 @@
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();
M
src/FbTk/ImageControl.hh
→
src/FbTk/ImageControl.hh
@@ -22,7 +22,7 @@ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// 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 @@ #include <list>
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 @@ unsigned int **, unsigned int **);
void setDither(bool d) { m_dither = d; } void setColorsPerChannel(int cpc); - virtual void timeout(); + void cleanCache(); private: /**