all repos — fluxbox @ 98013ee6f7b61b39c14a24e74751b0b6c2673375

custom fork of the fluxbox windowmanager

minor cleaning
fluxgen fluxgen
commit

98013ee6f7b61b39c14a24e74751b0b6c2673375

parent

2ae58a7e491bcf76dd7da3cc2ecdf52765d84de5

2 files changed, 20 insertions(+), 24 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.4 2003/08/18 09:55:11 fluxgen Exp $ +// $Id: ImageControl.cc,v 1.5 2003/08/18 11:37:14 fluxgen Exp $ #include "ImageControl.hh"

@@ -60,10 +60,15 @@ namespace FbTk {

// lookup table for texture unsigned long *ImageControl::sqrt_table = 0; +#ifdef TIMEDCACHE +bool ImageControl::s_timed_cache = true; +#else +bool ImageControl::s_timed_cache = false; +#endif // TIMEDCACHE namespace { // anonymous -unsigned long bsqrt(unsigned long x) { +inline unsigned long bsqrt(unsigned long x) { if (x <= 0) return 0; if (x == 1) return 1;

@@ -79,7 +84,6 @@ }

}; // end anonymous namespace - ImageControl::ImageControl(int screen_num, bool dither, int cpc, unsigned long cache_timeout, unsigned long cmax): m_dither(dither),

@@ -96,14 +100,13 @@ m_visual = DefaultVisual(disp, screen_num);

m_colormap = DefaultColormap(disp, screen_num); cache_max = cmax; -#ifdef TIMEDCACHE - if (cache_timeout) { + + if (cache_timeout && s_timed_cache) { m_timer.setTimeout(cache_timeout); RefCount<Command> clean_cache(new SimpleCommand<ImageControl>(*this, &ImageControl::cleanCache)); m_timer.setCommand(clean_cache); m_timer.start(); } -#endif // TIMEDCACHE createColorTable(); }

@@ -134,9 +137,6 @@ delete [] m_colors;

} if (cache.size() > 0) { -#ifdef DEBUG - cerr<<"FbTk::ImageContol: pixmap cache - releasing "<<cache.size()<<" pixmaps."<<endl; -#endif // DEBUG CacheList::iterator it = cache.begin(); CacheList::iterator it_end = cache.end(); Display *disp = FbTk::App::instance()->display();

@@ -210,12 +210,8 @@ tmp->pixel2 = 0l;

cache.push_back(tmp); - if ((unsigned) cache.size() > cache_max) { -#ifdef DEBUG - cerr<<"FbTk::ImageControl::renderImage(): cache is large, forcing cleanout"<<endl; -#endif // DEBUG + if ((unsigned) cache.size() > cache_max) cleanCache(); - } return pixmap; }

@@ -235,12 +231,11 @@ if ((*it)->pixmap == pixmap) {

if ((*it)->count) { (*it)->count--; -#ifdef TIMEDCACHE - cleanCache(); -#else // !TIMEDCACHE - if (! (*it)->count) + if (s_timed_cache) + cleanCache(); + else if (! (*it)->count) cleanCache(); -#endif // TIMEDCACHE + } return;

@@ -342,14 +337,14 @@ unsigned long ImageControl::getSqrt(unsigned int x) const {

if (! sqrt_table) { // build sqrt table for use with elliptic gradient - sqrt_table = new unsigned long[(256 * 256 * 2) + 1]; + sqrt_table = new unsigned long[256 * 256 * 2 + 1]; int i = 0; for (; i < (256 * 256 * 2); i++) - *(sqrt_table + i) = bsqrt(i); + sqrt_table[i] = bsqrt(i); } - return (*(sqrt_table + x)); + return sqrt_table[x]; } void ImageControl::cleanCache() {

@@ -534,7 +529,7 @@ }

if (m_colors_per_channel < 2 || m_num_colors > static_cast<unsigned int>(1 << m_screen_depth)) { fprintf(stderr,"FbTk::ImageControl: invalid colormap size %d " - "(%d/%d/%d) - reducing", + "(%d/%d/%d) - reducing", m_num_colors, m_colors_per_channel, m_colors_per_channel, m_colors_per_channel);
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.3 2003/08/11 15:59:49 fluxgen Exp $ +// $Id: ImageControl.hh,v 1.4 2003/08/18 11:37:15 fluxgen Exp $ #ifndef FBTK_IMAGECONTROL_HH #define FBTK_IMAGECONTROL_HH

@@ -119,6 +119,7 @@ unsigned long cache_max;

typedef std::list<Cache *> CacheList; mutable CacheList cache; + static bool s_timed_cache; }; }; // end namespace FbTk