From 7575f51c4501a3e165a88bfcdb116655c924c4ad Mon Sep 17 00:00:00 2001 From: omigamedev Date: Sat, 6 Jun 2026 11:03:28 +0200 Subject: [PATCH] Plan document export snapshot routing --- docs/modernization/build-inventory.md | 9 +- docs/modernization/debt.md | 12 +- docs/modernization/roadmap.md | 12 +- src/app_core/document_export.h | 48 +++++ src/legacy_document_export_services.cpp | 221 +++++++++++++++-------- tests/CMakeLists.txt | 18 ++ tests/app_core/document_export_tests.cpp | 74 ++++++++ tools/pano_cli/main.cpp | 180 ++++++++++++++++++ 8 files changed, 494 insertions(+), 80 deletions(-) diff --git a/docs/modernization/build-inventory.md b/docs/modernization/build-inventory.md index 4aad120..9af5d73 100644 --- a/docs/modernization/build-inventory.md +++ b/docs/modernization/build-inventory.md @@ -860,6 +860,10 @@ powershell -ExecutionPolicy Bypass -File scripts\automation\apple-remote-build.p - `pano_cli plan-export-report` exposes `pp_app_core` export failure and license-disabled dialog metadata as JSON; live export dialogs consume the same metadata before retained legacy export execution or logging continues. +- `pano_cli plan-export-snapshot-route` exposes the `pp_app_core` route policy + that decides whether payload-complete document snapshots use pure + document/renderer export writers or retained legacy exporters, including + target/platform unsupported and pending renderer-readback fallback reasons. - `pano_cli plan-export-start` exposes `pp_app_core` export availability planning for license-gated, demo-blocked, and missing-canvas states as JSON; the live image, layer, animation-frame, depth, and cube-face export dialogs @@ -1052,8 +1056,9 @@ powershell -ExecutionPolicy Bypass -File scripts\automation\apple-remote-build.p handling, and invalid export naming inputs, plus export-start license/canvas availability decisions, export menu executor dispatch, file/stem/collection export execution dispatch, failed directory creation preservation, named depth/cube export - dispatch, malformed export target rejection, video export dispatch for - animation MP4/timelapse paths, and empty video-path rejection. + dispatch, malformed export target rejection, document-snapshot export route + policy, video export dispatch for animation MP4/timelapse paths, and empty + video-path rejection. - `pp_app_core_document_recording_tests` covers recording start/stop, clear, platform recorded-file cleanup, frame-count reset, export progress totals, oversized progress-total clamping, and recording-worker encode-wake diff --git a/docs/modernization/debt.md b/docs/modernization/debt.md index b90b371..2a8e3f7 100644 --- a/docs/modernization/debt.md +++ b/docs/modernization/debt.md @@ -582,6 +582,14 @@ agent or engineer to remove them without reconstructing context from chat. then-open JPEG/XMP metadata parity, GPU filtering/golden parity, Web prepared-file handoff, and the then-retained collection/depth/video writers stayed open. +- 2026-06-06: DEBT-0010/DEBT-0036/DEBT-0043 were narrowed again. + `pp_app_core` now owns the document-snapshot export route decision used by + live equirectangular, layer, animation-frame, and cube-face export bridges, + including payload-complete writer use, target/platform unsupported fallback, + and pending renderer-readback fallback reasons. `pano_cli + plan-export-snapshot-route` exposes the same route policy. Retained writers, + Web handoff, video/depth export execution, and renderer-owned payload readback + remain 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 @@ -626,7 +634,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, pure equirectangular JPEG+XMP export, pure layer/animation-frame PNG collection export, shared document-frame export readiness reporting, depth export render-plan 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/JPEG equirectangular writer execution using the paint-renderer equirectangular exports 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/depth/cube-face export snapshot/render/export-readiness reporting through the shared readiness helper plus the depth render plan, but action-command adoption, live save-writer replacement, Web and incomplete-readback collection handoff, progress/threading parity, broader renderer-owned export execution, exact GPU/golden parity, depth render/readback replacement, 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 equirectangular JPEG+XMP export, pure layer/animation-frame PNG collection export, shared document-frame export readiness reporting, depth export render-plan 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/JPEG equirectangular writer execution using the paint-renderer equirectangular exports 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, tested app-core document-snapshot export route policy for writer versus retained fallback, and live equirectangular/layer/animation-frame/depth/cube-face export snapshot/render/export-readiness reporting through the shared readiness helper plus the depth render plan, but action-command adoption, live save-writer replacement, Web and incomplete-readback collection handoff, progress/threading parity, broader renderer-owned export execution, exact GPU/golden parity, depth render/readback replacement, 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`; `pano_cli plan-export-snapshot-route --kind layers-collection --captured-face-payloads 3 --pending-face-payloads 6`; `pp_document_tests`; `pp_document_ppi_import_tests`; `pp_document_ppi_export_tests`; `pp_paint_renderer_compositor_tests`; `pp_app_core_document_canvas_tests`; `pp_app_core_document_export_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_plan_export_snapshot_route_pending_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 | @@ -658,7 +666,7 @@ agent or engineer to remove them without reconstructing context from chat. | 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/depth/cube-face execution prepares a payload-bearing document snapshot plus the shared `pp_paint_renderer::prepare_document_frame_export_readiness` report, depth export target naming and two-payload write order are covered by tested `pp_app_core` helpers, 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/JPEG equirectangular export writes the pure `pp_paint_renderer` equirectangular payload 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 Web/incomplete-readback collection exports and depth rendering, creates export directories, handles picker-selected stems, performs Web prepared-file handoff directly, and leaves depth render/readback plus the legacy `.png`/JPEG payload mismatch 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/depth/cube-face execution prepares a payload-bearing document snapshot plus the shared `pp_paint_renderer::prepare_document_frame_export_readiness` report, document-snapshot writer-versus-retained fallback routing now comes from tested `pp_app_core` policy, depth export target naming and two-payload write order are covered by tested `pp_app_core` helpers, 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/JPEG equirectangular export writes the pure `pp_paint_renderer` equirectangular payload 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 Web/incomplete-readback collection exports and depth rendering, creates export directories, handles picker-selected stems, performs Web prepared-file handoff directly, and leaves depth render/readback plus the legacy `.png`/JPEG payload mismatch 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 plan-export-snapshot-route --kind layers-collection --captured-face-payloads 3 --pending-face-payloads 6`; `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 a868dd9..81df018 100644 --- a/docs/modernization/roadmap.md +++ b/docs/modernization/roadmap.md @@ -729,8 +729,12 @@ pure `pp_paint_renderer` equirectangular PNG generation plus app-core collection write/publish execution before retained fallback. Payload-complete desktop JPEG equirectangular export now uses the same projection through `pp_paint_renderer`, `pp_assets` JPEG encoding, and GPano XMP injection before -retained fallback. Web handoff, video, and incomplete-readback collection cases -still delegate to retained `Canvas` writers after readiness reporting. +retained fallback. `pp_app_core` now owns the document-snapshot export route +decision used by those live adapters, covering platform support, target support, +and incomplete renderer-payload fallback; `pano_cli plan-export-snapshot-route` +exposes the same decision for automation. Web handoff, video, depth writer +replacement, and incomplete-readback cases still delegate to retained `Canvas` +writers after route/readiness reporting. Depth export now also plans the retained image/depth file targets in `pp_app_core` and logs a `pp_paint_renderer` document depth render plan for the legacy 1024x1024 perspective render plus per-layer depth pass before falling @@ -2296,6 +2300,10 @@ Results: capture the payload-bearing canvas document snapshot and run the renderer-neutral upload report before retained `Canvas` export execution; failures are logged and retained export still continues to preserve behavior. +- `pp_app_core` now owns the document-snapshot export route decision for + equirectangular, layer, animation-frame, and cube-face writers, including + target/platform support and incomplete renderer-payload fallback reasons. + `pano_cli plan-export-snapshot-route` exposes the same policy as JSON. - `pp_app_core_document_import_tests` passed, covering wide equirectangular, legacy vertical cube strip, regular transform-placement, and invalid-dimension import route decisions, equirectangular service dispatch, transform import diff --git a/src/app_core/document_export.h b/src/app_core/document_export.h index 1d631b9..b7f56fd 100644 --- a/src/app_core/document_export.h +++ b/src/app_core/document_export.h @@ -1,6 +1,7 @@ #pragma once #include "app_core/app_dialog.h" +#include "app_core/document_canvas.h" #include "document/document.h" #include "foundation/result.h" @@ -137,6 +138,11 @@ enum class DocumentExportExecutionKind { timelapse, }; +enum class DocumentExportSnapshotRouteAction { + use_document_snapshot_writer, + use_legacy_export, +}; + struct DocumentExportMenuPlan { DocumentExportMenuKind kind = DocumentExportMenuKind::jpeg; DocumentExportMenuAction action = DocumentExportMenuAction::show_jpeg_dialog; @@ -156,6 +162,16 @@ struct DocumentExportSuccessDialogPlan { bool show_dialog = false; }; +struct DocumentExportSnapshotRoutePlan { + DocumentExportExecutionKind kind = DocumentExportExecutionKind::equirectangular_file; + DocumentExportSnapshotRouteAction action = DocumentExportSnapshotRouteAction::use_legacy_export; + bool payload_complete = false; + bool target_supported = false; + bool platform_supported = false; + bool uses_document_snapshot_writer = false; + std::string_view fallback_reason; +}; + class DocumentExportMenuServices { public: virtual ~DocumentExportMenuServices() = default; @@ -408,6 +424,38 @@ public: return "Document export failed"; } +[[nodiscard]] constexpr DocumentExportSnapshotRoutePlan plan_document_export_snapshot_route( + DocumentExportExecutionKind kind, + DocumentCanvasSaveSnapshotReport report, + bool target_supported, + bool platform_supported) noexcept +{ + DocumentExportSnapshotRoutePlan plan; + plan.kind = kind; + plan.payload_complete = report.payload_complete; + plan.target_supported = target_supported; + plan.platform_supported = platform_supported; + + if (!platform_supported) { + plan.fallback_reason = "document snapshot export is disabled on this platform"; + return plan; + } + + if (!target_supported) { + plan.fallback_reason = "document snapshot export does not support this target"; + return plan; + } + + if (!report.payload_complete) { + plan.fallback_reason = "document snapshot still requires renderer payload readback"; + return plan; + } + + plan.action = DocumentExportSnapshotRouteAction::use_document_snapshot_writer; + plan.uses_document_snapshot_writer = true; + return plan; +} + [[nodiscard]] constexpr DocumentExportCollectionTargetPlan plan_document_export_collection_target( DocumentExportCollectionKind kind, bool use_work_directory_collection) noexcept diff --git a/src/legacy_document_export_services.cpp b/src/legacy_document_export_services.cpp index 8bc01f6..16a2dfc 100644 --- a/src/legacy_document_export_services.cpp +++ b/src/legacy_document_export_services.cpp @@ -202,6 +202,37 @@ void prepare_legacy_document_export_snapshot_or_continue(App& app, const char* c } } +bool use_legacy_document_snapshot_writer( + const char* context, + pp::app::DocumentExportExecutionKind kind, + const LegacyDocumentExportSnapshotReports& reports, + bool target_supported, + bool platform_supported) +{ + const auto report = pp::app::make_document_canvas_save_snapshot_report(reports.snapshot); + const auto route = pp::app::plan_document_export_snapshot_route( + kind, + report, + target_supported, + platform_supported); + if (!route.uses_document_snapshot_writer) { + LOG( + "%s document export writer retained legacy export: %.*s", + context, + static_cast(route.fallback_reason.size()), + route.fallback_reason.data()); + return false; + } + + LOG( + "%s document export writer route: document-snapshot payloadComplete=%s capturedFaces=%zu pendingFaces=%zu", + context, + route.payload_complete ? "true" : "false", + report.captured_face_payloads, + report.pending_face_payloads); + return true; +} + pp::foundation::Status export_cube_faces_from_document_snapshot( App& app, std::string_view document_name, @@ -377,20 +408,27 @@ public: if (is_png_export_target(target.path) || is_jpeg_export_target(target.path)) { const auto prepared = prepare_legacy_document_export_snapshot(app_, "export-equirectangular"); if (prepared) { - const auto exported = export_equirectangular_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::equirectangular, - pp::app::document_export_equirectangular_platform_destination(), - app_.work_path)); - return; - } + if (use_legacy_document_snapshot_writer( + "export-equirectangular", + pp::app::DocumentExportExecutionKind::equirectangular_file, + prepared.value(), + true, + true)) { + const auto exported = export_equirectangular_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::equirectangular, + pp::app::document_export_equirectangular_platform_destination(), + app_.work_path)); + return; + } - LOG( - "export-equirectangular document export writer retained legacy export after failure: %s", - exported.message); + LOG( + "export-equirectangular document export writer retained legacy export after failure: %s", + exported.message); + } } else { LOG( "export-equirectangular document export snapshot bridge retained legacy export after failure: %s", @@ -427,18 +465,25 @@ public: 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; - } + if (use_legacy_document_snapshot_writer( + "export-layers", + pp::app::DocumentExportExecutionKind::layers_stem, + prepared.value(), + true, + true)) { + 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); + 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", @@ -463,17 +508,24 @@ public: #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; - } + if (use_legacy_document_snapshot_writer( + "export-layers", + pp::app::DocumentExportExecutionKind::layers_collection, + prepared.value(), + true, + true)) { + 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); + 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", @@ -500,23 +552,30 @@ public: 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( + if (use_legacy_document_snapshot_writer( + "export-animation-frames", + pp::app::DocumentExportExecutionKind::animation_frames_stem, + prepared.value(), + true, + true)) { + const auto exported = export_animation_frames_from_document_snapshot( app_, - pp::app::plan_document_export_success_dialog( - pp::app::DocumentExportSuccessKind::animation_frames, - pp::app::DocumentExportSuccessDestination::path, - target.stem_path)); - return; - } + 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); + 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", @@ -541,19 +600,26 @@ public: #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; - } + if (use_legacy_document_snapshot_writer( + "export-animation-frames", + pp::app::DocumentExportExecutionKind::animation_frames_collection, + prepared.value(), + true, + true)) { + 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); + 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", @@ -631,20 +697,27 @@ public: auto* app = &app_; const auto prepared = prepare_legacy_document_export_snapshot(app_, "export-cube-faces"); if (prepared) { - const auto exported = export_cube_faces_from_document_snapshot(app_, document_name, prepared.value()); - if (exported.ok()) { - show_export_success_dialog( - app_, - pp::app::plan_document_export_success_dialog( - pp::app::DocumentExportSuccessKind::cube_faces, - pp::app::document_export_media_platform_destination(), - app_.work_path)); - return; - } + if (use_legacy_document_snapshot_writer( + "export-cube-faces", + pp::app::DocumentExportExecutionKind::cube_faces, + prepared.value(), + true, + true)) { + const auto exported = export_cube_faces_from_document_snapshot(app_, document_name, prepared.value()); + if (exported.ok()) { + show_export_success_dialog( + app_, + pp::app::plan_document_export_success_dialog( + pp::app::DocumentExportSuccessKind::cube_faces, + pp::app::document_export_media_platform_destination(), + app_.work_path)); + return; + } - LOG( - "export-cube-faces document export writer retained legacy export after failure: %s", - exported.message); + LOG( + "export-cube-faces document export writer retained legacy export after failure: %s", + exported.message); + } } else { LOG( "export-cube-faces document export snapshot bridge retained legacy export after failure: %s", diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index eac9563..93066f2 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -900,6 +900,24 @@ if(TARGET pano_cli) LABELS "app;integration;desktop-fast" PASS_REGULAR_EXPRESSION "\"command\":\"plan-export-menu\".*\"kind\":\"layers\".*\"hasCanvas\":false.*\"action\":\"unavailable-no-canvas\".*\"opensDialog\":false") + add_test(NAME pano_cli_plan_export_snapshot_route_ready_smoke + COMMAND pano_cli plan-export-snapshot-route --kind equirectangular --captured-face-payloads 6 --pending-face-payloads 6) + set_tests_properties(pano_cli_plan_export_snapshot_route_ready_smoke PROPERTIES + LABELS "app;integration;desktop-fast" + PASS_REGULAR_EXPRESSION "\"command\":\"plan-export-snapshot-route\".*\"kind\":\"equirectangular\".*\"payloadComplete\":true.*\"action\":\"use-document-snapshot-writer\".*\"usesDocumentSnapshotWriter\":true.*\"fallbackReason\":\"\"") + + add_test(NAME pano_cli_plan_export_snapshot_route_pending_smoke + COMMAND pano_cli plan-export-snapshot-route --kind layers-collection --captured-face-payloads 3 --pending-face-payloads 6) + set_tests_properties(pano_cli_plan_export_snapshot_route_pending_smoke PROPERTIES + LABELS "app;integration;desktop-fast" + PASS_REGULAR_EXPRESSION "\"command\":\"plan-export-snapshot-route\".*\"kind\":\"layers-collection\".*\"payloadComplete\":false.*\"action\":\"use-legacy-export\".*\"usesDocumentSnapshotWriter\":false.*\"fallbackReason\":\"document snapshot still requires renderer payload readback\"") + + add_test(NAME pano_cli_plan_export_snapshot_route_unsupported_target_smoke + COMMAND pano_cli plan-export-snapshot-route --kind depth --unsupported-target) + set_tests_properties(pano_cli_plan_export_snapshot_route_unsupported_target_smoke PROPERTIES + LABELS "app;integration;desktop-fast" + PASS_REGULAR_EXPRESSION "\"command\":\"plan-export-snapshot-route\".*\"kind\":\"depth\".*\"targetSupported\":false.*\"action\":\"use-legacy-export\".*\"fallbackReason\":\"document snapshot export does not support this target\"") + add_test(NAME pano_cli_plan_export_menu_rejects_unknown COMMAND pano_cli plan-export-menu --kind unknown) set_tests_properties(pano_cli_plan_export_menu_rejects_unknown PROPERTIES diff --git a/tests/app_core/document_export_tests.cpp b/tests/app_core/document_export_tests.cpp index e0c7063..d366817 100644 --- a/tests/app_core/document_export_tests.cpp +++ b/tests/app_core/document_export_tests.cpp @@ -754,6 +754,73 @@ void export_execution_log_messages_cover_legacy_paths(pp::tests::Harness& harnes == "Document timelapse export failed"); } +void export_snapshot_route_uses_document_writer_when_ready(pp::tests::Harness& harness) +{ + pp::app::DocumentCanvasSaveSnapshotReport report; + report.payload_complete = true; + report.can_export_ppi = true; + + const auto plan = pp::app::plan_document_export_snapshot_route( + pp::app::DocumentExportExecutionKind::equirectangular_file, + report, + true, + true); + + PP_EXPECT(harness, plan.kind == pp::app::DocumentExportExecutionKind::equirectangular_file); + PP_EXPECT(harness, plan.action == pp::app::DocumentExportSnapshotRouteAction::use_document_snapshot_writer); + PP_EXPECT(harness, plan.uses_document_snapshot_writer); + PP_EXPECT(harness, plan.payload_complete); + PP_EXPECT(harness, plan.target_supported); + PP_EXPECT(harness, plan.platform_supported); + PP_EXPECT(harness, plan.fallback_reason.empty()); +} + +void export_snapshot_route_falls_back_for_pending_renderer_payloads(pp::tests::Harness& harness) +{ + pp::app::DocumentCanvasSaveSnapshotReport report; + report.payload_complete = false; + + const auto plan = pp::app::plan_document_export_snapshot_route( + pp::app::DocumentExportExecutionKind::layers_collection, + report, + true, + true); + + PP_EXPECT(harness, plan.action == pp::app::DocumentExportSnapshotRouteAction::use_legacy_export); + PP_EXPECT(harness, !plan.uses_document_snapshot_writer); + PP_EXPECT(harness, !plan.payload_complete); + PP_EXPECT( + harness, + plan.fallback_reason == "document snapshot still requires renderer payload readback"); +} + +void export_snapshot_route_falls_back_for_unsupported_target_or_platform(pp::tests::Harness& harness) +{ + pp::app::DocumentCanvasSaveSnapshotReport report; + report.payload_complete = true; + report.can_export_ppi = true; + + const auto unsupported_target = pp::app::plan_document_export_snapshot_route( + pp::app::DocumentExportExecutionKind::animation_mp4, + report, + false, + true); + const auto unsupported_platform = pp::app::plan_document_export_snapshot_route( + pp::app::DocumentExportExecutionKind::animation_frames_collection, + report, + true, + false); + + PP_EXPECT(harness, !unsupported_target.uses_document_snapshot_writer); + PP_EXPECT( + harness, + unsupported_target.fallback_reason == "document snapshot export does not support this target"); + PP_EXPECT(harness, !unsupported_platform.uses_document_snapshot_writer); + PP_EXPECT( + harness, + unsupported_platform.fallback_reason == "document snapshot export is disabled on this platform"); +} + void export_start_allows_valid_canvas_state(pp::tests::Harness& harness) { PP_EXPECT( @@ -1119,6 +1186,13 @@ int main() harness.run("export failure dialog plans titles and messages", export_failure_dialog_plans_titles_and_messages); harness.run("export license disabled dialog preserves legacy warning", export_license_disabled_dialog_preserves_legacy_warning); harness.run("export execution log messages cover legacy paths", export_execution_log_messages_cover_legacy_paths); + harness.run("export snapshot route uses document writer when ready", export_snapshot_route_uses_document_writer_when_ready); + harness.run( + "export snapshot route falls back for pending renderer payloads", + export_snapshot_route_falls_back_for_pending_renderer_payloads); + harness.run( + "export snapshot route falls back for unsupported target or platform", + export_snapshot_route_falls_back_for_unsupported_target_or_platform); harness.run("export start allows valid canvas state", export_start_allows_valid_canvas_state); harness.run("export start blocks demo only when license required", export_start_blocks_demo_only_when_license_required); harness.run("export start reports missing canvas after license gate", export_start_reports_missing_canvas_after_license_gate); diff --git a/tools/pano_cli/main.cpp b/tools/pano_cli/main.cpp index a2bba4c..7e687f5 100644 --- a/tools/pano_cli/main.cpp +++ b/tools/pano_cli/main.cpp @@ -191,6 +191,14 @@ struct PlanExportMenuArgs { bool has_canvas = true; }; +struct PlanExportSnapshotRouteArgs { + std::string kind = "equirectangular"; + std::uint32_t captured_face_payloads = 6; + std::uint32_t pending_face_payloads = 6; + bool target_supported = true; + bool platform_supported = true; +}; + struct PlanFileMenuArgs { std::string command = "new"; }; @@ -1937,6 +1945,45 @@ const char* document_export_menu_action_name(pp::app::DocumentExportMenuAction a return "unavailable-no-canvas"; } +const char* document_export_execution_kind_name(pp::app::DocumentExportExecutionKind kind) noexcept +{ + switch (kind) { + case pp::app::DocumentExportExecutionKind::equirectangular_file: + return "equirectangular-file"; + case pp::app::DocumentExportExecutionKind::layers_collection: + return "layers-collection"; + case pp::app::DocumentExportExecutionKind::layers_stem: + return "layers-stem"; + case pp::app::DocumentExportExecutionKind::animation_frames_collection: + return "animation-frames-collection"; + case pp::app::DocumentExportExecutionKind::animation_frames_stem: + return "animation-frames-stem"; + case pp::app::DocumentExportExecutionKind::depth: + return "depth"; + case pp::app::DocumentExportExecutionKind::cube_faces: + return "cube-faces"; + case pp::app::DocumentExportExecutionKind::animation_mp4: + return "animation-mp4"; + case pp::app::DocumentExportExecutionKind::timelapse: + return "timelapse"; + } + + return "equirectangular-file"; +} + +const char* document_export_snapshot_route_action_name( + pp::app::DocumentExportSnapshotRouteAction action) noexcept +{ + switch (action) { + case pp::app::DocumentExportSnapshotRouteAction::use_document_snapshot_writer: + return "use-document-snapshot-writer"; + case pp::app::DocumentExportSnapshotRouteAction::use_legacy_export: + return "use-legacy-export"; + } + + return "use-legacy-export"; +} + pp::foundation::Result parse_document_export_menu_kind( std::string_view kind) { @@ -1977,6 +2024,50 @@ pp::foundation::Result parse_document_export_me pp::foundation::Status::invalid_argument("unknown export menu kind")); } +pp::foundation::Result parse_document_export_execution_kind( + std::string_view kind) +{ + if (kind == "equirectangular" || kind == "equirect" || kind == "image" || kind == "equirectangular-file") { + return pp::foundation::Result::success( + pp::app::DocumentExportExecutionKind::equirectangular_file); + } + if (kind == "layers" || kind == "layers-collection") { + return pp::foundation::Result::success( + pp::app::DocumentExportExecutionKind::layers_collection); + } + if (kind == "layers-stem") { + return pp::foundation::Result::success( + pp::app::DocumentExportExecutionKind::layers_stem); + } + if (kind == "animation-frames" || kind == "frames" || kind == "animation-frames-collection") { + return pp::foundation::Result::success( + pp::app::DocumentExportExecutionKind::animation_frames_collection); + } + if (kind == "animation-frames-stem" || kind == "frames-stem") { + return pp::foundation::Result::success( + pp::app::DocumentExportExecutionKind::animation_frames_stem); + } + if (kind == "depth") { + return pp::foundation::Result::success( + pp::app::DocumentExportExecutionKind::depth); + } + if (kind == "cube-faces" || kind == "cube") { + return pp::foundation::Result::success( + pp::app::DocumentExportExecutionKind::cube_faces); + } + if (kind == "animation-mp4" || kind == "mp4") { + return pp::foundation::Result::success( + pp::app::DocumentExportExecutionKind::animation_mp4); + } + if (kind == "timelapse") { + return pp::foundation::Result::success( + pp::app::DocumentExportExecutionKind::timelapse); + } + + return pp::foundation::Result::failure( + pp::foundation::Status::invalid_argument("unknown export execution kind")); +} + const char* document_export_success_kind_name(pp::app::DocumentExportSuccessKind kind) noexcept { switch (kind) { @@ -2384,6 +2475,7 @@ void print_help() << " plan-document-session-prompt --kind close-unsaved|save-before-workflow|new-document-overwrite|file-overwrite|save-error [--name NAME]\n" << " plan-export-start [--requires-license] [--demo] [--no-canvas]\n" << " plan-export-menu --kind jpeg|png|layers|cube-faces|depth|animation-frames|animation-mp4|timelapse [--demo] [--no-canvas]\n" + << " plan-export-snapshot-route --kind equirectangular|layers-collection|layers-stem|animation-frames-collection|animation-frames-stem|cube-faces|depth [--captured-face-payloads N] [--pending-face-payloads N] [--unsupported-target] [--unsupported-platform]\n" << " plan-export-target --kind file|collection|stem|cube-faces|name --doc-name NAME [--work-dir DIR] [--directory DIR] [--extension EXT] [--suffix SUFFIX]\n" << " plan-export-message --kind equirectangular|layers|animation-frames|depth|cube-faces|animation-mp4|timelapse --destination photos|pictures|files|work|path|success|suppressed [--detail TEXT]\n" << " plan-export-report --kind license-disabled|equirectangular|layers|animation-frames|depth|cube-faces|animation-mp4|timelapse [--message TEXT]\n" @@ -3743,6 +3835,90 @@ int plan_export_menu(int argc, char** argv) return 0; } +pp::foundation::Status parse_plan_export_snapshot_route_args( + int argc, + char** argv, + PlanExportSnapshotRouteArgs& args) +{ + for (int i = 2; i < argc; ++i) { + const std::string_view key(argv[i]); + if (key == "--kind") { + if (i + 1 >= argc) { + return pp::foundation::Status::invalid_argument("missing value for option"); + } + args.kind = argv[++i]; + } else if (key == "--captured-face-payloads") { + if (i + 1 >= argc) { + return pp::foundation::Status::invalid_argument("missing value for option"); + } + const auto value = pp::foundation::parse_u32(argv[++i]); + if (!value) { + return value.status(); + } + args.captured_face_payloads = value.value(); + } else if (key == "--pending-face-payloads") { + if (i + 1 >= argc) { + return pp::foundation::Status::invalid_argument("missing value for option"); + } + const auto value = pp::foundation::parse_u32(argv[++i]); + if (!value) { + return value.status(); + } + args.pending_face_payloads = value.value(); + } else if (key == "--unsupported-target") { + args.target_supported = false; + } else if (key == "--unsupported-platform") { + args.platform_supported = false; + } else { + return pp::foundation::Status::invalid_argument("unknown option"); + } + } + + return pp::foundation::Status::success(); +} + +int plan_export_snapshot_route(int argc, char** argv) +{ + PlanExportSnapshotRouteArgs args; + const auto status = parse_plan_export_snapshot_route_args(argc, argv, args); + if (!status.ok()) { + print_error("plan-export-snapshot-route", status.message); + return 2; + } + + const auto kind = parse_document_export_execution_kind(args.kind); + if (!kind) { + print_error("plan-export-snapshot-route", kind.status().message); + return 2; + } + + pp::app::DocumentCanvasSaveSnapshotReport report; + report.captured_face_payloads = args.captured_face_payloads; + report.pending_face_payloads = args.pending_face_payloads; + report.payload_complete = args.captured_face_payloads >= args.pending_face_payloads; + report.can_export_ppi = report.payload_complete; + + const auto plan = pp::app::plan_document_export_snapshot_route( + kind.value(), + report, + args.target_supported, + args.platform_supported); + + std::cout << "{\"ok\":true,\"command\":\"plan-export-snapshot-route\"" + << ",\"state\":{\"kind\":\"" << json_escape(args.kind) + << "\",\"capturedFacePayloads\":" << args.captured_face_payloads + << ",\"pendingFacePayloads\":" << args.pending_face_payloads + << ",\"payloadComplete\":" << json_bool(report.payload_complete) + << ",\"targetSupported\":" << json_bool(args.target_supported) + << ",\"platformSupported\":" << json_bool(args.platform_supported) + << "},\"plan\":{\"kind\":\"" << document_export_execution_kind_name(plan.kind) + << "\",\"action\":\"" << document_export_snapshot_route_action_name(plan.action) + << "\",\"usesDocumentSnapshotWriter\":" << json_bool(plan.uses_document_snapshot_writer) + << ",\"fallbackReason\":\"" << json_escape(std::string(plan.fallback_reason)) + << "\"}}\n"; + return 0; +} + pp::foundation::Status parse_plan_export_message_args( int argc, char** argv, @@ -11957,6 +12133,10 @@ int main(int argc, char** argv) return plan_export_menu(argc, argv); } + if (command == "plan-export-snapshot-route") { + return plan_export_snapshot_route(argc, argv); + } + if (command == "plan-export-target") { return plan_export_target(argc, argv); }