Start on rendering shadows
This still doesn't work properly because shadows are rendered beneath quads and we still don't have a layering mechanism. Co-Authored-By: Nathan Sobo <nathan@zed.dev>
This commit is contained in:
co-authored by
Nathan Sobo
parent
45c1337c84
commit
bfc57cb4f6
@@ -11,6 +11,7 @@ pub struct Scene {
|
||||
pub struct Layer {
|
||||
clip_bounds: Option<RectF>,
|
||||
quads: Vec<Quad>,
|
||||
shadows: Vec<Shadow>,
|
||||
}
|
||||
|
||||
#[derive(Default, Debug)]
|
||||
@@ -21,6 +22,13 @@ pub struct Quad {
|
||||
pub corner_radius: f32,
|
||||
}
|
||||
|
||||
pub struct Shadow {
|
||||
pub bounds: RectF,
|
||||
pub corner_radius: f32,
|
||||
pub sigma: f32,
|
||||
pub color: ColorU,
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Default, Debug)]
|
||||
pub struct Border {
|
||||
pub width: f32,
|
||||
@@ -61,6 +69,10 @@ impl Scene {
|
||||
self.active_layer().push_quad(quad)
|
||||
}
|
||||
|
||||
pub fn push_shadow(&mut self, shadow: Shadow) {
|
||||
self.active_layer().push_shadow(shadow)
|
||||
}
|
||||
|
||||
fn active_layer(&mut self) -> &mut Layer {
|
||||
&mut self.layers[*self.active_layer_stack.last().unwrap()]
|
||||
}
|
||||
@@ -74,6 +86,14 @@ impl Layer {
|
||||
pub fn quads(&self) -> &[Quad] {
|
||||
self.quads.as_slice()
|
||||
}
|
||||
|
||||
fn push_shadow(&mut self, shadow: Shadow) {
|
||||
self.shadows.push(shadow);
|
||||
}
|
||||
|
||||
pub fn shadows(&self) -> &[Shadow] {
|
||||
self.shadows.as_slice()
|
||||
}
|
||||
}
|
||||
|
||||
impl Border {
|
||||
|
||||
Reference in New Issue
Block a user