Take an Iterator
of TextArea
in prepare
This commit is contained in:
parent
7f31965063
commit
0857bef584
3 changed files with 10 additions and 8 deletions
|
@ -101,7 +101,7 @@ async fn run() {
|
|||
width: config.width,
|
||||
height: config.height,
|
||||
},
|
||||
&[TextArea {
|
||||
[TextArea {
|
||||
buffer: &buffer,
|
||||
left: 10,
|
||||
top: 10,
|
||||
|
@ -112,7 +112,8 @@ async fn run() {
|
|||
bottom: 160,
|
||||
},
|
||||
default_color: Color::rgb(255, 255, 255),
|
||||
}],
|
||||
}]
|
||||
.into_iter(),
|
||||
&mut cache,
|
||||
)
|
||||
.unwrap();
|
||||
|
|
|
@ -96,6 +96,7 @@ impl Default for TextBounds {
|
|||
}
|
||||
|
||||
/// A text area containing text to be rendered along with its overflow behavior.
|
||||
#[derive(Clone, Copy)]
|
||||
pub struct TextArea<'a> {
|
||||
/// The buffer containing the text to be rendered.
|
||||
pub buffer: &'a Buffer,
|
||||
|
|
|
@ -61,14 +61,14 @@ impl TextRenderer {
|
|||
}
|
||||
|
||||
/// Prepares all of the provided text areas for rendering.
|
||||
pub fn prepare_with_depth(
|
||||
pub fn prepare_with_depth<'a>(
|
||||
&mut self,
|
||||
device: &Device,
|
||||
queue: &Queue,
|
||||
font_system: &mut FontSystem,
|
||||
atlas: &mut TextAtlas,
|
||||
screen_resolution: Resolution,
|
||||
text_areas: &[TextArea<'_>],
|
||||
text_areas: impl Iterator<Item = TextArea<'a>> + Clone,
|
||||
cache: &mut SwashCache,
|
||||
mut metadata_to_depth: impl FnMut(usize) -> f32,
|
||||
) -> Result<(), PrepareError> {
|
||||
|
@ -86,7 +86,7 @@ impl TextRenderer {
|
|||
});
|
||||
}
|
||||
|
||||
for text_area in text_areas.iter() {
|
||||
for text_area in text_areas.clone() {
|
||||
for run in text_area.buffer.layout_runs() {
|
||||
for glyph in run.glyphs.iter() {
|
||||
if atlas.mask_atlas.glyph_cache.contains(&glyph.cache_key) {
|
||||
|
@ -193,7 +193,7 @@ impl TextRenderer {
|
|||
let mut glyph_indices: Vec<u32> = Vec::new();
|
||||
let mut glyphs_added = 0;
|
||||
|
||||
for text_area in text_areas.iter() {
|
||||
for text_area in text_areas {
|
||||
// Note: subpixel positioning is not currently handled, so we always truncate down to
|
||||
// the nearest pixel whenever necessary.
|
||||
for run in text_area.buffer.layout_runs() {
|
||||
|
@ -351,14 +351,14 @@ impl TextRenderer {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
pub fn prepare(
|
||||
pub fn prepare<'a>(
|
||||
&mut self,
|
||||
device: &Device,
|
||||
queue: &Queue,
|
||||
font_system: &mut FontSystem,
|
||||
atlas: &mut TextAtlas,
|
||||
screen_resolution: Resolution,
|
||||
text_areas: &[TextArea<'_>],
|
||||
text_areas: impl Iterator<Item = TextArea<'a>> + Clone,
|
||||
cache: &mut SwashCache,
|
||||
) -> Result<(), PrepareError> {
|
||||
self.prepare_with_depth(
|
||||
|
|
Loading…
Reference in a new issue