Introduce custom backend-specific primitives
This commit is contained in:
parent
8d65e40a11
commit
0ae1baa37b
28 changed files with 618 additions and 263 deletions
|
|
@ -2,7 +2,8 @@ use crate::core;
|
|||
use crate::core::{Color, Font, Point, Size};
|
||||
use crate::graphics::backend;
|
||||
use crate::graphics::color;
|
||||
use crate::graphics::{Primitive, Transformation, Viewport};
|
||||
use crate::graphics::{Transformation, Viewport};
|
||||
use crate::primitive::{self, Primitive};
|
||||
use crate::quad;
|
||||
use crate::text;
|
||||
use crate::triangle;
|
||||
|
|
@ -334,6 +335,10 @@ impl Backend {
|
|||
}
|
||||
}
|
||||
|
||||
impl crate::graphics::Backend for Backend {
|
||||
type Primitive = primitive::Custom;
|
||||
}
|
||||
|
||||
impl backend::Text for Backend {
|
||||
const ICON_FONT: Font = Font::with_name("Iced-Icons");
|
||||
const CHECKMARK_ICON: char = '\u{f00c}';
|
||||
|
|
|
|||
|
|
@ -5,10 +5,10 @@ use crate::graphics::geometry::fill::{self, Fill};
|
|||
use crate::graphics::geometry::{
|
||||
LineCap, LineDash, LineJoin, Path, Stroke, Style, Text,
|
||||
};
|
||||
use crate::graphics::primitive::{self, Primitive};
|
||||
use crate::graphics::Gradient;
|
||||
use crate::graphics::gradient::{self, Gradient};
|
||||
use crate::graphics::primitive;
|
||||
use crate::Primitive;
|
||||
|
||||
use iced_graphics::gradient;
|
||||
use lyon::geom::euclid;
|
||||
use lyon::tessellation;
|
||||
use std::borrow::Cow;
|
||||
|
|
|
|||
|
|
@ -12,8 +12,9 @@ use crate::core;
|
|||
use crate::core::alignment;
|
||||
use crate::core::{Color, Font, Point, Rectangle, Size, Vector};
|
||||
use crate::graphics::color;
|
||||
use crate::graphics::{Primitive, Viewport};
|
||||
use crate::graphics::Viewport;
|
||||
use crate::quad::{self, Quad};
|
||||
use crate::Primitive;
|
||||
|
||||
/// A group of primitives that should be clipped together.
|
||||
#[derive(Debug)]
|
||||
|
|
@ -262,13 +263,7 @@ impl<'a> Layer<'a> {
|
|||
current_layer,
|
||||
);
|
||||
}
|
||||
_ => {
|
||||
// Not supported!
|
||||
log::warn!(
|
||||
"Unsupported primitive in `iced_wgpu`: {:?}",
|
||||
primitive
|
||||
);
|
||||
}
|
||||
Primitive::Custom(()) => {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,8 +24,8 @@
|
|||
html_logo_url = "https://raw.githubusercontent.com/iced-rs/iced/9ab6923e943f784985e9ef9ca28b10278297225d/docs/logo.svg"
|
||||
)]
|
||||
#![deny(
|
||||
missing_debug_implementations,
|
||||
missing_docs,
|
||||
//missing_debug_implementations,
|
||||
//missing_docs,
|
||||
unsafe_code,
|
||||
unused_results,
|
||||
clippy::extra_unused_lifetimes,
|
||||
|
|
@ -47,6 +47,7 @@ pub mod geometry;
|
|||
mod backend;
|
||||
mod buffer;
|
||||
mod color;
|
||||
mod primitive;
|
||||
mod quad;
|
||||
mod text;
|
||||
mod triangle;
|
||||
|
|
@ -60,6 +61,7 @@ pub use wgpu;
|
|||
|
||||
pub use backend::Backend;
|
||||
pub use layer::Layer;
|
||||
pub use primitive::Primitive;
|
||||
pub use settings::Settings;
|
||||
|
||||
#[cfg(any(feature = "image", feature = "svg"))]
|
||||
|
|
|
|||
3
wgpu/src/primitive.rs
Normal file
3
wgpu/src/primitive.rs
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
pub type Primitive = crate::graphics::Primitive<Custom>;
|
||||
|
||||
pub type Custom = ();
|
||||
|
|
@ -3,8 +3,8 @@ use crate::core::{Color, Size};
|
|||
use crate::graphics;
|
||||
use crate::graphics::color;
|
||||
use crate::graphics::compositor;
|
||||
use crate::graphics::{Error, Primitive, Viewport};
|
||||
use crate::{Backend, Renderer, Settings};
|
||||
use crate::graphics::{Error, Viewport};
|
||||
use crate::{Backend, Primitive, Renderer, Settings};
|
||||
|
||||
use futures::stream::{self, StreamExt};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue