mirror of
https://github.com/penpot/penpot.git
synced 2025-05-31 20:36:21 +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-COLUMN-ENTRY-SIZE 5)
|
||||||
(def GRID-LAYOUT-CELL-ENTRY-SIZE 37)
|
(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
|
(defn modifier-get-entries-size
|
||||||
"Returns the list of a modifier list in bytes"
|
"Returns the list of a modifier list in bytes"
|
||||||
[modifiers]
|
[modifiers]
|
||||||
|
@ -234,7 +224,7 @@
|
||||||
(h/call wasm/internal-module "_add_shape_solid_fill" rgba))
|
(h/call wasm/internal-module "_add_shape_solid_fill" rgba))
|
||||||
|
|
||||||
(some? gradient)
|
(some? gradient)
|
||||||
(let [size (gradient-byte-size gradient)
|
(let [size (sr-fills/gradient-byte-size gradient)
|
||||||
offset (mem/alloc-bytes size)
|
offset (mem/alloc-bytes size)
|
||||||
heap (mem/get-heap-u32)]
|
heap (mem/get-heap-u32)]
|
||||||
(sr-fills/serialize-gradient-fill gradient opacity heap offset)
|
(sr-fills/serialize-gradient-fill gradient opacity heap offset)
|
||||||
|
@ -280,7 +270,7 @@
|
||||||
|
|
||||||
(cond
|
(cond
|
||||||
(some? gradient)
|
(some? gradient)
|
||||||
(let [size (gradient-byte-size gradient)
|
(let [size (sr-fills/gradient-byte-size gradient)
|
||||||
offset (mem/alloc-bytes size)
|
offset (mem/alloc-bytes size)
|
||||||
heap (mem/get-heap-u32)]
|
heap (mem/get-heap-u32)]
|
||||||
(sr-fills/serialize-gradient-fill gradient opacity heap offset)
|
(sr-fills/serialize-gradient-fill gradient opacity heap offset)
|
||||||
|
|
|
@ -8,15 +8,4 @@
|
||||||
(let [rgb (js/parseInt (subs hex 1) 16)
|
(let [rgb (js/parseInt (subs hex 1) 16)
|
||||||
a (mth/floor (* (or opacity 1) 0xff))]
|
a (mth/floor (* (or opacity 1) 0xff))]
|
||||||
;; rgba >>> 0 so we have an unsigned representation
|
;; rgba >>> 0 so we have an unsigned representation
|
||||||
(unsigned-bit-shift-right (bit-or (bit-shift-left a 24) rgb) 0)))
|
(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]))
|
|
|
@ -6,6 +6,11 @@
|
||||||
(def GRADIENT-STOP-SIZE 8)
|
(def GRADIENT-STOP-SIZE 8)
|
||||||
(def GRADIENT-BASE-SIZE 24)
|
(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
|
(defn serialize-gradient-fill
|
||||||
[gradient opacity heap offset]
|
[gradient opacity heap offset]
|
||||||
(let [dview (js/DataView. (.-buffer heap))
|
(let [dview (js/DataView. (.-buffer heap))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue