Skip to content

Commit

Permalink
Replace use of unmaintained and deprecated generational-area with slo…
Browse files Browse the repository at this point in the history
…tmap

Unfortunately this requires a major version bump as the g-a's Index is
in the public API. While we're at this, this change also makes that
field private.

Fixes femtovg#198
  • Loading branch information
tronical committed Feb 23, 2024
1 parent 60adc6a commit 9d5d607
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 9 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -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 = [
Expand All @@ -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"] }
Expand Down
8 changes: 4 additions & 4 deletions src/image.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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)]
Expand Down Expand Up @@ -182,7 +182,7 @@ impl ImageInfo {
}
}

pub struct ImageStore<T>(Arena<(ImageInfo, T)>);
pub struct ImageStore<T>(SlotMap<DefaultKey, (ImageInfo, T)>);

impl<T> Default for ImageStore<T> {
fn default() -> Self {
Expand All @@ -192,7 +192,7 @@ impl<T> Default for ImageStore<T> {

impl<T> ImageStore<T> {
pub fn new() -> Self {
Self(Arena::new())
Self(SlotMap::new())
}

pub fn alloc<R: Renderer<Image = T>>(&mut self, renderer: &mut R, info: ImageInfo) -> Result<ImageId, ErrorKind> {
Expand Down
6 changes: 3 additions & 3 deletions src/text.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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`.
Expand Down Expand Up @@ -293,7 +293,7 @@ impl TextContext {
}

pub(crate) struct TextContextImpl {
fonts: Arena<Font>,
fonts: SlotMap<DefaultKey, Font>,
shaping_run_cache: ShapingRunCache<FnvBuildHasher>,
shaped_words_cache: ShapedWordsCache<FnvBuildHasher>,
}
Expand Down

0 comments on commit 9d5d607

Please sign in to comment.