diff options
author | 2023-03-22 00:36:57 +0100 | |
---|---|---|
committer | 2023-04-04 02:08:02 +0200 | |
commit | 0f7abffc0e94b4bb9f8117db633bfd07d900eb93 (patch) | |
tree | 89b6606db2619574369bf8c4a29d5ef0ecb7969c /tiny_skia/src/primitive.rs | |
parent | 6fae8bf6cbe7155bcee42eaeba68e31564df057c (diff) | |
download | iced-0f7abffc0e94b4bb9f8117db633bfd07d900eb93.tar.gz iced-0f7abffc0e94b4bb9f8117db633bfd07d900eb93.tar.bz2 iced-0f7abffc0e94b4bb9f8117db633bfd07d900eb93.zip |
Draft (very) basic incremental rendering for `iced_tiny_skia`
Diffstat (limited to 'tiny_skia/src/primitive.rs')
-rw-r--r-- | tiny_skia/src/primitive.rs | 82 |
1 files changed, 0 insertions, 82 deletions
diff --git a/tiny_skia/src/primitive.rs b/tiny_skia/src/primitive.rs deleted file mode 100644 index 22daaedc..00000000 --- a/tiny_skia/src/primitive.rs +++ /dev/null @@ -1,82 +0,0 @@ -use crate::{Rectangle, Vector}; - -use std::sync::Arc; - -#[derive(Debug, Clone)] -pub enum Primitive { - /// A group of primitives - Group { - /// The primitives of the group - primitives: Vec<Primitive>, - }, - /// A clip primitive - Clip { - /// The bounds of the clip - bounds: Rectangle, - /// The content of the clip - content: Box<Primitive>, - }, - /// A primitive that applies a translation - Translate { - /// The translation vector - translation: Vector, - - /// The primitive to translate - content: Box<Primitive>, - }, - /// A cached primitive. - /// - /// This can be useful if you are implementing a widget where primitive - /// generation is expensive. - Cached { - /// The cached primitive - cache: Arc<Primitive>, - }, - /// A basic primitive. - Basic(iced_graphics::Primitive), -} - -impl iced_graphics::backend::Primitive for Primitive { - fn translate(self, translation: Vector) -> Self { - Self::Translate { - translation, - content: Box::new(self), - } - } - - fn clip(self, bounds: Rectangle) -> Self { - Self::Clip { - bounds, - content: Box::new(self), - } - } -} - -#[derive(Debug, Clone, Default)] -pub struct Recording(pub(crate) Vec<Primitive>); - -impl iced_graphics::backend::Recording for Recording { - type Primitive = Primitive; - - fn push(&mut self, primitive: Primitive) { - self.0.push(primitive); - } - - fn push_basic(&mut self, basic: iced_graphics::Primitive) { - self.0.push(Primitive::Basic(basic)); - } - - fn group(self) -> Self::Primitive { - Primitive::Group { primitives: self.0 } - } - - fn clear(&mut self) { - self.0.clear(); - } -} - -impl Recording { - pub fn primitives(&self) -> &[Primitive] { - &self.0 - } -} |