Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorSergey Sharybin <sergey.vfx@gmail.com>2013-04-04 13:50:51 +0400
committerSergey Sharybin <sergey.vfx@gmail.com>2013-04-04 13:50:51 +0400
commit65023edabdde8657728df7d723f9cdfb1859b605 (patch)
treed5d8338ab8259c20e4f34ed3c4d95ee2365367dd /source
parent845aea6864cf4b3aa34d7676f725ab268465e34f (diff)
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.
Diffstat (limited to 'source')
-rw-r--r--source/blender/blenkernel/BKE_movieclip.h1
-rw-r--r--source/blender/blenkernel/intern/movieclip.c5
-rw-r--r--source/blender/editors/space_clip/clip_editor.c18
-rw-r--r--source/blender/makesrna/intern/rna_movieclip.c42
4 files changed, 61 insertions, 5 deletions
diff --git a/source/blender/blenkernel/BKE_movieclip.h b/source/blender/blenkernel/BKE_movieclip.h
index f97b5b1f3a1..4828df2fbec 100644
--- a/source/blender/blenkernel/BKE_movieclip.h
+++ b/source/blender/blenkernel/BKE_movieclip.h
@@ -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);
diff --git a/source/blender/blenkernel/intern/movieclip.c b/source/blender/blenkernel/intern/movieclip.c
index d180844e132..c8f3399665c 100644
--- a/source/blender/blenkernel/intern/movieclip.c
+++ b/source/blender/blenkernel/intern/movieclip.c
@@ -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 */
diff --git a/source/blender/editors/space_clip/clip_editor.c b/source/blender/editors/space_clip/clip_editor.c
index b3b6251645c..08d0af817a8 100644
--- a/source/blender/editors/space_clip/clip_editor.c
+++ b/source/blender/editors/space_clip/clip_editor.c
@@ -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);
}
diff --git a/source/blender/makesrna/intern/rna_movieclip.c b/source/blender/makesrna/intern/rna_movieclip.c
index cc3d5e5ca5e..9b2bcab4604 100644
--- a/source/blender/makesrna/intern/rna_movieclip.c
+++ b/source/blender/makesrna/intern/rna_movieclip.c
@@ -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)