mirror of
https://github.com/storytold/effectcraft.git
synced 2026-10-27 11:37:02 -06:00
refactor(psd): move the test counters module to counters.rs
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
use std::cell::Cell;
|
||||
use std::thread::LocalKey;
|
||||
|
||||
thread_local! {
|
||||
/// Scratch rows allocated by the 32-bit ZIP un-predictor.
|
||||
pub static SCRATCH: Cell<usize> = const { Cell::new(0) };
|
||||
/// `inside the mask rect` evaluations of the layer-mask loop.
|
||||
pub static INSIDE: Cell<usize> = const { Cell::new(0) };
|
||||
/// `square_to_quad` solves.
|
||||
pub static QUAD: Cell<usize> = const { Cell::new(0) };
|
||||
}
|
||||
|
||||
pub fn bump(c: &'static LocalKey<Cell<usize>>) {
|
||||
c.with(|c| c.set(c.get() + 1));
|
||||
}
|
||||
/// Read and reset.
|
||||
pub fn take(c: &'static LocalKey<Cell<usize>>) -> usize {
|
||||
c.with(|c| c.replace(0))
|
||||
}
|
||||
+1
-21
@@ -1496,24 +1496,4 @@ mod tests;
|
||||
|
||||
/// Test-only call counters (per thread), to prove what the optimised paths avoid doing.
|
||||
#[cfg(test)]
|
||||
pub(crate) mod counters {
|
||||
use std::cell::Cell;
|
||||
use std::thread::LocalKey;
|
||||
|
||||
thread_local! {
|
||||
/// Scratch rows allocated by the 32-bit ZIP un-predictor.
|
||||
pub static SCRATCH: Cell<usize> = const { Cell::new(0) };
|
||||
/// `inside the mask rect` evaluations of the layer-mask loop.
|
||||
pub static INSIDE: Cell<usize> = const { Cell::new(0) };
|
||||
/// `square_to_quad` solves.
|
||||
pub static QUAD: Cell<usize> = const { Cell::new(0) };
|
||||
}
|
||||
|
||||
pub fn bump(c: &'static LocalKey<Cell<usize>>) {
|
||||
c.with(|c| c.set(c.get() + 1));
|
||||
}
|
||||
/// Read and reset.
|
||||
pub fn take(c: &'static LocalKey<Cell<usize>>) -> usize {
|
||||
c.with(|c| c.replace(0))
|
||||
}
|
||||
}
|
||||
pub(crate) mod counters;
|
||||
|
||||
Reference in New Issue
Block a user