summaryrefslogtreecommitdiff
path: root/src/modules/evas/loaders/jpeg/evas_image_load_jpeg.c
diff options
context:
space:
mode:
authorCedric Bail <cedric.bail@samsung.com>2013-05-06 19:01:35 +0900
committerCedric Bail <cedric.bail@samsung.com>2013-05-06 19:02:05 +0900
commit0d2c6481b8ed9273f3430d4e8916f4dd881d7221 (patch)
tree4955ef6877469fd41f0eeeea3993169c4c058a81 /src/modules/evas/loaders/jpeg/evas_image_load_jpeg.c
parent692938689592ac9c8a79c7c69f6825be1313bb48 (diff)
evas: final cleanup of the API, should be ready to make it public by now.
Diffstat (limited to '')
-rw-r--r--src/modules/evas/loaders/jpeg/evas_image_load_jpeg.c65
1 files changed, 56 insertions, 9 deletions
diff --git a/src/modules/evas/loaders/jpeg/evas_image_load_jpeg.c b/src/modules/evas/loaders/jpeg/evas_image_load_jpeg.c
index 5417e4aa2d..6a440842e5 100644
--- a/src/modules/evas/loaders/jpeg/evas_image_load_jpeg.c
+++ b/src/modules/evas/loaders/jpeg/evas_image_load_jpeg.c
@@ -14,7 +14,6 @@
14#include "evas_common.h" 14#include "evas_common.h"
15#include "evas_private.h" 15#include "evas_private.h"
16 16
17
18typedef struct _JPEG_error_mgr *emptr; 17typedef struct _JPEG_error_mgr *emptr;
19struct _JPEG_error_mgr 18struct _JPEG_error_mgr
20{ 19{
@@ -22,6 +21,14 @@ struct _JPEG_error_mgr
22 jmp_buf setjmp_buffer; 21 jmp_buf setjmp_buffer;
23}; 22};
24 23
24typedef struct _Evas_Loader_Internal Evas_Loader_Internal;
25struct _Evas_Loader_Internal
26{
27 Eina_File *f;
28 Evas_Image_Load_Opts *opts;
29};
30
31
25static void _JPEGFatalErrorHandler(j_common_ptr cinfo); 32static void _JPEGFatalErrorHandler(j_common_ptr cinfo);
26static void _JPEGErrorHandler(j_common_ptr cinfo); 33static void _JPEGErrorHandler(j_common_ptr cinfo);
27static void _JPEGErrorHandler2(j_common_ptr cinfo, int msg_level); 34static void _JPEGErrorHandler2(j_common_ptr cinfo, int msg_level);
@@ -1213,17 +1220,52 @@ evas_image_load_file_data_jpeg_alpha_internal(Image_Entry *ie, FILE *f, int *err
1213} 1220}
1214#endif 1221#endif
1215 1222
1223static void *
1224evas_image_load_file_open_jpeg(Eina_File *f, const char *key EINA_UNUSED,
1225 Evas_Image_Load_Opts *opts,
1226 Evas_Image_Animated *animated EINA_UNUSED,
1227 int *error)
1228{
1229 Evas_Loader_Internal *loader;
1230
1231 loader = calloc(1, sizeof (Evas_Loader_Internal));
1232 if (!loader)
1233 {
1234 *error = EVAS_LOAD_ERROR_RESOURCE_ALLOCATION_FAILED;
1235 return NULL;
1236 }
1237
1238 loader->f = f;
1239 loader->opts = opts;
1240
1241 return loader;
1242}
1243
1244static void
1245evas_image_load_file_close_jpeg(void *loader_data)
1246{
1247 free(loader_data);
1248}
1249
1216static Eina_Bool 1250static Eina_Bool
1217evas_image_load_file_head_jpeg(Eina_File *f, const char *key EINA_UNUSED, Evas_Image_Property *prop, Evas_Image_Load_Opts *opts, Evas_Image_Animated *animated EINA_UNUSED, int *error) 1251evas_image_load_file_head_jpeg(void *loader_data,
1252 Evas_Image_Property *prop,
1253 int *error)
1218{ 1254{
1255 Evas_Loader_Internal *loader = loader_data;
1256 Evas_Image_Load_Opts *opts;
1257 Eina_File *f;
1219 void *map; 1258 void *map;
1220 Eina_Bool val = EINA_FALSE; 1259 Eina_Bool val;
1260
1261 opts = loader->opts;
1262 f = loader->f;
1221 1263
1222 map = eina_file_map_all(f, EINA_FILE_WILLNEED); 1264 map = eina_file_map_all(f, EINA_FILE_WILLNEED);
1223 if (!map) 1265 if (!map)
1224 { 1266 {
1225 *error = EVAS_LOAD_ERROR_DOES_NOT_EXIST; 1267 *error = EVAS_LOAD_ERROR_DOES_NOT_EXIST;
1226 goto on_error; 1268 return EINA_FALSE;
1227 } 1269 }
1228 1270
1229 val = evas_image_load_file_head_jpeg_internal(&prop->w, &prop->h, 1271 val = evas_image_load_file_head_jpeg_internal(&prop->w, &prop->h,
@@ -1234,21 +1276,24 @@ evas_image_load_file_head_jpeg(Eina_File *f, const char *key EINA_UNUSED, Evas_I
1234 1276
1235 eina_file_map_free(f, map); 1277 eina_file_map_free(f, map);
1236 1278
1237 on_error:
1238 return val; 1279 return val;
1239} 1280}
1240 1281
1241static Eina_Bool 1282static Eina_Bool
1242evas_image_load_file_data_jpeg(Eina_File *f, const char *key EINA_UNUSED, 1283evas_image_load_file_data_jpeg(void *loader_data,
1243 Evas_Image_Property *prop, 1284 Evas_Image_Property *prop,
1244 Evas_Image_Load_Opts *opts,
1245 Evas_Image_Animated *animated EINA_UNUSED,
1246 void *pixels, 1285 void *pixels,
1247 int *error) 1286 int *error)
1248{ 1287{
1288 Evas_Loader_Internal *loader = loader_data;
1289 Evas_Image_Load_Opts *opts;
1290 Eina_File *f;
1249 void *map; 1291 void *map;
1250 Eina_Bool val = EINA_FALSE; 1292 Eina_Bool val = EINA_FALSE;
1251 1293
1294 f = loader->f;
1295 opts = loader->opts;
1296
1252 map = eina_file_map_all(f, EINA_FILE_WILLNEED); 1297 map = eina_file_map_all(f, EINA_FILE_WILLNEED);
1253 if (!map) 1298 if (!map)
1254 { 1299 {
@@ -1269,6 +1314,8 @@ evas_image_load_file_data_jpeg(Eina_File *f, const char *key EINA_UNUSED,
1269static Evas_Image_Load_Func evas_image_load_jpeg_func = 1314static Evas_Image_Load_Func evas_image_load_jpeg_func =
1270{ 1315{
1271 EINA_TRUE, 1316 EINA_TRUE,
1317 evas_image_load_file_open_jpeg,
1318 evas_image_load_file_close_jpeg,
1272 evas_image_load_file_head_jpeg, 1319 evas_image_load_file_head_jpeg,
1273 evas_image_load_file_data_jpeg, 1320 evas_image_load_file_data_jpeg,
1274 NULL, 1321 NULL,