summaryrefslogtreecommitdiff
path: root/legacy/evas/src/lib/engines
diff options
context:
space:
mode:
authorCarsten Haitzler <raster@rasterman.com>2012-06-28 10:13:05 +0000
committerCarsten Haitzler <raster@rasterman.com>2012-06-28 10:13:05 +0000
commit6d605629cafb9e7c6bb4c923624e16062d2dee48 (patch)
treec80c45d52a2f00df20c45afc8c2752b231e198fc /legacy/evas/src/lib/engines
parentc6f644fbe088bb67a6557c729eb99995192b8240 (diff)
fix refcounting issue with font instances.
SVN revision: 72990
Diffstat (limited to 'legacy/evas/src/lib/engines')
-rw-r--r--legacy/evas/src/lib/engines/common/evas_font.h1
-rw-r--r--legacy/evas/src/lib/engines/common/evas_font_load.c108
-rw-r--r--legacy/evas/src/lib/engines/common/evas_text_utils.c18
3 files changed, 66 insertions, 61 deletions
diff --git a/legacy/evas/src/lib/engines/common/evas_font.h b/legacy/evas/src/lib/engines/common/evas_font.h
index 3769b13975..313c23e9b7 100644
--- a/legacy/evas/src/lib/engines/common/evas_font.h
+++ b/legacy/evas/src/lib/engines/common/evas_font.h
@@ -42,6 +42,7 @@ EAPI RGBA_Font *evas_common_font_load (const char *name,
42EAPI RGBA_Font *evas_common_font_add (RGBA_Font *fn, const char *name, int size, Font_Rend_Flags wanted_rend); 42EAPI RGBA_Font *evas_common_font_add (RGBA_Font *fn, const char *name, int size, Font_Rend_Flags wanted_rend);
43EAPI RGBA_Font *evas_common_font_memory_add (RGBA_Font *fn, const char *source, const char *name, int size, const void *data, int data_size, Font_Rend_Flags wanted_rend); 43EAPI RGBA_Font *evas_common_font_memory_add (RGBA_Font *fn, const char *source, const char *name, int size, const void *data, int data_size, Font_Rend_Flags wanted_rend);
44EAPI void evas_common_font_free (RGBA_Font *fn); 44EAPI void evas_common_font_free (RGBA_Font *fn);
45EAPI void evas_common_font_int_unref (RGBA_Font_Int *fi);
45EAPI void evas_common_font_hinting_set (RGBA_Font *fn, Font_Hint_Flags hinting); 46EAPI void evas_common_font_hinting_set (RGBA_Font *fn, Font_Hint_Flags hinting);
46EAPI Eina_Bool evas_common_hinting_available (Font_Hint_Flags hinting); 47EAPI Eina_Bool evas_common_hinting_available (Font_Hint_Flags hinting);
47EAPI RGBA_Font *evas_common_font_memory_hinting_load (const char *source, const char *name, int size, const void *data, int data_size, Font_Hint_Flags hinting, Font_Rend_Flags wanted_rend); 48EAPI RGBA_Font *evas_common_font_memory_hinting_load (const char *source, const char *name, int size, const void *data, int data_size, Font_Hint_Flags hinting, Font_Rend_Flags wanted_rend);
diff --git a/legacy/evas/src/lib/engines/common/evas_font_load.c b/legacy/evas/src/lib/engines/common/evas_font_load.c
index 2307fde8df..4024565760 100644
--- a/legacy/evas/src/lib/engines/common/evas_font_load.c
+++ b/legacy/evas/src/lib/engines/common/evas_font_load.c
@@ -80,7 +80,7 @@ _evas_common_font_int_free(RGBA_Font_Int *fi)
80 hb_font_destroy(fi->ft.hb_font); 80 hb_font_destroy(fi->ft.hb_font);
81#endif 81#endif
82 evas_common_font_source_free(fi->src); 82 evas_common_font_source_free(fi->src);
83 if (fi->references == 0) fonts_lru = eina_list_remove(fonts_lru, fi); 83 if (fi->references <= 0) fonts_lru = eina_list_remove(fonts_lru, fi);
84 if (fi->fash) fi->fash->freeme(fi->fash); 84 if (fi->fash) fi->fash->freeme(fi->fash);
85 if (fi->inuse) 85 if (fi->inuse)
86 { 86 {
@@ -509,13 +509,7 @@ evas_common_font_memory_load(const char *source, const char *name, int size, con
509 fn = calloc(1, sizeof(RGBA_Font)); 509 fn = calloc(1, sizeof(RGBA_Font));
510 if (!fn) 510 if (!fn)
511 { 511 {
512 fi->references--; 512 evas_common_font_int_unref(fi);
513 if (fi->references == 0)
514 {
515 fonts_lru = eina_list_prepend(fonts_lru, fi);
516 evas_common_font_int_modify_cache_by(fi, 1);
517 evas_common_font_flush();
518 }
519 return NULL; 513 return NULL;
520 } 514 }
521 fn->fonts = eina_list_append(fn->fonts, fi); 515 fn->fonts = eina_list_append(fn->fonts, fi);
@@ -552,13 +546,7 @@ evas_common_font_load(const char *name, int size, Font_Rend_Flags wanted_rend)
552 { 546 {
553 if (evas_common_font_source_load_complete(fi->src)) 547 if (evas_common_font_source_load_complete(fi->src))
554 { 548 {
555 fi->references--; 549 evas_common_font_int_unref(fi);
556 if (fi->references == 0)
557 {
558 fonts_lru = eina_list_prepend(fonts_lru, fi);
559 evas_common_font_int_modify_cache_by(fi, 1);
560 evas_common_font_flush();
561 }
562 return NULL; 550 return NULL;
563 } 551 }
564 } 552 }
@@ -567,13 +555,7 @@ evas_common_font_load(const char *name, int size, Font_Rend_Flags wanted_rend)
567 fn = calloc(1, sizeof(RGBA_Font)); 555 fn = calloc(1, sizeof(RGBA_Font));
568 if (!fn) 556 if (!fn)
569 { 557 {
570 fi->references--; 558 evas_common_font_int_unref(fi);
571 if (fi->references == 0)
572 {
573 fonts_lru = eina_list_prepend(fonts_lru, fi);
574 evas_common_font_int_modify_cache_by(fi, 1);
575 evas_common_font_flush();
576 }
577 return NULL; 559 return NULL;
578 } 560 }
579 561
@@ -637,6 +619,18 @@ evas_common_font_memory_add(RGBA_Font *fn, const char *source, const char *name,
637} 619}
638 620
639EAPI void 621EAPI void
622evas_common_font_int_unref(RGBA_Font_Int *fi)
623{
624 fi->references--;
625 if (fi->references == 0)
626 {
627 fonts_lru = eina_list_append(fonts_lru, fi);
628 evas_common_font_int_modify_cache_by(fi, 1);
629 evas_common_font_flush();
630 }
631}
632
633EAPI void
640evas_common_font_free(RGBA_Font *fn) 634evas_common_font_free(RGBA_Font *fn)
641{ 635{
642 Eina_List *l; 636 Eina_List *l;
@@ -646,14 +640,7 @@ evas_common_font_free(RGBA_Font *fn)
646 fn->references--; 640 fn->references--;
647 if (fn->references > 0) return; 641 if (fn->references > 0) return;
648 EINA_LIST_FOREACH(fn->fonts, l, fi) 642 EINA_LIST_FOREACH(fn->fonts, l, fi)
649 { 643 evas_common_font_int_unref(fi);
650 fi->references--;
651 if (fi->references == 0)
652 {
653 fonts_lru = eina_list_append(fonts_lru, fi);
654 evas_common_font_int_modify_cache_by(fi, 1);
655 }
656 }
657 evas_common_font_flush(); 644 evas_common_font_flush();
658 eina_list_free(fn->fonts); 645 eina_list_free(fn->fonts);
659 if (fn->fash) fn->fash->freeme(fn->fash); 646 if (fn->fash) fn->fash->freeme(fn->fash);
@@ -758,37 +745,40 @@ _evas_common_font_int_clear(RGBA_Font_Int *fi)
758 return; 745 return;
759 } 746 }
760 evas_common_font_int_modify_cache_by(fi, -1); 747 evas_common_font_int_modify_cache_by(fi, -1);
761 if (fi->fash) 748 if (fi->references <= 1)
762 { 749 {
763 for (k = 0; k <= 0xff; k++) // 24bits for unicode - v6 up to E01EF (chrs) & 10FFFD for private use (plane 16) 750 if (fi->fash)
764 { 751 {
765 Fash_Glyph_Map2 *fmap2 = fi->fash->bucket[k]; 752 for (k = 0; k <= 0xff; k++) // 24bits for unicode - v6 up to E01EF (chrs) & 10FFFD for private use (plane 16)
766 if (fmap2) 753 {
767 { 754 Fash_Glyph_Map2 *fmap2 = fi->fash->bucket[k];
768 for (j = 0; j <= 0xff; j++) // 24bits for unicode - v6 up to E01EF (chrs) & 10FFFD for private use (plane 16) 755 if (fmap2)
769 {
770 Fash_Glyph_Map *fmap = fmap2->bucket[j];
771 if (fmap)
772 { 756 {
773 for (i = 0; i <= 0xff; i++) 757 for (j = 0; j <= 0xff; j++) // 24bits for unicode - v6 up to E01EF (chrs) & 10FFFD for private use (plane 16)
774 { 758 {
775 RGBA_Font_Glyph *fg = fmap->item[i]; 759 Fash_Glyph_Map *fmap = fmap2->bucket[j];
776 if ((fg) && (fg != (void *)(-1))) 760 if (fmap)
777 { 761 {
778 FT_Done_Glyph(fg->glyph); 762 for (i = 0; i <= 0xff; i++)
779 /* extension calls */ 763 {
780 if (fg->ext_dat_free) fg->ext_dat_free(fg->ext_dat); 764 RGBA_Font_Glyph *fg = fmap->item[i];
781 if (fg->glyph_out_free) fg->glyph_out_free(fg->glyph_out); 765 if ((fg) && (fg != (void *)(-1)))
782 free(fg); 766 {
783 fmap->item[i] = NULL; 767 FT_Done_Glyph(fg->glyph);
784 } 768 /* extension calls */
785 } 769 if (fg->ext_dat_free) fg->ext_dat_free(fg->ext_dat);
770 if (fg->glyph_out_free) fg->glyph_out_free(fg->glyph_out);
771 free(fg);
772 fmap->item[i] = NULL;
773 }
774 }
775 }
776 }
786 } 777 }
787 } 778 }
788 } 779 fi->fash->freeme(fi->fash);
789 } 780 fi->fash = NULL;
790 fi->fash->freeme(fi->fash); 781 }
791 fi->fash = NULL;
792 } 782 }
793 if (fi->inuse) fonts_use_usage -= fi->usage; 783 if (fi->inuse) fonts_use_usage -= fi->usage;
794 fi->usage = 0; 784 fi->usage = 0;
diff --git a/legacy/evas/src/lib/engines/common/evas_text_utils.c b/legacy/evas/src/lib/engines/common/evas_text_utils.c
index dca75f6cd3..c1c1a2335e 100644
--- a/legacy/evas/src/lib/engines/common/evas_text_utils.c
+++ b/legacy/evas/src/lib/engines/common/evas_text_utils.c
@@ -47,6 +47,8 @@ evas_common_text_props_content_ref(Evas_Text_Props *props)
47 return; 47 return;
48 48
49 props->info->refcount++; 49 props->info->refcount++;
50 if (props->font_instance)
51 ((RGBA_Font_Int *)props->font_instance)->references++;
50} 52}
51 53
52void 54void
@@ -56,6 +58,12 @@ evas_common_text_props_content_unref(Evas_Text_Props *props)
56 if (!props->info) 58 if (!props->info)
57 return; 59 return;
58 60
61 if (props->font_instance)
62 {
63 evas_common_font_int_unref(props->font_instance);
64 props->font_instance = NULL;
65 }
66
59 if (--(props->info->refcount) == 0) 67 if (--(props->info->refcount) == 0)
60 { 68 {
61 if (props->bin) 69 if (props->bin)
@@ -478,8 +486,14 @@ evas_common_text_props_content_create(void *_fi, const Eina_Unicode *text,
478 } 486 }
479 text_props->info = calloc(1, sizeof(Evas_Text_Props_Info)); 487 text_props->info = calloc(1, sizeof(Evas_Text_Props_Info));
480 488
481 text_props->font_instance = fi; 489 if (text_props->font_instance != fi)
482 490 {
491 if (text_props->font_instance)
492 evas_common_font_int_unref(text_props->font_instance);
493 text_props->font_instance = fi;
494 fi->references++;
495 }
496
483 evas_common_font_int_reload(fi); 497 evas_common_font_int_reload(fi);
484 if (fi->src->current_size != fi->size) 498 if (fi->src->current_size != fi->size)
485 { 499 {