summaryrefslogtreecommitdiff
path: root/src/lib/evas/common/evas_image_load.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/lib/evas/common/evas_image_load.c
parent692938689592ac9c8a79c7c69f6825be1313bb48 (diff)
evas: final cleanup of the API, should be ready to make it public by now.
Diffstat (limited to 'src/lib/evas/common/evas_image_load.c')
-rw-r--r--src/lib/evas/common/evas_image_load.c70
1 files changed, 24 insertions, 46 deletions
diff --git a/src/lib/evas/common/evas_image_load.c b/src/lib/evas/common/evas_image_load.c
index 4ed3624e8c..a505bc99f6 100644
--- a/src/lib/evas/common/evas_image_load.c
+++ b/src/lib/evas/common/evas_image_load.c
@@ -150,18 +150,25 @@ _evas_image_file_header(Evas_Module *em, Image_Entry *ie, int *error)
150 if (evas_image_load_func) 150 if (evas_image_load_func)
151 { 151 {
152 Evas_Image_Property property; 152 Evas_Image_Property property;
153 Eina_File *f;
154 153
155 f = eina_file_open(ie->file, EINA_FALSE); 154 if (!ie->f) ie->f = eina_file_open(ie->file, EINA_FALSE);
156 if (!f) 155 if (!ie->f)
157 { 156 {
158 *error = EVAS_LOAD_ERROR_DOES_NOT_EXIST; 157 *error = EVAS_LOAD_ERROR_DOES_NOT_EXIST;
159 return EINA_TRUE; 158 goto load_error;
160 } 159 }
161 160
161 ie->loader_data = evas_image_load_func->file_open(ie->f, ie->key,
162 &ie->load_opts,
163 &ie->animated,
164 error);
165 if (!ie->loader_data)
166 {
167 goto load_error;
168 }
169
162 memset(&property, 0, sizeof (Evas_Image_Property)); 170 memset(&property, 0, sizeof (Evas_Image_Property));
163 if (evas_image_load_func->file_head(f, ie->key, &property, 171 if (evas_image_load_func->file_head(ie->loader_data, &property,
164 &ie->load_opts, &ie->animated,
165 error) && 172 error) &&
166 (*error == EVAS_LOAD_ERROR_NONE)) 173 (*error == EVAS_LOAD_ERROR_NONE))
167 { 174 {
@@ -184,7 +191,6 @@ _evas_image_file_header(Evas_Module *em, Image_Entry *ie, int *error)
184 "%s (%s)", 191 "%s (%s)",
185 em->definition->name, em, ie->file, evas_load_error_str(*error)); 192 em->definition->name, em, ie->file, evas_load_error_str(*error));
186 } 193 }
187 eina_file_close(f);
188 } 194 }
189 else 195 else
190 { 196 {
@@ -327,7 +333,6 @@ EAPI int
327evas_common_load_rgba_image_data_from_file(Image_Entry *ie) 333evas_common_load_rgba_image_data_from_file(Image_Entry *ie)
328{ 334{
329 void *pixels; 335 void *pixels;
330 Eina_File *f;
331 Evas_Image_Load_Func *evas_image_load_func = NULL; 336 Evas_Image_Load_Func *evas_image_load_func = NULL;
332 Evas_Image_Property property; 337 Evas_Image_Property property;
333 int ret = EVAS_LOAD_ERROR_NONE; 338 int ret = EVAS_LOAD_ERROR_NONE;
@@ -363,39 +368,23 @@ evas_common_load_rgba_image_data_from_file(Image_Entry *ie)
363 evas_image_load_func = ie->info.loader; 368 evas_image_load_func = ie->info.loader;
364 evas_module_use((Evas_Module*) ie->info.module); 369 evas_module_use((Evas_Module*) ie->info.module);
365 370
366 f = eina_file_open(ie->file, EINA_FALSE); 371 if (!ie->f) return EVAS_LOAD_ERROR_DOES_NOT_EXIST;
367 if (!f) return EVAS_LOAD_ERROR_DOES_NOT_EXIST;
368 372
369 memset(&property, 0, sizeof (Evas_Image_Property)); 373 memset(&property, 0, sizeof (Evas_Image_Property));
370 if (!(evas_image_load_func->file_head(f, ie->key, &property, 374 property.w = ie->w;
371 &ie->load_opts, &ie->animated, 375 property.h = ie->h;
372 &ret) && 376 property.scale = property.scale;
373 (ret == EVAS_LOAD_ERROR_NONE))) 377 property.rotated = ie->flags.rotated;
374 goto on_error; 378 property.premul = EINA_FALSE;
375 379 property.alpha_sparse = EINA_FALSE;
376 ie->w = property.w;
377 ie->h = property.h;
378 ie->scale = property.scale;
379 ie->flags.alpha = property.alpha;
380 if (ie->load_opts.orientation &&
381 ie->load_opts.degree != 0)
382 ie->flags.rotated = EINA_TRUE;
383 380
384 evas_cache_image_surface_alloc(ie, ie->w, ie->h); 381 evas_cache_image_surface_alloc(ie, ie->w, ie->h);
385 382
386 pixels = evas_cache_image_pixels(ie); 383 pixels = evas_cache_image_pixels(ie);
387 if (!pixels) 384 if (!pixels)
388 { 385 return EVAS_LOAD_ERROR_RESOURCE_ALLOCATION_FAILED;
389 ret = EVAS_LOAD_ERROR_RESOURCE_ALLOCATION_FAILED;
390 goto on_error;
391 }
392 386
393 evas_image_load_func->file_data(f, ie->key, 387 evas_image_load_func->file_data(ie->loader_data, &property, pixels, &ret);
394 &property,
395 &ie->load_opts,
396 &ie->animated,
397 pixels,
398 &ret);
399 388
400 ie->flags.alpha_sparse = property.alpha_sparse; 389 ie->flags.alpha_sparse = property.alpha_sparse;
401 390
@@ -404,9 +393,6 @@ evas_common_load_rgba_image_data_from_file(Image_Entry *ie)
404// evas_module_unref((Evas_Module*) ie->info.module); 393// evas_module_unref((Evas_Module*) ie->info.module);
405// ie->info.module = NULL; 394// ie->info.module = NULL;
406 395
407 on_error:
408 eina_file_close(f);
409
410 return ret; 396 return ret;
411} 397}
412 398
@@ -421,17 +407,9 @@ evas_common_load_rgba_image_frame_duration_from_file(Image_Entry *ie, const int
421 evas_module_use((Evas_Module*) ie->info.module); 407 evas_module_use((Evas_Module*) ie->info.module);
422 if (evas_image_load_func->frame_duration) 408 if (evas_image_load_func->frame_duration)
423 { 409 {
424 Eina_File *f; 410 if (!ie->f) return -1;
425 double r;
426
427 f = eina_file_open(ie->file, EINA_FALSE);
428 if (!f) return -1;
429
430 r = evas_image_load_func->frame_duration(f, &ie->animated, start, frame_num);
431
432 eina_file_close(f);
433 411
434 return r; 412 return evas_image_load_func->frame_duration(ie->loader_data, start, frame_num);
435 } 413 }
436 return -1; 414 return -1;
437} 415}