attachWaylandSurface method

RenderSessionHandle attachWaylandSurface(
  1. WaylandSurfaceDescriptor descriptor,
  2. RenderSessionAttachOptions options, {
  3. VulkanDeviceHandle? device,
})

Creates a session that presents the map to a Wayland surface, with a graphics context that the library creates.

A Vulkan build presents with device, or, when device is null, with a device that the library creates. An OpenGL build uses an EGL context on the display, and device must be null. Attach with RenderDriverKind.coreWorker.

The session presents without waiting for the compositor, so demand at most one frame per display refresh.

Keep the surface until a release or replacement of the target, or a detach of the session, completes. Keep the display connected until the session's detach completes. In an OpenGL build, if you also use EGL on the display, initialize it before you attach.

See mln_map_attach_wayland_surface in the C API reference.

Errors:

  • Status.unsupported when you created device without VulkanDeviceOptions.presentation.
  • Status.unsupported when the GPU or the Vulkan loader can't present to Wayland.
  • Status.nativeError when the library can't create the graphics context or present to the surface.

Implementation

RenderSessionHandle attachWaylandSurface(
  WaylandSurfaceDescriptor descriptor,
  RenderSessionAttachOptions options, {
  VulkanDeviceHandle? device,
}) {
  final registrations = _NativeRegistrations(_CallbackRoots());
  return _attach(
    (arena, completion, outSession) => registrations.run(
      () => raw.mln_map_attach_wayland_surface(
        _handle.raw,
        _writeWaylandSurfaceDescriptor(descriptor, arena),
        (device?._handle.raw ?? 0),
        _writeRenderSessionAttachOptions(options, arena, registrations),
        outSession,
        completion,
        nativeDiagnostic,
      ),
    ),
    (handle, ready) => _adoptOwned(
      handle,
      () =>
          (RenderSessionHandle._(this, _NativeRenderSession(handle), ready)
            .._state.retain(registrations)),
      (handle) {
        _check(raw.mln_render_session_dispose(handle, nativeDiagnostic));
      },
    ),
  );
}