diff options
author | Kim Woelders <kim@woelders.dk> | 2021-12-18 16:10:26 +0100 |
---|---|---|
committer | Kim Woelders <kim@woelders.dk> | 2021-12-19 14:58:43 +0100 |
commit | d105b290172eb0e4f352146872066f3a27477543 (patch) | |
tree | 7ac83294b2d34a580750d6a4860ef6d465798e91 /src/lib | |
parent | 1a57db7dcb21b48a960c0e67621e9f3f80a2a076 (diff) | |
download | imlib2-d105b290172eb0e4f352146872066f3a27477543.tar.gz |
Enable caching for multiframe images
Diffstat (limited to 'src/lib')
-rw-r--r-- | src/lib/api.c | 4 | ||||
-rw-r--r-- | src/lib/image.c | 17 |
2 files changed, 11 insertions, 10 deletions
diff --git a/src/lib/api.c b/src/lib/api.c index 4a5077c..6b68528 100644 --- a/src/lib/api.c +++ b/src/lib/api.c @@ -1344,13 +1344,13 @@ imlib_load_image_with_error_return(const char *file, * Loads the specified frame within the image. * On success an image handle is returned, otherwise NULL is returned * (e.g. if the requested frame does not exist). - * The image is loaded immediately and will not be cached. + * The image is loaded immediately. */ EAPI Imlib_Image imlib_load_image_frame(const char *file, int frame) { ImlibImage *im; - ImlibLoadArgs ila = { ILA0(ctx, 1, 1),.frame = frame }; + ImlibLoadArgs ila = { ILA0(ctx, 1, 0),.frame = frame }; CHECK_PARAM_POINTER_RETURN("file", file, NULL); diff --git a/src/lib/image.c b/src/lib/image.c index 6981b20..cb711d1 100644 --- a/src/lib/image.c +++ b/src/lib/image.c @@ -113,25 +113,26 @@ __imlib_ConsumeImage(ImlibImage * im) } static ImlibImage * -__imlib_FindCachedImage(const char *file) +__imlib_FindCachedImage(const char *file, int frame) { ImlibImage *im, *im_prev; - DP("%s: '%s'\n", __func__, file); + DP("%s: '%s' frame %d\n", __func__, file, frame); for (im = images, im_prev = NULL; im; im_prev = im, im = im->next) { /* if the filenames match and it's valid */ - if ((!strcmp(file, im->file)) && (IMAGE_IS_VALID(im))) + if (!strcmp(file, im->file) && IMAGE_IS_VALID(im) && + frame == im->frame_num) { - /* move the image to the head of the pixmap list */ + /* move the image to the head of the image list */ if (im_prev) { im_prev->next = im->next; im->next = images; images = im; } - DP(" got %p: '%s'\n", im, im->real_file); + DP(" got %p: '%s' frame %d\n", im, im->real_file, im->frame_num); return im; } } @@ -143,7 +144,7 @@ __imlib_FindCachedImage(const char *file) static void __imlib_AddImageToCache(ImlibImage * im) { - DP("%s: %p: '%s'\n", __func__, im, im->real_file); + DP("%s: %p: '%s' frame %d\n", __func__, im, im->real_file, im->frame_num); im->next = images; images = im; } @@ -155,7 +156,7 @@ __imlib_RemoveImageFromCache(ImlibImage * im_del) ImlibImage *im, *im_prev; im = im_del; - DP("%s: %p: '%s'\n", __func__, im, im->real_file); + DP("%s: %p: '%s' frame %d\n", __func__, im, im->real_file, im->frame_num); for (im = images, im_prev = NULL; im; im_prev = im, im = im->next) { @@ -446,7 +447,7 @@ __imlib_LoadImage(const char *file, ImlibLoadArgs * ila) return NULL; /* see if we already have the image cached */ - im = __imlib_FindCachedImage(file); + im = __imlib_FindCachedImage(file, ila->frame); /* if we found a cached image and we should always check that it is */ /* accurate to the disk conents if they changed since we last loaded */ |