Fix T66872: Changing clip color space does not update background images

Such reload can no longer happen directly and is to be done via dependency
graph.

Eventually, the movie cache will become shared across all copies of the
clip, but even then we still need to have dependency graph mechanism because
we need to update FFmpeg animation handle (which can not be shared across
the copies).
This commit is contained in:
2019-07-28 13:24:18 +02:00
parent 233f78c017
commit 2cce65de96
10 changed files with 38 additions and 12 deletions

View File

@@ -118,7 +118,9 @@ bool BKE_movieclip_put_frame_if_possible(struct MovieClip *clip,
/* Dependency graph evaluation. */
void BKE_movieclip_eval_update(struct Depsgraph *depsgraph, struct MovieClip *clip);
void BKE_movieclip_eval_update(struct Depsgraph *depsgraph,
struct Main *bmain,
struct MovieClip *clip);
void BKE_movieclip_eval_selection_update(struct Depsgraph *depsgraph, struct MovieClip *clip);
/* caching flags */

View File

@@ -53,6 +53,7 @@
#include "BKE_animsys.h"
#include "BKE_colortools.h"
#include "BKE_global.h"
#include "BKE_library.h"
#include "BKE_main.h"
#include "BKE_movieclip.h"
@@ -1772,9 +1773,17 @@ static void movieclip_selection_synchronize(MovieClip *clip_dst, const MovieClip
}
}
void BKE_movieclip_eval_update(struct Depsgraph *depsgraph, MovieClip *clip)
void movieclip_eval_update_reload(struct Depsgraph *depsgraph, Main *bmain, MovieClip *clip)
{
BKE_movieclip_reload(bmain, clip);
if (DEG_is_active(depsgraph)) {
MovieClip *clip_orig = (MovieClip *)DEG_get_original_id(&clip->id);
BKE_movieclip_reload(bmain, clip_orig);
}
}
void movieclip_eval_update_generic(struct Depsgraph *depsgraph, MovieClip *clip)
{
DEG_debug_print_eval(depsgraph, __func__, clip->id.name, clip);
BKE_tracking_dopesheet_tag_update(&clip->tracking);
if (DEG_is_active(depsgraph)) {
MovieClip *clip_orig = (MovieClip *)DEG_get_original_id(&clip->id);
@@ -1782,6 +1791,17 @@ void BKE_movieclip_eval_update(struct Depsgraph *depsgraph, MovieClip *clip)
}
}
void BKE_movieclip_eval_update(struct Depsgraph *depsgraph, Main *bmain, MovieClip *clip)
{
DEG_debug_print_eval(depsgraph, __func__, clip->id.name, clip);
if (clip->id.recalc & ID_RECALC_SOURCE) {
movieclip_eval_update_reload(depsgraph, bmain, clip);
}
else {
movieclip_eval_update_generic(depsgraph, clip);
}
}
void BKE_movieclip_eval_selection_update(struct Depsgraph *depsgraph, MovieClip *clip)
{
DEG_debug_print_eval(depsgraph, __func__, clip->id.name, clip);

View File

@@ -1557,7 +1557,7 @@ void DepsgraphNodeBuilder::build_movieclip(MovieClip *clip)
add_operation_node(clip_id,
NodeType::PARAMETERS,
OperationCode::MOVIECLIP_EVAL,
function_bind(BKE_movieclip_eval_update, _1, clip_cow));
function_bind(BKE_movieclip_eval_update, _1, bmain_, clip_cow));
add_operation_node(clip_id,
NodeType::BATCH_CACHE,

View File

@@ -1434,7 +1434,7 @@ static void proxy_endjob(void *pjv)
if (pj->clip->source == MCLIP_SRC_MOVIE) {
/* Timecode might have changed, so do a full reload to deal with this. */
BKE_movieclip_reload(pj->main, pj->clip);
DEG_id_tag_update(&pj->clip->id, ID_RECALC_SOURCE);
}
else {
/* For image sequences we'll preserve original cache. */

View File

@@ -620,6 +620,11 @@ typedef enum IDRecalcFlag {
* Basically, the same what changing frame in a timeline will do. */
ID_RECALC_TIME = (1 << 22),
/* Input has changed and datablock is to be reload from disk.
* Applies to movie clips to inform that copy-on-written version is to be refreshed for the new
* input file or for color space changes. */
ID_RECALC_SOURCE = (1 << 23),
/***************************************************************************
* Pseudonyms, to have more semantic meaning in the actual code without
* using too much low-level and implementation specific tags. */

View File

@@ -597,7 +597,7 @@ static void rna_ColorManagedColorspaceSettings_reload_update(Main *bmain,
else if (GS(id->name) == ID_MC) {
MovieClip *clip = (MovieClip *)id;
BKE_movieclip_reload(bmain, clip);
DEG_id_tag_update(&clip->id, ID_RECALC_SOURCE);
BKE_sequence_invalidate_movieclip_strips(bmain, clip);
WM_main_add_notifier(NC_MOVIECLIP | ND_DISPLAY, &clip->id);

View File

@@ -51,12 +51,11 @@
# include "DNA_screen_types.h"
# include "DNA_space_types.h"
static void rna_MovieClip_reload_update(Main *bmain, Scene *UNUSED(scene), PointerRNA *ptr)
static void rna_MovieClip_reload_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
{
MovieClip *clip = (MovieClip *)ptr->id.data;
BKE_movieclip_reload(bmain, clip);
DEG_id_tag_update(&clip->id, 0);
DEG_id_tag_update(&clip->id, ID_RECALC_SOURCE);
}
static void rna_MovieClip_size_get(PointerRNA *ptr, int *values)