diff options
author | fluxgen <fluxgen> | 2002-02-04 22:41:27 (GMT) |
---|---|---|
committer | fluxgen <fluxgen> | 2002-02-04 22:41:27 (GMT) |
commit | cdc6210bfe53ca05eae93e48e52a1ffed3a9b610 (patch) | |
tree | 9384d79d65250831ade68d648c90127835755a67 /src/Image.cc | |
parent | 0c4c33f9f595818868dc83f8582909f68dd7efdd (diff) | |
download | fluxbox_pavel-cdc6210bfe53ca05eae93e48e52a1ffed3a9b610.zip fluxbox_pavel-cdc6210bfe53ca05eae93e48e52a1ffed3a9b610.tar.bz2 |
replaced LinkedList with stl container
Diffstat (limited to 'src/Image.cc')
-rw-r--r-- | src/Image.cc | 92 |
1 files changed, 43 insertions, 49 deletions
diff --git a/src/Image.cc b/src/Image.cc index 611d307..ec0768a 100644 --- a/src/Image.cc +++ b/src/Image.cc | |||
@@ -25,7 +25,7 @@ | |||
25 | // stupid macros needed to access some functions in version 2 of the GNU C | 25 | // stupid macros needed to access some functions in version 2 of the GNU C |
26 | // library | 26 | // library |
27 | 27 | ||
28 | // $Id: Image.cc,v 1.3 2002/01/09 14:11:20 fluxgen Exp $ | 28 | // $Id: Image.cc,v 1.4 2002/02/04 22:41:27 fluxgen Exp $ |
29 | 29 | ||
30 | #ifndef _GNU_SOURCE | 30 | #ifndef _GNU_SOURCE |
31 | #define _GNU_SOURCE | 31 | #define _GNU_SOURCE |
@@ -2188,8 +2188,6 @@ BImageControl::BImageControl(BaseDisplay *dpy, ScreenInfo *scrn, Bool _dither, | |||
2188 | throw static_cast<int>(1); //throw error code 1 | 2188 | throw static_cast<int>(1); //throw error code 1 |
2189 | 2189 | ||
2190 | } | 2190 | } |
2191 | |||
2192 | cache = new LinkedList<Cache>; | ||
2193 | } | 2191 | } |
2194 | 2192 | ||
2195 | 2193 | ||
@@ -2218,8 +2216,7 @@ BImageControl::~BImageControl(void) { | |||
2218 | delete [] colors; | 2216 | delete [] colors; |
2219 | } | 2217 | } |
2220 | 2218 | ||
2221 | if (cache->count()) { | 2219 | if (cache.size() > 0) { |
2222 | int i, n = cache->count(); | ||
2223 | fprintf(stderr, | 2220 | fprintf(stderr, |
2224 | I18n::instance()-> | 2221 | I18n::instance()-> |
2225 | getMessage( | 2222 | getMessage( |
@@ -2229,48 +2226,44 @@ BImageControl::~BImageControl(void) { | |||
2229 | 0, 0, | 2226 | 0, 0, |
2230 | #endif // NLS | 2227 | #endif // NLS |
2231 | "BImageContol::~BImageControl: pixmap cache - " | 2228 | "BImageContol::~BImageControl: pixmap cache - " |
2232 | "releasing %d pixmaps\n"), n); | 2229 | "releasing %d pixmaps\n"), cache.size()); |
2233 | 2230 | ||
2234 | for (i = 0; i < n; i++) { | 2231 | CacheList::iterator it = cache.begin(); |
2235 | Cache *tmp = cache->first(); | 2232 | CacheList::iterator it_end = cache.end(); |
2236 | XFreePixmap(basedisplay->getXDisplay(), tmp->pixmap); | 2233 | for (; it != it_end; ++it) { |
2237 | cache->remove(tmp); | 2234 | XFreePixmap(basedisplay->getXDisplay(), (*it)->pixmap); |
2238 | delete tmp; | 2235 | delete (*it); |
2239 | } | 2236 | } |
2240 | 2237 | ||
2241 | #ifdef TIMEDCACHE | 2238 | #ifdef TIMEDCACHE |
2242 | if (timer) { | 2239 | if (timer) { |
2243 | timer->stop(); | ||
2244 | delete timer; | 2240 | delete timer; |
2245 | } | 2241 | } |
2246 | #endif // TIMEDCACHE | 2242 | #endif // TIMEDCACHE |
2247 | } | 2243 | } |
2248 | |||
2249 | delete cache; | ||
2250 | } | 2244 | } |
2251 | 2245 | ||
2252 | 2246 | ||
2253 | Pixmap BImageControl::searchCache(unsigned int width, unsigned int height, | 2247 | Pixmap BImageControl::searchCache(unsigned int width, unsigned int height, |
2254 | unsigned long texture, | 2248 | unsigned long texture, |
2255 | BColor *c1, BColor *c2) { | 2249 | BColor *c1, BColor *c2) { |
2256 | if (cache->count()) { | 2250 | CacheList::iterator it = cache.begin(); |
2257 | LinkedListIterator<Cache> it(cache); | 2251 | CacheList::iterator it_end = cache.end(); |
2258 | 2252 | for (; it != it_end; ++it) { | |
2259 | for (; it.current(); it++) { | 2253 | if (((*it)->width == width) && |
2260 | if ((it.current()->width == width) && | 2254 | ((*it)->height == height) && |
2261 | (it.current()->height == height) && | 2255 | ((*it)->texture == texture) && |
2262 | (it.current()->texture == texture) && | 2256 | ((*it)->pixel1 == c1->getPixel())) { |
2263 | (it.current()->pixel1 == c1->getPixel())) | 2257 | if (texture & BImage::GRADIENT) { |
2264 | if (texture & BImage::GRADIENT) { | 2258 | if ((*it)->pixel2 == c2->getPixel()) { |
2265 | if (it.current()->pixel2 == c2->getPixel()) { | 2259 | (*it)->count++; |
2266 | it.current()->count++; | 2260 | return (*it)->pixmap; |
2267 | return it.current()->pixmap; | 2261 | } |
2268 | } | 2262 | } else { |
2269 | } else { | 2263 | (*it)->count++; |
2270 | it.current()->count++; | 2264 | return (*it)->pixmap; |
2271 | return it.current()->pixmap; | 2265 | } |
2272 | } | 2266 | } |
2273 | } | ||
2274 | } | 2267 | } |
2275 | 2268 | ||
2276 | return None; | 2269 | return None; |
@@ -2303,9 +2296,9 @@ Pixmap BImageControl::renderImage(unsigned int width, unsigned int height, | |||
2303 | else | 2296 | else |
2304 | tmp->pixel2 = 0l; | 2297 | tmp->pixel2 = 0l; |
2305 | 2298 | ||
2306 | cache->insert(tmp); | 2299 | cache.push_back(tmp); |
2307 | 2300 | ||
2308 | if ((unsigned) cache->count() > cache_max) { | 2301 | if ((unsigned) cache.size() > cache_max) { |
2309 | #ifdef DEBUG | 2302 | #ifdef DEBUG |
2310 | fprintf(stderr, | 2303 | fprintf(stderr, |
2311 | I18n::instance()-> | 2304 | I18n::instance()-> |
@@ -2331,22 +2324,21 @@ Pixmap BImageControl::renderImage(unsigned int width, unsigned int height, | |||
2331 | 2324 | ||
2332 | void BImageControl::removeImage(Pixmap pixmap) { | 2325 | void BImageControl::removeImage(Pixmap pixmap) { |
2333 | if (pixmap) { | 2326 | if (pixmap) { |
2334 | LinkedListIterator<Cache> it(cache); | 2327 | CacheList::iterator it = cache.begin(); |
2335 | for (; it.current(); it++) { | 2328 | CacheList::iterator it_end = cache.end(); |
2336 | if (it.current()->pixmap == pixmap) { | 2329 | for (; it != it_end; ++it) { |
2337 | Cache *tmp = it.current(); | 2330 | if ((*it)->pixmap == pixmap) { |
2338 | 2331 | if ((*it)->count) { | |
2339 | if (tmp->count) { | 2332 | (*it)->count--; |
2340 | tmp->count--; | ||
2341 | 2333 | ||
2342 | #ifdef TIMEDCACHE | 2334 | #ifdef TIMEDCACHE |
2343 | if (! timer) timeout(); | 2335 | if (! timer) timeout(); |
2344 | #else // !TIMEDCACHE | 2336 | #else // !TIMEDCACHE |
2345 | if (! tmp->count) timeout(); | 2337 | if (! (*it)->count) timeout(); |
2346 | #endif // TIMEDCACHE | 2338 | #endif // TIMEDCACHE |
2347 | } | 2339 | } |
2348 | 2340 | ||
2349 | return; | 2341 | return; |
2350 | } | 2342 | } |
2351 | } | 2343 | } |
2352 | } | 2344 | } |
@@ -2586,14 +2578,16 @@ void BImageControl::parseColor(BColor *color, char *c) { | |||
2586 | 2578 | ||
2587 | 2579 | ||
2588 | void BImageControl::timeout(void) { | 2580 | void BImageControl::timeout(void) { |
2589 | LinkedListIterator<Cache> it(cache); | 2581 | CacheList::iterator it = cache.begin(); |
2590 | for (; it.current(); it++) { | 2582 | CacheList::iterator it_end = cache.end(); |
2591 | Cache *tmp = it.current(); | 2583 | for (; it != it_end; ++it) { |
2584 | Cache *tmp = (*it); | ||
2592 | 2585 | ||
2593 | if (tmp->count <= 0) { | 2586 | if (tmp->count <= 0) { |
2594 | XFreePixmap(basedisplay->getXDisplay(), tmp->pixmap); | 2587 | XFreePixmap(basedisplay->getXDisplay(), tmp->pixmap); |
2595 | cache->remove(tmp); | 2588 | it = cache.erase(it); |
2596 | delete tmp; | 2589 | delete tmp; |
2590 | if (it == it_end) break; | ||
2597 | } | 2591 | } |
2598 | } | 2592 | } |
2599 | } | 2593 | } |