We can almost remove image_load from the engine backend after this patch.
One little bit left in Evas_3D.
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;
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;
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;
}
_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;
}
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);
}
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);
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);
}
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);
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;
{
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;
}
return EINA_FALSE;
}
- if (o->file_obj)
- {
- efl_del(o->file_obj);
- o->file_obj = NULL;
- }
-
if (o->engine_data)
{
Evas_Colorspace ics;
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;
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; }
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);
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;
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);
[[Internal class for legacy support of Evas Image.]]
data: null;
implements {
- Efl.File.file { get; set; }
Efl.File.mmap { get; set; }
}
}
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
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)
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);
if (for_writing)
{
o->written = EINA_TRUE;
- EVAS_OBJECT_WRITE_IMAGE_FREE_FILE_AND_KEY(o);
}
return 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,
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 */
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);
}
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)
{
WRN("efl_file_mmap_set shouldn't be used on Evas.Image. please switch to Efl.Canvas.Image");
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;
Eina_Bool has_alpha :1;
Eina_Bool opaque_valid : 1;
Eina_Bool opaque : 1;
- Eina_Bool mmaped_source : 1;
};
struct _Evas_Image_Data
void *engine_data;
void *engine_data_prep;
- Efl_Vpath_File *file_obj;
void *plane;
};
/* 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);
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) \
{ \
{ 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,
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;
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);
}
}
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)
{
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);
}
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;
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);
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);
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)
{
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);
}
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);
{
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);
}
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))
)
_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)
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);
}
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); \
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); \