forked from enlightenment/efl
i've put back timestamp checks - but evas wont stata file more frequently
than once per 2 seconds to avoid overhead. SVN revision: 28532
This commit is contained in:
parent
635e741438
commit
e58afbca6e
|
@ -31,6 +31,8 @@ evas_common_load_image_from_file(const char *file, const char *key, RGBA_Image_L
|
|||
im = evas_common_image_new();
|
||||
if (!im) return NULL;
|
||||
|
||||
im->timestamp = st.st_mtime;
|
||||
|
||||
if (lo) im->load_opts = *lo;
|
||||
|
||||
p = strrchr(file, '.');
|
||||
|
|
|
@ -468,6 +468,7 @@ evas_common_image_unstore(RGBA_Image *im)
|
|||
im->flags &= ~RGBA_IMAGE_INDEXED;
|
||||
}
|
||||
|
||||
#define STAT_GAP 2
|
||||
|
||||
EAPI RGBA_Image *
|
||||
evas_common_image_find(const char *file, const char *key, DATA64 timestamp, RGBA_Image_Loadopts *lo)
|
||||
|
@ -476,6 +477,8 @@ evas_common_image_find(const char *file, const char *key, DATA64 timestamp, RGBA
|
|||
RGBA_Image *im;
|
||||
char buf[4096 + 1024];
|
||||
Evas_Object_List *l;
|
||||
struct stat st;
|
||||
static time_t last_stat = 0, t, mt;
|
||||
|
||||
if ((!file) && (!key)) return NULL;
|
||||
if (!file) return NULL;
|
||||
|
@ -498,29 +501,70 @@ evas_common_image_find(const char *file, const char *key, DATA64 timestamp, RGBA
|
|||
snprintf(buf, sizeof(buf), "//@/%i/%1.5f/%ix%i//%s", lo->scale_down_by, lo->dpi, lo->w, lo->h, file);
|
||||
}
|
||||
im = evas_hash_find(images, buf);
|
||||
if (im) return im;
|
||||
t = time();
|
||||
if (im)
|
||||
{
|
||||
if ((t - last_stat) < STAT_GAP)
|
||||
return im;
|
||||
else
|
||||
{
|
||||
struct stat st;
|
||||
|
||||
if (stat(file, &st) != 0) return NULL;
|
||||
mt = st.st_mtime;
|
||||
if (mt == im->timestamp)
|
||||
{
|
||||
last_stat = t;
|
||||
return im;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((t - last_stat) >= STAT_GAP)
|
||||
{
|
||||
if (stat(file, &st) != 0) return NULL;
|
||||
mt = st.st_mtime;
|
||||
last_stat = t;
|
||||
}
|
||||
}
|
||||
|
||||
for (l = cache; l; l = l->next)
|
||||
{
|
||||
int ok;
|
||||
|
||||
|
||||
im = (RGBA_Image *)l;
|
||||
ok = 0;
|
||||
lo2 = &(im->load_opts);
|
||||
ok = 0;
|
||||
if ((file) && (im->info.file) &&
|
||||
(!strcmp(file, im->info.file)))
|
||||
ok++;
|
||||
else if ((!file) && (!im->info.file))
|
||||
ok++;
|
||||
else continue;
|
||||
|
||||
if ((key) && (im->info.key) &&
|
||||
(!strcmp(key, im->info.key)))
|
||||
ok++;
|
||||
else if ((!key) && (!im->info.key))
|
||||
ok++;
|
||||
else continue;
|
||||
|
||||
if ((t - last_stat) >= STAT_GAP)
|
||||
{
|
||||
if (im->timestamp == mt)
|
||||
ok++;
|
||||
else continue;
|
||||
}
|
||||
else ok++;
|
||||
|
||||
if ((lo->scale_down_by == lo2->scale_down_by) &&
|
||||
(lo->dpi == lo2->dpi) && (lo->w == lo2->w) &&
|
||||
(lo->h == lo2->h))
|
||||
ok++;
|
||||
if (ok >= 3) return im;
|
||||
else continue;
|
||||
|
||||
return im;
|
||||
}
|
||||
/*
|
||||
for (l = cache; l; l = l->next)
|
||||
|
|
|
@ -46,6 +46,7 @@
|
|||
#include <signal.h>
|
||||
#include <setjmp.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#ifdef HAVE_ALLOCA_H
|
||||
|
@ -347,7 +348,7 @@ struct _RGBA_Image
|
|||
char *comment;
|
||||
} info;
|
||||
int references;
|
||||
// DATA64 timestamp;
|
||||
time_t timestamp;
|
||||
void *extended_info;
|
||||
RGBA_Image_Loadopts load_opts;
|
||||
unsigned char scale;
|
||||
|
|
Loading…
Reference in New Issue