Trim text atlas in iced_wgpu after drawing
This will need to change to only trim when all windows have finished drawing once we implement concurrent presentation, since there would be glyph fighting otherwise.
This commit is contained in:
parent
af6b8155c6
commit
76c5306581
2 changed files with 30 additions and 23 deletions
|
|
@ -152,6 +152,9 @@ impl Renderer {
|
|||
self.triangle.end_frame();
|
||||
self.text.end_frame();
|
||||
|
||||
// TODO: Move to runtime!
|
||||
self.engine.text_pipeline.trim();
|
||||
|
||||
#[cfg(any(feature = "svg", feature = "image"))]
|
||||
{
|
||||
self.image.end_frame();
|
||||
|
|
|
|||
|
|
@ -276,6 +276,33 @@ pub struct Pipeline {
|
|||
atlas: Arc<RwLock<cryoglyph::TextAtlas>>,
|
||||
}
|
||||
|
||||
impl Pipeline {
|
||||
pub fn new(
|
||||
device: &wgpu::Device,
|
||||
queue: &wgpu::Queue,
|
||||
format: wgpu::TextureFormat,
|
||||
) -> Self {
|
||||
let cache = cryoglyph::Cache::new(device);
|
||||
let atlas = cryoglyph::TextAtlas::with_color_mode(
|
||||
device, queue, &cache, format, COLOR_MODE,
|
||||
);
|
||||
|
||||
Pipeline {
|
||||
format,
|
||||
cache,
|
||||
atlas: Arc::new(RwLock::new(atlas)),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn create_viewport(&self, device: &wgpu::Device) -> Viewport {
|
||||
Viewport(cryoglyph::Viewport::new(device, &self.cache))
|
||||
}
|
||||
|
||||
pub fn trim(&self) {
|
||||
self.atlas.write().expect("Write text atlas").trim();
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct State {
|
||||
renderers: Vec<cryoglyph::TextRenderer>,
|
||||
|
|
@ -414,29 +441,6 @@ impl State {
|
|||
}
|
||||
}
|
||||
|
||||
impl Pipeline {
|
||||
pub fn new(
|
||||
device: &wgpu::Device,
|
||||
queue: &wgpu::Queue,
|
||||
format: wgpu::TextureFormat,
|
||||
) -> Self {
|
||||
let cache = cryoglyph::Cache::new(device);
|
||||
let atlas = cryoglyph::TextAtlas::with_color_mode(
|
||||
device, queue, &cache, format, COLOR_MODE,
|
||||
);
|
||||
|
||||
Pipeline {
|
||||
format,
|
||||
cache,
|
||||
atlas: Arc::new(RwLock::new(atlas)),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn create_viewport(&self, device: &wgpu::Device) -> Viewport {
|
||||
Viewport(cryoglyph::Viewport::new(device, &self.cache))
|
||||
}
|
||||
}
|
||||
|
||||
fn prepare(
|
||||
device: &wgpu::Device,
|
||||
queue: &wgpu::Queue,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue