Own Web fallback services and trim Win32 session state
This commit is contained in:
@@ -19,12 +19,22 @@ struct RetainedLegacyStoragePaths final {
|
||||
pp::platform::PlatformStoragePaths storage_paths;
|
||||
};
|
||||
|
||||
struct RetainedLegacyWebPlatformServicesBinding final {
|
||||
pp::platform::WebPlatformServices* services = nullptr;
|
||||
};
|
||||
|
||||
[[nodiscard]] RetainedLegacyStoragePaths& retained_legacy_storage_paths()
|
||||
{
|
||||
static RetainedLegacyStoragePaths state;
|
||||
return state;
|
||||
}
|
||||
|
||||
[[nodiscard]] RetainedLegacyWebPlatformServicesBinding& retained_legacy_web_platform_services_binding()
|
||||
{
|
||||
static RetainedLegacyWebPlatformServicesBinding state;
|
||||
return state;
|
||||
}
|
||||
|
||||
class RetainedWebPlatformServices final : public pp::platform::WebPlatformServices {
|
||||
public:
|
||||
void publish_exported_image(std::string_view path) override
|
||||
@@ -94,10 +104,23 @@ void request_legacy_glfw_app_close()
|
||||
|
||||
[[nodiscard]] pp::platform::WebPlatformServices& active_legacy_web_platform_services()
|
||||
{
|
||||
if (auto* services = retained_legacy_web_platform_services_binding().services)
|
||||
return *services;
|
||||
|
||||
static RetainedWebPlatformServices services;
|
||||
return pp::platform::resolve_web_platform_services(services);
|
||||
}
|
||||
|
||||
[[nodiscard]] std::unique_ptr<pp::platform::WebPlatformServices> create_legacy_web_platform_services()
|
||||
{
|
||||
return std::make_unique<RetainedWebPlatformServices>();
|
||||
}
|
||||
|
||||
void set_legacy_web_platform_services(pp::platform::WebPlatformServices* services)
|
||||
{
|
||||
retained_legacy_web_platform_services_binding().services = services;
|
||||
}
|
||||
|
||||
[[nodiscard]] bool handles_legacy_web_platform_family(pp::platform::PlatformFamily family) noexcept
|
||||
{
|
||||
return family == pp::platform::PlatformFamily::webgl;
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "platform_api/platform_policy.h"
|
||||
#include "platform_api/platform_services.h"
|
||||
|
||||
@@ -22,6 +24,8 @@ void request_legacy_glfw_app_close();
|
||||
#endif
|
||||
|
||||
[[nodiscard]] pp::platform::WebPlatformServices& active_legacy_web_platform_services();
|
||||
[[nodiscard]] std::unique_ptr<pp::platform::WebPlatformServices> create_legacy_web_platform_services();
|
||||
void set_legacy_web_platform_services(pp::platform::WebPlatformServices* services);
|
||||
[[nodiscard]] bool handles_legacy_web_platform_family(pp::platform::PlatformFamily family) noexcept;
|
||||
void publish_legacy_web_exported_image(std::string_view path);
|
||||
[[nodiscard]] bool try_publish_legacy_web_exported_image(
|
||||
|
||||
Reference in New Issue
Block a user