Draft support for dynamic custom renderer injection

This commit is contained in:
Héctor Ramón Jiménez 2024-03-21 05:52:48 +01:00
parent 2b00e8b145
commit 188db4da48
No known key found for this signature in database
GPG key ID: 7CC46565708259A7
12 changed files with 316 additions and 35 deletions

View file

@ -1,4 +1,5 @@
use crate::core::Size;
use crate::custom;
use crate::geometry::{Frame, Geometry};
use crate::Renderer;
@ -29,6 +30,7 @@ enum Internal {
TinySkia(Arc<iced_tiny_skia::Primitive>),
#[cfg(feature = "wgpu")]
Wgpu(Arc<iced_wgpu::Primitive>),
Custom(Arc<dyn custom::Geometry>),
}
impl Cache {
@ -82,6 +84,9 @@ impl Cache {
content: primitive.clone(),
});
}
Internal::Custom(geometry) => {
return Geometry::Custom(geometry.clone().load())
}
}
}
}
@ -100,6 +105,9 @@ impl Cache {
Geometry::Wgpu(primitive) => {
Internal::Wgpu(Arc::new(primitive))
}
Geometry::Custom(geometry) => {
Internal::Custom(geometry.cache())
}
}
};
@ -120,6 +128,7 @@ impl Cache {
content: primitive,
})
}
Internal::Custom(geometry) => Geometry::Custom(geometry.load()),
}
}
}