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
|
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||||
// DEALINGS IN THE SOFTWARE.
|
// 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 "ImageControl.hh"
|
||||||
|
|
||||||
#include "TextureRender.hh"
|
#include "TextureRender.hh"
|
||||||
#include "App.hh"
|
#include "App.hh"
|
||||||
|
#include "SimpleCommand.hh"
|
||||||
|
|
||||||
//use GNU extensions
|
//use GNU extensions
|
||||||
#ifndef _GNU_SOURCE
|
#ifndef _GNU_SOURCE
|
||||||
|
@ -82,7 +83,6 @@ unsigned long bsqrt(unsigned long x) {
|
||||||
ImageControl::ImageControl(int screen_num, bool dither,
|
ImageControl::ImageControl(int screen_num, bool dither,
|
||||||
int cpc, unsigned long cache_timeout, unsigned long cmax):
|
int cpc, unsigned long cache_timeout, unsigned long cmax):
|
||||||
m_dither(dither),
|
m_dither(dither),
|
||||||
m_timer(this),
|
|
||||||
m_colors(0),
|
m_colors(0),
|
||||||
m_num_colors(0),
|
m_num_colors(0),
|
||||||
m_colors_per_channel(cpc) {
|
m_colors_per_channel(cpc) {
|
||||||
|
@ -99,6 +99,8 @@ ImageControl::ImageControl(int screen_num, bool dither,
|
||||||
#ifdef TIMEDCACHE
|
#ifdef TIMEDCACHE
|
||||||
if (cache_timeout) {
|
if (cache_timeout) {
|
||||||
m_timer.setTimeout(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();
|
m_timer.start();
|
||||||
}
|
}
|
||||||
#endif // TIMEDCACHE
|
#endif // TIMEDCACHE
|
||||||
|
@ -212,7 +214,7 @@ Pixmap ImageControl::renderImage(unsigned int width, unsigned int height,
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
cerr<<"FbTk::ImageControl::renderImage(): cache is large, forcing cleanout"<<endl;
|
cerr<<"FbTk::ImageControl::renderImage(): cache is large, forcing cleanout"<<endl;
|
||||||
#endif // DEBUG
|
#endif // DEBUG
|
||||||
timeout();
|
cleanCache();
|
||||||
}
|
}
|
||||||
|
|
||||||
return pixmap;
|
return pixmap;
|
||||||
|
@ -234,9 +236,10 @@ void ImageControl::removeImage(Pixmap pixmap) {
|
||||||
(*it)->count--;
|
(*it)->count--;
|
||||||
|
|
||||||
#ifdef TIMEDCACHE
|
#ifdef TIMEDCACHE
|
||||||
timeout();
|
cleanCache();
|
||||||
#else // !TIMEDCACHE
|
#else // !TIMEDCACHE
|
||||||
if (! (*it)->count) timeout();
|
if (! (*it)->count)
|
||||||
|
cleanCache()
|
||||||
#endif // TIMEDCACHE
|
#endif // TIMEDCACHE
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -349,7 +352,7 @@ unsigned long ImageControl::getSqrt(unsigned int x) const {
|
||||||
return (*(sqrt_table + x));
|
return (*(sqrt_table + x));
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImageControl::timeout() {
|
void ImageControl::cleanCache() {
|
||||||
Display *disp = FbTk::App::instance()->display();
|
Display *disp = FbTk::App::instance()->display();
|
||||||
CacheList::iterator it = cache.begin();
|
CacheList::iterator it = cache.begin();
|
||||||
CacheList::iterator it_end = cache.end();
|
CacheList::iterator it_end = cache.end();
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||||
// DEALINGS IN THE SOFTWARE.
|
// 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
|
#ifndef FBTK_IMAGECONTROL_HH
|
||||||
#define FBTK_IMAGECONTROL_HH
|
#define FBTK_IMAGECONTROL_HH
|
||||||
|
@ -37,8 +37,8 @@
|
||||||
|
|
||||||
namespace FbTk {
|
namespace FbTk {
|
||||||
|
|
||||||
/// Holds screen info, color tables and caches textures
|
/// Holds screen info, color tables and caches textures
|
||||||
class ImageControl : public TimeoutHandler, private NotCopyable {
|
class ImageControl: private NotCopyable {
|
||||||
public:
|
public:
|
||||||
ImageControl(int screen_num, bool dither = false, int colors_per_channel = 4,
|
ImageControl(int screen_num, bool dither = false, int colors_per_channel = 4,
|
||||||
unsigned long cache_timeout = 300000l, unsigned long cache_max = 200l);
|
unsigned long cache_timeout = 300000l, unsigned long cache_max = 200l);
|
||||||
|
@ -72,7 +72,7 @@ public:
|
||||||
void setDither(bool d) { m_dither = d; }
|
void setDither(bool d) { m_dither = d; }
|
||||||
void setColorsPerChannel(int cpc);
|
void setColorsPerChannel(int cpc);
|
||||||
|
|
||||||
virtual void timeout();
|
void cleanCache();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue