0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-01-06 14:50:20 -05:00

Merge pull request #5409 from penpot/superalex-hidden-layer-support-for-wasm-render

🎉 Hidden layer support for wasm render
This commit is contained in:
Belén Albeza 2024-12-05 15:42:02 +01:00 committed by GitHub
commit b332f128b0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 20 additions and 3 deletions

View file

@ -216,6 +216,10 @@
[opacity]
(h/call internal-module "_set_shape_opacity" (or opacity 1)))
(defn set-shape-hidden
[hidden]
(h/call internal-module "_set_shape_hidden" hidden))
(def debounce-render-without-cache (fns/debounce render-without-cache 100))
(defn set-view
@ -239,7 +243,9 @@
fills (dm/get-prop shape :fills)
children (dm/get-prop shape :shapes)
blend-mode (dm/get-prop shape :blend-mode)
opacity (dm/get-prop shape :opacity)]
opacity (dm/get-prop shape :opacity)
hidden (dm/get-prop shape :hidden)]
(use-shape id)
(set-shape-selrect selrect)
(set-shape-rotation rotation)
@ -247,6 +253,7 @@
(set-shape-blend-mode blend-mode)
(set-shape-children children)
(set-shape-opacity opacity)
(set-shape-hidden hidden)
(let [pending-fills (doall (set-shape-fills fills))]
(recur (inc index) (into pending pending-fills))))
pending))]
@ -263,7 +270,6 @@
:stencil true
:alpha true})
(defn clear-canvas
[]
;; TODO: perform corresponding cleaning

View file

@ -118,6 +118,7 @@
:fills (api/set-shape-fills v)
:blend-mode (api/set-shape-blend-mode v)
:opacity (api/set-shape-opacity v)
:hidden (api/set-shape-hidden v)
:shapes (api/set-shape-children v)
nil)
;; when something synced with wasm

View file

@ -263,6 +263,14 @@ pub extern "C" fn set_shape_opacity(opacity: f32) {
}
}
#[no_mangle]
pub extern "C" fn set_shape_hidden(hidden: bool) {
let state = unsafe { STATE.as_mut() }.expect("got an invalid state pointer");
if let Some(shape) = state.current_shape() {
shape.hidden = hidden;
}
}
fn main() {
init_gl();
}

View file

@ -389,7 +389,7 @@ impl RenderState {
let mut is_complete = self.viewbox.area.contains(shape.selrect);
if !id.is_nil() {
if !shape.selrect.intersects(self.viewbox.area) {
if !shape.selrect.intersects(self.viewbox.area) || shape.hidden {
self.render_debug_shape(shape, false);
// TODO: This means that not all the shapes are renderer so we
// need to call a render_all on the zoom out.

View file

@ -51,6 +51,7 @@ pub struct Shape {
fills: Vec<Fill>,
pub blend_mode: BlendMode,
pub opacity: f32,
pub hidden: bool,
}
impl Shape {
@ -65,6 +66,7 @@ impl Shape {
fills: vec![],
blend_mode: BlendMode::default(),
opacity: 1.,
hidden: false,
}
}