summaryrefslogtreecommitdiffstats
path: root/wgpu
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2023-02-27 03:40:58 +0100
committerLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2023-02-27 03:41:32 +0100
commit11b2c3bbe31a43e73a61b9bd9f022233f302ae27 (patch)
treea577b430cec446719a1df5361bcd9821748dec00 /wgpu
parent368cadd25a8b57ee5c41e45d1abe8d1dfb194c69 (diff)
downloadiced-11b2c3bbe31a43e73a61b9bd9f022233f302ae27.tar.gz
iced-11b2c3bbe31a43e73a61b9bd9f022233f302ae27.tar.bz2
iced-11b2c3bbe31a43e73a61b9bd9f022233f302ae27.zip
Reuse text buffers independently of color in `iced_wgpu`
Diffstat (limited to '')
-rw-r--r--wgpu/Cargo.toml2
-rw-r--r--wgpu/src/text.rs28
2 files changed, 12 insertions, 18 deletions
diff --git a/wgpu/Cargo.toml b/wgpu/Cargo.toml
index 632873a3..9e80a76d 100644
--- a/wgpu/Cargo.toml
+++ b/wgpu/Cargo.toml
@@ -60,7 +60,7 @@ path = "../graphics"
[dependencies.glyphon]
version = "0.2"
git = "https://github.com/hecrj/glyphon.git"
-rev = "65b481d758f50fd13fc21af2cc5ef62ddee64955"
+rev = "810bc979f9005e2bd343b72b980e57e46174283f"
[dependencies.tracing]
version = "0.1.6"
diff --git a/wgpu/src/text.rs b/wgpu/src/text.rs
index dea6ab18..3839b31f 100644
--- a/wgpu/src/text.rs
+++ b/wgpu/src/text.rs
@@ -2,7 +2,7 @@ pub use iced_native::text::Hit;
use iced_graphics::layer::Text;
use iced_native::alignment;
-use iced_native::{Color, Font, Rectangle, Size};
+use iced_native::{Font, Rectangle, Size};
use rustc_hash::{FxHashMap, FxHashSet};
use std::borrow::Cow;
@@ -110,7 +110,6 @@ impl Pipeline {
height: (section.bounds.height * scale_factor)
.ceil(),
},
- color: section.color,
},
);
@@ -162,6 +161,16 @@ impl Pipeline {
left: left as i32,
top: top as i32,
bounds,
+ default_color: {
+ let [r, g, b, a] = section.color.into_linear();
+
+ glyphon::Color::rgba(
+ (r * 255.0) as u8,
+ (g * 255.0) as u8,
+ (b * 255.0) as u8,
+ (a * 255.0) as u8,
+ )
+ },
}
});
@@ -174,7 +183,6 @@ impl Pipeline {
height: target_size.height,
},
text_areas,
- glyphon::Color::rgb(0, 0, 0),
&mut glyphon::SwashCache::new(fields.fonts),
);
@@ -249,7 +257,6 @@ impl Pipeline {
size,
font,
bounds,
- color: Color::BLACK,
},
);
@@ -283,7 +290,6 @@ impl Pipeline {
size,
font,
bounds,
- color: Color::BLACK,
},
);
@@ -354,7 +360,6 @@ impl<'a> Cache<'a> {
key.font.hash(&mut hasher);
key.bounds.width.to_bits().hash(&mut hasher);
key.bounds.height.to_bits().hash(&mut hasher);
- key.color.into_rgba8().hash(&mut hasher);
hasher.finish()
};
@@ -371,16 +376,6 @@ impl<'a> Cache<'a> {
key.content,
glyphon::Attrs::new()
.family(to_family(key.font))
- .color({
- let [r, g, b, a] = key.color.into_linear();
-
- glyphon::Color::rgba(
- (r * 255.0) as u8,
- (g * 255.0) as u8,
- (b * 255.0) as u8,
- (a * 255.0) as u8,
- )
- })
.monospaced(matches!(key.font, Font::Monospace)),
);
@@ -412,7 +407,6 @@ struct Key<'a> {
size: f32,
font: Font,
bounds: Size,
- color: Color,
}
type KeyHash = u64;