TestPlatform
in treeThe in-process platform the test harness draws through: deterministic dispatchers, a simulated display and window, and no display server.
gpui_authoring · test-support
The platform is the host seam: it supplies the event loop, the windows, the displays, the clipboard and the GPU backend the scene draws through. Four ship and two harnesses exist for tests; a platform of your own is a Platform impl, not a fork.
A platform is never chosen by a manifest line or a runtime string. The facade's platform bundle enables the one for the target, and the application is constructed with it — which is why the same source compiles on all four. The two mobile slabs are the exception: they are a third-party platform crate, not a backend in this tree.
The wgpu renderer is the one two platforms share: Linux always draws through it, and the web reaches WebGPU through the same crate. Metal and Direct3D are native backends with their own command encoders.
The trait is the contract between the facade and a backend. It is declared in gpui_platform, the acyclic leaf that links no drivers — a backend implements it without depending on the framework.
Application::with_platform(Rc<dyn Platform>) — the constructor, not a setter. A platform is chosen with the application rather than chained onto it. The default is the host's own, compiled in by cfg.
Two implementations in the tree are not desktop platforms at all, and they are what a new backend can be modelled on: neither has a window server, and one has no GPU.
The in-process platform the test harness draws through: deterministic dispatchers, a simulated display and window, and no display server.
gpui_authoring · test-support
A platform with no compositor surface: layout, text shaping and entity plumbing run normally, and draw discards the scene.
gpui_linux · ZED_HEADLESS
An out-of-tree platform implements the same trait, gets a WindowId space and a renderer, and is installed with with_platform. The mobile path is the third-party gpui-mobile crate, which targets iOS (Metal) and Android (wgpu/Vulkan) — it is not ported to these crates yet.
Ways to extend has all four, and Bring your own surface is the pixels side. If what you want to change is the algorithm a seam runs, that is a swap.