Add document export file automation
This commit is contained in:
@@ -123,6 +123,9 @@ Known local toolchain state:
|
||||
- `pano_cli simulate-document-export` exposes the same pure document-to-PPI
|
||||
export, asset-level decode, and document reimport path through JSON
|
||||
automation and is covered by `pano_cli_simulate_document_export_smoke`.
|
||||
- `pano_cli save-document-project` writes that pure document export to a PPI
|
||||
file and is covered by `pano_cli_save_document_project_roundtrip_smoke`,
|
||||
which inspects and loads the generated file.
|
||||
- `pano_cli load-project` creates a `pp_document` projection with per-layer
|
||||
frame counts, durations, and decoded face-pixel payloads when present; the
|
||||
metadata-only minimal fixture remains covered by
|
||||
@@ -306,6 +309,8 @@ Known local toolchain state:
|
||||
future DEBT-0010/DEBT-0013 task.
|
||||
- `pano_cli simulate-document-export` exposes document export round-trip state
|
||||
through JSON automation for agent-driven checks.
|
||||
- `pano_cli save-document-project` exposes file-writing document export
|
||||
automation for inspect/load round trips.
|
||||
- `pp_ui_core` consumes vcpkg tinyxml2 only when `PP_USE_VCPKG_TINYXML2=ON`
|
||||
through the vcpkg preset; default and Android validation still use the
|
||||
retained vendored fallback tracked by DEBT-0012.
|
||||
|
||||
@@ -28,10 +28,10 @@ agent or engineer to remove them without reconstructing context from chat.
|
||||
| DEBT-0007 | Open | Modernization | `vcpkg.json` and `windows-msvc-vcpkg-headless` are validated for the headless Windows component matrix, but app targets still use vendored libraries and Android/Apple triplets are not proven | Dependency migration must stay incremental while SDK/patched/vendor dependencies remain in use | `$env:VCPKG_ROOT="C:\Program Files\Microsoft Visual Studio\2022\Community\VC\vcpkg"; cmake --preset windows-msvc-vcpkg-headless`; `ctest --preset desktop-fast-vcpkg --build-config Debug` | Component targets consume vcpkg packages where reliable and desktop app, Android, and Apple triplets are validated or explicitly documented as permanent vendor exceptions |
|
||||
| DEBT-0008 | Open | Modernization | `windows-msvc-default` preset is used for local validation because the VS 2026 generator is not installed here | The target VS 2026 preset must remain, but this machine configures with Visual Studio 17 2022 | `cmake --preset windows-msvc-default`; `ctest --preset desktop-fast --build-config Debug` | Validate `windows-vs2026-x64` on a machine with Visual Studio 2026 installed and make it the default Windows validation preset |
|
||||
| DEBT-0009 | Open | Modernization | Android root CMake validation currently builds headless targets only, not APK/package variants | Platform app entrypoints still live in legacy Gradle/CMake projects and need Phase 6 alignment | `powershell -ExecutionPolicy Bypass -File scripts\automation\platform-build.ps1 -Presets android-arm64` | Android standard, Quest, and Focus/Wave package targets consume shared component targets and have package smoke commands |
|
||||
| DEBT-0010 | Open | Modernization | `pp_document` is a pure layer/frame/document/undo-history model with alpha-lock metadata, snapshot construction, per-layer frame metadata, renderer-free RGBA8 face payload storage, snapshot-embedded face-payload validation, renderer-free alpha8 selection-mask storage, and PPI import/export helpers, but it is not yet wired to legacy `Canvas`, legacy save, or legacy action commands | Keep extraction incremental while preserving app behavior | `ctest --preset desktop-fast --build-config Debug`; `pano_cli create-document --width 64 --height 32 --layers 2`; `pano_cli load-project --path tests\data\projects\minimal-project.ppi`; `pp_document_tests`; `pp_document_ppi_import_tests`; `pp_document_ppi_export_tests`; `pano_cli_simulate_document_edits_smoke`; `pano_cli_simulate_document_export_smoke` | Legacy document behavior is represented by `pp_document` tests and the app consumes it through a boundary/facade |
|
||||
| DEBT-0010 | Open | Modernization | `pp_document` is a pure layer/frame/document/undo-history model with alpha-lock metadata, snapshot construction, per-layer frame metadata, renderer-free RGBA8 face payload storage, snapshot-embedded face-payload validation, renderer-free alpha8 selection-mask storage, and PPI import/export helpers, but it is not yet wired to legacy `Canvas`, legacy save, or legacy action commands | Keep extraction incremental while preserving app behavior | `ctest --preset desktop-fast --build-config Debug`; `pano_cli create-document --width 64 --height 32 --layers 2`; `pano_cli load-project --path tests\data\projects\minimal-project.ppi`; `pp_document_tests`; `pp_document_ppi_import_tests`; `pp_document_ppi_export_tests`; `pano_cli_simulate_document_edits_smoke`; `pano_cli_simulate_document_export_smoke`; `pano_cli_save_document_project_roundtrip_smoke` | Legacy document behavior is represented by `pp_document` tests and the app consumes it through a boundary/facade |
|
||||
| DEBT-0011 | Open | Modernization | `package-smoke` validates the Windows CMake app artifact only, not AppX/APK/Apple/WebGL package outputs | Platform package targets are not migrated to root CMake yet | `powershell -ExecutionPolicy Bypass -File scripts\automation\package-smoke.ps1 -Preset windows-msvc-default -Configuration Debug` | Package-smoke covers Windows AppX, Android APK variants, Apple bundles, and WebGL output where local toolchains are present |
|
||||
| DEBT-0012 | Open | Modernization | `pp_ui_core` uses vcpkg tinyxml2 on `windows-msvc-vcpkg-headless`, but retains `pp_vendor_tinyxml2` for default and unproven platform presets | Mobile/AppX/Apple triplets and app packaging still need validation before removing the vendored fallback | `ctest --preset desktop-fast-vcpkg --build-config Debug`; `ctest --preset desktop-fast --build-config Debug`; `powershell -ExecutionPolicy Bypass -File scripts\automation\platform-build.ps1 -Presets android-arm64` | All supported presets consume vcpkg tinyxml2 or document a permanent vendored exception |
|
||||
| DEBT-0013 | Open | Modernization | `pp_assets`, `pp_document`, `pano_cli inspect-project`, `pano_cli load-project`, and `pano_cli save-project` validate the fixed PPI header, thumbnail/body byte layout, generated multi-layer/multi-frame PPI writing with explicit layer opacity/blend/alpha-lock/visibility metadata, per-layer frame durations, metadata-only and targeted dirty-face-payload save/load round-trips, layer/frame index, dirty-face descriptors, dirty-face PNG payload metadata, asset-level RGBA PNG payload decoding, pure document-to-PPI export, CLI document export automation, and decoded pixel attachment to `pp_document`, but full legacy PPI round-trip parity is not yet extracted | Full PPI save parity requires staged extraction of legacy `Canvas` serialization and image/layer payload handling | `ctest --preset desktop-fast --build-config Debug`; `pp_assets_image_pixels_tests`; `pp_assets_ppi_header_tests`; `pp_document_ppi_import_tests`; `pp_document_ppi_export_tests`; `pano_cli_inspect_project_layout_smoke`; `pano_cli_load_project_metadata_smoke`; `pano_cli_save_project_roundtrip_smoke`; `pano_cli_save_project_payload_roundtrip_smoke`; `pano_cli_simulate_document_export_smoke` | Full PPI load/save fixtures cover thumbnails, decoded layer face payloads attached to documents, frames, corrupt payloads, dirty-face payload saving, arbitrary legacy canvas payload/layout combinations, and legacy app round-trip compatibility |
|
||||
| DEBT-0013 | Open | Modernization | `pp_assets`, `pp_document`, `pano_cli inspect-project`, `pano_cli load-project`, and `pano_cli save-project` validate the fixed PPI header, thumbnail/body byte layout, generated multi-layer/multi-frame PPI writing with explicit layer opacity/blend/alpha-lock/visibility metadata, per-layer frame durations, metadata-only and targeted dirty-face-payload save/load round-trips, layer/frame index, dirty-face descriptors, dirty-face PNG payload metadata, asset-level RGBA PNG payload decoding, pure document-to-PPI export, CLI document export automation, file-writing document export automation, and decoded pixel attachment to `pp_document`, but full legacy PPI round-trip parity is not yet extracted | Full PPI save parity requires staged extraction of legacy `Canvas` serialization and image/layer payload handling | `ctest --preset desktop-fast --build-config Debug`; `pp_assets_image_pixels_tests`; `pp_assets_ppi_header_tests`; `pp_document_ppi_import_tests`; `pp_document_ppi_export_tests`; `pano_cli_inspect_project_layout_smoke`; `pano_cli_load_project_metadata_smoke`; `pano_cli_save_project_roundtrip_smoke`; `pano_cli_save_project_payload_roundtrip_smoke`; `pano_cli_simulate_document_export_smoke`; `pano_cli_save_document_project_roundtrip_smoke` | Full PPI load/save fixtures cover thumbnails, decoded layer face payloads attached to documents, frames, corrupt payloads, dirty-face payload saving, arbitrary legacy canvas payload/layout combinations, and legacy app round-trip compatibility |
|
||||
| DEBT-0014 | Open | Modernization | `windows-clangcl-asan` now configures as a headless Ninja/clang-cl preset and uses the release MSVC runtime required by ASan, but local builds still fail because installed clang-cl 18.1.8 is paired with VS 2026-preview STL headers that require Clang 20 or newer | Sanitizer validation should be local and repeatable, but this machine's compiler/header pairing is incompatible | `cmake --fresh --preset windows-clangcl-asan`; `cmake --build --preset windows-clangcl-asan --target pp_foundation` | Install/use Clang 20+ with the VS 2026 STL, or point the preset at a compatible VS 2022 toolchain, then make `platform-build.ps1 -Presets windows-clangcl-asan` pass for the headless matrix |
|
||||
|
||||
## Closed Debt
|
||||
|
||||
@@ -355,6 +355,8 @@ bytes using that writer, including PNG-encoded layer/frame face payloads.
|
||||
`pano_cli simulate-document-export` exercises that pure document export path,
|
||||
decodes the generated PPI bytes, reimports them, and emits JSON round-trip
|
||||
metadata.
|
||||
`pano_cli save-document-project` writes the same pure document export to a PPI
|
||||
file for inspect/load round-trip automation.
|
||||
`pano_cli create-document` can create simple animation documents with explicit
|
||||
frame count/duration. `pano_cli simulate-document-edits` exercises pure
|
||||
layer metadata, frame reordering, active-index preservation, tiny face-payload
|
||||
@@ -364,6 +366,8 @@ summaries. `pano_cli simulate-image-import` decodes an embedded tiny PNG
|
||||
through `pp_assets` and attaches the resulting RGBA8 payload to `pp_document`.
|
||||
`pano_cli simulate-document-export` exercises pure document-to-PPI export,
|
||||
asset-level PPI image decode, and document reimport in one automation command.
|
||||
`pano_cli save-document-project` writes a deterministic pure document export
|
||||
PPI and verifies it through inspect/load smoke coverage.
|
||||
`pano_cli simulate-stroke` exercises the pure stroke sampler for
|
||||
scripted-stroke automation. `pano_cli simulate-stroke-script`
|
||||
loads stroke script fixtures, parses them through `pp_paint`, and samples every
|
||||
@@ -746,6 +750,9 @@ Results:
|
||||
`pp_assets` PPI writer can save a compressed RGBA PNG dirty-face payload to
|
||||
an explicit layer/frame slot, inspect the serialized descriptor, and reload
|
||||
it as decoded `pp_document` face-pixel data.
|
||||
- `pano_cli_save_document_project_roundtrip_smoke` passed and proves a pure
|
||||
`pp_document` export can be written to a PPI file, inspected for layer/frame
|
||||
dirty-face descriptors, and loaded back through the PPI import path.
|
||||
- `pano_cli_parse_layout_smoke` passed.
|
||||
- `pano_cli_simulate_stroke_smoke` passed and reports deterministic stroke
|
||||
sample counts/distances.
|
||||
@@ -824,6 +831,8 @@ Results:
|
||||
by DEBT-0010/DEBT-0013.
|
||||
- `pano_cli simulate-document-export` exposes the same export path through JSON
|
||||
automation for agents.
|
||||
- `pano_cli save-document-project` exposes file-writing document export
|
||||
automation for inspect/load round trips.
|
||||
- Snapshot creation now rejects invalid embedded RGBA8 face payloads before
|
||||
document export or history can persist malformed state.
|
||||
- PowerShell package-smoke wrapper validates the Windows CMake app executable
|
||||
|
||||
@@ -329,6 +329,14 @@ if(TARGET pano_cli)
|
||||
set_tests_properties(pano_cli_save_project_payload_roundtrip_smoke PROPERTIES
|
||||
LABELS "assets;document;integration;desktop-fast")
|
||||
|
||||
add_test(NAME pano_cli_save_document_project_roundtrip_smoke
|
||||
COMMAND "${CMAKE_COMMAND}"
|
||||
-DPANO_CLI=$<TARGET_FILE:pano_cli>
|
||||
-DOUTPUT_PATH=${CMAKE_CURRENT_BINARY_DIR}/data/generated/document-export-roundtrip.ppi
|
||||
-P "${CMAKE_CURRENT_SOURCE_DIR}/cmake/pano_cli_save_document_project_roundtrip.cmake")
|
||||
set_tests_properties(pano_cli_save_document_project_roundtrip_smoke PROPERTIES
|
||||
LABELS "assets;document;integration;desktop-fast")
|
||||
|
||||
add_test(NAME pano_cli_parse_layout_smoke
|
||||
COMMAND pano_cli parse-layout --path "${CMAKE_CURRENT_SOURCE_DIR}/data/layouts/simple-layout.xml")
|
||||
set_tests_properties(pano_cli_parse_layout_smoke PROPERTIES
|
||||
|
||||
87
tests/cmake/pano_cli_save_document_project_roundtrip.cmake
Normal file
87
tests/cmake/pano_cli_save_document_project_roundtrip.cmake
Normal file
@@ -0,0 +1,87 @@
|
||||
if(NOT DEFINED PANO_CLI)
|
||||
message(FATAL_ERROR "PANO_CLI must be set")
|
||||
endif()
|
||||
|
||||
if(NOT DEFINED OUTPUT_PATH)
|
||||
message(FATAL_ERROR "OUTPUT_PATH must be set")
|
||||
endif()
|
||||
|
||||
get_filename_component(output_dir "${OUTPUT_PATH}" DIRECTORY)
|
||||
file(MAKE_DIRECTORY "${output_dir}")
|
||||
file(REMOVE "${OUTPUT_PATH}")
|
||||
|
||||
execute_process(
|
||||
COMMAND "${PANO_CLI}" save-document-project
|
||||
--path "${OUTPUT_PATH}"
|
||||
--width 64
|
||||
--height 32
|
||||
RESULT_VARIABLE save_result
|
||||
OUTPUT_VARIABLE save_output
|
||||
ERROR_VARIABLE save_error)
|
||||
|
||||
if(NOT save_result EQUAL 0)
|
||||
message(FATAL_ERROR "save-document-project failed: ${save_output}${save_error}")
|
||||
endif()
|
||||
|
||||
string(FIND "${save_output}" "\"command\":\"save-document-project\"" save_command_index)
|
||||
string(FIND "${save_output}" "\"document\":{\"width\":64,\"height\":32,\"layers\":2,\"frames\":2,\"facePayloads\":2}" save_document_index)
|
||||
string(FIND "${save_output}" "\"export\":{\"dirtyFaces\":2,\"rgbaFacePayloads\":2" save_export_index)
|
||||
if(save_command_index LESS 0 OR save_document_index LESS 0 OR save_export_index LESS 0)
|
||||
message(FATAL_ERROR "save-document-project output did not contain expected summary: ${save_output}")
|
||||
endif()
|
||||
|
||||
if(NOT EXISTS "${OUTPUT_PATH}")
|
||||
message(FATAL_ERROR "save-document-project did not create ${OUTPUT_PATH}")
|
||||
endif()
|
||||
|
||||
execute_process(
|
||||
COMMAND "${PANO_CLI}" inspect-project --path "${OUTPUT_PATH}"
|
||||
RESULT_VARIABLE inspect_result
|
||||
OUTPUT_VARIABLE inspect_output
|
||||
ERROR_VARIABLE inspect_error)
|
||||
|
||||
if(NOT inspect_result EQUAL 0)
|
||||
message(FATAL_ERROR "inspect-project failed after save-document-project: ${inspect_output}${inspect_error}")
|
||||
endif()
|
||||
|
||||
string(FIND "${inspect_output}" "\"dirtyFaces\":2" inspect_dirty_index)
|
||||
string(FIND "${inspect_output}" "\"name\":\"Base\"" inspect_base_index)
|
||||
string(FIND "${inspect_output}" "\"name\":\"Paint\"" inspect_paint_index)
|
||||
string(REGEX MATCH "\"index\":0,\"durationMs\":100,\"dirtyFaces\":\\[\\{\"face\":0,\"box\":\\[2,3,3,4\\]" inspect_base_payload "${inspect_output}")
|
||||
string(REGEX MATCH "\"index\":1,\"storedOrder\":1,\"name\":\"Paint\".*\"dirtyFaces\":\\[\\{\"face\":5,\"box\":\\[4,5,5,6\\]" inspect_paint_payload "${inspect_output}")
|
||||
if(inspect_dirty_index LESS 0
|
||||
OR inspect_base_index LESS 0
|
||||
OR inspect_paint_index LESS 0
|
||||
OR NOT inspect_base_payload
|
||||
OR NOT inspect_paint_payload)
|
||||
message(FATAL_ERROR "inspect-project output did not contain expected document export layout: ${inspect_output}")
|
||||
endif()
|
||||
|
||||
execute_process(
|
||||
COMMAND "${PANO_CLI}" load-project --path "${OUTPUT_PATH}"
|
||||
RESULT_VARIABLE load_result
|
||||
OUTPUT_VARIABLE load_output
|
||||
ERROR_VARIABLE load_error)
|
||||
|
||||
if(NOT load_result EQUAL 0)
|
||||
message(FATAL_ERROR "load-project failed after save-document-project: ${load_output}${load_error}")
|
||||
endif()
|
||||
|
||||
string(FIND "${load_output}" "\"command\":\"load-project\"" load_command_index)
|
||||
string(FIND "${load_output}" "\"pixelDataLoaded\":true" load_pixels_index)
|
||||
string(FIND "${load_output}" "\"facePayloads\":2" load_payload_index)
|
||||
string(FIND "${load_output}" "\"layers\":2" load_layers_index)
|
||||
string(FIND "${load_output}" "\"frames\":2" load_frames_index)
|
||||
string(FIND "${load_output}" "\"layerNames\":[\"Base\",\"Paint\"]" load_names_index)
|
||||
string(FIND "${load_output}" "\"layerFrameCounts\":[2,1]" load_frame_counts_index)
|
||||
string(FIND "${load_output}" "\"layerDurationsMs\":[350,333]" load_durations_index)
|
||||
if(load_command_index LESS 0
|
||||
OR load_pixels_index LESS 0
|
||||
OR load_payload_index LESS 0
|
||||
OR load_layers_index LESS 0
|
||||
OR load_frames_index LESS 0
|
||||
OR load_names_index LESS 0
|
||||
OR load_frame_counts_index LESS 0
|
||||
OR load_durations_index LESS 0)
|
||||
message(FATAL_ERROR "load-project output did not contain expected document export summary: ${load_output}")
|
||||
endif()
|
||||
@@ -51,6 +51,12 @@ struct SaveProjectArgs {
|
||||
std::uint32_t payload_frame = 0;
|
||||
};
|
||||
|
||||
struct SaveDocumentProjectArgs {
|
||||
std::string path;
|
||||
std::uint32_t width = 64;
|
||||
std::uint32_t height = 32;
|
||||
};
|
||||
|
||||
struct InspectImageArgs {
|
||||
std::string path;
|
||||
};
|
||||
@@ -214,6 +220,7 @@ void print_help()
|
||||
<< " load-project --path FILE\n"
|
||||
<< " parse-layout --path FILE\n"
|
||||
<< " record-render [--width N] [--height N]\n"
|
||||
<< " save-document-project --path FILE [--width N] [--height N]\n"
|
||||
<< " save-project --path FILE --width N --height N [--layer-name NAME] [--layer-opacity N] [--blend-mode N] [--alpha-locked] [--hidden] [--layers N] [--frames N] [--frame-duration-ms N] [--include-test-face-payload] [--payload-layer N] [--payload-frame N]\n"
|
||||
<< " simulate-document-edits [--width N] [--height N]\n"
|
||||
<< " simulate-document-export [--width N] [--height N]\n"
|
||||
@@ -321,6 +328,175 @@ int create_document(int argc, char** argv)
|
||||
return 0;
|
||||
}
|
||||
|
||||
pp::foundation::Result<pp::document::CanvasDocument> create_export_sample_document(
|
||||
std::uint32_t width,
|
||||
std::uint32_t height)
|
||||
{
|
||||
const std::vector<std::uint8_t> red_pixel { 255, 0, 0, 255 };
|
||||
const std::vector<std::uint8_t> blue_pixel { 0, 0, 255, 128 };
|
||||
const pp::document::AnimationFrame root_frames[] {
|
||||
{ .duration_ms = 100, .face_pixels = {} },
|
||||
{ .duration_ms = 250, .face_pixels = {} },
|
||||
};
|
||||
const pp::document::AnimationFrame base_frames[] {
|
||||
{
|
||||
.duration_ms = 100,
|
||||
.face_pixels = {
|
||||
pp::document::LayerFacePixels {
|
||||
.face_index = 0,
|
||||
.x = 2,
|
||||
.y = 3,
|
||||
.width = 1,
|
||||
.height = 1,
|
||||
.rgba8 = red_pixel,
|
||||
},
|
||||
},
|
||||
},
|
||||
{ .duration_ms = 250, .face_pixels = {} },
|
||||
};
|
||||
const pp::document::AnimationFrame paint_frames[] {
|
||||
{
|
||||
.duration_ms = 333,
|
||||
.face_pixels = {
|
||||
pp::document::LayerFacePixels {
|
||||
.face_index = 5,
|
||||
.x = 4,
|
||||
.y = 5,
|
||||
.width = 1,
|
||||
.height = 1,
|
||||
.rgba8 = blue_pixel,
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
const pp::document::DocumentLayerConfig layers[] {
|
||||
{
|
||||
.name = "Base",
|
||||
.visible = true,
|
||||
.alpha_locked = false,
|
||||
.opacity = 1.0F,
|
||||
.blend_mode = pp::paint::BlendMode::normal,
|
||||
.frames = std::span<const pp::document::AnimationFrame>(base_frames, 2),
|
||||
},
|
||||
{
|
||||
.name = "Paint",
|
||||
.visible = false,
|
||||
.alpha_locked = true,
|
||||
.opacity = 0.5F,
|
||||
.blend_mode = pp::paint::BlendMode::overlay,
|
||||
.frames = std::span<const pp::document::AnimationFrame>(paint_frames, 1),
|
||||
},
|
||||
};
|
||||
|
||||
return pp::document::CanvasDocument::create_from_snapshot(
|
||||
pp::document::DocumentSnapshotConfig {
|
||||
.width = width,
|
||||
.height = height,
|
||||
.layers = std::span<const pp::document::DocumentLayerConfig>(layers, 2),
|
||||
.frames = std::span<const pp::document::AnimationFrame>(root_frames, 2),
|
||||
.selection_masks = {},
|
||||
});
|
||||
}
|
||||
|
||||
pp::foundation::Status parse_save_document_project_args(
|
||||
int argc,
|
||||
char** argv,
|
||||
SaveDocumentProjectArgs& args)
|
||||
{
|
||||
for (int i = 2; i < argc; ++i) {
|
||||
const std::string_view key(argv[i]);
|
||||
if (key == "--path") {
|
||||
if (i + 1 >= argc) {
|
||||
return pp::foundation::Status::invalid_argument("missing value for option");
|
||||
}
|
||||
args.path = argv[++i];
|
||||
} else if (key == "--width" || key == "--height") {
|
||||
if (i + 1 >= argc) {
|
||||
return pp::foundation::Status::invalid_argument("missing value for option");
|
||||
}
|
||||
|
||||
const auto value = pp::foundation::parse_u32(argv[++i]);
|
||||
if (!value) {
|
||||
return value.status();
|
||||
}
|
||||
|
||||
if (key == "--width") {
|
||||
args.width = value.value();
|
||||
} else {
|
||||
args.height = value.value();
|
||||
}
|
||||
} else {
|
||||
return pp::foundation::Status::invalid_argument("unknown option");
|
||||
}
|
||||
}
|
||||
|
||||
if (args.path.empty()) {
|
||||
return pp::foundation::Status::invalid_argument("path must not be empty");
|
||||
}
|
||||
|
||||
if (args.width < 8 || args.height < 8) {
|
||||
return pp::foundation::Status::out_of_range("width and height must be at least 8 for document export");
|
||||
}
|
||||
|
||||
return pp::foundation::Status::success();
|
||||
}
|
||||
|
||||
int save_document_project(int argc, char** argv)
|
||||
{
|
||||
SaveDocumentProjectArgs args;
|
||||
const auto status = parse_save_document_project_args(argc, argv, args);
|
||||
if (!status.ok()) {
|
||||
print_error("save-document-project", status.message);
|
||||
return 2;
|
||||
}
|
||||
|
||||
const auto document = create_export_sample_document(args.width, args.height);
|
||||
if (!document) {
|
||||
print_error("save-document-project", document.status().message);
|
||||
return 2;
|
||||
}
|
||||
|
||||
const auto exported = pp::document::export_ppi_project_document(document.value());
|
||||
if (!exported) {
|
||||
print_error("save-document-project", exported.status().message);
|
||||
return 2;
|
||||
}
|
||||
|
||||
std::ofstream stream(args.path, std::ios::binary);
|
||||
if (!stream) {
|
||||
print_error("save-document-project", "project file could not be opened for writing");
|
||||
return 2;
|
||||
}
|
||||
|
||||
const auto& bytes = exported.value();
|
||||
stream.write(reinterpret_cast<const char*>(bytes.data()), static_cast<std::streamsize>(bytes.size()));
|
||||
if (!stream) {
|
||||
print_error("save-document-project", "project file could not be written");
|
||||
return 2;
|
||||
}
|
||||
|
||||
const auto decoded = pp::assets::decode_ppi_project_images(bytes);
|
||||
if (!decoded) {
|
||||
print_error("save-document-project", decoded.status().message);
|
||||
return 2;
|
||||
}
|
||||
|
||||
std::cout << "{\"ok\":true,\"command\":\"save-document-project\""
|
||||
<< ",\"path\":\"" << json_escape(args.path) << "\""
|
||||
<< ",\"format\":\"ppi\""
|
||||
<< ",\"bytes\":" << bytes.size()
|
||||
<< ",\"document\":{\"width\":" << document.value().width()
|
||||
<< ",\"height\":" << document.value().height()
|
||||
<< ",\"layers\":" << document.value().layers().size()
|
||||
<< ",\"frames\":" << document.value().frames().size()
|
||||
<< ",\"facePayloads\":" << document.value().face_pixel_payload_count()
|
||||
<< "},\"export\":{\"dirtyFaces\":" << decoded.value().project.body.summary.dirty_face_count
|
||||
<< ",\"rgbaFacePayloads\":" << decoded.value().project.body.summary.rgba_face_payload_count
|
||||
<< ",\"compressedBytes\":" << decoded.value().project.body.summary.compressed_face_bytes
|
||||
<< "}}\n";
|
||||
return 0;
|
||||
}
|
||||
|
||||
pp::foundation::Status parse_save_project_args(int argc, char** argv, SaveProjectArgs& args)
|
||||
{
|
||||
for (int i = 2; i < argc; ++i) {
|
||||
@@ -1518,70 +1694,7 @@ int simulate_document_export(int argc, char** argv)
|
||||
return 2;
|
||||
}
|
||||
|
||||
const std::vector<std::uint8_t> red_pixel { 255, 0, 0, 255 };
|
||||
const std::vector<std::uint8_t> blue_pixel { 0, 0, 255, 128 };
|
||||
const pp::document::AnimationFrame root_frames[] {
|
||||
{ .duration_ms = 100, .face_pixels = {} },
|
||||
{ .duration_ms = 250, .face_pixels = {} },
|
||||
};
|
||||
const pp::document::AnimationFrame base_frames[] {
|
||||
{
|
||||
.duration_ms = 100,
|
||||
.face_pixels = {
|
||||
pp::document::LayerFacePixels {
|
||||
.face_index = 0,
|
||||
.x = 2,
|
||||
.y = 3,
|
||||
.width = 1,
|
||||
.height = 1,
|
||||
.rgba8 = red_pixel,
|
||||
},
|
||||
},
|
||||
},
|
||||
{ .duration_ms = 250, .face_pixels = {} },
|
||||
};
|
||||
const pp::document::AnimationFrame paint_frames[] {
|
||||
{
|
||||
.duration_ms = 333,
|
||||
.face_pixels = {
|
||||
pp::document::LayerFacePixels {
|
||||
.face_index = 5,
|
||||
.x = 4,
|
||||
.y = 5,
|
||||
.width = 1,
|
||||
.height = 1,
|
||||
.rgba8 = blue_pixel,
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
const pp::document::DocumentLayerConfig layers[] {
|
||||
{
|
||||
.name = "Base",
|
||||
.visible = true,
|
||||
.alpha_locked = false,
|
||||
.opacity = 1.0F,
|
||||
.blend_mode = pp::paint::BlendMode::normal,
|
||||
.frames = std::span<const pp::document::AnimationFrame>(base_frames, 2),
|
||||
},
|
||||
{
|
||||
.name = "Paint",
|
||||
.visible = false,
|
||||
.alpha_locked = true,
|
||||
.opacity = 0.5F,
|
||||
.blend_mode = pp::paint::BlendMode::overlay,
|
||||
.frames = std::span<const pp::document::AnimationFrame>(paint_frames, 1),
|
||||
},
|
||||
};
|
||||
|
||||
const auto document_result = pp::document::CanvasDocument::create_from_snapshot(
|
||||
pp::document::DocumentSnapshotConfig {
|
||||
.width = args.width,
|
||||
.height = args.height,
|
||||
.layers = std::span<const pp::document::DocumentLayerConfig>(layers, 2),
|
||||
.frames = std::span<const pp::document::AnimationFrame>(root_frames, 2),
|
||||
.selection_masks = {},
|
||||
});
|
||||
const auto document_result = create_export_sample_document(args.width, args.height);
|
||||
if (!document_result) {
|
||||
print_error("simulate-document-export", document_result.status().message);
|
||||
return 2;
|
||||
@@ -2030,6 +2143,10 @@ int main(int argc, char** argv)
|
||||
return record_render(argc, argv);
|
||||
}
|
||||
|
||||
if (command == "save-document-project") {
|
||||
return save_document_project(argc, argv);
|
||||
}
|
||||
|
||||
if (command == "save-project") {
|
||||
return save_project(argc, argv);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user