replaced LinkedList with stl container
This commit is contained in:
parent
0c4c33f9f5
commit
cdc6210bfe
4 changed files with 62 additions and 67 deletions
76
src/Image.cc
76
src/Image.cc
|
@ -25,7 +25,7 @@
|
||||||
// stupid macros needed to access some functions in version 2 of the GNU C
|
// stupid macros needed to access some functions in version 2 of the GNU C
|
||||||
// library
|
// library
|
||||||
|
|
||||||
// $Id: Image.cc,v 1.3 2002/01/09 14:11:20 fluxgen Exp $
|
// $Id: Image.cc,v 1.4 2002/02/04 22:41:27 fluxgen Exp $
|
||||||
|
|
||||||
#ifndef _GNU_SOURCE
|
#ifndef _GNU_SOURCE
|
||||||
#define _GNU_SOURCE
|
#define _GNU_SOURCE
|
||||||
|
@ -2188,8 +2188,6 @@ BImageControl::BImageControl(BaseDisplay *dpy, ScreenInfo *scrn, Bool _dither,
|
||||||
throw static_cast<int>(1); //throw error code 1
|
throw static_cast<int>(1); //throw error code 1
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
cache = new LinkedList<Cache>;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -2218,8 +2216,7 @@ BImageControl::~BImageControl(void) {
|
||||||
delete [] colors;
|
delete [] colors;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cache->count()) {
|
if (cache.size() > 0) {
|
||||||
int i, n = cache->count();
|
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
I18n::instance()->
|
I18n::instance()->
|
||||||
getMessage(
|
getMessage(
|
||||||
|
@ -2229,46 +2226,42 @@ BImageControl::~BImageControl(void) {
|
||||||
0, 0,
|
0, 0,
|
||||||
#endif // NLS
|
#endif // NLS
|
||||||
"BImageContol::~BImageControl: pixmap cache - "
|
"BImageContol::~BImageControl: pixmap cache - "
|
||||||
"releasing %d pixmaps\n"), n);
|
"releasing %d pixmaps\n"), cache.size());
|
||||||
|
|
||||||
for (i = 0; i < n; i++) {
|
CacheList::iterator it = cache.begin();
|
||||||
Cache *tmp = cache->first();
|
CacheList::iterator it_end = cache.end();
|
||||||
XFreePixmap(basedisplay->getXDisplay(), tmp->pixmap);
|
for (; it != it_end; ++it) {
|
||||||
cache->remove(tmp);
|
XFreePixmap(basedisplay->getXDisplay(), (*it)->pixmap);
|
||||||
delete tmp;
|
delete (*it);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef TIMEDCACHE
|
#ifdef TIMEDCACHE
|
||||||
if (timer) {
|
if (timer) {
|
||||||
timer->stop();
|
|
||||||
delete timer;
|
delete timer;
|
||||||
}
|
}
|
||||||
#endif // TIMEDCACHE
|
#endif // TIMEDCACHE
|
||||||
}
|
}
|
||||||
|
|
||||||
delete cache;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Pixmap BImageControl::searchCache(unsigned int width, unsigned int height,
|
Pixmap BImageControl::searchCache(unsigned int width, unsigned int height,
|
||||||
unsigned long texture,
|
unsigned long texture,
|
||||||
BColor *c1, BColor *c2) {
|
BColor *c1, BColor *c2) {
|
||||||
if (cache->count()) {
|
CacheList::iterator it = cache.begin();
|
||||||
LinkedListIterator<Cache> it(cache);
|
CacheList::iterator it_end = cache.end();
|
||||||
|
for (; it != it_end; ++it) {
|
||||||
for (; it.current(); it++) {
|
if (((*it)->width == width) &&
|
||||||
if ((it.current()->width == width) &&
|
((*it)->height == height) &&
|
||||||
(it.current()->height == height) &&
|
((*it)->texture == texture) &&
|
||||||
(it.current()->texture == texture) &&
|
((*it)->pixel1 == c1->getPixel())) {
|
||||||
(it.current()->pixel1 == c1->getPixel()))
|
|
||||||
if (texture & BImage::GRADIENT) {
|
if (texture & BImage::GRADIENT) {
|
||||||
if (it.current()->pixel2 == c2->getPixel()) {
|
if ((*it)->pixel2 == c2->getPixel()) {
|
||||||
it.current()->count++;
|
(*it)->count++;
|
||||||
return it.current()->pixmap;
|
return (*it)->pixmap;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
it.current()->count++;
|
(*it)->count++;
|
||||||
return it.current()->pixmap;
|
return (*it)->pixmap;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2303,9 +2296,9 @@ Pixmap BImageControl::renderImage(unsigned int width, unsigned int height,
|
||||||
else
|
else
|
||||||
tmp->pixel2 = 0l;
|
tmp->pixel2 = 0l;
|
||||||
|
|
||||||
cache->insert(tmp);
|
cache.push_back(tmp);
|
||||||
|
|
||||||
if ((unsigned) cache->count() > cache_max) {
|
if ((unsigned) cache.size() > cache_max) {
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
I18n::instance()->
|
I18n::instance()->
|
||||||
|
@ -2331,18 +2324,17 @@ Pixmap BImageControl::renderImage(unsigned int width, unsigned int height,
|
||||||
|
|
||||||
void BImageControl::removeImage(Pixmap pixmap) {
|
void BImageControl::removeImage(Pixmap pixmap) {
|
||||||
if (pixmap) {
|
if (pixmap) {
|
||||||
LinkedListIterator<Cache> it(cache);
|
CacheList::iterator it = cache.begin();
|
||||||
for (; it.current(); it++) {
|
CacheList::iterator it_end = cache.end();
|
||||||
if (it.current()->pixmap == pixmap) {
|
for (; it != it_end; ++it) {
|
||||||
Cache *tmp = it.current();
|
if ((*it)->pixmap == pixmap) {
|
||||||
|
if ((*it)->count) {
|
||||||
if (tmp->count) {
|
(*it)->count--;
|
||||||
tmp->count--;
|
|
||||||
|
|
||||||
#ifdef TIMEDCACHE
|
#ifdef TIMEDCACHE
|
||||||
if (! timer) timeout();
|
if (! timer) timeout();
|
||||||
#else // !TIMEDCACHE
|
#else // !TIMEDCACHE
|
||||||
if (! tmp->count) timeout();
|
if (! (*it)->count) timeout();
|
||||||
#endif // TIMEDCACHE
|
#endif // TIMEDCACHE
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2586,14 +2578,16 @@ void BImageControl::parseColor(BColor *color, char *c) {
|
||||||
|
|
||||||
|
|
||||||
void BImageControl::timeout(void) {
|
void BImageControl::timeout(void) {
|
||||||
LinkedListIterator<Cache> it(cache);
|
CacheList::iterator it = cache.begin();
|
||||||
for (; it.current(); it++) {
|
CacheList::iterator it_end = cache.end();
|
||||||
Cache *tmp = it.current();
|
for (; it != it_end; ++it) {
|
||||||
|
Cache *tmp = (*it);
|
||||||
|
|
||||||
if (tmp->count <= 0) {
|
if (tmp->count <= 0) {
|
||||||
XFreePixmap(basedisplay->getXDisplay(), tmp->pixmap);
|
XFreePixmap(basedisplay->getXDisplay(), tmp->pixmap);
|
||||||
cache->remove(tmp);
|
it = cache.erase(it);
|
||||||
delete tmp;
|
delete tmp;
|
||||||
|
if (it == it_end) break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
14
src/Image.hh
14
src/Image.hh
|
@ -22,7 +22,7 @@
|
||||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||||
// DEALINGS IN THE SOFTWARE.
|
// DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
// $Id: Image.hh,v 1.3 2002/01/09 14:11:20 fluxgen Exp $
|
// $Id: Image.hh,v 1.4 2002/02/04 22:41:27 fluxgen Exp $
|
||||||
|
|
||||||
#ifndef _IMAGE_HH_
|
#ifndef _IMAGE_HH_
|
||||||
#define _IMAGE_HH_
|
#define _IMAGE_HH_
|
||||||
|
@ -31,13 +31,9 @@
|
||||||
#include <X11/Xutil.h>
|
#include <X11/Xutil.h>
|
||||||
|
|
||||||
#include "Timer.hh"
|
#include "Timer.hh"
|
||||||
|
|
||||||
#ifndef _BASEDISPLAY_HH_
|
|
||||||
#include "BaseDisplay.hh"
|
#include "BaseDisplay.hh"
|
||||||
#endif
|
|
||||||
#ifndef _LINKEDLIST_HH_
|
#include <list>
|
||||||
#include "LinkedList.hh"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
class BImage;
|
class BImage;
|
||||||
class BImageControl;
|
class BImageControl;
|
||||||
|
@ -182,7 +178,9 @@ private:
|
||||||
unsigned long pixel1, pixel2, texture;
|
unsigned long pixel1, pixel2, texture;
|
||||||
} Cache;
|
} Cache;
|
||||||
|
|
||||||
LinkedList<Cache> *cache;
|
typedef std::list<Cache *> CacheList;
|
||||||
|
|
||||||
|
CacheList cache;
|
||||||
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
|
@ -503,18 +503,24 @@ void Toolbar::reconfigure(void) {
|
||||||
if (!iconbar) {
|
if (!iconbar) {
|
||||||
iconbar = new IconBar(screen, frame.window_label);
|
iconbar = new IconBar(screen, frame.window_label);
|
||||||
if (screen->getIconCount()) {
|
if (screen->getIconCount()) {
|
||||||
LinkedListIterator<FluxboxWindow> it(screen->getIconList());
|
BScreen::Icons & l = screen->getIconList();
|
||||||
for(; it.current(); it++)
|
BScreen::Icons::iterator it = l.begin();
|
||||||
addIcon(it.current());
|
BScreen::Icons::iterator it_end = l.end();
|
||||||
|
for(; it != it_end; ++it) {
|
||||||
|
addIcon(*it);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} else
|
} else
|
||||||
iconbar->reconfigure();
|
iconbar->reconfigure();
|
||||||
} else {
|
} else {
|
||||||
if (iconbar) {
|
if (iconbar) {
|
||||||
LinkedListIterator<FluxboxWindow> it(screen->getIconList());
|
BScreen::Icons & l = screen->getIconList();
|
||||||
for (; it.current(); it++)
|
BScreen::Icons::iterator it = l.begin();
|
||||||
delIcon(it.current());
|
BScreen::Icons::iterator it_end = l.end();
|
||||||
|
for(; it != it_end; ++it) {
|
||||||
|
delIcon(*it);
|
||||||
|
}
|
||||||
delete iconbar;
|
delete iconbar;
|
||||||
iconbar = 0;
|
iconbar = 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||||
// DEALINGS IN THE SOFTWARE.
|
// DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
// $Id: Toolbar.hh,v 1.5 2002/01/21 00:54:38 fluxgen Exp $
|
// $Id: Toolbar.hh,v 1.6 2002/02/04 22:38:41 fluxgen Exp $
|
||||||
|
|
||||||
#ifndef _TOOLBAR_HH_
|
#ifndef _TOOLBAR_HH_
|
||||||
#define _TOOLBAR_HH_
|
#define _TOOLBAR_HH_
|
||||||
|
@ -28,9 +28,6 @@
|
||||||
#ifndef _BASEMENU_HH_
|
#ifndef _BASEMENU_HH_
|
||||||
#include "Basemenu.hh"
|
#include "Basemenu.hh"
|
||||||
#endif
|
#endif
|
||||||
#ifndef _LINKEDLIST_HH_
|
|
||||||
#include "LinkedList.hh"
|
|
||||||
#endif
|
|
||||||
#ifndef _TIMER_HH_
|
#ifndef _TIMER_HH_
|
||||||
#include "Timer.hh"
|
#include "Timer.hh"
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue