cedric's patches.

SVN revision: 29353
This commit is contained in:
Carsten Haitzler 2007-04-04 13:25:55 +00:00
parent e0b17ee4ee
commit a9daf7dd89
7 changed files with 121 additions and 81 deletions

View File

@ -63,6 +63,32 @@ _edje_file_coll_open(Edje_File *edf, Eet_File *ef, const char *coll)
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 @@ _edje_file_open(const char *file, const char *coll, int *error_ret, Edje_Part_Co
}
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);

View File

@ -602,7 +602,6 @@ _edje_part_recalc_single(Edje *ed,
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 @@ _edje_part_recalc_single(Edje *ed,
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);

View File

@ -600,9 +600,10 @@ _edje_file_free(Edje_File *edf)
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);

View File

@ -221,13 +221,14 @@ struct _Edje_File
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
struct _Edje_Font_Directory_Entry
{
char *entry; /* the name of the font */
const char *entry; /* the name of the font */
char *path;
};

View File

@ -281,7 +281,6 @@ _edje_text_recalc_apply(Edje *ed, Edje_Real_Part *ep,
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 @@ _edje_text_recalc_apply(Edje *ed, Edje_Real_Part *ep,
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;
}
}

View File

@ -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

View File

@ -81,16 +81,24 @@ evas_common_tilebuf_add_redraw(Tilebuf *tb, int x, int y, int w, int h)
if (tilebuf_x_intersect(tb, x, w, &tx1, &tx2, &tfx1, &tfx2) &&
tilebuf_y_intersect(tb, y, h, &ty1, &ty2, &tfy1, &tfy2))
{
for (yy = ty1; yy <= ty2; yy++)
{
Tilebuf_Tile *tbt;
Tilebuf_Tile *tbt;
int delta_x;
int delta_y;
tbt = &(TILE(tb, tx1, yy));
for (xx = tx1; xx <= tx2; xx++)
tbt = &(TILE(tb, tx1, ty1));
delta_x = tx2 - tx1 + 1;
delta_y = ty2 - ty1 + 1;
for (yy = delta_y; yy > 0; yy--)
{
Tilebuf_Tile *tbti;
tbti = tbt;
for (xx = delta_x; xx > 0; xx--)
{
tbt->redraw = 1;
tbt++;
tbti->redraw = 1;
tbti++;
}
tbt += tb->tiles.w;
}
num = (tx2 - tx1 + 1) * (ty2 - ty1 + 1);
}
@ -115,20 +123,29 @@ evas_common_tilebuf_del_redraw(Tilebuf *tb, int x, int y, int w, int h)
if (tilebuf_x_intersect(tb, x, w, &tx1, &tx2, &tfx1, &tfx2) &&
tilebuf_y_intersect(tb, y, h, &ty1, &ty2, &tfy1, &tfy2))
{
if (!tfx1) tx1++;
Tilebuf_Tile *tbt;
int delta_y;
int delta_x;
if (!tfx1) tx1++;
if (!tfx2) tx2--;
if (!tfy1) ty1++;
if (!tfy2) ty2--;
for (yy = ty1; yy <= ty2; yy++)
{
Tilebuf_Tile *tbt;
tbt = &(TILE(tb, tx1, yy));
for (xx = tx1; xx <= tx2; xx++)
tbt = &(TILE(tb, tx1, ty1));
delta_x = tx2 - tx1 + 1;
delta_y = ty2 - ty1 + 1;
for (yy = delta_y; yy > 0; yy--)
{
Tilebuf_Tile *tbti;
tbti = tbt;
for (xx = delta_x; xx > 0; xx--)
{
tbt->redraw = 0;
tbt++;
tbti->redraw = 0;
tbti++;
}
tbt += tb->tiles.w;
}
num = (tx2 - tx1 + 1) * (ty2 - ty1 + 1);
}
@ -166,42 +183,56 @@ evas_common_tilebuf_get_render_rects(Tilebuf *tb)
return evas_common_regionbuf_rects_get(tb->rb);
#else
Tilebuf_Rect *rects = NULL;
Tilebuf_Tile *tbt;
int x, y;
tbt = &(TILE(tb, 0, 0));
for (y = 0; y < tb->tiles.h; y++)
{
for (x = 0; x < tb->tiles.w; x++)
for (x = 0; x < tb->tiles.w; x++, tbt++)
{
if (TILE(tb, x, y).redraw)
if (tbt->redraw)
{
Tilebuf_Tile *tbti;
int can_expand_x = 1, can_expand_y = 1;
Tilebuf_Rect *r = NULL;
int xx = 0, yy = 0;
r = calloc(1, sizeof(Tilebuf_Rect));
r = malloc(sizeof(Tilebuf_Rect));
r->_list_data.next = NULL;
r->_list_data.prev = NULL;
r->_list_data.last = NULL;
/* amalgamate tiles */
#if 1
tbti = tbt;
while (can_expand_x)
{
tbti++;
xx++;
if ((x + xx) >= tb->tiles.w)
can_expand_x = 0;
else if (!(TILE(tb, x + xx, y).redraw))
else if (!(tbti->redraw))
can_expand_x = 0;
if (can_expand_x)
TILE(tb, x + xx, y).redraw = 0;
tbti->redraw = 0;
}
tbti = tbt;
while (can_expand_y)
{
int i;
tbti += tb->tiles.w;
yy++;
if ((y + yy) >= tb->tiles.h)
can_expand_y = 0;
if (can_expand_y)
{
for (i = x; i < x + xx; i++)
Tilebuf_Tile *tbtj;
tbtj = tbti;
for (i = x; i < x + xx; i++, tbtj++)
{
if (!(TILE(tb, i, y + yy).redraw))
if (!(tbtj->redraw))
{
can_expand_y = 0;
break;
@ -210,11 +241,14 @@ evas_common_tilebuf_get_render_rects(Tilebuf *tb)
}
if (can_expand_y)
{
for (i = x; i < x + xx; i++)
TILE(tb, i, y + yy).redraw = 0;
Tilebuf_Tile *tbtj;
tbtj = tbti;
for (i = x; i < x + xx; i++, tbtj++)
tbtj->redraw = 0;
}
}
TILE(tb, x, y).redraw = 0;
tbt->redraw = 0;
#else
xx = 1;
yy = 1;
@ -225,6 +259,7 @@ evas_common_tilebuf_get_render_rects(Tilebuf *tb)
r->h = (yy) * tb->tile_size.h;
rects = evas_object_list_append(rects, r);
x = x + (xx - 1);
tbt += xx - 1;
}
}
}