Files
Mike-Solar 712badbaa7 build/ci: green builds and tests on all three platforms
Compiler hygiene (all platforms):
- Silence warnings across the tree: missing override, -Wreorder ctor
  init, -Wshadow, -Wsign-compare, missing switch cases, unused
  functions/captures, Qt 6.11 deprecations (QMouseEvent/QDropEvent
  accessors, qAsConst, Q_FOREACH over non-shared containers,
  AA_UseHighDpiPixmaps) and the .bak/ backup tree removal.
- Fix regressions from the cleanup: missing clip decls in
  capi/timeline.cpp, plugin.cpp rename fallout, panel setFocus
  ambiguity, QGraphicsItem::pos vs event->position(), duplicate
  k_push_button case, boolean test variable.

Windows:
- Qt portability: CommandLineParser is_set/add_option, QTimeZone
  systemTimeZone (QTimeZone::LocalTime is 6.11-only), k_progress_* enum.
- Linking: stop adding oakengine to OLIVE_LIBRARIES (import lib plus
  oakengine-obj caused multiple definitions); add OAKENGINE_STATIC so
  internal consumers no longer reference __imp_* stubs.
- oakengine.ver: export olive::Renderer typeinfo so liboakgl.so can be
  dlopened (Linux), DynamicRenderer no longer dlcloses backend libraries
  (crash in RenderManager's dtor calling into unmapped memory).
- OTIO runtime: copy DLLs next to every binary on Windows instead of
  relying on PATH (0xc0000135 in gtest discovery).
- Headless GL: the runner only has GDI OpenGL 1.1, killing every render
  worker. Deploy Mesa llvmpipe as opengl32sw.dll (Qt's software-GL
  channel) with QT_OPENGL=software, and let QT_OPENGL override the
  AA_UseDesktopOpenGL default. ExportTask fails fast after 8 consecutive
  undelivered frames instead of segfaulting or grinding forever;
  FFmpegEncoder::write_frame tolerates null frames.
- Tests: GetTempPathA+PID temp dirs, GetLongPathNameA for 8.3 names,
  forward-slash normalization when comparing project filenames.

Linux:
- Install libshaderc-dev so oakvulkan compiles GLSL (Vulkan tests).
- Accept UNORM floor-or-round (63/64) in the blit ping-pong test.
- Skip MainWindow construction test on the offscreen QPA (cannot paint
  QOpenGLWidget).

Also: oak_cli_transcode gets a 300s ctest timeout, worker logs GL
context version and LoadGraph/render_frame stages, and
docs/plans/eliminate-event-bridge-issues.md (English translation).
2026-08-04 21:34:31 +08:00

319 lines
6.9 KiB
C++

/***
Olive - Non-Linear Video Editor
Copyright (C) 2022 Olive Team
Modifications Copyright (C) 2025 mikesolar
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
***/
#include "playbackcache.h"
#include "node/output/viewer/viewer.h"
#include "node/project.h"
#include "node/project/sequence/sequence.h"
#include "render/diskmanager.h"
namespace olive
{
void PlaybackCache::invalidate(const TimeRange &r)
{
if (r.in() == r.out()) {
qWarning() << "Tried to invalidate zero-length range";
return;
}
validated_.remove(r);
if (!passthroughs_.empty()) {
TimeRangeList::util_remove(&passthroughs_, r);
}
InvalidateEvent(r);
emit invalidated(r);
if (saving_enabled_) {
save_state();
}
}
Node *PlaybackCache::parent() const
{
return dynamic_cast<Node *>(QObject::parent());
}
QDir PlaybackCache::get_this_cache_directory() const
{
return get_this_cache_directory(get_cache_directory(), get_uuid());
}
QDir PlaybackCache::get_this_cache_directory(const QString &cache_path,
const QUuid &cache_id)
{
return QDir(cache_path).filePath(cache_id.toString());
}
void PlaybackCache::load_state()
{
QDir cache_dir = get_this_cache_directory();
QFile f(cache_dir.filePath(QStringLiteral("state")));
if (!f.exists()) {
// No state exists, assume nothing valid
validated_.clear();
passthroughs_.clear();
return;
}
qint64 file_time =
f.fileTime(QFileDevice::FileModificationTime).toMSecsSinceEpoch();
if (file_time > last_loaded_state_ && f.open(QFile::ReadOnly)) {
QDataStream s(&f);
uint32_t version;
s >> version;
LoadStateEvent(s);
switch (version) {
case 1: {
int valid_count, pass_count;
s >> valid_count;
for (int i = 0; i < valid_count; i++) {
int in_num, in_den, out_num, out_den;
s >> in_num;
s >> in_den;
s >> out_num;
s >> out_den;
validated_.insert(TimeRange(Rational(in_num, in_den),
Rational(out_num, out_den)));
}
s >> pass_count;
for (int i = 0; i < pass_count; i++) {
QUuid id;
int in_num, in_den, out_num, out_den;
s >> in_num;
s >> in_den;
s >> out_num;
s >> out_den;
s >> id;
Passthrough p = TimeRange(Rational(in_num, in_den),
Rational(out_num, out_den));
p.cache = id;
passthroughs_.push_back(p);
}
break;
}
}
f.close();
last_loaded_state_ = file_time;
}
}
void PlaybackCache::save_state()
{
if (!DiskManager::instance()) {
return;
}
QDir cache_dir = get_this_cache_directory();
QFile f(cache_dir.filePath(QStringLiteral("state")));
if (validated_.isEmpty() && passthroughs_.empty()) {
if (f.exists()) {
f.remove();
}
} else {
if (FileFunctions::directory_is_valid(cache_dir)) {
if (f.open(QFile::WriteOnly)) {
QDataStream s(&f);
uint32_t version = 1;
s << version;
SaveStateEvent(s);
// Using "int" for backwards compatibility with when we used QVector, could potentially overflow
s << int(validated_.size());
for (const TimeRange &r : validated_) {
s << r.in().numerator();
s << r.in().denominator();
s << r.out().numerator();
s << r.out().denominator();
}
// Using "int" for backwards compatibility with when we used QVector, could potentially overflow
s << int(passthroughs_.size());
for (const Passthrough &p : passthroughs_) {
s << p.in().numerator();
s << p.in().denominator();
s << p.out().numerator();
s << p.out().denominator();
s << p.cache;
}
f.close();
last_loaded_state_ =
f.fileTime(QFileDevice::FileModificationTime)
.toMSecsSinceEpoch();
}
}
}
}
void PlaybackCache::draw(QPainter *p, const Rational &start, double scale,
const QRect &rect) const
{
p->fillRect(rect, Qt::red);
for (const TimeRange &range : get_validated_ranges()) {
int range_left = rect.left() + (range.in() - start).to_double() * scale;
if (range_left >= rect.right()) {
continue;
}
int range_right =
rect.left() + (range.out() - start).to_double() * scale;
if (range_right < rect.left()) {
continue;
}
int adjusted_left = std::max(range_left, rect.left());
int adjusted_right = std::min(range_right, rect.right());
p->fillRect(adjusted_left, rect.top(), adjusted_right - adjusted_left,
rect.height(), Qt::green);
}
}
void PlaybackCache::set_passthrough(PlaybackCache *cache)
{
for (const TimeRange &r : cache->get_validated_ranges()) {
Passthrough p = r;
p.cache = cache->get_uuid();
passthroughs_.push_back(p);
}
passthroughs_.insert(passthroughs_.end(), cache->get_passthroughs().begin(),
cache->get_passthroughs().end());
if (saving_enabled_) {
save_state();
}
}
void PlaybackCache::invalidate_all()
{
invalidate(TimeRange(0, RATIONAL_MAX));
}
void PlaybackCache::request(ViewerOutput *context, const TimeRange &r)
{
request_context_ = context;
requested_.insert(r);
emit requested(request_context_, r);
}
void PlaybackCache::validate(const TimeRange &r, bool signal)
{
validated_.insert(r);
if (signal) {
emit validated(r);
}
if (saving_enabled_) {
save_state();
}
}
void PlaybackCache::InvalidateEvent(const TimeRange &)
{
}
Project *PlaybackCache::get_project() const
{
return Project::get_project_from_object(this);
}
PlaybackCache::PlaybackCache(QObject *parent)
: QObject(parent)
, saving_enabled_(true)
, last_loaded_state_(0)
{
uuid_ = QUuid::createUuid();
}
void PlaybackCache::set_uuid(const QUuid &u)
{
uuid_ = u;
load_state();
}
TimeRangeList PlaybackCache::get_invalidated_ranges(TimeRange intersecting) const
{
TimeRangeList invalidated;
// Prevent TimeRange from being below 0, some other behavior in Olive relies on this behavior
// and it seemed reasonable to have safety code in here
intersecting.set_out(qMax(Rational(0), intersecting.out()));
intersecting.set_in(qMax(Rational(0), intersecting.in()));
invalidated.insert(intersecting);
for (const TimeRange &range : validated_) {
invalidated.remove(range);
}
for (const TimeRange &range : passthroughs_) {
invalidated.remove(range);
}
return invalidated;
}
bool PlaybackCache::has_invalidated_ranges(const TimeRange &intersecting) const
{
return !validated_.contains(intersecting);
}
QString PlaybackCache::get_cache_directory() const
{
Project *project = get_project();
if (project) {
return project->cache_path();
} else {
return DiskManager::instance()->get_default_cache_path();
}
}
}