diff --git a/docs/modernization/build-inventory.md b/docs/modernization/build-inventory.md index 0df10db..f708f00 100644 --- a/docs/modernization/build-inventory.md +++ b/docs/modernization/build-inventory.md @@ -446,8 +446,9 @@ Known local toolchain state: platform clipboard bridges. - `pp_platform_api` exposes the SDK-free `PlatformServices` interface for clipboard text, cursor visibility, virtual-keyboard visibility, external - file display, file sharing, native app/window close, picker callbacks, and - prepared-file save/download handoff; Windows live app execution now uses injected + file display, file sharing, native app/window close, per-frame platform + hooks, picker callbacks, and prepared-file save/download handoff; Windows + live app execution now uses injected `WindowsPlatformServices` from `src/platform_windows/windows_platform_services.*` in `pp_platform_windows`, while non-Windows platforms still reach retained platform bridges through diff --git a/docs/modernization/debt.md b/docs/modernization/debt.md index 7d73ef7..140d2d3 100644 --- a/docs/modernization/debt.md +++ b/docs/modernization/debt.md @@ -35,7 +35,7 @@ agent or engineer to remove them without reconstructing context from chat. | DEBT-0014 | Open | Modernization | `windows-clangcl-asan` now configures as a headless Ninja/clang-cl preset and uses the release MSVC runtime required by ASan, but local builds still fail because installed clang-cl 18.1.8 is paired with VS 2026-preview STL headers that require Clang 20 or newer | Sanitizer validation should be local and repeatable, but this machine's compiler/header pairing is incompatible | `cmake --fresh --preset windows-clangcl-asan`; `cmake --build --preset windows-clangcl-asan --target pp_foundation` | Install/use Clang 20+ with the VS 2026 STL, or point the preset at a compatible VS 2022 toolchain, then make `platform-build.ps1 -Presets windows-clangcl-asan` pass for the headless matrix | | DEBT-0015 | Open | Modernization | Cursor visibility requests now consume pure `pp_app_core` planning through `pano_cli plan-cursor-visibility`, `App::show_cursor`/`App::hide_cursor` dispatch through `PlatformServices` without platform guards, and Windows live execution uses injected `WindowsPlatformServices`, but macOS cursor execution still reaches the retained fallback adapter | Keep canvas cursor behavior stable while platform shells are extracted incrementally | `pp_app_core_document_platform_io_tests`; `pano_cli plan-cursor-visibility --visible`; `ctest --preset desktop-fast --build-config Debug` | Cursor visibility execution is owned by injected `pp_platform_*` services for every supported platform | | DEBT-0016 | Open | Modernization | Clipboard get/set requests now consume pure `pp_app_core` planning through `pano_cli plan-clipboard-read` and `pano_cli plan-clipboard-write`, and Windows live execution uses injected `WindowsPlatformServices`, but Apple/Android clipboard execution still reaches retained fallback adapter branches from `App::clipboard_get_text` and `App::clipboard_set_text` | Keep picker/color text clipboard behavior stable while platform shells are extracted incrementally | `pp_app_core_document_platform_io_tests`; `pano_cli plan-clipboard-write --text #ff00aa`; `ctest --preset desktop-fast --build-config Debug` | Clipboard execution is owned by injected `pp_platform_*` services for every supported platform | -| DEBT-0017 | Open | Modernization | `App::clipboard_get_text`, `App::clipboard_set_text`, `App::show_cursor`, `App::hide_cursor`, `App::showKeyboard`, `App::hideKeyboard`, `App::display_file`, `App::share_file`, native app/window close, `App::pick_image`, `App::pick_file`, the non-writer `App::pick_file_save`, `App::pick_dir`, and prepared-file save/download handoff now call the SDK-free `pp::platform::PlatformServices` interface, and Windows injects `WindowsPlatformServices` from `src/platform_windows/windows_platform_services.*`; non-Windows live implementations still use `src/platform_legacy/legacy_platform_services.*`, a named fallback adapter that forwards to retained Apple/Android/Linux/Web bridge functions and retained no-op branches | Preserve behavior while moving platform execution behind a testable service boundary before platform shell implementations are injected | `pp_platform_api_tests`; `pp_app_core_document_platform_io_tests`; `ctest --preset desktop-fast --build-config Debug`; `powershell -ExecutionPolicy Bypass -File scripts\automation\package-smoke.ps1 -Preset windows-msvc-default -Configuration Debug` | Replace `src/platform_legacy/legacy_platform_services.*` with injected `pp_platform_*` service implementations owned by each non-Windows platform shell | +| DEBT-0017 | Open | Modernization | `App::clipboard_get_text`, `App::clipboard_set_text`, `App::show_cursor`, `App::hide_cursor`, `App::showKeyboard`, `App::hideKeyboard`, `App::display_file`, `App::share_file`, native app/window close, per-frame platform hooks, `App::pick_image`, `App::pick_file`, the non-writer `App::pick_file_save`, `App::pick_dir`, and prepared-file save/download handoff now call the SDK-free `pp::platform::PlatformServices` interface, and Windows injects `WindowsPlatformServices` from `src/platform_windows/windows_platform_services.*`; non-Windows live implementations still use `src/platform_legacy/legacy_platform_services.*`, a named fallback adapter that forwards to retained Apple/Android/Linux/Web bridge functions and retained no-op branches | Preserve behavior while moving platform execution behind a testable service boundary before platform shell implementations are injected | `pp_platform_api_tests`; `pp_app_core_document_platform_io_tests`; `ctest --preset desktop-fast --build-config Debug`; `powershell -ExecutionPolicy Bypass -File scripts\automation\package-smoke.ps1 -Preset windows-msvc-default -Configuration Debug` | Replace `src/platform_legacy/legacy_platform_services.*` with injected `pp_platform_*` service implementations owned by each non-Windows platform shell | ## Closed Debt diff --git a/docs/modernization/roadmap.md b/docs/modernization/roadmap.md index 748e15d..30aa918 100644 --- a/docs/modernization/roadmap.md +++ b/docs/modernization/roadmap.md @@ -486,6 +486,10 @@ The unsaved-document close prompt now requests native app/window close through `PlatformServices`, with Windows implemented by `WindowsPlatformServices` and macOS/Linux still handled by the legacy adapter until those platform shells are injected. +The UI loop's per-frame platform hooks now dispatch through +`PlatformServices`: Windows stylus timeout polling and FPS-title updates live +in `WindowsPlatformServices`, while Linux FPS-title updates remain in the +legacy adapter pending Phase 6 platform shell extraction. `pano_cli plan-cloud-upload` exposes the app-core cloud upload decision used by the live cloud upload command for missing-canvas, new-document warning, publish prompt, and dirty-document save-before-upload states before legacy UI, canvas, @@ -1000,8 +1004,9 @@ Results: interface for clipboard read/write, empty clipboard writes, cursor visibility dispatch, virtual-keyboard visibility dispatch, external file display dispatch, file sharing dispatch, native app/window close dispatch, - picker callback dispatch, and prepared-file save/download callback dispatch. - The live Windows app now consumes this interface through an injected + per-frame platform hook dispatch, picker callback dispatch, and + prepared-file save/download callback dispatch. The live Windows app now + consumes this interface through an injected `WindowsPlatformServices` instance isolated in `src/platform_windows/windows_platform_services.*`; other platforms still use the legacy fallback adapter, now isolated in diff --git a/src/app.cpp b/src/app.cpp index ba3cb00..855179f 100644 --- a/src/app.cpp +++ b/src/app.cpp @@ -1123,10 +1123,7 @@ void App::ui_thread_main() float dt = std::chrono::duration(t_now - t_start).count(); t_start = t_now; -#ifdef _WIN32 - extern void win32_update_stylus(float dt); - win32_update_stylus(dt); -#endif + update_platform_frame(dt); // increment timers t_frame += dt; @@ -1134,13 +1131,7 @@ void App::ui_thread_main() if (t_fps_counter > 1.f) { -#ifdef _WIN32 - extern void win32_update_fps(int frames); - win32_update_fps(rendered_frames); -#elif __LINUX__ - extern void linux_update_fps(int frames); - linux_update_fps(rendered_frames); -#endif + report_rendered_frames(rendered_frames); t_fps_counter = 0; rendered_frames = 0; } diff --git a/src/app.h b/src/app.h index 8e13d9e..baf4ad1 100644 --- a/src/app.h +++ b/src/app.h @@ -190,6 +190,8 @@ public: void display_file(std::string path); void share_file(std::string path); void request_app_close(); + void update_platform_frame(float delta_time_seconds); + void report_rendered_frames(int frames); void save_prepared_file( std::string path, std::string suggested_name, diff --git a/src/app_events.cpp b/src/app_events.cpp index 41b5630..8eb6015 100644 --- a/src/app_events.cpp +++ b/src/app_events.cpp @@ -219,6 +219,16 @@ void App::request_app_close() active_platform_services().request_app_close(); } +void App::update_platform_frame(float delta_time_seconds) +{ + active_platform_services().update_platform_frame(delta_time_seconds); +} + +void App::report_rendered_frames(int frames) +{ + active_platform_services().report_rendered_frames(frames); +} + void App::save_prepared_file( std::string path, std::string suggested_name, diff --git a/src/platform_api/platform_services.h b/src/platform_api/platform_services.h index 6d6e134..d04c582 100644 --- a/src/platform_api/platform_services.h +++ b/src/platform_api/platform_services.h @@ -18,6 +18,8 @@ public: [[nodiscard]] virtual bool set_clipboard_text(std::string_view text) = 0; virtual void set_cursor_visible(bool visible) = 0; virtual void set_virtual_keyboard_visible(bool visible) = 0; + virtual void update_platform_frame(float delta_time_seconds) = 0; + virtual void report_rendered_frames(int frames) = 0; virtual void display_file(std::string_view path) = 0; virtual void share_file(std::string_view path) = 0; virtual void request_app_close() = 0; diff --git a/src/platform_legacy/legacy_platform_services.cpp b/src/platform_legacy/legacy_platform_services.cpp index b473bbd..310fdae 100644 --- a/src/platform_legacy/legacy_platform_services.cpp +++ b/src/platform_legacy/legacy_platform_services.cpp @@ -13,6 +13,7 @@ bool android_set_clipboard(const std::string& s); #elif __APPLE__ #elif __LINUX__ #include +void linux_update_fps(int frames); #elif __WEB__ void webgl_pick_file(std::function callback); void webgl_pick_file_save( @@ -87,6 +88,20 @@ public: #endif } + void update_platform_frame(float delta_time_seconds) override + { + (void)delta_time_seconds; + } + + void report_rendered_frames(int frames) override + { +#ifdef __LINUX__ + linux_update_fps(frames); +#else + (void)frames; +#endif + } + void pick_image(pp::platform::PickedPathCallback callback) override { #ifdef __IOS__ diff --git a/src/platform_windows/windows_platform_services.cpp b/src/platform_windows/windows_platform_services.cpp index 38f7632..9771148 100644 --- a/src/platform_windows/windows_platform_services.cpp +++ b/src/platform_windows/windows_platform_services.cpp @@ -8,6 +8,8 @@ extern std::deque> main_tasklist; extern std::mutex main_task_mutex; void destroy_window(); +void win32_update_fps(int frames); +void win32_update_stylus(float dt); namespace { @@ -168,6 +170,16 @@ public: (void)visible; } + void update_platform_frame(float delta_time_seconds) override + { + win32_update_stylus(delta_time_seconds); + } + + void report_rendered_frames(int frames) override + { + win32_update_fps(frames); + } + void display_file(std::string_view path) override { (void)path; diff --git a/tests/platform_api/platform_services_tests.cpp b/tests/platform_api/platform_services_tests.cpp index b9c2ce9..ad21ce7 100644 --- a/tests/platform_api/platform_services_tests.cpp +++ b/tests/platform_api/platform_services_tests.cpp @@ -40,6 +40,18 @@ public: keyboard_visible = visible; } + void update_platform_frame(float delta_time_seconds) override + { + ++platform_frame_updates; + last_platform_delta = delta_time_seconds; + } + + void report_rendered_frames(int frames) override + { + ++frame_reports; + last_frame_report = frames; + } + void display_file(std::string_view path) override { ++display_file_requests; @@ -98,6 +110,8 @@ public: int clipboard_writes = 0; int cursor_updates = 0; int keyboard_updates = 0; + int platform_frame_updates = 0; + int frame_reports = 0; int display_file_requests = 0; int share_file_requests = 0; int app_close_requests = 0; @@ -109,6 +123,8 @@ public: bool cursor_visible = false; bool keyboard_visible = false; bool prepared_file_saved = true; + float last_platform_delta = 0.0f; + int last_frame_report = 0; std::string displayed_path; std::string shared_path; std::string prepared_file_path; @@ -161,6 +177,20 @@ void platform_services_dispatch_visibility_updates(pp::tests::Harness& harness) PP_EXPECT(harness, !fake.keyboard_visible); } +void platform_services_dispatch_frame_hooks(pp::tests::Harness& harness) +{ + FakePlatformServices fake("unused"); + pp::platform::PlatformServices& services = fake; + + services.update_platform_frame(0.125f); + services.report_rendered_frames(42); + + PP_EXPECT(harness, fake.platform_frame_updates == 1); + PP_EXPECT(harness, fake.last_platform_delta == 0.125f); + PP_EXPECT(harness, fake.frame_reports == 1); + PP_EXPECT(harness, fake.last_frame_report == 42); +} + void platform_services_dispatch_file_actions(pp::tests::Harness& harness) { FakePlatformServices fake("unused"); @@ -233,6 +263,7 @@ int main() harness.run("platform services dispatch clipboard reads and writes", platform_services_dispatch_clipboard_reads_and_writes); harness.run("platform services preserve empty clipboard writes", platform_services_preserve_empty_clipboard_writes); harness.run("platform services dispatch visibility updates", platform_services_dispatch_visibility_updates); + harness.run("platform services dispatch frame hooks", platform_services_dispatch_frame_hooks); harness.run("platform services dispatch file actions", platform_services_dispatch_file_actions); harness.run("platform services dispatch picker callbacks", platform_services_dispatch_picker_callbacks); harness.run("platform services dispatch prepared file save", platform_services_dispatch_prepared_file_save);