aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorN-R-K <79544946+N-R-K@users.noreply.github.com>2021-11-26 03:04:02 +0600
committerNRK <nrk@disroot.org>2021-11-26 03:09:46 +0600
commit0639047dde5d3ccb35f9c1a7be3266a373945b6e (patch)
tree563ad08dfe45535136de5de3d713266e8ea617b1
parent43960312333bc9d9a6a8a95fff3563044856eccf (diff)
allow configuring imlib2's cache size (#171)
by default imlib2 uses a 4mb cache, which is quite small. this allows users who have more memory to spare to set a bigger cache size and avoid reloading an already viewed image if it fits into the cache. Co-authored-by: Berke Kocaoğlu <berke.kocaoglu@metu.edu.tr>
-rw-r--r--config.def.h6
-rw-r--r--image.c1
2 files changed, 7 insertions, 0 deletions
diff --git a/config.def.h b/config.def.h
index f044c66..99dd8ba 100644
--- a/config.def.h
+++ b/config.def.h
@@ -59,6 +59,12 @@ static const bool ANTI_ALIAS = true;
*/
static const bool ALPHA_LAYER = false;
+/* cache size for imlib2, in bytes. For backwards compatibility reasons, the
+ * size is kept at 4MiB. For most users, it is advised to pick a value close to
+ * or above 128MiB for better image (re)loading performance.
+ */
+static const int CACHE_SIZE = 4 * 1024 * 1024; /* 4MiB */
+
#endif
#ifdef _THUMBS_CONFIG
diff --git a/image.c b/image.c
index a4183b9..9a47a14 100644
--- a/image.c
+++ b/image.c
@@ -48,6 +48,7 @@ void img_init(img_t *img, win_t *win)
imlib_context_set_display(win->env.dpy);
imlib_context_set_visual(win->env.vis);
imlib_context_set_colormap(win->env.cmap);
+ imlib_set_cache_size(CACHE_SIZE);
img->im = NULL;
img->win = win;