Make iced_tiny_skia optional with a tiny-skia feature
This commit is contained in:
parent
bbafeed13d
commit
1f13a91361
20 changed files with 157 additions and 91 deletions
|
|
@ -18,9 +18,11 @@ all-features = true
|
||||||
maintenance = { status = "actively-developed" }
|
maintenance = { status = "actively-developed" }
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = ["wgpu", "fira-sans", "auto-detect-theme"]
|
default = ["wgpu", "tiny-skia", "fira-sans", "auto-detect-theme"]
|
||||||
# Enable the `wgpu` GPU-accelerated renderer backend
|
# Enable the `wgpu` GPU-accelerated renderer backend
|
||||||
wgpu = ["iced_renderer/wgpu", "iced_widget/wgpu"]
|
wgpu = ["iced_renderer/wgpu", "iced_widget/wgpu"]
|
||||||
|
# Enable the `tiny-skia` software renderer backend
|
||||||
|
tiny-skia = ["iced_renderer/tiny-skia"]
|
||||||
# Enables the `Image` widget
|
# Enables the `Image` widget
|
||||||
image = ["iced_widget/image", "dep:image"]
|
image = ["iced_widget/image", "dep:image"]
|
||||||
# Enables the `Svg` widget
|
# Enables the `Svg` widget
|
||||||
|
|
|
||||||
|
|
@ -95,7 +95,7 @@ impl<'a, Message, Theme, Renderer> Element<'a, Message, Theme, Renderer> {
|
||||||
///
|
///
|
||||||
/// ```no_run
|
/// ```no_run
|
||||||
/// # mod iced {
|
/// # mod iced {
|
||||||
/// # pub type Element<'a, Message> = iced_core::Element<'a, Message, iced_core::Theme, iced_core::renderer::Null>;
|
/// # pub type Element<'a, Message> = iced_core::Element<'a, Message, iced_core::Theme, ()>;
|
||||||
/// #
|
/// #
|
||||||
/// # pub mod widget {
|
/// # pub mod widget {
|
||||||
/// # pub fn row<'a, Message>(iter: impl IntoIterator<Item = super::Element<'a, Message>>) -> super::Element<'a, Message> {
|
/// # pub fn row<'a, Message>(iter: impl IntoIterator<Item = super::Element<'a, Message>>) -> super::Element<'a, Message> {
|
||||||
|
|
@ -109,7 +109,7 @@ impl<'a, Message, Theme, Renderer> Element<'a, Message, Theme, Renderer> {
|
||||||
/// # pub enum Message {}
|
/// # pub enum Message {}
|
||||||
/// # pub struct Counter;
|
/// # pub struct Counter;
|
||||||
/// #
|
/// #
|
||||||
/// # pub type Element<'a, Message> = iced_core::Element<'a, Message, iced_core::Theme, iced_core::renderer::Null>;
|
/// # pub type Element<'a, Message> = iced_core::Element<'a, Message, iced_core::Theme, ()>;
|
||||||
/// #
|
/// #
|
||||||
/// # impl Counter {
|
/// # impl Counter {
|
||||||
/// # pub fn view(&self) -> Element<Message> {
|
/// # pub fn view(&self) -> Element<Message> {
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,6 @@
|
||||||
//! Write your own renderer.
|
//! Write your own renderer.
|
||||||
#[cfg(debug_assertions)]
|
|
||||||
mod null;
|
mod null;
|
||||||
|
|
||||||
#[cfg(debug_assertions)]
|
|
||||||
pub use null::Null;
|
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
Background, Border, Color, Rectangle, Shadow, Size, Transformation, Vector,
|
Background, Border, Color, Rectangle, Shadow, Size, Transformation, Vector,
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
use crate::alignment;
|
use crate::alignment;
|
||||||
|
use crate::image;
|
||||||
use crate::renderer::{self, Renderer};
|
use crate::renderer::{self, Renderer};
|
||||||
use crate::text::{self, Text};
|
use crate::text::{self, Text};
|
||||||
use crate::{
|
use crate::{
|
||||||
|
|
@ -7,20 +8,7 @@ use crate::{
|
||||||
|
|
||||||
use std::borrow::Cow;
|
use std::borrow::Cow;
|
||||||
|
|
||||||
/// A renderer that does nothing.
|
impl Renderer for () {
|
||||||
///
|
|
||||||
/// It can be useful if you are writing tests!
|
|
||||||
#[derive(Debug, Clone, Copy, Default)]
|
|
||||||
pub struct Null;
|
|
||||||
|
|
||||||
impl Null {
|
|
||||||
/// Creates a new [`Null`] renderer.
|
|
||||||
pub fn new() -> Null {
|
|
||||||
Null
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Renderer for Null {
|
|
||||||
fn start_layer(&mut self) {}
|
fn start_layer(&mut self) {}
|
||||||
|
|
||||||
fn end_layer(&mut self, _bounds: Rectangle) {}
|
fn end_layer(&mut self, _bounds: Rectangle) {}
|
||||||
|
|
@ -39,7 +27,7 @@ impl Renderer for Null {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl text::Renderer for Null {
|
impl text::Renderer for () {
|
||||||
type Font = Font;
|
type Font = Font;
|
||||||
type Paragraph = ();
|
type Paragraph = ();
|
||||||
type Editor = ();
|
type Editor = ();
|
||||||
|
|
@ -173,3 +161,19 @@ impl text::Editor for () {
|
||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl image::Renderer for () {
|
||||||
|
type Handle = ();
|
||||||
|
|
||||||
|
fn measure_image(&self, _handle: &Self::Handle) -> Size<u32> {
|
||||||
|
Size::default()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn draw_image(
|
||||||
|
&mut self,
|
||||||
|
_handle: Self::Handle,
|
||||||
|
_filter_method: image::FilterMethod,
|
||||||
|
_bounds: Rectangle,
|
||||||
|
) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
use crate::Vector;
|
use crate::Vector;
|
||||||
|
|
||||||
/// An amount of space in 2 dimensions.
|
/// An amount of space in 2 dimensions.
|
||||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
|
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default)]
|
||||||
pub struct Size<T = f32> {
|
pub struct Size<T = f32> {
|
||||||
/// The width.
|
/// The width.
|
||||||
pub width: T,
|
pub width: T,
|
||||||
|
|
|
||||||
|
|
@ -356,7 +356,9 @@ where
|
||||||
renderer.with_translation(
|
renderer.with_translation(
|
||||||
Vector::new(bounds.x, bounds.y),
|
Vector::new(bounds.x, bounds.y),
|
||||||
|renderer| {
|
|renderer| {
|
||||||
renderer.draw_geometry([geometry]);
|
use iced::advanced::graphics::geometry::Renderer as _;
|
||||||
|
|
||||||
|
renderer.draw_geometry(geometry);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,9 @@ use std::borrow::Cow;
|
||||||
///
|
///
|
||||||
/// [`Renderer`]: crate::Renderer
|
/// [`Renderer`]: crate::Renderer
|
||||||
pub trait Backend {
|
pub trait Backend {
|
||||||
|
/// The compositor of this [`Backend`].
|
||||||
|
type Compositor;
|
||||||
|
|
||||||
/// The custom kind of primitives this [`Backend`] supports.
|
/// The custom kind of primitives this [`Backend`] supports.
|
||||||
type Primitive: TryFrom<Mesh, Error = &'static str>;
|
type Primitive: TryFrom<Mesh, Error = &'static str>;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ pub trait Compositor: Sized {
|
||||||
type Settings: Default;
|
type Settings: Default;
|
||||||
|
|
||||||
/// The iced renderer of the backend.
|
/// The iced renderer of the backend.
|
||||||
type Renderer: iced_core::Renderer;
|
type Renderer;
|
||||||
|
|
||||||
/// The surface of the backend.
|
/// The surface of the backend.
|
||||||
type Surface;
|
type Surface;
|
||||||
|
|
@ -122,3 +122,63 @@ pub struct Information {
|
||||||
/// Contains the graphics backend.
|
/// Contains the graphics backend.
|
||||||
pub backend: String,
|
pub backend: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Compositor for () {
|
||||||
|
type Settings = ();
|
||||||
|
type Renderer = ();
|
||||||
|
type Surface = ();
|
||||||
|
|
||||||
|
async fn new<W: Window + Clone>(
|
||||||
|
_settings: Self::Settings,
|
||||||
|
_compatible_window: W,
|
||||||
|
) -> Result<Self, Error> {
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
fn create_renderer(&self) -> Self::Renderer {}
|
||||||
|
|
||||||
|
fn create_surface<W: Window + Clone>(
|
||||||
|
&mut self,
|
||||||
|
_window: W,
|
||||||
|
_width: u32,
|
||||||
|
_height: u32,
|
||||||
|
) -> Self::Surface {
|
||||||
|
}
|
||||||
|
|
||||||
|
fn configure_surface(
|
||||||
|
&mut self,
|
||||||
|
_surface: &mut Self::Surface,
|
||||||
|
_width: u32,
|
||||||
|
_height: u32,
|
||||||
|
) {
|
||||||
|
}
|
||||||
|
|
||||||
|
fn fetch_information(&self) -> Information {
|
||||||
|
Information {
|
||||||
|
adapter: String::from("Null Renderer"),
|
||||||
|
backend: String::from("Null"),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn present<T: AsRef<str>>(
|
||||||
|
&mut self,
|
||||||
|
_renderer: &mut Self::Renderer,
|
||||||
|
_surface: &mut Self::Surface,
|
||||||
|
_viewport: &Viewport,
|
||||||
|
_background_color: Color,
|
||||||
|
_overlay: &[T],
|
||||||
|
) -> Result<(), SurfaceError> {
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
fn screenshot<T: AsRef<str>>(
|
||||||
|
&mut self,
|
||||||
|
_renderer: &mut Self::Renderer,
|
||||||
|
_surface: &mut Self::Surface,
|
||||||
|
_viewport: &Viewport,
|
||||||
|
_background_color: Color,
|
||||||
|
_overlay: &[T],
|
||||||
|
) -> Vec<u8> {
|
||||||
|
vec![]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -18,11 +18,11 @@ pub use text::Text;
|
||||||
|
|
||||||
pub use crate::gradient::{self, Gradient};
|
pub use crate::gradient::{self, Gradient};
|
||||||
|
|
||||||
use crate::core::Size;
|
use crate::core::{self, Size};
|
||||||
use crate::Cached;
|
use crate::Cached;
|
||||||
|
|
||||||
/// A renderer capable of drawing some [`Self::Geometry`].
|
/// A renderer capable of drawing some [`Self::Geometry`].
|
||||||
pub trait Renderer: crate::core::Renderer {
|
pub trait Renderer: core::Renderer {
|
||||||
/// The kind of geometry this renderer can draw.
|
/// The kind of geometry this renderer can draw.
|
||||||
type Geometry: Cached;
|
type Geometry: Cached;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
//! Draw and generate geometry.
|
//! Draw and generate geometry.
|
||||||
use crate::core::{Point, Radians, Rectangle, Size, Vector};
|
use crate::core::{Point, Radians, Rectangle, Size, Vector};
|
||||||
use crate::geometry::{self, Fill, Path, Stroke, Text};
|
use crate::geometry::{self, Fill, Path, Stroke, Text};
|
||||||
use crate::Cached;
|
|
||||||
|
|
||||||
/// The region of a surface that can be used to draw geometry.
|
/// The region of a surface that can be used to draw geometry.
|
||||||
#[allow(missing_debug_implementations)]
|
#[allow(missing_debug_implementations)]
|
||||||
|
|
@ -173,7 +172,7 @@ where
|
||||||
/// of each method.
|
/// of each method.
|
||||||
#[allow(missing_docs)]
|
#[allow(missing_docs)]
|
||||||
pub trait Backend: Sized {
|
pub trait Backend: Sized {
|
||||||
type Geometry: Cached;
|
type Geometry;
|
||||||
|
|
||||||
fn width(&self) -> f32;
|
fn width(&self) -> f32;
|
||||||
fn height(&self) -> f32;
|
fn height(&self) -> f32;
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
//! Draw triangles!
|
//! Draw triangles!
|
||||||
use crate::color;
|
use crate::color;
|
||||||
use crate::core::{self, Rectangle, Size};
|
use crate::core::{Rectangle, Size};
|
||||||
use crate::gradient;
|
use crate::gradient;
|
||||||
use crate::Damage;
|
use crate::Damage;
|
||||||
|
|
||||||
|
|
@ -76,7 +76,7 @@ pub struct GradientVertex2D {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A renderer capable of drawing a [`Mesh`].
|
/// A renderer capable of drawing a [`Mesh`].
|
||||||
pub trait Renderer: core::Renderer {
|
pub trait Renderer {
|
||||||
/// Draws the given [`Mesh`].
|
/// Draws the given [`Mesh`].
|
||||||
fn draw_mesh(&mut self, mesh: Mesh);
|
fn draw_mesh(&mut self, mesh: Mesh);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -12,18 +12,20 @@ keywords.workspace = true
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
wgpu = ["iced_wgpu"]
|
wgpu = ["iced_wgpu"]
|
||||||
image = ["iced_tiny_skia/image", "iced_wgpu?/image"]
|
tiny-skia = ["iced_tiny_skia"]
|
||||||
svg = ["iced_tiny_skia/svg", "iced_wgpu?/svg"]
|
image = ["iced_tiny_skia?/image", "iced_wgpu?/image"]
|
||||||
geometry = ["iced_graphics/geometry", "iced_tiny_skia/geometry", "iced_wgpu?/geometry"]
|
svg = ["iced_tiny_skia?/svg", "iced_wgpu?/svg"]
|
||||||
|
geometry = ["iced_graphics/geometry", "iced_tiny_skia?/geometry", "iced_wgpu?/geometry"]
|
||||||
tracing = ["iced_wgpu?/tracing"]
|
tracing = ["iced_wgpu?/tracing"]
|
||||||
web-colors = ["iced_wgpu?/web-colors"]
|
web-colors = ["iced_wgpu?/web-colors"]
|
||||||
webgl = ["iced_wgpu?/webgl"]
|
webgl = ["iced_wgpu?/webgl"]
|
||||||
fira-sans = ["iced_graphics/fira-sans"]
|
fira-sans = ["iced_graphics/fira-sans"]
|
||||||
custom = []
|
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
iced_graphics.workspace = true
|
iced_graphics.workspace = true
|
||||||
|
|
||||||
iced_tiny_skia.workspace = true
|
iced_tiny_skia.workspace = true
|
||||||
|
iced_tiny_skia.optional = true
|
||||||
|
|
||||||
iced_wgpu.workspace = true
|
iced_wgpu.workspace = true
|
||||||
iced_wgpu.optional = true
|
iced_wgpu.optional = true
|
||||||
|
|
|
||||||
|
|
@ -8,11 +8,7 @@ use crate::graphics;
|
||||||
use crate::graphics::compositor;
|
use crate::graphics::compositor;
|
||||||
use crate::graphics::mesh;
|
use crate::graphics::mesh;
|
||||||
|
|
||||||
pub enum Renderer<L, R>
|
pub enum Renderer<L, R> {
|
||||||
where
|
|
||||||
L: core::Renderer,
|
|
||||||
R: core::Renderer,
|
|
||||||
{
|
|
||||||
Left(L),
|
Left(L),
|
||||||
Right(R),
|
Right(R),
|
||||||
}
|
}
|
||||||
|
|
@ -26,29 +22,6 @@ macro_rules! delegate {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<L, R> Renderer<L, R>
|
|
||||||
where
|
|
||||||
L: core::Renderer,
|
|
||||||
R: core::Renderer,
|
|
||||||
{
|
|
||||||
#[cfg(feature = "geometry")]
|
|
||||||
pub fn draw_geometry<Geometry>(
|
|
||||||
&mut self,
|
|
||||||
layers: impl IntoIterator<Item = Geometry>,
|
|
||||||
) where
|
|
||||||
L: graphics::geometry::Renderer,
|
|
||||||
R: graphics::geometry::Renderer,
|
|
||||||
|
|
||||||
Geometry: Into<geometry::Geometry<L::Geometry, R::Geometry>>,
|
|
||||||
{
|
|
||||||
use graphics::geometry::Renderer;
|
|
||||||
|
|
||||||
for layer in layers {
|
|
||||||
<Self as Renderer>::draw_geometry(self, layer.into());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<L, R> core::Renderer for Renderer<L, R>
|
impl<L, R> core::Renderer for Renderer<L, R>
|
||||||
where
|
where
|
||||||
L: core::Renderer,
|
L: core::Renderer,
|
||||||
|
|
|
||||||
|
|
@ -19,27 +19,40 @@ pub use settings::Settings;
|
||||||
/// The default graphics renderer for [`iced`].
|
/// The default graphics renderer for [`iced`].
|
||||||
///
|
///
|
||||||
/// [`iced`]: https://github.com/iced-rs/iced
|
/// [`iced`]: https://github.com/iced-rs/iced
|
||||||
#[cfg(not(feature = "wgpu"))]
|
pub type Renderer = renderer::Renderer;
|
||||||
pub type Renderer = iced_tiny_skia::Renderer;
|
|
||||||
|
|
||||||
/// The default graphics renderer for [`iced`].
|
|
||||||
///
|
|
||||||
/// [`iced`]: https://github.com/iced-rs/iced
|
|
||||||
#[cfg(feature = "wgpu")]
|
|
||||||
pub type Renderer =
|
|
||||||
fallback::Renderer<iced_wgpu::Renderer, iced_tiny_skia::Renderer>;
|
|
||||||
|
|
||||||
/// The default graphics compositor for [`iced`].
|
/// The default graphics compositor for [`iced`].
|
||||||
///
|
///
|
||||||
/// [`iced`]: https://github.com/iced-rs/iced
|
/// [`iced`]: https://github.com/iced-rs/iced
|
||||||
#[cfg(not(feature = "wgpu"))]
|
pub type Compositor = renderer::Compositor;
|
||||||
pub type Compositor = iced_tiny_skia::window::Compositor;
|
|
||||||
|
|
||||||
/// The default graphics renderer for [`iced`].
|
#[cfg(all(feature = "wgpu", feature = "tiny-skia"))]
|
||||||
///
|
mod renderer {
|
||||||
/// [`iced`]: https://github.com/iced-rs/iced
|
pub type Renderer = crate::fallback::Renderer<
|
||||||
#[cfg(feature = "wgpu")]
|
iced_wgpu::Renderer,
|
||||||
pub type Compositor = fallback::Compositor<
|
iced_tiny_skia::Renderer,
|
||||||
|
>;
|
||||||
|
|
||||||
|
pub type Compositor = crate::fallback::Compositor<
|
||||||
iced_wgpu::window::Compositor,
|
iced_wgpu::window::Compositor,
|
||||||
iced_tiny_skia::window::Compositor,
|
iced_tiny_skia::window::Compositor,
|
||||||
>;
|
>;
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(all(feature = "wgpu", not(feature = "tiny-skia")))]
|
||||||
|
mod renderer {
|
||||||
|
pub type Renderer = iced_wgpu::Renderer;
|
||||||
|
pub type Compositor = iced_wgpu::window::Compositor;
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(all(not(feature = "wgpu"), feature = "tiny-skia"))]
|
||||||
|
mod renderer {
|
||||||
|
pub type Renderer = iced_tiny_skia::Renderer;
|
||||||
|
pub type Compositor = iced_tiny_skia::window::Compositor;
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(not(any(feature = "wgpu", feature = "tiny-skia")))]
|
||||||
|
mod renderer {
|
||||||
|
pub type Renderer = ();
|
||||||
|
pub type Compositor = ();
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,7 @@ impl Default for Settings {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "tiny-skia")]
|
||||||
impl From<Settings> for iced_tiny_skia::Settings {
|
impl From<Settings> for iced_tiny_skia::Settings {
|
||||||
fn from(settings: Settings) -> Self {
|
fn from(settings: Settings) -> Self {
|
||||||
Self {
|
Self {
|
||||||
|
|
@ -48,3 +49,7 @@ impl From<Settings> for iced_wgpu::Settings {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl From<Settings> for () {
|
||||||
|
fn from(_settings: Settings) -> Self {}
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -45,7 +45,7 @@ where
|
||||||
///
|
///
|
||||||
/// ```no_run
|
/// ```no_run
|
||||||
/// # mod iced_wgpu {
|
/// # mod iced_wgpu {
|
||||||
/// # pub use iced_runtime::core::renderer::Null as Renderer;
|
/// # pub type Renderer = ();
|
||||||
/// # }
|
/// # }
|
||||||
/// #
|
/// #
|
||||||
/// # pub struct Counter;
|
/// # pub struct Counter;
|
||||||
|
|
@ -62,7 +62,7 @@ where
|
||||||
/// // Initialization
|
/// // Initialization
|
||||||
/// let mut counter = Counter::new();
|
/// let mut counter = Counter::new();
|
||||||
/// let mut cache = user_interface::Cache::new();
|
/// let mut cache = user_interface::Cache::new();
|
||||||
/// let mut renderer = Renderer::new();
|
/// let mut renderer = Renderer::default();
|
||||||
/// let mut window_size = Size::new(1024.0, 768.0);
|
/// let mut window_size = Size::new(1024.0, 768.0);
|
||||||
///
|
///
|
||||||
/// // Application loop
|
/// // Application loop
|
||||||
|
|
@ -121,7 +121,7 @@ where
|
||||||
///
|
///
|
||||||
/// ```no_run
|
/// ```no_run
|
||||||
/// # mod iced_wgpu {
|
/// # mod iced_wgpu {
|
||||||
/// # pub use iced_runtime::core::renderer::Null as Renderer;
|
/// # pub type Renderer = ();
|
||||||
/// # }
|
/// # }
|
||||||
/// #
|
/// #
|
||||||
/// # pub struct Counter;
|
/// # pub struct Counter;
|
||||||
|
|
@ -139,7 +139,7 @@ where
|
||||||
///
|
///
|
||||||
/// let mut counter = Counter::new();
|
/// let mut counter = Counter::new();
|
||||||
/// let mut cache = user_interface::Cache::new();
|
/// let mut cache = user_interface::Cache::new();
|
||||||
/// let mut renderer = Renderer::new();
|
/// let mut renderer = Renderer::default();
|
||||||
/// let mut window_size = Size::new(1024.0, 768.0);
|
/// let mut window_size = Size::new(1024.0, 768.0);
|
||||||
/// let mut cursor = mouse::Cursor::default();
|
/// let mut cursor = mouse::Cursor::default();
|
||||||
/// let mut clipboard = clipboard::Null;
|
/// let mut clipboard = clipboard::Null;
|
||||||
|
|
@ -374,7 +374,7 @@ where
|
||||||
///
|
///
|
||||||
/// ```no_run
|
/// ```no_run
|
||||||
/// # mod iced_wgpu {
|
/// # mod iced_wgpu {
|
||||||
/// # pub use iced_runtime::core::renderer::Null as Renderer;
|
/// # pub type Renderer = ();
|
||||||
/// # pub type Theme = ();
|
/// # pub type Theme = ();
|
||||||
/// # }
|
/// # }
|
||||||
/// #
|
/// #
|
||||||
|
|
@ -394,7 +394,7 @@ where
|
||||||
///
|
///
|
||||||
/// let mut counter = Counter::new();
|
/// let mut counter = Counter::new();
|
||||||
/// let mut cache = user_interface::Cache::new();
|
/// let mut cache = user_interface::Cache::new();
|
||||||
/// let mut renderer = Renderer::new();
|
/// let mut renderer = Renderer::default();
|
||||||
/// let mut window_size = Size::new(1024.0, 768.0);
|
/// let mut window_size = Size::new(1024.0, 768.0);
|
||||||
/// let mut cursor = mouse::Cursor::default();
|
/// let mut cursor = mouse::Cursor::default();
|
||||||
/// let mut clipboard = clipboard::Null;
|
/// let mut clipboard = clipboard::Null;
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ use crate::graphics::backend;
|
||||||
use crate::graphics::text;
|
use crate::graphics::text;
|
||||||
use crate::graphics::{Damage, Viewport};
|
use crate::graphics::{Damage, Viewport};
|
||||||
use crate::primitive::{self, Primitive};
|
use crate::primitive::{self, Primitive};
|
||||||
|
use crate::window;
|
||||||
|
|
||||||
use std::borrow::Cow;
|
use std::borrow::Cow;
|
||||||
|
|
||||||
|
|
@ -990,6 +991,8 @@ fn rounded_box_sdf(
|
||||||
}
|
}
|
||||||
|
|
||||||
impl iced_graphics::Backend for Backend {
|
impl iced_graphics::Backend for Backend {
|
||||||
|
type Compositor = window::Compositor;
|
||||||
|
|
||||||
type Primitive = primitive::Custom;
|
type Primitive = primitive::Custom;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@ use crate::primitive::{self, Primitive};
|
||||||
use crate::quad;
|
use crate::quad;
|
||||||
use crate::text;
|
use crate::text;
|
||||||
use crate::triangle;
|
use crate::triangle;
|
||||||
|
use crate::window;
|
||||||
use crate::{Layer, Settings};
|
use crate::{Layer, Settings};
|
||||||
|
|
||||||
#[cfg(feature = "tracing")]
|
#[cfg(feature = "tracing")]
|
||||||
|
|
@ -372,6 +373,7 @@ impl Backend {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl crate::graphics::Backend for Backend {
|
impl crate::graphics::Backend for Backend {
|
||||||
|
type Compositor = window::Compositor;
|
||||||
type Primitive = primitive::Custom;
|
type Primitive = primitive::Custom;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
//! Draw primitives using custom pipelines.
|
//! Draw primitives using custom pipelines.
|
||||||
use crate::core::{Rectangle, Size};
|
use crate::core::{self, Rectangle, Size};
|
||||||
|
|
||||||
use std::any::{Any, TypeId};
|
use std::any::{Any, TypeId};
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
|
@ -58,7 +58,7 @@ pub trait Primitive: Debug + Send + Sync + 'static {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A renderer than can draw custom pipeline primitives.
|
/// A renderer than can draw custom pipeline primitives.
|
||||||
pub trait Renderer: crate::core::Renderer {
|
pub trait Renderer: core::Renderer {
|
||||||
/// Draws a custom pipeline primitive.
|
/// Draws a custom pipeline primitive.
|
||||||
fn draw_pipeline_primitive(
|
fn draw_pipeline_primitive(
|
||||||
&mut self,
|
&mut self,
|
||||||
|
|
|
||||||
|
|
@ -141,7 +141,9 @@ impl<'a, Message, Theme> Widget<Message, Theme, Renderer>
|
||||||
renderer.with_translation(
|
renderer.with_translation(
|
||||||
bounds.position() - Point::ORIGIN,
|
bounds.position() - Point::ORIGIN,
|
||||||
|renderer| {
|
|renderer| {
|
||||||
renderer.draw_geometry(vec![geometry]);
|
use crate::graphics::geometry::Renderer as _;
|
||||||
|
|
||||||
|
renderer.draw_geometry(geometry);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue