mirror of
https://github.com/penpot/penpot.git
synced 2025-05-28 20:26:10 +02:00
✨ Serialize image fills in binary
This commit is contained in:
parent
f30441626e
commit
173d6c23b0
6 changed files with 109 additions and 51 deletions
|
@ -236,17 +236,13 @@
|
|||
(h/call wasm/internal-module "_add_shape_radial_fill")))
|
||||
|
||||
(some? image)
|
||||
(let [id (dm/get-prop image :id)
|
||||
(let [heap (mem/get-heap-u32)
|
||||
offset (mem/alloc-bytes sr-fills/IMAGE-BYTE-SIZE)
|
||||
id (dm/get-prop image :id)
|
||||
buffer (uuid/get-u32 id)
|
||||
cached-image? (h/call wasm/internal-module "_is_image_cached" (aget buffer 0) (aget buffer 1) (aget buffer 2) (aget buffer 3))]
|
||||
(h/call wasm/internal-module "_add_shape_image_fill"
|
||||
(aget buffer 0)
|
||||
(aget buffer 1)
|
||||
(aget buffer 2)
|
||||
(aget buffer 3)
|
||||
opacity
|
||||
(dm/get-prop image :width)
|
||||
(dm/get-prop image :height))
|
||||
(sr-fills/write-image-fill! offset heap id opacity (dm/get-prop image :width) (dm/get-prop image :height))
|
||||
(h/call wasm/internal-module "_add_shape_image_fill")
|
||||
(when (== cached-image? 0)
|
||||
(store-image id))))))
|
||||
fills))
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
(ns app.render-wasm.serializers.fills
|
||||
(:require
|
||||
[app.common.uuid :as uuid]
|
||||
[app.render-wasm.serializers.color :as clr]))
|
||||
|
||||
(def SOLID-BYTE-SIZE 4)
|
||||
|
@ -10,6 +11,22 @@
|
|||
(.setUint32 dview offset argb true)
|
||||
(+ offset 4)))
|
||||
|
||||
(def IMAGE-BYTE-SIZE 28)
|
||||
|
||||
(defn write-image-fill!
|
||||
[offset heap-u32 id opacity width height]
|
||||
(js/console.log "write-image-fill!" (str id) opacity width height)
|
||||
(let [dview (js/DataView. (.-buffer heap-u32))
|
||||
uuid-buffer (uuid/get-u32 id)]
|
||||
(.setUint32 dview offset (aget uuid-buffer 0) true)
|
||||
(.setUint32 dview (+ offset 4) (aget uuid-buffer 1) true)
|
||||
(.setUint32 dview (+ offset 8) (aget uuid-buffer 2) true)
|
||||
(.setUint32 dview (+ offset 12) (aget uuid-buffer 3) true)
|
||||
(.setFloat32 dview (+ offset 16) opacity true)
|
||||
(.setInt32 dview (+ offset 20) width true)
|
||||
(.setInt32 dview (+ offset 24) height true)
|
||||
(+ offset 28)))
|
||||
|
||||
(def ^:private GRADIENT-STOP-SIZE 8)
|
||||
(def ^:private GRADIENT-BASE-SIZE 28)
|
||||
;; TODO: Define in shape model
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue