summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--legacy/evas/ChangeLog3
-rw-r--r--legacy/evas/NEWS1
-rw-r--r--legacy/evas/src/bin/loaders/xpm/evas_image_load_xpm.c178
-rw-r--r--legacy/evas/src/modules/loaders/xpm/evas_image_load_xpm.c181
4 files changed, 221 insertions, 142 deletions
diff --git a/legacy/evas/ChangeLog b/legacy/evas/ChangeLog
index 4ce66c78b0..ff136dda3c 100644
--- a/legacy/evas/ChangeLog
+++ b/legacy/evas/ChangeLog
@@ -1124,3 +1124,6 @@
1124 1124
1125 * Added Proxy'source events set APIs 1125 * Added Proxy'source events set APIs
1126 1126
11272012-10-25 Cedric Bail
1128
1129 * Make XPM loader faster.
diff --git a/legacy/evas/NEWS b/legacy/evas/NEWS
index a30f3e37a3..882946aafa 100644
--- a/legacy/evas/NEWS
+++ b/legacy/evas/NEWS
@@ -19,6 +19,7 @@ Improvements:
19 * EVAS_GL_NO_BLACKLIST env var to turn off blacklisted drivers in gl 19 * EVAS_GL_NO_BLACKLIST env var to turn off blacklisted drivers in gl
20 * Evas gl engine can do partial swaps now. 20 * Evas gl engine can do partial swaps now.
21 * evas_object_del() now takes NULL parameters 21 * evas_object_del() now takes NULL parameters
22 * make xpm loader faster (from O(N) to O(log(N))).
22 23
23Fixes: 24Fixes:
24 * Fix segmentation fault with the esvg loader. 25 * Fix segmentation fault with the esvg loader.
diff --git a/legacy/evas/src/bin/loaders/xpm/evas_image_load_xpm.c b/legacy/evas/src/bin/loaders/xpm/evas_image_load_xpm.c
index 8404509c70..18eb1277aa 100644
--- a/legacy/evas/src/bin/loaders/xpm/evas_image_load_xpm.c
+++ b/legacy/evas/src/bin/loaders/xpm/evas_image_load_xpm.c
@@ -6,6 +6,8 @@
6# include <Evil.h> 6# include <Evil.h>
7#endif 7#endif
8 8
9#include <ctype.h>
10
9#include "evas_macros.h" 11#include "evas_macros.h"
10 12
11#include "evas_cserve2.h" 13#include "evas_cserve2.h"
@@ -14,6 +16,23 @@
14static Eina_File *rgb_txt; 16static Eina_File *rgb_txt;
15static void *rgb_txt_map; 17static void *rgb_txt_map;
16 18
19static int
20_xpm_hexa_int(const char *s, int len)
21{
22 const char *hexa = "0123456789abcdef";
23 const char *lookup;
24 int i, c, r;
25
26 for (r = 0, i = 0; i < len; i++)
27 {
28 c = s[i];
29 lookup = strchr(hexa, tolower(c));
30 r = (r << 4) | (lookup ? lookup - hexa : 0);
31 }
32
33 return r;
34}
35
17static void 36static void
18xpm_parse_color(char *color, int *r, int *g, int *b) 37xpm_parse_color(char *color, int *r, int *g, int *b)
19{ 38{
@@ -26,26 +45,15 @@ xpm_parse_color(char *color, int *r, int *g, int *b)
26 if (color[0] == '#') 45 if (color[0] == '#')
27 { 46 {
28 int len; 47 int len;
29 char val[32];
30 48
31 len = strlen(color) - 1; 49 len = strlen(color) - 1;
32 if (len < 96) 50 if (len < 96)
33 { 51 {
34 int i;
35 52
36 len /= 3; 53 len /= 3;
37 for (i = 0; i < len; i++) 54 *r = _xpm_hexa_int(&(color[1 + (0 * len)]), len);
38 val[i] = color[1 + i + (0 * len)]; 55 *g = _xpm_hexa_int(&(color[1 + (1 * len)]), len);
39 val[i] = 0; 56 *b = _xpm_hexa_int(&(color[1 + (2 * len)]), len);
40 sscanf(val, "%x", r);
41 for (i = 0; i < len; i++)
42 val[i] = color[1 + i + (1 * len)];
43 val[i] = 0;
44 sscanf(val, "%x", g);
45 for (i = 0; i < len; i++)
46 val[i] = color[1 + i + (2 * len)];
47 val[i] = 0;
48 sscanf(val, "%x", b);
49 if (len == 1) 57 if (len == 1)
50 { 58 {
51 *r = (*r << 4) | *r; 59 *r = (*r << 4) | *r;
@@ -75,7 +83,7 @@ xpm_parse_color(char *color, int *r, int *g, int *b)
75 int rr, gg, bb; 83 int rr, gg, bb;
76 char name[4096]; 84 char name[4096];
77 85
78 /* FIXME: not really efficient */ 86 /* FIXME: not really efficient, should be loaded once in memory with a lookup table */
79 memcpy(buf, tmp, endline - tmp); 87 memcpy(buf, tmp, endline - tmp);
80 buf[endline - tmp + 1] = '\0'; 88 buf[endline - tmp + 1] = '\0';
81 89
@@ -94,29 +102,56 @@ xpm_parse_color(char *color, int *r, int *g, int *b)
94 } 102 }
95} 103}
96 104
105typedef struct _CMap CMap;
106struct _CMap {
107 EINA_RBTREE;
108 short r, g, b;
109 char str[6];
110 unsigned char transp;
111};
112
113Eina_Rbtree_Direction
114_cmap_cmp_node_cb(const Eina_Rbtree *left, const Eina_Rbtree *right, void *data __UNUSED__)
115{
116 CMap *lcm;
117 CMap *rcm;
118
119 lcm = EINA_RBTREE_CONTAINER_GET(left, CMap);
120 rcm = EINA_RBTREE_CONTAINER_GET(right, CMap);
121
122 if (strcmp(lcm->str, rcm->str) < 0)
123 return EINA_RBTREE_LEFT;
124 return EINA_RBTREE_RIGHT;
125}
126
127int
128_cmap_cmp_key_cb(const Eina_Rbtree *node, const void *key, int length __UNUSED__, void *data __UNUSED__)
129{
130 CMap *root = EINA_RBTREE_CONTAINER_GET(node, CMap);
131
132 return strcmp(root->str, key);
133}
134
97/** FIXME: clean this up and make more efficient **/ 135/** FIXME: clean this up and make more efficient **/
98static Eina_Bool 136static Eina_Bool
99evas_image_load_file_xpm(Evas_Img_Load_Params *ilp, const char *file, const char *key __UNUSED__, int load_data, int *error) 137evas_image_load_file_xpm(Evas_Img_Load_Params *ilp, const char *file, const char *key __UNUSED__, int load_data, int *error)
100{ 138{
101 DATA32 *ptr, *end; 139 DATA32 *ptr, *end;
102 Eina_File *f; 140 Eina_File *f;
103 const char *map; 141 const char *map;
104 size_t length; 142 size_t length;
105 size_t position; 143 size_t position;
106 144
107 int pc, c, i, j, k, w, h, ncolors, cpp, comment, transp, 145 int pc, c, i, j, k, w, h, ncolors, cpp, comment, transp,
108 quote, context, len, done, r, g, b, backslash, lu1, lu2; 146 quote, context, len, done, r, g, b, backslash, lu1, lu2;
109 char *line = NULL; 147 char *line = NULL;
110 char s[256], tok[128], col[256], *tl; 148 char s[256], tok[128], col[256], *tl;
111 int lsz = 256; 149 int lsz = 256;
112 struct _cmap { 150 CMap *cmap = NULL;
113 char str[6]; 151 Eina_Rbtree *root = NULL;
114 unsigned char transp; 152
115 short r, g, b; 153 short lookup[128 - 32][128 - 32];
116 } *cmap = NULL; 154 int count, pixels;
117
118 short lookup[128 - 32][128 - 32];
119 int count, pixels;
120 155
121 done = 0; 156 done = 0;
122// transp = -1; 157// transp = -1;
@@ -235,7 +270,7 @@ evas_image_load_file_xpm(Evas_Img_Load_Params *ilp, const char *file, const char
235 270
236 if (!cmap) 271 if (!cmap)
237 { 272 {
238 cmap = malloc(sizeof(struct _cmap) * ncolors); 273 cmap = malloc(sizeof(CMap) * ncolors);
239 if (!cmap) 274 if (!cmap)
240 { 275 {
241 *error = EVAS_LOAD_ERROR_RESOURCE_ALLOCATION_FAILED; 276 *error = EVAS_LOAD_ERROR_RESOURCE_ALLOCATION_FAILED;
@@ -264,6 +299,7 @@ evas_image_load_file_xpm(Evas_Img_Load_Params *ilp, const char *file, const char
264 len = strlen(line); 299 len = strlen(line);
265 strncpy(cmap[j].str, line, cpp); 300 strncpy(cmap[j].str, line, cpp);
266 cmap[j].str[cpp] = 0; 301 cmap[j].str[cpp] = 0;
302 if (load_data) root = eina_rbtree_inline_insert(root, EINA_RBTREE_GET(&cmap[j]), _cmap_cmp_node_cb, NULL);
267 for (slen = 0; slen < cpp; slen++) 303 for (slen = 0; slen < cpp; slen++)
268 { 304 {
269 /* fix the ascii of the color string - if its < 32 - just limit to 32 */ 305 /* fix the ascii of the color string - if its < 32 - just limit to 32 */
@@ -275,9 +311,11 @@ evas_image_load_file_xpm(Evas_Img_Load_Params *ilp, const char *file, const char
275 { 311 {
276 if (line[k] != ' ') 312 if (line[k] != ' ')
277 { 313 {
278 s[0] = 0; 314 const char *tmp = strchr(&line[k], ' ');
279 sscanf(&line[k], "%255s", s); 315 slen = tmp ? tmp - &line[k]: 255;
280 slen = strlen(s); 316
317 strncpy(s, &line[k], slen);
318 s[slen] = 0;
281 k += slen; 319 k += slen;
282 if (!strcmp(s, "c")) iscolor = 1; 320 if (!strcmp(s, "c")) iscolor = 1;
283 if ((!strcmp(s, "m")) || (!strcmp(s, "s")) 321 if ((!strcmp(s, "m")) || (!strcmp(s, "s"))
@@ -490,6 +528,8 @@ evas_image_load_file_xpm(Evas_Img_Load_Params *ilp, const char *file, const char
490 ((i < 65536) && (ptr < end) && (line[i])); 528 ((i < 65536) && (ptr < end) && (line[i]));
491 i++) 529 i++)
492 { 530 {
531 Eina_Rbtree *l;
532
493 for (j = 0; j < cpp; j++, i++) 533 for (j = 0; j < cpp; j++, i++)
494 { 534 {
495 col[j] = line[i]; 535 col[j] = line[i];
@@ -497,30 +537,26 @@ evas_image_load_file_xpm(Evas_Img_Load_Params *ilp, const char *file, const char
497 } 537 }
498 col[j] = 0; 538 col[j] = 0;
499 i--; 539 i--;
500 for (j = 0; j < ncolors; j++) 540
541 l = eina_rbtree_inline_lookup(root, col, j, _cmap_cmp_key_cb, NULL);
542 if (l)
501 { 543 {
502 if (!strcmp(col, cmap[j].str)) 544 CMap *cm = EINA_RBTREE_CONTAINER_GET(l, CMap);
545
546 r = (unsigned char)cm->r;
547 g = (unsigned char)cm->g;
548 b = (unsigned char)cm->b;
549 if (cm->transp)
503 { 550 {
504 if (cmap[j].transp) 551 *ptr = RGB_JOIN(r, g, b);
505 {
506 r = (unsigned char)cmap[j].r;
507 g = (unsigned char)cmap[j].g;
508 b = (unsigned char)cmap[j].b;
509 *ptr = RGB_JOIN(r, g, b);
510 ptr++;
511 count++;
512 }
513 else
514 {
515 r = (unsigned char)cmap[j].r;
516 g = (unsigned char)cmap[j].g;
517 b = (unsigned char)cmap[j].b;
518 *ptr = ARGB_JOIN(0xff, r, g, b);
519 ptr++;
520 count++;
521 }
522 break;
523 } 552 }
553 else
554 {
555 *ptr = ARGB_JOIN(0xff, r, g, b);
556 }
557
558 ptr++;
559 count++;
524 } 560 }
525 } 561 }
526 } 562 }
@@ -530,24 +566,26 @@ evas_image_load_file_xpm(Evas_Img_Load_Params *ilp, const char *file, const char
530 ((i < 65536) && (ptr < end) && (line[i])); 566 ((i < 65536) && (ptr < end) && (line[i]));
531 i++) 567 i++)
532 { 568 {
569 Eina_Rbtree *l;
570
533 for (j = 0; j < cpp; j++, i++) 571 for (j = 0; j < cpp; j++, i++)
534 { 572 {
535 col[j] = line[i]; 573 col[j] = line[i];
536 } 574 }
537 col[j] = 0; 575 col[j] = 0;
538 i--; 576 i--;
539 for (j = 0; j < ncolors; j++) 577
578 l = eina_rbtree_inline_lookup(root, col, 0, _cmap_cmp_key_cb, NULL);
579 if (l)
540 { 580 {
541 if (!strcmp(col, cmap[j].str)) 581 CMap *cm = EINA_RBTREE_CONTAINER_GET(l, CMap);
542 { 582
543 r = (unsigned char)cmap[j].r; 583 r = (unsigned char)cm->r;
544 g = (unsigned char)cmap[j].g; 584 g = (unsigned char)cm->g;
545 b = (unsigned char)cmap[j].b; 585 b = (unsigned char)cm->b;
546 *ptr = ARGB_JOIN(0xff, r, g, b); 586 *ptr = ARGB_JOIN(0xff, r, g, b);
547 ptr++; 587 ptr++;
548 count++; 588 count++;
549 break;
550 }
551 } 589 }
552 } 590 }
553 } 591 }
diff --git a/legacy/evas/src/modules/loaders/xpm/evas_image_load_xpm.c b/legacy/evas/src/modules/loaders/xpm/evas_image_load_xpm.c
index 00376eb51d..4464ed0533 100644
--- a/legacy/evas/src/modules/loaders/xpm/evas_image_load_xpm.c
+++ b/legacy/evas/src/modules/loaders/xpm/evas_image_load_xpm.c
@@ -31,6 +31,23 @@ static Evas_Image_Load_Func evas_image_load_xpm_func =
31static Eina_File *rgb_txt; 31static Eina_File *rgb_txt;
32static void *rgb_txt_map; 32static void *rgb_txt_map;
33 33
34static int
35_xpm_hexa_int(const char *s, int len)
36{
37 const char *hexa = "0123456789abcdef";
38 const char *lookup;
39 int i, c, r;
40
41 for (r = 0, i = 0; i < len; i++)
42 {
43 c = s[i];
44 lookup = strchr(hexa, tolower(c));
45 r = (r << 4) | (lookup ? lookup - hexa : 0);
46 }
47
48 return r;
49}
50
34static void 51static void
35xpm_parse_color(char *color, int *r, int *g, int *b) 52xpm_parse_color(char *color, int *r, int *g, int *b)
36{ 53{
@@ -43,26 +60,15 @@ xpm_parse_color(char *color, int *r, int *g, int *b)
43 if (color[0] == '#') 60 if (color[0] == '#')
44 { 61 {
45 int len; 62 int len;
46 char val[32];
47 63
48 len = strlen(color) - 1; 64 len = strlen(color) - 1;
49 if (len < 96) 65 if (len < 96)
50 { 66 {
51 int i;
52 67
53 len /= 3; 68 len /= 3;
54 for (i = 0; i < len; i++) 69 *r = _xpm_hexa_int(&(color[1 + (0 * len)]), len);
55 val[i] = color[1 + i + (0 * len)]; 70 *g = _xpm_hexa_int(&(color[1 + (1 * len)]), len);
56 val[i] = 0; 71 *b = _xpm_hexa_int(&(color[1 + (2 * len)]), len);
57 sscanf(val, "%x", r);
58 for (i = 0; i < len; i++)
59 val[i] = color[1 + i + (1 * len)];
60 val[i] = 0;
61 sscanf(val, "%x", g);
62 for (i = 0; i < len; i++)
63 val[i] = color[1 + i + (2 * len)];
64 val[i] = 0;
65 sscanf(val, "%x", b);
66 if (len == 1) 72 if (len == 1)
67 { 73 {
68 *r = (*r << 4) | *r; 74 *r = (*r << 4) | *r;
@@ -92,7 +98,7 @@ xpm_parse_color(char *color, int *r, int *g, int *b)
92 int rr, gg, bb; 98 int rr, gg, bb;
93 char name[4096]; 99 char name[4096];
94 100
95 /* FIXME: not really efficient */ 101 /* FIXME: not really efficient, should be loaded once in memory with a lookup table */
96 memcpy(buf, tmp, endline - tmp); 102 memcpy(buf, tmp, endline - tmp);
97 buf[endline - tmp + 1] = '\0'; 103 buf[endline - tmp + 1] = '\0';
98 104
@@ -111,29 +117,56 @@ xpm_parse_color(char *color, int *r, int *g, int *b)
111 } 117 }
112} 118}
113 119
120typedef struct _CMap CMap;
121struct _CMap {
122 EINA_RBTREE;
123 short r, g, b;
124 char str[6];
125 unsigned char transp;
126};
127
128Eina_Rbtree_Direction
129_cmap_cmp_node_cb(const Eina_Rbtree *left, const Eina_Rbtree *right, void *data __UNUSED__)
130{
131 CMap *lcm;
132 CMap *rcm;
133
134 lcm = EINA_RBTREE_CONTAINER_GET(left, CMap);
135 rcm = EINA_RBTREE_CONTAINER_GET(right, CMap);
136
137 if (strcmp(lcm->str, rcm->str) < 0)
138 return EINA_RBTREE_LEFT;
139 return EINA_RBTREE_RIGHT;
140}
141
142int
143_cmap_cmp_key_cb(const Eina_Rbtree *node, const void *key, int length __UNUSED__, void *data __UNUSED__)
144{
145 CMap *root = EINA_RBTREE_CONTAINER_GET(node, CMap);
146
147 return strcmp(root->str, key);
148}
149
114/** FIXME: clean this up and make more efficient **/ 150/** FIXME: clean this up and make more efficient **/
115static Eina_Bool 151static Eina_Bool
116evas_image_load_file_xpm(Image_Entry *ie, const char *file, const char *key __UNUSED__, int load_data, int *error) 152evas_image_load_file_xpm(Image_Entry *ie, const char *file, const char *key __UNUSED__, int load_data, int *error)
117{ 153{
118 DATA32 *ptr, *end; 154 DATA32 *ptr, *end, *head;
119 Eina_File *f; 155 Eina_File *f;
120 const char *map; 156 const char *map;
121 size_t length; 157 size_t length;
122 size_t position; 158 size_t position;
123 159
124 int pc, c, i, j, k, w, h, ncolors, cpp, comment, transp, 160 int pc, c, i, j, k, w, h, ncolors, cpp, comment, transp,
125 quote, context, len, done, r, g, b, backslash, lu1, lu2; 161 quote, context, len, done, r, g, b, backslash, lu1, lu2;
126 char *line = NULL; 162 char *line = NULL;
127 char s[256], tok[128], col[256], *tl; 163 char s[256], tok[128], col[256], *tl;
128 int lsz = 256; 164 int lsz = 256;
129 struct _cmap { 165 CMap *cmap = NULL;
130 char str[6]; 166 Eina_Rbtree *root = NULL;
131 unsigned char transp; 167
132 short r, g, b; 168 short lookup[128 - 32][128 - 32];
133 } *cmap = NULL; 169 int count, pixels;
134
135 short lookup[128 - 32][128 - 32];
136 int count, pixels;
137 170
138 done = 0; 171 done = 0;
139// transp = -1; 172// transp = -1;
@@ -264,7 +297,7 @@ evas_image_load_file_xpm(Image_Entry *ie, const char *file, const char *key __UN
264 297
265 if (!cmap) 298 if (!cmap)
266 { 299 {
267 cmap = malloc(sizeof(struct _cmap) * ncolors); 300 cmap = malloc(sizeof(CMap) * ncolors);
268 if (!cmap) 301 if (!cmap)
269 { 302 {
270 *error = EVAS_LOAD_ERROR_RESOURCE_ALLOCATION_FAILED; 303 *error = EVAS_LOAD_ERROR_RESOURCE_ALLOCATION_FAILED;
@@ -293,6 +326,7 @@ evas_image_load_file_xpm(Image_Entry *ie, const char *file, const char *key __UN
293 len = strlen(line); 326 len = strlen(line);
294 strncpy(cmap[j].str, line, cpp); 327 strncpy(cmap[j].str, line, cpp);
295 cmap[j].str[cpp] = 0; 328 cmap[j].str[cpp] = 0;
329 if (load_data) root = eina_rbtree_inline_insert(root, EINA_RBTREE_GET(&cmap[j]), _cmap_cmp_node_cb, NULL);
296 for (slen = 0; slen < cpp; slen++) 330 for (slen = 0; slen < cpp; slen++)
297 { 331 {
298 /* fix the ascii of the color string - if its < 32 - just limit to 32 */ 332 /* fix the ascii of the color string - if its < 32 - just limit to 32 */
@@ -304,9 +338,11 @@ evas_image_load_file_xpm(Image_Entry *ie, const char *file, const char *key __UN
304 { 338 {
305 if (line[k] != ' ') 339 if (line[k] != ' ')
306 { 340 {
307 s[0] = 0; 341 const char *tmp = strchr(&line[k], ' ');
308 sscanf(&line[k], "%255s", s); 342 slen = tmp ? tmp - &line[k]: 255;
309 slen = strlen(s); 343
344 strncpy(s, &line[k], slen);
345 s[slen] = 0;
310 k += slen; 346 k += slen;
311 if (slen == 1 && *s == 'c') iscolor = 1; 347 if (slen == 1 && *s == 'c') iscolor = 1;
312 if ((slen == 1 && ((s[0] == 'm') || (s[0] == 's') || (s[0] == 'g') || (s[0] == 'c'))) || 348 if ((slen == 1 && ((s[0] == 'm') || (s[0] == 's') || (s[0] == 'g') || (s[0] == 'c'))) ||
@@ -367,7 +403,7 @@ evas_image_load_file_xpm(Image_Entry *ie, const char *file, const char *key __UN
367 } 403 }
368 } 404 }
369 j++; 405 j++;
370 if (j >= ncolors) 406 if (load_data && j >= ncolors)
371 { 407 {
372 if (cpp == 1) 408 if (cpp == 1)
373 { 409 {
@@ -388,6 +424,7 @@ evas_image_load_file_xpm(Image_Entry *ie, const char *file, const char *key __UN
388 { 424 {
389 evas_cache_image_surface_alloc(ie, w, h); 425 evas_cache_image_surface_alloc(ie, w, h);
390 ptr = evas_cache_image_pixels(ie); 426 ptr = evas_cache_image_pixels(ie);
427 head = ptr;
391 if (!ptr) 428 if (!ptr)
392 { 429 {
393 *error = EVAS_LOAD_ERROR_RESOURCE_ALLOCATION_FAILED; 430 *error = EVAS_LOAD_ERROR_RESOURCE_ALLOCATION_FAILED;
@@ -520,6 +557,8 @@ evas_image_load_file_xpm(Image_Entry *ie, const char *file, const char *key __UN
520 ((i < 65536) && (ptr < end) && (line[i])); 557 ((i < 65536) && (ptr < end) && (line[i]));
521 i++) 558 i++)
522 { 559 {
560 Eina_Rbtree *l;
561
523 for (j = 0; j < cpp; j++, i++) 562 for (j = 0; j < cpp; j++, i++)
524 { 563 {
525 col[j] = line[i]; 564 col[j] = line[i];
@@ -527,30 +566,26 @@ evas_image_load_file_xpm(Image_Entry *ie, const char *file, const char *key __UN
527 } 566 }
528 col[j] = 0; 567 col[j] = 0;
529 i--; 568 i--;
530 for (j = 0; j < ncolors; j++) 569
570 l = eina_rbtree_inline_lookup(root, col, j, _cmap_cmp_key_cb, NULL);
571 if (l)
531 { 572 {
532 if (!strcmp(col, cmap[j].str)) 573 CMap *cm = EINA_RBTREE_CONTAINER_GET(l, CMap);
574
575 r = (unsigned char)cm->r;
576 g = (unsigned char)cm->g;
577 b = (unsigned char)cm->b;
578 if (cm->transp)
533 { 579 {
534 if (cmap[j].transp) 580 *ptr = RGB_JOIN(r, g, b);
535 {
536 r = (unsigned char)cmap[j].r;
537 g = (unsigned char)cmap[j].g;
538 b = (unsigned char)cmap[j].b;
539 *ptr = RGB_JOIN(r, g, b);
540 ptr++;
541 count++;
542 }
543 else
544 {
545 r = (unsigned char)cmap[j].r;
546 g = (unsigned char)cmap[j].g;
547 b = (unsigned char)cmap[j].b;
548 *ptr = ARGB_JOIN(0xff, r, g, b);
549 ptr++;
550 count++;
551 }
552 break;
553 } 581 }
582 else
583 {
584 *ptr = ARGB_JOIN(0xff, r, g, b);
585 }
586
587 ptr++;
588 count++;
554 } 589 }
555 } 590 }
556 } 591 }
@@ -560,24 +595,26 @@ evas_image_load_file_xpm(Image_Entry *ie, const char *file, const char *key __UN
560 ((i < 65536) && (ptr < end) && (line[i])); 595 ((i < 65536) && (ptr < end) && (line[i]));
561 i++) 596 i++)
562 { 597 {
598 Eina_Rbtree *l;
599
563 for (j = 0; j < cpp; j++, i++) 600 for (j = 0; j < cpp; j++, i++)
564 { 601 {
565 col[j] = line[i]; 602 col[j] = line[i];
566 } 603 }
567 col[j] = 0; 604 col[j] = 0;
568 i--; 605 i--;
569 for (j = 0; j < ncolors; j++) 606
607 l = eina_rbtree_inline_lookup(root, col, 0, _cmap_cmp_key_cb, NULL);
608 if (l)
570 { 609 {
571 if (!strcmp(col, cmap[j].str)) 610 CMap *cm = EINA_RBTREE_CONTAINER_GET(l, CMap);
572 { 611
573 r = (unsigned char)cmap[j].r; 612 r = (unsigned char)cm->r;
574 g = (unsigned char)cmap[j].g; 613 g = (unsigned char)cm->g;
575 b = (unsigned char)cmap[j].b; 614 b = (unsigned char)cm->b;
576 *ptr = ARGB_JOIN(0xff, r, g, b); 615 *ptr = ARGB_JOIN(0xff, r, g, b);
577 ptr++; 616 ptr++;
578 count++; 617 count++;
579 break;
580 }
581 } 618 }
582 } 619 }
583 } 620 }
@@ -610,7 +647,7 @@ evas_image_load_file_xpm(Image_Entry *ie, const char *file, const char *key __UN
610 if (!tl) break; 647 if (!tl) break;
611 line = tl; 648 line = tl;
612 } 649 }
613 if (((ptr) && ((ptr - evas_cache_image_pixels(ie)) >= (w * h * (int)sizeof(DATA32)))) || 650 if (((ptr) && ((ptr - head) >= (w * h * (int)sizeof(DATA32)))) ||
614 ((context > 1) && (count >= pixels))) 651 ((context > 1) && (count >= pixels)))
615 break; 652 break;
616 } 653 }