aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorCedric BAIL <cedric@osg.samsung.com>2015-04-03 16:23:14 +0200
committerCedric BAIL <cedric@osg.samsung.com>2015-04-03 16:23:14 +0200
commit2067e85d68915ee0e1fd4bbc0d196cc2be66b7ae (patch)
tree2a7b9e36935f5ab5e3c71951156b96c5f37a3f80 /src
parentefl: move mmap API to be part of Efl_File class. (diff)
downloadefl-2067e85d68915ee0e1fd4bbc0d196cc2be66b7ae.tar.gz
evas: use the new Efl_File mmap function correctly for Evas_VG API.
Diffstat (limited to 'src')
-rw-r--r--src/lib/evas/canvas/evas_object_vg.c29
-rw-r--r--src/lib/evas/canvas/evas_vg.eo32
-rw-r--r--src/lib/evas/canvas/evas_vg_image.c38
-rw-r--r--src/lib/evas/canvas/evas_vg_image.eo2
4 files changed, 57 insertions, 44 deletions
diff --git a/src/lib/evas/canvas/evas_object_vg.c b/src/lib/evas/canvas/evas_object_vg.c
index f74e06e3e4..c6bc95a05c 100644
--- a/src/lib/evas/canvas/evas_object_vg.c
+++ b/src/lib/evas/canvas/evas_object_vg.c
@@ -361,13 +361,26 @@ 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
+_evas_vg_efl_file_mmap_set(Eo *obj EINA_UNUSED, Evas_VG_Data *pd,
+ const Eina_File *f, const char *key)
{
Eina_File *tmp = f ? eina_file_dup(f) : NULL;
- // Start parsing here.
+ if (f == pd->f &&
+ ((key == NULL && pd->key == NULL) ||
+ (key != NULL && pd->key != NULL && !strcmp(key, pd->key))))
+ return EINA_FALSE;
+
+ tmp = f ? eina_file_dup(f) : NULL;
+
+ if (tmp)
+ {
+ if (!evas_vg_loader_svg(obj, tmp, NULL))
+ {
+ eina_file_close(tmp);
+ return EINA_FALSE;
+ }
+ }
// it succeeded.
if (pd->f) eina_file_close(pd->f);
@@ -377,8 +390,8 @@ _evas_vg_mmap_set(Eo *obj EINA_UNUSED, Evas_VG_Data *pd,
}
static void
-_evas_vg_mmap_get(Eo *obj EINA_UNUSED, Evas_VG_Data *pd,
- const Eina_File **f, const char **key)
+_evas_vg_efl_file_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;
@@ -394,7 +407,7 @@ _evas_vg_efl_file_file_set(Eo *obj, Evas_VG_Data *pd EINA_UNUSED,
f = eina_file_open(file, EINA_FALSE);
if (!f) return EINA_FALSE;
- eo_do(obj, r = evas_obj_vg_mmap_set(f, key));
+ eo_do(obj, efl_file_mmap_set(f, key));
eina_file_close(f);
return r;
@@ -406,7 +419,7 @@ _evas_vg_efl_file_file_get(Eo *obj, Evas_VG_Data *pd EINA_UNUSED,
{
const Eina_File *f = NULL;
- eo_do(obj, evas_obj_vg_mmap_get(&f, key));
+ eo_do(obj, efl_file_mmap_get(&f, key));
if (file) *file = eina_file_filename_get(f);
}
diff --git a/src/lib/evas/canvas/evas_vg.eo b/src/lib/evas/canvas/evas_vg.eo
index bf4960e3c1..24037d2384 100644
--- a/src/lib/evas/canvas/evas_vg.eo
+++ b/src/lib/evas/canvas/evas_vg.eo
@@ -30,36 +30,6 @@ 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. */
- }
- }
fill {
set {
/*@
@@ -115,5 +85,7 @@ class Evas.VG (Evas.Object, Efl.File)
Eo.Base.constructor;
Efl.File.file.set;
Efl.File.file.get;
+ Efl.File.mmap.set;
+ Efl.File.mmap.get;
}
} \ No newline at end of file
diff --git a/src/lib/evas/canvas/evas_vg_image.c b/src/lib/evas/canvas/evas_vg_image.c
index 4529197d51..62f02ece28 100644
--- a/src/lib/evas/canvas/evas_vg_image.c
+++ b/src/lib/evas/canvas/evas_vg_image.c
@@ -7,7 +7,8 @@ typedef struct _Evas_VG_Image_Data Evas_VG_Image_Data;
struct _Evas_VG_Image_Data
{
// FIXME: only manipulate Eina_File internally.
- Eina_Stringshare *file, *key;
+ Eina_File *f;
+ Eina_Stringshare *key;
int x, y;
unsigned int w, h;
@@ -44,20 +45,45 @@ _evas_vg_image_size_get(Eo *obj, Evas_VG_Image_Data *pd,
}
static Eina_Bool
+_evas_vg_image_efl_file_mmap_set(Eo *obj EINA_UNUSED, Evas_VG_Image_Data *pd,
+ const Eina_File *f, const char *key)
+{
+ Eina_File *tmp = pd->f;
+
+ pd->f = eina_file_dup(f);
+ eina_file_close(tmp);
+ eina_stringshare_replace(&pd->key, key);
+
+ return EINA_TRUE;
+}
+
+static void
+_evas_vg_image_efl_file_mmap_get(Eo *obj EINA_UNUSED, Evas_VG_Image_Data *pd,
+ const Eina_File **f, const char **key)
+{
+ if (f) *f = pd->f;
+ if (key) *key = pd->key;
+}
+
+static Eina_Bool
_evas_vg_image_efl_file_file_set(Eo *obj, Evas_VG_Image_Data *pd,
const char *file, const char *key)
{
- eina_stringshare_replace(&pd->file, file);
- eina_stringshare_replace(&pd->key, key);
+ Eina_File *tmp;
+ Eina_Bool r;
+
+ tmp = eina_file_open(file, EINA_FALSE);
+ r = _evas_vg_image_efl_file_mmap_set(obj, pd, tmp, key);
+ eina_file_close(tmp);
- return EINA_FALSE;
+ return r;
}
static void
-_evas_vg_image_efl_file_file_get(Eo *obj, Evas_VG_Image_Data *pd,
+_evas_vg_image_efl_file_file_get(Eo *obj EINA_UNUSED, Evas_VG_Image_Data *pd,
const char **file, const char **key)
{
- if (file) *file = pd->file;
+ if (file) *file = eina_file_filename_get(pd->f);
if (key) *key = pd->key;
}
diff --git a/src/lib/evas/canvas/evas_vg_image.eo b/src/lib/evas/canvas/evas_vg_image.eo
index 33fe0b0272..ff9ab8e965 100644
--- a/src/lib/evas/canvas/evas_vg_image.eo
+++ b/src/lib/evas/canvas/evas_vg_image.eo
@@ -28,6 +28,8 @@ class Evas.VG_Image (Evas.VG_Node, Efl.File)
implements {
Efl.File.file.set;
Efl.File.file.get;
+ Efl.File.mmap.set;
+ Efl.File.mmap.get;
Eo.Base.constructor;
Eo.Base.destructor;
}