Dispatch cube export writes through app core
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
#include "legacy_document_canvas_services.h"
|
||||
#include "paint_renderer/compositor.h"
|
||||
|
||||
#include <array>
|
||||
#include <fstream>
|
||||
#include <limits>
|
||||
#include <span>
|
||||
@@ -29,7 +30,7 @@ struct LegacyDocumentExportSnapshotReports {
|
||||
pp::paint_renderer::DocumentFrameFacePngExportResult face_pngs;
|
||||
};
|
||||
|
||||
pp::foundation::Status write_binary_file(std::string_view path, std::span<const std::byte> bytes)
|
||||
pp::foundation::Status write_export_binary_file(std::string_view path, std::span<const std::byte> bytes)
|
||||
{
|
||||
if (path.empty()) {
|
||||
return pp::foundation::Status::invalid_argument("export path must not be empty");
|
||||
@@ -51,6 +52,29 @@ pp::foundation::Status write_binary_file(std::string_view path, std::span<const
|
||||
return pp::foundation::Status::success();
|
||||
}
|
||||
|
||||
class LegacyCubeFaceExportWriteServices final : public pp::app::DocumentCubeFaceExportWriteServices {
|
||||
public:
|
||||
explicit LegacyCubeFaceExportWriteServices(App& app) noexcept
|
||||
: app_(app)
|
||||
{
|
||||
}
|
||||
|
||||
pp::foundation::Status write_binary_file(
|
||||
std::string_view path,
|
||||
std::span<const std::byte> bytes) override
|
||||
{
|
||||
return write_export_binary_file(path, bytes);
|
||||
}
|
||||
|
||||
void publish_exported_image(std::string_view path) override
|
||||
{
|
||||
app_.publish_exported_image(std::string(path));
|
||||
}
|
||||
|
||||
private:
|
||||
App& app_;
|
||||
};
|
||||
|
||||
pp::foundation::Result<LegacyDocumentExportSnapshotReports> prepare_legacy_document_export_snapshot(
|
||||
App& app,
|
||||
const char* context)
|
||||
@@ -149,16 +173,13 @@ pp::foundation::Status export_cube_faces_from_document_snapshot(
|
||||
return pp::foundation::Status::invalid_argument("document snapshot did not produce all cube face PNGs");
|
||||
}
|
||||
|
||||
for (std::size_t face_index = 0; face_index < target.value().face_count; ++face_index) {
|
||||
const auto& face = target.value().faces[face_index];
|
||||
const auto status = write_binary_file(face.path, reports.face_pngs.face_pngs[face_index]);
|
||||
if (!status.ok()) {
|
||||
return status;
|
||||
}
|
||||
app.publish_exported_image(face.path);
|
||||
std::array<pp::app::DocumentCubeFaceExportPayload, pp::document::cube_face_count> payloads;
|
||||
for (std::size_t face_index = 0; face_index < payloads.size(); ++face_index) {
|
||||
payloads[face_index].bytes = std::span<const std::byte>(reports.face_pngs.face_pngs[face_index]);
|
||||
}
|
||||
|
||||
return pp::foundation::Status::success();
|
||||
LegacyCubeFaceExportWriteServices services(app);
|
||||
return pp::app::execute_document_cube_face_export_write(target.value(), payloads, services);
|
||||
}
|
||||
|
||||
class LegacyDocumentExportServices final : public pp::app::DocumentExportServices {
|
||||
|
||||
Reference in New Issue
Block a user