Harden runtime flags and thin Apple/canvas seams

This commit is contained in:
2026-06-16 08:00:36 +02:00
parent 34e2747867
commit 2948e907bc
7 changed files with 157 additions and 50 deletions

View File

@@ -132,25 +132,62 @@ struct RetainedLegacyGlfwWindowHooks final {
return types;
}
struct RetainedLegacyAppleState final {
#ifdef __IOS__
decltype(App::I->ios_view) ios_view = nullptr;
decltype(App::I->ios_app) ios_app = nullptr;
#elif defined(__OSX__)
decltype(App::I->osx_view) osx_view = nullptr;
decltype(App::I->osx_app) osx_app = nullptr;
#endif
pp::platform::PlatformStoragePaths storage_paths;
};
[[nodiscard]] RetainedLegacyAppleState& active_legacy_apple_state()
{
static RetainedLegacyAppleState state = [] {
RetainedLegacyAppleState retained;
#ifdef __IOS__
retained.ios_view = App::I->ios_view;
retained.ios_app = App::I->ios_app;
retained.storage_paths = {
App::I->data_path,
App::I->work_path,
App::I->rec_path,
App::I->tmp_path,
};
#elif defined(__OSX__)
retained.osx_view = App::I->osx_view;
retained.osx_app = App::I->osx_app;
retained.storage_paths = {
App::I->data_path,
App::I->work_path,
App::I->rec_path,
App::I->tmp_path,
};
#endif
return retained;
}();
return state;
}
[[nodiscard]] pp::platform::PlatformStoragePaths prepare_legacy_apple_storage_paths()
{
const auto& apple_state = active_legacy_apple_state();
#ifdef __IOS__
[App::I->ios_view init_dirs];
[apple_state.ios_view init_dirs];
#elif defined(__OSX__)
[App::I->osx_app init_dirs];
[apple_state.osx_app init_dirs];
#endif
return {
App::I->data_path,
App::I->work_path,
App::I->rec_path,
App::I->tmp_path,
};
return apple_state.storage_paths;
}
[[nodiscard]] pp::platform::apple::AppleDocumentPlatformServices& active_apple_document_platform_services()
{
#ifdef __IOS__
auto* const ios_view = App::I->ios_view;
const auto& apple_state = active_legacy_apple_state();
auto* const ios_view = apple_state.ios_view;
auto* const ios_app = apple_state.ios_app;
static pp::platform::apple::AppleDocumentPlatformServices services(
pp::platform::PlatformFamily::ios,
[ios_view] {
@@ -173,8 +210,8 @@ struct RetainedLegacyGlfwWindowHooks final {
bridge.trigger_crash_test = [ios_view] {
[ios_view crash];
};
bridge.start_sonarpen = [ios_view] {
[App::I->ios_app sonarpen_start];
bridge.start_sonarpen = [ios_app] {
[ios_app sonarpen_start];
};
bridge.acquire_render_context = [ios_view] {
[ios_view async_lock];
@@ -224,8 +261,9 @@ struct RetainedLegacyGlfwWindowHooks final {
}());
return services;
#else
auto* const osx_view = App::I->osx_view;
auto* const osx_app = App::I->osx_app;
const auto& apple_state = active_legacy_apple_state();
auto* const osx_view = apple_state.osx_view;
auto* const osx_app = apple_state.osx_app;
static pp::platform::apple::AppleDocumentPlatformServices services(
pp::platform::PlatformFamily::macos,
[osx_view, osx_app] {