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,
|
||||
|
||||
@@ -55,6 +55,7 @@ pp::foundation::Status write_export_binary_file(std::string_view path, std::span
|
||||
class LegacyExportWriteServices final
|
||||
: public pp::app::DocumentCubeFaceExportWriteServices
|
||||
, public pp::app::DocumentDepthExportWriteServices
|
||||
, public pp::app::DocumentExportFileWriteServices
|
||||
, public pp::app::DocumentExportCollectionWriteServices {
|
||||
public:
|
||||
explicit LegacyExportWriteServices(App& app) noexcept
|
||||
@@ -320,13 +321,13 @@ pp::foundation::Status export_equirectangular_from_document_snapshot(
|
||||
"document snapshot equirectangular export currently supports PNG and JPEG targets only");
|
||||
}
|
||||
|
||||
const auto write_status = write_export_binary_file(target.path, bytes);
|
||||
if (!write_status.ok()) {
|
||||
return write_status;
|
||||
}
|
||||
|
||||
app.publish_exported_image(target.path);
|
||||
return pp::foundation::Status::success();
|
||||
LegacyExportWriteServices services(app);
|
||||
return pp::app::execute_document_export_file_write(
|
||||
target,
|
||||
pp::app::DocumentExportFilePayload {
|
||||
.bytes = bytes,
|
||||
},
|
||||
services);
|
||||
}
|
||||
|
||||
class LegacyDocumentExportServices final : public pp::app::DocumentExportServices {
|
||||
|
||||
Reference in New Issue
Block a user