diff options
author | Daniel Friesel <derf@finalrewind.org> | 2017-12-28 19:04:52 +0100 |
---|---|---|
committer | Daniel Friesel <derf@finalrewind.org> | 2017-12-28 19:04:52 +0100 |
commit | 68373bb7f5aa78aae0d40311e8cada7f4832387d (patch) | |
tree | fd42dc8e86e68e10afb1a2a5bd8c93cb37a7d908 | |
parent | 51ed4f02a56ac292a95f4347fbd0d385335a239c (diff) | |
parent | 91b331f0fa6999dff69fa1da90a8816b8d855ccc (diff) |
Merge branch 'ulteq-cache-size-option'
-rw-r--r-- | man/feh.pre | 10 | ||||
-rw-r--r-- | src/help.raw | 1 | ||||
-rw-r--r-- | src/imlib.c | 12 | ||||
-rw-r--r-- | src/options.c | 10 | ||||
-rw-r--r-- | src/options.h | 3 |
5 files changed, 36 insertions, 0 deletions
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; |