Skip to content

[GPU 07/20] Integrate GPU canvas images into Avalonia retained composition #29

Open

Description

@danwalmsley

Parent epic: #22
Implementation order: 07 of 20.
Depends on: #26, #27, #28.

Outcome

Render shared GPU canvas images inside WebScene's normal Avalonia scene with correct DOM order and zero ordinary CPU pixel readback.

Implementation

  • Extend the current composition handler/retained renderer to consume the new scene ABI and GPU-image leases. Draw images within the actual Skia draw scope, applying correct host transforms, content scale, opacity, clipping and canvas isolation.
  • Add a typed GPU image import/draw feature using available Avalonia GPU/context leases. Use supported public hooks first; implement a narrowly version-pinned framework hook where needed. A CompositionDrawingSurface on top of the entire scene is not sufficient if it breaks DOM interleaving/clipping.
  • Preserve existing retained Canvas2D/SVG/text pictures and cache GPU imports by resource/allocation generation. Never re-record an entire picture merely because GPU content changed.
  • Refine paint ordering where the existing backdrop/canvas/overlay split cannot represent interleaving. Include clips and transforms in damage/culling decisions.
  • Connect producer readiness and consumer completion to real compositor work. Release scene handles separately from GPU leases; retained redraw must remain possible after backing-surface recreation.
  • Preserve ordered scene consumption, frame timestamps, synchronous live-resize handling and the no-drawable retry path.
  • Detect/handle compositor device recreation, missing Skia lease, adapter mismatch and unsupported import. Do not route through WriteableBitmap/readback.
  • Keep any framework patches reproducible and documented; do not assume newer public docs match the repository's pinned Avalonia version.

Tests

  • All three desktop native producer bridges inside an actual Avalonia window.
  • GPU canvas behind/between/in front of DOM and Canvas2D content, nested clips, transforms, opacity, scroll, resizing and high DPI.
  • Missing lease, expose repaint, delayed completion, two documents/windows, detach/reparent and compositor loss.
  • Unchanged content produces retained replay without allocations proportional to draw count; existing text/SVG/canvas pixel suites remain correct.

Verification evidence

Attach actual presented screenshots/pixel assertions, desktop matrix results, native/compositor frame timeline and copy counters. Include patch/version metadata and baseline performance comparison.

Acceptance

  • Dawn and ANGLE probe images compose correctly on Windows/macOS/Linux.
  • DOM interleaving, clipping, alpha, transforms and damage remain correct.
  • GPU image reuse/release follows compositor completion.
  • No ordinary CPU pixel readback/upload occurs.
  • Existing rendering/input/resize regression suites pass.

Completion requirements

Link the implementation PR, exact test commands, native/runtime/framework revisions and verification artifacts before closing. Follow the epic's architecture and copy/lifetime invariants. Any unavailable mandatory hardware or missing required functionality remains incomplete, not a pass.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions