summaryrefslogtreecommitdiffstats
path: root/glow
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2021-07-22 18:21:50 +0700
committerLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2021-07-22 18:21:50 +0700
commit217f5be8272f48a5b043d066ed1788cc127e1164 (patch)
treeef09f2324d8d44d52938d34d8d007ff1bf681721 /glow
parent6469e463cd1f99190c6eba4701d4c1059934d3ee (diff)
downloadiced-217f5be8272f48a5b043d066ed1788cc127e1164.tar.gz
iced-217f5be8272f48a5b043d066ed1788cc127e1164.tar.bz2
iced-217f5be8272f48a5b043d066ed1788cc127e1164.zip
Add `text_multithreading` to `Settings` in `iced_glow` and `iced_wgpu`
Diffstat (limited to 'glow')
-rw-r--r--glow/Cargo.toml1
-rw-r--r--glow/src/backend.rs7
-rw-r--r--glow/src/settings.rs5
-rw-r--r--glow/src/text.rs10
4 files changed, 17 insertions, 6 deletions
diff --git a/glow/Cargo.toml b/glow/Cargo.toml
index f5934f8f..e40b8ba8 100644
--- a/glow/Cargo.toml
+++ b/glow/Cargo.toml
@@ -11,7 +11,6 @@ repository = "https://github.com/hecrj/iced"
canvas = ["iced_graphics/canvas"]
qr_code = ["iced_graphics/qr_code"]
default_system_font = ["iced_graphics/font-source"]
-glyph_draw_cache_multithread = []
# Not supported yet!
image = []
svg = []
diff --git a/glow/src/backend.rs b/glow/src/backend.rs
index 92bb993e..1680fc00 100644
--- a/glow/src/backend.rs
+++ b/glow/src/backend.rs
@@ -24,7 +24,12 @@ pub struct Backend {
impl Backend {
/// Creates a new [`Backend`].
pub fn new(gl: &glow::Context, settings: Settings) -> Self {
- let text_pipeline = text::Pipeline::new(gl, settings.default_font);
+ let text_pipeline = text::Pipeline::new(
+ gl,
+ settings.default_font,
+ settings.text_multithreading,
+ );
+
let quad_pipeline = quad::Pipeline::new(gl);
let triangle_pipeline = triangle::Pipeline::new(gl);
diff --git a/glow/src/settings.rs b/glow/src/settings.rs
index 8477eb57..cf8e891f 100644
--- a/glow/src/settings.rs
+++ b/glow/src/settings.rs
@@ -16,6 +16,10 @@ pub struct Settings {
/// By default, it will be set to 20.
pub default_text_size: u16,
+ /// If enabled, spread text workload in multiple threads when multiple cores
+ /// are available.
+ pub text_multithreading: bool,
+
/// The antialiasing strategy that will be used for triangle primitives.
pub antialiasing: Option<Antialiasing>,
}
@@ -25,6 +29,7 @@ impl Default for Settings {
Settings {
default_font: None,
default_text_size: 20,
+ text_multithreading: false,
antialiasing: None,
}
}
diff --git a/glow/src/text.rs b/glow/src/text.rs
index 7c9574a2..a4c39dfe 100644
--- a/glow/src/text.rs
+++ b/glow/src/text.rs
@@ -11,7 +11,11 @@ pub struct Pipeline {
}
impl Pipeline {
- pub fn new(gl: &glow::Context, default_font: Option<&[u8]>) -> Self {
+ pub fn new(
+ gl: &glow::Context,
+ default_font: Option<&[u8]>,
+ multithreading: bool,
+ ) -> Self {
let default_font = default_font.map(|slice| slice.to_vec());
// TODO: Font customization
@@ -41,9 +45,7 @@ impl Pipeline {
let draw_brush =
glow_glyph::GlyphBrushBuilder::using_font(font.clone())
.initial_cache_size((2048, 2048))
- .draw_cache_multithread(cfg!(
- feature = "glyph_draw_cache_multithread"
- ))
+ .draw_cache_multithread(multithreading)
.build(&gl);
let measure_brush =