evas: add file manipulation API to Evas_Object_VG. 90/43190/1
authorCedric BAIL <cedric@osg.samsung.com>
Thu, 22 Jan 2015 09:33:38 +0000 (10:33 +0100)
committerSubhransu Mohanty <sub.mohanty@samsung.com>
Wed, 8 Jul 2015 02:01:34 +0000 (11:01 +0900)
Change-Id: Ic5a56bff1930a3b5b0d01e1d44159b77882bfcd2

src/lib/evas/canvas/evas_object_vg.c
src/lib/evas/canvas/evas_vg.eo

index 07bf19d..23cc4f7 100644 (file)
@@ -16,8 +16,12 @@ typedef struct _Evas_VG_Data      Evas_VG_Data;
 
 struct _Evas_VG_Data
 {
-   void             *engine_data;
-   Evas_VG_Node     *root;
+   void         *engine_data;
+   Evas_VG_Node *root;
+
+   /* Opening an SVG file (could actually be inside an eet section */
+   Eina_File    *f;
+   const char   *key;
 };
 
 static void evas_object_vg_render(Evas_Object *eo_obj,
@@ -321,18 +325,55 @@ evas_object_vg_was_opaque(Evas_Object *eo_obj EINA_UNUSED,
 }
 
 
+static Eina_Bool
+_evas_vg_mmap_set(Eo *obj EINA_UNUSED, Evas_VG_Data *pd,
+                  const Eina_File *f, const char *key EINA_UNUSED)
+// For now we don't handle eet section filled with SVG, that's for later
+{
+   Eina_File *tmp = f ? eina_file_dup(f) : NULL;
+
+   // Start parsing here.
+
+   // it succeeded.
+   if (pd->f) eina_file_close(pd->f);
+   pd->f = tmp;
+
+   return EINA_TRUE;
+}
+
+static void
+_evas_vg_mmap_get(Eo *obj EINA_UNUSED, Evas_VG_Data *pd,
+                  const Eina_File **f, const char **key)
+{
+   if (f) *f = pd->f;
+   if (key) *key = pd->key;
+}
+
 Eina_Bool
-_evas_vg_efl_file_file_set(Eo *obj, Evas_VG_Data *pd,
+_evas_vg_efl_file_file_set(Eo *obj, Evas_VG_Data *pd EINA_UNUSED,
                            const char *file, const char *key)
 {
-   // FIXME: just load SVG for now
-   return EINA_FALSE;
+   Eina_File *f;
+   Eina_Bool r = EINA_FALSE;
+
+   f = eina_file_open(file, EINA_FALSE);
+   if (!f) return EINA_FALSE;
+
+   eo_do(obj, r = evas_obj_vg_mmap_set(f, key));
+
+   eina_file_close(f);
+   return r;
 }
 
 void
-_evas_vg_efl_file_file_get(Eo *obj, Evas_VG_Data *pd,
+_evas_vg_efl_file_file_get(Eo *obj, Evas_VG_Data *pd EINA_UNUSED,
                            const char **file, const char **key)
 {
+   const Eina_File *f = NULL;
+
+   eo_do(obj, evas_obj_vg_mmap_get(&f, key));
+
+   if (file) *file = eina_file_filename_get(f);
 }
 
 void
index 64cd2d1..dcf047b 100644 (file)
@@ -23,6 +23,36 @@ class Evas.VG (Evas.Object, Efl.File)
            uint h;
         }
       }
+      mmap {
+         set {
+            /*@
+            Set the source mmaped file from where an image object must fetch the real
+            image data (it must be an Eina_File).
+
+            If the file supports multiple data stored in it (as Eet files do),
+            you can specify the key to be used as the index of the image in
+            this file.
+
+            @since 1.14 */
+           return: bool;
+         }
+         get {
+            /*@
+            Get the source mmaped file from where an image object must fetch the real
+            image data (it must be an Eina_File).
+
+            If the file supports multiple data stored in it (as Eet files do),
+            you can get the key to be used as the index of the image in
+            this file.
+
+            @since 1.14 */
+         }
+         values {
+            const(Eina.File)* f; /*@ The mmaped file */
+            const(char)* key; /*@ The image key in @p file (if its an Eet one), or @c
+            NULL, otherwise. */
+         }
+      }
    }
    implements {
       Eo.Base.constructor;