Add document face compositor bridge
This commit is contained in:
@@ -210,6 +210,7 @@ target_include_directories(pp_paint_renderer
|
||||
target_link_libraries(pp_paint_renderer
|
||||
PUBLIC
|
||||
pp_foundation
|
||||
pp_document
|
||||
pp_paint
|
||||
pp_renderer_api
|
||||
pp_project_options
|
||||
|
||||
@@ -247,6 +247,10 @@ powershell -ExecutionPolicy Bypass -File scripts\automation\apple-remote-build.p
|
||||
- `pp_document_ppi_export_tests` exports pure `pp_document` metadata,
|
||||
per-layer frame durations, and RGBA8 face payloads to PPI bytes through
|
||||
`pp_assets`, then decodes and reimports them for round-trip coverage.
|
||||
- `pp_paint_renderer_compositor_tests` now covers pure `pp_document` frame/face
|
||||
compositing by expanding per-layer dirty face payload rectangles into a full
|
||||
renderer-sized RGBA buffer with layer visibility, opacity, and blend mode
|
||||
applied in document order.
|
||||
- `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`.
|
||||
|
||||
@@ -38,7 +38,7 @@ and validation command.
|
||||
| PPBR import/export | brush panel/dialog | `pp_assets`, `pp_panopainter_ui` | Round-trip fixture |
|
||||
| Stroke sampling | `Stroke`, `Canvas` | `pp_paint` | Property tests for spacing, pressure, jitter |
|
||||
| Dual brush/pattern behavior | `Brush`, shaders | `pp_paint`, `pp_paint_renderer` | Stroke-alpha CPU reference, dual/pattern feedback planning, GPU golden |
|
||||
| Blend modes | GLSL include files, layer rendering | `pp_paint`, `pp_paint_renderer` | Final RGBA and stroke-alpha CPU reference vectors, fixed-function/framebuffer-fetch/ping-pong stroke composite planning, live `Canvas`/`NodeCanvas` blend-gate coverage, live canvas stroke/thumbnail/brush-preview destination-copy coverage, and GPU parity |
|
||||
| Blend modes | GLSL include files, layer rendering | `pp_paint`, `pp_paint_renderer` | Final RGBA and stroke-alpha CPU reference vectors, pure `pp_document` frame/face compositing, fixed-function/framebuffer-fetch/ping-pong stroke composite planning, live `Canvas`/`NodeCanvas` blend-gate coverage, live canvas stroke/thumbnail/brush-preview destination-copy coverage, and GPU parity |
|
||||
| Erase/flood fill/masks | `Canvas`, modes, shaders | `pp_document`, `pp_paint_renderer` | Edge masks, alpha lock, dirty rects |
|
||||
|
||||
## Layers And Animation
|
||||
|
||||
@@ -439,6 +439,11 @@ agent or engineer to remove them without reconstructing context from chat.
|
||||
passes the configure-time CMake executable into `package-smoke.ps1`, so VS
|
||||
2026 generator validation does not depend on an older `cmake` on PATH, and
|
||||
the smoke checks cover the Windows launch-folder DLL payload.
|
||||
- 2026-06-05: DEBT-0010 was narrowed. `pp_paint_renderer` now consumes
|
||||
`pp_document` directly for pure frame/face compositing, expanding per-layer
|
||||
dirty face payload rectangles into a full renderer-sized RGBA buffer while
|
||||
preserving document layer visibility, opacity, blend mode, and uneven
|
||||
per-layer frame timelines.
|
||||
|
||||
## Open Debt
|
||||
|
||||
@@ -452,7 +457,7 @@ 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, and root CMake now exposes a focused `panopainter_platform_build_vcpkg_ui_core` target for the vcpkg-backed `pp_ui_core`/tinyxml2 boundary, 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 | `cmake --preset windows-msvc-vcpkg-headless`; `ctest --preset desktop-fast-vcpkg --build-config Debug`; `cmake --build --preset windows-msvc-default --config Debug --target panopainter_platform_build_vcpkg_ui_core` | 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` and `windows-msvc-vcpkg-headless` explicitly select Visual Studio 18 2026 for local validation, but non-VS2026 CMake executables on PATH may not know that generator | The local machine has VS 2026, but using an older CMake can still default to Ninja or reject the VS 2026 generator | `cmake --preset windows-msvc-default`; `cmake --build --preset windows-msvc-default --config Debug --target PanoPainter`; `ctest --preset desktop-fast --build-config Debug` | The repo automation invokes or locates a CMake executable that supports `Visual Studio 18 2026`, and VS 2026 generator validation is the normal Windows path without manual tool selection |
|
||||
| DEBT-0009 | Open | Modernization | Android root CMake validation currently builds headless targets only, while retained standard/Quest/Focus package CMake paths now have a refreshed CMake 3.10/C++23 baseline outside root CMake; automation queries `sdkmanager`, installs newer or missing SDK Manager NDK/CMake packages, selects the resulting pair before configure, and reports update decisions; root CMake exposes non-default platform-build and retained native package validation targets | 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`; `cmake --build --preset android-x64`; `cmake --build --preset android-quest-arm64`; `cmake --build --preset android-focus-arm64`; `cmake --build --preset windows-msvc-default --config Debug --target panopainter_platform_build_android_assets`; `powershell -ExecutionPolicy Bypass -File scripts\automation\android-legacy-package-build.ps1 -Packages standard`; `powershell -ExecutionPolicy Bypass -File scripts\automation\android-legacy-package-build.ps1 -Packages quest,focus -ConfigureOnly`; `powershell -ExecutionPolicy Bypass -File scripts\automation\package-smoke.ps1 -ReadinessOnly -AndroidNativeChecks -PackageKinds android-standard-apk,android-quest-apk,android-focus-apk`; `cmake --build --preset windows-msvc-default --config Debug --target panopainter_android_native_package_smoke` | 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, PPI import/export helpers, and stroke-script-to-face-payload CLI automation, 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`; `pano_cli_apply_stroke_script_roundtrip_smoke`; `pano_cli_apply_stroke_script_rejects_tiny_canvas` | 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, PPI import/export helpers, stroke-script-to-face-payload CLI automation, and a `pp_paint_renderer` document frame/face compositor, 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`; `pp_paint_renderer_compositor_tests`; `pano_cli_simulate_document_edits_smoke`; `pano_cli_simulate_document_export_smoke`; `pano_cli_save_document_project_roundtrip_smoke`; `pano_cli_apply_stroke_script_roundtrip_smoke`; `pano_cli_apply_stroke_script_rejects_tiny_canvas` | Legacy document behavior is represented by `pp_document`/`pp_paint_renderer` tests and the app consumes it through a boundary/facade |
|
||||
| DEBT-0011 | Open | Modernization | `package-smoke` validates the Windows CMake app artifact and launch-folder DLL payload, and reports a structured package readiness matrix for Windows AppX, Android standard/Quest/Focus APKs, Apple bundles, Linux app output, and WebGL output; the Windows app smoke passes the configure-time CMake executable so VS 2026 generator validation does not depend on `cmake` from PATH, retained Android package native CMake paths, and retained Linux/WebGL CMake baseline metadata are reachable from package validation and root CMake package-readiness targets, but Windows AppX/APK/Linux/Apple/WebGL package outputs are still `blocked` because root CMake package targets do not exist yet | 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`; `cmake --build --preset windows-msvc-default --config Debug --target panopainter_windows_app_package_smoke`; `powershell -ExecutionPolicy Bypass -File scripts\automation\package-smoke.ps1 -ReadinessOnly -AndroidNativeChecks -PackageKinds android-standard-apk,android-quest-apk,android-focus-apk`; `cmake --build --preset windows-msvc-default --config Debug --target panopainter_android_native_package_smoke`; `cmake --build --preset windows-msvc-default --config Debug --target panopainter_linux_webgl_package_readiness`; `python scripts/dev/check_package_smoke_readiness.py`; `bash -n scripts/automation/package-smoke.sh` | Package-smoke builds and validates Windows AppX, Android APK variants, Linux app, 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, file-writing document export automation, stroke-script-generated document payload export, 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`; `pano_cli_apply_stroke_script_roundtrip_smoke`; `pano_cli_apply_stroke_script_rejects_tiny_canvas` | 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 |
|
||||
|
||||
@@ -453,7 +453,9 @@ duplicate selection masks.
|
||||
`pp_renderer_api` has started with renderer-neutral
|
||||
texture/readback descriptors and validation tests. `pp_paint_renderer` has
|
||||
started with deterministic CPU layer compositing over renderer extents using
|
||||
the paint blend reference. `pp_ui_core` has started with XML-layout-facing
|
||||
the paint blend reference, and now exposes a pure `pp_document` face
|
||||
compositor that expands per-layer dirty face payload rectangles into a full
|
||||
renderer-sized RGBA buffer for a requested frame/face. `pp_ui_core` has started with XML-layout-facing
|
||||
length parsing, color parsing, tinyxml-backed layout XML parsing, and invalid
|
||||
input tests.
|
||||
`pano_cli inspect-image` exposes PNG IHDR metadata as JSON,
|
||||
@@ -1700,7 +1702,8 @@ Results:
|
||||
framebuffer-fetch backends, ping-pong texture-copy/blit fallbacks, simple
|
||||
no-feedback blends, invalid render-target usage, unsupported backends, and
|
||||
depth-target rejection.
|
||||
- `pp_paint_renderer_compositor_tests` passed.
|
||||
- `pp_paint_renderer_compositor_tests` passed, including pure
|
||||
`pp_document` frame/face compositing over per-layer dirty face payloads.
|
||||
The suite now covers fixed-function stroke composite planning,
|
||||
framebuffer-fetch planning, ping-pong texture-copy/blit fallback planning,
|
||||
dual/pattern blend feedback detection, invalid blend mode rejection,
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include "paint_renderer/compositor.h"
|
||||
|
||||
#include <limits>
|
||||
#include <utility>
|
||||
|
||||
namespace pp::paint_renderer {
|
||||
|
||||
@@ -93,6 +94,52 @@ namespace {
|
||||
return pp::foundation::Result<std::size_t>::success(static_cast<std::size_t>(count));
|
||||
}
|
||||
|
||||
[[nodiscard]] pp::paint::Rgba rgba8_pixel(std::span<const std::uint8_t> bytes) noexcept
|
||||
{
|
||||
constexpr auto inv = 1.0F / 255.0F;
|
||||
return pp::paint::Rgba {
|
||||
.r = static_cast<float>(bytes[0]) * inv,
|
||||
.g = static_cast<float>(bytes[1]) * inv,
|
||||
.b = static_cast<float>(bytes[2]) * inv,
|
||||
.a = static_cast<float>(bytes[3]) * inv,
|
||||
};
|
||||
}
|
||||
|
||||
[[nodiscard]] pp::foundation::Status composite_face_payload(
|
||||
std::span<pp::paint::Rgba> destination,
|
||||
pp::renderer::Extent2D extent,
|
||||
const pp::document::LayerFacePixels& payload,
|
||||
const pp::document::Layer& layer) noexcept
|
||||
{
|
||||
if (payload.x > extent.width || payload.width > extent.width - payload.x
|
||||
|| payload.y > extent.height || payload.height > extent.height - payload.y) {
|
||||
return pp::foundation::Status::out_of_range("document face payload rectangle is outside the render extent");
|
||||
}
|
||||
|
||||
const auto payload_pixel_count = static_cast<std::uint64_t>(payload.width)
|
||||
* static_cast<std::uint64_t>(payload.height);
|
||||
if (payload_pixel_count > static_cast<std::uint64_t>(std::numeric_limits<std::size_t>::max() / 4U)
|
||||
|| payload.rgba8.size() != static_cast<std::size_t>(payload_pixel_count) * 4U) {
|
||||
return pp::foundation::Status::invalid_argument("document face payload byte size does not match dimensions");
|
||||
}
|
||||
|
||||
for (std::uint32_t y = 0; y < payload.height; ++y) {
|
||||
for (std::uint32_t x = 0; x < payload.width; ++x) {
|
||||
const auto payload_index = (static_cast<std::size_t>(y) * payload.width + x) * 4U;
|
||||
const auto destination_index = static_cast<std::size_t>(payload.y + y) * extent.width
|
||||
+ static_cast<std::size_t>(payload.x + x);
|
||||
auto stroke = rgba8_pixel(std::span<const std::uint8_t>(&payload.rgba8[payload_index], 4U));
|
||||
stroke.a *= layer.opacity;
|
||||
destination[destination_index] = pp::paint::blend_pixels(
|
||||
destination[destination_index],
|
||||
stroke,
|
||||
layer.blend_mode);
|
||||
}
|
||||
}
|
||||
|
||||
return pp::foundation::Status::success();
|
||||
}
|
||||
|
||||
[[nodiscard]] StrokeCompositePath composite_path_from_feedback(pp::renderer::PaintFeedbackPath path) noexcept
|
||||
{
|
||||
switch (path) {
|
||||
@@ -176,6 +223,71 @@ pp::foundation::Status composite_layer(
|
||||
return pp::foundation::Status::success();
|
||||
}
|
||||
|
||||
pp::foundation::Result<DocumentFaceCompositeResult> composite_document_face(
|
||||
DocumentFaceCompositeRequest request)
|
||||
{
|
||||
if (request.document == nullptr) {
|
||||
return pp::foundation::Result<DocumentFaceCompositeResult>::failure(
|
||||
pp::foundation::Status::invalid_argument("document composite request requires a document"));
|
||||
}
|
||||
|
||||
if (request.face_index >= pp::document::cube_face_count) {
|
||||
return pp::foundation::Result<DocumentFaceCompositeResult>::failure(
|
||||
pp::foundation::Status::out_of_range("document composite face index is outside the cube"));
|
||||
}
|
||||
|
||||
if (request.frame_index >= request.document->frames().size()) {
|
||||
return pp::foundation::Result<DocumentFaceCompositeResult>::failure(
|
||||
pp::foundation::Status::out_of_range("document composite frame index is outside the document"));
|
||||
}
|
||||
|
||||
const pp::renderer::Extent2D extent {
|
||||
.width = request.document->width(),
|
||||
.height = request.document->height(),
|
||||
};
|
||||
const auto pixel_count = expected_pixel_count(extent);
|
||||
if (!pixel_count) {
|
||||
return pp::foundation::Result<DocumentFaceCompositeResult>::failure(pixel_count.status());
|
||||
}
|
||||
|
||||
DocumentFaceCompositeResult result;
|
||||
result.extent = extent;
|
||||
result.pixels.assign(pixel_count.value(), request.clear_color);
|
||||
result.visited_layer_count = request.document->layers().size();
|
||||
|
||||
for (const auto& layer : request.document->layers()) {
|
||||
if (!layer.visible || layer.opacity == 0.0F || request.frame_index >= layer.frames.size()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
bool composited_layer = false;
|
||||
const auto& frame = layer.frames[request.frame_index];
|
||||
for (const auto& payload : frame.face_pixels) {
|
||||
if (payload.face_index != request.face_index) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const auto status = composite_face_payload(
|
||||
result.pixels,
|
||||
extent,
|
||||
payload,
|
||||
layer);
|
||||
if (!status.ok()) {
|
||||
return pp::foundation::Result<DocumentFaceCompositeResult>::failure(status);
|
||||
}
|
||||
|
||||
composited_layer = true;
|
||||
++result.face_payload_count;
|
||||
}
|
||||
|
||||
if (composited_layer) {
|
||||
++result.composited_layer_count;
|
||||
}
|
||||
}
|
||||
|
||||
return pp::foundation::Result<DocumentFaceCompositeResult>::success(std::move(result));
|
||||
}
|
||||
|
||||
bool stroke_composite_requires_feedback(
|
||||
pp::paint::BlendMode layer_blend_mode,
|
||||
pp::paint::StrokeBlendMode stroke_blend_mode,
|
||||
|
||||
@@ -1,11 +1,14 @@
|
||||
#pragma once
|
||||
|
||||
#include "document/document.h"
|
||||
#include "foundation/result.h"
|
||||
#include "paint/blend.h"
|
||||
#include "renderer_api/renderer_api.h"
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <span>
|
||||
#include <vector>
|
||||
|
||||
namespace pp::paint_renderer {
|
||||
|
||||
@@ -83,11 +86,29 @@ struct CanvasStrokeFeedbackPlan {
|
||||
bool compatibility_fallback = false;
|
||||
};
|
||||
|
||||
struct DocumentFaceCompositeRequest {
|
||||
const pp::document::CanvasDocument* document = nullptr;
|
||||
std::size_t frame_index = 0;
|
||||
std::uint32_t face_index = 0;
|
||||
pp::paint::Rgba clear_color {};
|
||||
};
|
||||
|
||||
struct DocumentFaceCompositeResult {
|
||||
pp::renderer::Extent2D extent {};
|
||||
std::vector<pp::paint::Rgba> pixels;
|
||||
std::size_t visited_layer_count = 0;
|
||||
std::size_t composited_layer_count = 0;
|
||||
std::size_t face_payload_count = 0;
|
||||
};
|
||||
|
||||
[[nodiscard]] pp::foundation::Status composite_layer(
|
||||
std::span<pp::paint::Rgba> destination,
|
||||
pp::renderer::Extent2D extent,
|
||||
LayerCompositeView layer) noexcept;
|
||||
|
||||
[[nodiscard]] pp::foundation::Result<DocumentFaceCompositeResult> composite_document_face(
|
||||
DocumentFaceCompositeRequest request);
|
||||
|
||||
[[nodiscard]] bool stroke_composite_requires_feedback(
|
||||
pp::paint::BlendMode layer_blend_mode,
|
||||
pp::paint::StrokeBlendMode stroke_blend_mode,
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
#include "test_harness.h"
|
||||
|
||||
#include <cmath>
|
||||
#include <cstdint>
|
||||
#include <span>
|
||||
#include <string_view>
|
||||
#include <vector>
|
||||
|
||||
@@ -9,11 +11,13 @@ using pp::foundation::StatusCode;
|
||||
using pp::paint::BlendMode;
|
||||
using pp::paint::Rgba;
|
||||
using pp::paint::StrokeBlendMode;
|
||||
using pp::paint_renderer::LayerCompositeView;
|
||||
using pp::paint_renderer::CanvasBlendGateRequest;
|
||||
using pp::paint_renderer::DocumentFaceCompositeRequest;
|
||||
using pp::paint_renderer::LayerCompositeView;
|
||||
using pp::paint_renderer::StrokeCompositePath;
|
||||
using pp::paint_renderer::StrokeCompositeRequest;
|
||||
using pp::paint_renderer::composite_layer;
|
||||
using pp::paint_renderer::composite_document_face;
|
||||
using pp::paint_renderer::plan_canvas_blend_gate;
|
||||
using pp::paint_renderer::plan_canvas_stroke_feedback;
|
||||
using pp::paint_renderer::plan_stroke_composite;
|
||||
@@ -23,6 +27,11 @@ using pp::renderer::Extent2D;
|
||||
using pp::renderer::RenderDeviceFeatures;
|
||||
using pp::renderer::TextureFormat;
|
||||
using pp::renderer::TextureUsage;
|
||||
using pp::document::AnimationFrame;
|
||||
using pp::document::CanvasDocument;
|
||||
using pp::document::DocumentLayerConfig;
|
||||
using pp::document::DocumentSnapshotConfig;
|
||||
using pp::document::LayerFacePixels;
|
||||
|
||||
namespace {
|
||||
|
||||
@@ -110,6 +119,218 @@ void rejects_invalid_sizes_and_opacity(pp::tests::Harness& h)
|
||||
PP_EXPECT(h, bad_extent.code == StatusCode::invalid_argument);
|
||||
}
|
||||
|
||||
void composites_document_face_payloads_in_layer_order(pp::tests::Harness& h)
|
||||
{
|
||||
const AnimationFrame root_frames[] {
|
||||
{ .duration_ms = 100, .face_pixels = {} },
|
||||
};
|
||||
const AnimationFrame base_frames[] {
|
||||
{
|
||||
.duration_ms = 100,
|
||||
.face_pixels = {
|
||||
LayerFacePixels {
|
||||
.face_index = 0,
|
||||
.x = 0,
|
||||
.y = 0,
|
||||
.width = 2,
|
||||
.height = 1,
|
||||
.rgba8 = { 255, 0, 0, 255, 0, 255, 0, 255 },
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
const AnimationFrame paint_frames[] {
|
||||
{
|
||||
.duration_ms = 100,
|
||||
.face_pixels = {
|
||||
LayerFacePixels {
|
||||
.face_index = 0,
|
||||
.x = 1,
|
||||
.y = 0,
|
||||
.width = 1,
|
||||
.height = 1,
|
||||
.rgba8 = { 0, 0, 255, 255 },
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
const AnimationFrame hidden_frames[] {
|
||||
{
|
||||
.duration_ms = 100,
|
||||
.face_pixels = {
|
||||
LayerFacePixels {
|
||||
.face_index = 0,
|
||||
.x = 0,
|
||||
.y = 0,
|
||||
.width = 1,
|
||||
.height = 1,
|
||||
.rgba8 = { 255, 255, 255, 255 },
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
const DocumentLayerConfig layers[] {
|
||||
{
|
||||
.name = "Base",
|
||||
.frames = std::span<const AnimationFrame>(base_frames, 1),
|
||||
},
|
||||
{
|
||||
.name = "Paint",
|
||||
.opacity = 0.5F,
|
||||
.frames = std::span<const AnimationFrame>(paint_frames, 1),
|
||||
},
|
||||
{
|
||||
.name = "Hidden",
|
||||
.visible = false,
|
||||
.frames = std::span<const AnimationFrame>(hidden_frames, 1),
|
||||
},
|
||||
};
|
||||
|
||||
const auto document = CanvasDocument::create_from_snapshot(DocumentSnapshotConfig {
|
||||
.width = 2,
|
||||
.height = 1,
|
||||
.layers = std::span<const DocumentLayerConfig>(layers, 3),
|
||||
.frames = std::span<const AnimationFrame>(root_frames, 1),
|
||||
.selection_masks = {},
|
||||
});
|
||||
PP_EXPECT(h, document);
|
||||
const auto result = composite_document_face(DocumentFaceCompositeRequest {
|
||||
.document = &document.value(),
|
||||
.frame_index = 0,
|
||||
.face_index = 0,
|
||||
});
|
||||
|
||||
PP_EXPECT(h, result);
|
||||
if (result) {
|
||||
PP_EXPECT(h, result.value().extent.width == 2U);
|
||||
PP_EXPECT(h, result.value().extent.height == 1U);
|
||||
PP_EXPECT(h, result.value().visited_layer_count == 3U);
|
||||
PP_EXPECT(h, result.value().composited_layer_count == 2U);
|
||||
PP_EXPECT(h, result.value().face_payload_count == 2U);
|
||||
PP_EXPECT(h, result.value().pixels.size() == 2U);
|
||||
PP_EXPECT(h, near(result.value().pixels[0].r, 1.0F));
|
||||
PP_EXPECT(h, near(result.value().pixels[0].g, 0.0F));
|
||||
PP_EXPECT(h, near(result.value().pixels[0].b, 0.0F));
|
||||
PP_EXPECT(h, near(result.value().pixels[0].a, 1.0F));
|
||||
PP_EXPECT(h, near(result.value().pixels[1].r, 0.0F));
|
||||
PP_EXPECT(h, near(result.value().pixels[1].g, 0.5F));
|
||||
PP_EXPECT(h, near(result.value().pixels[1].b, 0.5F));
|
||||
PP_EXPECT(h, near(result.value().pixels[1].a, 1.0F));
|
||||
}
|
||||
}
|
||||
|
||||
void document_face_composite_skips_layers_without_requested_frame(pp::tests::Harness& h)
|
||||
{
|
||||
const AnimationFrame root_frames[] {
|
||||
{ .duration_ms = 100, .face_pixels = {} },
|
||||
{ .duration_ms = 100, .face_pixels = {} },
|
||||
};
|
||||
const AnimationFrame short_layer_frames[] {
|
||||
{
|
||||
.duration_ms = 100,
|
||||
.face_pixels = {
|
||||
LayerFacePixels {
|
||||
.face_index = 0,
|
||||
.x = 0,
|
||||
.y = 0,
|
||||
.width = 1,
|
||||
.height = 1,
|
||||
.rgba8 = { 255, 0, 0, 255 },
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
const AnimationFrame animated_layer_frames[] {
|
||||
{ .duration_ms = 100, .face_pixels = {} },
|
||||
{
|
||||
.duration_ms = 100,
|
||||
.face_pixels = {
|
||||
LayerFacePixels {
|
||||
.face_index = 0,
|
||||
.x = 0,
|
||||
.y = 0,
|
||||
.width = 1,
|
||||
.height = 1,
|
||||
.rgba8 = { 0, 0, 255, 255 },
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
const DocumentLayerConfig layers[] {
|
||||
{
|
||||
.name = "Short",
|
||||
.frames = std::span<const AnimationFrame>(short_layer_frames, 1),
|
||||
},
|
||||
{
|
||||
.name = "Animated",
|
||||
.frames = std::span<const AnimationFrame>(animated_layer_frames, 2),
|
||||
},
|
||||
};
|
||||
const auto document = CanvasDocument::create_from_snapshot(DocumentSnapshotConfig {
|
||||
.width = 1,
|
||||
.height = 1,
|
||||
.layers = std::span<const DocumentLayerConfig>(layers, 2),
|
||||
.frames = std::span<const AnimationFrame>(root_frames, 2),
|
||||
.selection_masks = {},
|
||||
});
|
||||
PP_EXPECT(h, document);
|
||||
|
||||
const auto result = composite_document_face(DocumentFaceCompositeRequest {
|
||||
.document = &document.value(),
|
||||
.frame_index = 1,
|
||||
.face_index = 0,
|
||||
});
|
||||
|
||||
PP_EXPECT(h, result);
|
||||
if (result) {
|
||||
PP_EXPECT(h, result.value().visited_layer_count == 2U);
|
||||
PP_EXPECT(h, result.value().composited_layer_count == 1U);
|
||||
PP_EXPECT(h, result.value().face_payload_count == 1U);
|
||||
PP_EXPECT(h, near(result.value().pixels[0].r, 0.0F));
|
||||
PP_EXPECT(h, near(result.value().pixels[0].g, 0.0F));
|
||||
PP_EXPECT(h, near(result.value().pixels[0].b, 1.0F));
|
||||
PP_EXPECT(h, near(result.value().pixels[0].a, 1.0F));
|
||||
}
|
||||
}
|
||||
|
||||
void document_face_composite_rejects_invalid_requests(pp::tests::Harness& h)
|
||||
{
|
||||
const auto no_document = composite_document_face(DocumentFaceCompositeRequest {});
|
||||
|
||||
const AnimationFrame root_frames[] {
|
||||
{ .duration_ms = 100, .face_pixels = {} },
|
||||
};
|
||||
const DocumentLayerConfig layers[] {
|
||||
{ .name = "Layer", .frames = {} },
|
||||
};
|
||||
const auto document = CanvasDocument::create_from_snapshot(DocumentSnapshotConfig {
|
||||
.width = 1,
|
||||
.height = 1,
|
||||
.layers = std::span<const DocumentLayerConfig>(layers, 1),
|
||||
.frames = std::span<const AnimationFrame>(root_frames, 1),
|
||||
.selection_masks = {},
|
||||
});
|
||||
PP_EXPECT(h, document);
|
||||
|
||||
const auto bad_frame = composite_document_face(DocumentFaceCompositeRequest {
|
||||
.document = &document.value(),
|
||||
.frame_index = 1,
|
||||
.face_index = 0,
|
||||
});
|
||||
const auto bad_face = composite_document_face(DocumentFaceCompositeRequest {
|
||||
.document = &document.value(),
|
||||
.frame_index = 0,
|
||||
.face_index = 6,
|
||||
});
|
||||
|
||||
PP_EXPECT(h, !no_document.ok());
|
||||
PP_EXPECT(h, no_document.status().code == StatusCode::invalid_argument);
|
||||
PP_EXPECT(h, !bad_frame.ok());
|
||||
PP_EXPECT(h, bad_frame.status().code == StatusCode::out_of_range);
|
||||
PP_EXPECT(h, !bad_face.ok());
|
||||
PP_EXPECT(h, bad_face.status().code == StatusCode::out_of_range);
|
||||
}
|
||||
|
||||
void detects_feedback_requirements(pp::tests::Harness& h)
|
||||
{
|
||||
PP_EXPECT(h, !stroke_composite_requires_feedback(
|
||||
@@ -449,6 +670,9 @@ int main()
|
||||
harness.run("composites_visible_layer_with_opacity", composites_visible_layer_with_opacity);
|
||||
harness.run("invisible_and_zero_opacity_layers_are_noops", invisible_and_zero_opacity_layers_are_noops);
|
||||
harness.run("rejects_invalid_sizes_and_opacity", rejects_invalid_sizes_and_opacity);
|
||||
harness.run("composites_document_face_payloads_in_layer_order", composites_document_face_payloads_in_layer_order);
|
||||
harness.run("document_face_composite_skips_layers_without_requested_frame", document_face_composite_skips_layers_without_requested_frame);
|
||||
harness.run("document_face_composite_rejects_invalid_requests", document_face_composite_rejects_invalid_requests);
|
||||
harness.run("detects_feedback_requirements", detects_feedback_requirements);
|
||||
harness.run("plans_stroke_composite_paths", plans_stroke_composite_paths);
|
||||
harness.run("rejects_bad_stroke_composite_plans", rejects_bad_stroke_composite_plans);
|
||||
|
||||
Reference in New Issue
Block a user