Files
test/source/blender/sequencer/SEQ_relations.hh
Richard Antalik 7169ee7850 VSE: Scene strip invalidation
Previously there was no mechanism to invalidate scene strip cache, when
changes were made to scene that the strip renders. Because of this, the
cache had to be cleared manually, even for other strips.

Strip invalidation is performed from function
`ED_render_id_flush_update`.
Recalc flags like selection or frame change are ignored as they are
unlikely to influence the rendered image.
When some ID is changed, all scene strips using
`DEGEditorUpdateContext::scene` will be invalidated.

Limitations:
- Because frame change is ignored, changes to physics caches would not
invalidate VSE strips
- Only active scene will be invalidated this way. So if an object is
linked to 2 scenes, inactive scene cache would be invalid
- If animated object is moved, and there is VSE preview to be updated
Scene re-rendering in VSE would cause object to snap to its evaluated
position. This is because scene frame is changed by VSE. Reported in
#139501.

To refresh VSE preview after cache is invalidated, relatively big chunk
of code was copied from `view3d_main_region_listener` to VSE preview
listener. Cases that would not result in visual changes like selection
were excluded.

Fixes #113137.

Pull Request: https://projects.blender.org/blender/blender/pulls/138231
2025-05-29 19:08:32 +02:00

89 lines
2.8 KiB
C++

/* SPDX-FileCopyrightText: 2004 Blender Authors
*
* SPDX-License-Identifier: GPL-2.0-or-later */
#pragma once
/** \file
* \ingroup sequencer
*/
#include <cstddef>
struct ListBase;
struct Main;
struct MovieClip;
struct ReportList;
struct Scene;
struct Strip;
namespace blender::seq {
/**
* Check if one strip is input to the other.
*/
bool relation_is_effect_of_strip(const Strip *effect, const Strip *input);
/**
* Function to free imbuf and anim data on changes.
*/
void relations_strip_free_anim(Strip *strip);
bool relations_check_scene_recursion(Scene *scene, ReportList *reports);
/**
* Check if "strip_main" (indirectly) uses strip "strip".
*/
bool relations_render_loop_check(Strip *strip_main, Strip *strip);
void relations_free_imbuf(Scene *scene, ListBase *seqbase, bool for_render);
/**
* Invalidates various caches related to a given strip:
* - Final cached frames over the length of the strip,
* - Intra-frame caches of the current frame,
* - Source/raw caches of the meta strip that contains this strip, if any,
* - Media presence cache of the strip,
* - Rebuilds speed index map if this is a speed effect strip,
* - Tags DEG for strip recalculation,
* - Stops prefetching job, if any.
*/
void relations_invalidate_cache(Scene *scene, Strip *strip);
/**
* Does everything #relations_invalidate_cache does, plus invalidates cached raw source
* images of the strip.
*/
void relations_invalidate_cache_raw(Scene *scene, Strip *strip);
void relations_invalidate_scene_strips(const Main *bmain, const Scene *scene_target);
void relations_invalidate_movieclip_strips(Main *bmain, MovieClip *clip_target);
/**
* Release FFmpeg handles of strips that are not currently displayed to minimize memory usage.
*/
void relations_free_all_anim_ibufs(Scene *scene, int timeline_frame);
/**
* A debug and development function which checks whether strips have unique UIDs.
* Errors will be reported to the console.
*/
void relations_check_uids_unique_and_report(const Scene *scene);
/**
* Generate new UID for the given strip.
*/
void relations_session_uid_generate(Strip *strip);
void cache_cleanup(Scene *scene);
bool is_cache_full(const Scene *scene);
void source_image_cache_iterate(Scene *scene,
void *userdata,
void callback_iter(void *userdata,
const Strip *strip,
int timeline_frame));
void final_image_cache_iterate(Scene *scene,
void *userdata,
void callback_iter(void *userdata, int timeline_frame));
size_t source_image_cache_calc_memory_size(const Scene *scene);
size_t final_image_cache_calc_memory_size(const Scene *scene);
bool exists_in_seqbase(const Strip *strip, const ListBase *seqbase);
} // namespace blender::seq