mirror of
https://github.com/penpot/penpot.git
synced 2025-06-02 00:51:38 +02:00
Merge pull request #5667 from penpot/superalex-fix-blend-modes-render-wasm
🐛 Fix blend modes for wasm render
This commit is contained in:
commit
2726fa04c0
3 changed files with 31 additions and 22 deletions
|
@ -493,7 +493,9 @@
|
||||||
id (dm/get-prop shape :id)
|
id (dm/get-prop shape :id)
|
||||||
type (dm/get-prop shape :type)
|
type (dm/get-prop shape :type)
|
||||||
selrect (dm/get-prop shape :selrect)
|
selrect (dm/get-prop shape :selrect)
|
||||||
clip-content (not (dm/get-prop shape :show-content))
|
clip-content (if (= type :frame)
|
||||||
|
(not (dm/get-prop shape :show-content))
|
||||||
|
false)
|
||||||
rotation (dm/get-prop shape :rotation)
|
rotation (dm/get-prop shape :rotation)
|
||||||
transform (dm/get-prop shape :transform)
|
transform (dm/get-prop shape :transform)
|
||||||
fills (if (= type :group)
|
fills (if (= type :group)
|
||||||
|
|
|
@ -115,7 +115,9 @@
|
||||||
:bool-type (api/set-shape-bool-type v)
|
:bool-type (api/set-shape-bool-type v)
|
||||||
:bool-content (api/set-shape-bool-content v)
|
:bool-content (api/set-shape-bool-content v)
|
||||||
:selrect (api/set-shape-selrect v)
|
:selrect (api/set-shape-selrect v)
|
||||||
:show-content (api/set-shape-clip-content (not v))
|
:show-content (if (= (:type self) :frame)
|
||||||
|
(api/set-shape-clip-content (not v))
|
||||||
|
(api/set-shape-clip-content false))
|
||||||
:rotation (api/set-shape-rotation v)
|
:rotation (api/set-shape-rotation v)
|
||||||
:transform (api/set-shape-transform v)
|
:transform (api/set-shape-transform v)
|
||||||
:fills (api/set-shape-fills v)
|
:fills (api/set-shape-fills v)
|
||||||
|
|
|
@ -142,7 +142,7 @@ impl RenderState {
|
||||||
pub fn reset_canvas(&mut self) {
|
pub fn reset_canvas(&mut self) {
|
||||||
self.drawing_surface
|
self.drawing_surface
|
||||||
.canvas()
|
.canvas()
|
||||||
.clear(skia::Color::TRANSPARENT)
|
.clear(self.background_color)
|
||||||
.reset_matrix();
|
.reset_matrix();
|
||||||
self.final_surface
|
self.final_surface
|
||||||
.canvas()
|
.canvas()
|
||||||
|
@ -154,7 +154,20 @@ impl RenderState {
|
||||||
.reset_matrix();
|
.reset_matrix();
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn render_shape(&mut self, shape: &mut Shape) {
|
pub fn apply_drawing_to_final_canvas(&mut self) {
|
||||||
|
self.drawing_surface.draw(
|
||||||
|
&mut self.final_surface.canvas(),
|
||||||
|
(0.0, 0.0),
|
||||||
|
skia::SamplingOptions::new(skia::FilterMode::Linear, skia::MipmapMode::Nearest),
|
||||||
|
Some(&skia::Paint::default()),
|
||||||
|
);
|
||||||
|
|
||||||
|
self.drawing_surface
|
||||||
|
.canvas()
|
||||||
|
.clear(skia::Color::TRANSPARENT);
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn render_shape(&mut self, shape: &mut Shape, clip: bool) {
|
||||||
let transform = shape.transform.to_skia_matrix();
|
let transform = shape.transform.to_skia_matrix();
|
||||||
|
|
||||||
// Check transform-matrix code from common/src/app/common/geom/shapes/transforms.cljc
|
// Check transform-matrix code from common/src/app/common/geom/shapes/transforms.cljc
|
||||||
|
@ -195,16 +208,13 @@ impl RenderState {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
self.drawing_surface.draw(
|
if clip {
|
||||||
&mut self.final_surface.canvas(),
|
self.drawing_surface
|
||||||
(0.0, 0.0),
|
.canvas()
|
||||||
skia::SamplingOptions::new(skia::FilterMode::Linear, skia::MipmapMode::Nearest),
|
.clip_rect(shape.bounds(), skia::ClipOp::Intersect, true);
|
||||||
Some(&skia::Paint::default()),
|
}
|
||||||
);
|
|
||||||
|
|
||||||
self.drawing_surface
|
self.apply_drawing_to_final_canvas();
|
||||||
.canvas()
|
|
||||||
.clear(skia::Color::TRANSPARENT);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn zoom(&mut self, tree: &HashMap<Uuid, Shape>) -> Result<(), String> {
|
pub fn zoom(&mut self, tree: &HashMap<Uuid, Shape>) -> Result<(), String> {
|
||||||
|
@ -325,17 +335,12 @@ impl RenderState {
|
||||||
let layer_rec = skia::canvas::SaveLayerRec::default().paint(&paint);
|
let layer_rec = skia::canvas::SaveLayerRec::default().paint(&paint);
|
||||||
// This is needed so the next non-children shape does not carry this shape's transform
|
// This is needed so the next non-children shape does not carry this shape's transform
|
||||||
self.final_surface.canvas().save_layer(&layer_rec);
|
self.final_surface.canvas().save_layer(&layer_rec);
|
||||||
self.drawing_surface.canvas().save();
|
|
||||||
|
|
||||||
|
self.drawing_surface.canvas().save();
|
||||||
if !root_id.is_nil() {
|
if !root_id.is_nil() {
|
||||||
self.render_shape(&mut element.clone());
|
self.render_shape(&mut element.clone(), element.clip());
|
||||||
if element.clip() {
|
} else {
|
||||||
self.drawing_surface.canvas().clip_rect(
|
self.apply_drawing_to_final_canvas();
|
||||||
element.bounds(),
|
|
||||||
skia::ClipOp::Intersect,
|
|
||||||
true,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
self.drawing_surface.canvas().restore();
|
self.drawing_surface.canvas().restore();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue