diff --git a/CHANGELOG.md b/CHANGELOG.md index bd1da24a..a05bf421 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,11 @@ All notable changes to this project will be documented in this file. ## Unreleased +## [0.9.0] - 2024-TBD + + - **breaking**: Removed pub key field in ImageId. This accidentally + exposed the implementation detail of the image store (generational-arena), + which has been replaced with slotmap. - Bumped MSRV to 1.66. ## [0.8.2] - 2024-01-20 diff --git a/Cargo.toml b/Cargo.toml index c59835c3..86f53d9b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "femtovg" description = "Antialiased 2D vector drawing library" -version = "0.8.2" +version = "0.9.0" license = "MIT/Apache-2.0" readme = "README.md" authors = [ @@ -25,7 +25,7 @@ bitflags = "2.0.2" rustybuzz = "0.11.0" unicode-bidi = "0.3.4" unicode-segmentation = "1.6.0" -generational-arena = "0.2.8" +slotmap = "1.0.7" lru = { version = "0.12.0", default-features = false } image = { version = "0.24.0", optional = true, default-features = false } serde = { version = "1.0", optional = true, features = ["derive", "rc"] } diff --git a/src/image.rs b/src/image.rs index a169a69c..fc345506 100644 --- a/src/image.rs +++ b/src/image.rs @@ -1,8 +1,8 @@ use bitflags::bitflags; -use generational_arena::{Arena, Index}; use imgref::*; use rgb::alt::GRAY8; use rgb::*; +use slotmap::{DefaultKey, SlotMap}; #[cfg(feature = "image-loading")] use ::image::DynamicImage; @@ -14,7 +14,7 @@ use crate::{ErrorKind, Renderer}; /// An image handle. #[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)] -pub struct ImageId(pub Index); +pub struct ImageId(DefaultKey); /// Image format: `Rgb8`, `Rgba8`, `Gray8`. #[derive(Copy, Clone, Debug, Eq, PartialEq, Hash)] @@ -182,7 +182,7 @@ impl ImageInfo { } } -pub struct ImageStore(Arena<(ImageInfo, T)>); +pub struct ImageStore(SlotMap); impl Default for ImageStore { fn default() -> Self { @@ -192,7 +192,7 @@ impl Default for ImageStore { impl ImageStore { pub fn new() -> Self { - Self(Arena::new()) + Self(SlotMap::new()) } pub fn alloc>(&mut self, renderer: &mut R, info: ImageInfo) -> Result { diff --git a/src/text.rs b/src/text.rs index f53ed274..a0be9481 100644 --- a/src/text.rs +++ b/src/text.rs @@ -11,9 +11,9 @@ use std::{ }; use fnv::{FnvBuildHasher, FnvHashMap, FnvHasher}; -use generational_arena::{Arena, Index}; use lru::LruCache; use rustybuzz::ttf_parser; +use slotmap::{DefaultKey, SlotMap}; use unicode_bidi::BidiInfo; use unicode_segmentation::UnicodeSegmentation; @@ -44,7 +44,7 @@ const DEFAULT_LRU_CACHE_CAPACITY: usize = 1000; /// A font handle. #[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)] -pub struct FontId(Index); +pub struct FontId(DefaultKey); /// Text baseline vertical alignment: /// `Top`, `Middle`, `Alphabetic` (default), `Bottom`. @@ -293,7 +293,7 @@ impl TextContext { } pub(crate) struct TextContextImpl { - fonts: Arena, + fonts: SlotMap, shaping_run_cache: ShapingRunCache, shaped_words_cache: ShapedWordsCache, }