Move export snapshot target support to app core

This commit is contained in:
2026-06-06 11:10:26 +02:00
parent 7575f51c45
commit 41279c8743
8 changed files with 208 additions and 110 deletions

View File

@@ -424,6 +424,71 @@ public:
return "Document export failed";
}
[[nodiscard]] constexpr bool ascii_iequals(std::string_view left, std::string_view right) noexcept
{
if (left.size() != right.size()) {
return false;
}
for (std::size_t i = 0; i < left.size(); ++i) {
auto lhs = left[i];
if (lhs >= 'A' && lhs <= 'Z') {
lhs = static_cast<char>(lhs - 'A' + 'a');
}
auto rhs = right[i];
if (rhs >= 'A' && rhs <= 'Z') {
rhs = static_cast<char>(rhs - 'A' + 'a');
}
if (lhs != rhs) {
return false;
}
}
return true;
}
[[nodiscard]] constexpr bool document_export_path_has_extension(
std::string_view path,
std::string_view extension) noexcept
{
return path.size() >= extension.size()
&& ascii_iequals(path.substr(path.size() - extension.size()), extension);
}
[[nodiscard]] constexpr bool document_export_path_is_png_target(std::string_view path) noexcept
{
return document_export_path_has_extension(path, ".png");
}
[[nodiscard]] constexpr bool document_export_path_is_jpeg_target(std::string_view path) noexcept
{
return document_export_path_has_extension(path, ".jpg")
|| document_export_path_has_extension(path, ".jpeg");
}
[[nodiscard]] constexpr bool document_export_snapshot_target_supported(
DocumentExportExecutionKind kind,
std::string_view target_path = {}) noexcept
{
switch (kind) {
case DocumentExportExecutionKind::equirectangular_file:
return document_export_path_is_png_target(target_path)
|| document_export_path_is_jpeg_target(target_path);
case DocumentExportExecutionKind::layers_collection:
case DocumentExportExecutionKind::layers_stem:
case DocumentExportExecutionKind::animation_frames_collection:
case DocumentExportExecutionKind::animation_frames_stem:
case DocumentExportExecutionKind::cube_faces:
return true;
case DocumentExportExecutionKind::depth:
case DocumentExportExecutionKind::animation_mp4:
case DocumentExportExecutionKind::timelapse:
return false;
}
return false;
}
[[nodiscard]] constexpr DocumentExportSnapshotRoutePlan plan_document_export_snapshot_route(
DocumentExportExecutionKind kind,
DocumentCanvasSaveSnapshotReport report,
@@ -456,6 +521,19 @@ public:
return plan;
}
[[nodiscard]] constexpr DocumentExportSnapshotRoutePlan plan_document_export_snapshot_route_for_target(
DocumentExportExecutionKind kind,
DocumentCanvasSaveSnapshotReport report,
std::string_view target_path,
bool platform_supported) noexcept
{
return plan_document_export_snapshot_route(
kind,
report,
document_export_snapshot_target_supported(kind, target_path),
platform_supported);
}
[[nodiscard]] constexpr DocumentExportCollectionTargetPlan plan_document_export_collection_target(
DocumentExportCollectionKind kind,
bool use_work_directory_collection) noexcept