evas: implement Efl.File.unload for evas image classes

this fixes unloading images using the evas_object_image_file_set legacy
api

ref D8616

Differential Revision: https://phab.enlightenment.org/D8618
This commit is contained in:
Mike Blumenkrantz 2019-04-18 09:05:31 -04:00
parent d49685cd83
commit 570005213a
6 changed files with 35 additions and 0 deletions

View File

@ -4,6 +4,21 @@
#define MY_CLASS EFL_CANVAS_IMAGE_CLASS
#define MY_CLASS_NAME efl_class_name_get(MY_CLASS)
void
_evas_image_file_unload(Eo *eo_obj)
{
Evas_Object_Protected_Data *obj;
Evas_Image_Data *o = efl_data_scope_get(eo_obj, EFL_CANVAS_IMAGE_INTERNAL_CLASS);
if (!o->cur->f) return;
obj = efl_data_scope_get(eo_obj, EFL_CANVAS_OBJECT_CLASS);
evas_object_async_block(obj);
_evas_image_init_set(NULL, NULL, eo_obj, obj, o, NULL);
o->buffer_data_set = EINA_FALSE;
_evas_image_done_set(eo_obj, obj, o);
o->load_error = EFL_GFX_IMAGE_LOAD_ERROR_NONE;
}
Eina_Bool
_evas_image_file_load(Eo *eo_obj)
{
@ -48,6 +63,13 @@ _efl_canvas_image_efl_file_load(Eo *eo_obj, void *_pd EINA_UNUSED)
return EFL_GFX_IMAGE_LOAD_ERROR_DOES_NOT_EXIST;
}
EOLIAN static void
_efl_canvas_image_efl_file_unload(Eo *eo_obj, void *_pd EINA_UNUSED)
{
efl_file_unload(efl_super(eo_obj, MY_CLASS));
_evas_image_file_unload(eo_obj);
}
const Eina_File *
_evas_image_mmap_get(const Eo *eo_obj)
{

View File

@ -17,6 +17,7 @@ class @beta Efl.Canvas.Image extends Efl.Canvas.Image_Internal implements
Efl.Gfx.Buffer.buffer_map;
Efl.Gfx.Buffer.buffer_unmap;
Efl.File.load;
Efl.File.unload;
Efl.Gfx.Frame_Controller.animated { get; }
Efl.Gfx.Frame_Controller.frame { get; set; }
Efl.Gfx.Frame_Controller.frame_count { get; }

View File

@ -15,6 +15,7 @@ _evas_image_class_initializer(Efl_Class *klass)
EFL_OPS_DEFINE(ops,
EFL_OBJECT_OP_FUNC(efl_file_load, _evas_image_efl_file_load),
EFL_OBJECT_OP_FUNC(efl_file_unload, _evas_image_efl_file_unload),
EVAS_IMAGE_EXTRA_OPS
);
opsp = &ops;

View File

@ -1304,4 +1304,12 @@ _evas_image_efl_file_load(Eo *obj, void *pd EINA_UNUSED)
return EFL_GFX_IMAGE_LOAD_ERROR_DOES_NOT_EXIST;
}
EOLIAN static void
_evas_image_efl_file_unload(Eo *obj, void *pd EINA_UNUSED)
{
EVAS_IMAGE_API(obj);
efl_file_unload(efl_super(obj, EVAS_IMAGE_CLASS));
_evas_image_file_unload(obj);
}
#include "canvas/evas_image_eo.c"

View File

@ -162,6 +162,7 @@ void _evas_image_fill_set(Eo *eo_obj, Evas_Image_Data *o, int x, int y, int w, i
/* Efl.File */
Eina_Bool _evas_image_file_load(Eo *eo_obj);
void _evas_image_file_unload(Eo *eo_obj);
const Eina_File *_evas_image_mmap_get(const Eo *eo_obj);
const char *_evas_image_key_get(const Eo *eo_obj);
void _efl_canvas_image_load_error_set(Eo *eo_obj EINA_UNUSED, Eina_Error err);

View File

@ -283,7 +283,9 @@ _evas_image_init_set(const Eina_File *f, const char *key,
}
ENFN->image_free(ENC, o->engine_data);
}
o->engine_data = NULL;
o->load_error = EFL_GFX_IMAGE_LOAD_ERROR_NONE;
if (!lo) return;
lo->emile.scale_down_by = o->load_opts->scale_down_by;
lo->emile.dpi = o->load_opts->dpi;
lo->emile.w = o->load_opts->w;