From 3c36be4b432bf7bfba3fa52176d49ac482e90c31 Mon Sep 17 00:00:00 2001 From: omigamedev Date: Fri, 5 Jun 2026 20:48:16 +0200 Subject: [PATCH] Export layer collections through paint renderer --- docs/modernization/build-inventory.md | 16 +- docs/modernization/capability-map.md | 4 +- docs/modernization/debt.md | 17 +- docs/modernization/roadmap.md | 20 ++- src/app_core/document_export.h | 85 +++++++++ src/legacy_document_export_services.cpp | 187 +++++++++++++++++++- src/paint_renderer/compositor.cpp | 156 +++++++++++++++++ src/paint_renderer/compositor.h | 52 ++++++ tests/app_core/document_export_tests.cpp | 99 ++++++++++- tests/paint_renderer/compositor_tests.cpp | 200 ++++++++++++++++++++++ 10 files changed, 815 insertions(+), 21 deletions(-) diff --git a/docs/modernization/build-inventory.md b/docs/modernization/build-inventory.md index 52f8352..5597e3e 100644 --- a/docs/modernization/build-inventory.md +++ b/docs/modernization/build-inventory.md @@ -258,7 +258,9 @@ powershell -ExecutionPolicy Bypass -File scripts\automation\apple-remote-build.p pure six-face PNG export bytes encoded through `pp_assets`. The compositor tests now also cover equirectangular PNG export from that same composited document frame using the shader-equivalent cube sampling policy and - `pp_assets` PNG encoding. + `pp_assets` PNG encoding, independent layer equirectangular PNG export for + layer collections, and merged animation-frame equirectangular PNG export for + frame collections. - `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`. @@ -289,7 +291,10 @@ powershell -ExecutionPolicy Bypass -File scripts\automation\apple-remote-build.p falls back to `Canvas::export_cube_faces` if snapshot capture, PNG generation, or file writing fails. PNG equirectangular export writes a pure document/paint-renderer equirectangular PNG before falling back to the - retained writer; JPEG/XMP equirectangular export, layer, animation-frame, + retained writer. Payload-complete layer and animation-frame PNG collections + write pure document/paint-renderer equirectangular PNG sequences through the + app-core collection write/publish executor before retained fallback; JPEG/XMP + equirectangular export, Web handoff, incomplete-readback collection cases, depth, and video export remain on retained writer paths. - `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`, @@ -1134,8 +1139,11 @@ powershell -ExecutionPolicy Bypass -File scripts\automation\apple-remote-build.p app-core planned legacy work-directory face paths through the app-core write/publish executor before falling back to the retained writer, PNG equirectangular export writes the pure document/paint-renderer - equirectangular PNG before retained fallback, and JPEG/XMP, collection, and - depth exports remain on older retained paths. It + equirectangular PNG before retained fallback, payload-complete layer and + animation-frame collections write pure document/paint-renderer PNG sequences + through the app-core collection write/publish executor, and JPEG/XMP, + Web/incomplete-readback collection cases, and depth exports remain on older + retained paths. It also bridges timelapse and animation MP4 export picker-selected paths while preserving desktop worker-thread timelapse behavior, mobile/Web save callbacks, `App::rec_export`, animation `Canvas::export_anim_mp4`, and diff --git a/docs/modernization/capability-map.md b/docs/modernization/capability-map.md index 75d0a52..6a3d298 100644 --- a/docs/modernization/capability-map.md +++ b/docs/modernization/capability-map.md @@ -24,8 +24,8 @@ and validation command. | Capability | Current Area | Target Owner | Required Tests | | --- | --- | --- | --- | | PNG/JPEG import | `Image`, `Canvas` import paths | `pp_assets`, `pp_document` | Fixture import, malformed file | -| PNG/JPEG export | `Canvas`, `Image`, export dialogs | `pp_assets`, `pp_paint_renderer`, `pp_app_core` | Golden output tolerance, export start/target planning tests, live export-adapter document snapshot readiness through the shared paint-renderer export report, pure cube-face PNG writer, pure equirectangular PNG writer, JPEG/XMP parity still retained | -| Equirectangular import/export | `Canvas`, shaders, RTT, export dialogs | `pp_paint_renderer`, `pp_app_core` | Tiny cube/equirect golden, app-core file target tests, live export-adapter renderer-upload/face-PNG readiness report, pure document-frame equirectangular PNG export and live PNG writer fallback, JPEG/XMP retained until metadata parity is owned | +| PNG/JPEG export | `Canvas`, `Image`, export dialogs | `pp_assets`, `pp_paint_renderer`, `pp_app_core` | Golden output tolerance, export start/target planning tests, live export-adapter document snapshot readiness through the shared paint-renderer export report, pure cube-face PNG writer, pure equirectangular PNG writer, pure layer/frame collection PNG writers, app-core collection write executor, JPEG/XMP parity still retained | +| Equirectangular import/export | `Canvas`, shaders, RTT, export dialogs | `pp_paint_renderer`, `pp_app_core` | Tiny cube/equirect golden, app-core file target tests, live export-adapter renderer-upload/face-PNG readiness report, pure document-frame equirectangular PNG export and live PNG writer fallback, pure layer/frame equirectangular PNG collection export, JPEG/XMP retained until metadata parity is owned | | Cube face export | `Canvas` fallback | `pp_paint_renderer`, `pp_app_core` | Pure six-face document frame composite, renderer texture-upload bridge, shared export-readiness report, app-core face filename planning and write/publish service execution, payload-complete canvas-snapshot renderer-upload and face-PNG automation, live document/renderer face-PNG writer with retained Canvas fallback, OpenGL command-plan coverage, six-face golden set | | Depth export | `Canvas`, grid tools | `pp_paint_renderer` | Float/readback validation | diff --git a/docs/modernization/debt.md b/docs/modernization/debt.md index a1c964c..5b309e7 100644 --- a/docs/modernization/debt.md +++ b/docs/modernization/debt.md @@ -533,7 +533,16 @@ agent or engineer to remove them without reconstructing context from chat. shader-equivalent cube sampling policy and `pp_assets` PNG encoding. Live PNG equirectangular export writes through that path before retained fallback; JPEG/XMP metadata parity, GPU filtering/golden parity, Web prepared-file - handoff, and the remaining collection/depth/video writers stay open. + handoff, and the then-retained collection/depth/video writers stayed open. +- 2026-06-05: DEBT-0010/DEBT-0036/DEBT-0043 were narrowed again. + `pp_paint_renderer` now exports independent layer equirectangular PNGs and + merged animation-frame equirectangular PNGs from payload-complete + `pp_document` snapshots, while `pp_app_core` owns the retained collection + filename suffixes plus collection write/publish execution. Live layer and + animation-frame PNG collection export uses those paths before retained + fallback; Web handoff, incomplete renderer-readback snapshots, progress and + threading parity, exact GPU filtering/goldens, depth, video, and JPEG/XMP + remain open. ## Open Debt @@ -547,7 +556,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, stroke-script-to-face-payload CLI automation, `pp_paint_renderer` document face/frame compositors, renderer-neutral six-face texture upload, pure six-face PNG export, pure equirectangular PNG export, shared document-frame export readiness reporting, OpenGL command-planner validation through CLI render automation, live Canvas snapshot projection through `pp_app_core`/`legacy_document_canvas_services`, captured RGBA8 payload attachment to `pp_document`, live Save/Save As/Save Version/save-before-workflow snapshot-readiness reporting before retained save execution, pure app-core PPI export for payload-complete canvas snapshots, payload-complete canvas-snapshot renderer-upload plus face-PNG export automation, live cube-face face-PNG writer execution using app-core face target planning and write/publish service dispatch with retained fallback, live PNG equirectangular writer execution using the paint-renderer equirectangular PNG export with retained fallback, and live equirectangular/layer/animation-frame/cube-face export snapshot/render/export-readiness reporting through the shared readiness helper, but action-command adoption, live save-writer replacement, JPEG/XMP metadata parity, broader renderer-owned export execution, and renderer-owned cube-face readback ownership are not yet wired | 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`; `pano_cli simulate-document-render --width 64 --height 32`; `pano_cli plan-canvas-document-snapshot --width 64 --height 32`; `pano_cli plan-canvas-document-snapshot --captured-face-payloads-per-layer 1`; `pp_document_tests`; `pp_document_ppi_import_tests`; `pp_document_ppi_export_tests`; `pp_paint_renderer_compositor_tests`; `pp_app_core_document_canvas_tests`; `pano_cli_simulate_document_edits_smoke`; `pano_cli_simulate_document_export_smoke`; `pano_cli_simulate_document_render_smoke`; `pano_cli_plan_canvas_document_snapshot_smoke`; `pano_cli_plan_canvas_document_snapshot_payload_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-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, `pp_paint_renderer` document face/frame compositors, renderer-neutral six-face texture upload, pure six-face PNG export, pure equirectangular PNG export, pure layer/animation-frame PNG collection export, shared document-frame export readiness reporting, OpenGL command-planner validation through CLI render automation, live Canvas snapshot projection through `pp_app_core`/`legacy_document_canvas_services`, captured RGBA8 payload attachment to `pp_document`, live Save/Save As/Save Version/save-before-workflow snapshot-readiness reporting before retained save execution, pure app-core PPI export for payload-complete canvas snapshots, payload-complete canvas-snapshot renderer-upload plus face-PNG export automation, live cube-face face-PNG writer execution using app-core face target planning and write/publish service dispatch with retained fallback, live PNG equirectangular writer execution using the paint-renderer equirectangular PNG export with retained fallback, live payload-complete layer/animation-frame collection writer execution using paint-renderer PNG sequences and app-core collection write/publish dispatch with retained fallback, and live equirectangular/layer/animation-frame/cube-face export snapshot/render/export-readiness reporting through the shared readiness helper, but action-command adoption, live save-writer replacement, JPEG/XMP metadata parity, Web and incomplete-readback collection handoff, progress/threading parity, broader renderer-owned export execution, and renderer-owned cube-face readback ownership are not yet wired | 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`; `pano_cli simulate-document-render --width 64 --height 32`; `pano_cli plan-canvas-document-snapshot --width 64 --height 32`; `pano_cli plan-canvas-document-snapshot --captured-face-payloads-per-layer 1`; `pp_document_tests`; `pp_document_ppi_import_tests`; `pp_document_ppi_export_tests`; `pp_paint_renderer_compositor_tests`; `pp_app_core_document_canvas_tests`; `pano_cli_simulate_document_edits_smoke`; `pano_cli_simulate_document_export_smoke`; `pano_cli_simulate_document_render_smoke`; `pano_cli_plan_canvas_document_snapshot_smoke`; `pano_cli_plan_canvas_document_snapshot_payload_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, decoded pixel attachment to `pp_document`, live save-path snapshot-readiness reporting, and app-core canvas-snapshot-to-PPI export automation, but full legacy PPI round-trip parity and pure live save writer replacement are 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 | @@ -572,14 +581,14 @@ agent or engineer to remove them without reconstructing context from chat. | DEBT-0033 | Open | Modernization | Tools menu planning and direct command execution dispatch now consume pure `pp_app_core` through `App::init_menu_tools`, `pano_cli plan-tools-menu`, `pano_cli plan-tools-panel`, `pano_cli plan-canvas-camera-reset`, `pano_cli plan-canvas-view-density`, `pano_cli plan-canvas-view-cursor-mode`, and the `ToolsMenuServices` boundary, direct command execution is centralized in `src/legacy_app_shell_services.*`, SonarPen availability/startup now routes through `PlatformServices`, and reset-camera, viewport-density, and cursor-mode execution now share `src/legacy_canvas_view_services.*`, but live adapters still construct legacy `NodePanelFloating` panels, mutate legacy panel nodes, clear `CanvasModeGrid`, open legacy shortcuts UI, mutate retained `Canvas` camera/density/cursor state, write retained `Settings`, and rely on the legacy platform adapter for the retained iOS SonarPen bridge | Preserve current Tools menu and canvas-view behavior while UI shell actions move toward app/UI/platform/canvas services | `pp_app_core_tools_menu_tests`; `pp_app_core_canvas_view_tests`; `pp_platform_api_tests`; `pano_cli plan-tools-menu --command shortcuts`; `pano_cli plan-tools-panel --panel layers`; `pano_cli plan-tools-panel --panel animation --already-visible`; `pano_cli plan-canvas-camera-reset`; `pano_cli plan-canvas-view-density --density 1.5`; `pano_cli plan-canvas-view-cursor-mode --mode 3`; `ctest --preset desktop-fast --build-config Debug` | Tools panel creation, submenu routing, grid clear, camera reset, viewport density, cursor mode, shortcuts dialog, and SonarPen dispatch are owned by injected app/UI/platform/canvas services with `App::init_menu_tools` and options callbacks acting only as UI adapters and no legacy Tools/canvas-view adapter | | DEBT-0034 | Open | Modernization | About menu command planning and execution dispatch now consume pure `pp_app_core` through `App::init_menu_about`, `pano_cli plan-about-menu`, and the `AboutMenuServices` boundary, and live execution is centralized in `src/legacy_app_shell_services.*`, but the bridge still opens legacy About/manual/what's-new dialogs, invokes the injected crash hook, and runs the legacy Canvas stroke performance test directly | Preserve About menu behavior while dialogs and diagnostics move toward app/UI/platform services | `pp_app_core_about_menu_tests`; `pano_cli plan-about-menu --command news --version-major 2 --version-minor 5 --version-fix 7`; `pano_cli plan-about-menu --command performance --no-canvas`; `ctest --preset desktop-fast --build-config Debug` | About/manual/what's-new dialog dispatch, crash-test dispatch, and performance-test execution are owned by injected app/UI/platform services with `App::init_menu_about` acting only as a UI adapter and no legacy About adapter | | DEBT-0035 | Open | Modernization | Main toolbar/status command planning and execution dispatch now consume pure `pp_app_core` through `App::init_toolbar_main`, `pano_cli plan-main-toolbar`, and the `MainToolbarServices` boundary; toolbar test-message dialog metadata now lives in `pp_app_core` through `plan_main_toolbar_message_dialog`, retained message-box creation routes through `src/legacy_app_dialog_services.*`, history/canvas commands now hand off through `HistoryUiServices` and `DocumentCanvasClearServices`, and live execution is centralized in `src/legacy_app_shell_services.*`, but the bridge still opens legacy open/save/settings dialogs, stores raw compatibility pointers, and delegates to legacy history/canvas adapters | Preserve reachable toolbar/status behavior while app shell commands move toward app/document/UI services | `pp_app_core_main_toolbar_tests`; `pano_cli plan-main-toolbar --command undo --undo-count 2`; `pano_cli plan-main-toolbar --command message-box`; `pano_cli plan-main-toolbar --command clear-canvas --no-canvas`; `ctest --preset desktop-fast --build-config Debug` | Open/save/settings/message-box routing, undo/redo/clear-history execution, and canvas-clear execution are owned by injected app/document/UI services with `App::init_toolbar_main` acting only as a UI adapter and no legacy toolbar adapter | -| DEBT-0036 | Open | Modernization | `pp_renderer_api`, `pp_paint_renderer`, `pano_cli plan-paint-feedback`, and `pano_cli plan-stroke-composite` can choose backend-neutral complex paint feedback strategies for fixed-function blending, framebuffer-fetch-capable renderers, or ping-pong render targets. OpenGL extension detection now stores `pp::renderer::RenderDeviceFeatures` through `ShaderManager`, using `pp_renderer_gl::query_opengl_capability_detection`, `detect_opengl_feature_state`, and `render_device_features` as the backend conversion point; that feature snapshot now includes float32-linear filtering, so canvas stroke texture format selection, renderer diagnostics, grid lightmap render planning, and grid bake target selection no longer read `ShaderManager::ext_*` flags directly. `pp_paint_renderer::plan_canvas_blend_gate` owns the compatibility mapping from persisted layer/brush blend indices to the extracted stroke-composite planner, and live `Canvas::draw_merge` plus `NodeCanvas` panorama rendering both call it with the stored renderer-neutral feature set for their existing shader-blend gates and destination-copy versus framebuffer-fetch decisions. `pp_paint_renderer::plan_canvas_stroke_feedback` also owns the current destination-feedback decision, and live `Canvas::stroke_draw`, thumbnail layer blending, and `NodeStrokePreview` brush-preview rendering use it for framebuffer-fetch versus destination-copy decisions. Pure document-frame compositing, renderer-neutral six-face texture upload, recorded upload-command reporting, pure six-face PNG encoding, and pure equirectangular PNG encoding are now covered by `simulate-document-render`, payload-complete `plan-canvas-document-snapshot` automation, and the shared `pp_paint_renderer::prepare_document_frame_export_readiness` helper consumed by live export before retained writer fallback. The retained `copy_framebuffer_to_texture_2d` utility bridge now routes 2D framebuffer-to-texture copies through tested `pp_renderer_gl` dispatch, retained `RTT::create`/`RTT::destroy` render-target texture parameter setup, optional depth renderbuffer allocation, framebuffer allocation/attachment/status checks, binding restore, and resource deletion now route through tested `pp_renderer_gl` dispatch, retained RTT clear, masked clear with color-write-mask restore, texture bind/unbind, and RGBA8 dirty-region texture writes now route through tested `pp_renderer_gl` dispatch, retained Canvas, NodeCanvas, and NodeStrokePreview texture-unit switches now route through tested active-texture dispatch, retained Canvas, NodeCanvas, NodeStrokePreview, and desktop HMD viewport/scissor/capability execution now route through tested `pp_renderer_gl` dispatch adapters, retained NodeCanvas, CanvasMode, and NodePanelGrid capability-state snapshots now route through tested `pp_renderer_gl` query dispatch, CanvasLayer cube/equirect generation plus frame clears now share `legacy_ui_gl_dispatch` for active-texture selection, cube texture binding, viewport execution, blend capability execution, clear-color query/restore, and color-buffer clear adapter endpoints backed by tested `pp_renderer_gl` dispatch helpers, while the cube-face framebuffer-to-texture copy now uses the shared retained `copy_framebuffer_to_texture_target` utility bridge backed by tested `pp_renderer_gl` dispatch and remains tracked by DEBT-0036 until renderer services own copy execution, `NodePanelGrid` live heightmap draw and bake setup now route depth/blend state, depth clears, color-write-mask toggles, active texture selection, bake viewport execution, sun-overlay viewport query, and desktop texture-resize readback through tested `pp_renderer_gl` dispatch adapters; its active-texture, depth/blend capability query/apply, viewport query/execution, depth-clear, and color-write-mask adapter endpoints now share `legacy_ui_gl_dispatch`, retained CanvasMode overlay/mask/transform paths now route active texture, depth/blend state, transform/cut viewport execution, paint-mode blend/depth state snapshots, and canvas-tip pick framebuffer readback through tested `pp_renderer_gl` dispatch adapters; their active-texture, capability query/apply, viewport, read-framebuffer query, and RGBA8 pixel-readback adapter endpoints now share `legacy_ui_gl_dispatch`, retained simple UI draw paths now share `legacy_ui_gl_dispatch` for blend-state execution, fallback 2D texture unbinds, `NodeViewport` viewport query/restore, color-buffer clears, and clear-color restore, retained `NodeCanvas` plus `NodeStrokePreview` draw-state paths now share `legacy_ui_gl_dispatch` for active-texture selection, fallback texture unbind, viewport/scissor execution, viewport and clear-color queries, color-buffer clears, clear-color restore, and capability query/apply adapter endpoints backed by tested `pp_renderer_gl` dispatch helpers, retained `Canvas` stroke/object/thumbnail/export/frame-clear state endpoints now share `legacy_ui_gl_dispatch` for active-texture selection, fallback texture unbind, viewport/scissor execution, viewport and clear-color query, clear-color restore, and capability query/apply adapter endpoints, retained Canvas and RTT depth renderbuffer allocation/attachment/delete now share `legacy_gl_renderbuffer_dispatch` while renderer-resource ownership remains retained, retained `Texture2D`, `TextureCube`, and RTT texture allocation/delete/bind/parameter/update/mipmap dispatch now share `legacy_gl_texture_dispatch` while renderer-resource ownership remains retained, retained `Texture2D` readback plus RTT framebuffer allocation/delete/bind/restore/blit/readback and PBO readback dispatch now share `legacy_gl_framebuffer_dispatch` while renderer-resource ownership remains retained, retained Sampler create/parameter/border/bind dispatch shares `legacy_gl_sampler_dispatch` and retained PBO allocation/readback/map/unmap/delete dispatch shares `legacy_gl_pixel_buffer_dispatch` while renderer-resource ownership remains retained, retained `Shape`, `TextMesh`, and `NodeColorWheel` mesh buffer/VAO creation/upload/draw/delete dispatch now share `legacy_gl_mesh_dispatch` while renderer-resource ownership remains retained, retained shader source compilation/deletion, program attach/link/use/delete, attribute rebinding/location lookup, active-uniform enumeration, uniform-location discovery, and uniform writes now share `legacy_gl_shader_dispatch` while shader-program ownership remains retained, retained `gl_state` save/restore and `copy_framebuffer_to_texture_target` now reuse shared retained UI/framebuffer/shader/sampler bridge callbacks while renderer state and framebuffer-copy execution remain retained, retained app startup, app clear, app UI viewport/scissor, command-convert renderer state, and desktop VR draw-state endpoints now share `legacy_ui_gl_dispatch` while app/VR renderer execution remains retained, retained RTT clear and masked-clear endpoints now share `legacy_ui_gl_dispatch` while RTT render-target execution remains retained, retained app startup logging, Windows early context logging/window-title detection, and shader capability detection now share `legacy_gl_runtime_dispatch` while runtime/capability probing remains retained, and retained `CanvasLayer` frame-clear draw-state paths route saved clear-color query and restore through the same tested helpers, but actual live stroke rasterization, dual-brush compositing, pattern feedback math, thumbnail layer compositing, brush-preview compositing, grid lightmap/heightmap mesh rendering, JPEG/XMP equirectangular metadata export, layer/animation-frame/depth export writer execution, exact GPU filtering parity, and the retained `ShaderManager::ext_*` compatibility fields still use legacy OpenGL canvas/UI execution | Preserve current painting behavior while the renderer boundary matures for OpenGL parity and later Vulkan/Metal experiments | `pp_renderer_api_tests`; `pp_renderer_gl_capabilities_tests`; `pp_paint_renderer_compositor_tests`; `pano_cli plan-paint-feedback --framebuffer-fetch --explicit-transitions --render-only`; `pano_cli plan-paint-feedback --texture-copy`; `pano_cli plan-stroke-composite --stroke-blend 10 --framebuffer-fetch --explicit-transitions --render-only`; `pano_cli plan-stroke-composite --layer-blend 4 --dual-blend --texture-copy`; `pano_cli plan-canvas-document-snapshot --captured-face-payloads-per-layer 1`; `ctest --preset desktop-fast --build-config Debug`; `cmake --build --preset windows-msvc-default --config Debug --target PanoPainter` | Live stroke/layer/export compositing chooses its feedback path through `pp_paint_renderer` and renderer services, with OpenGL golden parity and Vulkan/Metal lab tests covering framebuffer-fetch and ping-pong behavior | +| DEBT-0036 | Open | Modernization | `pp_renderer_api`, `pp_paint_renderer`, `pano_cli plan-paint-feedback`, and `pano_cli plan-stroke-composite` can choose backend-neutral complex paint feedback strategies for fixed-function blending, framebuffer-fetch-capable renderers, or ping-pong render targets. OpenGL extension detection now stores `pp::renderer::RenderDeviceFeatures` through `ShaderManager`, using `pp_renderer_gl::query_opengl_capability_detection`, `detect_opengl_feature_state`, and `render_device_features` as the backend conversion point; that feature snapshot now includes float32-linear filtering, so canvas stroke texture format selection, renderer diagnostics, grid lightmap render planning, and grid bake target selection no longer read `ShaderManager::ext_*` flags directly. `pp_paint_renderer::plan_canvas_blend_gate` owns the compatibility mapping from persisted layer/brush blend indices to the extracted stroke-composite planner, and live `Canvas::draw_merge` plus `NodeCanvas` panorama rendering both call it with the stored renderer-neutral feature set for their existing shader-blend gates and destination-copy versus framebuffer-fetch decisions. `pp_paint_renderer::plan_canvas_stroke_feedback` also owns the current destination-feedback decision, and live `Canvas::stroke_draw`, thumbnail layer blending, and `NodeStrokePreview` brush-preview rendering use it for framebuffer-fetch versus destination-copy decisions. Pure document-frame compositing, renderer-neutral six-face texture upload, recorded upload-command reporting, pure six-face PNG encoding, pure equirectangular PNG encoding, and pure layer/animation-frame collection PNG encoding are now covered by `simulate-document-render`, payload-complete `plan-canvas-document-snapshot` automation, and the shared `pp_paint_renderer::prepare_document_frame_export_readiness` helper consumed by live export before retained writer fallback. The retained `copy_framebuffer_to_texture_2d` utility bridge now routes 2D framebuffer-to-texture copies through tested `pp_renderer_gl` dispatch, retained `RTT::create`/`RTT::destroy` render-target texture parameter setup, optional depth renderbuffer allocation, framebuffer allocation/attachment/status checks, binding restore, and resource deletion now route through tested `pp_renderer_gl` dispatch, retained RTT clear, masked clear with color-write-mask restore, texture bind/unbind, and RGBA8 dirty-region texture writes now route through tested `pp_renderer_gl` dispatch, retained Canvas, NodeCanvas, and NodeStrokePreview texture-unit switches now route through tested active-texture dispatch, retained Canvas, NodeCanvas, NodeStrokePreview, and desktop HMD viewport/scissor/capability execution now route through tested `pp_renderer_gl` dispatch adapters, retained NodeCanvas, CanvasMode, and NodePanelGrid capability-state snapshots now route through tested `pp_renderer_gl` query dispatch, CanvasLayer cube/equirect generation plus frame clears now share `legacy_ui_gl_dispatch` for active-texture selection, cube texture binding, viewport execution, blend capability execution, clear-color query/restore, and color-buffer clear adapter endpoints backed by tested `pp_renderer_gl` dispatch helpers, while the cube-face framebuffer-to-texture copy now uses the shared retained `copy_framebuffer_to_texture_target` utility bridge backed by tested `pp_renderer_gl` dispatch and remains tracked by DEBT-0036 until renderer services own copy execution, `NodePanelGrid` live heightmap draw and bake setup now route depth/blend state, depth clears, color-write-mask toggles, active texture selection, bake viewport execution, sun-overlay viewport query, and desktop texture-resize readback through tested `pp_renderer_gl` dispatch adapters; its active-texture, depth/blend capability query/apply, viewport query/execution, depth-clear, and color-write-mask adapter endpoints now share `legacy_ui_gl_dispatch`, retained CanvasMode overlay/mask/transform paths now route active texture, depth/blend state, transform/cut viewport execution, paint-mode blend/depth state snapshots, and canvas-tip pick framebuffer readback through tested `pp_renderer_gl` dispatch adapters; their active-texture, capability query/apply, viewport, read-framebuffer query, and RGBA8 pixel-readback adapter endpoints now share `legacy_ui_gl_dispatch`, retained simple UI draw paths now share `legacy_ui_gl_dispatch` for blend-state execution, fallback 2D texture unbinds, `NodeViewport` viewport query/restore, color-buffer clears, and clear-color restore, retained `NodeCanvas` plus `NodeStrokePreview` draw-state paths now share `legacy_ui_gl_dispatch` for active-texture selection, fallback texture unbind, viewport/scissor execution, viewport and clear-color queries, color-buffer clears, clear-color restore, and capability query/apply adapter endpoints backed by tested `pp_renderer_gl` dispatch helpers, retained `Canvas` stroke/object/thumbnail/export/frame-clear state endpoints now share `legacy_ui_gl_dispatch` for active-texture selection, fallback texture unbind, viewport/scissor execution, viewport and clear-color query, clear-color restore, and capability query/apply adapter endpoints, retained Canvas and RTT depth renderbuffer allocation/attachment/delete now share `legacy_gl_renderbuffer_dispatch` while renderer-resource ownership remains retained, retained `Texture2D`, `TextureCube`, and RTT texture allocation/delete/bind/parameter/update/mipmap dispatch now share `legacy_gl_texture_dispatch` while renderer-resource ownership remains retained, retained `Texture2D` readback plus RTT framebuffer allocation/delete/bind/restore/blit/readback and PBO readback dispatch now share `legacy_gl_framebuffer_dispatch` while renderer-resource ownership remains retained, retained Sampler create/parameter/border/bind dispatch shares `legacy_gl_sampler_dispatch` and retained PBO allocation/readback/map/unmap/delete dispatch shares `legacy_gl_pixel_buffer_dispatch` while renderer-resource ownership remains retained, retained `Shape`, `TextMesh`, and `NodeColorWheel` mesh buffer/VAO creation/upload/draw/delete dispatch now share `legacy_gl_mesh_dispatch` while renderer-resource ownership remains retained, retained shader source compilation/deletion, program attach/link/use/delete, attribute rebinding/location lookup, active-uniform enumeration, uniform-location discovery, and uniform writes now share `legacy_gl_shader_dispatch` while shader-program ownership remains retained, retained `gl_state` save/restore and `copy_framebuffer_to_texture_target` now reuse shared retained UI/framebuffer/shader/sampler bridge callbacks while renderer state and framebuffer-copy execution remain retained, retained app startup, app clear, app UI viewport/scissor, command-convert renderer state, and desktop VR draw-state endpoints now share `legacy_ui_gl_dispatch` while app/VR renderer execution remains retained, retained RTT clear and masked-clear endpoints now share `legacy_ui_gl_dispatch` while RTT render-target execution remains retained, retained app startup logging, Windows early context logging/window-title detection, and shader capability detection now share `legacy_gl_runtime_dispatch` while runtime/capability probing remains retained, and retained `CanvasLayer` frame-clear draw-state paths route saved clear-color query and restore through the same tested helpers, but actual live stroke rasterization, dual-brush compositing, pattern feedback math, thumbnail layer compositing, brush-preview compositing, grid lightmap/heightmap mesh rendering, JPEG/XMP equirectangular metadata export, Web/incomplete-readback collection handoff, depth export writer execution, progress/threading parity, exact GPU filtering parity, and the retained `ShaderManager::ext_*` compatibility fields still use legacy OpenGL canvas/UI execution | Preserve current painting behavior while the renderer boundary matures for OpenGL parity and later Vulkan/Metal experiments | `pp_renderer_api_tests`; `pp_renderer_gl_capabilities_tests`; `pp_paint_renderer_compositor_tests`; `pano_cli plan-paint-feedback --framebuffer-fetch --explicit-transitions --render-only`; `pano_cli plan-paint-feedback --texture-copy`; `pano_cli plan-stroke-composite --stroke-blend 10 --framebuffer-fetch --explicit-transitions --render-only`; `pano_cli plan-stroke-composite --layer-blend 4 --dual-blend --texture-copy`; `pano_cli plan-canvas-document-snapshot --captured-face-payloads-per-layer 1`; `ctest --preset desktop-fast --build-config Debug`; `cmake --build --preset windows-msvc-default --config Debug --target PanoPainter` | Live stroke/layer/export compositing chooses its feedback path through `pp_paint_renderer` and renderer services, with OpenGL golden parity and Vulkan/Metal lab tests covering framebuffer-fetch and ping-pong behavior | | DEBT-0037 | Open | Modernization | Recording lifecycle/export planning, export progress-dialog metadata, and execution dispatch now consume pure `pp_app_core` through `App::rec_start`, `App::rec_stop`, `App::rec_clear`, `App::rec_export`, `pano_cli plan-recording-session`, and the `RecordingServices` boundary; live execution is centralized in `src/legacy_recording_services.*`, retained MP4 export progress bar creation routes through `src/legacy_app_dialog_services.*`, and retained `PBO` allocation/readback/map/unmap/delete operations now route through tested `pp_renderer_gl` dispatch, but the bridge still owns legacy recording thread startup/shutdown, platform recorded-file cleanup, progress lifetime, retained `App::rec_loop` readback call sites, and `MP4Encoder::write_mp4` execution | Preserve current timelapse/MP4 behavior while recording moves toward app/document/renderer/video services | `pp_app_core_document_recording_tests`; `pp_renderer_gl_capabilities_tests`; `pano_cli plan-recording-session --running --frame-count 12`; `pano_cli plan-recording-session --platform-deletes-recorded-files`; `ctest --preset desktop-fast --build-config Debug` | Recording thread lifecycle, frame readback scheduling, platform cleanup, progress reporting, and MP4 writing are owned by injected app/renderer/video services with `App` methods acting only as adapters | | DEBT-0038 | Open | Modernization | Cloud upload/browse/bulk planning, cloud prompt/progress metadata, and execution dispatch now consume pure `pp_app_core` through `App::cloud_upload`, `App::cloud_upload_all`, `App::cloud_browse`, `pano_cli plan-cloud-upload`, `pano_cli plan-cloud-upload-all`, `pano_cli plan-cloud-browse`, `pano_cli plan-cloud-transfer`, and the `CloudServices` boundary; live execution is centralized in `src/legacy_cloud_services.*`, the app-owned `upload`/`download` CURL helpers now consume `pp_app_core` cloud transfer request/progress planning and the platform TLS-verification bypass policy before retained CURL setup, upload warning/publish/success prompts, upload/bulk progress dialog titles, download-progress prompt metadata, and formatted download progress text come from tested app-core plans, retained cloud prompt/progress creation routes through `src/legacy_app_dialog_services.*` via `App::message_box`/`App::show_progress` or direct bridge calls, and retained `Asset::open_url`, `LogRemote::net_init`, and `NodeDialogCloud::load_thumbs_thread` curl sites consume the `pp_platform_api` default TLS policy helper instead of spelling Android branches locally, but the bridge still uses legacy save-before-upload, app-owned curl helpers instead of an injected network service, upload form construction, response/error handling, retained prompt/progress lifetime, OpenGL context guarding, `NodeDialogCloud`, `Canvas` project open, layer refresh, and `ActionManager` reset | Preserve current cloud behavior while cloud/network/document import flows move toward app/document/platform services | `pp_app_core_document_cloud_tests`; `pp_platform_api_tests`; `pano_cli plan-cloud-upload --new-document --unsaved`; `pano_cli plan-cloud-browse --selected-file demo.ppi`; `pano_cli plan-cloud-upload-all --file-count 3`; `pano_cli plan-cloud-transfer --direction download --progress --disable-tls-verification`; `ctest --preset desktop-fast --build-config Debug` | Cloud upload/download, TLS policy, save-before-upload, progress reporting, cloud browse dialog, downloaded project opening, layer refresh, OpenGL context ownership, and action-history reset are owned by injected app/document/network/platform/renderer services with `App` methods acting only as adapters | | DEBT-0039 | Open | Modernization | Document-open planning and execution dispatch now consume pure `pp_app_core` through `App::open_document`, `pano_cli plan-open-route`, `DocumentOpenServices`, and `src/legacy_document_open_services.*`, but the bridge still opens ABR/PPBR import prompts before delegating import execution to `src/legacy_brush_package_import_services.*`, applies unsaved-project discard prompts, calls legacy project-open execution, refreshes layer UI, updates the app title, and clears legacy history directly | Preserve current file-open/import behavior while document loading and brush import move toward app/document/asset/UI services | `pp_app_core_document_route_tests`; `pp_app_core_document_session_tests`; `pano_cli plan-open-route --path D:/Paint/Scenes/demo.ppi --unsaved`; `pano_cli plan-open-route --path D:/Paint/Brushes/clouds.ABR --unsaved`; `ctest --preset desktop-fast --build-config Debug` | Brush import prompting, project-open execution, unsaved-project discard prompting, layer refresh, title updates, and history clearing are owned by injected app/document/asset/UI services with `App::open_document` acting only as an adapter | | DEBT-0040 | Open | Modernization | Close request, document save, save-before-workflow planning/execution dispatch, and close/save-before/save-error prompt metadata now consume pure `pp_app_core` through `App::request_close`, `App::save_document`, `App::continue_document_workflow_after_optional_save`, `pano_cli simulate-app-session`, `pano_cli plan-document-session-prompt`, `DocumentSaveServices`, `CloseRequestServices`, `DocumentWorkflowServices`, and `src/legacy_document_session_services.*`; close/save-before prompt creation now uses `src/legacy_app_dialog_services.*`, Save dialog working-directory picker visibility/path formatting now dispatches through `PlatformServices`, and existing-project save/save-before-workflow execution prepares a payload-bearing canvas snapshot report before retained saving, but the bridge still opens retained save dialogs, wires prompt callbacks directly, delegates actual writing to `Canvas::project_save`, mutates the unsaved flag on close confirmation, invokes native app close, and routes save-version through the retained legacy dialog | Preserve current close/save/dirty-workflow behavior while document session execution moves toward app/document/UI/platform services | `pp_app_core_document_session_tests`; `pp_platform_api_tests`; `pano_cli plan-document-session-prompt --kind close-unsaved`; `pano_cli plan-document-session-prompt --kind save-before-workflow`; `pano_cli simulate-app-session --unsaved --save-intent save-dirty-version`; `pano_cli simulate-app-session --no-canvas`; `pano_cli plan-document-file --work-dir D:/Paint --name demo --target-exists`; `pano_cli plan-document-version --directory D:/Paint --doc-name demo.01 --existing-path D:/Paint/demo.02.ppi`; `ctest --preset desktop-fast --build-config Debug` | Close prompt execution, native close requests, dirty-workflow save prompts, existing-project saves, save dialogs, save-version execution, and unsaved-flag mutation are owned by injected app/document/UI/platform services with `App` methods acting only as adapters | | DEBT-0041 | Open | Modernization | Accepted new-document planning/execution dispatch and new-document overwrite prompt metadata now consume pure `pp_app_core` through `App::dialog_newdoc`, `pano_cli plan-new-document`, `pano_cli plan-document-session-prompt`, `NewDocumentServices`, and `src/legacy_document_session_services.*`; new-document overwrite prompt creation now uses `src/legacy_app_dialog_services.*`, and New Document dialog working-directory picker visibility/path formatting now dispatches through `PlatformServices`, but the bridge still mutates legacy app document fields, clears legacy layer UI, resizes legacy `Canvas`, clears legacy history, creates the default layer through legacy UI, mutates unsaved/new-document flags, updates the title, wires overwrite callbacks directly, and handles keyboard/dialog cleanup directly | Preserve current New Document dialog behavior while document creation moves toward app/document/UI services | `pp_app_core_document_session_tests`; `pp_platform_api_tests`; `pano_cli plan-new-document --work-dir D:/Paint --name demo --resolution-index 3`; `pano_cli plan-new-document --work-dir D:/Paint --name demo --resolution-index 3 --target-exists`; `pano_cli plan-document-session-prompt --kind new-document-overwrite`; `pano_cli simulate-app-session --save-intent save`; `ctest --preset desktop-fast --build-config Debug` | New document creation, overwrite confirmation, canvas/document allocation, default layer creation, history clearing, title updates, dirty/new-document state, and keyboard/dialog cleanup are owned by injected app/document/UI services with `App::dialog_newdoc` acting only as a UI adapter | | DEBT-0042 | Open | Modernization | Accepted Save As and Save Version planning/execution dispatch plus Save As overwrite prompt metadata now consumes pure `pp_app_core` through `App::dialog_save`, `App::dialog_save_ver`, `pano_cli plan-document-file`, `pano_cli plan-document-version`, `pano_cli plan-document-session-prompt`, `DocumentFileSaveServices`, `DocumentVersionSaveServices`, and `src/legacy_document_session_services.*`; Save As overwrite prompt creation now uses `src/legacy_app_dialog_services.*`, and accepted Save As/Save Version execution prepares a payload-bearing canvas snapshot report before retained saving, but the bridge still wires overwrite callbacks directly, delegates actual writing to legacy `Canvas::project_save`, mutates app document name/path/directory fields, marks version saves dirty before saving, updates the title, and handles keyboard/dialog cleanup directly | Preserve current Save As and Save Version behavior while document persistence moves toward app/document/storage/UI services | `pp_app_core_document_session_tests`; `pano_cli plan-document-file --work-dir D:/Paint --name demo --target-exists`; `pano_cli plan-document-session-prompt --kind file-overwrite --name demo`; `pano_cli plan-document-version --directory D:/Paint --doc-name demo.01 --existing-path D:/Paint/demo.02.ppi`; `pano_cli simulate-app-session --save-intent save-as`; `pano_cli simulate-app-session --save-intent save-version`; `ctest --preset desktop-fast --build-config Debug` | Save As overwrite prompting, project-save execution, app document metadata updates, title updates, version-save dirty-state handling, and keyboard/dialog cleanup are owned by injected app/document/storage/UI services with `App::dialog_save` and `App::dialog_save_ver` acting only as UI adapters | -| DEBT-0043 | Open | Modernization | Equirectangular, layer, animation-frame, depth, and cube-face export planning/execution dispatch now consumes pure `pp_app_core` through `App::dialog_export`, `App::dialog_export_layers`, `App::dialog_export_anim_frames`, `App::dialog_export_depth`, `App::dialog_export_cube_faces`, `pano_cli plan-export-*`, `DocumentExportServices`, and `src/legacy_document_export_services.*`; layer/frame dialogs also consume `plan_document_export_collection_target` plus `PlatformServices::uses_work_directory_document_export_collections()` instead of spelling local iOS branches, export success/failure/license dialog metadata plus execution log labels now come from `pp_app_core`, equirectangular/layer/animation-frame/cube-face execution prepares a payload-bearing document snapshot plus the shared `pp_paint_renderer::prepare_document_frame_export_readiness` report, cube-face export writes the pure face PNG bytes to `pp_app_core` planned work-directory face paths through `execute_document_cube_face_export_write` before falling back to retained Canvas execution on failure, and PNG equirectangular export writes the pure `pp_paint_renderer` equirectangular PNG before retained fallback, but the bridge still adapts retained filesystem writes/exported-image publishing locally, still calls legacy `Canvas` export methods for JPEG/XMP equirectangular export, layers, animation, and depth, creates export directories, handles picker-selected stems, performs Web prepared-file handoff directly, and leaves depth export on the retained path | Preserve current image/collection/depth/cube export behavior while export execution moves toward document/renderer/platform/storage services | `pp_app_core_document_export_tests`; `pp_platform_api_tests`; `pano_cli plan-export-start --requires-license --demo`; `pano_cli plan-export-menu --kind layers`; `pano_cli plan-export-target --kind collection --work-dir D:/Paint --doc-name demo --suffix _layers`; `pano_cli plan-export-target --kind cube-faces --work-dir D:/Paint --doc-name demo`; `pano_cli plan-export-message --kind equirectangular --destination work --detail D:/Paint`; `pano_cli plan-export-report --kind license-disabled`; `pano_cli simulate-document-export`; `ctest --preset desktop-fast --build-config Debug` | File, collection, stem, depth, and remaining retained export execution, export-directory creation, Web file handoff, picker-selected stem handling, and legacy canvas export calls are owned by injected document/renderer/platform/storage services with export dialogs acting only as UI adapters | +| DEBT-0043 | Open | Modernization | Equirectangular, layer, animation-frame, depth, and cube-face export planning/execution dispatch now consumes pure `pp_app_core` through `App::dialog_export`, `App::dialog_export_layers`, `App::dialog_export_anim_frames`, `App::dialog_export_depth`, `App::dialog_export_cube_faces`, `pano_cli plan-export-*`, `DocumentExportServices`, and `src/legacy_document_export_services.*`; layer/frame dialogs also consume `plan_document_export_collection_target` plus `PlatformServices::uses_work_directory_document_export_collections()` instead of spelling local iOS branches, export success/failure/license dialog metadata plus execution log labels now come from `pp_app_core`, equirectangular/layer/animation-frame/cube-face execution prepares a payload-bearing document snapshot plus the shared `pp_paint_renderer::prepare_document_frame_export_readiness` report, cube-face export writes the pure face PNG bytes to `pp_app_core` planned work-directory face paths through `execute_document_cube_face_export_write` before falling back to retained Canvas execution on failure, PNG equirectangular export writes the pure `pp_paint_renderer` equirectangular PNG before retained fallback, and payload-complete layer/animation-frame collections write pure `pp_paint_renderer` PNG sequences through `execute_document_export_collection_write` before retained fallback, but the bridge still adapts retained filesystem writes/exported-image publishing locally, still calls legacy `Canvas` export methods for JPEG/XMP equirectangular export, Web/incomplete-readback collection exports, and depth, creates export directories, handles picker-selected stems, performs Web prepared-file handoff directly, and leaves depth export on the retained path | Preserve current image/collection/depth/cube export behavior while export execution moves toward document/renderer/platform/storage services | `pp_app_core_document_export_tests`; `pp_platform_api_tests`; `pano_cli plan-export-start --requires-license --demo`; `pano_cli plan-export-menu --kind layers`; `pano_cli plan-export-target --kind collection --work-dir D:/Paint --doc-name demo --suffix _layers`; `pano_cli plan-export-target --kind cube-faces --work-dir D:/Paint --doc-name demo`; `pano_cli plan-export-message --kind equirectangular --destination work --detail D:/Paint`; `pano_cli plan-export-report --kind license-disabled`; `pano_cli simulate-document-export`; `ctest --preset desktop-fast --build-config Debug` | File, collection, stem, depth, and remaining retained export execution, export-directory creation, Web file handoff, picker-selected stem handling, and legacy canvas export calls are owned by injected document/renderer/platform/storage services with export dialogs acting only as UI adapters | | DEBT-0044 | Open | Modernization | Timelapse and animation MP4 export execution dispatch now consumes pure `pp_app_core` through `App::dialog_timelapse_export`, `App::dialog_export_mp4`, `pano_cli plan-export-menu`, `pano_cli plan-export-target --kind name`, `pano_cli plan-export-message`, `pano_cli plan-export-report`, `DocumentVideoExportServices`, and `src/legacy_document_export_services.*`, and success/failure/license dialog metadata plus execution log labels now come from `pp_app_core`, but the bridge still launches legacy desktop timelapse worker threads, calls `App::rec_export`, calls `Canvas::export_anim_mp4`, and owns mobile/Web save callbacks | Preserve current MP4/timelapse export behavior while video export moves toward app/document/renderer/video/platform/storage services | `pp_app_core_document_export_tests`; `pano_cli plan-export-menu --kind animation-mp4`; `pano_cli plan-export-menu --kind timelapse`; `pano_cli plan-export-target --kind name --doc-name demo --suffix -animation`; `pano_cli plan-export-target --kind name --doc-name demo --suffix -timelapse`; `pano_cli plan-export-message --kind timelapse --destination success`; `pano_cli plan-export-report --kind animation-mp4 --message "video export path must not be empty"`; `ctest --preset desktop-fast --build-config Debug` | Timelapse and animation MP4 execution, desktop worker threading, frame readback/video encoding handoff, and mobile/Web save callbacks are owned by injected app/document/renderer/video/platform/storage services with export dialogs acting only as UI adapters | | DEBT-0045 | Open | Modernization | Options-menu preference execution now consumes pure `pp_app_core` through UI scale, viewport scale, RTL direction, VR mode, VR-controller, auto-timelapse, and canvas cursor-mode callbacks plus `AppPreferenceServices` and `src/legacy_app_preference_services.*`; viewport-density and cursor-mode execution now delegate to `src/legacy_canvas_view_services.*`, but the bridges still call legacy `App::set_ui_scale`, `App::set_ui_rtl`, `App::rec_start`, `App::rec_stop`, retained canvas view mutation, and `Settings::save` directly; VR mode callbacks now call `App` VR wrappers that dispatch to `PlatformServices`, whose desktop runtime policy prefers OpenXR while the actual Windows OpenVR SDK bridge still lives in `WindowsPlatformServices` under DEBT-0061 | Preserve current options-menu behavior while preferences move toward app/UI/platform/storage services | `pp_app_core_app_preferences_tests`; `pp_app_core_canvas_view_tests`; `pano_cli plan-app-preferences --ui-scale 1.5 --display-density 2 --current-scale 1.6 --scale-option 1 --scale-option 1.5 --rtl`; `pano_cli plan-canvas-view-density --density 1.5`; `pano_cli plan-canvas-view-cursor-mode --mode 3`; `ctest --preset desktop-fast --build-config Debug`; `cmake --build --preset windows-msvc-default --config Debug --target PanoPainter` | Preference persistence, UI/layout direction, viewport density, cursor mode, VR mode start/stop/failure handling, VR-controller state, and auto-timelapse recording side effects are owned by injected app/UI/platform/storage services with options-menu callbacks acting only as UI adapters | | DEBT-0046 | Open | Modernization | Startup preference/runtime execution and startup resource sequencing now consume pure `pp_app_core` through `App::init`, `pano_cli plan-app-startup`, `pano_cli plan-app-startup-resources`, `AppStartupServices`, `AppStartupResourceServices`, and `src/legacy_app_startup_services.*`, but the bridge still calls legacy `Settings::set`, `Settings::save`, `App::rec_start`, app VR-controller state mutation, message-box license warning execution, shader loading, asset initialization, layout creation, title updates, and UI render-target creation directly | Preserve current startup behavior while app startup moves toward app/preferences/storage/recording/UI/renderer services | `pp_app_core_app_startup_tests`; `pano_cli plan-app-startup --run-counter 7 --vr-controllers-disabled --license-invalid`; `pano_cli plan-app-startup --run-counter -1`; `pano_cli plan-app-startup-resources --width 1280 --height 720`; `pano_cli plan-app-startup-resources --bad-size`; `ctest --preset desktop-fast --build-config Debug`; `cmake --build --preset windows-msvc-default --config Debug --target PanoPainter` | Startup preference persistence, auto-timelapse startup, stored VR-controller state, license validation/warning, startup resource initialization, title updates, and UI render-target allocation are owned by injected app/preferences/storage/recording/UI/renderer services with `App::init` acting only as orchestration | diff --git a/docs/modernization/roadmap.md b/docs/modernization/roadmap.md index 787164d..a65497e 100644 --- a/docs/modernization/roadmap.md +++ b/docs/modernization/roadmap.md @@ -692,9 +692,12 @@ executor using the app-core-planned legacy face filenames when available and falls back to retained `Canvas::export_cube_faces` on snapshot/write failure. PNG equirectangular export now uses the same document/composite payload to generate an equirectangular PNG through `pp_paint_renderer` before the retained -fallback. JPEG/XMP equirectangular export, layer collections, animation-frame -collections, depth, and video still delegate to retained `Canvas` writers after -readiness reporting. +fallback. Payload-complete layer and animation-frame PNG collections now use +pure `pp_paint_renderer` equirectangular PNG generation plus app-core +collection write/publish execution before retained fallback. JPEG/XMP +equirectangular export, Web handoff, depth, video, and incomplete-readback +collection cases still delegate to retained `Canvas` writers after readiness +reporting. `pano_cli plan-image-import` exposes app-core planning for File > Import image route decisions, including wide equirectangular images, legacy vertical cube strips, regular transform-placement images, and invalid image dimensions; live @@ -2536,10 +2539,13 @@ Results: write/publish service executor before falling back to retained `Canvas` execution on failure. PNG equirectangular export now writes a `pp_paint_renderer` equirectangular PNG from the same composited document - frame before falling back to retained `Canvas` execution; JPEG/XMP, - layer, animation-frame, depth, and video export remain on their prior - retained writer paths. Actual broader writer replacement remains tracked - under export debt. + frame before falling back to retained `Canvas` execution; payload-complete + layer and animation-frame PNG collections now write pure + `pp_paint_renderer` equirectangular PNG sequences through a tested app-core + collection write/publish executor before retained fallback. JPEG/XMP, + Web prepared-file handoff, depth, video, and incomplete-readback collection + cases remain on their prior retained writer paths. Actual broader writer + replacement remains tracked under export debt. - Snapshot creation now rejects invalid embedded RGBA8 face payloads before document export or history can persist malformed state. - Package-smoke wrappers validate the Windows CMake app executable/runtime diff --git a/src/app_core/document_export.h b/src/app_core/document_export.h index 5959282..be86a5a 100644 --- a/src/app_core/document_export.h +++ b/src/app_core/document_export.h @@ -41,6 +41,11 @@ struct DocumentCubeFaceExportPayload { std::span bytes; }; +struct DocumentExportCollectionPngPayload { + std::string path_suffix; + std::span bytes; +}; + struct DocumentExportSuggestedName { std::string name; }; @@ -190,6 +195,16 @@ public: virtual void publish_exported_image(std::string_view path) = 0; }; +class DocumentExportCollectionWriteServices { +public: + virtual ~DocumentExportCollectionWriteServices() = default; + + virtual pp::foundation::Status write_binary_file( + std::string_view path, + std::span bytes) = 0; + virtual void publish_exported_image(std::string_view path) = 0; +}; + [[nodiscard]] constexpr DocumentExportStartDecision plan_document_export_start( bool requires_license, bool license_valid, @@ -608,6 +623,41 @@ document_cube_face_export_names() noexcept return pp::foundation::Result::success(std::move(target)); } +[[nodiscard]] inline std::string document_export_two_digit_index(std::size_t index) +{ + auto value = std::to_string(index); + if (value.size() < 2U) { + value.insert(value.begin(), '0'); + } + return value; +} + +[[nodiscard]] inline std::string make_document_layer_export_path_suffix( + std::size_t layer_index, + std::string_view layer_name) +{ + std::string suffix; + const auto index = document_export_two_digit_index(layer_index); + suffix.reserve(10U + index.size() + layer_name.size()); + suffix += "-layer"; + suffix += index; + suffix += "-"; + suffix += layer_name; + suffix += ".png"; + return suffix; +} + +[[nodiscard]] inline std::string make_document_animation_frame_export_path_suffix(std::size_t frame_index) +{ + std::string suffix; + const auto index = document_export_two_digit_index(frame_index); + suffix.reserve(5U + index.size()); + suffix += "-"; + suffix += index; + suffix += ".png"; + return suffix; +} + [[nodiscard]] inline pp::foundation::Result make_document_export_suggested_name( std::string_view document_name, std::string_view suffix) @@ -656,6 +706,41 @@ document_cube_face_export_names() noexcept return pp::foundation::Status::success(); } +[[nodiscard]] inline pp::foundation::Status execute_document_export_collection_write( + const DocumentExportCollectionTarget& target, + std::span payloads, + DocumentExportCollectionWriteServices& services) +{ + if (target.stem_path.empty()) { + return pp::foundation::Status::invalid_argument("export collection target requires a stem path"); + } + + if (payloads.empty()) { + return pp::foundation::Status::invalid_argument("export collection payloads must not be empty"); + } + + for (const auto& payload : payloads) { + if (payload.path_suffix.empty()) { + return pp::foundation::Status::invalid_argument("export collection payload suffix must not be empty"); + } + if (payload.bytes.empty()) { + return pp::foundation::Status::invalid_argument("export collection payload must not be empty"); + } + + std::string path; + path.reserve(target.stem_path.size() + payload.path_suffix.size()); + path += target.stem_path; + path += payload.path_suffix; + const auto write_status = services.write_binary_file(path, payload.bytes); + if (!write_status.ok()) { + return write_status; + } + services.publish_exported_image(path); + } + + return pp::foundation::Status::success(); +} + [[nodiscard]] inline pp::foundation::Status execute_document_export_file( const DocumentExportFileTarget& target, DocumentExportServices& services) diff --git a/src/legacy_document_export_services.cpp b/src/legacy_document_export_services.cpp index 3d9178c..2513241 100644 --- a/src/legacy_document_export_services.cpp +++ b/src/legacy_document_export_services.cpp @@ -65,9 +65,11 @@ pp::foundation::Status write_export_binary_file(std::string_view path, std::span return pp::foundation::Status::success(); } -class LegacyCubeFaceExportWriteServices final : public pp::app::DocumentCubeFaceExportWriteServices { +class LegacyExportWriteServices final + : public pp::app::DocumentCubeFaceExportWriteServices + , public pp::app::DocumentExportCollectionWriteServices { public: - explicit LegacyCubeFaceExportWriteServices(App& app) noexcept + explicit LegacyExportWriteServices(App& app) noexcept : app_(app) { } @@ -183,10 +185,90 @@ pp::foundation::Status export_cube_faces_from_document_snapshot( payloads[face_index].bytes = std::span(reports.face_pngs.face_pngs[face_index]); } - LegacyCubeFaceExportWriteServices services(app); + LegacyExportWriteServices services(app); return pp::app::execute_document_cube_face_export_write(target.value(), payloads, services); } +pp::foundation::Status export_layers_from_document_snapshot( + App& app, + const pp::app::DocumentExportCollectionTarget& target, + const LegacyDocumentExportSnapshotReports& reports) +{ + const auto report = pp::app::make_document_canvas_save_snapshot_report(reports.snapshot); + if (!report.payload_complete) { + return pp::foundation::Status::invalid_argument( + "document snapshot layer export still requires renderer payload readback"); + } + + auto exported = pp::paint_renderer::export_document_layers_equirectangular_pngs( + pp::paint_renderer::DocumentLayerEquirectangularPngExportRequest { + .document = &reports.snapshot.document, + .frame_index = reports.snapshot.document.active_frame_index(), + .clear_color = {}, + }); + if (!exported) { + return exported.status(); + } + + auto exported_value = std::move(exported.value()); + LOG( + "export-layers document export PNG writer: layers=%zu bytes=%llu activeFrame=%zu", + exported_value.layer_count, + static_cast(exported_value.encoded_bytes), + reports.snapshot.document.active_frame_index()); + + std::vector payloads; + payloads.reserve(exported_value.layers.size()); + for (const auto& layer : exported_value.layers) { + payloads.push_back(pp::app::DocumentExportCollectionPngPayload { + .path_suffix = pp::app::make_document_layer_export_path_suffix(layer.layer_index, layer.layer_name), + .bytes = std::span(layer.png.data(), layer.png.size()), + }); + } + + LegacyExportWriteServices services(app); + return pp::app::execute_document_export_collection_write(target, payloads, services); +} + +pp::foundation::Status export_animation_frames_from_document_snapshot( + App& app, + const pp::app::DocumentExportCollectionTarget& target, + const LegacyDocumentExportSnapshotReports& reports) +{ + const auto report = pp::app::make_document_canvas_save_snapshot_report(reports.snapshot); + if (!report.payload_complete) { + return pp::foundation::Status::invalid_argument( + "document snapshot animation-frame export still requires renderer payload readback"); + } + + auto exported = pp::paint_renderer::export_document_animation_frames_equirectangular_pngs( + pp::paint_renderer::DocumentAnimationFrameEquirectangularPngExportRequest { + .document = &reports.snapshot.document, + .clear_color = {}, + }); + if (!exported) { + return exported.status(); + } + + auto exported_value = std::move(exported.value()); + LOG( + "export-animation-frames document export PNG writer: frames=%zu bytes=%llu", + exported_value.frame_count, + static_cast(exported_value.encoded_bytes)); + + std::vector payloads; + payloads.reserve(exported_value.frames.size()); + for (const auto& frame : exported_value.frames) { + payloads.push_back(pp::app::DocumentExportCollectionPngPayload { + .path_suffix = pp::app::make_document_animation_frame_export_path_suffix(frame.frame_index), + .bytes = std::span(frame.png.data(), frame.png.size()), + }); + } + + LegacyExportWriteServices services(app); + return pp::app::execute_document_export_collection_write(target, payloads, services); +} + pp::foundation::Status export_equirectangular_png_from_document_snapshot( App& app, const pp::app::DocumentExportFileTarget& target, @@ -284,7 +366,32 @@ public: void export_layers_to_stem(const pp::app::DocumentExportStemTarget& target) override { auto* app = &app_; +#if !__WEB__ + const auto prepared = prepare_legacy_document_export_snapshot(app_, "export-layers"); + if (prepared) { + const auto collection_target = pp::app::DocumentExportCollectionTarget { + .stem_path = target.stem_path, + }; + const auto exported = export_layers_from_document_snapshot(app_, collection_target, prepared.value()); + if (exported.ok()) { + show_export_success_dialog( + app_, + pp::app::plan_document_export_success_dialog( + pp::app::DocumentExportSuccessKind::layers, + pp::app::DocumentExportSuccessDestination::path, + target.stem_path)); + return; + } + + LOG("export-layers document export writer retained legacy export after failure: %s", exported.message); + } else { + LOG( + "export-layers document export snapshot bridge retained legacy export after failure: %s", + prepared.status().message); + } +#else prepare_legacy_document_export_snapshot_or_continue(app_, "export-layers"); +#endif app_.canvas->m_canvas->export_layers(target.stem_path, [app, target] { show_export_success_dialog( *app, @@ -298,7 +405,28 @@ public: void export_layers_to_collection(const pp::app::DocumentExportCollectionTarget& target) override { auto* app = &app_; +#if !__WEB__ + const auto prepared = prepare_legacy_document_export_snapshot(app_, "export-layers"); + if (prepared) { + const auto exported = export_layers_from_document_snapshot(app_, target, prepared.value()); + if (exported.ok()) { + show_export_success_dialog( + app_, + pp::app::plan_document_export_success_dialog( + pp::app::DocumentExportSuccessKind::layers, + pp::app::DocumentExportSuccessDestination::files_panopainter)); + return; + } + + LOG("export-layers document export writer retained legacy export after failure: %s", exported.message); + } else { + LOG( + "export-layers document export snapshot bridge retained legacy export after failure: %s", + prepared.status().message); + } +#else prepare_legacy_document_export_snapshot_or_continue(app_, "export-layers"); +#endif app_.canvas->m_canvas->export_layers(target.stem_path, [app] { show_export_success_dialog( *app, @@ -311,7 +439,37 @@ public: void export_animation_frames_to_stem(const pp::app::DocumentExportStemTarget& target) override { auto* app = &app_; +#if !__WEB__ + const auto prepared = prepare_legacy_document_export_snapshot(app_, "export-animation-frames"); + if (prepared) { + const auto collection_target = pp::app::DocumentExportCollectionTarget { + .stem_path = target.stem_path, + }; + const auto exported = export_animation_frames_from_document_snapshot( + app_, + collection_target, + prepared.value()); + if (exported.ok()) { + show_export_success_dialog( + app_, + pp::app::plan_document_export_success_dialog( + pp::app::DocumentExportSuccessKind::animation_frames, + pp::app::DocumentExportSuccessDestination::path, + target.stem_path)); + return; + } + + LOG( + "export-animation-frames document export writer retained legacy export after failure: %s", + exported.message); + } else { + LOG( + "export-animation-frames document export snapshot bridge retained legacy export after failure: %s", + prepared.status().message); + } +#else prepare_legacy_document_export_snapshot_or_continue(app_, "export-animation-frames"); +#endif app_.canvas->m_canvas->export_anim_frames(target.stem_path, [app, target] { show_export_success_dialog( *app, @@ -325,7 +483,30 @@ public: void export_animation_frames_to_collection(const pp::app::DocumentExportCollectionTarget& target) override { auto* app = &app_; +#if !__WEB__ + const auto prepared = prepare_legacy_document_export_snapshot(app_, "export-animation-frames"); + if (prepared) { + const auto exported = export_animation_frames_from_document_snapshot(app_, target, prepared.value()); + if (exported.ok()) { + show_export_success_dialog( + app_, + pp::app::plan_document_export_success_dialog( + pp::app::DocumentExportSuccessKind::animation_frames, + pp::app::DocumentExportSuccessDestination::files_panopainter)); + return; + } + + LOG( + "export-animation-frames document export writer retained legacy export after failure: %s", + exported.message); + } else { + LOG( + "export-animation-frames document export snapshot bridge retained legacy export after failure: %s", + prepared.status().message); + } +#else prepare_legacy_document_export_snapshot_or_continue(app_, "export-animation-frames"); +#endif app_.canvas->m_canvas->export_anim_frames(target.stem_path, [app] { show_export_success_dialog( *app, diff --git a/src/paint_renderer/compositor.cpp b/src/paint_renderer/compositor.cpp index 89f6065..eded8c7 100644 --- a/src/paint_renderer/compositor.cpp +++ b/src/paint_renderer/compositor.cpp @@ -408,6 +408,77 @@ pp::foundation::Result composite_document_frame( return pp::foundation::Result::success(std::move(result)); } +pp::foundation::Result composite_document_layer_frame( + const pp::document::CanvasDocument& document, + std::size_t layer_index, + std::size_t frame_index, + pp::paint::Rgba clear_color) +{ + if (layer_index >= document.layers().size()) { + return pp::foundation::Result::failure( + pp::foundation::Status::out_of_range("document layer export index is outside the document")); + } + + if (frame_index >= document.frames().size()) { + return pp::foundation::Result::failure( + pp::foundation::Status::out_of_range("document layer export frame index is outside the document")); + } + + const pp::renderer::Extent2D extent { + .width = document.width(), + .height = document.height(), + }; + const auto pixel_count = expected_pixel_count(extent); + if (!pixel_count) { + return pp::foundation::Result::failure(pixel_count.status()); + } + + const auto& source_layer = document.layers()[layer_index]; + auto export_layer = source_layer; + export_layer.visible = true; + export_layer.opacity = 1.0F; + export_layer.blend_mode = pp::paint::BlendMode::normal; + + DocumentFrameCompositeResult result; + result.extent = extent; + result.visited_layer_count = 1U; + + for (std::uint32_t face_index = 0; face_index < pp::document::cube_face_count; ++face_index) { + DocumentFaceCompositeResult face; + face.extent = extent; + face.pixels.assign(pixel_count.value(), clear_color); + face.visited_layer_count = 1U; + + if (frame_index < source_layer.frames.size()) { + bool composited_face = false; + const auto& frame = source_layer.frames[frame_index]; + for (const auto& payload : frame.face_pixels) { + if (payload.face_index != face_index) { + continue; + } + + const auto status = composite_face_payload(face.pixels, extent, payload, export_layer); + if (!status.ok()) { + return pp::foundation::Result::failure(status); + } + + composited_face = true; + ++face.face_payload_count; + ++result.face_payload_count; + } + + if (composited_face) { + face.composited_layer_count = 1U; + ++result.composited_layer_face_count; + } + } + + result.faces[face_index] = std::move(face); + } + + return pp::foundation::Result::success(std::move(result)); +} + pp::foundation::Result upload_document_frame_faces( pp::renderer::IRenderDevice& device, DocumentFrameUploadRequest request) @@ -612,6 +683,91 @@ export_document_frame_equirectangular_png(DocumentFrameCompositeRequest request) return export_document_frame_equirectangular_png(composite.value()); } +pp::foundation::Result +export_document_layers_equirectangular_pngs(DocumentLayerEquirectangularPngExportRequest request) +{ + if (request.document == nullptr) { + return pp::foundation::Result::failure( + pp::foundation::Status::invalid_argument("document layer export request requires a document")); + } + + if (request.frame_index >= request.document->frames().size()) { + return pp::foundation::Result::failure( + pp::foundation::Status::out_of_range("document layer export frame index is outside the document")); + } + + DocumentLayerEquirectangularPngExportResult result; + result.layers.reserve(request.document->layers().size()); + for (std::size_t layer_index = 0; layer_index < request.document->layers().size(); ++layer_index) { + auto composite = composite_document_layer_frame( + *request.document, + layer_index, + request.frame_index, + request.clear_color); + if (!composite) { + return pp::foundation::Result::failure(composite.status()); + } + + auto exported = export_document_frame_equirectangular_png(composite.value()); + if (!exported) { + return pp::foundation::Result::failure(exported.status()); + } + + DocumentLayerEquirectangularPng layer; + layer.layer_index = layer_index; + layer.layer_name = request.document->layers()[layer_index].name; + layer.face_extent = exported.value().face_extent; + layer.equirectangular_extent = exported.value().equirectangular_extent; + layer.encoded_bytes = exported.value().encoded_bytes; + layer.face_payload_count = exported.value().face_payload_count; + layer.composited_layer_face_count = exported.value().composited_layer_face_count; + layer.png = std::move(exported.value().png); + result.encoded_bytes += layer.encoded_bytes; + result.layers.push_back(std::move(layer)); + } + + result.layer_count = result.layers.size(); + return pp::foundation::Result::success(std::move(result)); +} + +pp::foundation::Result +export_document_animation_frames_equirectangular_pngs( + DocumentAnimationFrameEquirectangularPngExportRequest request) +{ + if (request.document == nullptr) { + return pp::foundation::Result::failure( + pp::foundation::Status::invalid_argument("document animation-frame export request requires a document")); + } + + DocumentAnimationFrameEquirectangularPngExportResult result; + result.frames.reserve(request.document->frames().size()); + for (std::size_t frame_index = 0; frame_index < request.document->frames().size(); ++frame_index) { + auto exported = export_document_frame_equirectangular_png(DocumentFrameCompositeRequest { + .document = request.document, + .frame_index = frame_index, + .clear_color = request.clear_color, + }); + if (!exported) { + return pp::foundation::Result::failure( + exported.status()); + } + + DocumentAnimationFrameEquirectangularPng frame; + frame.frame_index = frame_index; + frame.face_extent = exported.value().face_extent; + frame.equirectangular_extent = exported.value().equirectangular_extent; + frame.encoded_bytes = exported.value().encoded_bytes; + frame.face_payload_count = exported.value().face_payload_count; + frame.composited_layer_face_count = exported.value().composited_layer_face_count; + frame.png = std::move(exported.value().png); + result.encoded_bytes += frame.encoded_bytes; + result.frames.push_back(std::move(frame)); + } + + result.frame_count = result.frames.size(); + return pp::foundation::Result::success(std::move(result)); +} + pp::foundation::Result prepare_document_frame_export_readiness( DocumentFrameCompositeRequest request) { diff --git a/src/paint_renderer/compositor.h b/src/paint_renderer/compositor.h index 2ca9d53..c40f9ac 100644 --- a/src/paint_renderer/compositor.h +++ b/src/paint_renderer/compositor.h @@ -10,6 +10,7 @@ #include #include #include +#include #include namespace pp::paint_renderer { @@ -155,6 +156,50 @@ struct DocumentFrameEquirectangularPngExportResult { std::size_t composited_layer_face_count = 0; }; +struct DocumentLayerEquirectangularPngExportRequest { + const pp::document::CanvasDocument* document = nullptr; + std::size_t frame_index = 0; + pp::paint::Rgba clear_color {}; +}; + +struct DocumentLayerEquirectangularPng { + std::size_t layer_index = 0; + std::string layer_name; + pp::renderer::Extent2D face_extent {}; + pp::renderer::Extent2D equirectangular_extent {}; + std::vector png; + std::uint64_t encoded_bytes = 0; + std::size_t face_payload_count = 0; + std::size_t composited_layer_face_count = 0; +}; + +struct DocumentLayerEquirectangularPngExportResult { + std::vector layers; + std::uint64_t encoded_bytes = 0; + std::size_t layer_count = 0; +}; + +struct DocumentAnimationFrameEquirectangularPngExportRequest { + const pp::document::CanvasDocument* document = nullptr; + pp::paint::Rgba clear_color {}; +}; + +struct DocumentAnimationFrameEquirectangularPng { + std::size_t frame_index = 0; + pp::renderer::Extent2D face_extent {}; + pp::renderer::Extent2D equirectangular_extent {}; + std::vector png; + std::uint64_t encoded_bytes = 0; + std::size_t face_payload_count = 0; + std::size_t composited_layer_face_count = 0; +}; + +struct DocumentAnimationFrameEquirectangularPngExportResult { + std::vector frames; + std::uint64_t encoded_bytes = 0; + std::size_t frame_count = 0; +}; + struct DocumentFrameExportReadinessResult { RecordedDocumentFrameUploadResult recorded_upload {}; DocumentFrameFacePngExportResult face_pngs {}; @@ -187,6 +232,13 @@ export_document_frame_equirectangular_png(const DocumentFrameCompositeResult& co [[nodiscard]] pp::foundation::Result export_document_frame_equirectangular_png(DocumentFrameCompositeRequest request); +[[nodiscard]] pp::foundation::Result +export_document_layers_equirectangular_pngs(DocumentLayerEquirectangularPngExportRequest request); + +[[nodiscard]] pp::foundation::Result +export_document_animation_frames_equirectangular_pngs( + DocumentAnimationFrameEquirectangularPngExportRequest request); + [[nodiscard]] pp::foundation::Result prepare_document_frame_export_readiness( DocumentFrameCompositeRequest request); diff --git a/tests/app_core/document_export_tests.cpp b/tests/app_core/document_export_tests.cpp index 1cf6783..0f20379 100644 --- a/tests/app_core/document_export_tests.cpp +++ b/tests/app_core/document_export_tests.cpp @@ -152,7 +152,9 @@ public: std::string call_order; }; -class FakeDocumentCubeFaceExportWriteServices final : public pp::app::DocumentCubeFaceExportWriteServices { +class FakeDocumentCubeFaceExportWriteServices final + : public pp::app::DocumentCubeFaceExportWriteServices + , public pp::app::DocumentExportCollectionWriteServices { public: pp::foundation::Status write_binary_file( std::string_view path, @@ -347,6 +349,96 @@ void cube_face_export_writer_rejects_malformed_inputs(pp::tests::Harness& harnes PP_EXPECT(harness, services.publish_calls == 0); } +void collection_export_builds_legacy_path_suffixes(pp::tests::Harness& harness) +{ + PP_EXPECT( + harness, + pp::app::make_document_layer_export_path_suffix(0, "Base") == "-layer00-Base.png"); + PP_EXPECT( + harness, + pp::app::make_document_layer_export_path_suffix(12, "Paint") == "-layer12-Paint.png"); + PP_EXPECT( + harness, + pp::app::make_document_animation_frame_export_path_suffix(0) == "-00.png"); + PP_EXPECT( + harness, + pp::app::make_document_animation_frame_export_path_suffix(125) == "-125.png"); +} + +void collection_export_writer_writes_and_publishes_payloads_in_order(pp::tests::Harness& harness) +{ + const auto target = pp::app::make_document_export_collection_target("D:/Paint", "demo", "_layers"); + const std::array base_bytes {}; + const std::array paint_bytes {}; + const pp::app::DocumentExportCollectionPngPayload payloads[] { + { + .path_suffix = pp::app::make_document_layer_export_path_suffix(0, "Base"), + .bytes = std::span(base_bytes), + }, + { + .path_suffix = pp::app::make_document_layer_export_path_suffix(1, "Paint"), + .bytes = std::span(paint_bytes), + }, + }; + FakeDocumentCubeFaceExportWriteServices services; + + PP_EXPECT(harness, target); + PP_EXPECT( + harness, + pp::app::execute_document_export_collection_write(target.value(), payloads, services).ok()); + PP_EXPECT(harness, services.write_calls == 2); + PP_EXPECT(harness, services.publish_calls == 2); + PP_EXPECT(harness, services.total_bytes == 5U); + PP_EXPECT(harness, services.last_path == "D:/Paint/demo_layers/demo-layer01-Paint.png"); + PP_EXPECT( + harness, + services.call_order + == "write:D:/Paint/demo_layers/demo-layer00-Base.png;" + "publish:D:/Paint/demo_layers/demo-layer00-Base.png;" + "write:D:/Paint/demo_layers/demo-layer01-Paint.png;" + "publish:D:/Paint/demo_layers/demo-layer01-Paint.png;"); +} + +void collection_export_writer_rejects_malformed_inputs(pp::tests::Harness& harness) +{ + const auto target = pp::app::make_document_export_collection_target("D:/Paint", "demo", "_frames"); + const std::array bytes {}; + pp::app::DocumentExportCollectionPngPayload payloads[] { + { + .path_suffix = pp::app::make_document_animation_frame_export_path_suffix(0), + .bytes = std::span(bytes), + }, + }; + FakeDocumentCubeFaceExportWriteServices services; + + PP_EXPECT(harness, target); + auto empty_stem = target.value(); + empty_stem.stem_path.clear(); + PP_EXPECT( + harness, + !pp::app::execute_document_export_collection_write(empty_stem, payloads, services).ok()); + + PP_EXPECT( + harness, + !pp::app::execute_document_export_collection_write( + target.value(), + std::span(), + services) + .ok()); + + payloads[0].path_suffix.clear(); + PP_EXPECT( + harness, + !pp::app::execute_document_export_collection_write(target.value(), payloads, services).ok()); + payloads[0].path_suffix = pp::app::make_document_animation_frame_export_path_suffix(0); + payloads[0].bytes = {}; + PP_EXPECT( + harness, + !pp::app::execute_document_export_collection_write(target.value(), payloads, services).ok()); + PP_EXPECT(harness, services.write_calls == 0); + PP_EXPECT(harness, services.publish_calls == 0); +} + void video_export_builds_suggested_name(pp::tests::Harness& harness) { const auto timelapse = pp::app::make_document_export_suggested_name("demo", "-timelapse"); @@ -891,6 +983,11 @@ int main() "cube face export writer stops before publish on write failure", cube_face_export_writer_stops_before_publish_on_write_failure); harness.run("cube face export writer rejects malformed inputs", cube_face_export_writer_rejects_malformed_inputs); + harness.run("collection export builds legacy path suffixes", collection_export_builds_legacy_path_suffixes); + harness.run( + "collection export writer writes and publishes payloads in order", + collection_export_writer_writes_and_publishes_payloads_in_order); + harness.run("collection export writer rejects malformed inputs", collection_export_writer_rejects_malformed_inputs); harness.run("video export builds suggested name", video_export_builds_suggested_name); harness.run("collection export target plan selects platform destination", collection_export_target_plan_selects_platform_destination); harness.run("export success dialog plans image destinations", export_success_dialog_plans_image_destinations); diff --git a/tests/paint_renderer/compositor_tests.cpp b/tests/paint_renderer/compositor_tests.cpp index 6067303..9bc2584 100644 --- a/tests/paint_renderer/compositor_tests.cpp +++ b/tests/paint_renderer/compositor_tests.cpp @@ -46,6 +46,60 @@ bool near(float a, float b) return std::fabs(a - b) < 0.0001F; } +std::vector solid_rgba8( + std::uint32_t width, + std::uint32_t height, + std::uint8_t r, + std::uint8_t g, + std::uint8_t b, + std::uint8_t a) +{ + std::vector pixels( + static_cast(width) * height * pp::document::rgba8_components); + for (std::size_t i = 0; i < pixels.size(); i += pp::document::rgba8_components) { + pixels[i] = r; + pixels[i + 1U] = g; + pixels[i + 2U] = b; + pixels[i + 3U] = a; + } + return pixels; +} + +LayerFacePixels solid_face_payload( + std::uint32_t face_index, + std::uint32_t width, + std::uint32_t height, + std::uint8_t r, + std::uint8_t g, + std::uint8_t b, + std::uint8_t a) +{ + return LayerFacePixels { + .face_index = face_index, + .x = 0, + .y = 0, + .width = width, + .height = height, + .rgba8 = solid_rgba8(width, height, r, g, b, a), + }; +} + +std::vector solid_cube_faces( + std::uint32_t width, + std::uint32_t height, + std::uint8_t r, + std::uint8_t g, + std::uint8_t b, + std::uint8_t a) +{ + std::vector faces; + faces.reserve(pp::document::cube_face_count); + for (std::uint32_t face_index = 0; face_index < pp::document::cube_face_count; ++face_index) { + faces.push_back(solid_face_payload(face_index, width, height, r, g, b, a)); + } + return faces; +} + void composites_visible_layer_with_opacity(pp::tests::Harness& h) { std::vector destination { @@ -848,6 +902,140 @@ void exports_document_frame_as_equirectangular_png(pp::tests::Harness& h) PP_EXPECT(h, decoded.value().pixels[bottom + 2U] == 255U); } +void exports_document_layers_as_equirectangular_pngs(pp::tests::Harness& h) +{ + const AnimationFrame root_frames[] { + { .duration_ms = 100, .face_pixels = {} }, + }; + const AnimationFrame base_frames[] { + { + .duration_ms = 100, + .face_pixels = solid_cube_faces(1, 4, 255, 0, 0, 255), + }, + }; + const AnimationFrame hidden_frames[] { + { + .duration_ms = 100, + .face_pixels = solid_cube_faces(1, 4, 0, 0, 255, 255), + }, + }; + const DocumentLayerConfig layers[] { + { + .name = "Base", + .frames = std::span(base_frames, 1), + }, + { + .name = "HiddenPaint", + .visible = false, + .opacity = 0.0F, + .frames = std::span(hidden_frames, 1), + }, + }; + const auto document = CanvasDocument::create_from_snapshot(DocumentSnapshotConfig { + .width = 1, + .height = 4, + .layers = std::span(layers, 2), + .frames = std::span(root_frames, 1), + .selection_masks = {}, + }); + PP_EXPECT(h, document); + if (!document) { + return; + } + + const auto exported = pp::paint_renderer::export_document_layers_equirectangular_pngs( + pp::paint_renderer::DocumentLayerEquirectangularPngExportRequest { + .document = &document.value(), + .frame_index = 0, + }); + PP_EXPECT(h, exported); + if (!exported) { + return; + } + + PP_EXPECT(h, exported.value().layer_count == 2U); + PP_EXPECT(h, exported.value().layers.size() == 2U); + PP_EXPECT(h, exported.value().layers[0].layer_name == "Base"); + PP_EXPECT(h, exported.value().layers[1].layer_name == "HiddenPaint"); + PP_EXPECT(h, exported.value().layers[0].face_payload_count == pp::document::cube_face_count); + PP_EXPECT(h, exported.value().layers[1].face_payload_count == pp::document::cube_face_count); + PP_EXPECT(h, exported.value().encoded_bytes > 0U); + + const auto decoded = pp::assets::decode_png_rgba8(exported.value().layers[1].png); + PP_EXPECT(h, decoded); + if (!decoded) { + return; + } + + PP_EXPECT(h, decoded.value().width == 4U); + PP_EXPECT(h, decoded.value().height == 8U); + PP_EXPECT(h, decoded.value().pixels[0] == 0U); + PP_EXPECT(h, decoded.value().pixels[1] == 0U); + PP_EXPECT(h, decoded.value().pixels[2] == 255U); +} + +void exports_document_animation_frames_as_equirectangular_pngs(pp::tests::Harness& h) +{ + const AnimationFrame root_frames[] { + { .duration_ms = 100, .face_pixels = {} }, + { .duration_ms = 100, .face_pixels = {} }, + }; + const AnimationFrame layer_frames[] { + { + .duration_ms = 100, + .face_pixels = solid_cube_faces(1, 4, 255, 0, 0, 255), + }, + { + .duration_ms = 100, + .face_pixels = solid_cube_faces(1, 4, 0, 255, 0, 255), + }, + }; + const DocumentLayerConfig layers[] { + { + .name = "Paint", + .frames = std::span(layer_frames, 2), + }, + }; + const auto document = CanvasDocument::create_from_snapshot(DocumentSnapshotConfig { + .width = 1, + .height = 4, + .layers = std::span(layers, 1), + .frames = std::span(root_frames, 2), + .selection_masks = {}, + }); + PP_EXPECT(h, document); + if (!document) { + return; + } + + const auto exported = pp::paint_renderer::export_document_animation_frames_equirectangular_pngs( + pp::paint_renderer::DocumentAnimationFrameEquirectangularPngExportRequest { + .document = &document.value(), + }); + PP_EXPECT(h, exported); + if (!exported) { + return; + } + + PP_EXPECT(h, exported.value().frame_count == 2U); + PP_EXPECT(h, exported.value().frames.size() == 2U); + PP_EXPECT(h, exported.value().frames[0].frame_index == 0U); + PP_EXPECT(h, exported.value().frames[1].frame_index == 1U); + PP_EXPECT(h, exported.value().encoded_bytes > 0U); + + const auto decoded = pp::assets::decode_png_rgba8(exported.value().frames[1].png); + PP_EXPECT(h, decoded); + if (!decoded) { + return; + } + + PP_EXPECT(h, decoded.value().width == 4U); + PP_EXPECT(h, decoded.value().height == 8U); + PP_EXPECT(h, decoded.value().pixels[0] == 0U); + PP_EXPECT(h, decoded.value().pixels[1] == 255U); + PP_EXPECT(h, decoded.value().pixels[2] == 0U); +} + void document_frame_upload_rejects_invalid_requests(pp::tests::Harness& h) { RecordingRenderDevice device; @@ -858,6 +1046,10 @@ void document_frame_upload_rejects_invalid_requests(pp::tests::Harness& h) DocumentFrameCompositeRequest {}); const auto no_document_equirect = pp::paint_renderer::export_document_frame_equirectangular_png( DocumentFrameCompositeRequest {}); + const auto no_document_layers = pp::paint_renderer::export_document_layers_equirectangular_pngs( + pp::paint_renderer::DocumentLayerEquirectangularPngExportRequest {}); + const auto no_document_frames = pp::paint_renderer::export_document_animation_frames_equirectangular_pngs( + pp::paint_renderer::DocumentAnimationFrameEquirectangularPngExportRequest {}); const AnimationFrame root_frames[] { { .duration_ms = 100, .face_pixels = {} }, @@ -892,6 +1084,10 @@ void document_frame_upload_rejects_invalid_requests(pp::tests::Harness& h) PP_EXPECT(h, no_document_readiness.status().code == StatusCode::invalid_argument); PP_EXPECT(h, !no_document_equirect.ok()); PP_EXPECT(h, no_document_equirect.status().code == StatusCode::invalid_argument); + PP_EXPECT(h, !no_document_layers.ok()); + PP_EXPECT(h, no_document_layers.status().code == StatusCode::invalid_argument); + PP_EXPECT(h, !no_document_frames.ok()); + PP_EXPECT(h, no_document_frames.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_frame_readiness.ok()); @@ -1248,6 +1444,10 @@ int main() harness.run("exports_document_frame_faces_as_pngs", exports_document_frame_faces_as_pngs); harness.run("prepares_document_frame_export_readiness_report", prepares_document_frame_export_readiness_report); harness.run("exports_document_frame_as_equirectangular_png", exports_document_frame_as_equirectangular_png); + harness.run("exports_document_layers_as_equirectangular_pngs", exports_document_layers_as_equirectangular_pngs); + harness.run( + "exports_document_animation_frames_as_equirectangular_pngs", + exports_document_animation_frames_as_equirectangular_pngs); harness.run("document_frame_upload_rejects_invalid_requests", document_frame_upload_rejects_invalid_requests); harness.run("detects_feedback_requirements", detects_feedback_requirements); harness.run("plans_stroke_composite_paths", plans_stroke_composite_paths);