diff options
author | Campbell Barton <ideasman42@gmail.com> | 2021-05-05 11:09:37 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2021-05-05 11:09:37 +0300 |
commit | 515afeb11b330cc9e70abe331f4a517147f8433c (patch) | |
tree | f33c015a9e9bc3321b949b472eac82ac5d4001f1 /source/blender | |
parent | 89bc6b550807ffd4b726d5cc408fe3d9b114761f (diff) | |
parent | 20b6f7abb2f7698460c73809fcdcece1e848f176 (diff) |
Merge branch 'blender-v2.93-release'
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/windowmanager/intern/wm_playanim.c | 30 |
1 files changed, 23 insertions, 7 deletions
diff --git a/source/blender/windowmanager/intern/wm_playanim.c b/source/blender/windowmanager/intern/wm_playanim.c index d33948c97d5..7f62ade5669 100644 --- a/source/blender/windowmanager/intern/wm_playanim.c +++ b/source/blender/windowmanager/intern/wm_playanim.c @@ -237,6 +237,11 @@ typedef struct PlayAnimPict { struct anim *anim; int frame; int IB_flags; + +#ifdef USE_FRAME_CACHE_LIMIT + /** Back pointer to the #LinkData node for this struct in the #inmempicsbase list. */ + LinkData *frame_cache_node; +#endif } PlayAnimPict; static struct ListBase picsbase = {NULL, NULL}; @@ -1412,25 +1417,30 @@ static char *wm_main_playanim_intern(int argc, const char **argv) } if (ibuf) { -#ifdef USE_FRAME_CACHE_LIMIT - LinkData *node; -#endif - #ifdef USE_IMB_CACHE ps.picture->ibuf = ibuf; #endif #ifdef USE_FRAME_CACHE_LIMIT + /* Don't free the current frame by moving it to the head of the list. */ + if (ps.picture->frame_cache_node != NULL) { + BLI_assert(ps.picture->frame_cache_node->data == ps.picture); + BLI_remlink(&inmempicsbase, ps.picture->frame_cache_node); + BLI_addhead(&inmempicsbase, ps.picture->frame_cache_node); + } + /* Really basic memory conservation scheme. Keep frames in a FIFO queue. */ - node = inmempicsbase.last; + LinkData *node = inmempicsbase.last; while (node && added_images > PLAY_FRAME_CACHE_MAX) { PlayAnimPict *pic = node->data; + BLI_assert(pic->frame_cache_node == node); if (pic->ibuf && pic->ibuf != ibuf) { LinkData *node_tmp; IMB_freeImBuf(pic->ibuf); pic->ibuf = NULL; + pic->frame_cache_node = NULL; node_tmp = node->prev; BLI_freelinkN(&inmempicsbase, node); added_images--; @@ -1441,8 +1451,11 @@ static char *wm_main_playanim_intern(int argc, const char **argv) } } - BLI_addhead(&inmempicsbase, BLI_genericNodeN(ps.picture)); - added_images++; + if (ps.picture->frame_cache_node == NULL) { + ps.picture->frame_cache_node = BLI_genericNodeN(ps.picture); + BLI_addhead(&inmempicsbase, ps.picture->frame_cache_node); + added_images++; + } #endif /* USE_FRAME_CACHE_LIMIT */ BLI_strncpy(ibuf->name, ps.picture->name, sizeof(ibuf->name)); @@ -1550,8 +1563,11 @@ static char *wm_main_playanim_intern(int argc, const char **argv) #endif BLI_freelistN(&picsbase); + +#ifdef USE_FRAME_CACHE_LIMIT BLI_freelistN(&inmempicsbase); added_images = 0; +#endif #ifdef WITH_AUDASPACE if (playback_handle) { |