Merge pull request #5325 from penpot/niwinz-uuid-tweaks

 Improve Uint32 array generation from uuid
This commit is contained in:
Alejandro 2024-11-18 15:47:48 +01:00 committed by GitHub
commit 4e28f1b1f7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 157 additions and 73 deletions

View file

@ -27,13 +27,13 @@
(defn create-shape
[id]
(let [buffer (uuid/uuid->u32 id)
(let [buffer (uuid/get-u32 id)
create-shape (unchecked-get internal-module "_create_shape")]
(^function create-shape (aget buffer 0) (aget buffer 1) (aget buffer 2) (aget buffer 3))))
(defn use-shape
[id]
(let [buffer (uuid/uuid->u32 id)
(let [buffer (uuid/get-u32 id)
use-shape (unchecked-get internal-module "_use_shape")]
(^function use-shape (aget buffer 0) (aget buffer 1) (aget buffer 2) (aget buffer 3))))
@ -68,7 +68,7 @@
add-shape-child (unchecked-get internal-module "_add_shape_child")]
(^function clear-shape-children)
(doseq [id shape_ids]
(let [buffer (uuid/uuid->u32 id)]
(let [buffer (uuid/get-u32 id)]
(^function add-shape-child (aget buffer 0) (aget buffer 1) (aget buffer 2) (aget buffer 3))))))
(defn set-shape-fills

View file

@ -61,14 +61,16 @@
(cancel-idle-callback sem))))))
(def ^:private request-animation-frame
(or (and (exists? js/window) (.-requestAnimationFrame js/window))
#(js/setTimeout % 16)))
(if (and (exists? js/globalThis)
(exists? (.-requestAnimationFrame js/globalThis)))
#(.requestAnimationFrame js/globalThis %)
#(js/setTimeout % 16)))
(defn raf
[f]
(request-animation-frame f))
(^function request-animation-frame f))
(defn idle-then-raf
[f]
(schedule-on-idle #(raf f)))
(schedule-on-idle #(^function raf f)))