diff --git a/android/src/cpp/main.cpp b/android/src/cpp/main.cpp index 0e33f1a0..e2745bd1 100644 --- a/android/src/cpp/main.cpp +++ b/android/src/cpp/main.cpp @@ -276,7 +276,7 @@ JNIEXPORT void JNICALL Java_com_omixlab_panopainter_MainActivity_pickExternalCal App::I->data_path = file_path; App::I->work_path = file_path; App::I->rec_path = file_path + "/frames"; - pp::platform::legacy::set_legacy_storage_paths({ + pp::platform::legacy::set_legacy_android_storage_paths({ App::I->data_path, App::I->work_path, App::I->rec_path, @@ -716,7 +716,7 @@ static int engine_init_display(struct engine* engine) { if (App::I->data_path.empty() || App::I->data_path == ".") App::I->data_path = get_data_path(); LOG("data_path %s", App::I->data_path.c_str()); - pp::platform::legacy::set_legacy_storage_paths({ + pp::platform::legacy::set_legacy_android_storage_paths({ App::I->data_path, App::I->work_path.empty() ? App::I->data_path : App::I->work_path, App::I->rec_path, diff --git a/docs/modernization/roadmap.md b/docs/modernization/roadmap.md index af13cad7..d7aa115a 100644 --- a/docs/modernization/roadmap.md +++ b/docs/modernization/roadmap.md @@ -70,6 +70,16 @@ What is already real: - `pp_app_core` Latest slice: +- `src/platform_legacy/legacy_platform_services.cpp` now reads Android storage + paths from Android-owned retained state instead of the shared legacy + storage-path singleton. +- `src/legacy_app_startup_services.cpp` and `android/src/cpp/main.cpp` now + update Android-owned retained storage paths instead of the shared legacy + storage-path singleton. +- `src/app_events.cpp`, `linux/src/main.cpp`, and + `src/platform_legacy/legacy_platform_state.*` now route the Linux FPS-title + callback through a narrow legacy GLFW title helper instead of reaching into + retained GLFW window state from `App::set_platform_services(...)`. - `src/platform_apple/apple_platform_state.cpp` no longer reads Apple storage paths from `pp::platform::legacy::active_legacy_storage_paths()`; Apple-owned retained state now carries that path bundle. diff --git a/docs/modernization/tasks.md b/docs/modernization/tasks.md index 8a89912e..af3ab825 100644 --- a/docs/modernization/tasks.md +++ b/docs/modernization/tasks.md @@ -78,6 +78,15 @@ Completed, blocked, and superseded task history moved to the queue is now ordered by code movement instead. Current slice: +- `src/platform_legacy/legacy_platform_services.cpp` plus + `src/platform_legacy/legacy_platform_state.*` now give Android its own + retained storage-path surface instead of reading the shared legacy singleton. +- `src/legacy_app_startup_services.cpp` and `android/src/cpp/main.cpp` now + write Android-owned retained storage paths. +- `src/app_events.cpp`, `linux/src/main.cpp`, and + `src/platform_legacy/legacy_platform_state.*` now use a narrow GLFW title + helper for Linux FPS-title updates instead of direct retained-window access + in the app event layer. - `src/platform_apple/apple_platform_state.cpp` now reads Apple storage paths from Apple-owned retained state rather than the shared legacy storage-path singleton. diff --git a/linux/src/main.cpp b/linux/src/main.cpp index 790b5739..d9e15c35 100644 --- a/linux/src/main.cpp +++ b/linux/src/main.cpp @@ -39,15 +39,6 @@ std::string linux_home_path() return pw->pw_dir; } -void linux_update_fps(int frames) -{ - static char title_fps[512]; - sprintf(title_fps, "PanoPainter - %d fps", frames); - auto* const window = pp::platform::legacy::active_legacy_glfw_window_state().window; - if (window) - glfwSetWindowTitle(window, title_fps); -} - void error_log(int code, const char * s) { printf("glfw error: %s", s); diff --git a/src/app_events.cpp b/src/app_events.cpp index ac186946..95a3e841 100644 --- a/src/app_events.cpp +++ b/src/app_events.cpp @@ -9,7 +9,6 @@ #include #ifdef __LINUX__ -#include #include "platform_linux/linux_platform_services.h" #endif #ifdef _WIN32 @@ -62,12 +61,8 @@ void App::set_platform_services(pp::platform::PlatformServices* services) noexce #ifdef __LINUX__ if (services) { - pp::platform::linux_desktop::set_fps_title_callback([this](std::string title) { - auto* const window = pp::platform::legacy::active_legacy_glfw_window_state().window; - if (!window) - return; - - glfwSetWindowTitle(window, title.c_str()); + pp::platform::linux_desktop::set_fps_title_callback([](std::string title) { + pp::platform::legacy::set_legacy_glfw_window_title(title); }); } else diff --git a/src/legacy_app_startup_services.cpp b/src/legacy_app_startup_services.cpp index 37909d8b..974213c5 100644 --- a/src/legacy_app_startup_services.cpp +++ b/src/legacy_app_startup_services.cpp @@ -135,12 +135,21 @@ void execute_legacy_app_init_log(App& app) // TODO: save this path somewhere in the settings, don't overwrite every start app.work_path = paths.work_path.empty() ? app.data_path : paths.work_path; +#ifdef __ANDROID__ + pp::platform::legacy::set_legacy_android_storage_paths({ + app.data_path, + app.work_path, + app.rec_path, + app.tmp_path, + }); +#else pp::platform::legacy::set_legacy_storage_paths({ app.data_path, app.work_path, app.rec_path, app.tmp_path, }); +#endif //LogRemote::I.start(); LogRemote::I.file_init(); diff --git a/src/platform_legacy/legacy_platform_services.cpp b/src/platform_legacy/legacy_platform_services.cpp index 81fe9461..581a65b6 100644 --- a/src/platform_legacy/legacy_platform_services.cpp +++ b/src/platform_legacy/legacy_platform_services.cpp @@ -83,6 +83,8 @@ public: data_path + "/frames", {}, }; +#elif defined(__ANDROID__) + return pp::platform::legacy::active_legacy_android_storage_paths(); #else return pp::platform::legacy::active_legacy_storage_paths(); #endif diff --git a/src/platform_legacy/legacy_platform_state.cpp b/src/platform_legacy/legacy_platform_state.cpp index 78f24ca4..fbd859a9 100644 --- a/src/platform_legacy/legacy_platform_state.cpp +++ b/src/platform_legacy/legacy_platform_state.cpp @@ -19,6 +19,12 @@ struct RetainedLegacyStoragePaths final { pp::platform::PlatformStoragePaths storage_paths; }; +#ifdef __ANDROID__ +struct RetainedLegacyAndroidStoragePaths final { + pp::platform::PlatformStoragePaths storage_paths; +}; +#endif + struct RetainedLegacyWebPlatformServicesBinding final { pp::platform::WebPlatformServices* services = nullptr; }; @@ -29,6 +35,14 @@ struct RetainedLegacyWebPlatformServicesBinding final { return state; } +#ifdef __ANDROID__ +[[nodiscard]] RetainedLegacyAndroidStoragePaths& retained_legacy_android_storage_paths() +{ + static RetainedLegacyAndroidStoragePaths state; + return state; +} +#endif + [[nodiscard]] RetainedLegacyWebPlatformServicesBinding& retained_legacy_web_platform_services_binding() { static RetainedLegacyWebPlatformServicesBinding state; @@ -86,6 +100,16 @@ void set_legacy_glfw_window(GLFWwindow* window) active_legacy_glfw_window_state().window = window; } +void set_legacy_glfw_window_title(std::string_view title) +{ + auto* const window = active_legacy_glfw_window_state().window; + if (!window) + return; + + const std::string title_value(title); + glfwSetWindowTitle(window, title_value.c_str()); +} + void acquire_legacy_glfw_render_context() { glfwMakeContextCurrent(active_legacy_glfw_window_state().window); @@ -206,4 +230,16 @@ void set_legacy_storage_paths(pp::platform::PlatformStoragePaths paths) retained_legacy_storage_paths().storage_paths = std::move(paths); } +#ifdef __ANDROID__ +[[nodiscard]] const pp::platform::PlatformStoragePaths& active_legacy_android_storage_paths() +{ + return retained_legacy_android_storage_paths().storage_paths; +} + +void set_legacy_android_storage_paths(pp::platform::PlatformStoragePaths paths) +{ + retained_legacy_android_storage_paths().storage_paths = std::move(paths); +} +#endif + } diff --git a/src/platform_legacy/legacy_platform_state.h b/src/platform_legacy/legacy_platform_state.h index ef93ada7..ed57113b 100644 --- a/src/platform_legacy/legacy_platform_state.h +++ b/src/platform_legacy/legacy_platform_state.h @@ -18,6 +18,7 @@ struct RetainedLegacyGlfwWindowState final { [[nodiscard]] RetainedLegacyGlfwWindowState& active_legacy_glfw_window_state(); void set_legacy_glfw_window(GLFWwindow* window); +void set_legacy_glfw_window_title(std::string_view title); void acquire_legacy_glfw_render_context(); void present_legacy_glfw_render_context(); void request_legacy_glfw_app_close(); @@ -51,4 +52,9 @@ void save_legacy_web_prepared_file( [[nodiscard]] const pp::platform::PlatformStoragePaths& active_legacy_storage_paths(); void set_legacy_storage_paths(pp::platform::PlatformStoragePaths paths); +#ifdef __ANDROID__ +[[nodiscard]] const pp::platform::PlatformStoragePaths& active_legacy_android_storage_paths(); +void set_legacy_android_storage_paths(pp::platform::PlatformStoragePaths paths); +#endif + }