Route equirectangular export writes through app core
This commit is contained in:
@@ -52,6 +52,10 @@ struct DocumentDepthExportPayload {
|
||||
std::span<const std::byte> depth_bytes;
|
||||
};
|
||||
|
||||
struct DocumentExportFilePayload {
|
||||
std::span<const std::byte> bytes;
|
||||
};
|
||||
|
||||
struct DocumentExportCollectionPngPayload {
|
||||
std::string path_suffix;
|
||||
std::span<const std::byte> bytes;
|
||||
@@ -231,6 +235,16 @@ public:
|
||||
virtual void publish_exported_image(std::string_view path) = 0;
|
||||
};
|
||||
|
||||
class DocumentExportFileWriteServices {
|
||||
public:
|
||||
virtual ~DocumentExportFileWriteServices() = default;
|
||||
|
||||
virtual pp::foundation::Status write_binary_file(
|
||||
std::string_view path,
|
||||
std::span<const std::byte> bytes) = 0;
|
||||
virtual void publish_exported_image(std::string_view path) = 0;
|
||||
};
|
||||
|
||||
class DocumentExportCollectionWriteServices {
|
||||
public:
|
||||
virtual ~DocumentExportCollectionWriteServices() = default;
|
||||
@@ -928,6 +942,27 @@ document_cube_face_export_names() noexcept
|
||||
return pp::foundation::Status::success();
|
||||
}
|
||||
|
||||
[[nodiscard]] inline pp::foundation::Status execute_document_export_file_write(
|
||||
const DocumentExportFileTarget& target,
|
||||
DocumentExportFilePayload payload,
|
||||
DocumentExportFileWriteServices& services)
|
||||
{
|
||||
if (target.path.empty()) {
|
||||
return pp::foundation::Status::invalid_argument("export file target requires a path");
|
||||
}
|
||||
if (payload.bytes.empty()) {
|
||||
return pp::foundation::Status::invalid_argument("export file payload must not be empty");
|
||||
}
|
||||
|
||||
const auto write_status = services.write_binary_file(target.path, payload.bytes);
|
||||
if (!write_status.ok()) {
|
||||
return write_status;
|
||||
}
|
||||
services.publish_exported_image(target.path);
|
||||
|
||||
return pp::foundation::Status::success();
|
||||
}
|
||||
|
||||
[[nodiscard]] inline pp::foundation::Status execute_document_export_collection_write(
|
||||
const DocumentExportCollectionTarget& target,
|
||||
std::span<const DocumentExportCollectionPngPayload> payloads,
|
||||
|
||||
Reference in New Issue
Block a user