From a6dcaa0f9a6f8873ccb23db75b7e3065ddb06f03 Mon Sep 17 00:00:00 2001 From: Cedric Bail Date: Wed, 4 Oct 2017 21:32:22 -0700 Subject: [PATCH] evas: remove use of engine image_load from Evas.Canvas3D.Texture. --- src/lib/edje/edje_calc.c | 2 +- src/lib/evas/canvas/evas_canvas3d_texture.c | 23 ++++++++++++++++++----- src/lib/evas/canvas/evas_canvas3d_texture.eo | 18 +++++------------- src/lib/evas/include/evas_private.h | 3 +++ 4 files changed, 27 insertions(+), 19 deletions(-) diff --git a/src/lib/edje/edje_calc.c b/src/lib/edje/edje_calc.c index 3902ac4..fc71bad 100644 --- a/src/lib/edje/edje_calc.c +++ b/src/lib/edje/edje_calc.c @@ -5456,7 +5456,7 @@ _edje_part_recalc(Edje *ed, Edje_Real_Part *ep, int flags, Edje_Calc_Params *sta proxy = ed->file->image_dir->entries[pd_mesh_node->mesh_node.texture.id].entry; if (proxy) { - evas_canvas3d_texture_file_set(texture, eina_stringshare_add(proxy), NULL); + efl_file_mmap_set(texture, ed->file->f, proxy); evas_canvas3d_texture_filter_set(texture, pd_mesh_node->mesh_node.texture.filter1, pd_mesh_node->mesh_node.texture.filter2); evas_canvas3d_texture_wrap_set(texture, pd_mesh_node->mesh_node.texture.wrap1, pd_mesh_node->mesh_node.texture.wrap2); } diff --git a/src/lib/evas/canvas/evas_canvas3d_texture.c b/src/lib/evas/canvas/evas_canvas3d_texture.c index 6471dda..00cef85 100644 --- a/src/lib/evas/canvas/evas_canvas3d_texture.c +++ b/src/lib/evas/canvas/evas_canvas3d_texture.c @@ -332,8 +332,9 @@ _evas_canvas3d_texture_efl_object_constructor(Eo *obj, Evas_Canvas3D_Texture_Dat } EOLIAN static void -_evas_canvas3d_texture_efl_object_destructor(Eo *obj, Evas_Canvas3D_Texture_Data *pd EINA_UNUSED) +_evas_canvas3d_texture_efl_object_destructor(Eo *obj, Evas_Canvas3D_Texture_Data *pd) { + eina_file_close(pd->f); _texture_fini(obj); efl_destructor(efl_super(obj, MY_CLASS)); } @@ -372,7 +373,14 @@ _evas_canvas3d_texture_data_set(Eo *obj, Evas_Canvas3D_Texture_Data *pd, } EOLIAN static void -_evas_canvas3d_texture_file_set(Eo *obj, Evas_Canvas3D_Texture_Data *pd, const char *file, const char *key) +_evas_canvas3d_texture_efl_file_mmap_get(Eo *obj EINA_UNUSED, Evas_Canvas3D_Texture_Data *pd, const Eina_File **f, const char **key) +{ + if (f) *f = pd->f; + if (key) *key = pd->key; +} + +EOLIAN static Eina_Bool +_evas_canvas3d_texture_efl_file_mmap_set(Eo *obj, Evas_Canvas3D_Texture_Data *pd, const Eina_File *f, const char *key) { Evas_Image_Load_Opts lo; @@ -387,12 +395,12 @@ _evas_canvas3d_texture_file_set(Eo *obj, Evas_Canvas3D_Texture_Data *pd, const c pd->engine_data = e->engine.func->texture_new(_evas_engine_context(e), pd->atlas_enable); memset(&lo, 0x0, sizeof(Evas_Image_Load_Opts)); - image = e->engine.func->image_load(_evas_engine_context(e), - file, key, &load_error, &lo); + image = e->engine.func->image_mmap(_evas_engine_context(e), + (Eina_File *) f, key, &load_error, &lo); if (!image) { ERR("Can't load image from file"); - return; + return EINA_FALSE; } if (e->engine.func->texture_image_set) @@ -401,7 +409,12 @@ _evas_canvas3d_texture_file_set(Eo *obj, Evas_Canvas3D_Texture_Data *pd, const c image); e->engine.func->image_free(_evas_engine_context(e), image); + + pd->f = eina_file_dup(f); + pd->key = eina_stringshare_add(key); evas_canvas3d_object_change(obj, EVAS_CANVAS3D_STATE_TEXTURE_DATA, NULL); + + return EINA_TRUE; } EAPI void diff --git a/src/lib/evas/canvas/evas_canvas3d_texture.eo b/src/lib/evas/canvas/evas_canvas3d_texture.eo index 67cf5dc..c6ab979 100644 --- a/src/lib/evas/canvas/evas_canvas3d_texture.eo +++ b/src/lib/evas/canvas/evas_canvas3d_texture.eo @@ -1,6 +1,6 @@ type @extern Evas_Colorspace: int; [[Evas colorspace type]] /* FIXME: Need to get emile migrated. */ -class Evas.Canvas3D.Texture (Evas.Canvas3D.Object) +class Evas.Canvas3D.Texture (Evas.Canvas3D.Object, Efl.File) { [[Evas 3d canvas texture class]] data : Evas_Canvas3D_Texture_Data; @@ -46,7 +46,7 @@ class Evas.Canvas3D.Texture (Evas.Canvas3D.Object) data_set { [[Set the data of the given texture. - See also @.file_set. + See also @Efl.File.file.set. ]] params { @@ -57,15 +57,6 @@ class Evas.Canvas3D.Texture (Evas.Canvas3D.Object) } } - file_set { - [[Set the data of the given texture from file.]] - - params { - @in file: string; [[Path to the image file.]] - @in key: string; [[Key in the image file.]] - } - } - source_set { [[Set the data of the given texture from an evas object. @@ -89,7 +80,7 @@ class Evas.Canvas3D.Texture (Evas.Canvas3D.Object) has source object. Otherwise, the color format of the data will be returned. - See also @.data_set, @.file_set, @.source_set. + See also @.data_set, @Efl.File.file.set, @.source_set. ]] return: Evas_Colorspace; [[Color format of the given texture]] } @@ -101,7 +92,7 @@ class Evas.Canvas3D.Texture (Evas.Canvas3D.Object) will be returned. Otherwise, the size of the data (or image file) will be returned. - See also @.data_set, @.file_set, @.source_set. + See also @.data_set, @Efl.File.file.set, @.source_set. ]] params { @out w: int; [[Pointer to receive the width of the texture size.]] @@ -164,5 +155,6 @@ class Evas.Canvas3D.Texture (Evas.Canvas3D.Object) Efl.Object.destructor; Evas.Canvas3D.Object.update_notify; Evas.Canvas3D.Object.change_notify; + Efl.File.mmap { set; get; } } } diff --git a/src/lib/evas/include/evas_private.h b/src/lib/evas/include/evas_private.h index 71fd28f..f3552a0 100644 --- a/src/lib/evas/include/evas_private.h +++ b/src/lib/evas/include/evas_private.h @@ -433,6 +433,9 @@ struct _Evas_Canvas3D_Texture /* Engine-side object. */ void *engine_data; + Eina_File *f; + const char *key; + /*Use atlases, @EINA_TRUE by default*/ Eina_Bool atlas_enable :1; }; -- 2.7.4