VSE: Make cache overlay visible to non "Developer extras" users #119428

Merged
Sebastian Parborg merged 2 commits from ZedDB/blender:vse_cache_overlay into main 2024-05-02 16:36:21 +02:00
16 changed files with 214 additions and 102 deletions

View File

@ -320,6 +320,7 @@ class SEQUENCER_PT_sequencer_overlay(Panel):
layout.prop(overlay_settings, "show_strip_retiming", text="Retiming")
layout.prop(overlay_settings, "show_thumbnails", text="Thumbnails")
layout.prop(overlay_settings, "show_grid", text="Grid")
layout.prop(st.cache_overlay, "show_cache", text="Cache")
layout.separator()
@ -329,25 +330,6 @@ class SEQUENCER_PT_sequencer_overlay(Panel):
layout.row().prop(overlay_settings, "waveform_display_style", expand=True)
class SEQUENCER_MT_view_cache(Menu):
bl_label = "Cache"
def draw(self, context):
layout = self.layout
ed = context.scene.sequence_editor
layout.prop(ed, "show_cache")
layout.separator()
col = layout.column()
col.enabled = ed.show_cache
col.prop(ed, "show_cache_final_out")
col.prop(ed, "show_cache_raw")
col.prop(ed, "show_cache_preprocessed")
col.prop(ed, "show_cache_composite")
class SEQUENCER_MT_range(Menu):
bl_label = "Range"
@ -481,10 +463,6 @@ class SEQUENCER_MT_view(Menu):
layout.menu("SEQUENCER_MT_range")
layout.separator()
if context.preferences.view.show_developer_ui:
layout.menu("SEQUENCER_MT_view_cache", text="Cache")
layout.separator()
layout.operator("render.opengl", text="Sequence Render Image", icon='RENDER_STILL').sequencer = True
props = layout.operator("render.opengl", text="Sequence Render Animation", icon='RENDER_ANIMATION')
props.animation = True
@ -2287,8 +2265,7 @@ class SEQUENCER_PT_cache_settings(SequencerButtonsPanel, Panel):
@classmethod
def poll(cls, context):
show_developer_ui = context.preferences.view.show_developer_ui
return cls.has_sequencer(context) and context.scene.sequence_editor and show_developer_ui
return cls.has_sequencer(context) and context.scene.sequence_editor
def draw(self, context):
layout = self.layout
@ -2305,6 +2282,38 @@ class SEQUENCER_PT_cache_settings(SequencerButtonsPanel, Panel):
col.prop(ed, "use_cache_final", text="Final")
class SEQUENCER_PT_cache_view_settings(SequencerButtonsPanel, Panel):
bl_label = "Display"
bl_category = "Cache"
bl_parent_id = "SEQUENCER_PT_cache_settings"
@classmethod
def poll(cls, context):
return cls.has_sequencer(context) and context.scene.sequence_editor
def draw_header(self, context):
cache_settings = context.space_data.cache_overlay
self.layout.prop(cache_settings, "show_cache", text="")
def draw(self, context):
layout = self.layout
layout.use_property_split = True
layout.use_property_decorate = False
cache_settings = context.space_data.cache_overlay
layout.active = cache_settings.show_cache
col = layout.column(heading="Cache", align=True)
show_developer_ui = context.preferences.view.show_developer_ui
if show_developer_ui:
col.prop(cache_settings, "show_cache_raw", text="Raw")
col.prop(cache_settings, "show_cache_preprocessed", text="Preprocessed")
col.prop(cache_settings, "show_cache_composite", text="Composite")
col.prop(cache_settings, "show_cache_final_out", text="Final")
class SEQUENCER_PT_proxy_settings(SequencerButtonsPanel, Panel):
bl_label = "Proxy Settings"
bl_category = "Proxy"
@ -2791,7 +2800,6 @@ classes = (
SEQUENCER_MT_editor_menus,
SEQUENCER_MT_range,
SEQUENCER_MT_view,
SEQUENCER_MT_view_cache,
SEQUENCER_MT_preview_zoom,
SEQUENCER_MT_proxy,
SEQUENCER_MT_select_handle,
@ -2854,6 +2862,7 @@ classes = (
SEQUENCER_PT_modifiers,
SEQUENCER_PT_cache_settings,
SEQUENCER_PT_cache_view_settings,
SEQUENCER_PT_strip_cache,
SEQUENCER_PT_proxy_settings,
SEQUENCER_PT_strip_proxy,

View File

@ -29,7 +29,7 @@ extern "C" {
/* Blender file format version. */
#define BLENDER_FILE_VERSION BLENDER_VERSION
#define BLENDER_FILE_SUBVERSION 26
#define BLENDER_FILE_SUBVERSION 27
/* Minimum Blender version that supports reading file written with the current
* version. Older Blender versions will test this and cancel loading the file, showing a warning to

View File

@ -2987,8 +2987,6 @@ static void do_versions_seq_unique_name_all_strips(Scene *sce, ListBase *seqbase
static void do_versions_seq_set_cache_defaults(Editing *ed)
{
ed->cache_flag = SEQ_CACHE_STORE_FINAL_OUT;
ed->cache_flag |= SEQ_CACHE_VIEW_FINAL_OUT;
ed->cache_flag |= SEQ_CACHE_VIEW_ENABLE;
ed->recycle_max_cost = 10.0f;
}

View File

@ -3328,6 +3328,25 @@ void blo_do_versions_400(FileData *fd, Library * /*lib*/, Main *bmain)
}
}
if (!MAIN_VERSION_FILE_ATLEAST(bmain, 402, 27)) {
LISTBASE_FOREACH (Scene *, scene, &bmain->scenes) {
if (scene->ed != nullptr) {
scene->ed->cache_flag &= ~(SEQ_CACHE_UNUSED_5 | SEQ_CACHE_UNUSED_6 | SEQ_CACHE_UNUSED_7 |
SEQ_CACHE_UNUSED_8 | SEQ_CACHE_UNUSED_9);
}
}
LISTBASE_FOREACH (bScreen *, screen, &bmain->screens) {
LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) {
if (sl->spacetype == SPACE_SEQ) {
SpaceSeq *sseq = (SpaceSeq *)sl;
sseq->cache_overlay.flag |= SEQ_CACHE_SHOW_FINAL_OUT;
}
}
}
}
}
/**
* Always bump subversion in BKE_blender_version.h when adding versioning
* code here, and wrap it inside a MAIN_VERSION_FILE_ATLEAST check.

View File

@ -171,6 +171,7 @@ static void blo_update_defaults_screen(bScreen *screen,
SEQ_TIMELINE_SHOW_STRIP_COLOR_TAG |
SEQ_TIMELINE_SHOW_STRIP_RETIMING | SEQ_TIMELINE_ALL_WAVEFORMS;
seq->preview_overlay.flag |= SEQ_PREVIEW_SHOW_OUTLINE_SELECTED;
seq->cache_overlay.flag = SEQ_CACHE_SHOW | SEQ_CACHE_SHOW_FINAL_OUT;
}
else if (area->spacetype == SPACE_TEXT) {
/* Show syntax and line numbers in Script workspace text editor. */

View File

@ -290,7 +290,7 @@ void sequencer_draw_maskedit(const bContext *C, Scene *scene, ARegion *region, S
/* Force redraw, when prefetching and using cache view. */
static void seq_prefetch_wm_notify(const bContext *C, Scene *scene)
{
if (SEQ_prefetch_need_redraw(CTX_data_main(C), scene)) {
if (SEQ_prefetch_need_redraw(C, scene)) {
WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, nullptr);
}
}

View File

@ -1488,7 +1488,7 @@ static void draw_seq_solo_highlight(TimelineDrawContext *timeline_ctx,
/* Force redraw, when prefetching and using cache view. */
static void seq_prefetch_wm_notify(const bContext *C, Scene *scene)
{
if (SEQ_prefetch_need_redraw(CTX_data_main(C), scene)) {
if (SEQ_prefetch_need_redraw(C, scene)) {
WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, nullptr);
}
}
@ -1734,43 +1734,56 @@ static bool draw_cache_view_iter_fn(void *userdata,
using blender::uchar4;
CacheDrawData *drawdata = static_cast<CacheDrawData *>(userdata);
const View2D *v2d = drawdata->v2d;
float stripe_bot;
float stripe_top, stripe_bot;
const uchar4 col_final{255, 102, 51, 100};
/* NOTE: Final color is the same as the movie clip cache color.
* See ED_region_cache_draw_cached_segments.
*/
const uchar4 col_final{108, 108, 210, 255};
const uchar4 col_raw{255, 25, 5, 100};
const uchar4 col_preproc{25, 25, 191, 100};
const uchar4 col_composite{255, 153, 0, 100};
uchar4 col{0, 0, 0, 0};
bool dev_ui = (U.flag & USER_DEVELOPER_UI);
if ((cache_type & SEQ_CACHE_STORE_FINAL_OUT) &&
(drawdata->cache_flag & SEQ_CACHE_VIEW_FINAL_OUT))
(drawdata->cache_flag & SEQ_CACHE_SHOW_FINAL_OUT))
{
stripe_bot = UI_view2d_region_to_view_y(v2d, V2D_SCROLL_HANDLE_HEIGHT);
/* Draw the final cache on top of the timeline */
stripe_top = v2d->cur.ymax - (UI_TIME_SCRUB_MARGIN_Y / UI_view2d_scale_get_y(v2d));
stripe_bot = stripe_top - (UI_TIME_SCRUB_MARGIN_Y / UI_view2d_scale_get_y(v2d)) / 6.0f;
col = col_final;
}
else if ((cache_type & SEQ_CACHE_STORE_RAW) && (drawdata->cache_flag & SEQ_CACHE_VIEW_RAW)) {
stripe_bot = seq->machine + SEQ_STRIP_OFSBOTTOM + drawdata->stripe_ofs_y;
col = col_raw;
}
else if ((cache_type & SEQ_CACHE_STORE_PREPROCESSED) &&
(drawdata->cache_flag & SEQ_CACHE_VIEW_PREPROCESSED))
{
stripe_bot = seq->machine + SEQ_STRIP_OFSBOTTOM + drawdata->stripe_ht +
drawdata->stripe_ofs_y * 2;
col = col_preproc;
}
else if ((cache_type & SEQ_CACHE_STORE_COMPOSITE) &&
(drawdata->cache_flag & SEQ_CACHE_VIEW_COMPOSITE))
{
stripe_bot = seq->machine + SEQ_STRIP_OFSTOP - drawdata->stripe_ofs_y - drawdata->stripe_ht;
col = col_composite;
}
else {
return false;
if (!dev_ui) {
/* Don't show these cache types below unless developer extras is on. */
return false;
}
if ((cache_type & SEQ_CACHE_STORE_RAW) && (drawdata->cache_flag & SEQ_CACHE_SHOW_RAW)) {
stripe_bot = seq->machine + SEQ_STRIP_OFSBOTTOM + drawdata->stripe_ofs_y;
col = col_raw;
}
else if ((cache_type & SEQ_CACHE_STORE_PREPROCESSED) &&
(drawdata->cache_flag & SEQ_CACHE_SHOW_PREPROCESSED))
{
stripe_bot = seq->machine + SEQ_STRIP_OFSBOTTOM + drawdata->stripe_ht +
drawdata->stripe_ofs_y * 2;
col = col_preproc;
}
else if ((cache_type & SEQ_CACHE_STORE_COMPOSITE) &&
(drawdata->cache_flag & SEQ_CACHE_SHOW_COMPOSITE))
{
stripe_bot = seq->machine + SEQ_STRIP_OFSTOP - drawdata->stripe_ofs_y - drawdata->stripe_ht;
col = col_composite;
}
else {
return false;
}
stripe_top = stripe_bot + drawdata->stripe_ht;
}
float stripe_top = stripe_bot + drawdata->stripe_ht;
drawdata->quads->add_quad(timeline_frame, stripe_bot, timeline_frame + 1, stripe_top, col);
return false;
@ -1795,18 +1808,30 @@ static void draw_cache_background(const bContext *C, CacheDrawData *draw_data)
using blender::uchar4;
const Scene *scene = CTX_data_scene(C);
const View2D *v2d = UI_view2d_fromcontext(C);
const SpaceSeq *sseq = CTX_wm_space_seq(C);
const uchar4 bg_final{255, 102, 51, 25};
/* NOTE: Final bg color is the same as the movie clip cache color.
* See ED_region_cache_draw_background.
*/
const uchar4 bg_final{78, 78, 145, 255};
const uchar4 bg_raw{255, 25, 5, 25};
const uchar4 bg_preproc{25, 25, 191, 25};
const uchar4 bg_composite{255, 153, 0, 25};
float stripe_bot;
if (scene->ed->cache_flag & SEQ_CACHE_VIEW_FINAL_OUT) {
stripe_bot = UI_view2d_region_to_view_y(v2d, V2D_SCROLL_HANDLE_HEIGHT);
bool dev_ui = (U.flag & USER_DEVELOPER_UI);
draw_data->quads->add_quad(
scene->r.sfra, stripe_bot, scene->r.efra, stripe_bot + draw_data->stripe_ht, bg_final);
if (sseq->cache_overlay.flag & SEQ_CACHE_SHOW_FINAL_OUT) {
/* Draw the final cache on top of the timeline */
float stripe_top = v2d->cur.ymax - (UI_TIME_SCRUB_MARGIN_Y / UI_view2d_scale_get_y(v2d));
stripe_bot = stripe_top - (UI_TIME_SCRUB_MARGIN_Y / UI_view2d_scale_get_y(v2d)) / 6.0f;
draw_data->quads->add_quad(scene->r.sfra, stripe_bot, scene->r.efra, stripe_top, bg_final);
}
if (!dev_ui) {
/* Don't show these cache types below unless developer extras is on. */
return;
}
blender::Vector<Sequence *> strips = sequencer_visible_strips_get(C);
@ -1814,17 +1839,17 @@ static void draw_cache_background(const bContext *C, CacheDrawData *draw_data)
for (const Sequence *seq : strips) {
stripe_bot = seq->machine + SEQ_STRIP_OFSBOTTOM + draw_data->stripe_ofs_y;
if (scene->ed->cache_flag & SEQ_CACHE_VIEW_RAW) {
if (sseq->cache_overlay.flag & SEQ_CACHE_SHOW_RAW) {
draw_cache_stripe(scene, seq, *draw_data->quads, stripe_bot, draw_data->stripe_ht, bg_raw);
}
if (scene->ed->cache_flag & SEQ_CACHE_VIEW_PREPROCESSED) {
if (sseq->cache_overlay.flag & SEQ_CACHE_SHOW_PREPROCESSED) {
stripe_bot += draw_data->stripe_ht + draw_data->stripe_ofs_y;
draw_cache_stripe(
scene, seq, *draw_data->quads, stripe_bot, draw_data->stripe_ht, bg_preproc);
}
if (scene->ed->cache_flag & SEQ_CACHE_VIEW_COMPOSITE) {
if (sseq->cache_overlay.flag & SEQ_CACHE_SHOW_COMPOSITE) {
stripe_bot = seq->machine + SEQ_STRIP_OFSTOP - draw_data->stripe_ofs_y -
draw_data->stripe_ht;
draw_cache_stripe(
@ -1837,8 +1862,9 @@ static void draw_cache_view(const bContext *C)
{
Scene *scene = CTX_data_scene(C);
const View2D *v2d = UI_view2d_fromcontext(C);
const SpaceSeq *sseq = CTX_wm_space_seq(C);
if ((scene->ed->cache_flag & SEQ_CACHE_VIEW_ENABLE) == 0) {
if ((sseq->flag & SEQ_SHOW_OVERLAY) == 0 || (sseq->cache_overlay.flag & SEQ_CACHE_SHOW) == 0) {
return;
}
@ -1854,7 +1880,7 @@ static void draw_cache_view(const bContext *C)
userdata.v2d = v2d;
userdata.stripe_ofs_y = stripe_ofs_y;
userdata.stripe_ht = stripe_ht;
userdata.cache_flag = scene->ed->cache_flag;
userdata.cache_flag = sseq->cache_overlay.flag;
userdata.quads = &quads;
GPU_blend(GPU_BLEND_ALPHA);

View File

@ -102,6 +102,7 @@ static SpaceLink *sequencer_create(const ScrArea * /*area*/, const Scene *scene)
SEQ_TIMELINE_SHOW_STRIP_DURATION | SEQ_TIMELINE_SHOW_GRID |
SEQ_TIMELINE_SHOW_FCURVES | SEQ_TIMELINE_SHOW_STRIP_COLOR_TAG |
SEQ_TIMELINE_SHOW_STRIP_RETIMING | SEQ_TIMELINE_ALL_WAVEFORMS;
sseq->cache_overlay.flag = SEQ_CACHE_SHOW | SEQ_CACHE_SHOW_FINAL_OUT;
/* Header. */
region = MEM_cnew<ARegion>("header for sequencer");

View File

@ -823,12 +823,11 @@ enum {
SEQ_CACHE_OVERRIDE = (1 << 4),
/* enable cache visualization overlay in timeline UI */
SEQ_CACHE_VIEW_ENABLE = (1 << 5),
SEQ_CACHE_VIEW_RAW = (1 << 6),
SEQ_CACHE_VIEW_PREPROCESSED = (1 << 7),
SEQ_CACHE_VIEW_COMPOSITE = (1 << 8),
SEQ_CACHE_VIEW_FINAL_OUT = (1 << 9),
SEQ_CACHE_UNUSED_5 = (1 << 5),
ZedDB marked this conversation as resolved Outdated

For those it works better to clear the flag now and rename them to SEQ_CACHE_UNUSED_{5,6,7,8,9}. See, for example, WO_MODE_UNUSED_1 = 1 << 1, /* cleared */.

For those it works better to clear the flag now and rename them to `SEQ_CACHE_UNUSED_{5,6,7,8,9}`. See, for example, `WO_MODE_UNUSED_1 = 1 << 1, /* cleared */`.

No need to refer to something that was there in the code, but not any more. The comments are about the current state of the code.

No need to refer to something that was there in the code, but not any more. The comments are about the current state of the code.
SEQ_CACHE_UNUSED_6 = (1 << 6),
SEQ_CACHE_UNUSED_7 = (1 << 7),
SEQ_CACHE_UNUSED_8 = (1 << 8),
SEQ_CACHE_UNUSED_9 = (1 << 9),
SEQ_CACHE_PREFETCH_ENABLE = (1 << 10),
SEQ_CACHE_DISK_CACHE_ENABLE = (1 << 11),

View File

@ -646,6 +646,20 @@ typedef enum eSpaceSeq_SequencerTimelineOverlay_Flag {
SEQ_TIMELINE_SHOW_GRID = (1 << 18),
} eSpaceSeq_SequencerTimelineOverlay_Flag;
typedef struct SequencerCacheOverlay {
ZedDB marked this conversation as resolved Outdated

Not sure if it is necessary to make new struct for this. Functionally and semantically it would be just as fine under SequencerTimelineOverlay.

Not sure if it is necessary to make new struct for this. Functionally and semantically it would be just as fine under `SequencerTimelineOverlay`.

I made a new entry as the SEQ_TIMELINE_ flags would only have 8 entries left before it would be full. I think this might also make it more organized if we for what ever reason need to add more cache options in to future.

Do you have any strong opinions about this?

I made a new entry as the `SEQ_TIMELINE_` flags would only have 8 entries left before it would be full. I think this might also make it more organized if we for what ever reason need to add more cache options in to future. Do you have any strong opinions about this?

Not really a strong opinion. But bits 10-13 are free, SEQ_CACHE_SHOW_FINAL_OUT could be implied by SEQ_CACHE_SHOW. so this is squeezable :) I would do it...

Not really a strong opinion. But bits 10-13 are free, `SEQ_CACHE_SHOW_FINAL_OUT` could be implied by `SEQ_CACHE_SHOW`. so this is squeezable :) I would do it...

Ehh... I don't really like to try to squeeze things into other places if it is easy to just do a clean struct that has a clear category and intent. Especially because this area might change a bit in the future.

Ehh... I don't really like to try to squeeze things into other places if it is easy to just do a clean struct that has a clear category and intent. Especially because this area might change a bit in the future.

It is possible to share this cache by multiple copies of object before first change?

It is possible to share this cache by multiple copies of object before first change?
int flag;
char _pad0[4];
} SequencerCacheOverlay;
/** #SequencerCacheOverlay.flag */
typedef enum eSpaceSeq_SequencerCacheOverlay_Flag {
SEQ_CACHE_SHOW = (1 << 1),
SEQ_CACHE_SHOW_RAW = (1 << 2),
SEQ_CACHE_SHOW_PREPROCESSED = (1 << 3),
SEQ_CACHE_SHOW_COMPOSITE = (1 << 4),
SEQ_CACHE_SHOW_FINAL_OUT = (1 << 5),
} eSpaceSeq_SequencerCacheOverlay_Flag;
/** Sequencer. */
typedef struct SpaceSeq {
SpaceLink *next, *prev;
@ -686,6 +700,7 @@ typedef struct SpaceSeq {
struct SequencerPreviewOverlay preview_overlay;
struct SequencerTimelineOverlay timeline_overlay;
struct SequencerCacheOverlay cache_overlay;
/** Multi-view current eye - for internal use. */
char multiview_eye;

View File

@ -2501,31 +2501,6 @@ static void rna_def_editor(BlenderRNA *brna)
/* cache flags */
prop = RNA_def_property(srna, "show_cache", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, nullptr, "cache_flag", SEQ_CACHE_VIEW_ENABLE);
RNA_def_property_ui_text(prop, "Show Cache", "Visualize cached images on the timeline");
RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, nullptr);
prop = RNA_def_property(srna, "show_cache_final_out", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, nullptr, "cache_flag", SEQ_CACHE_VIEW_FINAL_OUT);
RNA_def_property_ui_text(prop, "Final Images", "Visualize cached complete frames");
RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, nullptr);
prop = RNA_def_property(srna, "show_cache_raw", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, nullptr, "cache_flag", SEQ_CACHE_VIEW_RAW);
RNA_def_property_ui_text(prop, "Raw Images", "Visualize cached raw images");
RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, nullptr);
prop = RNA_def_property(srna, "show_cache_preprocessed", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, nullptr, "cache_flag", SEQ_CACHE_VIEW_PREPROCESSED);
RNA_def_property_ui_text(prop, "Preprocessed Images", "Visualize cached pre-processed images");
RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, nullptr);
prop = RNA_def_property(srna, "show_cache_composite", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, nullptr, "cache_flag", SEQ_CACHE_VIEW_COMPOSITE);
RNA_def_property_ui_text(prop, "Composite Images", "Visualize cached composite images");
RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, nullptr);
prop = RNA_def_property(srna, "use_cache_raw", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, nullptr, "cache_flag", SEQ_CACHE_STORE_RAW);
RNA_def_property_ui_text(prop,

View File

@ -2512,6 +2512,11 @@ static std::optional<std::string> rna_SpaceSequencerTimelineOverlay_path(
return "timeline_overlay";
}
static std::optional<std::string> rna_SpaceSequencerCacheOverlay_path(const PointerRNA * /*ptr*/)
{
return "cache_overlay";
}
static float rna_SpaceSequenceEditor_zoom_percentage_get(PointerRNA *ptr)
{
ScrArea *area = rna_area_from_space(ptr);
@ -5958,6 +5963,43 @@ static void rna_def_space_sequencer_timeline_overlay(BlenderRNA *brna)
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_SEQUENCER, nullptr);
}
static void rna_def_space_sequencer_cache_overlay(BlenderRNA *brna)
{
StructRNA *srna;
PropertyRNA *prop;
srna = RNA_def_struct(brna, "SequencerCacheOverlay", nullptr);
RNA_def_struct_sdna(srna, "SequencerCacheOverlay");
RNA_def_struct_nested(brna, srna, "SpaceSequenceEditor");
RNA_def_struct_path_func(srna, "rna_SpaceSequencerCacheOverlay_path");
RNA_def_struct_ui_text(srna, "Cache Overlay Settings", "");
prop = RNA_def_property(srna, "show_cache", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, nullptr, "flag", SEQ_CACHE_SHOW);
RNA_def_property_ui_text(prop, "Show Cache", "Visualize cached images on the timeline");
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_SEQUENCER, nullptr);
prop = RNA_def_property(srna, "show_cache_final_out", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, nullptr, "flag", SEQ_CACHE_SHOW_FINAL_OUT);
RNA_def_property_ui_text(prop, "Final Images", "Visualize cached complete frames");
RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, nullptr);
prop = RNA_def_property(srna, "show_cache_raw", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, nullptr, "flag", SEQ_CACHE_SHOW_RAW);
RNA_def_property_ui_text(prop, "Raw Images", "Visualize cached raw images");
RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, nullptr);
prop = RNA_def_property(srna, "show_cache_preprocessed", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, nullptr, "flag", SEQ_CACHE_SHOW_PREPROCESSED);
RNA_def_property_ui_text(prop, "Preprocessed Images", "Visualize cached pre-processed images");
RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, nullptr);
prop = RNA_def_property(srna, "show_cache_composite", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, nullptr, "flag", SEQ_CACHE_SHOW_COMPOSITE);
RNA_def_property_ui_text(prop, "Composite Images", "Visualize cached composite images");
RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, nullptr);
}
static void rna_def_space_sequencer(BlenderRNA *brna)
{
StructRNA *srna;
@ -6164,8 +6206,14 @@ static void rna_def_space_sequencer(BlenderRNA *brna)
RNA_def_property_pointer_sdna(prop, nullptr, "timeline_overlay");
RNA_def_property_ui_text(prop, "Timeline Overlay Settings", "Settings for display of overlays");
prop = RNA_def_property(srna, "cache_overlay", PROP_POINTER, PROP_NONE);
RNA_def_property_flag(prop, PROP_NEVER_NULL);
RNA_def_property_struct_type(prop, "SequencerCacheOverlay");
RNA_def_property_pointer_sdna(prop, nullptr, "cache_overlay");
RNA_def_property_ui_text(prop, "Cache Overlay Settings", "Settings for display of overlays");
rna_def_space_sequencer_preview_overlay(brna);
rna_def_space_sequencer_timeline_overlay(brna);
rna_def_space_sequencer_cache_overlay(brna);
/* transform */
prop = RNA_def_property(srna, "cursor_location", PROP_FLOAT, PROP_XYZ);

View File

@ -8,7 +8,7 @@
* \ingroup sequencer
*/
struct Main;
struct bContext;
struct Scene;
void SEQ_prefetch_stop_all();
@ -17,4 +17,4 @@ void SEQ_prefetch_stop_all();
* This function should almost always be called by cache invalidation, not directly.
*/
void SEQ_prefetch_stop(Scene *scene);
bool SEQ_prefetch_need_redraw(Main *bmain, Scene *scene);
bool SEQ_prefetch_need_redraw(const bContext *C, Scene *scene);

View File

@ -919,8 +919,24 @@ void SEQ_cache_iterate(
SeqCacheKey *key = static_cast<SeqCacheKey *>(BLI_ghashIterator_getKey(&gh_iter));
BLI_ghashIterator_step(&gh_iter);
BLI_assert(key->cache_owner == cache);
int timeline_frame;
if (key->type & SEQ_CACHE_STORE_FINAL_OUT) {
timeline_frame = key->timeline_frame;
}
else {
/* This is not a final cache image. The cached frame is relative to where the strip is
* currently and where it was when it was cached. We can't use the timeline_frame, we need to
* derive the timeline frame from key->frame_index.
*
* NOTE This will not work for RAW caches if they have retiming, strobing, or different
* playback rate than the scene. Because it would take quite a bit of effort to properly
* convert RAW frames like that to a timeline frame, we skip doing this as visualizing these
* are a developer option that not many people will see.
*/
timeline_frame = key->frame_index + SEQ_time_start_frame_get(key->seq);
}
interrupt = callback_iter(userdata, key->seq, key->timeline_frame, key->type);
interrupt = callback_iter(userdata, key->seq, timeline_frame, key->type);
}
cache->last_key = nullptr;

View File

@ -15,6 +15,7 @@
#include "DNA_scene_types.h"
#include "DNA_screen_types.h"
#include "DNA_sequence_types.h"
#include "DNA_space_types.h"
#include "BLI_listbase.h"
#include "BLI_threads.h"
@ -24,6 +25,7 @@
#include "BKE_anim_data.hh"
#include "BKE_animsys.h"
#include "BKE_context.hh"
#include "BKE_global.hh"
#include "BKE_layer.hh"
#include "BKE_main.hh"
@ -587,15 +589,19 @@ void seq_prefetch_start(const SeqRenderData *context, float timeline_frame)
}
}
bool SEQ_prefetch_need_redraw(Main *bmain, Scene *scene)
bool SEQ_prefetch_need_redraw(const bContext *C, Scene *scene)
{
Main *bmain = CTX_data_main(C);
bool playing = seq_prefetch_is_playing(bmain);
bool scrubbing = seq_prefetch_is_scrubbing(bmain);
bool running = seq_prefetch_job_is_running(scene);
bool suspended = seq_prefetch_job_is_waiting(scene);
SpaceSeq *sseq = CTX_wm_space_seq(C);
bool showing_cache = sseq->cache_overlay.flag & SEQ_CACHE_SHOW;
/* force redraw, when prefetching and using cache view. */
if (running && !playing && !suspended && scene->ed->cache_flag & SEQ_CACHE_VIEW_ENABLE) {
if (running && !playing && !suspended && showing_cache) {
return true;
}
/* Sometimes scrubbing flag is set when not scrubbing. In that case I want to catch "event" of

View File

@ -265,8 +265,7 @@ Editing *SEQ_editing_ensure(Scene *scene)
ed = scene->ed = static_cast<Editing *>(MEM_callocN(sizeof(Editing), "addseq"));
ed->seqbasep = &ed->seqbase;
ed->cache = nullptr;
ed->cache_flag = SEQ_CACHE_STORE_FINAL_OUT;
ed->cache_flag |= SEQ_CACHE_STORE_RAW;
ed->cache_flag = (SEQ_CACHE_STORE_FINAL_OUT | SEQ_CACHE_STORE_RAW);
ed->show_missing_media_flag = SEQ_EDIT_SHOW_MISSING_MEDIA;
ed->displayed_channels = &ed->channels;
SEQ_channels_ensure(ed->displayed_channels);