Introduce custom backend-specific primitives

This commit is contained in:
Héctor Ramón Jiménez 2023-06-22 00:38:36 +02:00
parent 8d65e40a11
commit 0ae1baa37b
No known key found for this signature in database
GPG key ID: 140CC052C94F138E
28 changed files with 618 additions and 263 deletions

View file

@ -2,7 +2,8 @@ use crate::core::text;
use crate::core::Gradient;
use crate::core::{Background, Color, Font, Point, Rectangle, Size, Vector};
use crate::graphics::backend;
use crate::graphics::{Primitive, Viewport};
use crate::graphics::{Damage, Viewport};
use crate::primitive::{self, Primitive};
use crate::Settings;
use std::borrow::Cow;
@ -419,6 +420,13 @@ impl Backend {
self.raster_pipeline
.draw(handle, *bounds, pixels, transform, clip_mask);
}
#[cfg(not(feature = "image"))]
Primitive::Image { .. } => {
log::warn!(
"Unsupported primitive in `iced_tiny_skia`: {:?}",
primitive
);
}
#[cfg(feature = "svg")]
Primitive::Svg {
handle,
@ -442,12 +450,19 @@ impl Backend {
clip_mask,
);
}
Primitive::Fill {
#[cfg(not(feature = "svg"))]
Primitive::Svg { .. } => {
log::warn!(
"Unsupported primitive in `iced_tiny_skia`: {:?}",
primitive
);
}
Primitive::Custom(primitive::Custom::Fill {
path,
paint,
rule,
transform,
} => {
}) => {
let bounds = path.bounds();
let physical_bounds = (Rectangle {
@ -475,12 +490,12 @@ impl Backend {
clip_mask,
);
}
Primitive::Stroke {
Primitive::Custom(primitive::Custom::Stroke {
path,
paint,
stroke,
transform,
} => {
}) => {
let bounds = path.bounds();
let physical_bounds = (Rectangle {
@ -588,13 +603,6 @@ impl Backend {
primitive
);
}
_ => {
// Not supported!
log::warn!(
"Unsupported primitive in `iced_tiny_skia`: {:?}",
primitive
);
}
}
}
}
@ -766,6 +774,10 @@ fn adjust_clip_mask(clip_mask: &mut tiny_skia::Mask, bounds: Rectangle) {
);
}
impl iced_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}';