summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2023-07-07 07:12:37 +0200
committerLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2023-07-20 20:47:38 +0200
commit95ff96f71f8f8069608ad08985e2b1214dd42284 (patch)
treebd3a902ad36f9b7aa5c00fc26d748d4f8dbeda23
parentfd077918db7643530c3a7318ed5777d2f3d8761b (diff)
downloadiced-95ff96f71f8f8069608ad08985e2b1214dd42284.tar.gz
iced-95ff96f71f8f8069608ad08985e2b1214dd42284.tar.bz2
iced-95ff96f71f8f8069608ad08985e2b1214dd42284.zip
Update `cosmic-text` and `glyphon`
Diffstat (limited to '')
-rw-r--r--tiny_skia/Cargo.toml5
-rw-r--r--wgpu/Cargo.toml2
-rw-r--r--wgpu/src/backend.rs53
-rw-r--r--wgpu/src/text.rs22
4 files changed, 21 insertions, 61 deletions
diff --git a/tiny_skia/Cargo.toml b/tiny_skia/Cargo.toml
index d9276ea5..66ad35fd 100644
--- a/tiny_skia/Cargo.toml
+++ b/tiny_skia/Cargo.toml
@@ -12,6 +12,7 @@ geometry = ["iced_graphics/geometry"]
raw-window-handle = "0.5"
softbuffer = "0.2"
tiny-skia = "0.10"
+cosmic-text = "0.9"
bytemuck = "1"
rustc-hash = "1.1"
kurbo = "0.9"
@@ -21,10 +22,6 @@ log = "0.4"
version = "0.8"
path = "../graphics"
-[dependencies.cosmic-text]
-git = "https://github.com/hecrj/cosmic-text.git"
-rev = "c3cd24dc972bb8fd55d016c81ac9fa637e0a4ada"
-
[dependencies.twox-hash]
version = "1.6"
default-features = false
diff --git a/wgpu/Cargo.toml b/wgpu/Cargo.toml
index 22cfad55..a47c635a 100644
--- a/wgpu/Cargo.toml
+++ b/wgpu/Cargo.toml
@@ -45,7 +45,7 @@ path = "../graphics"
[dependencies.glyphon]
version = "0.2"
git = "https://github.com/hecrj/glyphon.git"
-rev = "8324f20158a62f8520bad4ed09f6aa5552f8f2a6"
+rev = "886f47c0a9905af340b07a488c953ac00c4bf370"
[dependencies.glam]
version = "0.24"
diff --git a/wgpu/src/backend.rs b/wgpu/src/backend.rs
index 4a0c54f0..9966a38c 100644
--- a/wgpu/src/backend.rs
+++ b/wgpu/src/backend.rs
@@ -94,18 +94,11 @@ impl Backend {
queue,
encoder,
scale_factor,
+ target_size,
transformation,
&layers,
);
- while !self.prepare_text(
- device,
- queue,
- scale_factor,
- target_size,
- &layers,
- ) {}
-
self.render(
device,
encoder,
@@ -124,44 +117,13 @@ impl Backend {
self.image_pipeline.end_frame();
}
- 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()
- && !self.text_pipeline.prepare(
- device,
- queue,
- &layer.text,
- layer.bounds,
- scale_factor,
- target_size,
- )
- {
- return false;
- }
- }
-
- true
- }
-
fn prepare(
&mut self,
device: &wgpu::Device,
queue: &wgpu::Queue,
_encoder: &mut wgpu::CommandEncoder,
scale_factor: f32,
+ target_size: Size<u32>,
transformation: Transformation,
layers: &[Layer<'_>],
) {
@@ -210,6 +172,17 @@ impl Backend {
);
}
}
+
+ if !layer.text.is_empty() {
+ self.text_pipeline.prepare(
+ device,
+ queue,
+ &layer.text,
+ layer.bounds,
+ scale_factor,
+ target_size,
+ );
+ }
}
}
diff --git a/wgpu/src/text.rs b/wgpu/src/text.rs
index 65d3b818..ef910c39 100644
--- a/wgpu/src/text.rs
+++ b/wgpu/src/text.rs
@@ -35,7 +35,7 @@ impl Pipeline {
.into_iter(),
)),
renderers: Vec::new(),
- atlas: glyphon::TextAtlas::new(
+ atlas: glyphon::TextAtlas::with_color_mode(
device,
queue,
format,
@@ -66,7 +66,7 @@ impl Pipeline {
bounds: Rectangle,
scale_factor: f32,
target_size: Size<u32>,
- ) -> bool {
+ ) {
if self.renderers.len() <= self.prepare_layer {
self.renderers.push(glyphon::TextRenderer::new(
&mut self.atlas,
@@ -188,21 +188,11 @@ impl Pipeline {
match result {
Ok(()) => {
self.prepare_layer += 1;
-
- true
}
- Err(glyphon::PrepareError::AtlasFull(content_type)) => {
- self.prepare_layer = 0;
-
- #[allow(clippy::needless_bool)]
- if self.atlas.grow(device, content_type) {
- false
- } else {
- // If the atlas cannot grow, then all bets are off.
- // Instead of panicking, we will just pray that the result
- // will be somewhat readable...
- true
- }
+ Err(glyphon::PrepareError::AtlasFull) => {
+ // If the atlas cannot grow, then all bets are off.
+ // Instead of panicking, we will just pray that the result
+ // will be somewhat readable...
}
}
}