bevy hates Rc
diff --git a/crates/encoding/src/glyph_cache.rs b/crates/encoding/src/glyph_cache.rs
index c871d8b..a3e3e2a 100644
--- a/crates/encoding/src/glyph_cache.rs
+++ b/crates/encoding/src/glyph_cache.rs
@@ -2,7 +2,7 @@
// SPDX-License-Identifier: Apache-2.0 OR MIT
use std::collections::HashMap;
-use std::rc::Rc;
+use std::sync::Arc;
use super::{Encoding, StreamOffsets};
@@ -13,7 +13,7 @@
#[derive(Default)]
pub struct GlyphCache {
- free_list: Vec<Rc<Encoding>>,
+ free_list: Vec<Arc<Encoding>>,
map: GlyphMap,
var_map: HashMap<VarKey, GlyphMap>,
cached_count: usize,
@@ -133,7 +133,7 @@
}
pub struct GlyphCacheSession<'a> {
- free_list: &'a mut Vec<Rc<Encoding>>,
+ free_list: &'a mut Vec<Arc<Encoding>>,
map: &'a mut GlyphMap,
font_id: u64,
font_index: u32,
@@ -149,7 +149,7 @@
}
impl<'a> GlyphCacheSession<'a> {
- pub fn get_or_insert(&mut self, glyph_id: u32) -> Option<(Rc<Encoding>, StreamOffsets)> {
+ pub fn get_or_insert(&mut self, glyph_id: u32) -> Option<(Arc<Encoding>, StreamOffsets)> {
let key = GlyphKey {
font_id: self.font_id,
font_index: self.font_index,
@@ -164,7 +164,7 @@
}
let outline = self.outlines.get(GlyphId::new(key.glyph_id as u16))?;
let mut encoding = self.free_list.pop().unwrap_or_default();
- let encoding_ptr = Rc::make_mut(&mut encoding);
+ let encoding_ptr = Arc::make_mut(&mut encoding);
encoding_ptr.reset();
let is_fill = match &self.style {
Style::Fill(fill) => {
@@ -224,7 +224,7 @@
#[derive(Clone, Default)]
struct GlyphEntry {
- encoding: Rc<Encoding>,
+ encoding: Arc<Encoding>,
stream_sizes: StreamOffsets,
/// Last use of this entry.
serial: u64,
diff --git a/crates/encoding/src/resolve.rs b/crates/encoding/src/resolve.rs
index a8745a6..c627c20 100644
--- a/crates/encoding/src/resolve.rs
+++ b/crates/encoding/src/resolve.rs
@@ -14,7 +14,7 @@
},
peniko::{Extend, Image},
std::ops::Range,
- std::rc::Rc,
+ std::sync::Arc,
};
/// Layout of a packed encoding.
@@ -164,7 +164,7 @@
#[derive(Default)]
pub struct Resolver {
glyph_cache: GlyphCache,
- glyphs: Vec<Rc<Encoding>>,
+ glyphs: Vec<Arc<Encoding>>,
ramp_cache: RampCache,
image_cache: ImageCache,
pending_images: Vec<PendingImage>,
@@ -438,11 +438,11 @@
};
let glyph_start = self.glyphs.len();
for glyph in glyphs {
- let Some((index, stream_sizes)) = session.get_or_insert(glyph.id) else {
+ let Some((encoding, stream_sizes)) = session.get_or_insert(glyph.id) else {
continue;
};
run_sizes.add(&stream_sizes);
- self.glyphs.push(index);
+ self.glyphs.push(encoding);
}
let glyph_end = self.glyphs.len();
run_sizes.path_tags += glyphs.len() + 1;