remove shifts, operations, and make caches node-agnostic

This commit is contained in:
itsmattkc
2022-05-16 19:53:38 -07:00
parent 70a4f7e749
commit e0bb31b199
26 changed files with 124 additions and 708 deletions
+11 -38
View File
@@ -43,40 +43,16 @@ void PlaybackCache::Invalidate(const TimeRange &r, bool signal)
}
}
Node *PlaybackCache::parent() const
{
return dynamic_cast<Node*>(QObject::parent());
}
void PlaybackCache::InvalidateAll()
{
Invalidate(TimeRange(0, RATIONAL_MAX));
}
void PlaybackCache::Shift(rational from, rational to)
{
if (from == to) {
return;
}
// An region between `from` and `to` will be inserted or spliced out
TimeRangeList ranges_to_shift = validated_.Intersects(TimeRange(from, RATIONAL_MAX));
// Remove all ranges starting at to
validated_.remove(TimeRange(qMin(from, to), RATIONAL_MAX));
// Restore ranges shifted
rational diff = to - from;
foreach (const TimeRange& r, ranges_to_shift) {
validated_.insert(r + diff);
}
// Tell derivatives that a shift has occurred
ShiftEvent(from, to);
// Emit signals
emit Shifted(from, to);
if (diff > 0) {
//emit Invalidated(TimeRange(from, to));
}
}
void PlaybackCache::Validate(const TimeRange &r, bool signal)
{
validated_.insert(r);
@@ -90,15 +66,17 @@ void PlaybackCache::InvalidateEvent(const TimeRange &)
{
}
void PlaybackCache::ShiftEvent(const rational &, const rational &)
{
}
Project *PlaybackCache::GetProject() const
{
return Project::GetProjectFromObject(this);
}
PlaybackCache::PlaybackCache(QObject *parent) :
QObject(parent)
{
uuid_ = QUuid::createUuid();
}
TimeRangeList PlaybackCache::GetInvalidatedRanges(TimeRange intersecting)
{
TimeRangeList invalidated;
@@ -133,9 +111,4 @@ QString PlaybackCache::GetCacheDirectory() const
}
}
ViewerOutput *PlaybackCache::viewer_parent() const
{
return dynamic_cast<ViewerOutput*>(parent());
}
}