WIP
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
use crate::{
|
||||
black, point, px, Bounds, FontId, Hsla, Pixels, Point, RunStyle, ShapedBoundary, ShapedLine,
|
||||
black, point, px, Bounds, FontId, Hsla, LineLayout, Pixels, Point, RunStyle, ShapedBoundary,
|
||||
ShapedRun, UnderlineStyle, WindowContext,
|
||||
};
|
||||
use anyhow::Result;
|
||||
@@ -8,7 +8,7 @@ use std::sync::Arc;
|
||||
|
||||
#[derive(Default, Debug, Clone)]
|
||||
pub struct Line {
|
||||
layout: Arc<ShapedLine>,
|
||||
layout: Arc<LineLayout>,
|
||||
style_runs: SmallVec<[StyleRun; 32]>,
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ struct StyleRun {
|
||||
}
|
||||
|
||||
impl Line {
|
||||
pub fn new(layout: Arc<ShapedLine>, runs: &[(usize, RunStyle)]) -> Self {
|
||||
pub fn new(layout: Arc<LineLayout>, runs: &[(usize, RunStyle)]) -> Self {
|
||||
let mut style_runs = SmallVec::new();
|
||||
for (len, style) in runs {
|
||||
style_runs.push(StyleRun {
|
||||
|
||||
@@ -287,7 +287,7 @@ mod tests {
|
||||
|
||||
let text = "aa bbb cccc ddddd eeee";
|
||||
let line = text_system
|
||||
.layout_line(
|
||||
.layout_text(
|
||||
text,
|
||||
px(16.),
|
||||
&[
|
||||
@@ -297,6 +297,7 @@ mod tests {
|
||||
(1, bold.clone()),
|
||||
(7, normal.clone()),
|
||||
],
|
||||
None,
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use crate::{FontId, Pixels, PlatformTextSystem, ShapedGlyph, ShapedLine, ShapedRun};
|
||||
use crate::{FontId, LineLayout, Pixels, PlatformTextSystem, ShapedGlyph, 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<ShapedLine>>>,
|
||||
curr_frame: RwLock<HashMap<CacheKeyValue, Arc<ShapedLine>>>,
|
||||
prev_frame: Mutex<HashMap<CacheKeyValue, Arc<LineLayout>>>,
|
||||
curr_frame: RwLock<HashMap<CacheKeyValue, Arc<LineLayout>>>,
|
||||
platform_text_system: Arc<dyn PlatformTextSystem>,
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ impl TextLayoutCache {
|
||||
text: &'a str,
|
||||
font_size: Pixels,
|
||||
runs: &[(usize, FontId)],
|
||||
) -> Arc<ShapedLine> {
|
||||
) -> Arc<LineLayout> {
|
||||
let key = &CacheKeyRef {
|
||||
text,
|
||||
font_size,
|
||||
|
||||
Reference in New Issue
Block a user