Checkpoint
This commit is contained in:
@@ -178,7 +178,7 @@ impl LineLayoutCache {
|
||||
&self,
|
||||
text: &SharedString,
|
||||
font_size: Pixels,
|
||||
runs: &[(usize, FontId)],
|
||||
runs: &[FontRun],
|
||||
wrap_width: Option<Pixels>,
|
||||
) -> Arc<WrappedLineLayout> {
|
||||
let key = &CacheKeyRef {
|
||||
@@ -219,6 +219,12 @@ impl LineLayoutCache {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, Eq, PartialEq, Hash)]
|
||||
pub struct FontRun {
|
||||
pub(crate) len: usize,
|
||||
pub(crate) font_id: FontId,
|
||||
}
|
||||
|
||||
trait AsCacheKeyRef {
|
||||
fn as_cache_key_ref(&self) -> CacheKeyRef;
|
||||
}
|
||||
@@ -227,15 +233,15 @@ trait AsCacheKeyRef {
|
||||
struct CacheKey {
|
||||
text: SharedString,
|
||||
font_size: Pixels,
|
||||
runs: SmallVec<[(usize, FontId); 1]>,
|
||||
runs: SmallVec<[FontRun; 1]>,
|
||||
wrap_width: Option<Pixels>,
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, PartialEq, Eq)]
|
||||
#[derive(Copy, Clone, PartialEq, Eq, Hash)]
|
||||
struct CacheKeyRef<'a> {
|
||||
text: &'a str,
|
||||
font_size: Pixels,
|
||||
runs: &'a [(usize, FontId)],
|
||||
runs: &'a [FontRun],
|
||||
wrap_width: Option<Pixels>,
|
||||
}
|
||||
|
||||
@@ -287,14 +293,3 @@ impl<'a> AsCacheKeyRef for CacheKeyRef<'a> {
|
||||
*self
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> Hash for CacheKeyRef<'a> {
|
||||
fn hash<H: Hasher>(&self, state: &mut H) {
|
||||
self.text.hash(state);
|
||||
self.font_size.hash(state);
|
||||
for (len, font_id) in self.runs {
|
||||
len.hash(state);
|
||||
font_id.hash(state);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use crate::{px, FontId, Pixels, PlatformTextSystem};
|
||||
use crate::{px, FontId, FontRun, Pixels, PlatformTextSystem};
|
||||
use collections::HashMap;
|
||||
use std::{iter, sync::Arc};
|
||||
|
||||
@@ -112,7 +112,14 @@ impl LineWrapper {
|
||||
let mut buffer = [0; 4];
|
||||
let buffer = c.encode_utf8(&mut buffer);
|
||||
self.platform_text_system
|
||||
.layout_line(buffer, self.font_size, &[(1, self.font_id)])
|
||||
.layout_line(
|
||||
buffer,
|
||||
self.font_size,
|
||||
&[FontRun {
|
||||
len: 1,
|
||||
font_id: self.font_id,
|
||||
}],
|
||||
)
|
||||
.width
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user