Move export snapshot platform support to app core

This commit is contained in:
2026-06-06 11:20:25 +02:00
parent 41279c8743
commit 09df47879d
7 changed files with 86 additions and 42 deletions

View File

@@ -489,6 +489,15 @@ public:
return false;
}
[[nodiscard]] constexpr bool document_export_snapshot_platform_supported() noexcept
{
#if __WEB__
return false;
#else
return true;
#endif
}
[[nodiscard]] constexpr DocumentExportSnapshotRoutePlan plan_document_export_snapshot_route(
DocumentExportExecutionKind kind,
DocumentCanvasSaveSnapshotReport report,
@@ -534,6 +543,18 @@ public:
platform_supported);
}
[[nodiscard]] constexpr DocumentExportSnapshotRoutePlan plan_document_export_snapshot_route_for_current_platform(
DocumentExportExecutionKind kind,
DocumentCanvasSaveSnapshotReport report,
std::string_view target_path = {}) noexcept
{
return plan_document_export_snapshot_route_for_target(
kind,
report,
target_path,
document_export_snapshot_platform_supported());
}
[[nodiscard]] constexpr DocumentExportCollectionTargetPlan plan_document_export_collection_target(
DocumentExportCollectionKind kind,
bool use_work_directory_collection) noexcept

View File

@@ -159,15 +159,13 @@ bool should_use_document_snapshot_writer(
const char* context,
pp::app::DocumentExportExecutionKind kind,
const LegacyDocumentExportSnapshotReports& reports,
std::string_view target_path,
bool platform_supported)
std::string_view target_path)
{
const auto report = pp::app::make_document_canvas_save_snapshot_report(reports.snapshot);
const auto route = pp::app::plan_document_export_snapshot_route_for_target(
const auto route = pp::app::plan_document_export_snapshot_route_for_current_platform(
kind,
report,
target_path,
platform_supported);
target_path);
if (!route.uses_document_snapshot_writer) {
LOG(
"%s document export writer retained legacy export: %.*s",
@@ -357,15 +355,13 @@ public:
void export_equirectangular(const pp::app::DocumentExportFileTarget& target) override
{
auto* app = &app_;
#if !__WEB__
const auto prepared = prepare_legacy_document_export_snapshot(app_, "export-equirectangular");
if (prepared) {
if (should_use_document_snapshot_writer(
"export-equirectangular",
pp::app::DocumentExportExecutionKind::equirectangular_file,
prepared.value(),
target.path,
true)) {
target.path)) {
const auto exported = export_equirectangular_from_document_snapshot(app_, target, prepared.value());
if (exported.ok()) {
show_export_success_dialog(
@@ -386,9 +382,6 @@ public:
"export-equirectangular document export snapshot bridge retained legacy export after failure: %s",
prepared.status().message);
}
#else
prepare_legacy_document_export_snapshot_or_continue(app_, "export-equirectangular");
#endif
app_.canvas->m_canvas->export_equirectangular(target.path, [app, target] {
#if __WEB__
app->ui_task([app, target] {
@@ -409,7 +402,6 @@ public:
void export_layers_to_stem(const pp::app::DocumentExportStemTarget& target) override
{
auto* app = &app_;
#if !__WEB__
const auto prepared = prepare_legacy_document_export_snapshot(app_, "export-layers");
if (prepared) {
const auto collection_target = pp::app::DocumentExportCollectionTarget {
@@ -419,8 +411,7 @@ public:
"export-layers",
pp::app::DocumentExportExecutionKind::layers_stem,
prepared.value(),
{},
true)) {
{})) {
const auto exported = export_layers_from_document_snapshot(app_, collection_target, prepared.value());
if (exported.ok()) {
show_export_success_dialog(
@@ -439,9 +430,6 @@ public:
"export-layers document export snapshot bridge retained legacy export after failure: %s",
prepared.status().message);
}
#else
prepare_legacy_document_export_snapshot_or_continue(app_, "export-layers");
#endif
app_.canvas->m_canvas->export_layers(target.stem_path, [app, target] {
show_export_success_dialog(
*app,
@@ -455,15 +443,13 @@ public:
void export_layers_to_collection(const pp::app::DocumentExportCollectionTarget& target) override
{
auto* app = &app_;
#if !__WEB__
const auto prepared = prepare_legacy_document_export_snapshot(app_, "export-layers");
if (prepared) {
if (should_use_document_snapshot_writer(
"export-layers",
pp::app::DocumentExportExecutionKind::layers_collection,
prepared.value(),
{},
true)) {
{})) {
const auto exported = export_layers_from_document_snapshot(app_, target, prepared.value());
if (exported.ok()) {
show_export_success_dialog(
@@ -481,9 +467,6 @@ public:
"export-layers document export snapshot bridge retained legacy export after failure: %s",
prepared.status().message);
}
#else
prepare_legacy_document_export_snapshot_or_continue(app_, "export-layers");
#endif
app_.canvas->m_canvas->export_layers(target.stem_path, [app] {
show_export_success_dialog(
*app,
@@ -496,7 +479,6 @@ public:
void export_animation_frames_to_stem(const pp::app::DocumentExportStemTarget& target) override
{
auto* app = &app_;
#if !__WEB__
const auto prepared = prepare_legacy_document_export_snapshot(app_, "export-animation-frames");
if (prepared) {
const auto collection_target = pp::app::DocumentExportCollectionTarget {
@@ -506,8 +488,7 @@ public:
"export-animation-frames",
pp::app::DocumentExportExecutionKind::animation_frames_stem,
prepared.value(),
{},
true)) {
{})) {
const auto exported = export_animation_frames_from_document_snapshot(
app_,
collection_target,
@@ -531,9 +512,6 @@ public:
"export-animation-frames document export snapshot bridge retained legacy export after failure: %s",
prepared.status().message);
}
#else
prepare_legacy_document_export_snapshot_or_continue(app_, "export-animation-frames");
#endif
app_.canvas->m_canvas->export_anim_frames(target.stem_path, [app, target] {
show_export_success_dialog(
*app,
@@ -547,15 +525,13 @@ public:
void export_animation_frames_to_collection(const pp::app::DocumentExportCollectionTarget& target) override
{
auto* app = &app_;
#if !__WEB__
const auto prepared = prepare_legacy_document_export_snapshot(app_, "export-animation-frames");
if (prepared) {
if (should_use_document_snapshot_writer(
"export-animation-frames",
pp::app::DocumentExportExecutionKind::animation_frames_collection,
prepared.value(),
{},
true)) {
{})) {
const auto exported = export_animation_frames_from_document_snapshot(app_, target, prepared.value());
if (exported.ok()) {
show_export_success_dialog(
@@ -575,9 +551,6 @@ public:
"export-animation-frames document export snapshot bridge retained legacy export after failure: %s",
prepared.status().message);
}
#else
prepare_legacy_document_export_snapshot_or_continue(app_, "export-animation-frames");
#endif
app_.canvas->m_canvas->export_anim_frames(target.stem_path, [app] {
show_export_success_dialog(
*app,
@@ -651,8 +624,7 @@ public:
"export-cube-faces",
pp::app::DocumentExportExecutionKind::cube_faces,
prepared.value(),
{},
true)) {
{})) {
const auto exported = export_cube_faces_from_document_snapshot(app_, document_name, prepared.value());
if (exported.ok()) {
show_export_success_dialog(