Add explicit PPI project writer
This commit is contained in:
@@ -120,11 +120,12 @@ Known local toolchain state:
|
||||
frame counts, durations, and decoded face-pixel payloads when present; the
|
||||
metadata-only minimal fixture remains covered by
|
||||
`pano_cli_load_project_metadata_smoke`.
|
||||
- `pano_cli save-project` writes generated multi-layer, multi-frame PPI files
|
||||
with configurable layer opacity, blend mode, alpha lock, and visibility
|
||||
through `pp_assets`; test dirty-face payloads can target explicit generated
|
||||
layer/frame slots. It is covered by `pano_cli_save_project_roundtrip_smoke`
|
||||
and `pano_cli_save_project_payload_roundtrip_smoke`, which reload generated
|
||||
- `pp_assets::create_ppi_project` writes generated multi-layer, multi-frame
|
||||
PPI files with explicit per-layer names, opacity, blend mode, alpha lock,
|
||||
visibility, per-layer frame durations, and targeted dirty-face layer/frame
|
||||
payloads. `pano_cli save-project` exposes that path for automation and is
|
||||
covered by `pano_cli_save_project_roundtrip_smoke` and
|
||||
`pano_cli_save_project_payload_roundtrip_smoke`, which reload generated
|
||||
metadata-only and targeted dirty-face-payload projects through
|
||||
`pano_cli load-project`.
|
||||
- `pano_cli create-document` supports `--frames` and `--frame-duration-ms` and
|
||||
|
||||
@@ -31,7 +31,7 @@ agent or engineer to remove them without reconstructing context from chat.
|
||||
| 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, and renderer-free alpha8 selection-mask storage, but it is not yet wired to legacy `Canvas`, 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_ppi_import_tests`; `pano_cli_simulate_document_edits_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`, `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 layer opacity/blend/alpha-lock/visibility metadata, 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, 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`; `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` | 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`, `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, 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`; `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` | 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
|
||||
|
||||
@@ -344,11 +344,11 @@ asset-level decode coverage, and
|
||||
`pano_cli load-project` creates a `pp_document` projection with per-layer frame
|
||||
counts, durations, and decoded face-pixel payload attachment when PPI image
|
||||
payloads are present.
|
||||
`pano_cli save-project` writes generated multi-layer, multi-frame PPI files
|
||||
with layer opacity, blend mode, alpha lock, and visibility metadata through the
|
||||
extracted `pp_assets` writer and round-trips metadata-only and test
|
||||
dirty-face-payload variants through `load-project`; dirty-face payloads can be
|
||||
targeted to explicit generated layer/frame slots for animation coverage.
|
||||
`pp_assets` can write generated PPI projects with explicit per-layer names,
|
||||
visibility, opacity, blend mode, alpha lock, per-layer frame durations, and
|
||||
dirty-face payloads targeted to layer/frame/face slots. `pano_cli save-project`
|
||||
exposes the generated writer for metadata-only and test dirty-face-payload
|
||||
round-trips through `load-project`.
|
||||
`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
|
||||
@@ -680,9 +680,10 @@ Results:
|
||||
- `pp_assets_image_pixels_tests` passed, including RGBA8 PNG decode and corrupt
|
||||
payload rejection.
|
||||
- `pp_assets_ppi_header_tests` passed, including PPI thumbnail/body layout,
|
||||
body summary validation, layer/frame indexing, dirty-face PNG payload
|
||||
metadata validation, targeted layer/frame dirty-face writing, and decoded
|
||||
dirty-face payload coverage.
|
||||
body summary validation, layer/frame indexing, explicit per-layer metadata
|
||||
and per-layer frame duration writing, dirty-face PNG payload metadata
|
||||
validation, targeted layer/frame dirty-face writing, and decoded dirty-face
|
||||
payload coverage.
|
||||
- `pp_assets_settings_document_tests` passed.
|
||||
- `pp_paint_brush_tests` passed.
|
||||
- `pp_paint_blend_tests` passed.
|
||||
@@ -801,6 +802,8 @@ Results:
|
||||
through JSON automation and is covered by metadata-only and
|
||||
dirty-face-payload save/load round-trip smoke tests. Full legacy canvas save
|
||||
parity remains tracked by DEBT-0013.
|
||||
- `pp_assets::create_ppi_project` exposes the underlying generated PPI writer
|
||||
for non-uniform layer metadata and frame-duration extraction work.
|
||||
- PowerShell package-smoke wrapper validates the Windows CMake app executable
|
||||
and runtime `data/` copy.
|
||||
- Android arm64 configured with NDK 29.0.14206865 through the platform-build
|
||||
|
||||
@@ -651,71 +651,72 @@ pp::foundation::Result<PpiDecodedProjectImages> decode_ppi_project_images(std::s
|
||||
return pp::foundation::Result<PpiDecodedProjectImages>::success(std::move(decoded));
|
||||
}
|
||||
|
||||
pp::foundation::Result<std::vector<std::byte>> create_minimal_ppi_project(PpiMinimalProjectConfig config)
|
||||
pp::foundation::Result<std::vector<std::byte>> create_ppi_project(PpiProjectConfig config)
|
||||
{
|
||||
const auto canvas_status = validate_canvas_size(config.width, config.height);
|
||||
if (!canvas_status.ok()) {
|
||||
return pp::foundation::Result<std::vector<std::byte>>::failure(canvas_status);
|
||||
}
|
||||
|
||||
if (config.layer_name.empty()) {
|
||||
return pp::foundation::Result<std::vector<std::byte>>::failure(
|
||||
pp::foundation::Status::invalid_argument("PPI layer name must not be empty"));
|
||||
}
|
||||
|
||||
if (config.layer_name.size() > max_ppi_layer_name_length) {
|
||||
return pp::foundation::Result<std::vector<std::byte>>::failure(
|
||||
pp::foundation::Status::out_of_range("PPI layer name exceeds the configured limit"));
|
||||
}
|
||||
|
||||
if (config.layer_metadata.opacity < 0.0F || config.layer_metadata.opacity > 1.0F) {
|
||||
return pp::foundation::Result<std::vector<std::byte>>::failure(
|
||||
pp::foundation::Status::out_of_range("PPI layer opacity is outside the supported range"));
|
||||
}
|
||||
|
||||
if (config.layer_metadata.blend_mode > 4U) {
|
||||
return pp::foundation::Result<std::vector<std::byte>>::failure(
|
||||
pp::foundation::Status::out_of_range("PPI layer blend mode is outside the supported range"));
|
||||
}
|
||||
|
||||
if (config.layer_count == 0 || config.layer_count > max_ppi_layer_count) {
|
||||
if (config.layers.empty() || config.layers.size() > max_ppi_layer_count) {
|
||||
return pp::foundation::Result<std::vector<std::byte>>::failure(
|
||||
pp::foundation::Status::out_of_range("PPI layer count is outside the configured range"));
|
||||
}
|
||||
|
||||
if (config.frame_duration_ms == 0) {
|
||||
return pp::foundation::Result<std::vector<std::byte>>::failure(
|
||||
pp::foundation::Status::invalid_argument("PPI frame duration must be greater than zero"));
|
||||
}
|
||||
|
||||
if (config.frame_count == 0 || config.frame_count > max_ppi_frame_count) {
|
||||
return pp::foundation::Result<std::vector<std::byte>>::failure(
|
||||
pp::foundation::Status::out_of_range("PPI frame count is outside the configured range"));
|
||||
}
|
||||
|
||||
if (config.layer_count > max_ppi_frame_count / config.frame_count) {
|
||||
return pp::foundation::Result<std::vector<std::byte>>::failure(
|
||||
pp::foundation::Status::out_of_range("PPI total layer frame count exceeds the configured range"));
|
||||
}
|
||||
|
||||
for (std::uint32_t layer = 0; layer < config.layer_count; ++layer) {
|
||||
const auto name = generated_layer_name(config.layer_name, layer, config.layer_count);
|
||||
if (name.size() > max_ppi_layer_name_length) {
|
||||
std::uint32_t total_frame_count = 0;
|
||||
std::vector<std::size_t> layer_frame_offsets;
|
||||
layer_frame_offsets.reserve(config.layers.size());
|
||||
for (const auto& layer : config.layers) {
|
||||
if (layer.name.empty()) {
|
||||
return pp::foundation::Result<std::vector<std::byte>>::failure(
|
||||
pp::foundation::Status::out_of_range("PPI generated layer name exceeds the configured limit"));
|
||||
pp::foundation::Status::invalid_argument("PPI layer name must not be empty"));
|
||||
}
|
||||
|
||||
if (layer.name.size() > max_ppi_layer_name_length) {
|
||||
return pp::foundation::Result<std::vector<std::byte>>::failure(
|
||||
pp::foundation::Status::out_of_range("PPI layer name exceeds the configured limit"));
|
||||
}
|
||||
|
||||
if (layer.metadata.opacity < 0.0F || layer.metadata.opacity > 1.0F) {
|
||||
return pp::foundation::Result<std::vector<std::byte>>::failure(
|
||||
pp::foundation::Status::out_of_range("PPI layer opacity is outside the supported range"));
|
||||
}
|
||||
|
||||
if (layer.metadata.blend_mode > 4U) {
|
||||
return pp::foundation::Result<std::vector<std::byte>>::failure(
|
||||
pp::foundation::Status::out_of_range("PPI layer blend mode is outside the supported range"));
|
||||
}
|
||||
|
||||
if (layer.frames.empty() || layer.frames.size() > max_ppi_frame_count) {
|
||||
return pp::foundation::Result<std::vector<std::byte>>::failure(
|
||||
pp::foundation::Status::out_of_range("PPI layer frame count is outside the configured range"));
|
||||
}
|
||||
|
||||
if (layer.frames.size() > max_ppi_frame_count - total_frame_count) {
|
||||
return pp::foundation::Result<std::vector<std::byte>>::failure(
|
||||
pp::foundation::Status::out_of_range("PPI total layer frame count exceeds the configured range"));
|
||||
}
|
||||
|
||||
layer_frame_offsets.push_back(total_frame_count);
|
||||
total_frame_count += static_cast<std::uint32_t>(layer.frames.size());
|
||||
|
||||
for (const auto& frame : layer.frames) {
|
||||
if (frame.duration_ms == 0) {
|
||||
return pp::foundation::Result<std::vector<std::byte>>::failure(
|
||||
pp::foundation::Status::invalid_argument("PPI frame duration must be greater than zero"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<std::array<bool, 6>> seen_faces(
|
||||
static_cast<std::size_t>(config.layer_count) * static_cast<std::size_t>(config.frame_count));
|
||||
std::vector<std::array<bool, 6>> seen_faces(total_frame_count);
|
||||
std::uint64_t total_payload_bytes = 0;
|
||||
for (const auto& face : config.dirty_faces) {
|
||||
if (face.layer_index >= config.layer_count) {
|
||||
if (face.layer_index >= config.layers.size()) {
|
||||
return pp::foundation::Result<std::vector<std::byte>>::failure(
|
||||
pp::foundation::Status::out_of_range("PPI dirty face layer index is outside the layer list"));
|
||||
}
|
||||
|
||||
if (face.frame_index >= config.frame_count) {
|
||||
if (face.frame_index >= config.layers[face.layer_index].frames.size()) {
|
||||
return pp::foundation::Result<std::vector<std::byte>>::failure(
|
||||
pp::foundation::Status::out_of_range("PPI dirty face frame index is outside the frame list"));
|
||||
}
|
||||
@@ -725,9 +726,7 @@ pp::foundation::Result<std::vector<std::byte>> create_minimal_ppi_project(PpiMin
|
||||
pp::foundation::Status::out_of_range("PPI dirty face index is outside the cube face list"));
|
||||
}
|
||||
|
||||
const auto slot_index =
|
||||
static_cast<std::size_t>(face.layer_index) * static_cast<std::size_t>(config.frame_count)
|
||||
+ static_cast<std::size_t>(face.frame_index);
|
||||
const auto slot_index = layer_frame_offsets[face.layer_index] + static_cast<std::size_t>(face.frame_index);
|
||||
if (seen_faces[slot_index][face.face_index]) {
|
||||
return pp::foundation::Result<std::vector<std::byte>>::failure(
|
||||
pp::foundation::Status::invalid_argument("PPI dirty face slot is duplicated"));
|
||||
@@ -789,20 +788,20 @@ pp::foundation::Result<std::vector<std::byte>> create_minimal_ppi_project(PpiMin
|
||||
|
||||
append_u32(bytes, config.width);
|
||||
append_u32(bytes, config.height);
|
||||
append_u32(bytes, config.layer_count);
|
||||
append_u32(bytes, config.layer_count * config.frame_count);
|
||||
for (std::uint32_t layer = 0; layer < config.layer_count; ++layer) {
|
||||
const auto name = generated_layer_name(config.layer_name, layer, config.layer_count);
|
||||
append_u32(bytes, static_cast<std::uint32_t>(config.layers.size()));
|
||||
append_u32(bytes, total_frame_count);
|
||||
for (std::uint32_t layer = 0; layer < config.layers.size(); ++layer) {
|
||||
const auto& layer_config = config.layers[layer];
|
||||
append_u32(bytes, layer);
|
||||
append_f32(bytes, config.layer_metadata.opacity);
|
||||
append_u32(bytes, static_cast<std::uint32_t>(name.size()));
|
||||
append_ascii(bytes, name);
|
||||
append_u32(bytes, config.layer_metadata.blend_mode);
|
||||
bytes.push_back(config.layer_metadata.alpha_locked ? std::byte { 1 } : std::byte { 0 });
|
||||
bytes.push_back(config.layer_metadata.visible ? std::byte { 1 } : std::byte { 0 });
|
||||
append_u32(bytes, config.frame_count);
|
||||
for (std::uint32_t frame = 0; frame < config.frame_count; ++frame) {
|
||||
append_u32(bytes, config.frame_duration_ms);
|
||||
append_f32(bytes, layer_config.metadata.opacity);
|
||||
append_u32(bytes, static_cast<std::uint32_t>(layer_config.name.size()));
|
||||
append_ascii(bytes, layer_config.name);
|
||||
append_u32(bytes, layer_config.metadata.blend_mode);
|
||||
bytes.push_back(layer_config.metadata.alpha_locked ? std::byte { 1 } : std::byte { 0 });
|
||||
bytes.push_back(layer_config.metadata.visible ? std::byte { 1 } : std::byte { 0 });
|
||||
append_u32(bytes, static_cast<std::uint32_t>(layer_config.frames.size()));
|
||||
for (std::uint32_t frame = 0; frame < layer_config.frames.size(); ++frame) {
|
||||
append_u32(bytes, layer_config.frames[frame].duration_ms);
|
||||
for (std::uint32_t face = 0; face < 6U; ++face) {
|
||||
const PpiDirtyFacePayloadConfig* dirty_face = nullptr;
|
||||
for (const auto& candidate : config.dirty_faces) {
|
||||
@@ -833,4 +832,41 @@ pp::foundation::Result<std::vector<std::byte>> create_minimal_ppi_project(PpiMin
|
||||
return pp::foundation::Result<std::vector<std::byte>>::success(std::move(bytes));
|
||||
}
|
||||
|
||||
pp::foundation::Result<std::vector<std::byte>> create_minimal_ppi_project(PpiMinimalProjectConfig config)
|
||||
{
|
||||
if (config.layer_count == 0 || config.layer_count > max_ppi_layer_count) {
|
||||
return pp::foundation::Result<std::vector<std::byte>>::failure(
|
||||
pp::foundation::Status::out_of_range("PPI layer count is outside the configured range"));
|
||||
}
|
||||
|
||||
if (config.frame_count == 0 || config.frame_count > max_ppi_frame_count) {
|
||||
return pp::foundation::Result<std::vector<std::byte>>::failure(
|
||||
pp::foundation::Status::out_of_range("PPI frame count is outside the configured range"));
|
||||
}
|
||||
|
||||
std::vector<std::string> names;
|
||||
names.reserve(config.layer_count);
|
||||
std::vector<std::vector<PpiFrameConfig>> frame_lists;
|
||||
frame_lists.reserve(config.layer_count);
|
||||
std::vector<PpiLayerConfig> layers;
|
||||
layers.reserve(config.layer_count);
|
||||
for (std::uint32_t layer = 0; layer < config.layer_count; ++layer) {
|
||||
names.push_back(generated_layer_name(config.layer_name, layer, config.layer_count));
|
||||
auto& frames = frame_lists.emplace_back();
|
||||
frames.assign(config.frame_count, PpiFrameConfig { .duration_ms = config.frame_duration_ms });
|
||||
layers.push_back(PpiLayerConfig {
|
||||
.name = names.back(),
|
||||
.metadata = config.layer_metadata,
|
||||
.frames = std::span<const PpiFrameConfig>(frames.data(), frames.size()),
|
||||
});
|
||||
}
|
||||
|
||||
return create_ppi_project(PpiProjectConfig {
|
||||
.width = config.width,
|
||||
.height = config.height,
|
||||
.layers = std::span<const PpiLayerConfig>(layers.data(), layers.size()),
|
||||
.dirty_faces = config.dirty_faces,
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#include <cstdint>
|
||||
#include <span>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <vector>
|
||||
|
||||
namespace pp::assets {
|
||||
@@ -136,6 +137,23 @@ struct PpiLayerMetadataConfig {
|
||||
bool visible = true;
|
||||
};
|
||||
|
||||
struct PpiFrameConfig {
|
||||
std::uint32_t duration_ms = 100;
|
||||
};
|
||||
|
||||
struct PpiLayerConfig {
|
||||
std::string_view name;
|
||||
PpiLayerMetadataConfig metadata;
|
||||
std::span<const PpiFrameConfig> frames;
|
||||
};
|
||||
|
||||
struct PpiProjectConfig {
|
||||
std::uint32_t width = 0;
|
||||
std::uint32_t height = 0;
|
||||
std::span<const PpiLayerConfig> layers;
|
||||
std::span<const PpiDirtyFacePayloadConfig> dirty_faces;
|
||||
};
|
||||
|
||||
struct PpiMinimalProjectConfig {
|
||||
std::uint32_t width = 0;
|
||||
std::uint32_t height = 0;
|
||||
@@ -172,6 +190,9 @@ struct PpiMinimalProjectConfig {
|
||||
[[nodiscard]] pp::foundation::Result<PpiDecodedProjectImages> decode_ppi_project_images(
|
||||
std::span<const std::byte> bytes);
|
||||
|
||||
[[nodiscard]] pp::foundation::Result<std::vector<std::byte>> create_ppi_project(
|
||||
PpiProjectConfig config);
|
||||
|
||||
[[nodiscard]] pp::foundation::Result<std::vector<std::byte>> create_minimal_ppi_project(
|
||||
PpiMinimalProjectConfig config);
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#include <vector>
|
||||
|
||||
using pp::assets::parse_ppi_header;
|
||||
using pp::assets::create_ppi_project;
|
||||
using pp::assets::create_minimal_ppi_project;
|
||||
using pp::assets::decode_ppi_project_images;
|
||||
using pp::assets::parse_ppi_project_index;
|
||||
@@ -481,6 +482,64 @@ void creates_minimal_project_with_multiple_frames(pp::tests::Harness& h)
|
||||
PP_EXPECT(h, index.value().body.layers[0].frames[2].duration_ms == 111U);
|
||||
}
|
||||
|
||||
void creates_explicit_project_with_layer_frame_metadata(pp::tests::Harness& h)
|
||||
{
|
||||
const pp::assets::PpiFrameConfig base_frames[] {
|
||||
{ .duration_ms = 100 },
|
||||
{ .duration_ms = 250 },
|
||||
};
|
||||
const pp::assets::PpiFrameConfig paint_frames[] {
|
||||
{ .duration_ms = 333 },
|
||||
};
|
||||
const pp::assets::PpiLayerConfig layers[] {
|
||||
{
|
||||
.name = "Base",
|
||||
.metadata = pp::assets::PpiLayerMetadataConfig {
|
||||
.opacity = 1.0F,
|
||||
.blend_mode = 0,
|
||||
.alpha_locked = false,
|
||||
.visible = true,
|
||||
},
|
||||
.frames = std::span<const pp::assets::PpiFrameConfig>(base_frames, 2),
|
||||
},
|
||||
{
|
||||
.name = "Paint",
|
||||
.metadata = pp::assets::PpiLayerMetadataConfig {
|
||||
.opacity = 0.5F,
|
||||
.blend_mode = 4,
|
||||
.alpha_locked = true,
|
||||
.visible = false,
|
||||
},
|
||||
.frames = std::span<const pp::assets::PpiFrameConfig>(paint_frames, 1),
|
||||
},
|
||||
};
|
||||
|
||||
const auto project = create_ppi_project(pp::assets::PpiProjectConfig {
|
||||
.width = 256,
|
||||
.height = 128,
|
||||
.layers = std::span<const pp::assets::PpiLayerConfig>(layers, 2),
|
||||
.dirty_faces = {},
|
||||
});
|
||||
|
||||
PP_EXPECT(h, project.ok());
|
||||
const auto index = parse_ppi_project_index(project.value());
|
||||
PP_EXPECT(h, index.ok());
|
||||
PP_EXPECT(h, index.value().body.summary.layer_count == 2U);
|
||||
PP_EXPECT(h, index.value().body.summary.declared_frame_count == 3U);
|
||||
PP_EXPECT(h, index.value().body.summary.total_layer_frames == 3U);
|
||||
PP_EXPECT(h, index.value().body.layers[0].name == "Base");
|
||||
PP_EXPECT(h, index.value().body.layers[0].frames.size() == 2U);
|
||||
PP_EXPECT(h, index.value().body.layers[0].frames[0].duration_ms == 100U);
|
||||
PP_EXPECT(h, index.value().body.layers[0].frames[1].duration_ms == 250U);
|
||||
PP_EXPECT(h, index.value().body.layers[1].name == "Paint");
|
||||
PP_EXPECT(h, index.value().body.layers[1].opacity == 0.5F);
|
||||
PP_EXPECT(h, index.value().body.layers[1].blend_mode == 4U);
|
||||
PP_EXPECT(h, index.value().body.layers[1].alpha_locked);
|
||||
PP_EXPECT(h, !index.value().body.layers[1].visible);
|
||||
PP_EXPECT(h, index.value().body.layers[1].frames.size() == 1U);
|
||||
PP_EXPECT(h, index.value().body.layers[1].frames[0].duration_ms == 333U);
|
||||
}
|
||||
|
||||
void creates_minimal_project_with_dirty_face_payload(pp::tests::Harness& h)
|
||||
{
|
||||
const auto png_payload = transparent_png_1x1();
|
||||
@@ -749,6 +808,71 @@ void rejects_invalid_minimal_project_writer_inputs(pp::tests::Harness& h)
|
||||
PP_EXPECT(h, bad_frame_dirty_face.status().code == StatusCode::out_of_range);
|
||||
}
|
||||
|
||||
void rejects_invalid_explicit_project_writer_inputs(pp::tests::Harness& h)
|
||||
{
|
||||
const pp::assets::PpiFrameConfig valid_frames[] {
|
||||
{ .duration_ms = 100 },
|
||||
};
|
||||
const pp::assets::PpiFrameConfig invalid_frames[] {
|
||||
{ .duration_ms = 0 },
|
||||
};
|
||||
const pp::assets::PpiLayerConfig unnamed_layers[] {
|
||||
{
|
||||
.name = "",
|
||||
.metadata = {},
|
||||
.frames = std::span<const pp::assets::PpiFrameConfig>(valid_frames, 1),
|
||||
},
|
||||
};
|
||||
const pp::assets::PpiLayerConfig frameless_layers[] {
|
||||
{
|
||||
.name = "Ink",
|
||||
.metadata = {},
|
||||
.frames = {},
|
||||
},
|
||||
};
|
||||
const pp::assets::PpiLayerConfig invalid_duration_layers[] {
|
||||
{
|
||||
.name = "Ink",
|
||||
.metadata = {},
|
||||
.frames = std::span<const pp::assets::PpiFrameConfig>(invalid_frames, 1),
|
||||
},
|
||||
};
|
||||
|
||||
const auto no_layers = create_ppi_project(pp::assets::PpiProjectConfig {
|
||||
.width = 128,
|
||||
.height = 64,
|
||||
.layers = {},
|
||||
.dirty_faces = {},
|
||||
});
|
||||
const auto unnamed = create_ppi_project(pp::assets::PpiProjectConfig {
|
||||
.width = 128,
|
||||
.height = 64,
|
||||
.layers = std::span<const pp::assets::PpiLayerConfig>(unnamed_layers, 1),
|
||||
.dirty_faces = {},
|
||||
});
|
||||
const auto frameless = create_ppi_project(pp::assets::PpiProjectConfig {
|
||||
.width = 128,
|
||||
.height = 64,
|
||||
.layers = std::span<const pp::assets::PpiLayerConfig>(frameless_layers, 1),
|
||||
.dirty_faces = {},
|
||||
});
|
||||
const auto invalid_duration = create_ppi_project(pp::assets::PpiProjectConfig {
|
||||
.width = 128,
|
||||
.height = 64,
|
||||
.layers = std::span<const pp::assets::PpiLayerConfig>(invalid_duration_layers, 1),
|
||||
.dirty_faces = {},
|
||||
});
|
||||
|
||||
PP_EXPECT(h, !no_layers.ok());
|
||||
PP_EXPECT(h, no_layers.status().code == StatusCode::out_of_range);
|
||||
PP_EXPECT(h, !unnamed.ok());
|
||||
PP_EXPECT(h, unnamed.status().code == StatusCode::invalid_argument);
|
||||
PP_EXPECT(h, !frameless.ok());
|
||||
PP_EXPECT(h, frameless.status().code == StatusCode::out_of_range);
|
||||
PP_EXPECT(h, !invalid_duration.ok());
|
||||
PP_EXPECT(h, invalid_duration.status().code == StatusCode::invalid_argument);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
int main()
|
||||
@@ -769,8 +893,10 @@ int main()
|
||||
harness.run("creates_minimal_project_for_roundtrip_load", creates_minimal_project_for_roundtrip_load);
|
||||
harness.run("creates_minimal_project_with_multiple_layers", creates_minimal_project_with_multiple_layers);
|
||||
harness.run("creates_minimal_project_with_multiple_frames", creates_minimal_project_with_multiple_frames);
|
||||
harness.run("creates_explicit_project_with_layer_frame_metadata", creates_explicit_project_with_layer_frame_metadata);
|
||||
harness.run("creates_minimal_project_with_dirty_face_payload", creates_minimal_project_with_dirty_face_payload);
|
||||
harness.run("creates_minimal_project_with_targeted_dirty_face_payloads", creates_minimal_project_with_targeted_dirty_face_payloads);
|
||||
harness.run("rejects_invalid_minimal_project_writer_inputs", rejects_invalid_minimal_project_writer_inputs);
|
||||
harness.run("rejects_invalid_explicit_project_writer_inputs", rejects_invalid_explicit_project_writer_inputs);
|
||||
return harness.finish();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user