summaryrefslogtreecommitdiff
path: root/src/lib/evas/common
diff options
context:
space:
mode:
authorCedric Bail <cedric.bail@samsung.com>2013-10-10 17:44:24 +0900
committerCedric Bail <cedric.bail@samsung.com>2013-10-11 11:08:17 +0900
commit6dcffec491f2281dd8649f1196f576fa715507f3 (patch)
treeecaf3025222b4bb48d457285e605465bec57c0a5 /src/lib/evas/common
parent12d34309c7c6e3f3041ee576afe93f9ca335059e (diff)
evas: Use Eina_Spinlock for Evas_Scalecache, Evas_Async_Events and Image_Entry.
Diffstat (limited to 'src/lib/evas/common')
-rw-r--r--src/lib/evas/common/evas_image_scalecache.c96
1 files changed, 48 insertions, 48 deletions
diff --git a/src/lib/evas/common/evas_image_scalecache.c b/src/lib/evas/common/evas_image_scalecache.c
index 490d3c8d3f..fc907614c8 100644
--- a/src/lib/evas/common/evas_image_scalecache.c
+++ b/src/lib/evas/common/evas_image_scalecache.c
@@ -57,7 +57,7 @@ struct _Scaleitem
57#ifdef SCALECACHE 57#ifdef SCALECACHE
58static unsigned long long use_counter = 0; 58static unsigned long long use_counter = 0;
59 59
60static LK(cache_lock); 60static SLK(cache_lock);
61static Eina_Inlist *cache_list = NULL; 61static Eina_Inlist *cache_list = NULL;
62static unsigned int cache_size = 0; 62static unsigned int cache_size = 0;
63static int init = 0; 63static int init = 0;
@@ -121,7 +121,7 @@ evas_common_scalecache_init(void)
121 init++; 121 init++;
122 if (init > 1) return; 122 if (init > 1) return;
123 use_counter = 0; 123 use_counter = 0;
124 LKI(cache_lock); 124 SLKI(cache_lock);
125 s = getenv("EVAS_SCALECACHE_SIZE"); 125 s = getenv("EVAS_SCALECACHE_SIZE");
126 if (s) max_cache_size = atoi(s) * 1024; 126 if (s) max_cache_size = atoi(s) * 1024;
127 s = getenv("EVAS_SCALECACHE_MAX_DIMENSION"); 127 s = getenv("EVAS_SCALECACHE_MAX_DIMENSION");
@@ -141,7 +141,7 @@ evas_common_scalecache_shutdown(void)
141#ifdef SCALECACHE 141#ifdef SCALECACHE
142 init--; 142 init--;
143 if (init ==0) 143 if (init ==0)
144 LKD(cache_lock); 144 SLKD(cache_lock);
145#endif 145#endif
146} 146}
147 147
@@ -151,7 +151,7 @@ evas_common_rgba_image_scalecache_init(Image_Entry *ie)
151#ifdef SCALECACHE 151#ifdef SCALECACHE
152 RGBA_Image *im = (RGBA_Image *)ie; 152 RGBA_Image *im = (RGBA_Image *)ie;
153 // NOTE: this conflicts with evas image cache init and del of lock 153 // NOTE: this conflicts with evas image cache init and del of lock
154 LKI(im->cache.lock); 154 SLKI(im->cache.lock);
155#endif 155#endif
156} 156}
157 157
@@ -162,7 +162,7 @@ evas_common_rgba_image_scalecache_shutdown(Image_Entry *ie)
162 RGBA_Image *im = (RGBA_Image *)ie; 162 RGBA_Image *im = (RGBA_Image *)ie;
163 evas_common_rgba_image_scalecache_dirty(ie); 163 evas_common_rgba_image_scalecache_dirty(ie);
164 // NOTE: this conflicts with evas image cache init and del of lock 164 // NOTE: this conflicts with evas image cache init and del of lock
165 LKD(im->cache.lock); 165 SLKD(im->cache.lock);
166#endif 166#endif
167} 167}
168 168
@@ -172,7 +172,7 @@ evas_common_rgba_image_scalecache_dirty(Image_Entry *ie)
172#ifdef SCALECACHE 172#ifdef SCALECACHE
173 RGBA_Image *im = (RGBA_Image *)ie; 173 RGBA_Image *im = (RGBA_Image *)ie;
174 174
175 LKL(im->cache.lock); 175 SLKL(im->cache.lock);
176 while (im->cache.list) 176 while (im->cache.list)
177 { 177 {
178 Scaleitem *sci = im->cache.list->data; 178 Scaleitem *sci = im->cache.list->data;
@@ -180,7 +180,7 @@ evas_common_rgba_image_scalecache_dirty(Image_Entry *ie)
180 im->cache.list = eina_list_remove(im->cache.list, sci); 180 im->cache.list = eina_list_remove(im->cache.list, sci);
181 if ((sci->im) && (sci->im->cache_entry.references == 0)) 181 if ((sci->im) && (sci->im->cache_entry.references == 0))
182 { 182 {
183 LKL(cache_lock); 183 SLKL(cache_lock);
184 184
185 evas_common_rgba_image_free(&sci->im->cache_entry); 185 evas_common_rgba_image_free(&sci->im->cache_entry);
186 sci->im = NULL; 186 sci->im = NULL;
@@ -191,7 +191,7 @@ evas_common_rgba_image_scalecache_dirty(Image_Entry *ie)
191 cache_size -= sci->size_adjust; 191 cache_size -= sci->size_adjust;
192 cache_list = eina_inlist_remove(cache_list, (Eina_Inlist *)sci); 192 cache_list = eina_inlist_remove(cache_list, (Eina_Inlist *)sci);
193 193
194 LKU(cache_lock); 194 SLKU(cache_lock);
195 } 195 }
196 196
197 if (!sci->im) 197 if (!sci->im)
@@ -199,7 +199,7 @@ evas_common_rgba_image_scalecache_dirty(Image_Entry *ie)
199 } 199 }
200 eina_hash_free(im->cache.hash); 200 eina_hash_free(im->cache.hash);
201 im->cache.hash = NULL; 201 im->cache.hash = NULL;
202 LKU(im->cache.lock); 202 SLKU(im->cache.lock);
203#endif 203#endif
204} 204}
205 205
@@ -208,13 +208,13 @@ evas_common_rgba_image_scalecache_orig_use(Image_Entry *ie)
208{ 208{
209#ifdef SCALECACHE 209#ifdef SCALECACHE
210 RGBA_Image *im = (RGBA_Image *)ie; 210 RGBA_Image *im = (RGBA_Image *)ie;
211 LKL(im->cache.lock); 211 SLKL(im->cache.lock);
212 use_counter++; 212 use_counter++;
213 // FIXME: if orig not loaded, reload 213 // FIXME: if orig not loaded, reload
214 // FIXME: mark orig with current used counter 214 // FIXME: mark orig with current used counter
215 im->cache.orig_usage++; 215 im->cache.orig_usage++;
216 im->cache.usage_count = use_counter; 216 im->cache.usage_count = use_counter;
217 LKU(im->cache.lock); 217 SLKU(im->cache.lock);
218#endif 218#endif
219} 219}
220 220
@@ -226,12 +226,12 @@ evas_common_rgba_image_scalecache_usage_get(Image_Entry *ie)
226 int size = 0; 226 int size = 0;
227 Eina_List *l; 227 Eina_List *l;
228 Scaleitem *sci; 228 Scaleitem *sci;
229 LKL(im->cache.lock); 229 SLKL(im->cache.lock);
230 EINA_LIST_FOREACH(im->cache.list, l, sci) 230 EINA_LIST_FOREACH(im->cache.list, l, sci)
231 { 231 {
232 if (sci->im) size += sci->key.dst_w * sci->key.dst_h * 4; 232 if (sci->im) size += sci->key.dst_w * sci->key.dst_h * 4;
233 } 233 }
234 LKU(im->cache.lock); 234 SLKU(im->cache.lock);
235 return size; 235 return size;
236#else 236#else
237 return 0; 237 return 0;
@@ -247,7 +247,7 @@ evas_common_rgba_image_scalecache_items_ref(Image_Entry *ie, Eina_Array *ret)
247 Eina_List *l; 247 Eina_List *l;
248 Scaleitem *sci; 248 Scaleitem *sci;
249 249
250 LKL(im->cache.lock); 250 SLKL(im->cache.lock);
251 EINA_LIST_FOREACH(im->cache.list, l, sci) 251 EINA_LIST_FOREACH(im->cache.list, l, sci)
252 { 252 {
253 if (sci->im) 253 if (sci->im)
@@ -258,7 +258,7 @@ evas_common_rgba_image_scalecache_items_ref(Image_Entry *ie, Eina_Array *ret)
258 eina_array_push(ret, scie); 258 eina_array_push(ret, scie);
259 } 259 }
260 } 260 }
261 LKU(im->cache.lock); 261 SLKU(im->cache.lock);
262#endif 262#endif
263} 263}
264 264
@@ -435,13 +435,13 @@ EAPI void
435evas_common_rgba_image_scalecache_size_set(unsigned int size) 435evas_common_rgba_image_scalecache_size_set(unsigned int size)
436{ 436{
437#ifdef SCALECACHE 437#ifdef SCALECACHE
438 LKL(cache_lock); 438 SLKL(cache_lock);
439 if (size != max_cache_size) 439 if (size != max_cache_size)
440 { 440 {
441 max_cache_size = size; 441 max_cache_size = size;
442 _cache_prune(NULL, 1); 442 _cache_prune(NULL, 1);
443 } 443 }
444 LKU(cache_lock); 444 SLKU(cache_lock);
445#endif 445#endif
446} 446}
447 447
@@ -450,9 +450,9 @@ evas_common_rgba_image_scalecache_size_get(void)
450{ 450{
451#ifdef SCALECACHE 451#ifdef SCALECACHE
452 int t; 452 int t;
453 LKL(cache_lock); 453 SLKL(cache_lock);
454 t = max_cache_size; 454 t = max_cache_size;
455 LKU(cache_lock); 455 SLKU(cache_lock);
456 return t; 456 return t;
457#else 457#else
458 return 0; 458 return 0;
@@ -463,9 +463,9 @@ EAPI void
463evas_common_rgba_image_scalecache_prune(void) 463evas_common_rgba_image_scalecache_prune(void)
464{ 464{
465#ifdef SCALECACHE 465#ifdef SCALECACHE
466 LKL(cache_lock); 466 SLKL(cache_lock);
467 _cache_prune(NULL, 0); 467 _cache_prune(NULL, 0);
468 LKU(cache_lock); 468 SLKU(cache_lock);
469#endif 469#endif
470} 470}
471 471
@@ -474,12 +474,12 @@ evas_common_rgba_image_scalecache_dump(void)
474{ 474{
475#ifdef SCALECACHE 475#ifdef SCALECACHE
476 int t; 476 int t;
477 LKL(cache_lock); 477 SLKL(cache_lock);
478 t = max_cache_size; 478 t = max_cache_size;
479 max_cache_size = 0; 479 max_cache_size = 0;
480 _cache_prune(NULL, 0); 480 _cache_prune(NULL, 0);
481 max_cache_size = t; 481 max_cache_size = t;
482 LKU(cache_lock); 482 SLKU(cache_lock);
483#endif 483#endif
484} 484}
485 485
@@ -488,12 +488,12 @@ evas_common_rgba_image_scalecache_flush(void)
488{ 488{
489#ifdef SCALECACHE 489#ifdef SCALECACHE
490 int t; 490 int t;
491 LKL(cache_lock); 491 SLKL(cache_lock);
492 t = max_cache_size; 492 t = max_cache_size;
493 max_cache_size = 0; 493 max_cache_size = 0;
494 _cache_prune(NULL, 1); 494 _cache_prune(NULL, 1);
495 max_cache_size = t; 495 max_cache_size = t;
496 LKU(cache_lock); 496 SLKU(cache_lock);
497#endif 497#endif
498} 498}
499 499
@@ -513,11 +513,11 @@ evas_common_rgba_image_scalecache_prepare(Image_Entry *ie, RGBA_Image *dst EINA_
513 if (!im->image.data) return; 513 if (!im->image.data) return;
514 if ((dst_region_w == 0) || (dst_region_h == 0) || 514 if ((dst_region_w == 0) || (dst_region_h == 0) ||
515 (src_region_w == 0) || (src_region_h == 0)) return; 515 (src_region_w == 0) || (src_region_h == 0)) return;
516 // was having major lock issues here - LKL was deadlocking. what was 516 // was having major lock issues here - SLKL was deadlocking. what was
517 // going on? it may have been an eina treads badness but this will stay here 517 // going on? it may have been an eina treads badness but this will stay here
518 // for now for debug 518 // for now for debug
519#if 1 519#if 1
520 ret = LKT(im->cache.lock); 520 ret = SLKT(im->cache.lock);
521 if (ret == EINA_FALSE) /* can't get image lock */ 521 if (ret == EINA_FALSE) /* can't get image lock */
522 { 522 {
523 useconds_t slp = 1, slpt = 0; 523 useconds_t slp = 1, slpt = 0;
@@ -531,7 +531,7 @@ evas_common_rgba_image_scalecache_prepare(Image_Entry *ie, RGBA_Image *dst EINA_
531#endif 531#endif
532 slpt += slp; 532 slpt += slp;
533 slp++; 533 slp++;
534 ret = LKT(im->cache.lock); 534 ret = SLKT(im->cache.lock);
535 if (ret == EINA_LOCK_DEADLOCK) 535 if (ret == EINA_LOCK_DEADLOCK)
536 { 536 {
537 printf("WARNING: DEADLOCK on image %p (%s)\n", im, ie->file); 537 printf("WARNING: DEADLOCK on image %p (%s)\n", im, ie->file);
@@ -546,7 +546,7 @@ evas_common_rgba_image_scalecache_prepare(Image_Entry *ie, RGBA_Image *dst EINA_
546 { 546 {
547 printf("WARNING: lock still there after %i usec\n", slpt); 547 printf("WARNING: lock still there after %i usec\n", slpt);
548 printf("WARNING: stucklock on image %p (%s)\n", im, ie->file); 548 printf("WARNING: stucklock on image %p (%s)\n", im, ie->file);
549 LKDBG(im->cache.lock); 549 /* SLKDBG(im->cache.lock); */
550 } 550 }
551 } 551 }
552 else if (ret == EINA_LOCK_DEADLOCK) 552 else if (ret == EINA_LOCK_DEADLOCK)
@@ -555,14 +555,14 @@ evas_common_rgba_image_scalecache_prepare(Image_Entry *ie, RGBA_Image *dst EINA_
555 } 555 }
556 else locked = 1; 556 else locked = 1;
557#endif 557#endif
558 if (!locked) { LKL(im->cache.lock); locked = 1; } 558 if (!locked) { SLKL(im->cache.lock); locked = 1; }
559 use_counter++; 559 use_counter++;
560 if ((src_region_w == dst_region_w) && (src_region_h == dst_region_h)) 560 if ((src_region_w == dst_region_w) && (src_region_h == dst_region_h))
561 { 561 {
562 // 1:1 scale. 562 // 1:1 scale.
563 im->cache.orig_usage++; 563 im->cache.orig_usage++;
564 im->cache.usage_count = use_counter; 564 im->cache.usage_count = use_counter;
565 if (locked) LKU(im->cache.lock); 565 if (locked) SLKU(im->cache.lock);
566 return; 566 return;
567 } 567 }
568 if ((!im->cache_entry.flags.alpha) && (!smooth)) 568 if ((!im->cache_entry.flags.alpha) && (!smooth))
@@ -571,17 +571,17 @@ evas_common_rgba_image_scalecache_prepare(Image_Entry *ie, RGBA_Image *dst EINA_
571 // or in some cases faster not cached 571 // or in some cases faster not cached
572 im->cache.orig_usage++; 572 im->cache.orig_usage++;
573 im->cache.usage_count = use_counter; 573 im->cache.usage_count = use_counter;
574 if (locked) LKU(im->cache.lock); 574 if (locked) SLKU(im->cache.lock);
575 return; 575 return;
576 } 576 }
577 LKL(cache_lock); 577 SLKL(cache_lock);
578 sci = _sci_find(im, dc, smooth, 578 sci = _sci_find(im, dc, smooth,
579 src_region_x, src_region_y, src_region_w, src_region_h, 579 src_region_x, src_region_y, src_region_w, src_region_h,
580 dst_region_w, dst_region_h); 580 dst_region_w, dst_region_h);
581 if (!sci) 581 if (!sci)
582 { 582 {
583 LKU(cache_lock); 583 SLKU(cache_lock);
584 if (locked) LKU(im->cache.lock); 584 if (locked) SLKU(im->cache.lock);
585 return; 585 return;
586 } 586 }
587// INF("%10i | %4i %4i %4ix%4i -> %4i %4i %4ix%4i | %i", 587// INF("%10i | %4i %4i %4ix%4i -> %4i %4i %4ix%4i | %i",
@@ -609,7 +609,7 @@ evas_common_rgba_image_scalecache_prepare(Image_Entry *ie, RGBA_Image *dst EINA_
609 } 609 }
610 sci->usage++; 610 sci->usage++;
611 sci->usage_count = use_counter; 611 sci->usage_count = use_counter;
612 LKU(cache_lock); 612 SLKU(cache_lock);
613 if (sci->usage > im->cache.newest_usage) 613 if (sci->usage > im->cache.newest_usage)
614 im->cache.newest_usage = sci->usage; 614 im->cache.newest_usage = sci->usage;
615// INF("newset? %p %i > %i", im, 615// INF("newset? %p %i > %i", im,
@@ -618,7 +618,7 @@ evas_common_rgba_image_scalecache_prepare(Image_Entry *ie, RGBA_Image *dst EINA_
618 if (sci->usage_count > im->cache.newest_usage_count) 618 if (sci->usage_count > im->cache.newest_usage_count)
619 im->cache.newest_usage_count = sci->usage_count; 619 im->cache.newest_usage_count = sci->usage_count;
620// INF(" -------------- used %8i#, %8i@", (int)sci->usage, (int)sci->usage_count); 620// INF(" -------------- used %8i#, %8i@", (int)sci->usage, (int)sci->usage_count);
621 if (locked) LKU(im->cache.lock); 621 if (locked) SLKU(im->cache.lock);
622#endif 622#endif
623} 623}
624 624
@@ -682,11 +682,11 @@ evas_common_rgba_image_scalecache_do_cbs(Image_Entry *ie, RGBA_Image *dst,
682 } 682 }
683 return EINA_FALSE; 683 return EINA_FALSE;
684 } 684 }
685 LKL(cache_lock); 685 SLKL(cache_lock);
686 sci = _sci_find(im, dc, smooth, 686 sci = _sci_find(im, dc, smooth,
687 src_region_x, src_region_y, src_region_w, src_region_h, 687 src_region_x, src_region_y, src_region_w, src_region_h,
688 dst_region_w, dst_region_h); 688 dst_region_w, dst_region_h);
689 LKU(cache_lock); 689 SLKU(cache_lock);
690 if (!sci) 690 if (!sci)
691 { 691 {
692 if (im->cache_entry.space == EVAS_COLORSPACE_ARGB8888) 692 if (im->cache_entry.space == EVAS_COLORSPACE_ARGB8888)
@@ -718,7 +718,7 @@ evas_common_rgba_image_scalecache_do_cbs(Image_Entry *ie, RGBA_Image *dst,
718 } 718 }
719 return EINA_FALSE; 719 return EINA_FALSE;
720 } 720 }
721 LKL(im->cache.lock); 721 SLKL(im->cache.lock);
722 if (sci->populate_me) 722 if (sci->populate_me)
723 { 723 {
724 int size, osize, used; 724 int size, osize, used;
@@ -768,7 +768,7 @@ evas_common_rgba_image_scalecache_do_cbs(Image_Entry *ie, RGBA_Image *dst,
768 { 768 {
769 static RGBA_Draw_Context *ct = NULL; 769 static RGBA_Draw_Context *ct = NULL;
770 770
771 LKL(cache_lock); 771 SLKL(cache_lock);
772 im->cache.orig_usage++; 772 im->cache.orig_usage++;
773 im->cache.usage_count = use_counter; 773 im->cache.usage_count = use_counter;
774 im->cache.populate_count--; 774 im->cache.populate_count--;
@@ -780,7 +780,7 @@ evas_common_rgba_image_scalecache_do_cbs(Image_Entry *ie, RGBA_Image *dst,
780 ct = evas_common_draw_context_new(); 780 ct = evas_common_draw_context_new();
781 evas_common_draw_context_set_render_op(ct, _EVAS_RENDER_COPY); 781 evas_common_draw_context_set_render_op(ct, _EVAS_RENDER_COPY);
782 } 782 }
783 LKU(im->cache.lock); 783 SLKU(im->cache.lock);
784 if (im->cache_entry.space == EVAS_COLORSPACE_ARGB8888) 784 if (im->cache_entry.space == EVAS_COLORSPACE_ARGB8888)
785 { 785 {
786#ifdef EVAS_CSERVE2 786#ifdef EVAS_CSERVE2
@@ -790,7 +790,7 @@ evas_common_rgba_image_scalecache_do_cbs(Image_Entry *ie, RGBA_Image *dst,
790#endif 790#endif
791 evas_cache_image_load_data(&im->cache_entry); 791 evas_cache_image_load_data(&im->cache_entry);
792 } 792 }
793 LKL(im->cache.lock); 793 SLKL(im->cache.lock);
794 evas_common_image_colorspace_normalize(im); 794 evas_common_image_colorspace_normalize(im);
795 if (im->image.data) 795 if (im->image.data)
796 { 796 {
@@ -845,7 +845,7 @@ evas_common_rgba_image_scalecache_do_cbs(Image_Entry *ie, RGBA_Image *dst,
845// sci->dst_w * sci->dst_h * 4, sci->flop, 845// sci->dst_w * sci->dst_h * 4, sci->flop,
846// sci->dst_w, sci->dst_h); 846// sci->dst_w, sci->dst_h);
847 cache_list = eina_inlist_append(cache_list, (Eina_Inlist *)sci); 847 cache_list = eina_inlist_append(cache_list, (Eina_Inlist *)sci);
848 LKU(cache_lock); 848 SLKU(cache_lock);
849 didpop = 1; 849 didpop = 1;
850 } 850 }
851 } 851 }
@@ -853,17 +853,17 @@ evas_common_rgba_image_scalecache_do_cbs(Image_Entry *ie, RGBA_Image *dst,
853 { 853 {
854 if (!didpop) 854 if (!didpop)
855 { 855 {
856 LKL(cache_lock); 856 SLKL(cache_lock);
857 cache_list = eina_inlist_remove(cache_list, (Eina_Inlist *)sci); 857 cache_list = eina_inlist_remove(cache_list, (Eina_Inlist *)sci);
858 cache_list = eina_inlist_append(cache_list, (Eina_Inlist *)sci); 858 cache_list = eina_inlist_append(cache_list, (Eina_Inlist *)sci);
859 LKU(cache_lock); 859 SLKU(cache_lock);
860 } 860 }
861 else 861 else
862 { 862 {
863 if (sci->flop >= FLOP_DEL) sci->flop -= FLOP_DEL; 863 if (sci->flop >= FLOP_DEL) sci->flop -= FLOP_DEL;
864 } 864 }
865// INF("use cached!"); 865// INF("use cached!");
866 LKU(im->cache.lock); 866 SLKU(im->cache.lock);
867 ret |= cb_sample(sci->im, dst, dc, 867 ret |= cb_sample(sci->im, dst, dc,
868 0, 0, 868 0, 0,
869 dst_region_w, dst_region_h, 869 dst_region_w, dst_region_h,
@@ -909,7 +909,7 @@ evas_common_rgba_image_scalecache_do_cbs(Image_Entry *ie, RGBA_Image *dst,
909 } 909 }
910 else 910 else
911 { 911 {
912 LKU(im->cache.lock); 912 SLKU(im->cache.lock);
913 if (im->cache_entry.space == EVAS_COLORSPACE_ARGB8888) 913 if (im->cache_entry.space == EVAS_COLORSPACE_ARGB8888)
914 { 914 {
915#ifdef EVAS_CSERVE2 915#ifdef EVAS_CSERVE2