diff options
Diffstat (limited to 'src/FbTk/ImageControl.cc')
-rw-r--r-- | src/FbTk/ImageControl.cc | 66 |
1 files changed, 33 insertions, 33 deletions
diff --git a/src/FbTk/ImageControl.cc b/src/FbTk/ImageControl.cc index e89b2cb..cd86c94 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.15 2004/09/09 21:13:10 akir Exp $ | 25 | // $Id: ImageControl.cc,v 1.16 2004/09/10 16:41:30 akir Exp $ |
26 | 26 | ||
27 | #include "ImageControl.hh" | 27 | #include "ImageControl.hh" |
28 | 28 | ||
@@ -120,7 +120,7 @@ ImageControl::ImageControl(int screen_num, bool dither, | |||
120 | m_timer.setCommand(clean_cache); | 120 | m_timer.setCommand(clean_cache); |
121 | m_timer.start(); | 121 | m_timer.start(); |
122 | } | 122 | } |
123 | 123 | ||
124 | createColorTable(); | 124 | createColorTable(); |
125 | } | 125 | } |
126 | 126 | ||
@@ -140,7 +140,7 @@ ImageControl::~ImageControl() { | |||
140 | } | 140 | } |
141 | 141 | ||
142 | Display *disp = FbTk::App::instance()->display(); | 142 | Display *disp = FbTk::App::instance()->display(); |
143 | 143 | ||
144 | if (m_colors) { | 144 | if (m_colors) { |
145 | unsigned long *pixels = new unsigned long [m_num_colors]; | 145 | unsigned long *pixels = new unsigned long [m_num_colors]; |
146 | 146 | ||
@@ -167,7 +167,7 @@ ImageControl::~ImageControl() { | |||
167 | 167 | ||
168 | Pixmap ImageControl::searchCache(unsigned int width, unsigned int height, | 168 | Pixmap ImageControl::searchCache(unsigned int width, unsigned int height, |
169 | const Texture &text) const { | 169 | const Texture &text) const { |
170 | 170 | ||
171 | if (text.pixmap().drawable() != None) { | 171 | if (text.pixmap().drawable() != None) { |
172 | // do comparsion with width/height and texture_pixmap | 172 | // do comparsion with width/height and texture_pixmap |
173 | CacheList::iterator it = cache.begin(); | 173 | CacheList::iterator it = cache.begin(); |
@@ -191,28 +191,28 @@ Pixmap ImageControl::searchCache(unsigned int width, unsigned int height, | |||
191 | tmp.pixel1 = text.color().pixel(); | 191 | tmp.pixel1 = text.color().pixel(); |
192 | tmp.pixel2 = text.colorTo().pixel(); | 192 | tmp.pixel2 = text.colorTo().pixel(); |
193 | */ | 193 | */ |
194 | 194 | ||
195 | CacheList::iterator it = cache.begin(); | 195 | CacheList::iterator it = cache.begin(); |
196 | CacheList::iterator it_end = cache.end(); | 196 | CacheList::iterator it_end = cache.end(); |
197 | for (; it != it_end; ++it) { | 197 | for (; it != it_end; ++it) { |
198 | if (((*it)->width == width) && | 198 | if (((*it)->width == width) && |
199 | ((*it)->height == height) && | 199 | ((*it)->height == height) && |
200 | ((*it)->texture == text.type()) && | 200 | ((*it)->texture == text.type()) && |
201 | ((*it)->pixel1 == text.color().pixel())) { | 201 | ((*it)->pixel1 == text.color().pixel())) { |
202 | if (text.type() & FbTk::Texture::GRADIENT) { | 202 | if (text.type() & FbTk::Texture::GRADIENT) { |
203 | if ((*it)->pixel2 == text.colorTo().pixel()) { | 203 | if ((*it)->pixel2 == text.colorTo().pixel()) { |
204 | (*it)->count++; | 204 | (*it)->count++; |
205 | return (*it)->pixmap; | 205 | return (*it)->pixmap; |
206 | } | 206 | } |
207 | } else { | 207 | } else { |
208 | (*it)->count++; | 208 | (*it)->count++; |
209 | return (*it)->pixmap; | 209 | return (*it)->pixmap; |
210 | } | 210 | } |
211 | } | 211 | } |
212 | } | 212 | } |
213 | 213 | ||
214 | return None; | 214 | return None; |
215 | 215 | ||
216 | } | 216 | } |
217 | 217 | ||
218 | 218 | ||
@@ -250,7 +250,7 @@ Pixmap ImageControl::renderImage(unsigned int width, unsigned int height, | |||
250 | else | 250 | else |
251 | tmp->pixel2 = 0l; | 251 | tmp->pixel2 = 0l; |
252 | 252 | ||
253 | cache.push_back(tmp); | 253 | cache.push_back(tmp); |
254 | 254 | ||
255 | if ((unsigned) cache.size() > cache_max) | 255 | if ((unsigned) cache.size() > cache_max) |
256 | cleanCache(); | 256 | cleanCache(); |
@@ -343,10 +343,10 @@ void ImageControl::getGradientBuffers(unsigned int w, | |||
343 | 343 | ||
344 | 344 | ||
345 | void ImageControl::installRootColormap() { | 345 | void ImageControl::installRootColormap() { |
346 | XGrabServer(FbTk::App::instance()->display()); | ||
347 | |||
348 | 346 | ||
349 | Display *disp = FbTk::App::instance()->display(); | 347 | Display *disp = FbTk::App::instance()->display(); |
348 | XGrabServer(disp); | ||
349 | |||
350 | bool install = true; | 350 | bool install = true; |
351 | int i = 0, ncmap = 0; | 351 | int i = 0, ncmap = 0; |
352 | Colormap *cmaps = | 352 | Colormap *cmaps = |
@@ -357,14 +357,14 @@ void ImageControl::installRootColormap() { | |||
357 | if (*(cmaps + i) == m_colormap) | 357 | if (*(cmaps + i) == m_colormap) |
358 | install = false; | 358 | install = false; |
359 | } | 359 | } |
360 | 360 | ||
361 | if (install) | 361 | if (install) |
362 | XInstallColormap(disp, m_colormap); | 362 | XInstallColormap(disp, m_colormap); |
363 | 363 | ||
364 | XFree(cmaps); | 364 | XFree(cmaps); |
365 | } | 365 | } |
366 | 366 | ||
367 | XUngrabServer(FbTk::App::instance()->display()); | 367 | XUngrabServer(disp); |
368 | } | 368 | } |
369 | 369 | ||
370 | 370 | ||
@@ -402,7 +402,7 @@ void ImageControl::cleanCache() { | |||
402 | deadlist.push_back(it); | 402 | deadlist.push_back(it); |
403 | delete tmp; | 403 | delete tmp; |
404 | tmp=0; | 404 | tmp=0; |
405 | } | 405 | } |
406 | } | 406 | } |
407 | 407 | ||
408 | std::list<CacheList::iterator>::iterator dead_it = deadlist.begin(); | 408 | std::list<CacheList::iterator>::iterator dead_it = deadlist.begin(); |
@@ -410,7 +410,7 @@ void ImageControl::cleanCache() { | |||
410 | for (; dead_it != dead_it_end; ++dead_it) { | 410 | for (; dead_it != dead_it_end; ++dead_it) { |
411 | cache.erase(*dead_it); | 411 | cache.erase(*dead_it); |
412 | } | 412 | } |
413 | 413 | ||
414 | } | 414 | } |
415 | 415 | ||
416 | void ImageControl::createColorTable() { | 416 | void ImageControl::createColorTable() { |
@@ -511,7 +511,7 @@ void ImageControl::createColorTable() { | |||
511 | } | 511 | } |
512 | } | 512 | } |
513 | } | 513 | } |
514 | 514 | ||
515 | for (unsigned int i = 0; i < m_num_colors; i++) { | 515 | for (unsigned int i = 0; i < m_num_colors; i++) { |
516 | if (! XAllocColor(disp, m_colormap, &m_colors[i])) { | 516 | if (! XAllocColor(disp, m_colormap, &m_colors[i])) { |
517 | fprintf(stderr, "couldn't alloc color %i %i %i\n", | 517 | fprintf(stderr, "couldn't alloc color %i %i %i\n", |
@@ -520,7 +520,7 @@ void ImageControl::createColorTable() { | |||
520 | } else | 520 | } else |
521 | m_colors[i].flags = DoRed|DoGreen|DoBlue; | 521 | m_colors[i].flags = DoRed|DoGreen|DoBlue; |
522 | } | 522 | } |
523 | 523 | ||
524 | XColor icolors[256]; | 524 | XColor icolors[256]; |
525 | unsigned int incolors = (((1 << m_screen_depth) > 256) ? 256 : (1 << m_screen_depth)); | 525 | unsigned int incolors = (((1 << m_screen_depth) > 256) ? 256 : (1 << m_screen_depth)); |
526 | 526 | ||
@@ -532,7 +532,7 @@ void ImageControl::createColorTable() { | |||
532 | if (! m_colors[i].flags) { | 532 | if (! m_colors[i].flags) { |
533 | unsigned long chk = 0xffffffff, pixel, close = 0; | 533 | unsigned long chk = 0xffffffff, pixel, close = 0; |
534 | char p = 2; | 534 | char p = 2; |
535 | 535 | ||
536 | while (p--) { | 536 | while (p--) { |
537 | for (unsigned int ii = 0; ii < incolors; ii++) { | 537 | for (unsigned int ii = 0; ii < incolors; ii++) { |
538 | int r = (m_colors[i].red - icolors[i].red) >> 8; | 538 | int r = (m_colors[i].red - icolors[i].red) >> 8; |