changeset 848:e1d158ac6d36

cache size made configurable
author nadvornik
date Sat, 21 Jun 2008 22:01:45 +0000
parents 77fc0ea3457d
children db68d673448f
files src/image.c src/options.c src/options.h src/preferences.c src/rcfile.c
diffstat 5 files changed, 10 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/image.c	Sat Jun 21 19:26:01 2008 +0000
+++ b/src/image.c	Sat Jun 21 22:01:45 2008 +0000
@@ -492,7 +492,8 @@
 static FileCacheData *image_get_cache()
 {
 	static FileCacheData *cache = NULL;
-	if (!cache) cache = file_cache_new(image_cache_release_cb, 120000000);
+	if (!cache) cache = file_cache_new(image_cache_release_cb, 1);
+	file_cache_set_max_size(cache, (gulong)options->image.image_cache_max * 1048576); /* update from options */
 	return cache;
 }
 
--- a/src/options.c	Sat Jun 21 19:26:01 2008 +0000
+++ b/src/options.c	Sat Jun 21 22:01:45 2008 +0000
@@ -76,6 +76,7 @@
 	options->image.read_buffer_size = IMAGE_LOADER_READ_BUFFER_SIZE_DEFAULT;
 	options->image.scroll_reset_method = SCROLL_RESET_TOPLEFT;
 	options->image.tile_cache_max = 10;
+	options->image.image_cache_max = 128; /* 4 x 10MPix */
 	options->image.use_custom_border_color = FALSE;
 	options->image.zoom_2pass = TRUE;
 	options->image.zoom_increment = 5;
--- a/src/options.h	Sat Jun 21 19:26:01 2008 +0000
+++ b/src/options.h	Sat Jun 21 22:01:45 2008 +0000
@@ -67,6 +67,7 @@
 		gint max_autofit_size;
 
 		gint tile_cache_max;	/* in megabytes */
+		gint image_cache_max;   /* in megabytes */
 		gint dither_quality;
 		gint enable_read_ahead;
 
--- a/src/preferences.c	Sat Jun 21 19:26:01 2008 +0000
+++ b/src/preferences.c	Sat Jun 21 22:01:45 2008 +0000
@@ -262,6 +262,7 @@
 	options->collections.rectangular_selection = c_options->collections.rectangular_selection;
 
 	options->image.tile_cache_max = c_options->image.tile_cache_max;
+	options->image.image_cache_max = c_options->image.image_cache_max;
 
 	options->image.read_buffer_size = c_options->image.read_buffer_size;
 	options->image.idle_read_loop_count = c_options->image.idle_read_loop_count;
@@ -1509,6 +1510,9 @@
 	pref_spin_new_int(group, _("Offscreen cache size (Mb per image):"), NULL,
 			  0, 128, 1, options->image.tile_cache_max, &c_options->image.tile_cache_max);
 
+	pref_spin_new_int(group, _("Decoded image cache size (Mb):"), NULL,
+			  0, 1024, 1, options->image.image_cache_max, &c_options->image.image_cache_max);
+
 	pref_spin_new_int(group, _("Image read buffer size (bytes):"), NULL,
 			  IMAGE_LOADER_READ_BUFFER_SIZE_MIN, IMAGE_LOADER_READ_BUFFER_SIZE_MAX, 512,
 			  options->image.read_buffer_size, &c_options->image.read_buffer_size);
--- a/src/rcfile.c	Sat Jun 21 19:26:01 2008 +0000
+++ b/src/rcfile.c	Sat Jun 21 22:01:45 2008 +0000
@@ -448,6 +448,7 @@
 	WRITE_INT(image.max_autofit_size);
 	WRITE_INT(image.scroll_reset_method);
 	WRITE_INT(image.tile_cache_max);
+	WRITE_INT(image.image_cache_max);
 	WRITE_INT(image.dither_quality);
 	WRITE_BOOL(image.enable_read_ahead);
 	WRITE_BOOL(image.exif_rotate_enable);
@@ -807,6 +808,7 @@
 		READ_INT(image.max_autofit_size);
 		READ_INT(image.scroll_reset_method);
 		READ_INT(image.tile_cache_max);
+		READ_INT(image.image_cache_max);
 		READ_INT_CLAMP(image.zoom_quality, GDK_INTERP_NEAREST, GDK_INTERP_HYPER);
 		READ_INT_CLAMP(image.dither_quality, GDK_RGB_DITHER_NONE, GDK_RGB_DITHER_MAX);
 		READ_INT(image.zoom_increment);