2022-10-28 04:58:47 +00:00
|
|
|
use std::cell::Cell;
|
2022-11-04 03:56:31 +00:00
|
|
|
use crate::factory::RenderReturn;
|
2022-11-20 01:07:29 +00:00
|
|
|
use bumpalo::Bump;
|
2022-10-28 04:58:47 +00:00
|
|
|
|
|
|
|
pub struct BumpFrame {
|
|
|
|
pub bump: Bump,
|
2022-11-04 03:56:31 +00:00
|
|
|
pub node: Cell<*mut RenderReturn<'static>>,
|
2022-10-28 04:58:47 +00:00
|
|
|
}
|
2022-11-20 01:07:29 +00:00
|
|
|
|
2022-10-28 04:58:47 +00:00
|
|
|
impl BumpFrame {
|
|
|
|
pub fn new(capacity: usize) -> Self {
|
|
|
|
let bump = Bump::with_capacity(capacity);
|
|
|
|
Self {
|
|
|
|
bump,
|
2022-11-04 03:56:31 +00:00
|
|
|
node: Cell::new(std::ptr::null_mut()),
|
2022-10-28 04:58:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn reset(&mut self) {
|
|
|
|
self.bump.reset();
|
2022-11-04 03:56:31 +00:00
|
|
|
self.node.set(std::ptr::null_mut());
|
2022-10-28 04:58:47 +00:00
|
|
|
}
|
2022-11-12 02:29:27 +00:00
|
|
|
|
2022-11-20 01:07:29 +00:00
|
|
|
/// Creates a new lifetime out of thin air
|
2022-11-12 02:29:27 +00:00
|
|
|
pub unsafe fn load_node<'b>(&self) -> &'b RenderReturn<'b> {
|
|
|
|
unsafe { std::mem::transmute(&*self.node.get()) }
|
|
|
|
}
|
2022-10-28 04:58:47 +00:00
|
|
|
}
|