Thin recording bridge and canvas draw seams
This commit is contained in:
72
src/app.cpp
72
src/app.cpp
@@ -211,6 +211,11 @@ void App::initLog()
|
||||
LOG("load preferences failed");
|
||||
}
|
||||
|
||||
namespace pp::panopainter
|
||||
{
|
||||
bool process_legacy_recording_worker_iteration(App& app);
|
||||
}
|
||||
|
||||
bool App::check_license()
|
||||
{
|
||||
return true; // TODO: for distribuiton only
|
||||
@@ -641,78 +646,13 @@ void App::rec_export(std::string path)
|
||||
LOG("Recording export action failed: %s", status.message);
|
||||
}
|
||||
|
||||
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,
|
||||
pp::app::RecordingWorkerIterationPlan const& plan,
|
||||
Canvas* legacy_canvas,
|
||||
CanvasDocument* canvas_document,
|
||||
CanvasEncoder* encoder)
|
||||
{
|
||||
if (plan.clear_dirty_stroke)
|
||||
canvas_document->m_dirty_stroke = false;
|
||||
|
||||
PBO equirect = legacy_canvas->m_layers_merge.gen_equirect_pbo(encoder->frame_size());
|
||||
std::this_thread::yield();
|
||||
|
||||
ImageRef img;
|
||||
img.create(equirect.width, equirect.height, equirect.map());
|
||||
encoder->encode(img);
|
||||
equirect.unmap();
|
||||
LOG("rec frame encoded");
|
||||
|
||||
if (plan.update_frame_label)
|
||||
app.update_rec_frames();
|
||||
}
|
||||
|
||||
template <typename CanvasDocument>
|
||||
bool process_recording_worker_iteration(App& app)
|
||||
{
|
||||
std::unique_lock<std::mutex> lock(app.rec_mutex);
|
||||
app.rec_cv.wait(lock);
|
||||
|
||||
const auto iteration = make_recording_worker_iteration_context<CanvasDocument>(app);
|
||||
if (!iteration.plan.continue_running)
|
||||
return false;
|
||||
|
||||
if (iteration.plan.encode_frame && iteration.legacy_canvas && iteration.canvas_document && iteration.encoder)
|
||||
encode_recording_frame(app, iteration.plan, iteration.legacy_canvas, iteration.canvas_document, iteration.encoder);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
void App::rec_loop()
|
||||
{
|
||||
BT_SetTerminate();
|
||||
rec_running = true;
|
||||
while (rec_running)
|
||||
{
|
||||
if (!process_recording_worker_iteration<CanvasDocument>(*this))
|
||||
if (!pp::panopainter::process_legacy_recording_worker_iteration(*this))
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user