diff options
Diffstat (limited to 'src/lib/evas/canvas/evas_image_legacy.c')
-rw-r--r-- | src/lib/evas/canvas/evas_image_legacy.c | 99 |
1 files changed, 72 insertions, 27 deletions
diff --git a/src/lib/evas/canvas/evas_image_legacy.c b/src/lib/evas/canvas/evas_image_legacy.c index 75f4c2c..fc81727 100644 --- a/src/lib/evas/canvas/evas_image_legacy.c +++ b/src/lib/evas/canvas/evas_image_legacy.c | |||
@@ -1,6 +1,6 @@ | |||
1 | 1 | ||
2 | #include "evas_image_private.h" | 2 | #include "evas_image_private.h" |
3 | #include "evas_image.eo.h" | 3 | #include "evas_image_eo.h" |
4 | 4 | ||
5 | #define EVAS_IMAGE_API(_o, ...) do { \ | 5 | #define EVAS_IMAGE_API(_o, ...) do { \ |
6 | if (EINA_UNLIKELY(!efl_isa(_o, EFL_CANVAS_IMAGE_INTERNAL_CLASS))) { \ | 6 | if (EINA_UNLIKELY(!efl_isa(_o, EFL_CANVAS_IMAGE_INTERNAL_CLASS))) { \ |
@@ -49,7 +49,7 @@ evas_object_image_memfile_set(Evas_Object *eo_obj, void *data, int size, char *f | |||
49 | 49 | ||
50 | f = eina_file_virtualize(NULL, data, size, EINA_TRUE); | 50 | f = eina_file_virtualize(NULL, data, size, EINA_TRUE); |
51 | if (!f) return ; | 51 | if (!f) return ; |
52 | efl_file_mmap_set(eo_obj, f, key); | 52 | efl_file_simple_mmap_load(eo_obj, f, key); |
53 | eina_file_close(f); | 53 | eina_file_close(f); |
54 | } | 54 | } |
55 | 55 | ||
@@ -194,35 +194,66 @@ EAPI void | |||
194 | evas_object_image_file_set(Evas_Object *obj, const char *file, const char *key) | 194 | evas_object_image_file_set(Evas_Object *obj, const char *file, const char *key) |
195 | { | 195 | { |
196 | EVAS_IMAGE_API(obj); | 196 | EVAS_IMAGE_API(obj); |
197 | efl_file_set(obj, file, key); | 197 | efl_file_simple_load(obj, file, key); |
198 | } | 198 | } |
199 | 199 | ||
200 | EAPI void | 200 | EAPI void |
201 | evas_object_image_file_get(const Evas_Object *obj, const char **file, const char **key) | 201 | evas_object_image_file_get(const Evas_Object *obj, const char **file, const char **key) |
202 | { | 202 | { |
203 | EVAS_IMAGE_API(obj); | 203 | EVAS_IMAGE_API(obj); |
204 | efl_file_get(obj, file, key); | 204 | efl_file_simple_get(obj, file, key); |
205 | } | 205 | } |
206 | 206 | ||
207 | EAPI void | 207 | EAPI void |
208 | evas_object_image_mmap_set(Evas_Object *obj, const Eina_File *f, const char *key) | 208 | evas_object_image_mmap_set(Evas_Object *obj, const Eina_File *f, const char *key) |
209 | { | 209 | { |
210 | EVAS_IMAGE_API(obj); | 210 | EVAS_IMAGE_API(obj); |
211 | _evas_image_mmap_set(obj, f, key); | 211 | efl_file_simple_mmap_load(obj, f, key); |
212 | } | 212 | } |
213 | 213 | ||
214 | EAPI void | 214 | EAPI void |
215 | evas_object_image_mmap_get(const Evas_Object *obj, const Eina_File **f, const char **key) | 215 | evas_object_image_mmap_get(const Evas_Object *obj, const Eina_File **f, const char **key) |
216 | { | 216 | { |
217 | EVAS_IMAGE_API(obj); | 217 | EVAS_IMAGE_API(obj); |
218 | _evas_image_mmap_get(obj, f, key); | 218 | efl_file_simple_mmap_get(obj, f, key); |
219 | } | 219 | } |
220 | 220 | ||
221 | EAPI Eina_Bool | 221 | EAPI Eina_Bool |
222 | evas_object_image_save(const Evas_Object *obj, const char *file, const char *key, const char *flags) | 222 | evas_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 | ||
228 | EAPI Eina_Bool | 259 | EAPI Eina_Bool |
@@ -362,7 +393,7 @@ EAPI Evas_Load_Error | |||
362 | evas_object_image_load_error_get(const Evas_Object *obj) | 393 | evas_object_image_load_error_get(const Evas_Object *obj) |
363 | { | 394 | { |
364 | EVAS_IMAGE_API(obj, EVAS_LOAD_ERROR_GENERIC); | 395 | EVAS_IMAGE_API(obj, EVAS_LOAD_ERROR_GENERIC); |
365 | return _evas_image_load_error_get(obj); | 396 | return _efl_gfx_image_load_error_to_evas_load_error(efl_gfx_image_load_error_get(obj)); |
366 | } | 397 | } |
367 | 398 | ||
368 | EAPI void | 399 | EAPI void |
@@ -511,7 +542,7 @@ evas_object_image_native_surface_set(Evas_Object *eo_obj, Evas_Native_Surface *s | |||
511 | { | 542 | { |
512 | Evas_Image_Data *o = efl_data_scope_get(eo_obj, EFL_CANVAS_IMAGE_INTERNAL_CLASS); | 543 | Evas_Image_Data *o = efl_data_scope_get(eo_obj, EFL_CANVAS_IMAGE_INTERNAL_CLASS); |
513 | 544 | ||
514 | o->load_error = EVAS_LOAD_ERROR_GENERIC; | 545 | o->load_error = EFL_GFX_IMAGE_LOAD_ERROR_GENERIC; |
515 | } | 546 | } |
516 | } | 547 | } |
517 | 548 | ||
@@ -638,7 +669,7 @@ evas_object_image_data_set(Eo *eo_obj, void *data) | |||
638 | o->changed = EINA_TRUE; | 669 | o->changed = EINA_TRUE; |
639 | evas_object_change(eo_obj, obj); | 670 | evas_object_change(eo_obj, obj); |
640 | } | 671 | } |
641 | o->load_error = EVAS_LOAD_ERROR_NONE; | 672 | o->load_error = EFL_GFX_IMAGE_LOAD_ERROR_NONE; |
642 | if ((o->cur->image.w != 0) || (o->cur->image.h != 0)) | 673 | if ((o->cur->image.w != 0) || (o->cur->image.h != 0)) |
643 | resize_call = EINA_TRUE; | 674 | resize_call = EINA_TRUE; |
644 | 675 | ||
@@ -687,6 +718,7 @@ evas_object_image_data_get(const Eo *eo_obj, Eina_Bool for_writing) | |||
687 | void *pixels = NULL; | 718 | void *pixels = NULL; |
688 | int stride = 0; | 719 | int stride = 0; |
689 | DATA32 *data; | 720 | DATA32 *data; |
721 | int load_error; | ||
690 | 722 | ||
691 | if (!o->engine_data) return NULL; | 723 | if (!o->engine_data) return NULL; |
692 | 724 | ||
@@ -700,7 +732,8 @@ evas_object_image_data_get(const Eo *eo_obj, Eina_Bool for_writing) | |||
700 | ENFN->image_scale_hint_set(ENC, o->engine_data, o->scale_hint); | 732 | ENFN->image_scale_hint_set(ENC, o->engine_data, o->scale_hint); |
701 | if (ENFN->image_content_hint_set) | 733 | if (ENFN->image_content_hint_set) |
702 | ENFN->image_content_hint_set(ENC, o->engine_data, o->content_hint); | 734 | ENFN->image_content_hint_set(ENC, o->engine_data, o->content_hint); |
703 | pixels = ENFN->image_data_get(ENC, o->engine_data, for_writing, &data, &o->load_error, &tofree); | 735 | pixels = ENFN->image_data_get(ENC, o->engine_data, for_writing, &data, &load_error, &tofree); |
736 | o->load_error = _evas_load_error_to_efl_gfx_image_load_error(load_error); | ||
704 | 737 | ||
705 | /* if we fail to get engine_data, we have to return NULL */ | 738 | /* if we fail to get engine_data, we have to return NULL */ |
706 | if (!pixels || !data) goto error; | 739 | if (!pixels || !data) goto error; |
@@ -1079,6 +1112,7 @@ evas_object_image_data_convert(Evas_Object *eo_obj, Evas_Colorspace to_cspace) | |||
1079 | void *engine_data; | 1112 | void *engine_data; |
1080 | DATA32 *data; | 1113 | DATA32 *data; |
1081 | void* result = NULL; | 1114 | void* result = NULL; |
1115 | int load_error; | ||
1082 | 1116 | ||
1083 | static int warned = 0; | 1117 | static int warned = 0; |
1084 | if (!warned) | 1118 | if (!warned) |
@@ -1099,7 +1133,8 @@ evas_object_image_data_convert(Evas_Object *eo_obj, Evas_Colorspace to_cspace) | |||
1099 | ENFN->image_data_preload_cancel(ENC, o->engine_data, eo_obj, EINA_TRUE); | 1133 | ENFN->image_data_preload_cancel(ENC, o->engine_data, eo_obj, EINA_TRUE); |
1100 | } | 1134 | } |
1101 | data = NULL; | 1135 | data = NULL; |
1102 | engine_data = ENFN->image_data_get(ENC, o->engine_data, 0, &data, &o->load_error, NULL); | 1136 | engine_data = ENFN->image_data_get(ENC, o->engine_data, 0, &data, &load_error, NULL); |
1137 | o->load_error = _evas_load_error_to_efl_gfx_image_load_error(load_error); | ||
1103 | result = _evas_image_data_convert_internal(o, data, to_cspace); | 1138 | result = _evas_image_data_convert_internal(o, data, to_cspace); |
1104 | if (engine_data) | 1139 | if (engine_data) |
1105 | o->engine_data = ENFN->image_data_put(ENC, engine_data, data); | 1140 | o->engine_data = ENFN->image_data_put(ENC, engine_data, data); |
@@ -1153,6 +1188,7 @@ evas_object_image_pixels_import(Evas_Object *eo_obj, Evas_Pixel_Import_Source *p | |||
1153 | 1188 | ||
1154 | Evas_Object_Protected_Data *obj = efl_data_scope_get(eo_obj, EFL_CANVAS_OBJECT_CLASS); | 1189 | Evas_Object_Protected_Data *obj = efl_data_scope_get(eo_obj, EFL_CANVAS_OBJECT_CLASS); |
1155 | Evas_Image_Data *o; | 1190 | Evas_Image_Data *o; |
1191 | int load_error; | ||
1156 | 1192 | ||
1157 | static int warned = 0; | 1193 | static int warned = 0; |
1158 | if (!warned) | 1194 | if (!warned) |
@@ -1180,7 +1216,8 @@ evas_object_image_pixels_import(Evas_Object *eo_obj, Evas_Pixel_Import_Source *p | |||
1180 | o->engine_data, | 1216 | o->engine_data, |
1181 | 1, | 1217 | 1, |
1182 | &image_pixels, | 1218 | &image_pixels, |
1183 | &o->load_error); | 1219 | &load_error); |
1220 | o->load_error = _evas_load_error_to_efl_gfx_image_load_error(load_error); | ||
1184 | /* FIXME: need to actualyl support this */ | 1221 | /* FIXME: need to actualyl support this */ |
1185 | /* memcpy(image_pixels, pixels->rows, o->cur->image.w * o->cur->image.h * 4);*/ | 1222 | /* memcpy(image_pixels, pixels->rows, o->cur->image.w * o->cur->image.h * 4);*/ |
1186 | if (o->engine_data) | 1223 | if (o->engine_data) |
@@ -1201,7 +1238,8 @@ evas_object_image_pixels_import(Evas_Object *eo_obj, Evas_Pixel_Import_Source *p | |||
1201 | { | 1238 | { |
1202 | DATA32 *image_pixels = NULL; | 1239 | DATA32 *image_pixels = NULL; |
1203 | 1240 | ||
1204 | o->engine_data = ENFN->image_data_get(ENC, o->engine_data, 1, &image_pixels,&o->load_error, NULL); | 1241 | o->engine_data = ENFN->image_data_get(ENC, o->engine_data, 1, &image_pixels, &load_error, NULL); |
1242 | o->load_error = _evas_load_error_to_efl_gfx_image_load_error(load_error); | ||
1205 | if (image_pixels) | 1243 | if (image_pixels) |
1206 | evas_common_convert_yuv_422p_601_rgba((DATA8 **) pixels->rows, (DATA8 *) image_pixels, o->cur->image.w, o->cur->image.h); | 1244 | evas_common_convert_yuv_422p_601_rgba((DATA8 **) pixels->rows, (DATA8 *) image_pixels, o->cur->image.w, o->cur->image.h); |
1207 | if (o->engine_data) | 1245 | if (o->engine_data) |
@@ -1243,20 +1281,27 @@ evas_object_image_alpha_mask_set(Evas_Object *eo_obj EINA_UNUSED, Eina_Bool isma | |||
1243 | EVAS_IMAGE_LEGACY_API(eo_obj); | 1281 | EVAS_IMAGE_LEGACY_API(eo_obj); |
1244 | } | 1282 | } |
1245 | 1283 | ||
1246 | EOLIAN static Eina_Bool | 1284 | EOLIAN static Eina_Error |
1247 | _evas_image_efl_file_mmap_set(Eo *obj, void *pd EINA_UNUSED, const Eina_File *f, const char *key) | 1285 | _evas_image_efl_file_load(Eo *obj, void *pd EINA_UNUSED) |
1248 | { | 1286 | { |
1249 | EVAS_IMAGE_API(obj, EINA_FALSE); | 1287 | EVAS_IMAGE_API(obj, EINA_FALSE); |
1250 | return _evas_image_mmap_set(obj, f, key); | 1288 | if (efl_file_loaded_get(obj)) return 0; |
1251 | } | 1289 | Eina_Error err = efl_file_load(efl_super(obj, EVAS_IMAGE_CLASS)); |
1252 | 1290 | if (err) | |
1253 | EOLIAN static void | 1291 | { |
1254 | _evas_image_efl_file_mmap_get(const Eo *obj, void *pd EINA_UNUSED, const Eina_File **f, const char **key) | 1292 | if (err == ENOENT) |
1255 | { | 1293 | _efl_canvas_image_load_error_set(obj, EFL_GFX_IMAGE_LOAD_ERROR_DOES_NOT_EXIST); |
1256 | if (f) *f = NULL; | 1294 | else if (err == ENOMEM) |
1257 | if (key) *key = NULL; | 1295 | _efl_canvas_image_load_error_set(obj, EFL_GFX_IMAGE_LOAD_ERROR_RESOURCE_ALLOCATION_FAILED); |
1258 | EVAS_IMAGE_API(obj); | 1296 | else if ((err == EPERM) || (err == EACCES)) |
1259 | _evas_image_mmap_get(obj, f, key); | 1297 | _efl_canvas_image_load_error_set(obj, EFL_GFX_IMAGE_LOAD_ERROR_PERMISSION_DENIED); |
1298 | else | ||
1299 | _efl_canvas_image_load_error_set(obj, EFL_GFX_IMAGE_LOAD_ERROR_GENERIC); | ||
1300 | return err; | ||
1301 | } | ||
1302 | if (_evas_image_file_load(obj)) | ||
1303 | return 0; | ||
1304 | return EFL_GFX_IMAGE_LOAD_ERROR_DOES_NOT_EXIST; | ||
1260 | } | 1305 | } |
1261 | 1306 | ||
1262 | #include "canvas/evas_image.eo.c" | 1307 | #include "canvas/evas_image_eo.c" |