From 38789cba7bd466746af9bd97386330064ccc2e99 Mon Sep 17 00:00:00 2001 From: Ji-Youn Park Date: Tue, 22 Mar 2016 22:44:04 +0830 Subject: elm_image: remove elm_image_memfile_set api from eo API. memfile_set feature will be deprecated. instead of memfile_set, use Efl.file.mmap. and merge elm_image_obj_mmap_set and elm_image_efl_file_mmap_set --- src/lib/elm_icon.c | 29 ++++------ src/lib/elm_icon.eo | 1 - src/lib/elm_image.c | 130 +++++++++++++++++++++++---------------------- src/lib/elm_image.eo | 47 ---------------- src/lib/elm_image_legacy.h | 26 +++++++++ 5 files changed, 104 insertions(+), 129 deletions(-) (limited to 'src') diff --git a/src/lib/elm_icon.c b/src/lib/elm_icon.c index e2ec1614c..1432d7869 100644 --- a/src/lib/elm_icon.c +++ b/src/lib/elm_icon.c @@ -392,21 +392,6 @@ _elm_icon_efl_file_file_set(Eo *obj, Elm_Icon_Data *sd, const char *file, const return EINA_TRUE; } -EOLIAN static Eina_Bool -_elm_icon_elm_image_memfile_set(Eo *obj, Elm_Icon_Data *sd, const void *img, size_t size, const char *format, const char *key) -{ - Eina_Bool int_ret = EINA_FALSE; - - EINA_SAFETY_ON_NULL_RETURN_VAL(img, EINA_FALSE); - EINA_SAFETY_ON_TRUE_RETURN_VAL(!size, EINA_FALSE); - ELM_SAFE_FREE(sd->stdicon, eina_stringshare_del); - - _edje_signals_free(sd); - - int_ret = elm_obj_image_memfile_set(eo_super(obj, MY_CLASS), img, size, format, key); - return int_ret; -} - EOLIAN static Eina_Bool _elm_icon_elm_widget_theme_apply(Eo *obj, Elm_Icon_Data *sd) { @@ -683,11 +668,19 @@ elm_icon_memfile_set(Evas_Object *obj, const char *format, const char *key) { + Eina_Bool int_ret = EINA_FALSE; ELM_ICON_CHECK(obj) EINA_FALSE; - Eina_Bool ret = EINA_FALSE; - ret = elm_obj_image_memfile_set(obj, img, size, format, key); - return ret; + EINA_SAFETY_ON_NULL_RETURN_VAL(img, EINA_FALSE); + EINA_SAFETY_ON_TRUE_RETURN_VAL(!size, EINA_FALSE); + + ELM_ICON_DATA_GET(obj, sd); + ELM_SAFE_FREE(sd->stdicon, eina_stringshare_del); + + _edje_signals_free(sd); + + int_ret = elm_image_memfile_set(eo_super(obj, MY_CLASS), img, size, format, key); + return int_ret; } EAPI Eina_Bool diff --git a/src/lib/elm_icon.eo b/src/lib/elm_icon.eo index 016a4bbcb..421d0d0c7 100644 --- a/src/lib/elm_icon.eo +++ b/src/lib/elm_icon.eo @@ -104,7 +104,6 @@ class Elm.Icon (Elm.Image) Evas.Object_Smart.add; Evas.Object_Smart.del; Elm.Widget.theme_apply; - Elm.Image.memfile.set; Efl.File.file.set; } events { diff --git a/src/lib/elm_image.c b/src/lib/elm_image.c index 9edeea955..a32a666f2 100644 --- a/src/lib/elm_image.c +++ b/src/lib/elm_image.c @@ -885,35 +885,6 @@ _elm_image_file_set_do(Evas_Object *obj) } } -EOLIAN static Eina_Bool -_elm_image_memfile_set(Eo *obj, Elm_Image_Data *sd, const void *img, size_t size, const char *format, const char *key) -{ - Evas_Load_Error err; - - _elm_image_file_set_do(obj); - - evas_object_image_memfile_set - (sd->img, (void *)img, size, (char *)format, (char *)key); - - sd->preload_status = ELM_IMAGE_PRELOADING; - evas_object_image_preload(sd->img, EINA_FALSE); - - err = evas_object_image_load_error_get(sd->img); - if (err != EVAS_LOAD_ERROR_NONE) - { - if (img) - ERR("Failed to load image from memory block (" FMT_SIZE_T - " bytes): %s (%p)", size, evas_load_error_str(err), sd->img); - else - ERR("NULL image data passed (%p)", sd->img); - return EINA_FALSE; - } - - _elm_image_internal_sizing_eval(obj, sd); - - return EINA_TRUE; -} - EOLIAN static void _elm_image_scale_set(Eo *obj, Elm_Image_Data *sd, double scale) { @@ -947,45 +918,19 @@ _elm_image_eo_base_constructor(Eo *obj, Elm_Image_Data *_pd EINA_UNUSED) return obj; } -EAPI Eina_Bool -elm_image_file_set(Evas_Object *obj, - const char *file, - const char *group) -{ - Eina_Bool ret = EINA_FALSE; - - ELM_IMAGE_CHECK(obj) EINA_FALSE; - ret = efl_file_set(obj, file, group); - elm_obj_image_sizing_eval(obj); - return ret; -} - -EAPI void -elm_image_file_get(const Eo *obj, const char **file, const char **group) -{ - efl_file_get((Eo *) obj, file, group); -} - -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; - ret = efl_file_mmap_set(obj, file, group); - return ret; -} - EOLIAN Eina_Bool -_elm_image_efl_file_mmap_set(Eo *obj, Elm_Image_Data *pd EINA_UNUSED, +_elm_image_efl_file_mmap_set(Eo *obj, Elm_Image_Data *sd, const Eina_File *file, const char *key) { Eina_Bool ret = EINA_FALSE; - ret = elm_obj_image_mmap_set(obj, file, key); - elm_obj_image_sizing_eval(obj); + if (sd->remote) _elm_url_cancel(sd->remote); + sd->remote = NULL; + + if (!sd->async_enable) + ret = _elm_image_smart_internal_file_set(obj, sd, eina_file_filename_get(file), file, key); + else + ret = _elm_image_async_file_set(obj, sd, eina_file_filename_get(file), file, key); return ret; } @@ -1658,4 +1603,63 @@ elm_image_editable_get(const Evas_Object *obj) return evas_draggable_interface_drag_target_get(obj); } +EAPI Eina_Bool +elm_image_file_set(Evas_Object *obj, const char *file, const char *group) +{ + Eina_Bool ret = EINA_FALSE; + + ELM_IMAGE_CHECK(obj) EINA_FALSE; + ret = efl_file_set(obj, file, group); + elm_obj_image_sizing_eval(obj); + return ret; +} + +EAPI void +elm_image_file_get(const Eo *obj, const char **file, const char **group) +{ + efl_file_get((Eo *) obj, file, group); +} + +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; + ret = efl_file_mmap_set(obj, file, group); + return ret; +} + +EAPI Eina_Bool +elm_image_memfile_set(Evas_Object *obj, const void *img, size_t size, const char *format, const char *key) +{ + Evas_Load_Error err; + + ELM_IMAGE_CHECK(obj) EINA_FALSE; + ELM_IMAGE_DATA_GET(obj, sd); + + _elm_image_file_set_do(obj); + + evas_object_image_memfile_set + (sd->img, (void *)img, size, (char *)format, (char *)key); + + sd->preload_status = ELM_IMAGE_PRELOADING; + evas_object_image_preload(sd->img, EINA_FALSE); + + err = evas_object_image_load_error_get(sd->img); + if (err != EVAS_LOAD_ERROR_NONE) + { + if (img) + ERR("Failed to load image from memory block (" FMT_SIZE_T + " bytes): %s (%p)", size, evas_load_error_str(err), sd->img); + else + ERR("NULL image data passed (%p)", sd->img); + return EINA_FALSE; + } + + _elm_image_internal_sizing_eval(obj, sd); + + return EINA_TRUE; +} + #include "elm_image.eo.c" diff --git a/src/lib/elm_image.eo b/src/lib/elm_image.eo index f3c8cbb4f..52ca4b07b 100644 --- a/src/lib/elm_image.eo +++ b/src/lib/elm_image.eo @@ -198,53 +198,6 @@ class Elm.Image (Elm.Widget, Efl.File, Efl.Image_Load, Evas.Clickable_Interface, disabled: bool; [[If true, preloading will be disabled]] } } - @property mmap { - set { - [[Set the file that will be used as the image's source. - - See: elm_image_file_set() - - Note: This function will trigger the Edje file case based on the - extension of the $file string use to create the Eina_File (expects - $".edj", for this case). - - 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.]] - - return: bool; [[$true = success, $false = error]] - legacy: null; - } - values { - file: const(Eina.File)*; [[The handler to an Eina_File that will be used as image source]] - group: const(char)* @optional; [[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.]] - } - } - @property memfile { - set { - [[Set a location in memory to be used as an image object's source bitmap. - - This function is handy when the contents of an image file are - mapped in memory, for example. - - The $format string should be something like $"png", $"jpg", - $"tga", $"tiff", $"bmp" etc, when provided ($NULL, on the - contrary). This improves the loader performance as it tries the - "correct" loader first, before trying a range of other possible - loaders until one succeeds. - - @since 1.7]] - - return: bool; [[$true = success, $false = error]] - } - values { - img: const(void)*; [[The binary data that will be used as image source]] - size: size; [[The size of binary data blob $img]] - format: const(char)* @optional; [[(Optional) expected format of $img bytes]] - key: const(char)* @optional; [[Optional indexing key of $img to be passed to the image loader (eg. if $img is a memory-mapped EET file)]] - } - } @property object { get { [[Get the inlined image object of the image widget. diff --git a/src/lib/elm_image_legacy.h b/src/lib/elm_image_legacy.h index 01df5fe3a..db798831d 100644 --- a/src/lib/elm_image_legacy.h +++ b/src/lib/elm_image_legacy.h @@ -272,4 +272,30 @@ EAPI void elm_image_editable_set(Evas_Object *obj, Eina_Bool set); * @ingroup Elm_Image */ EAPI Eina_Bool elm_image_editable_get(const Evas_Object *obj); + +/** + * @brief Set a location in memory to be used as an image object's source + * bitmap. + * + * This function is handy when the contents of an image file are mapped in + * memory, for example. + * + * The @c format string should be something like $"png", $"jpg", $"tga", + * $"tiff", $"bmp" etc, when provided ($NULL, on the contrary). This improves + * the loader performance as it tries the "correct" loader first, before trying + * a range of other possible loaders until one succeeds. + * + * @param[in] img The binary data that will be used as image source + * @param[in] size The size of binary data blob @c img + * @param[in] format (Optional) expected format of @c img bytes + * @param[in] key Optional indexing key of @c img to be passed to the image + * loader (eg. if @c img is a memory-mapped EET file) + * + * @return @c true = success, @c false = error + * + * @since 1.7 + * + * @ingroup Elm_Image + */ +EAPI Eina_Bool elm_image_memfile_set(Evas_Object *obj, const void *img, size_t size, const char *format, const char *key); #include "elm_image.eo.legacy.h" -- cgit v1.2.1