Centralize Win32 app runtime binding setup
This commit is contained in:
@@ -97,6 +97,10 @@ Latest slice:
|
|||||||
and bound-tablet bindings beside the retained owned `App`, `AppRuntime*`,
|
and bound-tablet bindings beside the retained owned `App`, `AppRuntime*`,
|
||||||
and `WacomTablet` objects instead of leaving that binding surface in
|
and `WacomTablet` objects instead of leaving that binding surface in
|
||||||
`windows_runtime_shell.cpp`.
|
`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
|
- `src/platform_windows/windows_runtime_shell.h` is now a thinner runtime
|
||||||
entrypoint header that picks up the retained binding surface from
|
entrypoint header that picks up the retained binding surface from
|
||||||
`windows_runtime_state.h` instead of declaring a second shell-owned binding
|
`windows_runtime_state.h` instead of declaring a second shell-owned binding
|
||||||
|
|||||||
@@ -104,6 +104,10 @@ Current slice:
|
|||||||
- `src/platform_windows/windows_runtime_state.*` now also owns the bound
|
- `src/platform_windows/windows_runtime_state.*` now also owns the bound
|
||||||
Win32 `App*` / tablet binding surface alongside the retained owned `App`,
|
Win32 `App*` / tablet binding surface alongside the retained owned `App`,
|
||||||
runtime, and tablet objects.
|
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
|
- `src/platform_windows/windows_runtime_shell.h` is thinner again and now
|
||||||
imports that binding surface from `windows_runtime_state.h` instead of
|
imports that binding surface from `windows_runtime_state.h` instead of
|
||||||
declaring shell-owned bind/release accessors itself.
|
declaring shell-owned bind/release accessors itself.
|
||||||
|
|||||||
@@ -17,13 +17,9 @@ int run_main_application(int argc, char** argv)
|
|||||||
{
|
{
|
||||||
const auto instance = GetModuleHandle(NULL);
|
const auto instance = GetModuleHandle(NULL);
|
||||||
|
|
||||||
auto& owned_app = retained_owned_app();
|
auto& app = initialize_bound_app_runtime();
|
||||||
owned_app = std::make_unique<App>();
|
app.set_platform_services(&pp::platform::windows::platform_services());
|
||||||
auto* app = owned_app.get();
|
app.initLog();
|
||||||
bind_app(app);
|
|
||||||
bind_runtime(&app->runtime());
|
|
||||||
app->set_platform_services(&pp::platform::windows::platform_services());
|
|
||||||
app->initLog();
|
|
||||||
|
|
||||||
pp::platform::windows::init_shcore_API();
|
pp::platform::windows::init_shcore_API();
|
||||||
pp::platform::windows::initialize_stylus_input();
|
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::initialize_retained_input_state();
|
||||||
|
|
||||||
pp::platform::windows::setup_exception_handler(*app);
|
pp::platform::windows::setup_exception_handler(app);
|
||||||
|
|
||||||
pp::platform::windows::read_WMI_info();
|
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 {};
|
auto context = pp::platform::windows::OpenGlWindowContext {};
|
||||||
switch (pp::platform::windows::initialize_main_window_and_gl(
|
switch (pp::platform::windows::initialize_main_window_and_gl(
|
||||||
startup,
|
startup,
|
||||||
@@ -70,8 +66,8 @@ int run_main_application(int argc, char** argv)
|
|||||||
switch (const_hash(argv[1]))
|
switch (const_hash(argv[1]))
|
||||||
{
|
{
|
||||||
case const_hash("convert"):
|
case const_hash("convert"):
|
||||||
app->initShaders();
|
app.initShaders();
|
||||||
app->cmd_convert(argv[2], argv[3]);
|
app.cmd_convert(argv[2], argv[3]);
|
||||||
release_bound_app();
|
release_bound_app();
|
||||||
return 0;
|
return 0;
|
||||||
case const_hash("-vrmode"):
|
case const_hash("-vrmode"):
|
||||||
|
|||||||
@@ -24,6 +24,16 @@ struct RetainedWindowsRuntimeState final {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
App& initialize_bound_app_runtime()
|
||||||
|
{
|
||||||
|
auto& owned_app = retained_owned_app();
|
||||||
|
owned_app = std::make_unique<App>();
|
||||||
|
auto& app = *owned_app;
|
||||||
|
bind_app(&app);
|
||||||
|
bind_runtime(&app.runtime());
|
||||||
|
return app;
|
||||||
|
}
|
||||||
|
|
||||||
void bind_app(App* app) noexcept
|
void bind_app(App* app) noexcept
|
||||||
{
|
{
|
||||||
auto& state = retained_runtime_state();
|
auto& state = retained_runtime_state();
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ class WacomTablet;
|
|||||||
|
|
||||||
namespace pp::platform::windows {
|
namespace pp::platform::windows {
|
||||||
|
|
||||||
|
[[nodiscard]] App& initialize_bound_app_runtime();
|
||||||
void bind_app(App* app) noexcept;
|
void bind_app(App* app) noexcept;
|
||||||
[[nodiscard]] App* bound_app() noexcept;
|
[[nodiscard]] App* bound_app() noexcept;
|
||||||
void release_bound_app() noexcept;
|
void release_bound_app() noexcept;
|
||||||
|
|||||||
Reference in New Issue
Block a user