Move prepared-file work into app runtime

This commit is contained in:
2026-06-16 08:24:19 +02:00
parent 640ebc4be4
commit 3e4eb89499
9 changed files with 162 additions and 110 deletions

View File

@@ -643,6 +643,29 @@ void App::rec_export(std::string path)
namespace
{
template <typename CanvasDocument>
struct RecordingWorkerIterationContext
{
Canvas* legacy_canvas = nullptr;
CanvasDocument* canvas_document = nullptr;
CanvasEncoder* encoder = nullptr;
pp::app::RecordingWorkerIterationPlan plan{};
};
template <typename CanvasDocument>
RecordingWorkerIterationContext<CanvasDocument> make_recording_worker_iteration_context(App& app)
{
RecordingWorkerIterationContext<CanvasDocument> context;
context.legacy_canvas = Canvas::I;
context.canvas_document = app.canvas ? app.canvas->m_canvas.get() : nullptr;
context.encoder = context.legacy_canvas ? context.legacy_canvas->m_encoder.get() : nullptr;
context.plan = pp::app::plan_recording_worker_iteration(
app.rec_running,
context.encoder != nullptr,
context.legacy_canvas != nullptr && context.canvas_document != nullptr);
return context;
}
template <typename CanvasDocument>
void encode_recording_frame(
App& app,
@@ -676,18 +699,12 @@ void App::rec_loop()
{
std::unique_lock<std::mutex> lock(rec_mutex);
rec_cv.wait(lock/*, [this] { return !(rec_frames.empty() && rec_running); }*/);
auto* legacy_canvas = Canvas::I;
auto* canvas_document = canvas ? canvas->m_canvas.get() : nullptr;
auto* encoder = legacy_canvas ? legacy_canvas->m_encoder.get() : nullptr;
const auto plan = pp::app::plan_recording_worker_iteration(
rec_running,
encoder != nullptr,
legacy_canvas != nullptr && canvas_document != nullptr);
if (!plan.continue_running)
const auto iteration = make_recording_worker_iteration_context<CanvasDocument>(*this);
if (!iteration.plan.continue_running)
break;
if (plan.encode_frame && legacy_canvas && canvas_document && encoder)
encode_recording_frame(*this, plan, legacy_canvas, canvas_document, encoder);
if (iteration.plan.encode_frame && iteration.legacy_canvas && iteration.canvas_document && iteration.encoder)
encode_recording_frame(*this, iteration.plan, iteration.legacy_canvas, iteration.canvas_document, iteration.encoder);
}
}