From 6469e463cd1f99190c6eba4701d4c1059934d3ee Mon Sep 17 00:00:00 2001 From: Yusuf Bera Ertan Date: Mon, 14 Jun 2021 18:06:28 +0300 Subject: feat: expose draw_cache_multithread --- glow/Cargo.toml | 1 + glow/src/text.rs | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) (limited to 'glow') diff --git a/glow/Cargo.toml b/glow/Cargo.toml index e40b8ba8..f5934f8f 100644 --- a/glow/Cargo.toml +++ b/glow/Cargo.toml @@ -11,6 +11,7 @@ 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/text.rs b/glow/src/text.rs index 925c7287..7c9574a2 100644 --- a/glow/src/text.rs +++ b/glow/src/text.rs @@ -41,7 +41,9 @@ impl Pipeline { let draw_brush = glow_glyph::GlyphBrushBuilder::using_font(font.clone()) .initial_cache_size((2048, 2048)) - .draw_cache_multithread(false) // TODO: Expose as a configuration flag + .draw_cache_multithread(cfg!( + feature = "glyph_draw_cache_multithread" + )) .build(&gl); let measure_brush = -- cgit From 217f5be8272f48a5b043d066ed1788cc127e1164 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Thu, 22 Jul 2021 18:21:50 +0700 Subject: Add `text_multithreading` to `Settings` in `iced_glow` and `iced_wgpu` --- glow/Cargo.toml | 1 - glow/src/backend.rs | 7 ++++++- glow/src/settings.rs | 5 +++++ glow/src/text.rs | 10 ++++++---- 4 files changed, 17 insertions(+), 6 deletions(-) (limited to 'glow') 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, } @@ -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 = -- cgit From 357a8a95c9820651110fe4d80d8d33a2678827c0 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Thu, 22 Jul 2021 18:27:33 +0700 Subject: Introduce `text_multithreading` to `Settings` --- glow/src/settings.rs | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'glow') diff --git a/glow/src/settings.rs b/glow/src/settings.rs index cf8e891f..f3dddfaf 100644 --- a/glow/src/settings.rs +++ b/glow/src/settings.rs @@ -18,9 +18,13 @@ pub struct Settings { /// If enabled, spread text workload in multiple threads when multiple cores /// are available. + /// + /// By default, it is disabled. pub text_multithreading: bool, /// The antialiasing strategy that will be used for triangle primitives. + /// + /// By default, it is `None`. pub antialiasing: Option, } -- cgit