aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfluxgen <fluxgen>2003-08-11 15:59:49 (GMT)
committerfluxgen <fluxgen>2003-08-11 15:59:49 (GMT)
commit2e4b09e37c320ec83857d60d3ee64eb90ca2f53e (patch)
tree471b509e471feb856c06e8cdf9886e6528a30b92
parentaf9349661477a4bf15c48df94f498f3955cc7c09 (diff)
downloadfluxbox-2e4b09e37c320ec83857d60d3ee64eb90ca2f53e.zip
fluxbox-2e4b09e37c320ec83857d60d3ee64eb90ca2f53e.tar.bz2
using new timer command
-rw-r--r--src/FbTk/ImageControl.cc15
-rw-r--r--src/FbTk/ImageControl.hh8
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 @@
22// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 22// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
23// DEALINGS IN THE SOFTWARE. 23// DEALINGS IN THE SOFTWARE.
24 24
25// $Id: ImageControl.cc,v 1.2 2003/07/12 21:50:15 fluxgen Exp $ 25// $Id: ImageControl.cc,v 1.3 2003/08/11 15:59:49 fluxgen Exp $
26 26
27#include "ImageControl.hh" 27#include "ImageControl.hh"
28 28
29#include "TextureRender.hh" 29#include "TextureRender.hh"
30#include "App.hh" 30#include "App.hh"
31#include "SimpleCommand.hh"
31 32
32//use GNU extensions 33//use GNU extensions
33#ifndef _GNU_SOURCE 34#ifndef _GNU_SOURCE
@@ -82,7 +83,6 @@ unsigned long bsqrt(unsigned long x) {
82ImageControl::ImageControl(int screen_num, bool dither, 83ImageControl::ImageControl(int screen_num, bool dither,
83 int cpc, unsigned long cache_timeout, unsigned long cmax): 84 int cpc, unsigned long cache_timeout, unsigned long cmax):
84 m_dither(dither), 85 m_dither(dither),
85 m_timer(this),
86 m_colors(0), 86 m_colors(0),
87 m_num_colors(0), 87 m_num_colors(0),
88 m_colors_per_channel(cpc) { 88 m_colors_per_channel(cpc) {
@@ -99,6 +99,8 @@ ImageControl::ImageControl(int screen_num, bool dither,
99#ifdef TIMEDCACHE 99#ifdef TIMEDCACHE
100 if (cache_timeout) { 100 if (cache_timeout) {
101 m_timer.setTimeout(cache_timeout); 101 m_timer.setTimeout(cache_timeout);
102 RefCount<Command> clean_cache(new SimpleCommand<ImageControl>(*this, &ImageControl::cleanCache));
103 m_timer.setCommand(clean_cache);
102 m_timer.start(); 104 m_timer.start();
103 } 105 }
104#endif // TIMEDCACHE 106#endif // TIMEDCACHE
@@ -212,7 +214,7 @@ Pixmap ImageControl::renderImage(unsigned int width, unsigned int height,
212#ifdef DEBUG 214#ifdef DEBUG
213 cerr<<"FbTk::ImageControl::renderImage(): cache is large, forcing cleanout"<<endl; 215 cerr<<"FbTk::ImageControl::renderImage(): cache is large, forcing cleanout"<<endl;
214#endif // DEBUG 216#endif // DEBUG
215 timeout(); 217 cleanCache();
216 } 218 }
217 219
218 return pixmap; 220 return pixmap;
@@ -234,9 +236,10 @@ void ImageControl::removeImage(Pixmap pixmap) {
234 (*it)->count--; 236 (*it)->count--;
235 237
236#ifdef TIMEDCACHE 238#ifdef TIMEDCACHE
237 timeout(); 239 cleanCache();
238#else // !TIMEDCACHE 240#else // !TIMEDCACHE
239 if (! (*it)->count) timeout(); 241 if (! (*it)->count)
242 cleanCache()
240#endif // TIMEDCACHE 243#endif // TIMEDCACHE
241 } 244 }
242 245
@@ -349,7 +352,7 @@ unsigned long ImageControl::getSqrt(unsigned int x) const {
349 return (*(sqrt_table + x)); 352 return (*(sqrt_table + x));
350} 353}
351 354
352void ImageControl::timeout() { 355void ImageControl::cleanCache() {
353 Display *disp = FbTk::App::instance()->display(); 356 Display *disp = FbTk::App::instance()->display();
354 CacheList::iterator it = cache.begin(); 357 CacheList::iterator it = cache.begin();
355 CacheList::iterator it_end = cache.end(); 358 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 @@
22// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 22// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
23// DEALINGS IN THE SOFTWARE. 23// DEALINGS IN THE SOFTWARE.
24 24
25// $Id: ImageControl.hh,v 1.2 2003/05/16 00:19:51 fluxgen Exp $ 25// $Id: ImageControl.hh,v 1.3 2003/08/11 15:59:49 fluxgen Exp $
26 26
27#ifndef FBTK_IMAGECONTROL_HH 27#ifndef FBTK_IMAGECONTROL_HH
28#define FBTK_IMAGECONTROL_HH 28#define FBTK_IMAGECONTROL_HH
@@ -37,8 +37,8 @@
37 37
38namespace FbTk { 38namespace FbTk {
39 39
40/// Holds screen info, color tables and caches textures 40/// Holds screen info, color tables and caches textures
41class ImageControl : public TimeoutHandler, private NotCopyable { 41class ImageControl: private NotCopyable {
42public: 42public:
43 ImageControl(int screen_num, bool dither = false, int colors_per_channel = 4, 43 ImageControl(int screen_num, bool dither = false, int colors_per_channel = 4,
44 unsigned long cache_timeout = 300000l, unsigned long cache_max = 200l); 44 unsigned long cache_timeout = 300000l, unsigned long cache_max = 200l);
@@ -72,7 +72,7 @@ public:
72 void setDither(bool d) { m_dither = d; } 72 void setDither(bool d) { m_dither = d; }
73 void setColorsPerChannel(int cpc); 73 void setColorsPerChannel(int cpc);
74 74
75 virtual void timeout(); 75 void cleanCache();
76 76
77private: 77private:
78 /** 78 /**