viewer: allow temporarily suspending the auto-cache
While the auto-cache will always default to on, there are cases where the user may not want the viewer to barrel ahead caching something (footage viewer for instance or if the user is making a lot of changes in a short amount of time).
This commit is contained in:
@@ -82,8 +82,7 @@ void Config::SetDefaults()
|
||||
config_map_["DropWithoutSequenceBehavior"] = TimelineWidget::kDWSAsk;
|
||||
config_map_["Loop"] = false;
|
||||
|
||||
config_map_["AutoCache"] = true;
|
||||
config_map_["AutoCacheInterval"] = 1000;
|
||||
config_map_["AutoCacheInterval"] = 250;
|
||||
|
||||
config_map_["NodeCatColor0"] = QVariant::fromValue(Color(0.75f, 0.75f, 0.75f));
|
||||
config_map_["NodeCatColor1"] = QVariant::fromValue(Color(0.25f, 0.25f, 0.25f));
|
||||
|
||||
@@ -29,6 +29,7 @@ FootageViewerPanel::FootageViewerPanel(QWidget *parent) :
|
||||
{
|
||||
// Set ViewerWidget as the central widget
|
||||
FootageViewerWidget* fvw = new FootageViewerWidget();
|
||||
fvw->SetAutoCacheEnabled(false);
|
||||
connect(fvw, &FootageViewerWidget::RequestScopePanel, this, &FootageViewerPanel::CreateScopePanel);
|
||||
SetTimeBasedWidget(fvw);
|
||||
|
||||
|
||||
@@ -58,7 +58,8 @@ ViewerWidget::ViewerWidget(QWidget *parent) :
|
||||
time_changed_from_timer_(false),
|
||||
prequeuing_(false),
|
||||
busy_(false),
|
||||
our_cache_background_task_(nullptr)
|
||||
our_cache_background_task_(nullptr),
|
||||
autocache_(true)
|
||||
{
|
||||
// Set up main layout
|
||||
QVBoxLayout* layout = new QVBoxLayout(this);
|
||||
@@ -114,7 +115,7 @@ ViewerWidget::ViewerWidget(QWidget *parent) :
|
||||
renderer_->SetRenderMode(RenderMode::kOffline);
|
||||
|
||||
// Setup cache wait timer (waits a few seconds of inactivity before caching)
|
||||
cache_wait_timer_.setInterval(250);
|
||||
cache_wait_timer_.setInterval(Config::Current()["AutoCacheInterval"].toInt());
|
||||
cache_wait_timer_.setSingleShot(true);
|
||||
connect(&cache_wait_timer_, &QTimer::timeout, this, &ViewerWidget::StartBackgroundCaching);
|
||||
|
||||
@@ -369,6 +370,18 @@ void ViewerWidget::ForceUpdate()
|
||||
UpdateTextureFromNode(GetTime());
|
||||
}
|
||||
|
||||
void ViewerWidget::SetAutoCacheEnabled(bool e)
|
||||
{
|
||||
autocache_ = e;
|
||||
|
||||
if (autocache_) {
|
||||
StartBackgroundCaching();
|
||||
} else if (cache_background_task_ == our_cache_background_task_) {
|
||||
StopAllBackgroundCacheTasks(false);
|
||||
cache_background_task_ = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void ViewerWidget::SetGizmos(Node *node)
|
||||
{
|
||||
display_widget_->SetTimeTarget(GetConnectedNode());
|
||||
@@ -865,10 +878,10 @@ void ViewerWidget::StartBackgroundCaching()
|
||||
}
|
||||
#endif
|
||||
|
||||
if (GetConnectedNode()
|
||||
if (autocache_
|
||||
&& GetConnectedNode()
|
||||
&& (GetConnectedNode()->video_frame_cache()->HasInvalidatedRanges()
|
||||
|| GetConnectedNode()->audio_playback_cache()->HasInvalidatedRanges())
|
||||
&& Config::Current()["AutoCache"].toBool()) {
|
||||
|| GetConnectedNode()->audio_playback_cache()->HasInvalidatedRanges())) {
|
||||
if (cache_background_task_ || busy_viewers_) {
|
||||
|
||||
// Something else is caching right now, we don't want to do multiple at once so we'll check
|
||||
@@ -987,6 +1000,16 @@ void ViewerWidget::ShowContextMenu(const QPoint &pos)
|
||||
|
||||
menu.addSeparator();
|
||||
|
||||
{
|
||||
// Auto-cache
|
||||
QAction* autocache_action = menu.addAction(tr("Auto-Cache"));
|
||||
autocache_action->setCheckable(true);
|
||||
autocache_action->setChecked(autocache_);
|
||||
connect(autocache_action, &QAction::triggered, this, &ViewerWidget::SetAutoCacheEnabled);
|
||||
}
|
||||
|
||||
menu.addSeparator();
|
||||
|
||||
{
|
||||
// Safe Margins
|
||||
Menu* safe_margin_menu = new Menu(tr("Safe Margins"), &menu);
|
||||
|
||||
@@ -122,6 +122,8 @@ public slots:
|
||||
|
||||
void ForceUpdate();
|
||||
|
||||
void SetAutoCacheEnabled(bool e);
|
||||
|
||||
signals:
|
||||
/**
|
||||
* @brief Wrapper for ViewerGLWidget::CursorColor()
|
||||
@@ -249,6 +251,8 @@ private:
|
||||
|
||||
int prequeue_length_;
|
||||
|
||||
bool autocache_;
|
||||
|
||||
static CacheTask* cache_background_task_;
|
||||
|
||||
static int busy_viewers_;
|
||||
|
||||
Reference in New Issue
Block a user