Merge pull request #6126 from penpot/elenatorro-10516-fix-stroke-shadows

🐛 Fix stroke shadows
This commit is contained in:
Alejandro 2025-03-28 09:54:39 +01:00 committed by GitHub
commit bd5e47f5fc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 122 additions and 201 deletions

View file

@ -210,43 +210,35 @@ impl RenderState {
}
pub fn apply_drawing_to_render_canvas(&mut self, shape: Option<&Shape>) {
self.surfaces
.flush_and_submit(&mut self.gpu_state, SurfaceId::Fills);
self.surfaces
.flush_and_submit(&mut self.gpu_state, SurfaceId::DropShadows);
self.surfaces
.flush_and_submit(&mut self.gpu_state, SurfaceId::InnerShadows);
self.surfaces.draw_into(
SurfaceId::DropShadows,
SurfaceId::Current,
Some(&skia::Paint::default()),
);
self.surfaces
.flush_and_submit(&mut self.gpu_state, SurfaceId::Fills);
self.surfaces.draw_into(
SurfaceId::Fills,
SurfaceId::Current,
Some(&skia::Paint::default()),
);
self.surfaces.draw_into(
SurfaceId::InnerShadows,
SurfaceId::Current,
Some(&skia::Paint::default()),
);
let mut render_overlay_below_strokes = false;
if let Some(shape) = shape {
render_overlay_below_strokes = shape.fills().len() > 0;
render_overlay_below_strokes = shape.has_fills();
}
if render_overlay_below_strokes {
self.surfaces
.flush_and_submit(&mut self.gpu_state, SurfaceId::Overlay);
.flush_and_submit(&mut self.gpu_state, SurfaceId::InnerShadows);
self.surfaces.draw_into(
SurfaceId::Overlay,
SurfaceId::InnerShadows,
SurfaceId::Current,
Some(&skia::Paint::default()),
);
@ -254,6 +246,7 @@ impl RenderState {
self.surfaces
.flush_and_submit(&mut self.gpu_state, SurfaceId::Strokes);
self.surfaces.draw_into(
SurfaceId::Strokes,
SurfaceId::Current,
@ -262,25 +255,22 @@ impl RenderState {
if !render_overlay_below_strokes {
self.surfaces
.flush_and_submit(&mut self.gpu_state, SurfaceId::Overlay);
.flush_and_submit(&mut self.gpu_state, SurfaceId::InnerShadows);
self.surfaces.draw_into(
SurfaceId::Overlay,
SurfaceId::InnerShadows,
SurfaceId::Current,
Some(&skia::Paint::default()),
);
}
self.surfaces
.draw_into(SurfaceId::Overlay, SurfaceId::Current, None);
self.surfaces
.flush_and_submit(&mut self.gpu_state, SurfaceId::Current);
self.surfaces.apply_mut(
&[
SurfaceId::Shadow,
SurfaceId::InnerShadows,
SurfaceId::DropShadows,
SurfaceId::Overlay,
SurfaceId::InnerShadows,
SurfaceId::Fills,
SurfaceId::Strokes,
],
@ -403,11 +393,13 @@ impl RenderState {
}
for stroke in shape.strokes().rev() {
strokes::render(self, &shape, stroke, antialias);
shadows::render_stroke_drop_shadows(self, &shape, stroke, antialias);
strokes::render(self, &shape, stroke, None, None, antialias);
shadows::render_stroke_inner_shadows(self, &shape, stroke, antialias);
}
shadows::render_inner_shadows(self, &shape, antialias);
shadows::render_drop_shadows(self, &shape, antialias);
shadows::render_fill_inner_shadows(self, &shape, antialias);
shadows::render_fill_drop_shadows(self, &shape, antialias);
}
};