diff --git a/legacy/elementary/src/lib/elm_image.c b/legacy/elementary/src/lib/elm_image.c index 676d801ce0..f28d11d44b 100755 --- a/legacy/elementary/src/lib/elm_image.c +++ b/legacy/elementary/src/lib/elm_image.c @@ -191,7 +191,7 @@ _elm_image_internal_sizing_eval(Evas_Object *obj, Elm_Image_Smart_Data *sd) static Eina_Bool _elm_image_edje_file_set(Evas_Object *obj, const char *file, - Eina_File *f, + const Eina_File *f, const char *group) { Evas_Object *pclip; @@ -851,9 +851,24 @@ elm_image_file_set(Evas_Object *obj, return ret; } +EAPI Eina_Bool +elm_image_mmap_set(Evas_Object *obj, + const Eina_File *file, + const char *group) +{ + Eina_Bool ret = EINA_FALSE; + + ELM_IMAGE_CHECK(obj) EINA_FALSE; + EINA_SAFETY_ON_NULL_RETURN_VAL(file, EINA_FALSE); + eo_do(obj, + elm_obj_image_mmap_set(file, group, &ret), + elm_obj_image_sizing_eval()); + return ret; +} + static void _elm_image_smart_internal_file_set(Eo *obj, Elm_Image_Smart_Data *sd, - const char *file, Eina_File *f, const char *key, Eina_Bool *ret) + const char *file, const Eina_File *f, const char *key, Eina_Bool *ret) { if (eina_str_has_extension(file, ".edj")) { @@ -997,6 +1012,23 @@ _elm_image_smart_file_set(Eo *obj, void *_pd, va_list *list) _elm_image_smart_internal_file_set(obj, sd, file, NULL, key, ret); } +static void +_elm_image_smart_mmap_set(Eo *obj, void *_pd, va_list *list) +{ + const Eina_File *f = va_arg(*list, const Eina_File *); + const char *key = va_arg(*list, const char*); + Eina_Bool *ret = va_arg(*list, Eina_Bool *); + + Elm_Image_Smart_Data *sd = _pd; + + if (sd->remote) elm_url_cancel(sd->remote); + sd->remote = NULL; + + _elm_image_smart_internal_file_set(obj, sd, + eina_file_filename_get(f), f, + key, ret); +} + EAPI void elm_image_file_get(const Evas_Object *obj, const char **file, @@ -1720,6 +1752,7 @@ _class_constructor(Eo_Class *klass) EO_OP_FUNC(ELM_OBJ_IMAGE_ID(ELM_OBJ_IMAGE_SUB_ID_LOAD_SIZE_GET), _elm_image_smart_load_size_get), EO_OP_FUNC(ELM_OBJ_IMAGE_ID(ELM_OBJ_IMAGE_SUB_ID_MEMFILE_SET), _elm_image_smart_memfile_set), + EO_OP_FUNC(ELM_OBJ_IMAGE_ID(ELM_OBJ_IMAGE_SUB_ID_MMAP_SET), _elm_image_smart_mmap_set), EO_OP_FUNC(ELM_OBJ_IMAGE_ID(ELM_OBJ_IMAGE_SUB_ID_ORIENT_SET), _elm_image_smart_orient_set), EO_OP_FUNC(ELM_OBJ_IMAGE_ID(ELM_OBJ_IMAGE_SUB_ID_ORIENT_GET), _elm_image_smart_orient_get), @@ -1788,6 +1821,7 @@ static const Eo_Op_Description op_desc[] = { EO_OP_DESCRIPTION(ELM_OBJ_IMAGE_SUB_ID_LOAD_SIZE_GET, "'Virtual' function on retrieving the object's image loading size."), EO_OP_DESCRIPTION(ELM_OBJ_IMAGE_SUB_ID_MEMFILE_SET, "Set a location in memory to be used as an image object's source bitmap."), + EO_OP_DESCRIPTION(ELM_OBJ_IMAGE_SUB_ID_MMAP_SET, "Set an Eina_File to be used as an image object's source bitmap."), EO_OP_DESCRIPTION(ELM_OBJ_IMAGE_SUB_ID_ORIENT_SET, "Set the image orientation."), EO_OP_DESCRIPTION(ELM_OBJ_IMAGE_SUB_ID_ORIENT_GET, "Get the image orientation."), diff --git a/legacy/elementary/src/lib/elm_image_eo.h b/legacy/elementary/src/lib/elm_image_eo.h index d34f320c3d..f65812fae9 100644 --- a/legacy/elementary/src/lib/elm_image_eo.h +++ b/legacy/elementary/src/lib/elm_image_eo.h @@ -37,6 +37,7 @@ enum ELM_OBJ_IMAGE_SUB_ID_LOAD_SIZE_GET, ELM_OBJ_IMAGE_SUB_ID_MEMFILE_SET, + ELM_OBJ_IMAGE_SUB_ID_MMAP_SET, ELM_OBJ_IMAGE_SUB_ID_ORIENT_SET, ELM_OBJ_IMAGE_SUB_ID_ORIENT_GET, @@ -107,6 +108,20 @@ enum */ #define elm_obj_image_file_set(file, group, ret) ELM_OBJ_IMAGE_ID(ELM_OBJ_IMAGE_SUB_ID_FILE_SET), EO_TYPECHECK(const char *, file), EO_TYPECHECK(const char *, group), EO_TYPECHECK(Eina_Bool *, ret) +/** + * @def elm_obj_image_mmap_set + * @since 1.8 + * + * Set the file that will be used as the image's source. + * + * @param[in] file + * @param[in] group + * @param[out] ret + * + * @see elm_image_mmap_set + */ +#define elm_obj_image_mmap_set(file, group, ret) ELM_OBJ_IMAGE_ID(ELM_OBJ_IMAGE_SUB_ID_MMAP_SET), EO_TYPECHECK(const Eina_File *, file), EO_TYPECHECK(const char *, group), EO_TYPECHECK(Eina_Bool *, ret) + /** * @def elm_obj_image_file_get * @since 1.8 diff --git a/legacy/elementary/src/lib/elm_image_legacy.h b/legacy/elementary/src/lib/elm_image_legacy.h index 04bdc8ee88..f869278616 100644 --- a/legacy/elementary/src/lib/elm_image_legacy.h +++ b/legacy/elementary/src/lib/elm_image_legacy.h @@ -38,6 +38,34 @@ EAPI Evas_Object *elm_image_add(Evas_Object *parent); */ EAPI Eina_Bool elm_image_memfile_set(Evas_Object *obj, const void *img, size_t size, const char *format, const char *key); +/** + * Set the file that will be used as the image's source. + * + * @param obj The image object + * @param file The handler to an Eina_File that will be used as image source + * @param group The group that the image belongs to, in case it's an + * EET (including Edje case) file. This can be used as a key inside + * evas image cache if this is a normal image file not eet file. + * + * @return (@c EINA_TRUE = success, @c EINA_FALSE = error) + * + * @see elm_image_file_set() + * + * @note This function will trigger the Edje file case based on the + * extension of the @a file string use to create the Eina_File (expects + * @c ".edj", for this case). If one wants to force this type of file + * independently of the extension, elm_image_file_edje_set() must be + * used, instead. + * + * @note If you use animated gif image and create multiple image objects with + * one gif image file, you should set the @group differently for each object. + * Or image objects will share one evas image cache entry and you will get + * unwanted frames. + * + * @ingroup Image + */ +EAPI Eina_Bool elm_image_mmap_set(Evas_Object *obj, const Eina_File *file, const char *group); + /** * Set the file that will be used as the image's source. *