aboutsummaryrefslogtreecommitdiff
path: root/src/FbTk/ImageControl.cc
diff options
context:
space:
mode:
authorrathnor <rathnor>2003-10-09 16:48:09 (GMT)
committerrathnor <rathnor>2003-10-09 16:48:09 (GMT)
commit018665d7a3ae8cb642880176d415f57fc178c299 (patch)
tree05a21b11a9f28bd8b456e080be52148de30f5018 /src/FbTk/ImageControl.cc
parent075dc35b5eeb875e971842e8230338395367e08f (diff)
downloadfluxbox_pavel-018665d7a3ae8cb642880176d415f57fc178c299.zip
fluxbox_pavel-018665d7a3ae8cb642880176d415f57fc178c299.tar.bz2
drawing optimisations and fixes
Diffstat (limited to 'src/FbTk/ImageControl.cc')
-rw-r--r--src/FbTk/ImageControl.cc29
1 files changed, 24 insertions, 5 deletions
diff --git a/src/FbTk/ImageControl.cc b/src/FbTk/ImageControl.cc
index 915dc1c..2ceb106 100644
--- a/src/FbTk/ImageControl.cc
+++ b/src/FbTk/ImageControl.cc
@@ -22,7 +22,7 @@
22// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 22// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
23// DEALINGS IN THE SOFTWARE. 23// DEALINGS IN THE SOFTWARE.
24 24
25// $Id: ImageControl.cc,v 1.5 2003/08/18 11:37:14 fluxgen Exp $ 25// $Id: ImageControl.cc,v 1.6 2003/10/09 16:48:09 rathnor Exp $
26 26
27#include "ImageControl.hh" 27#include "ImageControl.hh"
28 28
@@ -152,6 +152,21 @@ ImageControl::~ImageControl() {
152Pixmap ImageControl::searchCache(unsigned int width, unsigned int height, 152Pixmap ImageControl::searchCache(unsigned int width, unsigned int height,
153 unsigned long texture_type, 153 unsigned long texture_type,
154 const FbTk::Color &color, const FbTk::Color &color_to) const { 154 const FbTk::Color &color, const FbTk::Color &color_to) const {
155 Cache tmp;
156 tmp.width = width;
157 tmp.height = height;
158 tmp.texture = texture_type;
159 tmp.pixel1 = color.pixel();
160 tmp.pixel2 = color_to.pixel();
161 CacheList::iterator it = cache.find(&tmp);
162 if (it == cache.end()) {
163 return None;
164 } else {
165 (*it)->count++;
166 return (*it)->pixmap;
167 }
168
169 /*
155 CacheList::iterator it = cache.begin(); 170 CacheList::iterator it = cache.begin();
156 CacheList::iterator it_end = cache.end(); 171 CacheList::iterator it_end = cache.end();
157 for (; it != it_end; ++it) { 172 for (; it != it_end; ++it) {
@@ -170,8 +185,8 @@ Pixmap ImageControl::searchCache(unsigned int width, unsigned int height,
170 } 185 }
171 } 186 }
172 } 187 }
173
174 return None; 188 return None;
189 */
175} 190}
176 191
177 192
@@ -187,7 +202,7 @@ Pixmap ImageControl::renderImage(unsigned int width, unsigned int height,
187 if (pixmap) 202 if (pixmap)
188 return pixmap; // return cache item 203 return pixmap; // return cache item
189 204
190 // render new image 205 // render new image
191 TextureRender image(*this, width, height, m_colors, m_num_colors); 206 TextureRender image(*this, width, height, m_colors, m_num_colors);
192 pixmap = image.render(texture); 207 pixmap = image.render(texture);
193 208
@@ -208,7 +223,7 @@ Pixmap ImageControl::renderImage(unsigned int width, unsigned int height,
208 else 223 else
209 tmp->pixel2 = 0l; 224 tmp->pixel2 = 0l;
210 225
211 cache.push_back(tmp); 226 cache.insert(tmp);
212 227
213 if ((unsigned) cache.size() > cache_max) 228 if ((unsigned) cache.size() > cache_max)
214 cleanCache(); 229 cleanCache();
@@ -355,9 +370,13 @@ void ImageControl::cleanCache() {
355 Cache *tmp = (*it); 370 Cache *tmp = (*it);
356 371
357 if (tmp->count <= 0) { 372 if (tmp->count <= 0) {
373 CacheList::iterator tmp_it = it;
374 ++tmp_it;
358 XFreePixmap(disp, tmp->pixmap); 375 XFreePixmap(disp, tmp->pixmap);
359 it = cache.erase(it); 376 cache.erase(it);
360 delete tmp; 377 delete tmp;
378 tmp=0;
379 it = tmp_it;
361 if (it == it_end) break; 380 if (it == it_end) break;
362 } 381 }
363 } 382 }