timeline: heavily optimized and improved nearly all timeline optimizations

Features a lot of timeline-related cache optimizations as well as general
optimizations and improvements in timeline behavior. Should improve
usability significantly.
This commit is contained in:
itsmattkc
2020-06-01 04:42:59 +10:00
parent 93f8b4f79c
commit c2e47a296c
35 changed files with 1496 additions and 939 deletions
@@ -96,29 +96,11 @@ void TimelineViewBlockItem::paint(QPainter *painter, const QStyleOptionGraphicsI
}
// Draw waveform if one is available
QString wave_fn = QDir(QDir(Config::Current()["DiskCachePath"].toString()).filePath("waveform")).filePath(QString::number(reinterpret_cast<quintptr>(block_)));
QFile wave_file(wave_fn);
if (wave_file.open(QFile::ReadOnly)){
painter->setPen(QColor(64, 64, 64));
QByteArray w = wave_file.readAll();
wave_file.close();
// Read metadata
SampleSummer::Info info;
memcpy(&info, w.data(), sizeof(SampleSummer::Info));
// Prevent divide by zero
if (info.channels) {
AudioWaveformView::DrawWaveform(painter,
rect().toRect(),
this->GetScale(),
reinterpret_cast<const SampleSummer::Sum*>(w.constData() + sizeof(SampleSummer::Info)),
(w.size() - sizeof(SampleSummer::Info)) / sizeof(SampleSummer::Sum),
info.channels);
}
}
painter->setPen(QColor(64, 64, 64));
AudioVisualWaveform::DrawWaveform(painter,
rect().toRect(),
this->GetScale(),
static_cast<ClipBlock*>(block_)->waveform());
painter->setPen(Qt::white);
painter->drawLine(rect().topLeft(), QPointF(rect().right(), rect().top()));