use super::*;
#[derive(Clone, Copy, Data, Debug, Default, Eq, Hash, New, Ord, PartialEq, PartialOrd)]
pub struct ParallelLayoutStats {
#[get(type(copy))]
pub(crate) used_parallel: bool,
#[get(type(copy))]
pub(crate) parallel_tasks_dispatched: usize,
#[get(type(copy))]
pub(crate) worker_threads_available: usize,
#[get(type(copy))]
pub(crate) simd_translations: usize,
#[get(type(copy))]
pub(crate) simd_text_measures: usize,
#[get(type(copy))]
pub(crate) nodes_computed: usize,
#[get(type(copy))]
pub(crate) nodes_changed: usize,
}
#[derive(Clone, Copy, Data, Debug, Default, New)]
pub(crate) struct ParallelFlexItem {
#[get(pub(crate), type(copy))]
#[set(pub(crate))]
pub(crate) bfs_index: u32,
#[get(pub(crate), type(copy))]
#[get_mut(pub(crate))]
#[set(pub(crate))]
pub(crate) size: Size,
#[get(pub(crate), type(copy))]
#[set(pub(crate))]
pub(crate) margin: Edges,
#[get(pub(crate), type(copy))]
#[set(pub(crate))]
#[new(skip)]
pub(crate) flex_grow: f32,
#[get(pub(crate), type(copy))]
#[set(pub(crate))]
#[new(skip)]
pub(crate) flex_shrink: f32,
#[get(pub(crate), type(copy))]
#[set(pub(crate))]
#[new(skip)]
pub(crate) min_main: f32,
#[get(pub(crate), type(copy))]
#[set(pub(crate))]
pub(crate) align_self: AlignSelf,
#[get(pub(crate), type(copy))]
#[set(pub(crate))]
pub(crate) overflow: Overflow,
#[get(pub(crate), type(copy))]
#[set(pub(crate))]
pub(crate) flags: u16,
}
#[derive(Clone, Debug, Default)]
pub struct WorkerLayoutScratch {
pub(crate) flow_scratch: Vec<u32>,
pub(crate) abs_scratch: Vec<u32>,
pub(crate) flex_items_scratch: Vec<ParallelFlexItem>,
pub(crate) flex_lines_scratch: Vec<(usize, usize)>,
pub(crate) translate_arena_scratch: Vec<u32>,
pub(crate) translate_bfs_scratch: Vec<u32>,
pub(crate) text_size_cache: TextSizeCache,
pub(crate) nodes_computed: usize,
pub(crate) nodes_changed: usize,
pub(crate) simd_translations: usize,
pub(crate) simd_text_measures: usize,
}
#[derive(Debug)]
pub(crate) struct WorkerScratchBank {
pub(crate) lanes: Vec<UnsafeCell<WorkerLayoutScratch>>,
}
#[derive(Clone, Copy, Debug, Default)]
pub(crate) struct ParallelNodeResult {
pub(crate) size: Size,
pub(crate) natural_bounds: Rect,
pub(crate) natural_content_bounds: Rect,
pub(crate) dep_flags: u8,
pub(crate) min_avail_w: f32,
pub(crate) post_stretched: bool,
pub(crate) hidden: bool,
pub(crate) written: bool,
pub(crate) has_nonzero_z: bool,
}
#[derive(Clone, Debug, Default)]
pub(crate) struct ParallelOutputArena {
pub(crate) boxes: Vec<LayoutBox>,
pub(crate) constraints: Vec<Option<AvailableSpace>>,
pub(crate) subtree_bounds: Vec<Rect>,
pub(crate) results: Vec<ParallelNodeResult>,
}
#[derive(Clone, Copy, Debug)]
pub(crate) struct DisjointOutputView {
pub(crate) boxes_ptr: *mut LayoutBox,
pub(crate) constraints_ptr: *mut Option<AvailableSpace>,
pub(crate) subtree_bounds_ptr: *mut Rect,
pub(crate) results_ptr: *mut ParallelNodeResult,
pub(crate) arena_len: usize,
}
#[cfg(not(target_arch = "wasm32"))]
#[derive(Clone, Copy, Debug, Default)]
pub(crate) struct ParallelChildOutcome {
pub(crate) size: Size,
pub(crate) dep_flags: u8,
pub(crate) min_avail_w: f32,
}
#[cfg(not(target_arch = "wasm32"))]
#[derive(Clone, Copy, Debug, Default)]
pub(crate) struct ParallelChildTask {
pub(crate) bfs_index: u32,
pub(crate) space: AvailableSpace,
pub(crate) mode: LayoutRunMode,
}
#[cfg(not(target_arch = "wasm32"))]
#[derive(Clone, Copy, Debug)]
pub(crate) struct DisjointOutcomeView {
pub(crate) outcomes_ptr: *mut ParallelChildOutcome,
pub(crate) outcomes_len: usize,
}
#[cfg(not(target_arch = "wasm32"))]
pub(crate) struct ParallelForkContext<'a> {
pub(crate) soa: &'a SceneLayoutSoa,
pub(crate) output_view: DisjointOutputView,
pub(crate) scratch_bank: &'a WorkerScratchBank,
pub(crate) pool: &'a EngineWorkerPool,
pub(crate) child_tasks: &'a mut Vec<ParallelChildTask>,
pub(crate) child_outcomes: &'a mut Vec<ParallelChildOutcome>,
pub(crate) dispatched_tasks: &'a mut usize,
}
#[derive(Clone, Copy, Debug, Default)]
pub(crate) struct ResolvedNodeConstraints {
pub(crate) own_deps: u8,
pub(crate) resolved_w: Option<f32>,
pub(crate) resolved_h: Option<f32>,
pub(crate) explicit_w: Option<f32>,
pub(crate) stretched_w: bool,
pub(crate) min_w: f32,
pub(crate) max_w: f32,
pub(crate) min_h: f32,
pub(crate) max_h: f32,
pub(crate) chrome_h: f32,
pub(crate) chrome_v: f32,
pub(crate) inner_avail_w: f32,
pub(crate) inner_avail_h: f32,
pub(crate) content_origin_x: f32,
pub(crate) content_origin_y: f32,
}
#[derive(Clone, Copy, Debug, Default)]
pub(crate) struct PreparedFlexItemMeta {
pub(crate) zero_basis_size: Option<Size>,
pub(crate) explicit_basis_main: Option<f32>,
pub(crate) explicit_min_main: Option<f32>,
pub(crate) explicit_max_main: Option<f32>,
pub(crate) is_unwrapped_clip_text: bool,
pub(crate) has_px_main: bool,
}
#[cfg(not(target_arch = "wasm32"))]
#[derive(Clone, Copy, Debug)]
pub(crate) struct FlexPlacementMeta {
pub(crate) target_w: f32,
pub(crate) target_h: f32,
pub(crate) avail_item_cross: f32,
pub(crate) cross_offset: f32,
pub(crate) align: AlignItems,
pub(crate) auto_cross_grow: bool,
pub(crate) main_resized_item: bool,
}
#[derive(Debug)]
pub struct ParallelLayoutSolver {
pub(crate) scratch_bank: WorkerScratchBank,
pub(crate) output_arena: ParallelOutputArena,
#[cfg(not(target_arch = "wasm32"))]
pub(crate) child_tasks: Vec<ParallelChildTask>,
#[cfg(not(target_arch = "wasm32"))]
pub(crate) child_outcomes: Vec<ParallelChildOutcome>,
pub(crate) last_stats: ParallelLayoutStats,
}