Bind Win32 app shell and move more legacy platform state

This commit is contained in:
2026-06-17 01:54:59 +02:00
parent 3cbc88fe78
commit 5c8a87faa0
11 changed files with 185 additions and 123 deletions

View File

@@ -10,6 +10,12 @@
#include <GLFW/glfw3.h>
#endif
void webgl_pick_file_save(
const std::string& path,
const std::string& name,
std::function<void(bool)> callback);
void webgl_sync();
namespace pp::platform::legacy {
namespace {
@@ -204,6 +210,43 @@ struct RetainedLegacyAppleDocumentPlatformState final {
}
#endif
class RetainedWebPlatformServices final : public pp::platform::WebPlatformServices {
public:
void publish_exported_image(std::string_view path) override
{
(void)path;
}
void flush_persistent_storage() override
{
#ifdef __WEB__
webgl_sync();
#endif
}
[[nodiscard]] int default_canvas_resolution() override
{
return pp::platform::platform_default_canvas_resolution(pp::platform::PlatformFamily::webgl);
}
void save_prepared_file(
std::string_view path,
std::string_view suggested_name,
pp::platform::PreparedFileCallback callback) override
{
const std::string value(path);
const std::string name(suggested_name);
#ifdef __WEB__
webgl_pick_file_save(value, name, [callback = std::move(callback), value](bool success) {
callback(value, success);
});
#else
(void)name;
callback(value, false);
#endif
}
};
}
#if defined(__LINUX__) || defined(__WEB__)
@@ -254,6 +297,17 @@ active_legacy_apple_document_platform_services()
return *retained.services;
}
[[nodiscard]] pp::platform::PlatformStoragePaths prepare_legacy_apple_storage_paths()
{
const auto& apple_state = active_legacy_apple_state();
#ifdef __IOS__
[apple_state.ios_view init_dirs];
#elif defined(__OSX__)
[apple_state.osx_app init_dirs];
#endif
return active_legacy_storage_paths();
}
void set_legacy_apple_state(
#ifdef __IOS__
GameViewController* ios_view,
@@ -294,6 +348,12 @@ void set_legacy_apple_state(
}
#endif
[[nodiscard]] pp::platform::WebPlatformServices& active_legacy_web_platform_services()
{
static RetainedWebPlatformServices services;
return pp::platform::resolve_web_platform_services(services);
}
[[nodiscard]] const pp::platform::PlatformStoragePaths& active_legacy_storage_paths()
{
return retained_legacy_storage_paths().storage_paths;