mirror of
https://github.com/penpot/penpot.git
synced 2025-01-21 14:12:36 -05:00
🐛 Fix drawing multiple shapes with different blend modes
This commit is contained in:
parent
defe6ff7f8
commit
f56a665206
1 changed files with 15 additions and 8 deletions
|
@ -1,4 +1,4 @@
|
||||||
use skia_safe::{self as skia, SamplingOptions};
|
use skia_safe::{self as skia, Color, SamplingOptions};
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
|
|
||||||
|
@ -49,11 +49,13 @@ impl<'a> State<'a> {
|
||||||
self.render_state.final_surface.canvas().save();
|
self.render_state.final_surface.canvas().save();
|
||||||
self.render_state.drawing_surface.canvas().save();
|
self.render_state.drawing_surface.canvas().save();
|
||||||
|
|
||||||
render_single_shape(
|
if id != Uuid::nil() {
|
||||||
&mut self.render_state.final_surface,
|
render_single_shape(
|
||||||
&mut self.render_state.drawing_surface,
|
&mut self.render_state.final_surface,
|
||||||
shape,
|
&mut self.render_state.drawing_surface,
|
||||||
);
|
shape,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
// draw all the children shapes
|
// draw all the children shapes
|
||||||
let shape_ids = shape.children.clone();
|
let shape_ids = shape.children.clone();
|
||||||
|
@ -80,7 +82,11 @@ impl<'a> State<'a> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render_single_shape(surface: &mut skia::Surface, offscreen: &mut skia::Surface, shape: &Shape) {
|
fn render_single_shape(
|
||||||
|
final_surface: &mut skia::Surface,
|
||||||
|
offscreen: &mut skia::Surface,
|
||||||
|
shape: &Shape,
|
||||||
|
) {
|
||||||
let r = skia::Rect::new(
|
let r = skia::Rect::new(
|
||||||
shape.selrect.x1,
|
shape.selrect.x1,
|
||||||
shape.selrect.y1,
|
shape.selrect.y1,
|
||||||
|
@ -120,9 +126,10 @@ fn render_single_shape(surface: &mut skia::Surface, offscreen: &mut skia::Surfac
|
||||||
let mut paint = skia::Paint::default();
|
let mut paint = skia::Paint::default();
|
||||||
paint.set_blend_mode(shape.blend_mode.into());
|
paint.set_blend_mode(shape.blend_mode.into());
|
||||||
offscreen.draw(
|
offscreen.draw(
|
||||||
&mut surface.canvas(),
|
&mut final_surface.canvas(),
|
||||||
(0.0, 0.0),
|
(0.0, 0.0),
|
||||||
SamplingOptions::new(skia::FilterMode::Linear, skia::MipmapMode::None),
|
SamplingOptions::new(skia::FilterMode::Linear, skia::MipmapMode::None),
|
||||||
Some(&paint),
|
Some(&paint),
|
||||||
);
|
);
|
||||||
|
offscreen.canvas().clear(Color::TRANSPARENT);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue