remove modules and have single event manager (atomics feature parity + preparation for local state)

This commit is contained in:
iris committed 2025-12-12 01:46:24 -05:00
1 parent a708813ce7
commit 37b1987aa8
17 files changed
+390 -432

No files matched your search

+16 -10
View File
@@ -2,6 +2,8 @@ use std::ops::{Index, IndexMut};
use crate::render::{MaskIdx, Primitive, PrimitiveHandle, PrimitiveInst, Primitives};
pub type LayerId = usize;
struct LayerNode<T> {
next: Ptr,
prev: Ptr,
@@ -49,13 +51,13 @@ impl<T: Default> Layers<T> {
self.vec.push(LayerNode::head());
}
fn push(&mut self, node: LayerNode<T>) -> usize {
fn push(&mut self, node: LayerNode<T>) -> LayerId {
let i = self.vec.len();
self.vec.push(node);
i
}
pub fn next(&mut self, i: usize) -> usize {
pub fn next(&mut self, i: LayerId) -> LayerId {
if let Ptr::Next(i) = self.vec[i].next {
return i;
}
@@ -75,7 +77,7 @@ impl<T: Default> Layers<T> {
i_new
}
pub fn child(&mut self, i: usize) -> usize {
pub fn child(&mut self, i: LayerId) -> LayerId {
if let Some(c) = self.vec[i].child {
return c.head;
}
@@ -100,11 +102,11 @@ impl<T: Default> Layers<T> {
self.vec.iter_mut().map(|n| &mut n.data).enumerate()
}
pub fn iter(&self) -> impl Iterator<Item = (usize, &T)> {
pub fn iter(&self) -> impl Iterator<Item = (LayerId, &T)> {
self.indices().map(|i| (i, &self.vec[i].data))
}
pub fn iter_depth(&self) -> impl Iterator<Item = ((usize, usize), &T)> {
pub fn iter_depth(&self) -> impl Iterator<Item = ((LayerId, usize), &T)> {
self.indices()
.map(|i| ((i, self.vec[i].depth), &self.vec[i].data))
}
@@ -115,7 +117,11 @@ impl<T: Default> Layers<T> {
}
impl PrimitiveLayers {
pub fn write<P: Primitive>(&mut self, layer: usize, info: PrimitiveInst<P>) -> PrimitiveHandle {
pub fn write<P: Primitive>(
&mut self,
layer: LayerId,
info: PrimitiveInst<P>,
) -> PrimitiveHandle {
self[layer].write(layer, info)
}
@@ -130,16 +136,16 @@ impl<T: Default> Default for Layers<T> {
}
}
impl<T> Index<usize> for Layers<T> {
impl<T> Index<LayerId> for Layers<T> {
type Output = T;
fn index(&self, index: usize) -> &Self::Output {
fn index(&self, index: LayerId) -> &Self::Output {
&self.vec[index].data
}
}
impl<T> IndexMut<usize> for Layers<T> {
fn index_mut(&mut self, index: usize) -> &mut Self::Output {
impl<T> IndexMut<LayerId> for Layers<T> {
fn index_mut(&mut self, index: LayerId) -> &mut Self::Output {
&mut self.vec[index].data
}
}