🎉 Tile rendering system

This commit is contained in:
Aitor Moreno 2025-02-17 12:54:51 +01:00 committed by Alejandro Alonso
parent b727f2fe1f
commit 084816fb9f
17 changed files with 956 additions and 408 deletions

View file

@ -50,10 +50,6 @@ impl<'a> State<'a> {
Ok(())
}
pub fn render_from_cache(&mut self) {
let _ = self.render_state.render_from_cache();
}
pub fn use_shape(&'a mut self, id: Uuid) {
if !self.shapes.contains_key(&id) {
let new_shape = Shape::new(id);
@ -70,4 +66,22 @@ impl<'a> State<'a> {
pub fn set_background_color(&mut self, color: skia::Color) {
self.render_state.set_background_color(color);
}
pub fn set_selrect_for_current_shape(&mut self, left: f32, top: f32, right: f32, bottom: f32) {
match self.current_shape.as_mut() {
Some(shape) => {
shape.set_selrect(left, top, right, bottom);
// We don't need to update the tile for the root shape.
if !shape.id.is_nil() {
self.render_state.update_tile_for(&shape);
}
}
None => panic!("Invalid current shape"),
}
}
pub fn rebuild_tiles(&mut self) {
self.render_state
.rebuild_tiles(&mut self.shapes, &self.modifiers);
}
}