cedric pushed a commit to branch master.

http://git.enlightenment.org/core/elementary.git/commit/?id=840dcc618ead292414b0de64a7a3ae38d778311f

commit 840dcc618ead292414b0de64a7a3ae38d778311f
Author: Cedric Bail <cedric.b...@samsung.com>
Date:   Mon Nov 4 12:17:42 2013 +0900

    elm_image: add mmap_set infrastructure.
---
 src/lib/elm_image.c        | 38 ++++++++++++++++++++++++++++++++++++--
 src/lib/elm_image_eo.h     | 15 +++++++++++++++
 src/lib/elm_image_legacy.h | 28 ++++++++++++++++++++++++++++
 3 files changed, 79 insertions(+), 2 deletions(-)

diff --git a/src/lib/elm_image.c b/src/lib/elm_image.c
index 676d801..f28d11d 100755
--- a/src/lib/elm_image.c
+++ b/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/src/lib/elm_image_eo.h b/src/lib/elm_image_eo.h
index d34f320..f65812f 100644
--- a/src/lib/elm_image_eo.h
+++ b/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,
@@ -108,6 +109,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/src/lib/elm_image_legacy.h b/src/lib/elm_image_legacy.h
index 04bdc8e..f869278 100644
--- a/src/lib/elm_image_legacy.h
+++ b/src/lib/elm_image_legacy.h
@@ -42,6 +42,34 @@ EAPI Eina_Bool        elm_image_memfile_set(Evas_Object 
*obj, const void *img, s
  * 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.
+ *
+ * @param obj The image object
  * @param file The path to 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

-- 


Reply via email to