Trim recording loop and retain async worker state
This commit is contained in:
@@ -102,10 +102,21 @@ private:
|
||||
std::jthread worker_;
|
||||
};
|
||||
|
||||
LegacyCanvasAsyncWorker& canvas_async_worker()
|
||||
class RetainedCanvasAsyncWorkerState final {
|
||||
public:
|
||||
void post(std::function<void()> task)
|
||||
{
|
||||
worker_.post(std::move(task));
|
||||
}
|
||||
|
||||
private:
|
||||
LegacyCanvasAsyncWorker worker_;
|
||||
};
|
||||
|
||||
RetainedCanvasAsyncWorkerState& canvas_async_worker_state()
|
||||
{
|
||||
static LegacyCanvasAsyncWorker worker;
|
||||
return worker;
|
||||
static RetainedCanvasAsyncWorkerState state;
|
||||
return state;
|
||||
}
|
||||
|
||||
GLint current_canvas_stroke_internal_format()
|
||||
@@ -2846,7 +2857,7 @@ void Canvas::import_equirectangular(std::string file_path, std::shared_ptr<Layer
|
||||
{
|
||||
if (App::I->check_license())
|
||||
{
|
||||
canvas_async_worker().post([this, file_path = std::move(file_path), layer = std::move(layer)] {
|
||||
canvas_async_worker_state().post([this, file_path = std::move(file_path), layer = std::move(layer)] {
|
||||
BT_SetTerminate();
|
||||
import_equirectangular_thread(file_path, layer);
|
||||
});
|
||||
@@ -2938,7 +2949,7 @@ void Canvas::export_equirectangular(std::string file_path, std::function<void()>
|
||||
{
|
||||
if (App::I->check_license())
|
||||
{
|
||||
canvas_async_worker().post([this, file_path = std::move(file_path), on_complete = std::move(on_complete)]() mutable {
|
||||
canvas_async_worker_state().post([this, file_path = std::move(file_path), on_complete = std::move(on_complete)]() mutable {
|
||||
BT_SetTerminate();
|
||||
export_equirectangular_thread(file_path);
|
||||
if (on_complete)
|
||||
@@ -3024,7 +3035,7 @@ void Canvas::export_depth(std::string file_name, std::function<void()> on_comple
|
||||
{
|
||||
if (App::I->check_license())
|
||||
{
|
||||
canvas_async_worker().post([this, file_name = std::move(file_name), on_complete = std::move(on_complete)]() mutable {
|
||||
canvas_async_worker_state().post([this, file_name = std::move(file_name), on_complete = std::move(on_complete)]() mutable {
|
||||
BT_SetTerminate();
|
||||
export_depth_thread(file_name);
|
||||
if (on_complete)
|
||||
@@ -3131,7 +3142,7 @@ void Canvas::export_layers(std::string path, std::function<void()> on_complete)
|
||||
{
|
||||
if (App::I->check_license())
|
||||
{
|
||||
canvas_async_worker().post([this, path = std::move(path), on_complete = std::move(on_complete)]() mutable {
|
||||
canvas_async_worker_state().post([this, path = std::move(path), on_complete = std::move(on_complete)]() mutable {
|
||||
BT_SetTerminate();
|
||||
export_layers_thread(path);
|
||||
if (on_complete)
|
||||
@@ -3157,7 +3168,7 @@ void Canvas::export_anim_frames(std::string path, std::function<void()> on_compl
|
||||
{
|
||||
if (App::I->check_license())
|
||||
{
|
||||
canvas_async_worker().post([this, path = std::move(path), on_complete = std::move(on_complete)]() mutable {
|
||||
canvas_async_worker_state().post([this, path = std::move(path), on_complete = std::move(on_complete)]() mutable {
|
||||
BT_SetTerminate();
|
||||
export_anim_frames_thread(path);
|
||||
if (on_complete)
|
||||
@@ -3182,7 +3193,7 @@ void Canvas::export_anim_mp4(std::string path, std::function<void()> on_complete
|
||||
{
|
||||
if (App::I->check_license())
|
||||
{
|
||||
canvas_async_worker().post([this, path = std::move(path), on_complete = std::move(on_complete)]() mutable {
|
||||
canvas_async_worker_state().post([this, path = std::move(path), on_complete = std::move(on_complete)]() mutable {
|
||||
BT_SetTerminate();
|
||||
export_anim_mp4_thread(path);
|
||||
if (on_complete)
|
||||
@@ -3220,7 +3231,7 @@ void Canvas::export_cube_faces(std::string file_name, std::function<void()> on_c
|
||||
{
|
||||
if (App::I->check_license())
|
||||
{
|
||||
canvas_async_worker().post([this, file_name = std::move(file_name), on_complete = std::move(on_complete)]() mutable {
|
||||
canvas_async_worker_state().post([this, file_name = std::move(file_name), on_complete = std::move(on_complete)]() mutable {
|
||||
BT_SetTerminate();
|
||||
export_cube_faces_thread(file_name);
|
||||
if (on_complete)
|
||||
@@ -3273,7 +3284,7 @@ void Canvas::project_save(std::function<void(bool)> on_complete)
|
||||
if (App::I->check_license())
|
||||
{
|
||||
const auto file_path = App::I->doc_path;
|
||||
canvas_async_worker().post([this, file_path, on_complete = std::move(on_complete)]() mutable {
|
||||
canvas_async_worker_state().post([this, file_path, on_complete = std::move(on_complete)]() mutable {
|
||||
BT_SetTerminate();
|
||||
bool ret = project_save_thread(file_path, true);
|
||||
if (on_complete)
|
||||
@@ -3287,7 +3298,7 @@ void Canvas::project_save(std::string file_path, std::function<void(bool)> on_co
|
||||
LOG("saving %s", file_path.c_str());
|
||||
if (App::I->check_license())
|
||||
{
|
||||
canvas_async_worker().post([this, file_path = std::move(file_path), on_complete = std::move(on_complete)]() mutable {
|
||||
canvas_async_worker_state().post([this, file_path = std::move(file_path), on_complete = std::move(on_complete)]() mutable {
|
||||
BT_SetTerminate();
|
||||
bool ret = project_save_thread(file_path, true);
|
||||
if (on_complete)
|
||||
@@ -3568,7 +3579,7 @@ bool Canvas::project_save_thread(std::string file_path, bool show_progress)
|
||||
|
||||
void Canvas::project_open(std::string file_path, std::function<void(bool)> on_complete)
|
||||
{
|
||||
canvas_async_worker().post([this, file_path = std::move(file_path), on_complete = std::move(on_complete)]() mutable {
|
||||
canvas_async_worker_state().post([this, file_path = std::move(file_path), on_complete = std::move(on_complete)]() mutable {
|
||||
BT_SetTerminate();
|
||||
bool result = project_open_thread(file_path);
|
||||
if (on_complete)
|
||||
|
||||
Reference in New Issue
Block a user