diff options
author | 2024-04-14 13:43:10 +0200 | |
---|---|---|
committer | 2024-04-14 13:43:10 +0200 | |
commit | 105b8bd5ad6ade1f203a0d8b0b93bd06f61f621a (patch) | |
tree | 4a5efa021b0dbe7d87ff57993c118753a32ea241 /tiny_skia/src/primitive.rs | |
parent | ee105e3bee1bc676dcf3324693984ccda8e4e733 (diff) | |
parent | dbbbadfc950dfdfd02c7abbbf993e0685ca0f64a (diff) | |
download | iced-105b8bd5ad6ade1f203a0d8b0b93bd06f61f621a.tar.gz iced-105b8bd5ad6ade1f203a0d8b0b93bd06f61f621a.tar.bz2 iced-105b8bd5ad6ade1f203a0d8b0b93bd06f61f621a.zip |
Merge pull request #2382 from iced-rs/wgpu/better-architecture
Improved architecture for `iced_wgpu` and `iced_tiny_skia`
Diffstat (limited to 'tiny_skia/src/primitive.rs')
-rw-r--r-- | tiny_skia/src/primitive.rs | 38 |
1 files changed, 13 insertions, 25 deletions
diff --git a/tiny_skia/src/primitive.rs b/tiny_skia/src/primitive.rs index b7c428e4..5de51047 100644 --- a/tiny_skia/src/primitive.rs +++ b/tiny_skia/src/primitive.rs @@ -1,10 +1,7 @@ use crate::core::Rectangle; -use crate::graphics::{Damage, Mesh}; - -pub type Primitive = crate::graphics::Primitive<Custom>; #[derive(Debug, Clone, PartialEq)] -pub enum Custom { +pub enum Primitive { /// A path filled with some paint. Fill { /// The path to fill. @@ -25,28 +22,19 @@ pub enum Custom { }, } -impl Damage for Custom { - fn bounds(&self) -> Rectangle { - match self { - Self::Fill { path, .. } | Self::Stroke { path, .. } => { - let bounds = path.bounds(); +impl Primitive { + /// Returns the visible bounds of the [`Primitive`]. + pub fn visible_bounds(&self) -> Rectangle { + let bounds = match self { + Primitive::Fill { path, .. } => path.bounds(), + Primitive::Stroke { path, .. } => path.bounds(), + }; - Rectangle { - x: bounds.x(), - y: bounds.y(), - width: bounds.width(), - height: bounds.height(), - } - .expand(1.0) - } + Rectangle { + x: bounds.x(), + y: bounds.y(), + width: bounds.width(), + height: bounds.height(), } } } - -impl TryFrom<Mesh> for Custom { - type Error = &'static str; - - fn try_from(_mesh: Mesh) -> Result<Self, Self::Error> { - Err("unsupported") - } -} |