forked from enlightenment/efl
evas vg: Add FIXME and fix strbuf use
This is the result of a really quick review of the new VG code. Most of it was moved around, but this merge includes the following: - Move logic from edje to evas - Create static lib for common VG handling - Add file_set() API - Add a basic VG cache in evas side - Add savers modules, implement loaders and savers.
This commit is contained in:
parent
8329c98d5f
commit
ec1acca74d
|
@ -1267,7 +1267,7 @@ data_write_vectors(Eet_File *ef, int *vector_num)
|
||||||
char *s;
|
char *s;
|
||||||
Eina_File *f = NULL;
|
Eina_File *f = NULL;
|
||||||
Edje_Vector_Directory_Entry *vector;
|
Edje_Vector_Directory_Entry *vector;
|
||||||
char buf[100];
|
Eina_Strbuf *buf;
|
||||||
Eina_Bool found = EINA_FALSE;
|
Eina_Bool found = EINA_FALSE;
|
||||||
Ecore_Evas *ee;
|
Ecore_Evas *ee;
|
||||||
Evas *evas;
|
Evas *evas;
|
||||||
|
@ -1281,7 +1281,7 @@ data_write_vectors(Eet_File *ef, int *vector_num)
|
||||||
error_and_abort(ef, "Cannot create buffer engine canvas for image load.");
|
error_and_abort(ef, "Cannot create buffer engine canvas for image load.");
|
||||||
evas = ecore_evas_get(ee);
|
evas = ecore_evas_get(ee);
|
||||||
vg = evas_object_vg_add(evas);
|
vg = evas_object_vg_add(evas);
|
||||||
|
buf = eina_strbuf_new();
|
||||||
for (i = 0; i < edje_file->image_dir->vectors_count; i++)
|
for (i = 0; i < edje_file->image_dir->vectors_count; i++)
|
||||||
{
|
{
|
||||||
if (!beta)
|
if (!beta)
|
||||||
|
@ -1290,18 +1290,18 @@ data_write_vectors(Eet_File *ef, int *vector_num)
|
||||||
vector = &edje_file->image_dir->vectors[i];
|
vector = &edje_file->image_dir->vectors[i];
|
||||||
EINA_LIST_FOREACH(img_dirs, ll, s)
|
EINA_LIST_FOREACH(img_dirs, ll, s)
|
||||||
{
|
{
|
||||||
sprintf(buf, "%s/%s", s, vector->entry);
|
eina_strbuf_reset(buf);
|
||||||
|
eina_strbuf_append_printf(buf, "%s" EINA_PATH_SEP_S "%s", s, vector->entry);
|
||||||
f = eina_file_open(buf, EINA_FALSE);
|
f = eina_file_open(eina_strbuf_string_get(buf), EINA_FALSE);
|
||||||
if (!f) continue;
|
if (!f) continue;
|
||||||
eina_file_close(f);
|
eina_file_close(f);
|
||||||
|
|
||||||
if (!efl_file_set(vg, buf, NULL))
|
if (!efl_file_set(vg, eina_strbuf_string_get(buf), NULL))
|
||||||
error_and_abort(ef, "Failed to parse svg : %s", vector->entry);
|
error_and_abort(ef, "Failed to parse svg : %s", vector->entry);
|
||||||
|
|
||||||
sprintf(buf, "edje/vectors/%i", vector->id);
|
eina_strbuf_reset(buf);
|
||||||
|
eina_strbuf_append_printf(buf, "edje/vectors/%i", vector->id);
|
||||||
if(!efl_file_save(vg, eet_file_get(ef), buf, NULL))
|
if (!efl_file_save(vg, eet_file_get(ef), eina_strbuf_string_get(buf), NULL))
|
||||||
error_and_abort(ef, "Failed to write data in Eet for svg :%s", vector->entry);
|
error_and_abort(ef, "Failed to write data in Eet for svg :%s", vector->entry);
|
||||||
|
|
||||||
*vector_num += 1;
|
*vector_num += 1;
|
||||||
|
@ -1312,6 +1312,7 @@ data_write_vectors(Eet_File *ef, int *vector_num)
|
||||||
error_and_abort(ef, "Unable to find the svg :%s", vector->entry);
|
error_and_abort(ef, "Unable to find the svg :%s", vector->entry);
|
||||||
found = EINA_FALSE;
|
found = EINA_FALSE;
|
||||||
}
|
}
|
||||||
|
eina_strbuf_free(buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
|
@ -3696,13 +3696,13 @@ _edje_svg_recalc_apply(Edje *ed, Edje_Real_Part *ep, Edje_Calc_Params *p3 EINA_U
|
||||||
{
|
{
|
||||||
int new_svg = -1; //invalid svg
|
int new_svg = -1; //invalid svg
|
||||||
int w, h;
|
int w, h;
|
||||||
char src_key[20], dest_key[20];
|
char src_key[32], dest_key[32];
|
||||||
Efl_VG *src_root, *dest_root, *root;
|
Efl_VG *src_root, *dest_root, *root;
|
||||||
|
|
||||||
evas_object_geometry_get(ep->object, NULL, NULL, &w, &h);
|
evas_object_geometry_get(ep->object, NULL, NULL, &w, &h);
|
||||||
if( (w == 0) || (h == 0)) return;
|
if( (w == 0) || (h == 0)) return;
|
||||||
|
|
||||||
sprintf(src_key, "edje/vectors/%i", chosen_desc->vg.id);
|
snprintf(src_key, sizeof(src_key), "edje/vectors/%i", chosen_desc->vg.id);
|
||||||
|
|
||||||
if (ep->param2)
|
if (ep->param2)
|
||||||
{
|
{
|
||||||
|
@ -3719,22 +3719,27 @@ _edje_svg_recalc_apply(Edje *ed, Edje_Real_Part *ep, Edje_Calc_Params *p3 EINA_U
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
sprintf(dest_key, "edje/vectors/%i", new_svg);
|
snprintf(dest_key, sizeof(dest_key), "edje/vectors/%i", new_svg);
|
||||||
|
|
||||||
efl_file_set(ep->object, ed->file->path, src_key);
|
efl_file_set(ep->object, ed->file->path, src_key);
|
||||||
src_root = efl_canvas_vg_root_node_get(ep->object);
|
src_root = efl_canvas_vg_root_node_get(ep->object);
|
||||||
|
efl_ref(src_root);
|
||||||
|
|
||||||
efl_file_set(ep->object, ed->file->path, dest_key);
|
efl_file_set(ep->object, ed->file->path, dest_key);
|
||||||
dest_root = efl_canvas_vg_root_node_get(ep->object);
|
dest_root = efl_canvas_vg_root_node_get(ep->object);
|
||||||
|
efl_ref(dest_root);
|
||||||
|
|
||||||
|
// FIXME: root = dup(), root.interpolate(dest).
|
||||||
root = evas_vg_container_add(NULL);
|
root = evas_vg_container_add(NULL);
|
||||||
evas_vg_node_dup(root, src_root);
|
evas_vg_node_dup(root, src_root);
|
||||||
|
|
||||||
if (!evas_vg_node_interpolate(root, src_root, dest_root, pos))
|
if (!evas_vg_node_interpolate(root, src_root, dest_root, pos))
|
||||||
{
|
{
|
||||||
ERR(" Can't interpolate check the svg file \n");
|
ERR("Can't interpolate check the svg file");
|
||||||
}
|
}
|
||||||
efl_canvas_vg_root_node_set(ep->object, root);
|
efl_canvas_vg_root_node_set(ep->object, root);
|
||||||
|
efl_unref(src_root);
|
||||||
|
efl_unref(dest_root);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -244,22 +244,18 @@ _efl_canvas_vg_viewbox_align_get(Eo *obj EINA_UNUSED, Efl_Canvas_Vg_Data *pd, do
|
||||||
EOLIAN static Eina_Bool
|
EOLIAN static Eina_Bool
|
||||||
_efl_canvas_vg_efl_file_file_set(Eo *obj, Efl_Canvas_Vg_Data *pd, const char *file, const char *key)
|
_efl_canvas_vg_efl_file_file_set(Eo *obj, Efl_Canvas_Vg_Data *pd, const char *file, const char *key)
|
||||||
{
|
{
|
||||||
|
Evas_Cache_Vg_Entry *old_entry;
|
||||||
int w, h;
|
int w, h;
|
||||||
Evas_Cache_Vg_Entry *entry;
|
|
||||||
|
|
||||||
if (!file) return EINA_FALSE;
|
if (!file) return EINA_FALSE;
|
||||||
|
|
||||||
|
old_entry = pd->vg_entry;
|
||||||
evas_object_geometry_get(obj, NULL, NULL, &w, &h);
|
evas_object_geometry_get(obj, NULL, NULL, &w, &h);
|
||||||
entry = evas_cache_vg_entry_find(file, key, w, h);
|
pd->vg_entry = evas_cache_vg_entry_find(file, key, w, h);
|
||||||
if (entry != pd->vg_entry)
|
if (pd->vg_entry != old_entry)
|
||||||
{
|
evas_object_change(obj, efl_data_scope_get(obj, EFL_CANVAS_OBJECT_CLASS));
|
||||||
if (pd->vg_entry)
|
evas_cache_vg_entry_del(old_entry);
|
||||||
{
|
|
||||||
evas_cache_vg_entry_del(pd->vg_entry);
|
|
||||||
}
|
|
||||||
pd->vg_entry = entry;
|
|
||||||
}
|
|
||||||
evas_object_change(obj, efl_data_scope_get(obj, EFL_CANVAS_OBJECT_CLASS));
|
|
||||||
return EINA_TRUE;
|
return EINA_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -276,7 +272,7 @@ _efl_canvas_vg_efl_file_file_get(Eo *obj EINA_UNUSED, Efl_Canvas_Vg_Data *pd, co
|
||||||
EOLIAN static Eina_Bool
|
EOLIAN static Eina_Bool
|
||||||
_efl_canvas_vg_efl_file_save(const Eo *obj, Efl_Canvas_Vg_Data *pd, const char *file, const char *key, const char *flags)
|
_efl_canvas_vg_efl_file_save(const Eo *obj, Efl_Canvas_Vg_Data *pd, const char *file, const char *key, const char *flags)
|
||||||
{
|
{
|
||||||
Vg_File_Data tmp;
|
Vg_File_Data tmp = {};
|
||||||
Vg_File_Data *info = &tmp;
|
Vg_File_Data *info = &tmp;
|
||||||
|
|
||||||
if (pd->vg_entry && pd->vg_entry->file)
|
if (pd->vg_entry && pd->vg_entry->file)
|
||||||
|
@ -291,8 +287,7 @@ _efl_canvas_vg_efl_file_save(const Eo *obj, Efl_Canvas_Vg_Data *pd, const char *
|
||||||
info->root = pd->root;
|
info->root = pd->root;
|
||||||
info->preserve_aspect = EINA_FALSE;
|
info->preserve_aspect = EINA_FALSE;
|
||||||
}
|
}
|
||||||
evas_vg_save_to_file(info, file, key, flags);
|
return evas_vg_save_to_file(info, file, key, flags);
|
||||||
return EINA_TRUE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -431,7 +426,6 @@ _efl_canvas_vg_render(Evas_Object *eo_obj EINA_UNUSED,
|
||||||
{
|
{
|
||||||
root = vd->root;
|
root = vd->root;
|
||||||
}
|
}
|
||||||
//obj->layer->evas->engine.func->ector_begin(output, context,
|
|
||||||
obj->layer->evas->engine.func->ector_begin(engine, context,
|
obj->layer->evas->engine.func->ector_begin(engine, context,
|
||||||
ector, surface,
|
ector, surface,
|
||||||
vd->engine_data,
|
vd->engine_data,
|
||||||
|
|
|
@ -73,6 +73,7 @@ class Efl.Canvas.Vg (Efl.Canvas.Object, Efl.File)
|
||||||
Efl.Object.constructor;
|
Efl.Object.constructor;
|
||||||
Efl.Object.finalize;
|
Efl.Object.finalize;
|
||||||
Efl.Object.destructor;
|
Efl.Object.destructor;
|
||||||
|
// FIXME: Implement mmap only (also fix cache keys)
|
||||||
Efl.File.file { get; set; }
|
Efl.File.file { get; set; }
|
||||||
Efl.File.save;
|
Efl.File.save;
|
||||||
}
|
}
|
||||||
|
|
|
@ -324,5 +324,6 @@ evas_cache_vg_entry_del(Evas_Cache_Vg_Entry *svg_entry)
|
||||||
if (!svg_entry) return;
|
if (!svg_entry) return;
|
||||||
|
|
||||||
svg_entry->ref--;
|
svg_entry->ref--;
|
||||||
|
// FIXME implement delete logic (LRU)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue