cache: began base implementation of "shifting" the cache
Should be a fairly important optimization to make.
This commit is contained in:
@@ -61,6 +61,30 @@ bool PlaybackCache::IsFullyValidated() const
|
||||
return invalidated_.isEmpty();
|
||||
}
|
||||
|
||||
void PlaybackCache::Shift(const rational &from, const rational &to)
|
||||
{
|
||||
// An region between `from` and `to` will be inserted or spliced out
|
||||
TimeRangeList ranges_to_shift = invalidated_.Intersects(TimeRange(from, RATIONAL_MAX));
|
||||
|
||||
// Remove everything from the minimum point
|
||||
invalidated_.RemoveTimeRange(TimeRange(qMin(from, to), RATIONAL_MAX));
|
||||
|
||||
// Shift everything in our ranges to shift list
|
||||
//
|
||||
// `diff` is POSITIVE when moving forward -> and NEGATIVE when moving backward <-
|
||||
rational diff = to - from;
|
||||
foreach (const TimeRange& r, ranges_to_shift) {
|
||||
invalidated_.InsertTimeRange(r + diff);
|
||||
}
|
||||
|
||||
ShiftEvent(from, to);
|
||||
|
||||
if (diff > rational()) {
|
||||
// If shifting forward, add this section to the invalidated region
|
||||
Invalidate(TimeRange(from, to));
|
||||
}
|
||||
}
|
||||
|
||||
void PlaybackCache::Validate(const TimeRange &r)
|
||||
{
|
||||
invalidated_.RemoveTimeRange(r);
|
||||
@@ -81,4 +105,8 @@ void PlaybackCache::InvalidateEvent(const TimeRange &)
|
||||
{
|
||||
}
|
||||
|
||||
void PlaybackCache::ShiftEvent(const rational &, const rational &)
|
||||
{
|
||||
}
|
||||
|
||||
OLIVE_NAMESPACE_EXIT
|
||||
|
||||
Reference in New Issue
Block a user