minigpu_view library
Zero-copy Flutter rendering for minigpu / miniav GPU resources.
Provides a MiniavGpuPreview widget that displays a PreviewSource without any CPU readback on every frame.
TWO WAYS IN, and the difference is who owns the destination texture.
You already have a texture — present it directly. No copies:
final controller = MinigpuPreviewController();
final shared = gpu.createSharedOutputTexture(W, H);
// ... write to `shared` via minigpu pipeline ...
await controller.present(shared.asPreviewSource());
MiniavGpuPreview(controller: controller) // in your widget tree
You have frames in whatever shape a producer gave you — use a GpuPane, which owns the destination and takes any of them:
final pane = GpuPane(gpu);
await pane.showSharedHandle(handle, width: w, height: h); // capture/decode
await pane.showBuffer(buffer, width: w, height: h); // compute output
await pane.showBytes(rgba, width: w, height: h); // host memory
MiniavGpuPreview(controller: pane.controller)
A pane costs one GPU-to-GPU blit per displayed frame and buys two things: it accepts every source shape without the caller writing a display path per producer, and — because the caller drives GpuPane.flush — it makes the pane's update rate something you control rather than something the producer decides. Host-memory frames are uploaded and composited on the GPU, never decoded into an image on the UI isolate.
Classes
- BufferGpuFrame
-
A frame already resident in a minigpu
Bufferas packed RGBA8 — one u32 per pixel, row major. The cheapest case: no import, no upload, a GPU-to-GPU blit. - CpuBytesGpuFrame
- Packed RGBA8 bytes in host memory — a CPU capture fallback, a software decoder, a generator.
- GpuFrame
- Something that can become the contents of a pane.
- GpuPane
- One displayable pane: a destination texture, the controller that shows it, and a pooled upload buffer for host-memory frames.
- GpuPaneTarget
- The destination a frame copies itself into, plus scratch it may borrow.
- MiniavGpuPreview
- Renders the current GPU frame from a MinigpuPreviewController.
- MinigpuPreviewController
- Listenable controller backing a MiniavGpuPreview widget.
- PlanarCpuGpuFrame
- Planar or subsampled bytes in host memory — NV12, I420, YUY2, BGRA.
- PlanarPlane
- One plane of a host-memory frame.
- PreviewSource
-
A presentable frame source. Lifetime is owned by the producer; the
preview controller borrows the underlying GPU resource until the
next
PreviewController.presentcall or until disposal. - RawGpuBufferPreviewSource
- Web/storage-buffer flavour of RawSharedTexturePreviewSource: a WGPUBuffer integer handle of packed RGBA8.
-
A present source built from RAW HANDLES, for producers that publish their
surface as integers rather than as a
SharedOutputTexture. - A frame behind a platform shared handle: a D3D11 shared NT handle on Windows, as produced by screen/camera capture and by GPU video decoders.
Enums
- PlanarColorRange
- Whether luma/chroma use the studio-swing subset or the full 0..255 range.
- PlanarFormat
- Host-memory layouts this can unpack.
- PreviewSourceKind
- Discriminator for PreviewSource subtypes — used by the platform plugin to dispatch to the correct host-side handler.
Extensions
- MiniavBufferPreviewSourceAdapter on MiniAVBuffer
-
Adapts a GPU-backed
MiniAVBufferinto a PreviewSource. - MiniavGpuFrameAdapter on MiniAVBuffer
- MinigpuPreviewSourceAdapter on SharedOutputTexture
-
Adapts a minigpu
SharedOutputTextureinto a PreviewSource. - PlanarFormatCode on PlanarFormat
Constants
- kPlanarCfgWords → const int
-
Number of
cfgwords the kernel reads. - kPlanarToRgbaWgsl → const String
- The conversion kernel.
Exceptions / Errors
- PreviewPresentException
- Thrown when the platform plugin reports an error wiring the GPU resource into Flutter's texture registry (e.g. handle is invalid, device was lost, format mismatch).
- UnsupportedPreviewException
- Thrown when the current platform cannot present a given source.