Own Web legacy platform services explicitly

This commit is contained in:
2026-06-17 12:05:52 +02:00
parent 680452983f
commit e343557a3f
8 changed files with 57 additions and 117 deletions

View File

@@ -18,6 +18,15 @@ agent or engineer to remove them without reconstructing context from chat.
## Reductions ## Reductions
- 2026-06-17: `DEBT-0017`/`DEBT-0050`/`DEBT-0053`/`DEBT-0057` were narrowed
again. `src/platform_legacy/legacy_platform_services.*` now takes an
explicit `WebPlatformServices*` dependency through
`create_platform_services(...)`, `webgl/src/main.cpp` now threads its owned
Web service directly into that legacy adapter, and
`src/platform_legacy/legacy_platform_state.*` no longer carries the retained
`active_legacy_web_platform_services()` / `try_*legacy_web*` dispatch layer;
retained non-Windows adapter execution still exists, but the live WebGL path
no longer depends on a legacy Web fallback singleton-style bridge.
- 2026-06-17: `DEBT-0017` was narrowed again. - 2026-06-17: `DEBT-0017` was narrowed again.
`src/platform_legacy/legacy_platform_services.*` no longer exposes the dead `src/platform_legacy/legacy_platform_services.*` no longer exposes the dead
`pp::platform::legacy::platform_services()` fallback singleton; Linux, `pp::platform::legacy::platform_services()` fallback singleton; Linux,

View File

@@ -70,6 +70,15 @@ What is already real:
- `pp_app_core` - `pp_app_core`
Latest slice: Latest slice:
- `src/platform_legacy/legacy_platform_services.*` now takes an explicit
`WebPlatformServices*` dependency through `create_platform_services(...)`
instead of routing WebGL publish/flush/default-canvas/save-prepared-file
behavior through retained `try_*legacy_web*` fallback helpers.
- `webgl/src/main.cpp` now creates the owned Web service first and threads it
directly into its owned legacy `PlatformServices` instance.
- `src/platform_legacy/legacy_platform_state.*` is down to the retained Web
service factory only; the old `active_legacy_web_platform_services()` and
`try_*legacy_web*` dispatch layer are gone.
- `src/platform_legacy/legacy_platform_services.*` no longer exposes the dead - `src/platform_legacy/legacy_platform_services.*` no longer exposes the dead
`pp::platform::legacy::platform_services()` singleton accessor. `pp::platform::legacy::platform_services()` singleton accessor.
- Linux, WebGL, and Android were already on owned - Linux, WebGL, and Android were already on owned

View File

@@ -78,6 +78,15 @@ Completed, blocked, and superseded task history moved to
the queue is now ordered by code movement instead. the queue is now ordered by code movement instead.
Current slice: Current slice:
- `src/platform_legacy/legacy_platform_services.*` now takes an explicit
`WebPlatformServices*` dependency through `create_platform_services(...)`
instead of routing WebGL publish/flush/default-canvas/save-prepared-file
behavior through retained `try_*legacy_web*` fallback helpers.
- `webgl/src/main.cpp` now creates the owned Web service first and threads it
directly into its owned legacy `PlatformServices` instance.
- `src/platform_legacy/legacy_platform_state.*` is down to the retained Web
service factory only; the old `active_legacy_web_platform_services()` and
`try_*legacy_web*` dispatch layer are gone.
- `src/platform_legacy/legacy_platform_services.*` no longer exposes the dead - `src/platform_legacy/legacy_platform_services.*` no longer exposes the dead
`pp::platform::legacy::platform_services()` singleton accessor. `pp::platform::legacy::platform_services()` singleton accessor.
- Linux, WebGL, and Android were already on owned - Linux, WebGL, and Android were already on owned
@@ -194,9 +203,9 @@ Current slice:
singleton. singleton.
- `PanoPainter-OSX/main.cpp` and `PanoPainter/GameViewController.m` now seed - `PanoPainter-OSX/main.cpp` and `PanoPainter/GameViewController.m` now seed
Apple-owned storage paths directly. Apple-owned storage paths directly.
- `src/platform_legacy/legacy_platform_state.*` now exposes - `src/platform_legacy/legacy_platform_state.*` now only exposes
`create_legacy_web_platform_services()` plus an explicit binding hook for the `create_legacy_web_platform_services()` for the retained default Web service
retained Web service surface. implementation.
- `webgl/src/main.cpp` now owns and binds the Web platform-services - `webgl/src/main.cpp` now owns and binds the Web platform-services
implementation explicitly instead of relying only on the retained fallback implementation explicitly instead of relying only on the retained fallback
object in legacy platform state. object in legacy platform state.

View File

@@ -1,6 +1,5 @@
#include "pch.h" #include "pch.h"
#include "platform_legacy/legacy_platform_services.h" #include "platform_legacy/legacy_platform_services.h"
#include "platform_legacy/legacy_platform_state.h"
#include <memory> #include <memory>
@@ -54,6 +53,7 @@ public:
#ifdef __ANDROID__ #ifdef __ANDROID__
, android_storage_paths_(std::move(config.android_storage_paths)) , android_storage_paths_(std::move(config.android_storage_paths))
#endif #endif
, web_platform_services_(config.web_platform_services)
{ {
} }
@@ -272,8 +272,11 @@ public:
void publish_exported_image(std::string_view path) override void publish_exported_image(std::string_view path) override
{ {
const auto family = pp::platform::current_platform_family(); const auto family = pp::platform::current_platform_family();
if (pp::platform::legacy::try_publish_legacy_web_exported_image(family, path)) if (family == pp::platform::PlatformFamily::webgl)
{
active_web_platform_services().publish_exported_image(path);
return; return;
}
if (!pp::platform::platform_publishes_exported_images(family)) if (!pp::platform::platform_publishes_exported_images(family))
{ {
(void)path; (void)path;
@@ -289,8 +292,11 @@ public:
void flush_persistent_storage() override void flush_persistent_storage() override
{ {
const auto family = pp::platform::current_platform_family(); const auto family = pp::platform::current_platform_family();
if (pp::platform::legacy::try_flush_legacy_web_persistent_storage(family)) if (family == pp::platform::PlatformFamily::webgl)
{
active_web_platform_services().flush_persistent_storage();
return; return;
}
if (!pp::platform::platform_flushes_persistent_storage(family)) if (!pp::platform::platform_flushes_persistent_storage(family))
return; return;
} }
@@ -456,9 +462,8 @@ public:
[[nodiscard]] int default_canvas_resolution() override [[nodiscard]] int default_canvas_resolution() override
{ {
const auto family = pp::platform::current_platform_family(); const auto family = pp::platform::current_platform_family();
int resolution = 0; if (family == pp::platform::PlatformFamily::webgl)
if (pp::platform::legacy::try_default_legacy_web_canvas_resolution(family, resolution)) return active_web_platform_services().default_canvas_resolution();
return resolution;
return pp::platform::platform_default_canvas_resolution(family); return pp::platform::platform_default_canvas_resolution(family);
} }
@@ -535,12 +540,14 @@ public:
pp::platform::PreparedFileCallback callback) override pp::platform::PreparedFileCallback callback) override
{ {
const auto family = pp::platform::current_platform_family(); const auto family = pp::platform::current_platform_family();
if (pp::platform::legacy::try_save_legacy_web_prepared_file( if (family == pp::platform::PlatformFamily::webgl)
family, {
active_web_platform_services().save_prepared_file(
path, path,
suggested_name, suggested_name,
std::move(callback))) std::move(callback));
return; return;
}
const std::string value(path); const std::string value(path);
const std::string name(suggested_name); const std::string name(suggested_name);
@@ -556,6 +563,13 @@ public:
} }
private: private:
[[nodiscard]] pp::platform::WebPlatformServices& active_web_platform_services() const noexcept
{
if (web_platform_services_)
return *web_platform_services_;
return pp::platform::active_web_platform_services();
}
static void invoke_legacy_glfw_shell_callback(const std::function<void()>& callback) static void invoke_legacy_glfw_shell_callback(const std::function<void()>& callback)
{ {
if (callback) if (callback)
@@ -566,6 +580,7 @@ private:
#ifdef __ANDROID__ #ifdef __ANDROID__
std::shared_ptr<pp::platform::PlatformStoragePaths> android_storage_paths_; std::shared_ptr<pp::platform::PlatformStoragePaths> android_storage_paths_;
#endif #endif
pp::platform::WebPlatformServices* web_platform_services_ = nullptr;
}; };
} }

View File

@@ -16,6 +16,7 @@ struct LegacyGlfwPlatformShell {
struct LegacyPlatformServicesConfig { struct LegacyPlatformServicesConfig {
LegacyGlfwPlatformShell glfw_shell; LegacyGlfwPlatformShell glfw_shell;
std::shared_ptr<pp::platform::PlatformStoragePaths> android_storage_paths; std::shared_ptr<pp::platform::PlatformStoragePaths> android_storage_paths;
pp::platform::WebPlatformServices* web_platform_services = nullptr;
}; };
[[nodiscard]] std::unique_ptr<PlatformServices> create_platform_services( [[nodiscard]] std::unique_ptr<PlatformServices> create_platform_services(

View File

@@ -50,90 +50,9 @@ public:
} }
[[nodiscard]] pp::platform::WebPlatformServices& active_legacy_web_platform_services()
{
static RetainedWebPlatformServices services;
return pp::platform::resolve_web_platform_services(services);
}
[[nodiscard]] std::unique_ptr<pp::platform::WebPlatformServices> create_legacy_web_platform_services() [[nodiscard]] std::unique_ptr<pp::platform::WebPlatformServices> create_legacy_web_platform_services()
{ {
return std::make_unique<RetainedWebPlatformServices>(); return std::make_unique<RetainedWebPlatformServices>();
} }
[[nodiscard]] bool handles_legacy_web_platform_family(pp::platform::PlatformFamily family) noexcept
{
return family == pp::platform::PlatformFamily::webgl;
}
void publish_legacy_web_exported_image(std::string_view path)
{
active_legacy_web_platform_services().publish_exported_image(path);
}
[[nodiscard]] bool try_publish_legacy_web_exported_image(
pp::platform::PlatformFamily family,
std::string_view path)
{
if (!handles_legacy_web_platform_family(family))
return false;
publish_legacy_web_exported_image(path);
return true;
}
void flush_legacy_web_persistent_storage()
{
active_legacy_web_platform_services().flush_persistent_storage();
}
[[nodiscard]] bool try_flush_legacy_web_persistent_storage(pp::platform::PlatformFamily family)
{
if (!handles_legacy_web_platform_family(family))
return false;
flush_legacy_web_persistent_storage();
return true;
}
[[nodiscard]] int default_legacy_web_canvas_resolution() noexcept
{
return active_legacy_web_platform_services().default_canvas_resolution();
}
[[nodiscard]] bool try_default_legacy_web_canvas_resolution(
pp::platform::PlatformFamily family,
int& resolution) noexcept
{
if (!handles_legacy_web_platform_family(family))
return false;
resolution = default_legacy_web_canvas_resolution();
return true;
}
void save_legacy_web_prepared_file(
std::string_view path,
std::string_view suggested_name,
pp::platform::PreparedFileCallback callback)
{
active_legacy_web_platform_services().save_prepared_file(
path,
suggested_name,
std::move(callback));
}
[[nodiscard]] bool try_save_legacy_web_prepared_file(
pp::platform::PlatformFamily family,
std::string_view path,
std::string_view suggested_name,
pp::platform::PreparedFileCallback callback)
{
if (!handles_legacy_web_platform_family(family))
return false;
save_legacy_web_prepared_file(path, suggested_name, std::move(callback));
return true;
}
} }

View File

@@ -2,33 +2,10 @@
#include <memory> #include <memory>
#include "platform_api/platform_policy.h"
#include "platform_api/platform_services.h" #include "platform_api/platform_services.h"
namespace pp::platform::legacy { namespace pp::platform::legacy {
[[nodiscard]] pp::platform::WebPlatformServices& active_legacy_web_platform_services();
[[nodiscard]] std::unique_ptr<pp::platform::WebPlatformServices> create_legacy_web_platform_services(); [[nodiscard]] std::unique_ptr<pp::platform::WebPlatformServices> create_legacy_web_platform_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(
pp::platform::PlatformFamily family,
std::string_view path);
void flush_legacy_web_persistent_storage();
[[nodiscard]] bool try_flush_legacy_web_persistent_storage(
pp::platform::PlatformFamily family);
[[nodiscard]] int default_legacy_web_canvas_resolution() noexcept;
[[nodiscard]] bool try_default_legacy_web_canvas_resolution(
pp::platform::PlatformFamily family,
int& resolution) noexcept;
void save_legacy_web_prepared_file(
std::string_view path,
std::string_view suggested_name,
pp::platform::PreparedFileCallback callback);
[[nodiscard]] bool try_save_legacy_web_prepared_file(
pp::platform::PlatformFamily family,
std::string_view path,
std::string_view suggested_name,
pp::platform::PreparedFileCallback callback);
} }

View File

@@ -203,13 +203,14 @@ int main()
if (glfwInit() != GL_TRUE) if (glfwInit() != GL_TRUE)
printf("Failed to init GLFW"); printf("Failed to init GLFW");
wnd = glfwCreateWindow(1024, 768, "PanoPainter", nullptr, nullptr); wnd = glfwCreateWindow(1024, 768, "PanoPainter", nullptr, nullptr);
g_web_platform_services = pp::platform::legacy::create_legacy_web_platform_services();
g_platform_services = pp::platform::legacy::create_platform_services({ g_platform_services = pp::platform::legacy::create_platform_services({
.glfw_shell = { .glfw_shell = {
.acquire_render_context = [wnd] { glfwMakeContextCurrent(wnd); }, .acquire_render_context = [wnd] { glfwMakeContextCurrent(wnd); },
.present_render_context = [wnd] { glfwSwapBuffers(wnd); }, .present_render_context = [wnd] { glfwSwapBuffers(wnd); },
}, },
.web_platform_services = g_web_platform_services.get(),
}); });
g_web_platform_services = pp::platform::legacy::create_legacy_web_platform_services();
glfwMakeContextCurrent(wnd); glfwMakeContextCurrent(wnd);
/* /*