mirror of
https://github.com/penpot/penpot.git
synced 2025-05-29 18:46:11 +02:00
💄 Remove no longer used functions in wasm serialization
This commit is contained in:
parent
f500a00d04
commit
b41a7b8547
3 changed files with 8 additions and 24 deletions
|
@ -51,16 +51,6 @@
|
|||
(def GRID-LAYOUT-COLUMN-ENTRY-SIZE 5)
|
||||
(def GRID-LAYOUT-CELL-ENTRY-SIZE 37)
|
||||
|
||||
;; FIXME: use `gradient-byte-size` instead
|
||||
(defn gradient-stop-get-entries-size
|
||||
[stops]
|
||||
(mem/get-list-size stops sr-fills/GRADIENT-STOP-SIZE))
|
||||
|
||||
(defn gradient-byte-size
|
||||
[gradient]
|
||||
(let [stops (:stops gradient)]
|
||||
(+ sr-fills/GRADIENT-BASE-SIZE (* (count stops) sr-fills/GRADIENT-STOP-SIZE))))
|
||||
|
||||
(defn modifier-get-entries-size
|
||||
"Returns the list of a modifier list in bytes"
|
||||
[modifiers]
|
||||
|
@ -234,7 +224,7 @@
|
|||
(h/call wasm/internal-module "_add_shape_solid_fill" rgba))
|
||||
|
||||
(some? gradient)
|
||||
(let [size (gradient-byte-size gradient)
|
||||
(let [size (sr-fills/gradient-byte-size gradient)
|
||||
offset (mem/alloc-bytes size)
|
||||
heap (mem/get-heap-u32)]
|
||||
(sr-fills/serialize-gradient-fill gradient opacity heap offset)
|
||||
|
@ -280,7 +270,7 @@
|
|||
|
||||
(cond
|
||||
(some? gradient)
|
||||
(let [size (gradient-byte-size gradient)
|
||||
(let [size (sr-fills/gradient-byte-size gradient)
|
||||
offset (mem/alloc-bytes size)
|
||||
heap (mem/get-heap-u32)]
|
||||
(sr-fills/serialize-gradient-fill gradient opacity heap offset)
|
||||
|
|
|
@ -8,15 +8,4 @@
|
|||
(let [rgb (js/parseInt (subs hex 1) 16)
|
||||
a (mth/floor (* (or opacity 1) 0xff))]
|
||||
;; rgba >>> 0 so we have an unsigned representation
|
||||
(unsigned-bit-shift-right (bit-or (bit-shift-left a 24) rgb) 0)))
|
||||
|
||||
(defn rgba-bytes-from-hex
|
||||
"Takes a hex color in #rrggbb format, and an opacity value from 0 to 1 and returns an array with its r g b a values"
|
||||
[hex opacity]
|
||||
(let [rgb (js/parseInt (subs hex 1) 16)
|
||||
a (mth/floor (* (or opacity 1) 0xff))
|
||||
;; rgba >>> 0 so we have an unsigned representation
|
||||
r (bit-shift-right rgb 16)
|
||||
g (bit-and (bit-shift-right rgb 8) 255)
|
||||
b (bit-and rgb 255)]
|
||||
[r g b a]))
|
||||
(unsigned-bit-shift-right (bit-or (bit-shift-left a 24) rgb) 0)))
|
|
@ -6,6 +6,11 @@
|
|||
(def GRADIENT-STOP-SIZE 8)
|
||||
(def GRADIENT-BASE-SIZE 24)
|
||||
|
||||
(defn gradient-byte-size
|
||||
[gradient]
|
||||
(let [stops (:stops gradient)]
|
||||
(+ GRADIENT-BASE-SIZE (* (count stops) GRADIENT-STOP-SIZE))))
|
||||
|
||||
(defn serialize-gradient-fill
|
||||
[gradient opacity heap offset]
|
||||
(let [dview (js/DataView. (.-buffer heap))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue