mirror of
https://github.com/penpot/penpot.git
synced 2025-01-08 07:50:43 -05:00
Merge pull request #5435 from penpot/superalex-render-wasm-show-content-support
🎉 Suport for show-content in render wasm
This commit is contained in:
commit
8599c52fc0
5 changed files with 47 additions and 23 deletions
|
@ -80,6 +80,10 @@
|
||||||
(aget buffer 2)
|
(aget buffer 2)
|
||||||
(aget buffer 3))))
|
(aget buffer 3))))
|
||||||
|
|
||||||
|
(defn set-shape-clip-content
|
||||||
|
[clip-content]
|
||||||
|
(h/call internal-module "_set_shape_clip_content" clip-content))
|
||||||
|
|
||||||
(defn set-shape-selrect
|
(defn set-shape-selrect
|
||||||
[selrect]
|
[selrect]
|
||||||
(h/call internal-module "_set_shape_selrect"
|
(h/call internal-module "_set_shape_selrect"
|
||||||
|
@ -247,21 +251,23 @@
|
||||||
pending
|
pending
|
||||||
(loop [index 0 pending []]
|
(loop [index 0 pending []]
|
||||||
(if (< index total-shapes)
|
(if (< index total-shapes)
|
||||||
(let [shape (nth shapes index)
|
(let [shape (nth shapes index)
|
||||||
type (dm/get-prop shape :type)
|
type (dm/get-prop shape :type)
|
||||||
id (dm/get-prop shape :id)
|
id (dm/get-prop shape :id)
|
||||||
selrect (dm/get-prop shape :selrect)
|
clip-content (not (dm/get-prop shape :show-content))
|
||||||
rotation (dm/get-prop shape :rotation)
|
selrect (dm/get-prop shape :selrect)
|
||||||
transform (dm/get-prop shape :transform)
|
rotation (dm/get-prop shape :rotation)
|
||||||
fills (if (= type :group)
|
transform (dm/get-prop shape :transform)
|
||||||
[] (dm/get-prop shape :fills))
|
fills (if (= type :group)
|
||||||
children (dm/get-prop shape :shapes)
|
[] (dm/get-prop shape :fills))
|
||||||
blend-mode (dm/get-prop shape :blend-mode)
|
children (dm/get-prop shape :shapes)
|
||||||
opacity (dm/get-prop shape :opacity)
|
blend-mode (dm/get-prop shape :blend-mode)
|
||||||
hidden (dm/get-prop shape :hidden)
|
opacity (dm/get-prop shape :opacity)
|
||||||
content (dm/get-prop shape :content)]
|
hidden (dm/get-prop shape :hidden)
|
||||||
|
content (dm/get-prop shape :content)]
|
||||||
|
|
||||||
(use-shape id)
|
(use-shape id)
|
||||||
|
(set-shape-clip-content clip-content)
|
||||||
(set-shape-selrect selrect)
|
(set-shape-selrect selrect)
|
||||||
(set-shape-rotation rotation)
|
(set-shape-rotation rotation)
|
||||||
(set-shape-transform transform)
|
(set-shape-transform transform)
|
||||||
|
|
|
@ -111,15 +111,16 @@
|
||||||
(when ^boolean shape/*wasm-sync*
|
(when ^boolean shape/*wasm-sync*
|
||||||
(api/use-shape (:id self))
|
(api/use-shape (:id self))
|
||||||
(case k
|
(case k
|
||||||
:selrect (api/set-shape-selrect v)
|
:selrect (api/set-shape-selrect v)
|
||||||
:rotation (api/set-shape-rotation v)
|
:show-content (api/set-shape-clip-content (not v))
|
||||||
:transform (api/set-shape-transform v)
|
:rotation (api/set-shape-rotation v)
|
||||||
:fills (api/set-shape-fills v)
|
:transform (api/set-shape-transform v)
|
||||||
:blend-mode (api/set-shape-blend-mode v)
|
:fills (api/set-shape-fills v)
|
||||||
:opacity (api/set-shape-opacity v)
|
:blend-mode (api/set-shape-blend-mode v)
|
||||||
:hidden (api/set-shape-hidden v)
|
:opacity (api/set-shape-opacity v)
|
||||||
:shapes (api/set-shape-children v)
|
:hidden (api/set-shape-hidden v)
|
||||||
:content (api/set-shape-path-content v)
|
:shapes (api/set-shape-children v)
|
||||||
|
:content (api/set-shape-path-content v)
|
||||||
nil)
|
nil)
|
||||||
;; when something synced with wasm
|
;; when something synced with wasm
|
||||||
;; is modified, we need to request
|
;; is modified, we need to request
|
||||||
|
|
|
@ -111,7 +111,15 @@ pub extern "C" fn set_shape_selrect(left: f32, top: f32, right: f32, bottom: f32
|
||||||
}
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub extern "C" fn set_shape_rotation(rotation: f32) {
|
pub unsafe extern "C" fn set_shape_clip_content(clip_content: bool) {
|
||||||
|
let state = unsafe { STATE.as_mut() }.expect("got an invalid state pointer");
|
||||||
|
if let Some(shape) = state.current_shape() {
|
||||||
|
shape.clip_content = clip_content;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[no_mangle]
|
||||||
|
pub unsafe extern "C" fn set_shape_rotation(rotation: f32) {
|
||||||
let state = unsafe { STATE.as_mut() }.expect("got an invalid state pointer");
|
let state = unsafe { STATE.as_mut() }.expect("got an invalid state pointer");
|
||||||
if let Some(shape) = state.current_shape() {
|
if let Some(shape) = state.current_shape() {
|
||||||
shape.rotation = rotation;
|
shape.rotation = rotation;
|
||||||
|
|
|
@ -413,6 +413,13 @@ impl RenderState {
|
||||||
|
|
||||||
if !id.is_nil() {
|
if !id.is_nil() {
|
||||||
self.render_single_shape(shape);
|
self.render_single_shape(shape);
|
||||||
|
if shape.clip_content {
|
||||||
|
self.drawing_surface.canvas().clip_rect(
|
||||||
|
shape.selrect,
|
||||||
|
skia::ClipOp::Intersect,
|
||||||
|
true,
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// draw all the children shapes
|
// draw all the children shapes
|
||||||
|
|
|
@ -51,6 +51,7 @@ pub struct Shape {
|
||||||
pub selrect: math::Rect,
|
pub selrect: math::Rect,
|
||||||
pub transform: Matrix,
|
pub transform: Matrix,
|
||||||
pub rotation: f32,
|
pub rotation: f32,
|
||||||
|
pub clip_content: bool,
|
||||||
fills: Vec<Fill>,
|
fills: Vec<Fill>,
|
||||||
pub blend_mode: BlendMode,
|
pub blend_mode: BlendMode,
|
||||||
pub opacity: f32,
|
pub opacity: f32,
|
||||||
|
@ -66,6 +67,7 @@ impl Shape {
|
||||||
selrect: math::Rect::new_empty(),
|
selrect: math::Rect::new_empty(),
|
||||||
transform: Matrix::identity(),
|
transform: Matrix::identity(),
|
||||||
rotation: 0.,
|
rotation: 0.,
|
||||||
|
clip_content: true,
|
||||||
fills: vec![],
|
fills: vec![],
|
||||||
blend_mode: BlendMode::default(),
|
blend_mode: BlendMode::default(),
|
||||||
opacity: 1.,
|
opacity: 1.,
|
||||||
|
|
Loading…
Reference in a new issue