all repos — fluxbox @ 135579a9bfa6a23a1fd8217ae15ea4d4937fbf59

custom fork of the fluxbox windowmanager

back to std list until we get std set working again
fluxgen fluxgen
commit

135579a9bfa6a23a1fd8217ae15ea4d4937fbf59

parent

d5b04d1fa00c3e4edd951bbbf1bfddac8c33a066

2 files changed, 40 insertions(+), 23 deletions(-)

jump to
M src/FbTk/ImageControl.ccsrc/FbTk/ImageControl.cc

@@ -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.cc,v 1.10 2004/01/03 01:12:10 fluxgen Exp $ +// $Id: ImageControl.cc,v 1.11 2004/01/11 12:40:47 fluxgen Exp $ #include "ImageControl.hh"

@@ -146,6 +146,7 @@ delete (*it);

} } + }

@@ -167,19 +168,31 @@ }

return None; } - Cache tmp; + /* Cache tmp; tmp.texture_pixmap = text.pixmap().drawable(); tmp.width = width; tmp.height = height; tmp.texture = text.type(); tmp.pixel1 = text.color().pixel(); tmp.pixel2 = text.colorTo().pixel(); - CacheList::iterator it = cache.find(&tmp); - if (it == cache.end()) { - return None; - } else { - (*it)->count++; - return (*it)->pixmap; + */ + CacheList::iterator it = cache.begin(); + CacheList::iterator it_end = cache.end(); + for (; it != it_end; ++it) { + if (((*it)->width == width) && + ((*it)->height == height) && + ((*it)->texture == text.type()) && + ((*it)->pixel1 == text.color().pixel())) { + if (text.type() & FbTk::Texture::GRADIENT) { + if ((*it)->pixel2 == text.colorTo().pixel()) { + (*it)->count++; + return (*it)->pixmap; + } + } else { + (*it)->count++; + return (*it)->pixmap; + } + } } return None;

@@ -221,7 +234,7 @@ tmp->pixel2 = texture.colorTo().pixel();

else tmp->pixel2 = 0l; - cache.insert(tmp); + cache.push_back(tmp); if ((unsigned) cache.size() > cache_max) cleanCache();

@@ -243,13 +256,14 @@ for (; it != it_end; ++it) {

if ((*it)->pixmap == pixmap) { if ((*it)->count) { (*it)->count--; - - if (s_timed_cache) + if (s_timed_cache) { cleanCache(); - else if (! (*it)->count) - cleanCache(); + return; + } + } - } + if ((*it)->count <= 0) + cleanCache(); return; }

@@ -362,22 +376,25 @@ }

void ImageControl::cleanCache() { Display *disp = FbTk::App::instance()->display(); + std::list<CacheList::iterator> deadlist; CacheList::iterator it = cache.begin(); CacheList::iterator it_end = cache.end(); for (; it != it_end; ++it) { Cache *tmp = (*it); - if (tmp->count <= 0) { - CacheList::iterator tmp_it = it; - ++tmp_it; XFreePixmap(disp, tmp->pixmap); - cache.erase(it); + deadlist.push_back(it); delete tmp; tmp=0; - it = tmp_it; - if (it == it_end) break; - } + } + } + + std::list<CacheList::iterator>::iterator dead_it = deadlist.begin(); + std::list<CacheList::iterator>::iterator dead_it_end = deadlist.end(); + for (; dead_it != dead_it_end; ++dead_it) { + cache.erase(*dead_it); } + } void ImageControl::createColorTable() {
M src/FbTk/ImageControl.hhsrc/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.8 2004/01/02 22:19:39 fluxgen Exp $ +// $Id: ImageControl.hh,v 1.9 2004/01/11 12:40:47 fluxgen Exp $ #ifndef FBTK_IMAGECONTROL_HH #define FBTK_IMAGECONTROL_HH

@@ -127,7 +127,7 @@ };

unsigned long cache_max; - typedef std::set<Cache *, ltCacheEntry> CacheList; + typedef std::list<Cache *> CacheList; mutable CacheList cache; static bool s_timed_cache;