summaryrefslogtreecommitdiff
path: root/src/lib/evas/canvas
diff options
context:
space:
mode:
authorMike Blumenkrantz <michael.blumenkrantz@gmail.com>2019-02-27 13:17:35 -0500
committerMike Blumenkrantz <zmike@samsung.com>2019-02-27 13:17:35 -0500
commit540d3b95874e1ebdcbd6ccf9eaf1cab0af30f833 (patch)
tree34575d7a518cecc4745576be7ea3099a5087268d /src/lib/evas/canvas
parent4192753490a3c791cc18c57be07c230b9ca33732 (diff)
efl.file_save: rework save flags
Summary: instead of passing a string which requires reading docs to know which arbitrary string key=value sets can be passed, use an extensible struct which contains more easily referenced values ref T7672 Depends on D8035 Reviewers: segfaultxavi Reviewed By: segfaultxavi Subscribers: segfaultxavi, cedric, #reviewers, #committers Tags: #efl Maniphest Tasks: T7672 Differential Revision: https://phab.enlightenment.org/D8039
Diffstat (limited to 'src/lib/evas/canvas')
-rw-r--r--src/lib/evas/canvas/efl_canvas_vg_object.c6
-rw-r--r--src/lib/evas/canvas/evas_canvas3d_mesh.c2
-rw-r--r--src/lib/evas/canvas/evas_image_legacy.c33
-rw-r--r--src/lib/evas/canvas/evas_object_image.c61
-rw-r--r--src/lib/evas/canvas/evas_vg_private.h4
5 files changed, 60 insertions, 46 deletions
diff --git a/src/lib/evas/canvas/efl_canvas_vg_object.c b/src/lib/evas/canvas/efl_canvas_vg_object.c
index db224fd..25c092f 100644
--- a/src/lib/evas/canvas/efl_canvas_vg_object.c
+++ b/src/lib/evas/canvas/efl_canvas_vg_object.c
@@ -292,14 +292,14 @@ _efl_canvas_vg_object_efl_file_unload(Eo *eo_obj, Efl_Canvas_Vg_Object_Data *pd)
292} 292}
293 293
294EOLIAN static Eina_Bool 294EOLIAN static Eina_Bool
295_efl_canvas_vg_object_efl_file_save_save(const Eo *obj, Efl_Canvas_Vg_Object_Data *pd, const char *file, const char *key, const char *flags) 295_efl_canvas_vg_object_efl_file_save_save(const Eo *obj, Efl_Canvas_Vg_Object_Data *pd, const char *file, const char *key, const Efl_File_Save_Info *info)
296{ 296{
297 if (pd->vg_entry) 297 if (pd->vg_entry)
298 return evas_cache_vg_entry_file_save(pd->vg_entry, file, key, flags); 298 return evas_cache_vg_entry_file_save(pd->vg_entry, file, key, info);
299 299
300 Evas_Coord w, h; 300 Evas_Coord w, h;
301 evas_object_geometry_get(obj, NULL, NULL, &w, &h); 301 evas_object_geometry_get(obj, NULL, NULL, &w, &h);
302 return evas_cache_vg_file_save(pd->root, w, h, file, key, flags); 302 return evas_cache_vg_file_save(pd->root, w, h, file, key, info);
303} 303}
304 304
305static void 305static void
diff --git a/src/lib/evas/canvas/evas_canvas3d_mesh.c b/src/lib/evas/canvas/evas_canvas3d_mesh.c
index ccac776..bdf50e0d 100644
--- a/src/lib/evas/canvas/evas_canvas3d_mesh.c
+++ b/src/lib/evas/canvas/evas_canvas3d_mesh.c
@@ -887,7 +887,7 @@ EOLIAN static Eina_Bool
887_evas_canvas3d_mesh_efl_file_save_save(const Eo *obj, Evas_Canvas3D_Mesh_Data *pd, 887_evas_canvas3d_mesh_efl_file_save_save(const Eo *obj, Evas_Canvas3D_Mesh_Data *pd,
888 const char *file, 888 const char *file,
889 const char *key EINA_UNUSED, 889 const char *key EINA_UNUSED,
890 const char *flags EINA_UNUSED) 890 const Efl_File_Save_Info *info EINA_UNUSED)
891{ 891{
892 if ((file == NULL) || (obj == NULL) || (pd == NULL)) return EINA_FALSE; 892 if ((file == NULL) || (obj == NULL) || (pd == NULL)) return EINA_FALSE;
893 893
diff --git a/src/lib/evas/canvas/evas_image_legacy.c b/src/lib/evas/canvas/evas_image_legacy.c
index 886a37f..88052a7 100644
--- a/src/lib/evas/canvas/evas_image_legacy.c
+++ b/src/lib/evas/canvas/evas_image_legacy.c
@@ -221,8 +221,39 @@ evas_object_image_mmap_get(const Evas_Object *obj, const Eina_File **f, const ch
221EAPI Eina_Bool 221EAPI Eina_Bool
222evas_object_image_save(const Evas_Object *obj, const char *file, const char *key, const char *flags) 222evas_object_image_save(const Evas_Object *obj, const char *file, const char *key, const char *flags)
223{ 223{
224 char *encoding = NULL;
225 Efl_File_Save_Info info;
226 Eina_Error ret;
227
224 EVAS_IMAGE_API(obj, EINA_FALSE); 228 EVAS_IMAGE_API(obj, EINA_FALSE);
225 return efl_file_save(obj, file, key, flags); 229
230 if (flags)
231 {
232 char *p, *pp;
233 char *tflags;
234 int quality = 80, compress = 9;
235
236 tflags = alloca(strlen(flags) + 1);
237 strcpy(tflags, flags);
238 p = tflags;
239 while (p)
240 {
241 pp = strchr(p, ' ');
242 if (pp) *pp = 0;
243 sscanf(p, "quality=%4i", &quality);
244 sscanf(p, "compress=%4i", &compress);
245 sscanf(p, "encoding=%ms", &encoding);
246 if (pp) p = pp + 1;
247 else break;
248 }
249 info.quality = quality;
250 info.compression = compress;
251 info.encoding = encoding;
252
253 }
254 ret = efl_file_save(obj, file, key, flags ? &info : NULL);
255 free(encoding);
256 return ret;
226} 257}
227 258
228EAPI Eina_Bool 259EAPI Eina_Bool
diff --git a/src/lib/evas/canvas/evas_object_image.c b/src/lib/evas/canvas/evas_object_image.c
index a47934e..1053451 100644
--- a/src/lib/evas/canvas/evas_object_image.c
+++ b/src/lib/evas/canvas/evas_object_image.c
@@ -861,10 +861,10 @@ _efl_canvas_image_internal_efl_gfx_image_image_load_error_get(const Eo *eo_obj E
861} 861}
862 862
863EOLIAN static Eina_Bool 863EOLIAN static Eina_Bool
864_efl_canvas_image_internal_efl_file_save_save(const Eo *eo_obj, Evas_Image_Data *o, const char *file, const char *key, const char *flags) 864_efl_canvas_image_internal_efl_file_save_save(const Eo *eo_obj, Evas_Image_Data *o, const char *file, const char *key, const Efl_File_Save_Info *info)
865{ 865{
866 int quality = 80, compress = 9, ok = 0; 866 int quality = 80, compress = 9, ok = 0;
867 char *encoding = NULL; 867 const char *encoding = NULL;
868 Image_Entry *ie; 868 Image_Entry *ie;
869 Evas_Colorspace cspace = EVAS_COLORSPACE_ARGB8888; 869 Evas_Colorspace cspace = EVAS_COLORSPACE_ARGB8888;
870 Evas_Colorspace want_cspace = EVAS_COLORSPACE_ARGB8888; 870 Evas_Colorspace want_cspace = EVAS_COLORSPACE_ARGB8888;
@@ -889,46 +889,31 @@ _efl_canvas_image_internal_efl_file_save_save(const Eo *eo_obj, Evas_Image_Data
889 889
890 cspace = ENFN->image_file_colorspace_get(ENC, pixels); 890 cspace = ENFN->image_file_colorspace_get(ENC, pixels);
891 want_cspace = cspace; 891 want_cspace = cspace;
892 892 if (info)
893 if (flags)
894 { 893 {
895 const char *ext; 894 encoding = info->encoding;
896 char *p, *pp; 895 quality = info->quality;
897 char *tflags; 896 compress = info->compression;
898 897 }
899 tflags = alloca(strlen(flags) + 1);
900 strcpy(tflags, flags);
901 p = tflags;
902 while (p)
903 {
904 pp = strchr(p, ' ');
905 if (pp) *pp = 0;
906 sscanf(p, "quality=%4i", &quality);
907 sscanf(p, "compress=%4i", &compress);
908 sscanf(p, "encoding=%ms", &encoding);
909 if (pp) p = pp + 1;
910 else break;
911 }
912 898
913 if (encoding) 899 if (encoding)
900 {
901 const char *ext = strrchr(file, '.');
902 if (ext && !strcasecmp(ext, ".tgv"))
914 { 903 {
915 ext = strrchr(file, '.'); 904 if (!strcmp(encoding, "auto"))
916 if (ext && !strcasecmp(ext, ".tgv")) 905 want_cspace = cspace;
906 else if (!strcmp(encoding, "etc1"))
907 want_cspace = EVAS_COLORSPACE_ETC1;
908 else if (!strcmp(encoding, "etc2"))
917 { 909 {
918 if (!strcmp(encoding, "auto")) 910 if (!ENFN->image_alpha_get(ENC, pixels))
919 want_cspace = cspace; 911 want_cspace = EVAS_COLORSPACE_RGB8_ETC2;
920 else if (!strcmp(encoding, "etc1")) 912 else
921 want_cspace = EVAS_COLORSPACE_ETC1; 913 want_cspace = EVAS_COLORSPACE_RGBA8_ETC2_EAC;
922 else if (!strcmp(encoding, "etc2"))
923 {
924 if (!ENFN->image_alpha_get(ENC, pixels))
925 want_cspace = EVAS_COLORSPACE_RGB8_ETC2;
926 else
927 want_cspace = EVAS_COLORSPACE_RGBA8_ETC2_EAC;
928 }
929 else if (!strcmp(encoding, "etc1+alpha"))
930 want_cspace = EVAS_COLORSPACE_ETC1_ALPHA;
931 } 914 }
915 else if (!strcmp(encoding, "etc1+alpha"))
916 want_cspace = EVAS_COLORSPACE_ETC1_ALPHA;
932 } 917 }
933 } 918 }
934 919
@@ -971,12 +956,10 @@ _efl_canvas_image_internal_efl_file_save_save(const Eo *eo_obj, Evas_Image_Data
971 if (unmap_it) 956 if (unmap_it)
972 ENFN->image_data_unmap(ENC, pixels, &slice); 957 ENFN->image_data_unmap(ENC, pixels, &slice);
973 958
974 free(encoding);
975 if (!ok) ERR("Image save failed."); 959 if (!ok) ERR("Image save failed.");
976 return ok; 960 return ok;
977 961
978no_pixels: 962no_pixels:
979 free(encoding);
980 ERR("Could not get image pixels for saving."); 963 ERR("Could not get image pixels for saving.");
981 return EINA_FALSE; 964 return EINA_FALSE;
982} 965}
diff --git a/src/lib/evas/canvas/evas_vg_private.h b/src/lib/evas/canvas/evas_vg_private.h
index 904c425..7fb62d4 100644
--- a/src/lib/evas/canvas/evas_vg_private.h
+++ b/src/lib/evas/canvas/evas_vg_private.h
@@ -123,8 +123,8 @@ Vg_Cache_Entry* evas_cache_vg_entry_create(const char *file, const c
123Efl_VG* evas_cache_vg_tree_get(Vg_Cache_Entry *vg_entry); 123Efl_VG* evas_cache_vg_tree_get(Vg_Cache_Entry *vg_entry);
124void evas_cache_vg_entry_del(Vg_Cache_Entry *vg_entry); 124void evas_cache_vg_entry_del(Vg_Cache_Entry *vg_entry);
125Vg_File_Data * evas_cache_vg_file_open(const char *file, const char *key); 125Vg_File_Data * evas_cache_vg_file_open(const char *file, const char *key);
126Eina_Bool evas_cache_vg_file_save(Efl_VG *root, int w, int h, const char *file, const char *key, const char *flags); 126Eina_Bool evas_cache_vg_file_save(Efl_VG *root, int w, int h, const char *file, const char *key, const Efl_File_Save_Info *info);
127Eina_Bool evas_cache_vg_entry_file_save(Vg_Cache_Entry *vg_entry, const char *file, const char *key, const char *flags); 127Eina_Bool evas_cache_vg_entry_file_save(Vg_Cache_Entry *vg_entry, const char *file, const char *key, const Efl_File_Save_Info *info);
128void efl_canvas_vg_node_vg_obj_set(Efl_VG *node, Efl_VG *vg_obj, Efl_Canvas_Vg_Object_Data *vd); 128void efl_canvas_vg_node_vg_obj_set(Efl_VG *node, Efl_VG *vg_obj, Efl_Canvas_Vg_Object_Data *vd);
129void efl_canvas_vg_node_change(Efl_VG *node); 129void efl_canvas_vg_node_change(Efl_VG *node);
130void efl_canvas_vg_container_vg_obj_update(Efl_VG *obj, Efl_Canvas_Vg_Node_Data *nd); 130void efl_canvas_vg_container_vg_obj_update(Efl_VG *obj, Efl_Canvas_Vg_Node_Data *nd);