Changes to cache invalidation policy for movie clips
- When changing clip in clip editor, remove all frames from it's cache to free memory for new clip. - When changing proxy render settings, free cache as well.
This commit is contained in:
@@ -45,6 +45,7 @@ void BKE_movieclip_unlink(struct Main *bmain, struct MovieClip *clip);
|
||||
|
||||
struct MovieClip *BKE_movieclip_file_add(struct Main *bmain, const char *name);
|
||||
void BKE_movieclip_reload(struct MovieClip *clip);
|
||||
void BKE_movieclip_clear_cache(struct MovieClip *clip);
|
||||
|
||||
struct ImBuf *BKE_movieclip_get_ibuf(struct MovieClip *clip, struct MovieClipUser *user);
|
||||
struct ImBuf *BKE_movieclip_get_postprocessed_ibuf(struct MovieClip *clip, struct MovieClipUser *user, int postprocess_flag);
|
||||
|
||||
@@ -1162,6 +1162,11 @@ static void free_buffers(MovieClip *clip)
|
||||
BKE_free_animdata((ID *) clip);
|
||||
}
|
||||
|
||||
void BKE_movieclip_clear_cache(MovieClip *clip)
|
||||
{
|
||||
free_buffers(clip);
|
||||
}
|
||||
|
||||
void BKE_movieclip_reload(MovieClip *clip)
|
||||
{
|
||||
/* clear cache */
|
||||
|
||||
@@ -528,6 +528,7 @@ MovieClip *ED_space_clip_get_clip(SpaceClip *sc)
|
||||
void ED_space_clip_set_clip(bContext *C, bScreen *screen, SpaceClip *sc, MovieClip *clip)
|
||||
{
|
||||
MovieClip *old_clip;
|
||||
bool old_clip_visible = false;
|
||||
|
||||
if (!screen && C)
|
||||
screen = CTX_wm_screen(C);
|
||||
@@ -546,9 +547,15 @@ void ED_space_clip_set_clip(bContext *C, bScreen *screen, SpaceClip *sc, MovieCl
|
||||
if (sl->spacetype == SPACE_CLIP) {
|
||||
SpaceClip *cur_sc = (SpaceClip *) sl;
|
||||
|
||||
if (cur_sc != sc && cur_sc->view != SC_VIEW_CLIP) {
|
||||
if (cur_sc->clip == old_clip || cur_sc->clip == NULL) {
|
||||
cur_sc->clip = clip;
|
||||
if (cur_sc != sc) {
|
||||
if (cur_sc->view == SC_VIEW_CLIP) {
|
||||
if (cur_sc->clip == old_clip)
|
||||
old_clip_visible = true;
|
||||
}
|
||||
else {
|
||||
if (cur_sc->clip == old_clip || cur_sc->clip == NULL) {
|
||||
cur_sc->clip = clip;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -556,6 +563,11 @@ void ED_space_clip_set_clip(bContext *C, bScreen *screen, SpaceClip *sc, MovieCl
|
||||
}
|
||||
}
|
||||
|
||||
/* If clip is no longer visible on screen, free memory used by it's cache */
|
||||
if (old_clip && old_clip != clip && !old_clip_visible) {
|
||||
BKE_movieclip_clear_cache(old_clip);
|
||||
}
|
||||
|
||||
if (C)
|
||||
WM_event_add_notifier(C, NC_MOVIECLIP | NA_SELECTED, sc->clip);
|
||||
}
|
||||
|
||||
@@ -49,6 +49,11 @@
|
||||
|
||||
#include "BKE_depsgraph.h"
|
||||
|
||||
#include "ED_clip.h"
|
||||
|
||||
#include "DNA_screen_types.h"
|
||||
#include "DNA_space_types.h"
|
||||
|
||||
static void rna_MovieClip_reload_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
|
||||
{
|
||||
MovieClip *clip = (MovieClip *)ptr->id.data;
|
||||
@@ -65,6 +70,39 @@ static void rna_MovieClip_size_get(PointerRNA *ptr, int *values)
|
||||
values[1] = clip->lastsize[1];
|
||||
}
|
||||
|
||||
static void rna_MovieClipUser_proxy_render_settings_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
|
||||
{
|
||||
ID *id = (ID *) ptr->id.data;
|
||||
MovieClipUser *user = (MovieClipUser *) ptr->data;
|
||||
|
||||
/* when changing render settings of space clip user
|
||||
* clear cache for clip, so all the memory is available
|
||||
* for new render settings
|
||||
*/
|
||||
if (GS(id->name) == ID_SCR) {
|
||||
bScreen *screen = (bScreen *) id;
|
||||
ScrArea *area;
|
||||
SpaceLink *sl;
|
||||
|
||||
for (area = screen->areabase.first; area; area = area->next) {
|
||||
for (sl = area->spacedata.first; sl; sl = sl->next) {
|
||||
if (sl->spacetype == SPACE_CLIP) {
|
||||
SpaceClip *sc = (SpaceClip *) sl;
|
||||
|
||||
if (&sc->user == user) {
|
||||
MovieClip *clip = ED_space_clip_get_clip(sc);
|
||||
|
||||
if (clip && (clip->flag & MCLIP_USE_PROXY))
|
||||
BKE_movieclip_clear_cache(clip);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
static void rna_def_movieclip_proxy(BlenderRNA *brna)
|
||||
@@ -197,13 +235,13 @@ static void rna_def_moviecliUser(BlenderRNA *brna)
|
||||
RNA_def_property_enum_items(prop, clip_render_size_items);
|
||||
RNA_def_property_ui_text(prop, "Proxy render size",
|
||||
"Draw preview using full resolution or different proxy resolutions");
|
||||
RNA_def_property_update(prop, NC_MOVIECLIP | ND_DISPLAY, NULL);
|
||||
RNA_def_property_update(prop, NC_MOVIECLIP | ND_DISPLAY, "rna_MovieClipUser_proxy_render_settings_update");
|
||||
|
||||
/* render undistorted */
|
||||
prop = RNA_def_property(srna, "use_render_undistorted", PROP_BOOLEAN, PROP_NONE);
|
||||
RNA_def_property_boolean_sdna(prop, NULL, "render_flag", MCLIP_PROXY_RENDER_UNDISTORT);
|
||||
RNA_def_property_ui_text(prop, "Render Undistorted", "Render preview using undistorted proxy");
|
||||
RNA_def_property_update(prop, NC_MOVIECLIP | ND_DISPLAY, NULL);
|
||||
RNA_def_property_update(prop, NC_MOVIECLIP | ND_DISPLAY, "rna_MovieClipUser_proxy_render_settings_update");
|
||||
}
|
||||
|
||||
static void rna_def_movieClipScopes(BlenderRNA *brna)
|
||||
|
||||
Reference in New Issue
Block a user