forked from enlightenment/efl
Replace heavy snprintf by eina convertion functions.
SVN revision: 36751
This commit is contained in:
parent
c99824328f
commit
f9e815645f
|
@ -428,18 +428,38 @@ evas_cache_image_shutdown(Evas_Cache_Image *cache)
|
||||||
EAPI Image_Entry *
|
EAPI Image_Entry *
|
||||||
evas_cache_image_request(Evas_Cache_Image *cache, const char *file, const char *key, RGBA_Image_Loadopts *lo, int *error)
|
evas_cache_image_request(Evas_Cache_Image *cache, const char *file, const char *key, RGBA_Image_Loadopts *lo, int *error)
|
||||||
{
|
{
|
||||||
|
const char *ckey = "(null)";
|
||||||
const char *format;
|
const char *format;
|
||||||
char *hkey;
|
char *hkey;
|
||||||
Image_Entry *im;
|
Image_Entry *im;
|
||||||
Evas_Image_Load_Opts prevent = { 0, 0, 0, 0 };
|
Evas_Image_Load_Opts prevent = { 0, 0, 0, 0 };
|
||||||
int size;
|
int size;
|
||||||
int stat_done = 0;
|
int stat_done = 0;
|
||||||
|
int file_length;
|
||||||
|
int key_length;
|
||||||
struct stat st;
|
struct stat st;
|
||||||
|
|
||||||
assert(cache != NULL);
|
assert(cache != NULL);
|
||||||
|
|
||||||
if (!file && !key) return NULL;
|
if (!file && !key) return NULL;
|
||||||
if (!file) return NULL;
|
if (!file) return NULL;
|
||||||
|
|
||||||
|
file_length = strlen(file);
|
||||||
|
key_length = key ? strlen(key) : 6;
|
||||||
|
|
||||||
|
size = file_length + key_length + 64;
|
||||||
|
hkey = alloca(sizeof (char) * size);
|
||||||
|
|
||||||
|
memcpy(hkey, file, file_length);
|
||||||
|
size = file_length;
|
||||||
|
|
||||||
|
memcpy(hkey + size, "//://", 5);
|
||||||
|
size += 5;
|
||||||
|
|
||||||
|
if (key) ckey = key;
|
||||||
|
memcpy(hkey + size, ckey, key_length);
|
||||||
|
size += key_length;
|
||||||
|
|
||||||
if ((!lo) ||
|
if ((!lo) ||
|
||||||
(lo &&
|
(lo &&
|
||||||
(lo->scale_down_by == 0) &&
|
(lo->scale_down_by == 0) &&
|
||||||
|
@ -454,14 +474,28 @@ evas_cache_image_request(Evas_Cache_Image *cache, const char *file, const char *
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (key)
|
memcpy(hkey + size, "//@/", 4);
|
||||||
format = "%s//://%s//@/%i/%1.5f/%ix%i";
|
size += 4;
|
||||||
else
|
|
||||||
format = "%s//://%p//@/%i/%1.5f/%ix%i";
|
size += eina_convert_xtoa(lo->scale_down_by, hkey + size);
|
||||||
|
|
||||||
|
hkey[size] = '/';
|
||||||
|
size += 1;
|
||||||
|
|
||||||
|
size += eina_convert_dtoa(lo->dpi, hkey + size);
|
||||||
|
|
||||||
|
hkey[size] = '/';
|
||||||
|
size += 1;
|
||||||
|
|
||||||
|
size += eina_convert_xtoa(lo->w, hkey + size);
|
||||||
|
|
||||||
|
hkey[size] = 'x';
|
||||||
|
size += 1;
|
||||||
|
|
||||||
|
size += eina_convert_xtoa(lo->h, hkey + size);
|
||||||
}
|
}
|
||||||
size = strlen(file) + (key ? strlen(key) : 6) + 64;
|
|
||||||
hkey = alloca(sizeof (char) * size);
|
hkey[size] = '\0';
|
||||||
snprintf(hkey, size, format, file, key, lo->scale_down_by, lo->dpi, lo->w, lo->h);
|
|
||||||
|
|
||||||
im = evas_hash_find(cache->activ, hkey);
|
im = evas_hash_find(cache->activ, hkey);
|
||||||
if (im)
|
if (im)
|
||||||
|
|
Loading…
Reference in New Issue