aboutsummaryrefslogtreecommitdiff
path: root/src/FbTk/ImageControl.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/FbTk/ImageControl.cc')
-rw-r--r--src/FbTk/ImageControl.cc12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/FbTk/ImageControl.cc b/src/FbTk/ImageControl.cc
index 9eaec31..a745cf8 100644
--- a/src/FbTk/ImageControl.cc
+++ b/src/FbTk/ImageControl.cc
@@ -177,7 +177,7 @@ struct ImageControl::Cache {
177ImageControl::ImageControl(int screen_num, 177ImageControl::ImageControl(int screen_num,
178 int cpc, unsigned int cache_timeout, unsigned long cmax): 178 int cpc, unsigned int cache_timeout, unsigned long cmax):
179 m_colors_per_channel(cpc), 179 m_colors_per_channel(cpc),
180 m_screen_num(screen_num) { 180 m_screen_num(screen_num), m_cache_max(cmax) {
181 181
182 Display *disp = FbTk::App::instance()->display(); 182 Display *disp = FbTk::App::instance()->display();
183 183
@@ -185,8 +185,6 @@ ImageControl::ImageControl(int screen_num,
185 m_visual = DefaultVisual(disp, screen_num); 185 m_visual = DefaultVisual(disp, screen_num);
186 m_colormap = DefaultColormap(disp, screen_num); 186 m_colormap = DefaultColormap(disp, screen_num);
187 187
188 cache_max = cmax;
189
190 RefCount<Command<void> > clean_cache(new SimpleCommand<ImageControl>(*this, &ImageControl::cleanCache)); 188 RefCount<Command<void> > clean_cache(new SimpleCommand<ImageControl>(*this, &ImageControl::cleanCache));
191 m_timer.setCommand(clean_cache); 189 m_timer.setCommand(clean_cache);
192 setCacheTimeout(cache_timeout); 190 setCacheTimeout(cache_timeout);
@@ -226,6 +224,12 @@ void ImageControl::setCacheTimeout(unsigned int cache_timeout) {
226 m_timer.stop(); 224 m_timer.stop();
227} 225}
228 226
227void ImageControl::setCacheMax(unsigned long cache_max) {
228 m_cache_max = cache_max;
229 if (cache.size() > m_cache_max)
230 cleanCache();
231}
232
229Pixmap ImageControl::searchCache(unsigned int width, unsigned int height, 233Pixmap ImageControl::searchCache(unsigned int width, unsigned int height,
230 const Texture &text, FbTk::Orientation orient) const { 234 const Texture &text, FbTk::Orientation orient) const {
231 235
@@ -326,7 +330,7 @@ Pixmap ImageControl::renderImage(unsigned int width, unsigned int height,
326 330
327 cache.push_back(tmp); 331 cache.push_back(tmp);
328 332
329 if (cache.size() > cache_max) 333 if (cache.size() > m_cache_max)
330 cleanCache(); 334 cleanCache();
331 335
332 return pixmap; 336 return pixmap;