Redesign iced_wgpu layering architecture

This commit is contained in:
Héctor Ramón Jiménez 2024-04-03 21:07:54 +02:00
parent 99a904112c
commit b05e61f5c8
No known key found for this signature in database
GPG key ID: 7CC46565708259A7
36 changed files with 2781 additions and 2048 deletions

View file

@ -16,7 +16,6 @@ tiny-skia = ["iced_tiny_skia"]
image = ["iced_tiny_skia?/image", "iced_wgpu?/image"]
svg = ["iced_tiny_skia?/svg", "iced_wgpu?/svg"]
geometry = ["iced_graphics/geometry", "iced_tiny_skia?/geometry", "iced_wgpu?/geometry"]
tracing = ["iced_wgpu?/tracing"]
web-colors = ["iced_wgpu?/web-colors"]
webgl = ["iced_wgpu?/webgl"]
fira-sans = ["iced_graphics/fira-sans"]

View file

@ -39,16 +39,20 @@ where
delegate!(self, renderer, renderer.clear());
}
fn start_layer(&mut self) {
delegate!(self, renderer, renderer.start_layer());
fn start_layer(&mut self, bounds: Rectangle) {
delegate!(self, renderer, renderer.start_layer(bounds));
}
fn end_layer(&mut self, bounds: Rectangle) {
delegate!(self, renderer, renderer.end_layer(bounds));
}
fn start_transformation(&mut self) {
delegate!(self, renderer, renderer.start_transformation());
fn start_transformation(&mut self, transformation: Transformation) {
delegate!(
self,
renderer,
renderer.start_transformation(transformation)
);
}
fn end_transformation(&mut self, transformation: Transformation) {
@ -433,6 +437,7 @@ mod geometry {
}
}
#[derive(Clone)]
pub enum Geometry<L, R> {
Left(L),
Right(R),
@ -452,10 +457,21 @@ mod geometry {
}
}
fn cache(self) -> Self::Cache {
match self {
Self::Left(geometry) => Geometry::Left(geometry.cache()),
Self::Right(geometry) => Geometry::Right(geometry.cache()),
fn cache(self, previous: Option<Self::Cache>) -> Self::Cache {
match (self, previous) {
(Self::Left(geometry), Some(Geometry::Left(previous))) => {
Geometry::Left(geometry.cache(Some(previous)))
}
(Self::Left(geometry), None) => {
Geometry::Left(geometry.cache(None))
}
(Self::Right(geometry), Some(Geometry::Right(previous))) => {
Geometry::Right(geometry.cache(Some(previous)))
}
(Self::Right(geometry), None) => {
Geometry::Right(geometry.cache(None))
}
_ => unreachable!(),
}
}
}