summaryrefslogtreecommitdiffstats
path: root/wgpu/src/backend.rs
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2023-02-08 23:21:04 +0100
committerLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2023-02-24 13:37:32 +0100
commit05c787c2efbd8c8bc11925e1605b8b09ba744268 (patch)
tree933c28610ae7415228e6be69b31160926481e763 /wgpu/src/backend.rs
parentddbf93a82ff2ee0ca3265baf2f5b4442717b9101 (diff)
downloadiced-05c787c2efbd8c8bc11925e1605b8b09ba744268.tar.gz
iced-05c787c2efbd8c8bc11925e1605b8b09ba744268.tar.bz2
iced-05c787c2efbd8c8bc11925e1605b8b09ba744268.zip
Grow atlas in `text::Pipeline` when necessary
Diffstat (limited to '')
-rw-r--r--wgpu/src/backend.rs55
1 files changed, 41 insertions, 14 deletions
diff --git a/wgpu/src/backend.rs b/wgpu/src/backend.rs
index d07898f7..7f44fafa 100644
--- a/wgpu/src/backend.rs
+++ b/wgpu/src/backend.rs
@@ -93,10 +93,17 @@ impl Backend {
encoder,
scale_factor,
transformation,
- target_size,
&layers,
);
+ while !self.prepare_text(
+ device,
+ queue,
+ scale_factor,
+ target_size,
+ &layers,
+ ) {}
+
self.render(
device,
encoder,
@@ -115,6 +122,38 @@ impl Backend {
self.image_pipeline.end_frame(device, queue, encoder);
}
+ fn prepare_text(
+ &mut self,
+ device: &wgpu::Device,
+ queue: &wgpu::Queue,
+ scale_factor: f32,
+ target_size: Size<u32>,
+ layers: &[Layer<'_>],
+ ) -> bool {
+ for layer in layers {
+ let bounds = (layer.bounds * scale_factor).snap();
+
+ if bounds.width < 1 || bounds.height < 1 {
+ continue;
+ }
+
+ if !layer.text.is_empty() {
+ if !self.text_pipeline.prepare(
+ device,
+ queue,
+ &layer.text,
+ layer.bounds,
+ scale_factor,
+ target_size,
+ ) {
+ return false;
+ }
+ }
+ }
+
+ true
+ }
+
fn prepare(
&mut self,
device: &wgpu::Device,
@@ -122,14 +161,13 @@ impl Backend {
_encoder: &mut wgpu::CommandEncoder,
scale_factor: f32,
transformation: Transformation,
- target_size: Size<u32>,
layers: &[Layer<'_>],
) {
for layer in layers {
let bounds = (layer.bounds * scale_factor).snap();
if bounds.width < 1 || bounds.height < 1 {
- return;
+ continue;
}
if !layer.quads.is_empty() {
@@ -170,17 +208,6 @@ impl Backend {
);
}
}
-
- if !layer.text.is_empty() {
- self.text_pipeline.prepare(
- device,
- queue,
- &layer.text,
- layer.bounds,
- scale_factor,
- target_size,
- );
- }
}
}