diff options
author | 2023-01-31 06:29:21 +0100 | |
---|---|---|
committer | 2023-02-24 13:19:48 +0100 | |
commit | baf51a8fcffc78e4ca20f7dcbba18ca3655f2840 (patch) | |
tree | fd7ba1920ac0ff57b6ddefd692d8cad5d57274cd /wgpu/src/backend.rs | |
parent | b9a9576207ddfc7afd89da30b7cfc7ca0d7e335c (diff) | |
download | iced-baf51a8fcffc78e4ca20f7dcbba18ca3655f2840.tar.gz iced-baf51a8fcffc78e4ca20f7dcbba18ca3655f2840.tar.bz2 iced-baf51a8fcffc78e4ca20f7dcbba18ca3655f2840.zip |
Draft `glyphon` implementation of text pipeline for `iced_wgpu`
Diffstat (limited to '')
-rw-r--r-- | wgpu/src/backend.rs | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/wgpu/src/backend.rs b/wgpu/src/backend.rs index e9e23e80..77785760 100644 --- a/wgpu/src/backend.rs +++ b/wgpu/src/backend.rs @@ -18,7 +18,7 @@ use crate::image; /// /// [`wgpu`]: https://github.com/gfx-rs/wgpu-rs /// [`iced`]: https://github.com/iced-rs/iced -#[derive(Debug)] +#[allow(missing_debug_implementations)] pub struct Backend { quad_pipeline: quad::Pipeline, text_pipeline: text::Pipeline, @@ -34,11 +34,13 @@ impl Backend { /// Creates a new [`Backend`]. pub fn new( device: &wgpu::Device, + queue: &wgpu::Queue, settings: Settings, format: wgpu::TextureFormat, ) -> Self { let text_pipeline = text::Pipeline::new( device, + queue, format, settings.default_font, settings.text_multithreading, @@ -70,6 +72,7 @@ impl Backend { pub fn present<T: AsRef<str>>( &mut self, device: &wgpu::Device, + queue: &wgpu::Queue, staging_belt: &mut wgpu::util::StagingBelt, encoder: &mut wgpu::CommandEncoder, frame: &wgpu::TextureView, @@ -91,6 +94,7 @@ impl Backend { for layer in layers { self.flush( device, + queue, scale_factor, transformation, &layer, @@ -108,6 +112,7 @@ impl Backend { fn flush( &mut self, device: &wgpu::Device, + queue: &wgpu::Queue, scale_factor: f32, transformation: Transformation, layer: &Layer<'_>, @@ -171,11 +176,15 @@ impl Backend { } if !layer.text.is_empty() { - for _text in layer.text.iter() { - // TODO: Queue text sections - } + self.text_pipeline.prepare( + device, + queue, + &layer.text, + scale_factor, + target_size, + ); - // TODO: Draw queued + self.text_pipeline.render(encoder, target); } } } |