mirror of
https://github.com/penpot/penpot.git
synced 2025-05-29 09:26:11 +02:00
♻️ Use a single byte to store gradient stop count (wasm)
This commit is contained in:
parent
86a498fc29
commit
8e18a0880e
2 changed files with 5 additions and 3 deletions
|
@ -25,7 +25,7 @@
|
|||
(.setFloat32 dview (+ offset 12) end-y true)
|
||||
(.setFloat32 dview (+ offset 16) opacity true)
|
||||
(.setFloat32 dview (+ offset 20) width true)
|
||||
(.setUint32 dview (+ offset 24) (count stops) true)
|
||||
(.setUint8 dview (+ offset 24) (count stops) true)
|
||||
(loop [stops (seq stops) offset (+ offset GRADIENT-BASE-SIZE)]
|
||||
(if (empty? stops)
|
||||
offset
|
||||
|
|
|
@ -17,7 +17,8 @@ pub struct RawGradientData {
|
|||
end_y: f32,
|
||||
opacity: f32,
|
||||
width: f32,
|
||||
stop_count: u32,
|
||||
stop_count: u8,
|
||||
_padding: [u8; 3],
|
||||
stops: [RawStopData; MAX_GRADIENT_STOPS],
|
||||
}
|
||||
|
||||
|
@ -30,7 +31,8 @@ impl From<[u8; RAW_GRADIENT_DATA_SIZE]> for RawGradientData {
|
|||
end_y: f32::from_le_bytes([bytes[12], bytes[13], bytes[14], bytes[15]]),
|
||||
opacity: f32::from_le_bytes([bytes[16], bytes[17], bytes[18], bytes[19]]),
|
||||
width: f32::from_le_bytes([bytes[20], bytes[21], bytes[22], bytes[23]]),
|
||||
stop_count: u32::from_le_bytes([bytes[24], bytes[25], bytes[26], bytes[27]]),
|
||||
stop_count: bytes[24],
|
||||
_padding: [0; 3],
|
||||
// FIXME: 2025-04-22: use `array_chunks` once the next release is out
|
||||
// and we update our devenv.
|
||||
// See https://github.com/rust-lang/rust/issues/74985
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue