Plan cube export face targets in app core
This commit is contained in:
@@ -6,7 +6,6 @@
|
||||
#include "legacy_document_canvas_services.h"
|
||||
#include "paint_renderer/compositor.h"
|
||||
|
||||
#include <array>
|
||||
#include <fstream>
|
||||
#include <limits>
|
||||
#include <span>
|
||||
@@ -142,30 +141,21 @@ pp::foundation::Status export_cube_faces_from_document_snapshot(
|
||||
std::string_view document_name,
|
||||
const LegacyDocumentExportSnapshotReports& reports)
|
||||
{
|
||||
static constexpr std::array<std::string_view, pp::document::cube_face_count> plane_names {
|
||||
"front",
|
||||
"right",
|
||||
"back",
|
||||
"left",
|
||||
"top",
|
||||
"bottom",
|
||||
};
|
||||
|
||||
if (document_name.empty()) {
|
||||
return pp::foundation::Status::invalid_argument("document name must not be empty");
|
||||
const auto target = pp::app::make_document_cube_face_export_target(app.work_path, document_name);
|
||||
if (!target) {
|
||||
return target.status();
|
||||
}
|
||||
if (reports.face_pngs.face_count != pp::document::cube_face_count) {
|
||||
return pp::foundation::Status::invalid_argument("document snapshot did not produce all cube face PNGs");
|
||||
}
|
||||
|
||||
for (std::size_t face_index = 0; face_index < plane_names.size(); ++face_index) {
|
||||
const std::string path = app.work_path + "/" + std::string(document_name) + "-"
|
||||
+ std::string(plane_names[face_index]) + ".png";
|
||||
const auto status = write_binary_file(path, reports.face_pngs.face_pngs[face_index]);
|
||||
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(path);
|
||||
app.publish_exported_image(face.path);
|
||||
}
|
||||
|
||||
return pp::foundation::Status::success();
|
||||
|
||||
Reference in New Issue
Block a user