From a050a21fae0c2a72f3f606d451785a62f480caf3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elena=20Torr=C3=B3?= Date: Tue, 17 Nov 2026 07:58:10 +0100 Subject: [PATCH] :bug: Omit board fill on WASM export when Show in exports is off (#13073) Send the flag to render-wasm and drop the root's fills while it renders. Closes #12930 AI-assisted-by: claude-opus-5.5 --- .../app/common/render_wasm/api/upload.cljs | 5 ++- frontend/src/app/main/data/exports/wasm.cljs | 2 +- .../main/data/workspace/thumbnails_wasm.cljs | 2 +- frontend/src/app/render_wasm/api.cljs | 12 +++++-- frontend/src/app/render_wasm/shape.cljs | 3 ++ render-wasm/src/main.rs | 15 ++++++-- render-wasm/src/math/bools.rs | 6 +--- render-wasm/src/render/pdf.rs | 18 +++++----- render-wasm/src/render/pdf/to_unicode.rs | 2 +- render-wasm/src/shapes.rs | 6 ++++ render-wasm/src/state.rs | 27 ++++++++++---- render-wasm/src/state/shapes_pool.rs | 36 +++++++++++++++++++ render-wasm/src/tiles.rs | 3 +- render-wasm/src/wasm/fills.rs | 6 ++-- render-wasm/src/wasm/shapes/base_props.rs | 6 ++++ render-wasm/src/wasm/text/helpers.rs | 28 +++++---------- render-wasm/src/wasm/ui.rs | 6 ++-- 17 files changed, 131 insertions(+), 52 deletions(-) diff --git a/common/src/app/common/render_wasm/api/upload.cljs b/common/src/app/common/render_wasm/api/upload.cljs index 8f53145b05..146de90edf 100644 --- a/common/src/app/common/render_wasm/api/upload.cljs +++ b/common/src/app/common/render_wasm/api/upload.cljs @@ -27,6 +27,7 @@ (def ^:const BASE-PROPS-SIZE 104) (def ^:const FLAG-CLIP-CONTENT 0x01) (def ^:const FLAG-HIDDEN 0x02) +(def ^:const FLAG-HIDE-FILL-ON-EXPORT 0x04) (def ^:const SECTION-CHILDREN 0x01) (def ^:const SECTION-BLUR-LAYER 0x02) @@ -61,9 +62,11 @@ (not (get shape :show-content)) false) hidden (get shape :hidden false) + hide-fill (get shape :hide-fill-on-export false) flags (cond-> 0 clip-content (bit-or FLAG-CLIP-CONTENT) - hidden (bit-or FLAG-HIDDEN)) + hidden (bit-or FLAG-HIDDEN) + hide-fill (bit-or FLAG-HIDE-FILL-ON-EXPORT)) blend-mode (sr/translate-blend-mode (get shape :blend-mode)) constraint-h (sr/translate-constraint-h (or (get shape :constraints-h) :none)) constraint-v (sr/translate-constraint-v (or (get shape :constraints-v) :none)) diff --git a/frontend/src/app/main/data/exports/wasm.cljs b/frontend/src/app/main/data/exports/wasm.cljs index b23556474a..f6e6b4aab8 100644 --- a/frontend/src/app/main/data/exports/wasm.cljs +++ b/frontend/src/app/main/data/exports/wasm.cljs @@ -55,7 +55,7 @@ :pdf (wasm.api/render-shape-pdf object-id) :svg (wasm.api/render-shape-svg object-id scale) (if (= :client (wasm.api/export-target object-id scale type)) - (wasm.api/render-shape-pixels object-id scale type) + (wasm.api/render-shape-pixels object-id scale type true) (wasm.api/render-shape-raster object-id scale type))))) (defn export-image-uri diff --git a/frontend/src/app/main/data/workspace/thumbnails_wasm.cljs b/frontend/src/app/main/data/workspace/thumbnails_wasm.cljs index b5b78b92c5..d11a040e1f 100644 --- a/frontend/src/app/main/data/workspace/thumbnails_wasm.cljs +++ b/frontend/src/app/main/data/workspace/thumbnails_wasm.cljs @@ -70,7 +70,7 @@ scale (mth/max 1 (/ target-size max-size)) ;; Thumbnails are always PNG: they need the alpha ;; channel and are consumed as a `image/png` data uri. - png-bytes (wasm.api/render-shape-pixels frame-id scale :png)] + png-bytes (wasm.api/render-shape-pixels frame-id scale :png false)] (if (or (nil? png-bytes) (zero? (.-length png-bytes))) (do (l/error :hint "render-shape-pixels returned empty" :frame-id (str frame-id)) diff --git a/frontend/src/app/render_wasm/api.cljs b/frontend/src/app/render_wasm/api.cljs index d9ad59efc5..612f9756fc 100644 --- a/frontend/src/app/render_wasm/api.cljs +++ b/frontend/src/app/render_wasm/api.cljs @@ -1130,6 +1130,10 @@ [hidden] (h/call wasm/internal-module "_set_shape_hidden" hidden)) +(defn set-shape-hide-fill-on-export + [hide] + (h/call wasm/internal-module "_set_shape_hide_fill_on_export" hide)) + (defn clear-shape-fills! "Clear the fills of the currently-selected shape (call `use-shape` first). Equivalent to `set-shape-fills` with an empty collection." @@ -2934,8 +2938,9 @@ (defn render-shape-pixels "Renders a shape subtree to encoded image bytes on the GPU export surface. `format` is :png, :jpeg or :webp; jpeg is flattened onto white on the Rust - side, since it has no alpha channel." - [shape-id scale format] + side, since it has no alpha channel. With `export?` the root drops its + fills when it hides them on export." + [shape-id scale format export?] (when (initialized?) (let [buffer (uuid/get-u32 shape-id) offset (h/call wasm/internal-module "_render_shape_pixels" @@ -2944,7 +2949,8 @@ (aget buffer 2) (aget buffer 3) scale - (sr/translate-raster-format format))] + (sr/translate-raster-format format) + export?)] (read-raster-result offset)))) (defn render-shape-raster diff --git a/frontend/src/app/render_wasm/shape.cljs b/frontend/src/app/render_wasm/shape.cljs index dfbcf37bb4..7190062f9f 100644 --- a/frontend/src/app/render_wasm/shape.cljs +++ b/frontend/src/app/render_wasm/shape.cljs @@ -191,6 +191,9 @@ :hidden (api/set-shape-hidden v) + :hide-fill-on-export + (api/set-shape-hide-fill-on-export (boolean v)) + :shapes (api/set-shape-children v) diff --git a/render-wasm/src/main.rs b/render-wasm/src/main.rs index fe38624844..239594020e 100644 --- a/render-wasm/src/main.rs +++ b/render-wasm/src/main.rs @@ -588,6 +588,15 @@ pub extern "C" fn set_shape_hidden(hidden: bool) -> Result<()> { Ok(()) } +#[no_mangle] +#[wasm_error] +pub extern "C" fn set_shape_hide_fill_on_export(hide: bool) -> Result<()> { + with_current_shape_mut!(state, |shape: &mut Shape| { + shape.set_hide_fill_on_export(hide); + }); + Ok(()) +} + #[no_mangle] #[wasm_error] pub extern "C" fn set_shape_corners(r1: f32, r2: f32, r3: f32, r4: f32) -> Result<()> { @@ -775,7 +784,8 @@ pub extern "C" fn get_shape_extrect(a: u32, b: u32, c: u32, d: u32) -> Result<*m /// Raster image via the GPU surface. Returns `[len][width][height][bytes]` /// (LE). `format` selects the encoder: 0 = PNG, 1 = JPEG, 2 = WEBP (see -/// `RasterFormat`). +/// `RasterFormat`). `export` drops the root's fills when it hides them on +/// export; thumbnails keep them. #[no_mangle] #[wasm_error] pub extern "C" fn render_shape_pixels( @@ -785,6 +795,7 @@ pub extern "C" fn render_shape_pixels( d: u32, scale: f32, format: u32, + export: bool, ) -> Result<*mut u8> { let id = uuid_from_u32_quartet(a, b, c, d); @@ -796,7 +807,7 @@ pub extern "C" fn render_shape_pixels( with_state!(state, { let (data, width, height) = - state.render_shape_pixels(&id, scale, performance::get_time(), format)?; + state.render_shape_pixels(&id, scale, performance::get_time(), format, export)?; let len = data.len() as u32; let mut buf = Vec::with_capacity(4 + data.len()); diff --git a/render-wasm/src/math/bools.rs b/render-wasm/src/math/bools.rs index cb300d83d9..653ab6cc8f 100644 --- a/render-wasm/src/math/bools.rs +++ b/render-wasm/src/math/bools.rs @@ -419,11 +419,7 @@ fn beziers_to_segments(beziers: &[(BezierSource, Bezier)]) -> Vec { let mut last_end = (first_bezier.end.x as f32, first_bezier.end.y as f32); let mut cur_end = first_bezier.end; - loop { - let Some((next_src, next_bezier)) = find_next_in_pool(&mut pool, cur_end, cur_src) - else { - break; - }; + while let Some((next_src, next_bezier)) = find_next_in_pool(&mut pool, cur_end, cur_src) { push_bezier(&mut result, &next_bezier); last_end = (next_bezier.end.x as f32, next_bezier.end.y as f32); cur_end = next_bezier.end; diff --git a/render-wasm/src/render/pdf.rs b/render-wasm/src/render/pdf.rs index 746b26242d..29ddd4f863 100644 --- a/render-wasm/src/render/pdf.rs +++ b/render-wasm/src/render/pdf.rs @@ -3,7 +3,7 @@ use std::mem::ManuallyDrop; use skia_safe as skia; use crate::error::{Error, Result}; -use crate::state::ShapesPoolRef; +use crate::state::{ShapesPoolMutRef, ShapesPoolRef}; use crate::uuid::Uuid; use super::vector; @@ -143,7 +143,7 @@ pub fn export_abort(slot: &mut Option) { pub fn render_to_pdf( shared: &mut RenderResources, id: &Uuid, - tree: ShapesPoolRef, + tree: ShapesPoolMutRef, ) -> Result> { render_to_pdf_multi(shared, &[*id], tree) } @@ -154,7 +154,7 @@ pub fn render_to_pdf( pub fn render_to_pdf_multi( shared: &mut RenderResources, ids: &[Uuid], - tree: ShapesPoolRef, + tree: ShapesPoolMutRef, ) -> Result> { if ids.is_empty() { return Err(Error::CriticalError( @@ -164,7 +164,9 @@ pub fn render_to_pdf_multi( let mut session = None; export_begin(&mut session)?; for id in ids { - if let Err(err) = export_add_page(&mut session, shared, id, tree) { + let page = + tree.with_export_root(id, |tree| export_add_page(&mut session, shared, id, tree)); + if let Err(err) = page { export_abort(&mut session); return Err(err); } @@ -234,7 +236,7 @@ mod tests { let mut resources = RenderResources::try_new_headless().expect("headless resources"); let _guard = crate::globals::TestRenderResourcesGuard::install(&mut resources); - let pdf = render_to_pdf_multi(&mut resources, &[a, b], &pool).expect("pdf"); + let pdf = render_to_pdf_multi(&mut resources, &[a, b], &mut pool).expect("pdf"); assert!(pdf.starts_with(b"%PDF"), "missing PDF header"); assert_eq!(page_count(&pdf), 2, "expected two pages"); } @@ -270,11 +272,11 @@ mod tests { #[test] fn empty_id_list_is_an_error() { - let pool = ShapesPool::new(); + let mut pool = ShapesPool::new(); let mut resources = RenderResources::try_new_headless().expect("headless resources"); let _guard = crate::globals::TestRenderResourcesGuard::install(&mut resources); - let err = render_to_pdf_multi(&mut resources, &[], &pool).expect_err("empty"); + let err = render_to_pdf_multi(&mut resources, &[], &mut pool).expect_err("empty"); assert!( matches!(err, Error::CriticalError(_)), "empty ids must fail critically: {err:?}" @@ -295,7 +297,7 @@ mod tests { let mut resources = RenderResources::try_new_headless().expect("headless resources"); let _guard = crate::globals::TestRenderResourcesGuard::install(&mut resources); - let pdf = render_to_pdf(&mut resources, &id, &pool).expect("pdf"); + let pdf = render_to_pdf(&mut resources, &id, &mut pool).expect("pdf"); assert!(pdf.starts_with(b"%PDF")); assert_eq!(page_count(&pdf), 1); } diff --git a/render-wasm/src/render/pdf/to_unicode.rs b/render-wasm/src/render/pdf/to_unicode.rs index ffb36f233e..412e6aea85 100644 --- a/render-wasm/src/render/pdf/to_unicode.rs +++ b/render-wasm/src/render/pdf/to_unicode.rs @@ -781,7 +781,7 @@ mod tests { .add(family, LIGATURE_FONT, false, false) .expect("ligature font"); let _guard = crate::globals::TestRenderResourcesGuard::install(&mut resources); - let pdf = super::super::render_to_pdf(&mut resources, &id, &pool).expect("pdf"); + let pdf = super::super::render_to_pdf(&mut resources, &id, &mut pool).expect("pdf"); let trailer = parse_xref(&pdf).expect("xref").trailer; assert!( diff --git a/render-wasm/src/shapes.rs b/render-wasm/src/shapes.rs index 6a157a1c13..c8d218dd9b 100644 --- a/render-wasm/src/shapes.rs +++ b/render-wasm/src/shapes.rs @@ -191,6 +191,7 @@ pub struct Shape { pub background_blur: Option, pub opacity: f32, pub hidden: bool, + pub hide_fill_on_export: bool, pub svg: Option, pub svg_attrs: Option, pub shadows: Vec, @@ -295,6 +296,7 @@ impl Shape { vertical_align: VerticalAlign::Top, opacity: 1., hidden: false, + hide_fill_on_export: false, blur: None, background_blur: None, svg: None, @@ -466,6 +468,10 @@ impl Shape { self.hidden = value; } + pub fn set_hide_fill_on_export(&mut self, value: bool) { + self.hide_fill_on_export = value; + } + pub fn svg_transform(&self) -> Option { self.svg_transform } diff --git a/render-wasm/src/state.rs b/render-wasm/src/state.rs index 97296058b0..eadfd7616f 100644 --- a/render-wasm/src/state.rs +++ b/render-wasm/src/state.rs @@ -98,16 +98,24 @@ impl State { scale: f32, timestamp: i32, format: RasterFormat, + export: bool, ) -> Result<(Vec, i32, i32)> { - get_render_state().render_shape_pixels(id, &self.shapes, scale, timestamp, format) + let render = |tree: &ShapesPool| { + get_render_state().render_shape_pixels(id, tree, scale, timestamp, format) + }; + if export { + self.shapes.with_export_root(id, render) + } else { + render(&self.shapes) + } } pub fn render_shape_pdf(&mut self, id: &Uuid) -> Result> { - crate::render::pdf::render_to_pdf(get_resources(), id, &self.shapes) + crate::render::pdf::render_to_pdf(get_resources(), id, &mut self.shapes) } pub fn render_shapes_pdf(&mut self, ids: &[Uuid]) -> Result> { - crate::render::pdf::render_to_pdf_multi(get_resources(), ids, &self.shapes) + crate::render::pdf::render_to_pdf_multi(get_resources(), ids, &mut self.shapes) } pub fn pdf_export_begin(&mut self) -> Result<()> { @@ -115,7 +123,10 @@ impl State { } pub fn pdf_export_add_page(&mut self, id: &Uuid) -> Result<()> { - crate::render::pdf::export_add_page(&mut self.pdf_export, get_resources(), id, &self.shapes) + let session = &mut self.pdf_export; + self.shapes.with_export_root(id, |tree| { + crate::render::pdf::export_add_page(session, get_resources(), id, tree) + }) } pub fn pdf_export_finish(&mut self) -> Result> { @@ -127,7 +138,9 @@ impl State { } pub fn render_shape_svg(&mut self, id: &Uuid, scale: f32) -> Result> { - crate::render::svg::render_to_svg(get_resources(), id, &self.shapes, scale) + self.shapes.with_export_root(id, |tree| { + crate::render::svg::render_to_svg(get_resources(), id, tree, scale) + }) } pub fn render_shapes_svg(&mut self, ids: &[Uuid], scale: f32) -> Result> { @@ -142,7 +155,9 @@ impl State { scale: f32, format: RasterFormat, ) -> Result<(Vec, i32, i32)> { - crate::render::raster::render_to_raster(get_resources(), id, &self.shapes, scale, format) + self.shapes.with_export_root(id, |tree| { + crate::render::raster::render_to_raster(get_resources(), id, tree, scale, format) + }) } /// Distinct font families used by the (visible) subtree rooted at `id`, in diff --git a/render-wasm/src/state/shapes_pool.rs b/render-wasm/src/state/shapes_pool.rs index cd9542068a..e4ee3d22c3 100644 --- a/render-wasm/src/state/shapes_pool.rs +++ b/render-wasm/src/state/shapes_pool.rs @@ -142,6 +142,24 @@ impl ShapesPoolImpl { self.uuid_to_idx.contains_key(id) } + /// Runs `render` with the fills of `id` removed when it hides them on + /// export. Only the exported board applies the flag; nested boards keep + /// their fills. + pub fn with_export_root(&mut self, id: &Uuid, render: impl FnOnce(&Self) -> T) -> T { + let hide = self.get(id).is_some_and(|shape| shape.hide_fill_on_export); + let fills = if hide { + self.get_mut(id) + .map(|shape| std::mem::take(&mut shape.fills)) + } else { + None + }; + let result = render(self); + if let (Some(fills), Some(shape)) = (fills, self.get_mut(id)) { + shape.fills = fills; + } + result + } + pub fn get_mut(&mut self, id: &Uuid) -> Option<&mut Shape> { let idx = *self.uuid_to_idx.get(id)?; // The caller may change the shape, so its modified copy goes stale. @@ -611,6 +629,24 @@ mod tests { (pool, parent, child) } + #[test] + fn with_export_root_hides_only_the_root_fills() { + let (mut pool, parent, child) = pool_with_parent_and_child(); + let fills = vec![shapes::Fill::Solid(shapes::SolidColor(skia::Color::RED))]; + for id in [parent, child] { + let shape = pool.get_mut(&id).expect("shape"); + shape.set_fills(fills.clone()); + shape.set_hide_fill_on_export(true); + } + + pool.with_export_root(&parent, |tree| { + assert!(tree.get(&parent).expect("parent").fills.is_empty()); + assert_eq!(tree.get(&child).expect("child").fills, fills); + }); + + assert_eq!(pool.get(&parent).expect("parent").fills, fills); + } + #[test] fn set_modifiers_passes_a_move_down_to_children() { let (mut pool, parent, child) = pool_with_parent_and_child(); diff --git a/render-wasm/src/tiles.rs b/render-wasm/src/tiles.rs index 8180266fb9..2dbfec39b4 100644 --- a/render-wasm/src/tiles.rs +++ b/render-wasm/src/tiles.rs @@ -444,7 +444,8 @@ impl PendingTiles { // Farthest first, since we use pop() to process the tiles // in order of priority (closest first) - self.tile_order.sort_unstable_by(|a, b| b.0.cmp(&a.0)); + self.tile_order + .sort_unstable_by_key(|a| std::cmp::Reverse(a.0)); for (_, tile) in self.tile_order.iter() { let tile = *tile; diff --git a/render-wasm/src/wasm/fills.rs b/render-wasm/src/wasm/fills.rs index 28ff005bec..c09c61c97c 100644 --- a/render-wasm/src/wasm/fills.rs +++ b/render-wasm/src/wasm/fills.rs @@ -87,10 +87,12 @@ impl TryFrom<&[u8]> for RawFillData { // FIXME: return Result pub fn read_fills_from_bytes(buffer: &[u8], num_fills: usize) -> Vec { buffer - .chunks_exact(RAW_FILL_DATA_SIZE) + .as_chunks::() + .0 + .iter() .take(num_fills) .map(|bytes| { - RawFillData::try_from(bytes) + RawFillData::try_from(bytes.as_slice()) .expect("Invalid fill data") .into() }) diff --git a/render-wasm/src/wasm/shapes/base_props.rs b/render-wasm/src/wasm/shapes/base_props.rs index 9ab65f78fe..826876ec75 100644 --- a/render-wasm/src/wasm/shapes/base_props.rs +++ b/render-wasm/src/wasm/shapes/base_props.rs @@ -11,6 +11,7 @@ use super::RawShapeType; const FLAG_CLIP_CONTENT: u8 = 0b0000_0001; const FLAG_HIDDEN: u8 = 0b0000_0010; +const FLAG_HIDE_FILL_ON_EXPORT: u8 = 0b0000_0100; pub(crate) const RAW_BASE_PROPS_SIZE: usize = std::mem::size_of::(); @@ -78,6 +79,10 @@ impl RawBasePropsData { (self.flags & FLAG_HIDDEN) != 0 } + fn hide_fill_on_export(&self) -> bool { + (self.flags & FLAG_HIDE_FILL_ON_EXPORT) != 0 + } + fn blend_mode(&self) -> BlendMode { RawBlendMode::from(self.blend_mode).into() } @@ -112,6 +117,7 @@ pub(crate) fn apply_base_props(raw: &RawBasePropsData) -> Result<()> { shape.set_shape_type(shape_type.into()); shape.set_clip(raw.clip_content()); shape.set_hidden(raw.hidden()); + shape.set_hide_fill_on_export(raw.hide_fill_on_export()); shape.set_blend_mode(raw.blend_mode()); shape.set_opacity(raw.opacity); shape.set_constraint_h(raw.constraint_h()); diff --git a/render-wasm/src/wasm/text/helpers.rs b/render-wasm/src/wasm/text/helpers.rs index f9ccfebdd0..9b7b2b469f 100644 --- a/render-wasm/src/wasm/text/helpers.rs +++ b/render-wasm/src/wasm/text/helpers.rs @@ -297,12 +297,9 @@ pub fn replace_text_with_newlines( let mut current_cursor = *cursor; - if let Some(new_offset) = replace_text_at_cursor(text_content, ¤t_cursor, lines[0]) { - current_cursor = - TextPositionWithAffinity::new_downstream_affinity(current_cursor.paragraph, new_offset); - } else { - return None; - } + let new_offset = replace_text_at_cursor(text_content, ¤t_cursor, lines[0])?; + current_cursor = + TextPositionWithAffinity::new_downstream_affinity(current_cursor.paragraph, new_offset); for line in lines.iter().skip(1) { if !split_paragraph_at_cursor(text_content, ¤t_cursor) { @@ -336,12 +333,9 @@ pub fn insert_text_with_newlines( let mut current_cursor = *cursor; - if let Some(new_offset) = insert_text_at_cursor(text_content, ¤t_cursor, lines[0]) { - current_cursor = - TextPositionWithAffinity::new_downstream_affinity(current_cursor.paragraph, new_offset); - } else { - return None; - } + let new_offset = insert_text_at_cursor(text_content, ¤t_cursor, lines[0])?; + current_cursor = + TextPositionWithAffinity::new_downstream_affinity(current_cursor.paragraph, new_offset); for line in lines.iter().skip(1) { if !split_paragraph_at_cursor(text_content, ¤t_cursor) { @@ -477,8 +471,7 @@ pub fn delete_selection_range(text_content: &mut TextContent, selection: &TextSe delete_range_in_paragraph(&mut paragraphs[end_paragraph], 0, end.offset); - let end_para_children: Vec<_> = - paragraphs[end_paragraph].children_mut().drain(..).collect(); + let end_para_children = std::mem::take(paragraphs[end_paragraph].children_mut()); paragraphs[start.paragraph] .children_mut() .extend(end_para_children); @@ -593,10 +586,7 @@ pub fn delete_char_before( let paragraphs = text_content.paragraphs_mut(); let prev_para_len = paragraph_char_count(¶graphs[prev_para_idx]); - let current_children: Vec<_> = paragraphs[cursor.paragraph] - .children_mut() - .drain(..) - .collect(); + let current_children = std::mem::take(paragraphs[cursor.paragraph].children_mut()); paragraphs[prev_para_idx] .children_mut() .extend(current_children); @@ -770,7 +760,7 @@ pub fn delete_char_after(text_content: &mut TextContent, cursor: &TextPositionWi delete_range_in_paragraph(para, cursor.offset, end); } else if cursor.paragraph < paragraphs.len() - 1 { let next_para_idx = cursor.paragraph + 1; - let next_children: Vec<_> = paragraphs[next_para_idx].children_mut().drain(..).collect(); + let next_children = std::mem::take(paragraphs[next_para_idx].children_mut()); paragraphs[cursor.paragraph] .children_mut() .extend(next_children); diff --git a/render-wasm/src/wasm/ui.rs b/render-wasm/src/wasm/ui.rs index 3ef343618c..f63bccfd2d 100644 --- a/render-wasm/src/wasm/ui.rs +++ b/render-wasm/src/wasm/ui.rs @@ -76,11 +76,13 @@ impl TryFrom<&[u8]> for RawGuide { fn read_guides_from_bytes(buffer: &[u8], count: usize) -> Result> { buffer - .chunks_exact(RAW_GUIDE_SIZE) + .as_chunks::() + .0 + .iter() .take(count) .enumerate() .map(|(i, bytes)| { - RawGuide::try_from(bytes).map(|raw_guide| { + RawGuide::try_from(bytes.as_slice()).map(|raw_guide| { let mut guide: Guide = raw_guide.into(); guide.index = i; guide