evas/cserve2: Fix reload of image without load_opts

Problem: Images opened without load_opts are reopened
multiple times.
Solution: Use empty load opts when looking for the key.
This commit is contained in:
Jean-Philippe Andre 2013-10-01 11:59:40 +09:00
parent 74080fba22
commit 6f485d2a12
2 changed files with 9 additions and 8 deletions

View File

@ -320,7 +320,7 @@ void cserve2_cache_client_new(Client *client);
void cserve2_cache_client_del(Client *client);
int cserve2_cache_file_open(Client *client, unsigned int client_file_id, const char *path, const char *key, unsigned int rid, Evas_Image_Load_Opts *lo);
void cserve2_cache_file_close(Client *client, unsigned int client_file_id);
int cserve2_cache_image_entry_create(Client *client, int rid, unsigned int client_file_id, unsigned int image_id, Evas_Image_Load_Opts *opts);
int cserve2_cache_image_entry_create(Client *client, int rid, unsigned int client_file_id, unsigned int image_id, const Evas_Image_Load_Opts *opts);
void cserve2_rgba_image_scale_do(void *src_data, int src_full_w, int src_full_h, void *dst_data, int src_x, int src_y, int src_w, int src_h, int dst_x, int dst_y, int dst_w, int dst_h, int alpha, int smooth);
void cserve2_cache_image_load(Client *client, unsigned int client_image_id, unsigned int rid);
void cserve2_cache_image_preload(Client *client, unsigned int client_image_id, unsigned int rid);

View File

@ -932,10 +932,8 @@ static void
_image_key_set(unsigned int file_id, const Evas_Image_Load_Opts *opts,
char *buf, int size)
{
const char empty[sizeof(Evas_Image_Load_Opts)] = {0};
if (!opts)
opts = (Evas_Image_Load_Opts *) ∅
opts = &empty_lo;
snprintf(buf, size,
"%u:%0.3f:%dx%d:%d:%d,%d+%dx%d:!([%d,%d:%dx%d]-[%dx%d:%d]):%d:%d",
@ -950,7 +948,7 @@ _image_key_set(unsigned int file_id, const Evas_Image_Load_Opts *opts,
}
static unsigned int
_image_opts_id_get(unsigned int file_id, Evas_Image_Load_Opts *opts,
_image_opts_id_get(unsigned int file_id, const Evas_Image_Load_Opts *opts,
char *buf, int size)
{
uintptr_t image_id;
@ -1580,7 +1578,7 @@ cserve2_cache_client_del(Client *client)
static Image_Entry *
_image_entry_new(Client *client, int rid,
unsigned int client_file_id, unsigned int client_image_id,
Evas_Image_Load_Opts *opts, char *buf, size_t buf_size)
const Evas_Image_Load_Opts *opts, char *buf, size_t buf_size)
{
Reference *ref, *oldref;
Image_Entry *ientry;
@ -2823,7 +2821,7 @@ int
cserve2_cache_image_entry_create(Client *client, int rid,
unsigned int client_file_id,
unsigned int client_image_id,
Evas_Image_Load_Opts *opts)
const Evas_Image_Load_Opts *opts)
{
Image_Data *idata;
Image_Entry *ientry;
@ -2832,9 +2830,12 @@ cserve2_cache_image_entry_create(Client *client, int rid,
unsigned int image_id = 0;
char buf[4096];
if (!opts)
opts = &empty_lo;
// search whether the image is already loaded by another client
ref = eina_hash_find(client->files.referencing, &client_file_id);
if (ref && opts)
if (ref)
image_id = _image_opts_id_get(ref->entry->id, opts, buf, sizeof(buf));
if (image_id)