Enlightenment CVS committal
Author : raster
Project : e17
Module : libs/evas
Dir : e17/libs/evas/src/lib/engines/common
Modified Files:
evas_image_load.c evas_image_main.c
Log Message:
i've put back timestamp checks - but evas wont stata file more frequently
than once per 2 seconds to avoid overhead.
===================================================================
RCS file: /cvs/e/e17/libs/evas/src/lib/engines/common/evas_image_load.c,v
retrieving revision 1.36
retrieving revision 1.37
diff -u -3 -r1.36 -r1.37
--- evas_image_load.c 18 Sep 2006 14:51:48 -0000 1.36
+++ evas_image_load.c 2 Mar 2007 22:27:52 -0000 1.37
@@ -31,6 +31,8 @@
im = evas_common_image_new();
if (!im) return NULL;
+ im->timestamp = st.st_mtime;
+
if (lo) im->load_opts = *lo;
p = strrchr(file, '.');
===================================================================
RCS file: /cvs/e/e17/libs/evas/src/lib/engines/common/evas_image_main.c,v
retrieving revision 1.43
retrieving revision 1.44
diff -u -3 -r1.43 -r1.44
--- evas_image_main.c 2 Mar 2007 22:09:18 -0000 1.43
+++ evas_image_main.c 2 Mar 2007 22:27:52 -0000 1.44
@@ -468,6 +468,7 @@
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 @@
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 @@
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)
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
enlightenment-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs