Enable caching for multiframe images

This commit is contained in:
Kim Woelders 2021-12-18 16:10:26 +01:00
parent 1a57db7dcb
commit d105b29017
2 changed files with 11 additions and 10 deletions

View File

@ -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);

View File

@ -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 */