use super::*;
#[cfg(not(target_arch = "wasm32"))]
#[derive(Clone, Copy, Data, Debug, Default)]
pub(crate) struct BandTaskSlice {
#[get(type(copy))]
pub(crate) pixels_ptr: usize,
#[get(type(copy))]
pub(crate) pixels_len: usize,
#[get(type(copy))]
pub(crate) width: u32,
#[get(type(copy))]
pub(crate) y_start: u32,
#[get(type(copy))]
pub(crate) height: u32,
#[get(type(copy))]
pub(crate) base_src_ptr: usize,
#[get(type(copy))]
pub(crate) restore_x0_bytes: usize,
#[get(type(copy))]
pub(crate) restore_row_bytes: usize,
}
#[derive(Clone, Copy, Debug, Default)]
pub(crate) struct BandRestoreSpec<'a> {
pub(crate) base_pixels: Option<&'a [u8]>,
pub(crate) x0: u32,
pub(crate) x1: u32,
pub(crate) scrim_luts: Option<&'a RgbaLutQuad>,
}
#[derive(Clone, Copy, Debug, Default)]
pub(crate) struct EdgeBlendSample {
pub(crate) x: u32,
pub(crate) rgba: [u8; 4],
pub(crate) sr_a: f32,
pub(crate) sg_a: f32,
pub(crate) sb_a: f32,
pub(crate) inv_a: f32,
pub(crate) sa_u32: u32,
pub(crate) is_opaque: bool,
}
#[derive(Clone, Copy, Debug, Default, Eq, PartialEq)]
pub(crate) struct CornerMaskRowSpan {
pub(crate) ext_start: u16,
pub(crate) ext_end: u16,
pub(crate) aa_start: u16,
pub(crate) aa_end: u16,
pub(crate) dirty_start: u16,
pub(crate) dirty_end: u16,
}
#[derive(Clone, Debug)]
pub(crate) struct CachedCornerMask {
pub(crate) radius_bits: u32,
pub(crate) quadrant: u8,
pub(crate) aa_enabled: bool,
pub(crate) dim: u16,
pub(crate) cov: Vec<u8>,
pub(crate) row_spans: Vec<CornerMaskRowSpan>,
}
#[derive(Clone, Debug, Default)]
pub(crate) struct CornerMaskCache {
pub(crate) entries: Vec<CachedCornerMask>,
}
#[derive(Clone, Copy, Debug, Default)]
pub(crate) struct SavedCornerRow {
pub(crate) y: u32,
pub(crate) sx0: u32,
pub(crate) sx1: u32,
pub(crate) byte_off: usize,
pub(crate) mask_id: u32,
pub(crate) origin_x: i32,
pub(crate) origin_y: i32,
}
#[derive(Debug, Default)]
pub(crate) struct BandCornerScratch {
pub(crate) saved_bytes: Vec<u8>,
pub(crate) saved_rows: Vec<SavedCornerRow>,
pub(crate) corner_boxes: Vec<(u32, u32, u32, u32)>,
}
#[derive(Clone, Copy, Data, Debug, Default, PartialEq)]
pub(crate) struct RoundedClipMask {
#[get(type(copy))]
pub(crate) rect: Rect,
#[get(type(copy))]
pub(crate) radius: CornerRadius,
#[get(type(copy))]
pub(crate) corner_mask_ids: [u32; 4],
}
#[derive(Clone, Copy, Debug, Default, Eq, PartialEq)]
pub(crate) struct PositionedGlyph {
pub(crate) glyph_idx: u32,
pub(crate) x: i32,
pub(crate) y: i32,
pub(crate) width: u16,
pub(crate) height: u16,
}
#[cfg(not(target_arch = "wasm32"))]
#[derive(Debug)]
pub(crate) struct BandJob {
pub(crate) tasks_ptr: usize,
pub(crate) tasks_len: usize,
pub(crate) commands_ptr: usize,
pub(crate) commands_len: usize,
pub(crate) prepped_ptr: usize,
pub(crate) prepped_len: usize,
pub(crate) glyphs_ptr: usize,
pub(crate) glyphs_len: usize,
pub(crate) caret_rects_ptr: usize,
pub(crate) caret_rects_len: usize,
pub(crate) rounded_clips_ptr: usize,
pub(crate) rounded_clips_len: usize,
pub(crate) corner_masks_ptr: usize,
pub(crate) corner_masks_len: usize,
pub(crate) atlas_ptr: usize,
pub(crate) scrim_luts_ptr: usize,
pub(crate) scale: f32,
pub(crate) aa: AntialiasingMode,
pub(crate) next_idx: AtomicUsize,
pub(crate) workers_done: AtomicUsize,
pub(crate) total_shaded: AtomicUsize,
}
#[cfg(not(target_arch = "wasm32"))]
#[repr(align(128))]
#[derive(Debug, Default)]
pub(crate) struct BandWorkerSlot {
pub(crate) epoch: AtomicUsize,
pub(crate) parked: AtomicUsize,
pub(crate) lock: Mutex<()>,
pub(crate) wake: Condvar,
}
#[cfg(not(target_arch = "wasm32"))]
#[derive(Debug, Default)]
pub(crate) struct BandPoolShared {
pub(crate) active_job: AtomicUsize,
pub(crate) active_workers: AtomicUsize,
pub(crate) caller_parked: AtomicUsize,
pub(crate) shutdown: AtomicUsize,
pub(crate) caller_lock: Mutex<()>,
pub(crate) wake_caller: Condvar,
pub(crate) slots: Vec<BandWorkerSlot>,
}
#[cfg(not(target_arch = "wasm32"))]
#[derive(Debug)]
pub(crate) struct BandWorkerPool {
pub(crate) worker_count: usize,
pub(crate) dispatch_tasks: Mutex<Vec<BandTaskSlice>>,
pub(crate) shared: Arc<BandPoolShared>,
pub(crate) handles: Vec<JoinHandle<()>>,
}
#[derive(Clone, Copy, Data, Debug, Default, PartialEq)]
pub(crate) struct PreppedCommand {
#[get(type(copy))]
pub(crate) cmd_index: usize,
#[get(type(copy))]
pub(crate) active_clip: Rect,
#[get(type(copy))]
pub(crate) y0: u32,
#[get(type(copy))]
pub(crate) y1: u32,
#[get(type(copy))]
pub(crate) opaque_cutout_h: Rect,
#[get(type(copy))]
pub(crate) opaque_cutout_v: Rect,
#[get(type(copy))]
pub(crate) glyph_run_start: u32,
#[get(type(copy))]
pub(crate) glyph_run_len: u32,
#[get(type(copy))]
pub(crate) caret_rect_idx: u32,
#[get(type(copy))]
pub(crate) rounded_clip_start: u32,
#[get(type(copy))]
pub(crate) rounded_clip_len: u16,
#[get(type(copy))]
pub(crate) skip_delta: u32,
}
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub(crate) struct TextLayoutSlot {
pub(crate) key_hash: u64,
pub(crate) width_key: u32,
pub(crate) entry_idx: u32,
}
#[derive(Clone, Debug, Default)]
pub(crate) struct TextLayoutCache {
pub(crate) slots: Vec<TextLayoutSlot>,
pub(crate) entries: Vec<TextLayoutResult>,
pub(crate) entry_keys: Vec<(u64, u32)>,
pub(crate) entry_last_used: Vec<u64>,
pub(crate) entry_bytes: Vec<usize>,
pub(crate) resident_bytes: usize,
pub(crate) budget_bytes: usize,
pub(crate) lru_clock: u64,
pub(crate) cache_hits: u64,
pub(crate) cache_misses: u64,
pub(crate) evictions: u64,
}
#[derive(Clone, Data, Debug, Default)]
pub struct SoftwareRenderer {
pub(crate) framebuffer: Framebuffer,
pub(crate) glyph_atlas: GlyphAtlas,
pub(crate) font_provider: NativeSystemFont,
#[get(type(copy))]
pub(crate) measurer: DeterministicTextMeasurer,
#[get(pub(crate))]
#[get_mut(pub(crate))]
#[set(pub(crate))]
pub(crate) text_layout_cache: TextLayoutCache,
#[get(pub(crate))]
#[get_mut(pub(crate))]
#[set(pub(crate))]
pub(crate) clip_stack: Vec<Rect>,
#[get(pub(crate))]
#[get_mut(pub(crate))]
#[set(pub(crate))]
pub(crate) rounded_clip_stack: Vec<Option<RoundedClipMask>>,
#[get(type(copy))]
pub(crate) antialiasing: AntialiasingMode,
#[get(type(copy))]
pub(crate) tile_size: u32,
#[get(pub(crate), type(copy))]
#[set(pub(crate))]
pub(crate) base_cache_width: u32,
#[get(pub(crate), type(copy))]
#[set(pub(crate))]
pub(crate) base_cache_height: u32,
#[get(pub(crate), type(copy))]
#[set(pub(crate))]
pub(crate) base_cache_hash: u64,
#[get(pub(crate), type(copy))]
#[set(pub(crate))]
pub(crate) prev_base_hash: u64,
#[get(pub(crate))]
#[get_mut(pub(crate))]
#[set(pub(crate))]
pub(crate) base_cache_pixels: Vec<u8>,
#[get(pub(crate))]
#[get_mut(pub(crate))]
#[set(pub(crate))]
pub(crate) prepped_scratch: Vec<PreppedCommand>,
#[get(pub(crate))]
#[get_mut(pub(crate))]
#[set(pub(crate))]
pub(crate) rounded_clips_scratch: Vec<RoundedClipMask>,
#[get(pub(crate))]
#[get_mut(pub(crate))]
#[set(pub(crate))]
pub(crate) positioned_glyphs_scratch: Vec<PositionedGlyph>,
#[get(pub(crate))]
#[get_mut(pub(crate))]
#[set(pub(crate))]
pub(crate) line_glyphs_scratch: Vec<(u32, f32, u16, u16)>,
#[get(pub(crate))]
#[get_mut(pub(crate))]
#[set(pub(crate))]
pub(crate) caret_rects_scratch: Vec<Rect>,
#[get(pub(crate))]
#[get_mut(pub(crate))]
#[set(pub(crate))]
pub(crate) corner_mask_cache: CornerMaskCache,
#[get(pub(crate), type(copy))]
#[set(pub(crate))]
pub(crate) prev_portal_bounds: Option<Rect>,
#[get(pub(crate), type(copy))]
#[set(pub(crate))]
pub(crate) prev_portal_scrim: Option<Color>,
#[get(pub(crate), type(copy))]
#[set(pub(crate))]
pub(crate) prepped_bounds: Option<Rect>,
#[get(pub(crate), type(copy))]
#[set(pub(crate))]
pub(crate) prepped_fg_bounds: Option<Rect>,
#[get(pub(crate))]
#[get_mut(pub(crate))]
#[set(pub(crate))]
pub(crate) clip_scope_scratch: Vec<(u32, u32, Option<usize>)>,
#[get(skip)]
#[get_mut(skip)]
#[set(skip)]
pub(crate) cached_scrim_color: Option<Color>,
#[get(skip)]
#[get_mut(skip)]
#[set(skip)]
pub(crate) cached_scrim_luts: Option<Box<RgbaLutQuad>>,
#[get(type(copy))]
#[get_mut(skip)]
#[set(skip)]
pub(crate) serial_dispatches: u64,
#[get(type(copy))]
#[get_mut(skip)]
#[set(skip)]
pub(crate) parallel_dispatches: u64,
}
#[derive(Clone, Copy, Debug, Default)]
pub(crate) struct ShadowStripHot {
pub(crate) ign_x: f32,
pub(crate) cached_dst: u32,
pub(crate) q4_r: i16,
pub(crate) q4_g: i16,
pub(crate) q4_b: i16,
pub(crate) out_a: u8,
pub(crate) state: u8,
}
#[derive(Clone, Copy, Debug, Default)]
pub(crate) struct ShadowStripParams {
pub(crate) sr_a: f32,
pub(crate) sg_a: f32,
pub(crate) sb_a: f32,
pub(crate) inv_a: f32,
pub(crate) sa_u32: u32,
pub(crate) inv_a_u32: u32,
}
#[derive(Clone, Copy, Debug, Default)]
pub(crate) struct ShadowPixelCache {
pub(crate) dst_u32: u32,
pub(crate) q4_r: i32,
pub(crate) q4_g: i32,
pub(crate) q4_b: i32,
pub(crate) out_a: u8,
pub(crate) valid: bool,
}
#[derive(Debug, Default)]
pub(crate) struct BandShadowScratch {
pub(crate) left_hot: Vec<ShadowStripHot>,
pub(crate) left_params: Vec<ShadowStripParams>,
pub(crate) right_hot: Vec<ShadowStripHot>,
pub(crate) right_params: Vec<ShadowStripParams>,
}
#[derive(Clone, Copy, Debug)]
pub(crate) struct ShadowRenderCtx {
pub(crate) color: Color,
pub(crate) color_rgb: [u8; 3],
pub(crate) lin_rgb: [f32; 3],
pub(crate) cx: f32,
pub(crate) cy: f32,
pub(crate) half_w: f32,
pub(crate) half_h: f32,
pub(crate) base_alpha: f32,
pub(crate) inv_sigma: f32,
pub(crate) cutoff: f32,
pub(crate) uniform_r: f32,
pub(crate) cutoff_r_safe_sq: f32,
pub(crate) x0: u32,
pub(crate) x1: u32,
pub(crate) lx1: u32,
pub(crate) rx0: u32,
pub(crate) mirror_x_sum: i32,
pub(crate) has_mid_x: bool,
}