nsxiv0639047
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.
+7 −0
2 files changed
- M config.def.h +6 −0
- M image.c +1 −0
| @@ -59,6 +59,12 @@ static const bool ANTI_ALIAS = true; | |||
| 59 | 59 | */ | |
| 60 | 60 | static const bool ALPHA_LAYER = false; | |
| 61 | 61 | ||
| 62 | + | /* cache size for imlib2, in bytes. For backwards compatibility reasons, the | |
| 63 | + | * size is kept at 4MiB. For most users, it is advised to pick a value close to | |
| 64 | + | * or above 128MiB for better image (re)loading performance. | |
| 65 | + | */ | |
| 66 | + | static const int CACHE_SIZE = 4 * 1024 * 1024; /* 4MiB */ | |
| 67 | + | ||
| 62 | 68 | #endif | |
| 63 | 69 | #ifdef _THUMBS_CONFIG | |
| 64 | 70 | ||
| @@ -48,6 +48,7 @@ void img_init(img_t *img, win_t *win) | |||
| 48 | 48 | imlib_context_set_display(win->env.dpy); | |
| 49 | 49 | imlib_context_set_visual(win->env.vis); | |
| 50 | 50 | imlib_context_set_colormap(win->env.cmap); | |
| 51 | + | imlib_set_cache_size(CACHE_SIZE); | |
| 51 | 52 | ||
| 52 | 53 | img->im = NULL; | |
| 53 | 54 | img->win = win; | |