X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=src%2FImage.cc;h=884d235f601581f9c3c82b1b39db2a37d9075be4;hb=ae093dba2fb97124bb4af3eaf4070b46f07dfd74;hp=b9335902904045dae3c0d5ca215feb7433b3aa35;hpb=ffce7be32582e3e93ca4d18c751f5c4e250a661e;p=chaz%2Fopenbox diff --git a/src/Image.cc b/src/Image.cc index b9335902..884d235f 100644 --- a/src/Image.cc +++ b/src/Image.cc @@ -50,10 +50,13 @@ typedef unsigned int u_int32_t; # endif #endif -#ifdef STDC_HEADERS +#ifdef HAVE_STDLIB_H # include +#endif // HAVE_STDLIB_H + +#ifdef HAVE_STRING_H # include -#endif // STDC_HEADERS +#endif // HAVE_STRING_H #ifdef HAVE_STDIO_H # include @@ -64,7 +67,8 @@ typedef unsigned int u_int32_t; #endif // HAVE_CTYPE_H #include -using namespace std; +using std::min; +using std::max; static unsigned long bsqrt(unsigned long x) { if (x <= 0) return 0; @@ -2053,8 +2057,6 @@ BImageControl::BImageControl(BaseDisplay &dpy, ScreenInfo &scrn, Bool _dither, getVisual()->c_class); exit(1); } - - cache = new LinkedList; } @@ -2083,16 +2085,16 @@ BImageControl::~BImageControl(void) { delete [] colors; } - if (cache->count()) { - int i, n = cache->count(); + if (!cache.empty()) { + int i, n = cache.size(); fprintf(stderr, i18n->getMessage(ImageSet, ImagePixmapRelease, "BImageContol::~BImageControl: pixmap cache - " "releasing %d pixmaps\n"), n); for (i = 0; i < n; i++) { - Cache *tmp = cache->first(); + Cache *tmp = cache.front(); XFreePixmap(basedisplay.getXDisplay(), tmp->pixmap); - cache->remove(tmp); + cache.remove(tmp); delete tmp; } @@ -2103,30 +2105,29 @@ BImageControl::~BImageControl(void) { } #endif // TIMEDCACHE } - - delete cache; } Pixmap BImageControl::searchCache(unsigned int width, unsigned int height, unsigned long texture, BColor *c1, BColor *c2) { - if (cache->count()) { - LinkedListIterator it(cache); + if (!cache.empty()) { - for (Cache *tmp = it.current(); tmp; it++, tmp = it.current()) { + CacheList::iterator it; + for (it = cache.begin(); it != cache.end(); ++it) { + Cache *tmp = *it; if ((tmp->width == width) && (tmp->height == height) && (tmp->texture == texture) && (tmp->pixel1 == c1->getPixel())) - if (texture & BImage_Gradient) { - if (tmp->pixel2 == c2->getPixel()) { - tmp->count++; - return tmp->pixmap; - } - } else { + if (texture & BImage_Gradient) { + if (tmp->pixel2 == c2->getPixel()) { tmp->count++; return tmp->pixmap; } + } else { + tmp->count++; + return tmp->pixmap; } + } } return None; @@ -2159,9 +2160,9 @@ Pixmap BImageControl::renderImage(unsigned int width, unsigned int height, else tmp->pixel2 = 0l; - cache->insert(tmp); + cache.push_back(tmp); - if ((unsigned) cache->count() > cache_max) { + if ((unsigned) cache.size() > cache_max) { #ifdef DEBUG fprintf(stderr, i18n->getMessage(ImageSet, ImagePixmapCacheLarge, "BImageControl::renderImage: cache is large, " @@ -2180,8 +2181,9 @@ Pixmap BImageControl::renderImage(unsigned int width, unsigned int height, void BImageControl::removeImage(Pixmap pixmap) { if (pixmap) { - LinkedListIterator it(cache); - for (Cache *tmp = it.current(); tmp; it++, tmp = it.current()) { + CacheList::iterator it; + for (it = cache.begin(); it != cache.end(); ++it) { + Cache *tmp = *it; if (tmp->pixmap == pixmap) { if (tmp->count) { tmp->count--; @@ -2430,12 +2432,14 @@ void BImageControl::parseColor(BColor *color, const char *c) { void BImageControl::timeout(void) { - LinkedListIterator it(cache); - for (Cache *tmp = it.current(); tmp; it++, tmp = it.current()) { + CacheList::iterator it; + for (it = cache.begin(); it != cache.end(); ) { + Cache *tmp = *it; + ++it; // move on to the next item before this one is removed if (tmp->count <= 0) { XFreePixmap(basedisplay.getXDisplay(), tmp->pixmap); - cache->remove(tmp); + cache.remove(tmp); delete tmp; - } + } } }