Skip to content

Commit

Permalink
replace dev-dependency once-cell with std LazyLock
Browse files Browse the repository at this point in the history
  • Loading branch information
alexheretic committed Jul 25, 2024
1 parent 2927d71 commit 827f3c7
Show file tree
Hide file tree
Showing 9 changed files with 15 additions and 19 deletions.
1 change: 0 additions & 1 deletion draw-cache/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ rayon = "1.3"
approx = "0.5"
criterion = "0.5"
glyph_brush_layout = { version = "0.2", path = "../layout" }
once_cell = "1.3"

[[bench]]
name = "draw_cache"
Expand Down
4 changes: 2 additions & 2 deletions draw-cache/benches/draw_cache.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use criterion::{criterion_group, criterion_main, Criterion};
use glyph_brush_draw_cache::*;
use glyph_brush_layout::ab_glyph::*;
use once_cell::sync::Lazy;
use std::sync::LazyLock;

fn mock_gpu_upload_4us(_region: Rectangle<u32>, _bytes: &[u8]) {
use std::time::{Duration, Instant};
Expand Down Expand Up @@ -68,7 +68,7 @@ pub fn layout_paragraph<F, SF>(
}
}

static FONTS: Lazy<Vec<FontRef<'static>>> = Lazy::new(|| {
static FONTS: LazyLock<Vec<FontRef<'static>>> = LazyLock::new(|| {
vec![
include_bytes!("../../fonts/WenQuanYiMicroHei.ttf") as &[u8],
include_bytes!("../../fonts/OpenSans-Italic.ttf") as &[u8],
Expand Down
4 changes: 2 additions & 2 deletions draw-cache/benches/st_vs_mt.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use criterion::{criterion_group, criterion_main, measurement::WallTime, Bencher, Criterion};
use glyph_brush_draw_cache::*;
use glyph_brush_layout::ab_glyph::*;
use once_cell::sync::Lazy;
use std::sync::LazyLock;

/// Simple paragraph layout for glyphs into `target`.
///
Expand Down Expand Up @@ -46,7 +46,7 @@ pub fn layout_paragraph<F, SF>(
}
}

static DEJA_VU_SANS: Lazy<FontRef<'static>> = Lazy::new(|| {
static DEJA_VU_SANS: LazyLock<FontRef<'static>> = LazyLock::new(|| {
FontRef::try_from_slice(include_bytes!("../../fonts/DejaVuSans.ttf") as &[u8]).unwrap()
});

Expand Down
4 changes: 2 additions & 2 deletions gfx-glyph/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
//! Makes use of three kinds of caching to optimise frame performance.
//!
//! * Caching of glyph positioning output to avoid repeated cost of identical text
//! rendering on sequential frames.
//! rendering on sequential frames.
//! * Caches draw calculations to avoid repeated cost of identical text rendering on
//! sequential frames.
//! sequential frames.
//! * GPU cache logic to dynamically maintain a GPU texture of rendered glyphs.
//!
//! # Example
Expand Down
1 change: 0 additions & 1 deletion glyph-brush/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ env_logger = { version = "0.11", default-features = false }
gl = "0.14"
glutin = "0.32"
glutin-winit = "0.5"
once_cell = "1.3"
raw-window-handle = "0.6"
spin_sleep_util = "0.1"
winit = "0.30"
Expand Down
2 changes: 1 addition & 1 deletion glyph-brush/examples/opengl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@
//! * Load a font
//! * Initialize the brush
//! * Set up the glyph cache texture
//!
//! Per frame:
//! * Queue up Sections of text, containing per-glyph colors and layout information
//! * Process the text into vertices, increasing glyph cache size if necessary
//! * Upload the vertices to the GPU if they've changed, and draw to the screen

use gl::types::*;
use glutin::{
context::PossiblyCurrentContext,
Expand Down
7 changes: 3 additions & 4 deletions glyph-brush/src/glyph_calculator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -398,13 +398,12 @@ impl<X> GlyphedSection<X> {
mod test {
use super::*;
use approx::*;
use once_cell::sync::Lazy;
use std::f32;
use std::{f32, sync::LazyLock};

static MONO_FONT: Lazy<FontArc> = Lazy::new(|| {
static MONO_FONT: LazyLock<FontArc> = LazyLock::new(|| {
FontArc::try_from_slice(include_bytes!("../../fonts/DejaVuSansMono.ttf") as &[u8]).unwrap()
});
static OPEN_SANS_LIGHT: Lazy<FontArc> = Lazy::new(|| {
static OPEN_SANS_LIGHT: LazyLock<FontArc> = LazyLock::new(|| {
FontArc::try_from_slice(include_bytes!("../../fonts/OpenSans-Light.ttf") as &[u8]).unwrap()
});

Expand Down
1 change: 0 additions & 1 deletion layout/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,4 @@ approx = "0.5"
xi-unicode = "0.3"

[dev-dependencies]
once_cell = "1"
ordered-float = "4"
10 changes: 5 additions & 5 deletions layout/src/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -380,17 +380,17 @@ mod layout_test {
use super::*;
use crate::{BuiltInLineBreaker::*, FontId, SectionText};
use approx::assert_relative_eq;
use once_cell::sync::Lazy;
use ordered_float::OrderedFloat;
use std::{collections::*, f32};
use std::{collections::*, f32, sync::LazyLock};

static A_FONT: Lazy<FontRef<'static>> = Lazy::new(|| {
static A_FONT: LazyLock<FontRef<'static>> = LazyLock::new(|| {
FontRef::try_from_slice(include_bytes!("../../fonts/DejaVuSansMono.ttf")).unwrap()
});
static CJK_FONT: Lazy<FontRef<'static>> = Lazy::new(|| {
static CJK_FONT: LazyLock<FontRef<'static>> = LazyLock::new(|| {
FontRef::try_from_slice(include_bytes!("../../fonts/WenQuanYiMicroHei.ttf")).unwrap()
});
static FONT_MAP: Lazy<[&'static FontRef<'static>; 2]> = Lazy::new(|| [&*A_FONT, &*CJK_FONT]);
static FONT_MAP: LazyLock<[&'static FontRef<'static>; 2]> =
LazyLock::new(|| [&*A_FONT, &*CJK_FONT]);

/// All the chars used in testing, so we can reverse lookup the glyph-ids
const TEST_CHARS: &[char] = &[
Expand Down

0 comments on commit 827f3c7

Please sign in to comment.