Skip to content

feat(platform): add owned SurfaceTarget seam for GPU renderer attachment - #24

Merged
Xuepoo merged 1 commit into
mainfrom
ctx-0017/feat-platform-surface-seam
Aug 26, 2026
Merged

Xuepoo merged 1 commit into
mainfrom
ctx-0017/feat-platform-surface-seam

Conversation

@Xuepoo

@Xuepoo Xuepoo commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

Closes #23

Implements CarryCtx task CTX-0017 (team core-foundation, agent core-implementer).

Outcome

Adds the owned SurfaceTarget GPU-attachment seam to bitty-platform so a future renderer slice can attach a wgpu surface without winit/raw-window-handle types leaking through the public API — except the single documented exception below.

  • surface::SurfaceTarget: derived from WindowHandle::surface_target(); winit stays behind a private SurfaceSource trait (headless test seam).
  • SurfaceTarget::with_raw_handles: lends raw display/window handles for wgpu surface creation.
  • DPI-size refresh hooks: WindowHandle::logical_to_physical, SurfaceTarget::logical_to_physical.
  • Resize→surface-extent flow documented on PlatformEvent/WindowEventKind; pure mapper map_resize_to_surface_extent returns None for zero extents.
  • New owned error variant PlatformError::SurfaceHandle.

Boundary-type decision

raw-window-handle types are unavoidable at the surface handoff boundary: wgpu 25 (bitty-render, ADR-0004) consumes raw display/window handles as its creation payload. Per the task's fallback clause the dependency is pinned exactly (=0.6.2, matching the version already locked via wgpu 25.0.2 — zero lock drift) and re-exported at the crate root (bitty_platform::raw_window_handle) so consumers share one version instead of adding their own. No winit type escapes; rationale documented in crate ownership rules and src/surface.rs.

Security/performance impact

None beyond surface: zero unsafe added (crate forbids it); no new attack surface (handles are lent only to an in-process caller closure). Performance-neutral; no hot-path code.

Docs synchronization

Crate/module/variant docs updated in-repo (lib.rs ownership rules + limitations, surface module flow, event resize-flow docs). Cross-repo bitty-docs sync is tracked by the owning task lifecycle per documentation rules; no canonical doc in bitty-docs describes this API yet.

Validation

  • just check green locally: fmt-check, clippy -D warnings (workspace, all targets), workspace tests, actionlint, markdownlint.
  • 11 new headless unit tests (handle plumbing, error paths without invoking configure, clone identity sharing, extent mapping incl. zero-dim drops, DPI refresh math); 32 crate tests green; gui-tests smoke extended (display-gated, local evidence).

Merge order

None; single-repository change scoped to crates/bitty-platform/** + manifest/lock pin.

Implements CTX-0017 per ADR-0004 (GPU rendering strategy touches only
bitty-render and bitty-platform) and closes the CTX-0015 deferral of
window-surface attachment.

- surface::SurfaceTarget: Bitty-owned attachment point derived from
  WindowHandle::surface_target(); winit stays behind a private
  SurfaceSource trait so headless unit tests drive the seam with
  constructed inputs (same pattern as the event translation seam).
- SurfaceTarget::with_raw_handles lends raw display/window handles to a
  caller closure for wgpu surface creation. raw-window-handle types are
  unavoidable at this boundary, so the dependency is pinned exactly to
  the version wgpu 25 consumes (=0.6.2, already in Cargo.lock) and
  re-exported at the crate root; rationale documented in crate
  ownership rules.
- DPI-size refresh hook: WindowHandle::logical_to_physical and
  SurfaceTarget::logical_to_physical; resize->surface-extent flow
  documented on PlatformEvent/WindowEventKind and the surface module,
  with map_resize_to_surface_extent returning None for zero extents
  (minimized windows) so renderers skip configuration.
- PlatformError::SurfaceHandle for owned handle-failure reporting.
- gui-tests display smoke extended: live window yields both handles and
  its size maps to a usable surface extent.

Headless unit tests cover handle plumbing, error paths without
invoking configure, clone identity sharing, extent mapping, and DPI
refresh math; 32 crate tests green. just check green.

Closes #23

CarryCtx: CTX-0017 (team core-foundation)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:platform Area: platform / windowing area:render Area: rendering feat Feature P0 Priority: highest

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(platform): expose owned surface-target seam for renderer attachment

1 participant