Enlightenment CVS committal

Author  : raster
Project : e17
Module  : libs/edje

Dir     : e17/libs/edje/src/lib


Modified Files:
        edje_cache.c edje_calc.c edje_load.c edje_private.h 
        edje_text.c edje_textblock_styles.c 


Log Message:


cedric's patches.

===================================================================
RCS file: /cvs/e/e17/libs/edje/src/lib/edje_cache.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -3 -r1.10 -r1.11
--- edje_cache.c        6 Mar 2007 12:03:34 -0000       1.10
+++ edje_cache.c        4 Apr 2007 13:25:54 -0000       1.11
@@ -63,6 +63,32 @@
    return edc;
 }
 
+static int
+_edje_font_hash (Edje_File *edf)
+{
+   int count = 0;
+
+   if (edf->font_dir)
+     {
+       Evas_List *l;
+       for (l = edf->font_dir->entries; l; l = evas_list_next (l))
+         {
+            Edje_Font_Directory_Entry  *fnt = l->data;
+            int                        length = strlen (fnt->entry) + 7;
+            char                       *tmp = alloca (length);
+
+            snprintf (tmp, length, "fonts/%s", fnt->entry);
+            fnt->path = evas_stringshare_add (tmp);
+            evas_stringshare_del (fnt->entry);
+            fnt->entry = fnt->path + 6;
+            edf->font_hash = evas_hash_direct_add (edf->font_hash, fnt->entry, 
fnt);
+
+            count++;
+         }
+     }
+   return count;
+}
+
 static Edje_File *
 _edje_file_open(const char *file, const char *coll, int *error_ret, 
Edje_Part_Collection **edc_ret)
 {
@@ -112,18 +138,19 @@
      }
    edf->data = NULL;
    
-   if (!coll)
+   if (coll)
      {
-       eet_close(ef);
-       return edf;
+       edc = _edje_file_coll_open(edf, ef, coll);
+       if (!edc)
+         {
+            *error_ret = EDJE_LOAD_ERROR_UNKNOWN_COLLECTION;
+         }
+       if (edc_ret) *edc_ret = edc;
      }
+
+   edf->font_hash = NULL;
    
-   edc = _edje_file_coll_open(edf, ef, coll);
-   if (!edc)
-     {
-       *error_ret = EDJE_LOAD_ERROR_UNKNOWN_COLLECTION;
-     }
-   if (edc_ret) *edc_ret = edc;
+   _edje_font_hash (edf);
 
    eet_close(ef);
 
===================================================================
RCS file: /cvs/e/e17/libs/edje/src/lib/edje_calc.c,v
retrieving revision 1.95
retrieving revision 1.96
diff -u -3 -r1.95 -r1.96
--- edje_calc.c 31 Mar 2007 10:33:24 -0000      1.95
+++ edje_calc.c 4 Apr 2007 13:25:54 -0000       1.96
@@ -602,7 +602,6 @@
        const char      *font;
        int              size;
        Evas_Coord       tw, th;
-       char             buf[4096];
        int              inlined_font = 0;
 
        /* Update a object_text part */ 
@@ -683,24 +682,14 @@
        if (!text) text = "";
        
         /* check if the font is embedded in the .eet */
-        /* FIXME: we should cache this result */
-        if (ed->file->font_dir)
+        if (ed->file->font_hash)
          {
-            Evas_List *l;
-            
-            for (l = ed->file->font_dir->entries; l; l = l->next)
-              {
-                 Edje_Font_Directory_Entry *fnt = l->data;
+            Edje_Font_Directory_Entry *fnt = evas_hash_find 
(ed->file->font_hash, font);
 
-                 if ((fnt->entry) && (!strcmp(fnt->entry, font)))
-                   {
-                      strcpy(buf, "fonts/");
-                      strncpy(buf + 6, font, sizeof(buf) - 7);
-                      buf[sizeof(buf) - 1] = 0;
-                      font = buf;
-                      inlined_font = 1;
-                      break;
-                   }
+            if (fnt)
+              {
+                 font = fnt->path;
+                 inlined_font = 1;
               }
          }
        if (inlined_font) evas_object_text_font_source_set(ep->object, 
ed->path);
===================================================================
RCS file: /cvs/e/e17/libs/edje/src/lib/edje_load.c,v
retrieving revision 1.99
retrieving revision 1.100
diff -u -3 -r1.99 -r1.100
--- edje_load.c 4 Apr 2007 12:51:51 -0000       1.99
+++ edje_load.c 4 Apr 2007 13:25:54 -0000       1.100
@@ -600,9 +600,10 @@
             Edje_Font_Directory_Entry *fe;
             
             fe = edf->font_dir->entries->data;
-            edf->font_dir->entries = 
+            edf->font_dir->entries =
               evas_list_remove_list(edf->font_dir->entries, 
edf->font_dir->entries);
-            if (fe->entry) evas_stringshare_del(fe->entry);
+            edf->font_hash = evas_hash_del(edf->font_hash, fe->entry, NULL);
+            if (fe->path) evas_stringshare_del(fe->path);
             free(fe);
          }
        free(edf->font_dir);
===================================================================
RCS file: /cvs/e/e17/libs/edje/src/lib/edje_private.h,v
retrieving revision 1.119
retrieving revision 1.120
diff -u -3 -r1.119 -r1.120
--- edje_private.h      4 Apr 2007 12:51:51 -0000       1.119
+++ edje_private.h      4 Apr 2007 13:25:54 -0000       1.120
@@ -221,13 +221,14 @@
    Evas_List                      *data;
    Evas_List                      *styles;
    Evas_List                      *color_classes;
-   
+
    int                             references;
    char                           *compiler;
    int                             version;
    int                             feature_ver;
    
    Evas_Hash                      *collection_hash;
+   Evas_Hash                     *font_hash;
    Evas_List                      *collection_cache;
    Evas_Hash                      *data_cache;
 };
@@ -265,7 +266,8 @@
 
 struct _Edje_Font_Directory_Entry
 {
-   char *entry; /* the name of the font */
+   const char *entry; /* the name of the font */
+   char *path;
 };
 
        
===================================================================
RCS file: /cvs/e/e17/libs/edje/src/lib/edje_text.c,v
retrieving revision 1.58
retrieving revision 1.59
diff -u -3 -r1.58 -r1.59
--- edje_text.c 30 Mar 2007 23:39:41 -0000      1.58
+++ edje_text.c 4 Apr 2007 13:25:54 -0000       1.59
@@ -281,7 +281,6 @@
    int          size;
    Evas_Coord   tw, th;
    Evas_Coord   sw, sh;
-   char                 font_buf[4096];
    int          inlined_font = 0, free_text = 0;
    
 
@@ -309,24 +308,14 @@
    if (!font) font = "";
    
    /* check if the font is embedded in the .eet */
-   /* FIXME: we should cache this result */
-   if (ed->file->font_dir)
+   if (ed->file->font_hash)
      {
-       Evas_List *l;
-       
-       for (l = ed->file->font_dir->entries; l; l = l->next)
+       Edje_Font_Directory_Entry *fnt = evas_hash_find (ed->file->font_hash, 
font);
+
+       if (fnt)
          {
-            Edje_Font_Directory_Entry *fnt = l->data;
-            
-            if ((fnt->entry) && (!strcmp(fnt->entry, font)))
-              {
-                 strcpy(font_buf, "fonts/");
-                 strncpy(font_buf + 6, font, sizeof(font_buf) - 7);
-                 font_buf[sizeof(font_buf) - 1] = 0;
-                 font = font_buf;
-                 inlined_font = 1;
-                 break;
-              }
+            font = fnt->path;
+            inlined_font = 1;
          }
      }
 
===================================================================
RCS file: /cvs/e/e17/libs/edje/src/lib/edje_textblock_styles.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -3 -r1.9 -r1.10
--- edje_textblock_styles.c     3 Jul 2006 06:15:05 -0000       1.9
+++ edje_textblock_styles.c     4 Apr 2007 13:25:54 -0000       1.10
@@ -8,17 +8,14 @@
 static int
 _edje_font_is_embedded(Edje_File *edf, char *font)
 {
-   Evas_List *l;
+   Edje_Font_Directory_Entry *fnt = NULL;
    
    if (!edf->font_dir) return 0;
-   for (l = edf->font_dir->entries; l; l = l->next)
-     {
-       Edje_Font_Directory_Entry *fnt = l->data;
-       
-       if ((fnt->entry) && (!strcmp(fnt->entry, font)))
-         return 1;
-     }
-   return 1;
+/*    fnt = evas_hash_find (edf->font_hash, font); */
+/*    if (fnt) */
+/*      if (fnt->entry && (!strcmp(fnt->entry, font))) */
+/*        return 1; */
+     return 1;
 }
 
 #if 0



-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
enlightenment-cvs mailing list
enlightenment-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to