summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog8
-rw-r--r--man/feh.pre10
-rw-r--r--src/help.raw1
-rw-r--r--src/imlib.c12
-rw-r--r--src/options.c10
-rw-r--r--src/options.h3
6 files changed, 44 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index 76b46c8..e70775c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+Thu, 28 Dec 2017 19:26:29 +0100
+
+* Release v2.23
+ * Fix broken thumbnail/index windows when using --scale-down
+ * Use Imlib2 in-memory image cache (default cache size: 4MiB). This allows
+ for significant performance improvements especially in small slideshows
+ * Add --cache-size option to set Imlib2 image cache size
+
Tue, 07 Nov 2017 17:36:26 +0100 Daniel Friesel <derf+feh@finalrewind.org>
* Release v2.22.2
diff --git a/man/feh.pre b/man/feh.pre
index ac9a81a..c2a4cd1 100644
--- a/man/feh.pre
+++ b/man/feh.pre
@@ -205,6 +205,16 @@ Zoom pictures to screen size in fullscreen / fixed geometry mode.
.
Create borderless windows.
.
+.It Cm --cache-size Ar size
+.
+Set Imlib2 in-memory cache to
+.Ar size
+MiB. A higher cache size can
+significantly improve performance especially for small slide shows, however at
+the cost of increased memory consumption.
+.Ar size
+must be between 0 and 2048 MiB and defaults to 4.
+.
.It Cm -P , --cache-thumbnails
.
Enable thumbnail caching in
diff --git a/src/help.raw b/src/help.raw
index 2bc5986..37e0e71 100644
--- a/src/help.raw
+++ b/src/help.raw
@@ -94,6 +94,7 @@ OPTIONS
--min-dimension WxH Only show images with width >= W and height >= H
--max-dimension WxH Only show images with width <= W and height <= H
--scroll-step COUNT scroll COUNT pixels when movement key is pressed
+ --cache-size NUM imlib cache size in mebibytes (0 .. 2048)
MONTAGE MODE OPTIONS
-X, --ignore-aspect Set thumbnail to specified width/height without
diff --git a/src/imlib.c b/src/imlib.c
index 5b96e8a..73b7039 100644
--- a/src/imlib.c
+++ b/src/imlib.c
@@ -131,6 +131,8 @@ void init_x_and_imlib(void)
imlib_context_set_operation(IMLIB_OP_COPY);
wmDeleteWindow = XInternAtom(disp, "WM_DELETE_WINDOW", False);
+ imlib_set_cache_size(opt.cache_size * 1024 * 1024);
+
/* Initialise random numbers */
srand(getpid() * time(NULL) % ((unsigned int) -1));
@@ -254,6 +256,16 @@ int feh_load_image(Imlib_Image * im, feh_file * file)
return(0);
}
+ /*
+ * By default, Imlib2 unconditionally loads a cached file without checking
+ * if it was modified on disk. However, feh (or rather its users) should
+ * expect image changes to appear at the next reload. So we tell Imlib2 to
+ * always check the file modification time and only use a cached image if
+ * the mtime was not changed. The performance penalty is usually negligible.
+ */
+ imlib_context_set_image(*im);
+ imlib_image_set_changes_on_disk();
+
#ifdef HAVE_LIBEXIF
int orientation = 0;
ExifData *exifData = exif_data_new_from_file(file->filename);
diff --git a/src/options.c b/src/options.c
index 1ed5b54..c874832 100644
--- a/src/options.c
+++ b/src/options.c
@@ -68,6 +68,7 @@ void init_parse_options(int argc, char **argv)
opt.jump_on_resort = 1;
opt.screen_clip = 1;
+ opt.cache_size = 4;
#ifdef HAVE_LIBXINERAMA
/* if we're using xinerama, then enable it by default */
opt.xinerama = 1;
@@ -410,6 +411,7 @@ static void feh_parse_option_array(int argc, char **argv, int finalrun)
{"xinerama-index", 1, 0, 239},
{"insecure" , 0, 0, 240},
{"no-recursive" , 0, 0, 241},
+ {"cache-size" , 1, 0, 243},
{0, 0, 0, 0}
};
int optch = 0, cmdx = 0;
@@ -772,6 +774,14 @@ static void feh_parse_option_array(int argc, char **argv, int finalrun)
break;
case 241:
opt.recursive = 0;
+ break;
+ case 243:
+ opt.cache_size = atoi(optarg);
+ if (opt.cache_size < 0)
+ opt.cache_size = 0;
+ if (opt.cache_size > 2048)
+ opt.cache_size = 2048;
+ break;
default:
break;
}
diff --git a/src/options.h b/src/options.h
index 4e2703e..c6959c8 100644
--- a/src/options.h
+++ b/src/options.h
@@ -117,6 +117,9 @@ struct __fehoptions {
/* signed in case someone wants to invert scrolling real quick */
int scroll_step;
+ // imlib cache size in mebibytes
+ int cache_size;
+
unsigned int min_width, min_height, max_width, max_height;
unsigned char mode;