From 97d9fab7042f213498268dfc58636b823380245c Mon Sep 17 00:00:00 2001 From: Jean-Philippe Andre Date: Wed, 4 Sep 2013 16:14:37 +0900 Subject: [PATCH] evas/cserve2: Fallback to normal cache for animated gifs Pass around "animated" flag for images that can be animated. Fallback to local cache if the image is animated. Implementing support for animated images in cserve2 does not seem to make a lot of sense considering each frame must be requested independently in real time,... and to be honest there doesn't seem to be any valid use case anyway :) --- src/bin/evas/evas_cserve2_cache.c | 2 ++ src/bin/evas/evas_cserve2_shm_debug.c | 3 ++- src/lib/evas/cache2/evas_cache2.c | 3 +++ src/lib/evas/cserve2/evas_cs2.h | 2 ++ src/lib/evas/cserve2/evas_cs2_client.c | 9 ++++++- .../engines/software_generic/evas_engine.c | 24 ++++++++++++++++--- 6 files changed, 38 insertions(+), 5 deletions(-) diff --git a/src/bin/evas/evas_cserve2_cache.c b/src/bin/evas/evas_cserve2_cache.c index 40cd55df4b..83923d48c9 100644 --- a/src/bin/evas/evas_cserve2_cache.c +++ b/src/bin/evas/evas_cserve2_cache.c @@ -444,6 +444,7 @@ _image_opened_msg_create(File_Data *fd, int *size) msg->image.loop_count = fd->loop_count; msg->image.loop_hint = fd->loop_hint; msg->image.alpha = fd->alpha; + msg->image.animated = fd->animated; *size = sizeof(*msg); @@ -615,6 +616,7 @@ _open_request_response(Entry *entry, Slave_Msg_Image_Opened *resp, int *size) fd->w = resp->w; fd->h = resp->h; + fd->animated = resp->animated; fd->frame_count = resp->frame_count; fd->loop_count = resp->loop_count; fd->loop_hint = resp->loop_hint; diff --git a/src/bin/evas/evas_cserve2_shm_debug.c b/src/bin/evas/evas_cserve2_shm_debug.c index 426fd67a95..49bae201f0 100644 --- a/src/bin/evas/evas_cserve2_shm_debug.c +++ b/src/bin/evas/evas_cserve2_shm_debug.c @@ -519,7 +519,8 @@ _images_all_print_full(void) printf(" Loader: %s\n", _shared_string_get(fd->loader_data)); printf(" Geometry: %dx%d\n", fd->w, fd->h); - printf(" Animation: frames: %d, loop: %d, hint: %d\n", + printf(" Animation: anim: %s, frames: %d, loop: %d, hint: %d\n", + fd->animated ? "YES" : "NO", fd->frame_count, fd->loop_count, fd->loop_hint); printf(" Alpha: %s\n", fd->alpha ? "YES" : "NO"); printf(" Invalid: %s\n", fd->invalid ? "YES" : "NO"); diff --git a/src/lib/evas/cache2/evas_cache2.c b/src/lib/evas/cache2/evas_cache2.c index 4b51b3292e..0444741289 100644 --- a/src/lib/evas/cache2/evas_cache2.c +++ b/src/lib/evas/cache2/evas_cache2.c @@ -873,6 +873,9 @@ evas_cache2_image_scale_load(Image_Entry *im, int error = EVAS_LOAD_ERROR_NONE; Image_Entry *ret; + if (!im->cache2) + return im; + if (!smooth && im->scale_hint != EVAS_IMAGE_SCALE_HINT_STATIC) goto parent_out; diff --git a/src/lib/evas/cserve2/evas_cs2.h b/src/lib/evas/cserve2/evas_cs2.h index a47c384b82..835ed31c0b 100644 --- a/src/lib/evas/cserve2/evas_cs2.h +++ b/src/lib/evas/cserve2/evas_cs2.h @@ -73,6 +73,7 @@ struct _Msg_Opened { int loop_count; int loop_hint; /* include Evas.h? Copy the enum around? */ Eina_Bool alpha : 1; + Eina_Bool animated : 1; } image; }; @@ -333,6 +334,7 @@ struct _File_Data { Eina_Bool alpha : 1; Eina_Bool invalid : 1; Eina_Bool valid : 1; + Eina_Bool animated : 1; }; #define IMAGE_DATA_ARRAY_TAG ('I' | 'M' << 8 | 'A' << 16 | 'G' << 24) diff --git a/src/lib/evas/cserve2/evas_cs2_client.c b/src/lib/evas/cserve2/evas_cs2_client.c index 852ae08640..566bd0655a 100644 --- a/src/lib/evas/cserve2/evas_cs2_client.c +++ b/src/lib/evas/cserve2/evas_cs2_client.c @@ -505,6 +505,7 @@ _image_opened_cb(void *data, const void *msg_received, int size) ie->animated.loop_hint = msg->image.loop_hint; ie->animated.loop_count = msg->image.loop_count; ie->animated.frame_count = msg->image.frame_count; + ie->animated.animated = msg->image.animated; } static void @@ -985,9 +986,9 @@ evas_cserve2_image_load_wait(Image_Entry *ie) ie->animated.loop_hint = fd->loop_hint; ie->animated.loop_count = fd->loop_count; ie->animated.frame_count = fd->frame_count; + ie->animated.animated = fd->animated; ie->server_id = fd->id; ie->open_rid = 0; - return CSERVE2_NONE; } #endif @@ -999,6 +1000,12 @@ evas_cserve2_image_load_wait(Image_Entry *ie) return CSERVE2_GENERIC; } + if (ie->animated.animated) + { + WRN("This image is animated. cserve2 does not support animations"); + return CSERVE2_GENERIC; + } + return CSERVE2_NONE; } diff --git a/src/modules/evas/engines/software_generic/evas_engine.c b/src/modules/evas/engines/software_generic/evas_engine.c index 8b3441444b..577d3af4b0 100644 --- a/src/modules/evas/engines/software_generic/evas_engine.c +++ b/src/modules/evas/engines/software_generic/evas_engine.c @@ -949,10 +949,19 @@ eng_image_load(void *data EINA_UNUSED, const char *file, const char *key, int *e ie = evas_cache2_image_open(evas_common_image_cache2_get(), file, key, lo, error); if (ie) - *error = evas_cache2_image_open_wait(ie); + { + *error = evas_cache2_image_open_wait(ie); + if ((*error != EVAS_LOAD_ERROR_NONE) && ie->animated.animated) + { + evas_cache2_image_close(ie); + goto use_local_cache; + } + } return ie; } +use_local_cache: #endif + return evas_common_load_image_from_file(file, key, lo, error); } @@ -968,10 +977,19 @@ eng_image_mmap(void *data EINA_UNUSED, Eina_File *f, const char *key, int *error ie = evas_cache2_image_open(evas_common_image_cache2_get(), eina_file_filename_get(f), key, lo, error); if (ie) - *error = evas_cache2_image_open_wait(ie); + { + *error = evas_cache2_image_open_wait(ie); + if ((*error != EVAS_LOAD_ERROR_NONE) && ie->animated.animated) + { + evas_cache2_image_close(ie); + goto use_local_cache; + } + } return ie; } +use_local_cache: #endif + return evas_common_load_image_from_mmap(f, key, lo, error); } @@ -1295,7 +1313,7 @@ eng_image_draw(void *data EINA_UNUSED, void *context, void *surface, void *image if (im->cache_entry.space == EVAS_COLORSPACE_ARGB8888) { #if EVAS_CSERVE2 - if (evas_cserve2_use_get()) + if (evas_cserve2_use_get() && evas_cache2_image_cached(&im->cache_entry)) evas_cache2_image_load_data(&im->cache_entry); else #endif