diff --git a/docs/modernization/roadmap.md b/docs/modernization/roadmap.md index 43cc4018..a3e16074 100644 --- a/docs/modernization/roadmap.md +++ b/docs/modernization/roadmap.md @@ -97,6 +97,10 @@ Latest slice: and bound-tablet bindings beside the retained owned `App`, `AppRuntime*`, and `WacomTablet` objects instead of leaving that binding surface in `windows_runtime_shell.cpp`. +- `src/platform_windows/windows_runtime_state.*` now also owns the Win32 + owned-app creation plus app/runtime binding handoff, so + `windows_runtime_shell.cpp` is down to a thinner startup dispatcher over the + retained runtime-state helper. - `src/platform_windows/windows_runtime_shell.h` is now a thinner runtime entrypoint header that picks up the retained binding surface from `windows_runtime_state.h` instead of declaring a second shell-owned binding diff --git a/docs/modernization/tasks.md b/docs/modernization/tasks.md index daf8f242..ae4227f2 100644 --- a/docs/modernization/tasks.md +++ b/docs/modernization/tasks.md @@ -104,6 +104,10 @@ Current slice: - `src/platform_windows/windows_runtime_state.*` now also owns the bound Win32 `App*` / tablet binding surface alongside the retained owned `App`, runtime, and tablet objects. +- `src/platform_windows/windows_runtime_state.*` now also owns the Win32 + owned-app creation plus app/runtime binding handoff, so + `windows_runtime_shell.cpp` is thinner and no longer open-codes that + retained runtime-state setup. - `src/platform_windows/windows_runtime_shell.h` is thinner again and now imports that binding surface from `windows_runtime_state.h` instead of declaring shell-owned bind/release accessors itself. diff --git a/src/platform_windows/windows_runtime_shell.cpp b/src/platform_windows/windows_runtime_shell.cpp index 8b21ac79..00b379ab 100644 --- a/src/platform_windows/windows_runtime_shell.cpp +++ b/src/platform_windows/windows_runtime_shell.cpp @@ -17,13 +17,9 @@ int run_main_application(int argc, char** argv) { const auto instance = GetModuleHandle(NULL); - auto& owned_app = retained_owned_app(); - owned_app = std::make_unique(); - auto* app = owned_app.get(); - bind_app(app); - bind_runtime(&app->runtime()); - app->set_platform_services(&pp::platform::windows::platform_services()); - app->initLog(); + auto& app = initialize_bound_app_runtime(); + app.set_platform_services(&pp::platform::windows::platform_services()); + app.initLog(); pp::platform::windows::init_shcore_API(); pp::platform::windows::initialize_stylus_input(); @@ -37,13 +33,13 @@ int run_main_application(int argc, char** argv) pp::platform::windows::initialize_retained_input_state(); - pp::platform::windows::setup_exception_handler(*app); + pp::platform::windows::setup_exception_handler(app); pp::platform::windows::read_WMI_info(); - app->create(); + app.create(); - auto startup = pp::platform::windows::initialize_main_window_startup_state(*app); + auto startup = pp::platform::windows::initialize_main_window_startup_state(app); auto context = pp::platform::windows::OpenGlWindowContext {}; switch (pp::platform::windows::initialize_main_window_and_gl( startup, @@ -70,8 +66,8 @@ int run_main_application(int argc, char** argv) switch (const_hash(argv[1])) { case const_hash("convert"): - app->initShaders(); - app->cmd_convert(argv[2], argv[3]); + app.initShaders(); + app.cmd_convert(argv[2], argv[3]); release_bound_app(); return 0; case const_hash("-vrmode"): diff --git a/src/platform_windows/windows_runtime_state.cpp b/src/platform_windows/windows_runtime_state.cpp index c5e4f365..e592ad48 100644 --- a/src/platform_windows/windows_runtime_state.cpp +++ b/src/platform_windows/windows_runtime_state.cpp @@ -24,6 +24,16 @@ struct RetainedWindowsRuntimeState final { } +App& initialize_bound_app_runtime() +{ + auto& owned_app = retained_owned_app(); + owned_app = std::make_unique(); + auto& app = *owned_app; + bind_app(&app); + bind_runtime(&app.runtime()); + return app; +} + void bind_app(App* app) noexcept { auto& state = retained_runtime_state(); diff --git a/src/platform_windows/windows_runtime_state.h b/src/platform_windows/windows_runtime_state.h index 8e6c594a..c1b0a98c 100644 --- a/src/platform_windows/windows_runtime_state.h +++ b/src/platform_windows/windows_runtime_state.h @@ -8,6 +8,7 @@ class WacomTablet; namespace pp::platform::windows { +[[nodiscard]] App& initialize_bound_app_runtime(); void bind_app(App* app) noexcept; [[nodiscard]] App* bound_app() noexcept; void release_bound_app() noexcept;