summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiika Pekkarinen <miipekk@ihme.org>2006-02-01 08:43:29 +0000
committerMiika Pekkarinen <miipekk@ihme.org>2006-02-01 08:43:29 +0000
commitb106e010d5974e6e8812028f967a29692e52632d (patch)
treecca8717f7ab13b40d7676af88e1a4df56f19f582
parent98c37c7f89e811ad65a811cb408231b42f0c638a (diff)
downloadrockbox-b106e010d5974e6e8812028f967a29692e52632d.zip
rockbox-b106e010d5974e6e8812028f967a29692e52632d.tar.gz
rockbox-b106e010d5974e6e8812028f967a29692e52632d.tar.bz2
rockbox-b106e010d5974e6e8812028f967a29692e52632d.tar.xz
Reverted the wps image cache as it was causing trouble to users when
updating the image files on disk. Better solution is to be implemented soon. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@8519 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--apps/gui/gwps-common.c124
-rw-r--r--apps/gui/gwps-common.h3
-rw-r--r--apps/gui/gwps.c5
3 files changed, 4 insertions, 128 deletions
diff --git a/apps/gui/gwps-common.c b/apps/gui/gwps-common.c
index 1cda8c0..d6d765f 100644
--- a/apps/gui/gwps-common.c
+++ b/apps/gui/gwps-common.c
@@ -75,22 +75,6 @@ static char* skip_utf8_bom(char* buf)
* a..z and A..Z
*/
#ifdef HAVE_LCD_BITMAP
-#define BMP_CACHE_VERSION 1
-
-struct bmp_cache_header {
- int version;
-};
-
-struct bmp_cache_entry {
- char filename[MAX_PATH];
- int width;
- int height;
- int format;
- int size;
-};
-static int bmp_cache_fd = -1;
-static bool bmp_cache_write;
-
static int get_image_id(int c)
{
if(c >= 'a' && c <= 'z')
@@ -99,80 +83,6 @@ static int get_image_id(int c)
c = c - 'A' + 26;
return c;
}
-
-void wps_initialize_bmp_cache(const char *file)
-{
- struct bmp_cache_header h;
-
- bmp_cache_fd = open(file, O_RDONLY);
- bmp_cache_write = 0;
-
- /* Check header validity. */
- if (bmp_cache_fd >= 0)
- {
- if ((read(bmp_cache_fd, &h, sizeof(struct bmp_cache_header))
- != sizeof(struct bmp_cache_header)
- ) || h.version != BMP_CACHE_VERSION)
- {
- close(bmp_cache_fd);
- bmp_cache_fd = -1;
- }
- }
-
- if (bmp_cache_fd < 0)
- {
- bmp_cache_fd = open(file, O_WRONLY | O_CREAT);
- bmp_cache_write = 1;
-
- /* Write the header. */
- h.version = BMP_CACHE_VERSION;
- write(bmp_cache_fd, &h, sizeof(struct bmp_cache_header));
- }
-}
-
-void wps_close_bmp_cache(const char *file)
-{
- if (bmp_cache_fd >= 0)
- {
- close(bmp_cache_fd);
- bmp_cache_fd = -1;
- return ;
- }
-
- /* Remove the file if cache read failed. */
- remove(file);
-}
-
-static int read_bmp_from_cache(const char *filename, struct bitmap *bm,
- int buflen)
-{
- struct bmp_cache_entry c;
- int rc;
-
- if (!bmp_cache_fd || bmp_cache_write)
- return -1;
-
- rc = read(bmp_cache_fd, &c, sizeof(struct bmp_cache_entry));
- if (rc != sizeof(struct bmp_cache_entry))
- return -2;
-
- if (buflen < c.size)
- return -3;
-
- if (strcasecmp(filename, c.filename))
- return -4;
-
- bm->width = c.width;
- bm->height = c.height;
-#if LCD_DEPTH > 1
- bm->format = c.format;
-#endif
- rc = read(bmp_cache_fd, bm->data, c.size);
- if (rc != c.size)
- return -4;
-
- return c.size;
-}
#endif
/*
@@ -308,21 +218,9 @@ bool wps_data_preload_tags(struct wps_data *data, char *buf,
/* load the image */
data->img[n].bm.data = data->img_buf_ptr;
- ret = read_bmp_from_cache(imgname, &data->img[n].bm,
- data->img_buf_free);
-
- if (ret < 0)
- {
- if (!bmp_cache_write)
- {
- close(bmp_cache_fd);
- bmp_cache_fd = -1;
- }
-
- ret = read_bmp_file(imgname, &data->img[n].bm,
- data->img_buf_free,
- FORMAT_ANY|FORMAT_TRANSPARENT);
- }
+ ret = read_bmp_file(imgname, &data->img[n].bm,
+ data->img_buf_free,
+ FORMAT_ANY|FORMAT_TRANSPARENT);
if (ret > 0)
{
@@ -330,21 +228,7 @@ bool wps_data_preload_tags(struct wps_data *data, char *buf,
if (ret % 2) ret++;
/* Always consume an even number of bytes */
#endif
- /* Update the image cache. */
- if (bmp_cache_write && bmp_cache_fd >= 0)
- {
- struct bmp_cache_entry c;
- strncpy(c.filename, imgname, sizeof(c.filename)-1);
- c.width = data->img[n].bm.width;
- c.height = data->img[n].bm.height;
-#if LCD_DEPTH > 1
- c.format = data->img[n].bm.format;
-#endif
- c.size = ret;
- write(bmp_cache_fd, &c, sizeof(struct bmp_cache_entry));
- write(bmp_cache_fd, data->img_buf_ptr, ret);
- }
-
+
data->img_buf_ptr += ret;
data->img_buf_free -= ret;
data->img[n].loaded = true;
diff --git a/apps/gui/gwps-common.h b/apps/gui/gwps-common.h
index b106203..ecda1d4 100644
--- a/apps/gui/gwps-common.h
+++ b/apps/gui/gwps-common.h
@@ -23,9 +23,6 @@
#include "gwps.h"
-void wps_initialize_bmp_cache(const char *file);
-void wps_close_bmp_cache(const char *file);
-
void gui_wps_format_time(char* buf, int buf_size, long time);
void fade(bool fade_in);
void gui_wps_format(struct wps_data *data);
diff --git a/apps/gui/gwps.c b/apps/gui/gwps.c
index e7ae672..d7d436c 100644
--- a/apps/gui/gwps.c
+++ b/apps/gui/gwps.c
@@ -862,7 +862,6 @@ bool wps_data_load(struct wps_data *wps_data,
wps_data->img_buf_ptr = wps_data->img_buf; /* where in image buffer */
wps_data->img_buf_free = IMG_BUFSIZE; /* free space in image buffer */
- wps_initialize_bmp_cache(ROCKBOX_DIR "/.wpscache");
#endif
while( ( read_line(fd, &wps_data->format_buffer[start],
sizeof(wps_data->format_buffer)-start) ) > 0 )
@@ -881,10 +880,6 @@ bool wps_data_load(struct wps_data *wps_data,
}
}
-#ifdef HAVE_LCD_BITMAP
- wps_close_bmp_cache(ROCKBOX_DIR "/.wpscache");
-#endif
-
if (start > 0)
{
gui_wps_format(wps_data);