mod backdrop;
mod draw_context;
mod draw_state;
mod drawing;
mod emit;
mod filter_output;
mod filter_passes;
mod filter_tree;
mod filters;
pub(crate) mod gaussian;
mod layer_coverage;
mod layers;
mod pattern_filter;
mod plan_writer;
mod primitives;
mod raster_embed;
mod replay;
mod route;
mod segments;
mod shading;
mod snapshot;
mod source;
mod text;
use valo_dl::DisplayList;
use crate::contours::ContourCache;
use crate::frame::FramePlan;
use crate::glyphs::GlyphStore;
use crate::pool::TargetPool;
use crate::raster::ListRasterCache;
use crate::renderer::RenderTarget;
use draw_context::{DrawContext, DrawContexts};
use drawing::Drawing;
use emit::StepEmitter;
use filter_passes::FilterPasses;
use plan_writer::PlanWriter;
use replay::ReplayState;
pub(crate) use emit::{EmitterServices, LinearSamplers};
pub(crate) struct Planner<'a> {
contexts: DrawContexts,
plan: PlanWriter,
tools: Tools<'a>,
caches: &'a mut Caches,
}
struct Tools<'a> {
emit: StepEmitter<'a>,
pool: &'a mut TargetPool,
device: &'a wgpu::Device,
format: wgpu::TextureFormat,
}
pub(crate) struct Caches {
pub glyphs: GlyphStore,
pub contours: ContourCache,
pub rasters: ListRasterCache,
}
impl<'a> Planner<'a> {
pub fn plan(
device: &'a wgpu::Device,
services: &'a mut EmitterServices,
pool: &'a mut TargetPool,
caches: &'a mut Caches,
list: &DisplayList,
target: &RenderTarget,
) -> FramePlan {
let attachments = pool.take_attachments(target.size, target.format);
let main = DrawContext::main(attachments, target, list);
let mut planner = Self {
contexts: DrawContexts::new(main),
plan: PlanWriter::default(),
tools: Tools {
emit: StepEmitter::new(services, device, target.format),
pool,
device,
format: target.format,
},
caches,
};
if target.clear.is_none() {
planner.start_from_existing_pixels();
}
planner.replay_list(list, &mut ReplayState::root());
planner.emit_segment();
planner.plan.finish()
}
fn drawing(&mut self) -> Drawing<'_, 'a> {
Drawing {
context: self.contexts.top_mut(),
emit: &mut self.tools.emit,
caches: self.caches,
stats: &mut self.plan.stats,
}
}
fn filter_passes(&mut self) -> FilterPasses<'_, 'a> {
FilterPasses {
pool: self.tools.pool,
emit: &mut self.tools.emit,
plan: &mut self.plan,
format: self.tools.format,
}
}
}