mirror of
https://github.com/penpot/penpot.git
synced 2025-01-22 14:39:45 -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 3))))
|
||||
|
||||
(defn set-shape-clip-content
|
||||
[clip-content]
|
||||
(h/call internal-module "_set_shape_clip_content" clip-content))
|
||||
|
||||
(defn set-shape-selrect
|
||||
[selrect]
|
||||
(h/call internal-module "_set_shape_selrect"
|
||||
|
@ -250,6 +254,7 @@
|
|||
(let [shape (nth shapes index)
|
||||
type (dm/get-prop shape :type)
|
||||
id (dm/get-prop shape :id)
|
||||
clip-content (not (dm/get-prop shape :show-content))
|
||||
selrect (dm/get-prop shape :selrect)
|
||||
rotation (dm/get-prop shape :rotation)
|
||||
transform (dm/get-prop shape :transform)
|
||||
|
@ -262,6 +267,7 @@
|
|||
content (dm/get-prop shape :content)]
|
||||
|
||||
(use-shape id)
|
||||
(set-shape-clip-content clip-content)
|
||||
(set-shape-selrect selrect)
|
||||
(set-shape-rotation rotation)
|
||||
(set-shape-transform transform)
|
||||
|
|
|
@ -112,6 +112,7 @@
|
|||
(api/use-shape (:id self))
|
||||
(case k
|
||||
:selrect (api/set-shape-selrect v)
|
||||
:show-content (api/set-shape-clip-content (not v))
|
||||
:rotation (api/set-shape-rotation v)
|
||||
:transform (api/set-shape-transform v)
|
||||
:fills (api/set-shape-fills v)
|
||||
|
|
|
@ -111,7 +111,15 @@ pub extern "C" fn set_shape_selrect(left: f32, top: f32, right: f32, bottom: f32
|
|||
}
|
||||
|
||||
#[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");
|
||||
if let Some(shape) = state.current_shape() {
|
||||
shape.rotation = rotation;
|
||||
|
|
|
@ -413,6 +413,13 @@ impl RenderState {
|
|||
|
||||
if !id.is_nil() {
|
||||
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
|
||||
|
|
|
@ -51,6 +51,7 @@ pub struct Shape {
|
|||
pub selrect: math::Rect,
|
||||
pub transform: Matrix,
|
||||
pub rotation: f32,
|
||||
pub clip_content: bool,
|
||||
fills: Vec<Fill>,
|
||||
pub blend_mode: BlendMode,
|
||||
pub opacity: f32,
|
||||
|
@ -66,6 +67,7 @@ impl Shape {
|
|||
selrect: math::Rect::new_empty(),
|
||||
transform: Matrix::identity(),
|
||||
rotation: 0.,
|
||||
clip_content: true,
|
||||
fills: vec![],
|
||||
blend_mode: BlendMode::default(),
|
||||
opacity: 1.,
|
||||
|
|
Loading…
Add table
Reference in a new issue