Checkpoint

This commit is contained in:
Antonio Scandurra
2023-10-03 15:23:49 +02:00
parent 12ba10bc2c
commit 08464ee26e
9 changed files with 121 additions and 62 deletions
+5 -5
View File
@@ -1,6 +1,6 @@
use crate::{
black, point, px, Bounds, FontId, Hsla, Layout, LineLayout, Pixels, Point, Run, RunStyle,
ShapedBoundary, UnderlineStyle, WindowContext,
black, point, px, Bounds, FontId, Hsla, Layout, Pixels, Point, RunStyle, ShapedBoundary,
ShapedLine, ShapedRun, UnderlineStyle, WindowContext,
};
use anyhow::Result;
use smallvec::SmallVec;
@@ -8,7 +8,7 @@ use std::sync::Arc;
#[derive(Default, Debug, Clone)]
pub struct Line {
layout: Arc<LineLayout>,
layout: Arc<ShapedLine>,
style_runs: SmallVec<[StyleRun; 32]>,
}
@@ -20,7 +20,7 @@ struct StyleRun {
}
impl Line {
pub fn new(layout: Arc<LineLayout>, runs: &[(usize, RunStyle)]) -> Self {
pub fn new(layout: Arc<ShapedLine>, runs: &[(usize, RunStyle)]) -> Self {
let mut style_runs = SmallVec::new();
for (len, style) in runs {
style_runs.push(StyleRun {
@@ -32,7 +32,7 @@ impl Line {
Self { layout, style_runs }
}
pub fn runs(&self) -> &[Run] {
pub fn runs(&self) -> &[ShapedRun] {
&self.layout.runs
}
@@ -1,4 +1,4 @@
use crate::{FontId, Glyph, LineLayout, Pixels, PlatformTextSystem, Run};
use crate::{FontId, Pixels, PlatformTextSystem, ShapedGlyph, ShapedLine, ShapedRun};
use parking_lot::{Mutex, RwLock, RwLockUpgradableReadGuard};
use smallvec::SmallVec;
use std::{
@@ -9,8 +9,8 @@ use std::{
};
pub(crate) struct TextLayoutCache {
prev_frame: Mutex<HashMap<CacheKeyValue, Arc<LineLayout>>>,
curr_frame: RwLock<HashMap<CacheKeyValue, Arc<LineLayout>>>,
prev_frame: Mutex<HashMap<CacheKeyValue, Arc<ShapedLine>>>,
curr_frame: RwLock<HashMap<CacheKeyValue, Arc<ShapedLine>>>,
platform_text_system: Arc<dyn PlatformTextSystem>,
}
@@ -35,7 +35,7 @@ impl TextLayoutCache {
text: &'a str,
font_size: Pixels,
runs: &[(usize, FontId)],
) -> Arc<LineLayout> {
) -> Arc<ShapedLine> {
let key = &CacheKeyRef {
text,
font_size,
@@ -146,8 +146,8 @@ pub struct ShapedBoundary {
pub glyph_ix: usize,
}
impl Run {
pub fn glyphs(&self) -> &[Glyph] {
impl ShapedRun {
pub fn glyphs(&self) -> &[ShapedGlyph] {
&self.glyphs
}
}