WGPU: Add support for using WGPU textures in Slint

This adds a `unstable-wgpu-24` feature that exposes WGPU types in the
GraphicsAPI enum, adds `require_wgpu_24()` to the backend selector,
and adds a conversion from `wgpu::Texture` to `slint::Image`.

The `require_wgpu_24()` function in the selector will be extended in the
future (before the next release) to permit specifying additional aspects
of the WGPU configuration.

Co-Authored-By: Olivier Goffart <olivier.goffart@slint.dev>
This commit is contained in:
Simon Hausmann 2025-04-25 14:00:52 +02:00 committed by Simon Hausmann
parent 8261e405d3
commit da5e7d5b22
28 changed files with 711 additions and 27 deletions

View file

@ -1,6 +1,13 @@
// Copyright © SixtyFPS GmbH <info@slint.dev>
// SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-Royalty-free-2.0 OR LicenseRef-Slint-Software-3.0
#![warn(missing_docs)]
/*!
This module contains types that are public and re-exported in the slint-rs as well as the slint-interpreter crate as public API,
in particular the `BackendSelector` type.
*/
use alloc::boxed::Box;
use alloc::{format, string::String};
@ -89,6 +96,18 @@ impl BackendSelector {
self
}
/// Adds the requirement to the selector that the backend must render using [WGPU](http://wgpu.rs).
/// Use this when you integrate other WGPU-based renderers with a Slint UI.
///
/// *Note*: This function is behind a feature flag and may be removed or changed in future minor releases,
/// as new major WGPU releases become available.
#[cfg(feature = "unstable-wgpu-24")]
#[must_use]
pub fn require_wgpu_24(mut self) -> Self {
self.requested_graphics_api = Some(RequestedGraphicsAPI::WGPU24);
self
}
/// Adds the requirement that the selected renderer must match the given name. This is
/// equivalent to setting the `SLINT_BACKEND=name` environment variable and requires
/// that the corresponding renderer feature is enabled. For example, to select the Skia renderer,