forked from enlightenment/efl
evas: remove duplicated code and rely on Efl.File { get; set; }
We can almost remove image_load from the engine backend after this patch. One little bit left in Evas_3D.
This commit is contained in:
parent
ea4d27f1b2
commit
c8c4572d70
|
@ -11,7 +11,7 @@ _evas_image_mmap_set(Eo *eo_obj, const Eina_File *f, const char *key)
|
|||
Evas_Image_Data *o = efl_data_scope_get(eo_obj, EFL_CANVAS_IMAGE_INTERNAL_CLASS);
|
||||
Evas_Image_Load_Opts lo;
|
||||
|
||||
if (o->cur->u.f == f)
|
||||
if (o->cur->f == f)
|
||||
{
|
||||
if ((!o->cur->key) && (!key))
|
||||
return EINA_FALSE;
|
||||
|
@ -19,8 +19,8 @@ _evas_image_mmap_set(Eo *eo_obj, const Eina_File *f, const char *key)
|
|||
return EINA_FALSE;
|
||||
}
|
||||
evas_object_async_block(obj);
|
||||
_evas_image_init_set(f, NULL, key, eo_obj, obj, o, &lo);
|
||||
o->engine_data = ENFN->image_mmap(ENC, o->cur->u.f, o->cur->key, &o->load_error, &lo);
|
||||
_evas_image_init_set(f, key, eo_obj, obj, o, &lo);
|
||||
o->engine_data = ENFN->image_mmap(ENC, o->cur->f, o->cur->key, &o->load_error, &lo);
|
||||
o->buffer_data_set = EINA_FALSE;
|
||||
_evas_image_done_set(eo_obj, obj, o);
|
||||
o->file_size.w = o->cur->image.w;
|
||||
|
@ -42,7 +42,7 @@ _evas_image_mmap_get(const Eo *eo_obj, const Eina_File **f, const char **key)
|
|||
Evas_Image_Data *o = efl_data_scope_get(eo_obj, EFL_CANVAS_IMAGE_INTERNAL_CLASS);
|
||||
|
||||
if (f)
|
||||
*f = o->cur->mmaped_source ? o->cur->u.f : NULL;
|
||||
*f = o->cur->f;
|
||||
if (key)
|
||||
*key = o->cur->key;
|
||||
}
|
||||
|
@ -54,82 +54,13 @@ _efl_canvas_image_efl_file_mmap_get(Eo *eo_obj, void *_pd EINA_UNUSED EINA_UNUSE
|
|||
_evas_image_mmap_get(eo_obj, f, key);
|
||||
}
|
||||
|
||||
Eina_Bool
|
||||
_evas_image_file_set(Eo *eo_obj, const char *file, const char *key)
|
||||
{
|
||||
Evas_Object_Protected_Data *obj = efl_data_scope_get(eo_obj, EFL_CANVAS_OBJECT_CLASS);
|
||||
Evas_Image_Data *o = efl_data_scope_get(eo_obj, EFL_CANVAS_IMAGE_INTERNAL_CLASS);
|
||||
Evas_Image_Load_Opts lo;
|
||||
const char *file2;
|
||||
|
||||
if ((o->cur->u.file) && (file) && (!strcmp(o->cur->u.file, file)))
|
||||
{
|
||||
if ((!o->cur->key) && (!key))
|
||||
return EINA_FALSE;
|
||||
if ((o->cur->key) && (key) && (!strcmp(o->cur->key, key)))
|
||||
return EINA_FALSE;
|
||||
}
|
||||
|
||||
evas_object_async_block(obj);
|
||||
_evas_image_init_set(NULL, file, key, eo_obj, obj, o, &lo);
|
||||
if (o->file_obj) efl_del(o->file_obj);
|
||||
o->file_obj = NULL;
|
||||
file2 = o->cur->u.file;
|
||||
if (file2)
|
||||
{
|
||||
o->file_obj = efl_vpath_manager_fetch(EFL_VPATH_MANAGER_CLASS, file2);
|
||||
efl_vpath_file_do(o->file_obj);
|
||||
// XXX:FIXME: allow this to be async
|
||||
efl_vpath_file_wait(o->file_obj);
|
||||
file2 = efl_vpath_file_result_get(o->file_obj);
|
||||
}
|
||||
o->engine_data = ENFN->image_load(ENC, file2, o->cur->key, &o->load_error, &lo);
|
||||
o->buffer_data_set = EINA_FALSE;
|
||||
_evas_image_done_set(eo_obj, obj, o);
|
||||
o->file_size.w = o->cur->image.w;
|
||||
o->file_size.h = o->cur->image.h;
|
||||
if ((o->file_obj) && (!efl_vpath_file_keep_get(o->file_obj)))
|
||||
{
|
||||
efl_del(o->file_obj);
|
||||
o->file_obj = NULL;
|
||||
}
|
||||
return EINA_TRUE;
|
||||
}
|
||||
|
||||
EOLIAN static Eina_Bool
|
||||
_efl_canvas_image_efl_file_file_set(Eo *eo_obj, void *_pd EINA_UNUSED EINA_UNUSED,
|
||||
const char *file, const char *key)
|
||||
{
|
||||
return _evas_image_file_set(eo_obj, file, key);
|
||||
}
|
||||
|
||||
void
|
||||
_evas_image_file_get(const Eo *eo_obj, const char **file, const char **key)
|
||||
{
|
||||
Evas_Image_Data *o = efl_data_scope_get(eo_obj, EFL_CANVAS_IMAGE_INTERNAL_CLASS);
|
||||
|
||||
if (file)
|
||||
{
|
||||
if (o->cur->mmaped_source)
|
||||
*file = eina_file_filename_get(o->cur->u.f);
|
||||
else
|
||||
*file = o->cur->u.file;
|
||||
}
|
||||
if (key) *key = o->cur->key;
|
||||
}
|
||||
|
||||
EOLIAN static void
|
||||
_efl_canvas_image_efl_file_file_get(Eo *eo_obj, void *_pd EINA_UNUSED EINA_UNUSED,
|
||||
const char **file, const char **key)
|
||||
{
|
||||
_evas_image_file_get(eo_obj, file, key);
|
||||
}
|
||||
|
||||
Efl_Image_Load_Error
|
||||
_evas_image_load_error_get(const Eo *eo_obj)
|
||||
{
|
||||
Evas_Image_Data *o = efl_data_scope_get(eo_obj, EFL_CANVAS_IMAGE_INTERNAL_CLASS);
|
||||
Efl_Image_Load_Error r = efl_file_load_error_get(eo_obj);
|
||||
|
||||
if (r != EFL_IMAGE_LOAD_ERROR_NONE) return r;
|
||||
return o->load_error;
|
||||
}
|
||||
|
||||
|
@ -213,7 +144,7 @@ _evas_image_load_dpi_set(Eo *eo_obj, double dpi)
|
|||
low->dpi = dpi;
|
||||
EINA_COW_LOAD_OPTS_WRITE_END(o, low);
|
||||
|
||||
if (o->cur->u.file)
|
||||
if (o->cur->f)
|
||||
{
|
||||
_evas_image_unload(eo_obj, obj, 0);
|
||||
evas_object_inform_call_image_unloaded(eo_obj);
|
||||
|
@ -258,7 +189,7 @@ _evas_image_load_size_set(Eo *eo_obj, int w, int h)
|
|||
}
|
||||
EINA_COW_LOAD_OPTS_WRITE_END(o, low);
|
||||
|
||||
if (o->cur->u.file)
|
||||
if (o->cur->f)
|
||||
{
|
||||
_evas_image_unload(eo_obj, obj, 0);
|
||||
evas_object_inform_call_image_unloaded(eo_obj);
|
||||
|
@ -304,7 +235,7 @@ _evas_image_load_scale_down_set(Eo *eo_obj, int scale_down)
|
|||
low->scale_down_by = scale_down;
|
||||
EINA_COW_LOAD_OPTS_WRITE_END(o, low);
|
||||
|
||||
if (o->cur->u.file)
|
||||
if (o->cur->f)
|
||||
{
|
||||
_evas_image_unload(eo_obj, obj, 0);
|
||||
evas_object_inform_call_image_unloaded(eo_obj);
|
||||
|
@ -378,7 +309,7 @@ _evas_image_load_region_set(Eo *eo_obj, int x, int y, int w, int h)
|
|||
}
|
||||
EINA_COW_LOAD_OPTS_WRITE_END(o, low);
|
||||
|
||||
if (o->cur->u.file)
|
||||
if (o->cur->f)
|
||||
{
|
||||
_evas_image_unload(eo_obj, obj, 0);
|
||||
evas_object_inform_call_image_unloaded(eo_obj);
|
||||
|
@ -570,7 +501,7 @@ _evas_image_animated_frame_set(Eo *eo_obj, int frame_index)
|
|||
Evas_Image_Data *o = efl_data_scope_get(eo_obj, EFL_CANVAS_IMAGE_INTERNAL_CLASS);
|
||||
int frame_count = 0;
|
||||
|
||||
if (!o->cur->u.file) return EINA_FALSE;
|
||||
if (!o->cur->f) return EINA_FALSE;
|
||||
if (o->cur->frame == frame_index) return EINA_TRUE;
|
||||
|
||||
if (!evas_object_image_animated_get(eo_obj)) return EINA_FALSE;
|
||||
|
@ -610,7 +541,7 @@ _evas_image_animated_frame_get(const Eo *eo_obj)
|
|||
{
|
||||
Evas_Image_Data *o = efl_data_scope_get(eo_obj, EFL_CANVAS_IMAGE_INTERNAL_CLASS);
|
||||
|
||||
if (!o->cur->u.file) return EINA_FALSE;
|
||||
if (!o->cur->f) return EINA_FALSE;
|
||||
if (!evas_object_image_animated_get(eo_obj)) return EINA_FALSE;
|
||||
return o->cur->frame;
|
||||
}
|
||||
|
@ -657,12 +588,6 @@ _image_pixels_set(Evas_Object_Protected_Data *obj,
|
|||
return EINA_FALSE;
|
||||
}
|
||||
|
||||
if (o->file_obj)
|
||||
{
|
||||
efl_del(o->file_obj);
|
||||
o->file_obj = NULL;
|
||||
}
|
||||
|
||||
if (o->engine_data)
|
||||
{
|
||||
Evas_Colorspace ics;
|
||||
|
@ -712,12 +637,12 @@ _image_pixels_set(Evas_Object_Protected_Data *obj,
|
|||
if (ENFN->image_stride_get)
|
||||
ENFN->image_stride_get(ENC, o->engine_data, &int_stride);
|
||||
|
||||
if (resized || o->cur->u.file || o->cur->key ||
|
||||
if (resized || o->cur->f || o->cur->key ||
|
||||
(o->cur->image.stride != int_stride) || (cspace != o->cur->cspace))
|
||||
{
|
||||
EINA_COW_IMAGE_STATE_WRITE_BEGIN(o, cur)
|
||||
{
|
||||
cur->u.f = NULL;
|
||||
cur->f = NULL;
|
||||
cur->key = NULL;
|
||||
cur->cspace = cspace;
|
||||
cur->image.w = w;
|
||||
|
|
|
@ -16,7 +16,6 @@ class Efl.Canvas.Image (Efl.Canvas.Image.Internal, Efl.Gfx.Buffer,
|
|||
Efl.Gfx.Buffer.buffer_size { get; }
|
||||
Efl.Gfx.Buffer.buffer_map;
|
||||
Efl.Gfx.Buffer.buffer_unmap;
|
||||
Efl.File.file { get; set; }
|
||||
Efl.File.mmap { get; set; }
|
||||
Efl.Image.Animated.animated { get; }
|
||||
Efl.Image.Animated.animated_frame { get; set; }
|
||||
|
|
|
@ -47,8 +47,8 @@ _evas_image_proxy_source_set(Eo *eo_obj, Evas_Object *eo_src)
|
|||
evas_object_async_block(obj);
|
||||
_evas_image_cleanup(eo_obj, obj, o);
|
||||
/* Kill the image if any */
|
||||
if (o->cur->u.file || o->cur->key)
|
||||
evas_object_image_file_set(eo_obj, NULL, NULL);
|
||||
if (o->cur->f || o->cur->key)
|
||||
evas_object_image_mmap_set(eo_obj, NULL, NULL);
|
||||
|
||||
if (eo_src) _evas_image_proxy_set(eo_obj, eo_src);
|
||||
else _evas_image_proxy_unset(eo_obj, obj, o);
|
||||
|
@ -219,7 +219,7 @@ _evas_image_proxy_set(Evas_Object *eo_proxy, Evas_Object *eo_src)
|
|||
Evas_Object_Protected_Data *proxy = efl_data_scope_get(eo_proxy, EFL_CANVAS_OBJECT_CLASS);
|
||||
Evas_Image_Data *o = efl_data_scope_get(eo_proxy, EFL_CANVAS_IMAGE_INTERNAL_CLASS);
|
||||
|
||||
_evas_image_file_set(eo_proxy, NULL, NULL);
|
||||
efl_file_set(eo_proxy, NULL, NULL);
|
||||
|
||||
EINA_COW_WRITE_BEGIN(evas_object_proxy_cow, proxy->proxy, Evas_Object_Proxy_Data, proxy_write)
|
||||
proxy_write->is_proxy = EINA_TRUE;
|
||||
|
|
|
@ -13,8 +13,8 @@ _efl_canvas_scene3d_scene3d_set(Eo *eo_obj, void *pd EINA_UNUSED, Evas_Canvas3D_
|
|||
if (o->cur->scene == scene) return;
|
||||
|
||||
evas_object_async_block(obj);
|
||||
_evas_image_init_set(NULL, NULL, NULL, eo_obj, obj, o, &lo);
|
||||
o->engine_data = ENFN->image_load(ENC, o->cur->u.file, o->cur->key, &o->load_error, &lo);
|
||||
_evas_image_init_set(NULL, NULL, eo_obj, obj, o, &lo);
|
||||
o->engine_data = ENFN->image_mmap(ENC, o->cur->f, o->cur->key, &o->load_error, &lo);
|
||||
_evas_image_done_set(eo_obj, obj, o);
|
||||
|
||||
if (scene) _evas_image_3d_set(eo_obj, scene);
|
||||
|
|
|
@ -3,7 +3,6 @@ class Evas.Image (Efl.Canvas.Image.Internal, Efl.File)
|
|||
[[Internal class for legacy support of Evas Image.]]
|
||||
data: null;
|
||||
implements {
|
||||
Efl.File.file { get; set; }
|
||||
Efl.File.mmap { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -195,14 +195,14 @@ EAPI void
|
|||
evas_object_image_file_set(Evas_Object *obj, const char *file, const char *key)
|
||||
{
|
||||
EVAS_IMAGE_API(obj);
|
||||
_evas_image_file_set(obj, file, key);
|
||||
efl_file_set(obj, file, key);
|
||||
}
|
||||
|
||||
EAPI void
|
||||
evas_object_image_file_get(const Evas_Object *obj, const char **file, const char **key)
|
||||
{
|
||||
EVAS_IMAGE_API(obj);
|
||||
_evas_image_file_get(obj, file, key);
|
||||
efl_file_get(obj, file, key);
|
||||
}
|
||||
|
||||
EAPI void
|
||||
|
@ -648,11 +648,6 @@ evas_object_image_data_set(Eo *eo_obj, void *data)
|
|||
EINA_COW_IMAGE_STATE_WRITE_END(o, state_write);
|
||||
|
||||
o->engine_data = NULL;
|
||||
if (o->file_obj)
|
||||
{
|
||||
efl_del(o->file_obj);
|
||||
o->file_obj = NULL;
|
||||
}
|
||||
}
|
||||
/* FIXME - in engine call above
|
||||
if (o->engine_data)
|
||||
|
@ -661,7 +656,6 @@ evas_object_image_data_set(Eo *eo_obj, void *data)
|
|||
if (o->pixels_checked_out > 0) o->pixels_checked_out--;
|
||||
if (p_data != o->engine_data)
|
||||
{
|
||||
EVAS_OBJECT_WRITE_IMAGE_FREE_FILE_AND_KEY(o);
|
||||
o->pixels_checked_out = 0;
|
||||
}
|
||||
if (resize_call) evas_object_inform_call_image_resize(eo_obj);
|
||||
|
@ -748,7 +742,6 @@ evas_object_image_data_get(const Eo *eo_obj, Eina_Bool for_writing)
|
|||
if (for_writing)
|
||||
{
|
||||
o->written = EINA_TRUE;
|
||||
EVAS_OBJECT_WRITE_IMAGE_FREE_FILE_AND_KEY(o);
|
||||
}
|
||||
|
||||
return data;
|
||||
|
@ -775,11 +768,6 @@ evas_object_image_data_copy_set(Eo *eo_obj, void *data)
|
|||
(o->cur->image.h <= 0)) return;
|
||||
if (o->engine_data)
|
||||
ENFN->image_free(ENC, o->engine_data);
|
||||
if (o->file_obj)
|
||||
{
|
||||
efl_del(o->file_obj);
|
||||
o->file_obj = NULL;
|
||||
}
|
||||
o->engine_data = ENFN->image_new_from_copied_data(ENC,
|
||||
o->cur->image.w,
|
||||
o->cur->image.h,
|
||||
|
@ -810,7 +798,6 @@ evas_object_image_data_copy_set(Eo *eo_obj, void *data)
|
|||
o->written = EINA_TRUE;
|
||||
}
|
||||
o->pixels_checked_out = 0;
|
||||
EVAS_OBJECT_WRITE_IMAGE_FREE_FILE_AND_KEY(o);
|
||||
}
|
||||
|
||||
/* Evas_Object equivalent: pixels_set(null, w, h, cspace) to (re)allocate an image */
|
||||
|
@ -1129,18 +1116,21 @@ evas_object_image_reload(Evas_Object *eo_obj)
|
|||
o->preloading = EINA_FALSE;
|
||||
ENFN->image_data_preload_cancel(ENC, o->engine_data, eo_obj);
|
||||
}
|
||||
if ((!o->cur->u.file) ||
|
||||
if ((!o->cur->f) ||
|
||||
(o->pixels_checked_out > 0)) return;
|
||||
if (o->engine_data)
|
||||
o->engine_data = ENFN->image_dirty_region(ENC, o->engine_data, 0, 0, o->cur->image.w, o->cur->image.h);
|
||||
|
||||
eina_file_refresh(o->cur->f);
|
||||
o->written = EINA_FALSE;
|
||||
|
||||
_evas_image_unload(eo_obj, obj, 1);
|
||||
evas_object_inform_call_image_unloaded(eo_obj);
|
||||
_evas_image_load(eo_obj, obj, o);
|
||||
|
||||
EINA_COW_WRITE_BEGIN(evas_object_image_state_cow, o->prev, Evas_Object_Image_State, prev_write)
|
||||
{
|
||||
prev_write->u.file = NULL;
|
||||
prev_write->f = NULL;
|
||||
prev_write->key = NULL;
|
||||
}
|
||||
EINA_COW_WRITE_END(evas_object_image_state_cow, o->prev, prev_write);
|
||||
|
@ -1232,24 +1222,6 @@ evas_object_image_alpha_mask_set(Evas_Object *eo_obj EINA_UNUSED, Eina_Bool isma
|
|||
EVAS_IMAGE_LEGACY_API(eo_obj);
|
||||
}
|
||||
|
||||
EOLIAN static Eina_Bool
|
||||
_evas_image_efl_file_file_set(Eo *obj, void *pd EINA_UNUSED, const char *file, const char *key)
|
||||
{
|
||||
WRN("efl_file_set shouldn't be used on Evas.Image. please switch to Efl.Canvas.Image");
|
||||
EVAS_IMAGE_API(obj, EINA_FALSE);
|
||||
return _evas_image_file_set(obj, file, key);
|
||||
}
|
||||
|
||||
EOLIAN static void
|
||||
_evas_image_efl_file_file_get(Eo *obj, void *pd EINA_UNUSED, const char **file, const char **key)
|
||||
{
|
||||
WRN("efl_file_get shouldn't be used on Evas.Image. please switch to Efl.Canvas.Image");
|
||||
if (file) *file = NULL;
|
||||
if (key) *key = NULL;
|
||||
EVAS_IMAGE_API(obj);
|
||||
_evas_image_file_get(obj, file, key);
|
||||
}
|
||||
|
||||
EOLIAN static Eina_Bool
|
||||
_evas_image_efl_file_mmap_set(Eo *obj, void *pd EINA_UNUSED, const Eina_File *f, const char *key)
|
||||
{
|
||||
|
|
|
@ -83,10 +83,7 @@ struct _Evas_Object_Image_State
|
|||
Evas_Map *defmap;
|
||||
Evas_Canvas3D_Scene *scene;
|
||||
|
||||
union {
|
||||
const char *file; // used if !mmaped_source
|
||||
Eina_File *f; // used if mmaped_source
|
||||
} u;
|
||||
Eina_File *f;
|
||||
const char *key;
|
||||
int frame;
|
||||
|
||||
|
@ -97,7 +94,6 @@ struct _Evas_Object_Image_State
|
|||
Eina_Bool has_alpha :1;
|
||||
Eina_Bool opaque_valid : 1;
|
||||
Eina_Bool opaque : 1;
|
||||
Eina_Bool mmaped_source : 1;
|
||||
};
|
||||
|
||||
struct _Evas_Image_Data
|
||||
|
@ -109,7 +105,6 @@ struct _Evas_Image_Data
|
|||
|
||||
void *engine_data;
|
||||
void *engine_data_prep;
|
||||
Efl_Vpath_File *file_obj;
|
||||
|
||||
void *plane;
|
||||
|
||||
|
@ -153,7 +148,7 @@ struct _Evas_Image_Data
|
|||
};
|
||||
|
||||
/* shared functions between legacy and new eo classes */
|
||||
void _evas_image_init_set(const Eina_File *f, const char *file, const char *key, Eo *eo_obj, Evas_Object_Protected_Data *obj, Evas_Image_Data *o, Evas_Image_Load_Opts *lo);
|
||||
void _evas_image_init_set(const Eina_File *f, const char *key, Eo *eo_obj, Evas_Object_Protected_Data *obj, Evas_Image_Data *o, Evas_Image_Load_Opts *lo);
|
||||
void _evas_image_done_set(Eo *eo_obj, Evas_Object_Protected_Data *obj, Evas_Image_Data *o);
|
||||
void _evas_image_cleanup(Evas_Object *eo_obj, Evas_Object_Protected_Data *obj, Evas_Image_Data *o);
|
||||
void *_evas_image_pixels_get(Eo *eo_obj, Evas_Object_Protected_Data *obj, void *engine, void *output, void *context, void *surface, int x, int y, int *imagew, int *imageh, int *uvw, int *uvh, Eina_Bool filtered, Eina_Bool needs_post_render);
|
||||
|
@ -240,7 +235,7 @@ void _evas_image_load(Evas_Object *eo_obj, Evas_Object_Protected_Data *obj, Evas
|
|||
EINA_COW_WRITE_END(evas_object_image_load_opts_cow, Obj->load_opts, Write)
|
||||
|
||||
# define EVAS_OBJECT_WRITE_IMAGE_FREE_FILE_AND_KEY(Obj) \
|
||||
if ((!Obj->cur->mmaped_source && Obj->cur->u.file) || Obj->cur->key) \
|
||||
if (Obj->cur->key) \
|
||||
{ \
|
||||
EINA_COW_IMAGE_STATE_WRITE_BEGIN(Obj, cur_write) \
|
||||
{ \
|
||||
|
|
|
@ -96,7 +96,7 @@ static const Evas_Object_Image_State default_state = {
|
|||
{ 0, 0, 0 }, // image
|
||||
{ 1.0, 0, 0, 0, 0, 1 }, // border
|
||||
NULL, NULL, NULL, //source, defmap, scene
|
||||
{ NULL }, //u
|
||||
NULL, //f
|
||||
NULL, //key
|
||||
0, //frame
|
||||
EVAS_COLORSPACE_ARGB8888,
|
||||
|
@ -105,8 +105,7 @@ static const Evas_Object_Image_State default_state = {
|
|||
EINA_TRUE, // smooth
|
||||
EINA_FALSE, // has_alpha
|
||||
EINA_FALSE, // opaque_valid
|
||||
EINA_FALSE, // opaque
|
||||
EINA_FALSE // mmapped_source
|
||||
EINA_FALSE // opaque
|
||||
};
|
||||
|
||||
Eina_Cow *evas_object_image_load_opts_cow = NULL;
|
||||
|
@ -120,7 +119,7 @@ evas_object_image_render_prepare(Evas_Object *eo_obj EINA_UNUSED, Evas_Object_Pr
|
|||
Evas_Image_Data *o = efl_data_scope_get(eo_obj, MY_CLASS);
|
||||
|
||||
// if image data not loaded or in texture then upload
|
||||
if ((o->cur->u.file) || (o->written) || (o->cur->frame != 0))
|
||||
if ((o->cur->f) || (o->written) || (o->cur->frame != 0))
|
||||
{
|
||||
if (o->engine_data) ENFN->image_prepare(ENC, o->engine_data);
|
||||
}
|
||||
|
@ -247,7 +246,7 @@ _efl_canvas_image_internal_efl_object_finalize(Eo *eo_obj, Evas_Image_Data *o)
|
|||
}
|
||||
|
||||
void
|
||||
_evas_image_init_set(const Eina_File *f, const char *file, const char *key,
|
||||
_evas_image_init_set(const Eina_File *f, const char *key,
|
||||
Eo *eo_obj, Evas_Object_Protected_Data *obj, Evas_Image_Data *o,
|
||||
Evas_Image_Load_Opts *lo)
|
||||
{
|
||||
|
@ -256,36 +255,23 @@ _evas_image_init_set(const Eina_File *f, const char *file, const char *key,
|
|||
|
||||
EINA_COW_IMAGE_STATE_WRITE_BEGIN(o, state_write)
|
||||
{
|
||||
if (f)
|
||||
{
|
||||
if (!state_write->mmaped_source)
|
||||
eina_stringshare_del(state_write->u.file);
|
||||
else if (state_write->u.f)
|
||||
eina_file_close(state_write->u.f);
|
||||
state_write->u.f = eina_file_dup(f);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!state_write->mmaped_source)
|
||||
eina_stringshare_replace(&state_write->u.file, file);
|
||||
else
|
||||
{
|
||||
if (state_write->u.f) eina_file_close(state_write->u.f);
|
||||
state_write->u.file = eina_stringshare_add(file);
|
||||
}
|
||||
}
|
||||
state_write->mmaped_source = !!f;
|
||||
eina_stringshare_replace(&state_write->key, key);
|
||||
Eina_File *tmp = state_write->f;
|
||||
|
||||
state_write->f = NULL;
|
||||
|
||||
if (f) state_write->f = eina_file_dup(f);
|
||||
eina_file_close(tmp);
|
||||
|
||||
eina_stringshare_replace(&state_write->key, key);
|
||||
state_write->opaque_valid = 0;
|
||||
}
|
||||
EINA_COW_IMAGE_STATE_WRITE_END(o, state_write);
|
||||
|
||||
if (o->prev->u.file != NULL || o->prev->key != NULL)
|
||||
if (o->prev->f != NULL || o->prev->key != NULL)
|
||||
{
|
||||
EINA_COW_WRITE_BEGIN(evas_object_image_state_cow, o->prev, Evas_Object_Image_State, state_write)
|
||||
{
|
||||
state_write->u.file = NULL;
|
||||
state_write->f = NULL;
|
||||
state_write->key = NULL;
|
||||
}
|
||||
EINA_COW_WRITE_END(evas_object_image_state_cow, o->prev, state_write);
|
||||
|
@ -300,11 +286,6 @@ _evas_image_init_set(const Eina_File *f, const char *file, const char *key,
|
|||
}
|
||||
ENFN->image_free(ENC, o->engine_data);
|
||||
}
|
||||
if (o->file_obj)
|
||||
{
|
||||
efl_del(o->file_obj);
|
||||
o->file_obj = NULL;
|
||||
}
|
||||
o->load_error = EVAS_LOAD_ERROR_NONE;
|
||||
lo->emile.scale_down_by = o->load_opts->scale_down_by;
|
||||
lo->emile.dpi = o->load_opts->dpi;
|
||||
|
@ -514,10 +495,7 @@ _efl_canvas_image_internal_efl_object_dbg_info_get(Eo *eo_obj, Evas_Image_Data *
|
|||
Efl_Dbg_Info *group = EFL_DBG_INFO_LIST_APPEND(root, MY_CLASS_NAME);
|
||||
|
||||
const char *file, *key;
|
||||
if (o->cur->mmaped_source)
|
||||
file = eina_file_filename_get(o->cur->u.f);
|
||||
else
|
||||
file = o->cur->u.file;
|
||||
file = eina_file_filename_get(o->cur->f);
|
||||
key = o->cur->key;
|
||||
|
||||
EFL_DBG_INFO_APPEND(group, "Image File", EINA_VALUE_TYPE_STRING, file);
|
||||
|
@ -1230,7 +1208,7 @@ _evas_image_unload(Evas_Object *eo_obj, Evas_Object_Protected_Data *obj, Eina_Bo
|
|||
Eina_Bool resize_call = EINA_FALSE;
|
||||
|
||||
o = efl_data_scope_get(eo_obj, MY_CLASS);
|
||||
if ((!o->cur->u.file) ||
|
||||
if ((!o->cur->f) ||
|
||||
(o->pixels_checked_out > 0)) return;
|
||||
|
||||
evas_object_async_block(obj);
|
||||
|
@ -1292,29 +1270,7 @@ _evas_image_load(Evas_Object *eo_obj, Evas_Object_Protected_Data *obj, Evas_Imag
|
|||
lo.emile.orientation = o->load_opts->orientation;
|
||||
lo.emile.degree = 0;
|
||||
lo.skip_head = o->skip_head;
|
||||
if (o->cur->mmaped_source)
|
||||
o->engine_data = ENFN->image_mmap(ENC, o->cur->u.f, o->cur->key, &o->load_error, &lo);
|
||||
else
|
||||
{
|
||||
const char *file2 = o->cur->u.file;
|
||||
|
||||
if (o->file_obj) efl_del(o->file_obj);
|
||||
o->file_obj = NULL;
|
||||
if (file2)
|
||||
{
|
||||
o->file_obj = efl_vpath_manager_fetch(EFL_VPATH_MANAGER_CLASS, file2);
|
||||
efl_vpath_file_do(o->file_obj);
|
||||
// XXX:FIXME: allow this to be async
|
||||
efl_vpath_file_wait(o->file_obj);
|
||||
file2 = efl_vpath_file_result_get(o->file_obj);
|
||||
}
|
||||
o->engine_data = ENFN->image_load(ENC, file2, o->cur->key, &o->load_error, &lo);
|
||||
if ((o->file_obj) && (!efl_vpath_file_keep_get(o->file_obj)))
|
||||
{
|
||||
efl_del(o->file_obj);
|
||||
o->file_obj = NULL;
|
||||
}
|
||||
}
|
||||
o->engine_data = ENFN->image_mmap(ENC, o->cur->f, o->cur->key, &o->load_error, &lo);
|
||||
|
||||
if (o->engine_data)
|
||||
{
|
||||
|
@ -1476,14 +1432,7 @@ evas_object_image_free(Evas_Object *eo_obj, Evas_Object_Protected_Data *obj)
|
|||
Eina_Rectangle *r;
|
||||
|
||||
/* free obj */
|
||||
if (!o->cur->mmaped_source)
|
||||
{
|
||||
if (o->cur->u.file) eina_stringshare_del(o->cur->u.file);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (o->cur->u.f) eina_file_close(o->cur->u.f);
|
||||
}
|
||||
eina_file_close(o->cur->f);
|
||||
if (o->cur->key) eina_stringshare_del(o->cur->key);
|
||||
if (o->cur->source) _evas_image_proxy_unset(eo_obj, obj, o);
|
||||
if (o->cur->scene) _evas_image_3d_unset(eo_obj, obj, o);
|
||||
|
@ -1510,11 +1459,6 @@ evas_object_image_free(Evas_Object *eo_obj, Evas_Object_Protected_Data *obj)
|
|||
}
|
||||
o->engine_data = NULL;
|
||||
o->engine_data_prep = NULL;
|
||||
if (o->file_obj)
|
||||
{
|
||||
efl_del(o->file_obj);
|
||||
o->file_obj = NULL;
|
||||
}
|
||||
if (o->pixels->images_to_free)
|
||||
{
|
||||
eina_hash_free(o->pixels->images_to_free);
|
||||
|
@ -1681,7 +1625,6 @@ evas_process_dirty_pixels(Evas_Object *eo_obj, Evas_Object_Protected_Data *obj,
|
|||
{
|
||||
Evas_Native_Surface *ns;
|
||||
ns = ENFN->image_native_get(engine, o->engine_data);
|
||||
fprintf(stderr, "direct render\n");
|
||||
|
||||
if (ENFN->gl_direct_override_get)
|
||||
ENFN->gl_direct_override_get(engine, &direct_override, &direct_force_off);
|
||||
|
@ -2497,8 +2440,8 @@ evas_object_image_render_pre(Evas_Object *eo_obj,
|
|||
}
|
||||
if (o->changed)
|
||||
{
|
||||
if (((o->cur->u.file) && (!o->prev->u.file)) ||
|
||||
((!o->cur->u.file) && (o->prev->u.file)) ||
|
||||
if (((o->cur->f) && (!o->prev->f)) ||
|
||||
((!o->cur->f) && (o->prev->f)) ||
|
||||
((o->cur->key) && (!o->prev->key)) ||
|
||||
((!o->cur->key) && (o->prev->key))
|
||||
)
|
||||
|
@ -3691,10 +3634,9 @@ EOLIAN static Eina_Strbuf *
|
|||
_efl_canvas_image_internal_efl_object_debug_name_override(Eo *eo_obj, Evas_Image_Data *o, Eina_Strbuf *sb)
|
||||
{
|
||||
sb = efl_debug_name_override(efl_super(eo_obj, MY_CLASS), sb);
|
||||
if (o->cur->u.f)
|
||||
if (o->cur->f)
|
||||
{
|
||||
const char *fname = o->cur->mmaped_source ?
|
||||
eina_file_filename_get(o->cur->u.f) : o->cur->u.file;
|
||||
const char *fname = eina_file_filename_get(o->cur->f);
|
||||
eina_strbuf_append_printf(sb, ":file='%s',key='%s'", fname, o->cur->key);
|
||||
}
|
||||
else if (o->pixels && o->pixels->func.get_pixels)
|
||||
|
|
|
@ -787,7 +787,7 @@ _evas_module_libdir_get(void)
|
|||
if (!pfx) pfx = eina_prefix_new
|
||||
(NULL, _evas_module_libdir_get, "EVAS", "evas", "checkme",
|
||||
PACKAGE_BIN_DIR, PACKAGE_LIB_DIR, PACKAGE_DATA_DIR, PACKAGE_DATA_DIR);
|
||||
if (!pfx) return NULL;
|
||||
if (!pfx) return "";
|
||||
return eina_prefix_lib_get(pfx);
|
||||
}
|
||||
|
||||
|
|
|
@ -637,13 +637,6 @@ MAGIC_CHECK_FAILED(o, t, m)
|
|||
if (!_e) return __VA_ARGS__
|
||||
|
||||
#define EVAS_OBJECT_IMAGE_FREE_FILE_AND_KEY(cur, prev) \
|
||||
if (cur->u.file && !cur->mmaped_source) \
|
||||
{ \
|
||||
eina_stringshare_del(cur->u.file); \
|
||||
if (prev->u.file == cur->u.file) \
|
||||
prev->u.file = NULL; \
|
||||
cur->u.file = NULL; \
|
||||
} \
|
||||
if (cur->key) \
|
||||
{ \
|
||||
eina_stringshare_del(cur->key); \
|
||||
|
@ -651,11 +644,6 @@ MAGIC_CHECK_FAILED(o, t, m)
|
|||
prev->key = NULL; \
|
||||
cur->key = NULL; \
|
||||
} \
|
||||
if (prev->u.file && !prev->mmaped_source) \
|
||||
{ \
|
||||
eina_stringshare_del(prev->u.file); \
|
||||
prev->u.file = NULL; \
|
||||
} \
|
||||
if (prev->key) \
|
||||
{ \
|
||||
eina_stringshare_del(prev->key); \
|
||||
|
|
Loading…
Reference in New Issue