Merge pull request #5343 from penpot/azazeln28-render-only-visible-shapes

🎉  Render only visible shapes
This commit is contained in:
Belén Albeza 2024-11-21 17:40:24 +01:00 committed by GitHub
commit 361c56fd9c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
13 changed files with 248 additions and 122 deletions

View file

@ -285,6 +285,10 @@
(fn []
(wasm.api/clear-canvas))))
(mf/with-effect [vport]
(when @canvas-init?
(wasm.api/resize-canvas (:width vport) (:height vport))))
(mf/with-effect [base-objects canvas-init?]
(when @canvas-init?
(wasm.api/set-objects base-objects)))

View file

@ -120,13 +120,13 @@
;; https://rust-skia.github.io/doc/skia_safe/enum.BlendMode.html
(h/call internal-module "_set_shape_blend_mode" (translate-blend-mode blend-mode)))
(def debounce_render (fns/debounce render 100))
(def debounce-render (fns/debounce render 100))
(defn set-view
[zoom vbox]
(h/call internal-module "_set_view" zoom (- (:x vbox)) (- (:y vbox)) (:width vbox) (:height vbox))
(h/call internal-module "_set_view" zoom (- (:x vbox)) (- (:y vbox)))
(h/call internal-module "_navigate")
(debounce_render))
(debounce-render))
(defn set-objects
[objects]
@ -163,6 +163,10 @@
;; TODO: perform corresponding cleaning
)
(defn resize-canvas
[width height]
(h/call internal-module "_resize_canvas" width height))
(defn assign-canvas
[canvas]
(let [gl (unchecked-get internal-module "GL")
@ -175,7 +179,8 @@
(.makeContextCurrent ^js gl handle)
;; Initialize Skia
(^function init-fn (.-width ^js canvas)
(.-height ^js canvas))
(.-height ^js canvas)
1)
(set! (.-width canvas) (.-clientWidth ^js canvas))
(set! (.-height canvas) (.-clientHeight ^js canvas))))