Skip to content

Commit

Permalink
cache size made configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
nadvornik committed Jun 21, 2008
1 parent c74e058 commit 58b7c37
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/image.c
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,8 @@ static void image_cache_release_cb(FileData *fd)
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;
}

Expand Down
1 change: 1 addition & 0 deletions src/options.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ ConfOptions *init_options(ConfOptions *options)
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;
Expand Down
1 change: 1 addition & 0 deletions src/options.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ struct _ConfOptions
gint max_autofit_size;

gint tile_cache_max; /* in megabytes */
gint image_cache_max; /* in megabytes */
gint dither_quality;
gint enable_read_ahead;

Expand Down
4 changes: 4 additions & 0 deletions src/preferences.c
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,7 @@ static void config_window_apply(void)
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;
Expand Down Expand Up @@ -1509,6 +1510,9 @@ static void config_tab_advanced(GtkWidget *notebook)
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);
Expand Down
2 changes: 2 additions & 0 deletions src/rcfile.c
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,7 @@ static gboolean save_options_to(const gchar *utf8_path, ConfOptions *options)
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);
Expand Down Expand Up @@ -807,6 +808,7 @@ static gboolean load_options_from(const gchar *utf8_path, ConfOptions *options)
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);
Expand Down

0 comments on commit 58b7c37

Please sign in to comment.