Dispatch cube export writes through app core
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
|
||||
#include <array>
|
||||
#include <cstddef>
|
||||
#include <span>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <utility>
|
||||
@@ -36,6 +37,10 @@ struct DocumentCubeFaceExportTarget {
|
||||
std::size_t face_count = 0;
|
||||
};
|
||||
|
||||
struct DocumentCubeFaceExportPayload {
|
||||
std::span<const std::byte> bytes;
|
||||
};
|
||||
|
||||
struct DocumentExportSuggestedName {
|
||||
std::string name;
|
||||
};
|
||||
@@ -175,6 +180,16 @@ public:
|
||||
virtual void show_timelapse_export_success(std::string_view path) = 0;
|
||||
};
|
||||
|
||||
class DocumentCubeFaceExportWriteServices {
|
||||
public:
|
||||
virtual ~DocumentCubeFaceExportWriteServices() = 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;
|
||||
};
|
||||
|
||||
[[nodiscard]] constexpr DocumentExportStartDecision plan_document_export_start(
|
||||
bool requires_license,
|
||||
bool license_valid,
|
||||
@@ -609,6 +624,38 @@ document_cube_face_export_names() noexcept
|
||||
return pp::foundation::Result<DocumentExportSuggestedName>::success(std::move(target));
|
||||
}
|
||||
|
||||
[[nodiscard]] inline pp::foundation::Status execute_document_cube_face_export_write(
|
||||
const DocumentCubeFaceExportTarget& target,
|
||||
std::span<const DocumentCubeFaceExportPayload> face_payloads,
|
||||
DocumentCubeFaceExportWriteServices& services)
|
||||
{
|
||||
if (target.face_count != pp::document::cube_face_count) {
|
||||
return pp::foundation::Status::invalid_argument("cube face export target must contain all cube faces");
|
||||
}
|
||||
|
||||
if (face_payloads.size() != target.face_count) {
|
||||
return pp::foundation::Status::invalid_argument("cube face export payload count must match target face count");
|
||||
}
|
||||
|
||||
for (std::size_t face_index = 0; face_index < target.face_count; ++face_index) {
|
||||
const auto& face = target.faces[face_index];
|
||||
if (face.path.empty()) {
|
||||
return pp::foundation::Status::invalid_argument("cube face export path must not be empty");
|
||||
}
|
||||
if (face_payloads[face_index].bytes.empty()) {
|
||||
return pp::foundation::Status::invalid_argument("cube face export payload must not be empty");
|
||||
}
|
||||
|
||||
const auto write_status = services.write_binary_file(face.path, face_payloads[face_index].bytes);
|
||||
if (!write_status.ok()) {
|
||||
return write_status;
|
||||
}
|
||||
services.publish_exported_image(face.path);
|
||||
}
|
||||
|
||||
return pp::foundation::Status::success();
|
||||
}
|
||||
|
||||
[[nodiscard]] inline pp::foundation::Status execute_document_export_file(
|
||||
const DocumentExportFileTarget& target,
|
||||
DocumentExportServices& services)
|
||||
|
||||
Reference in New Issue
Block a user