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 :)
This commit is contained in:
Jean-Philippe Andre 2013-09-04 16:14:37 +09:00
parent bfe3fe27df
commit 97d9fab704
6 changed files with 38 additions and 5 deletions

View File

@ -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;

View File

@ -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");

View File

@ -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;

View File

@ -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)

View File

@ -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;
}

View File

@ -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