Add text_multithreading to Settings in iced_glow and iced_wgpu
This commit is contained in:
parent
6469e463cd
commit
217f5be827
9 changed files with 31 additions and 16 deletions
|
|
@ -25,8 +25,6 @@ canvas = ["iced_wgpu/canvas"]
|
||||||
qr_code = ["iced_wgpu/qr_code"]
|
qr_code = ["iced_wgpu/qr_code"]
|
||||||
# Enables using system fonts
|
# Enables using system fonts
|
||||||
default_system_font = ["iced_wgpu/default_system_font"]
|
default_system_font = ["iced_wgpu/default_system_font"]
|
||||||
# Enables draw_cache_multithread for glyph drawing
|
|
||||||
glyph_draw_cache_multithread = ["iced_wgpu/glyph_draw_cache_multithread"]
|
|
||||||
# Enables the `iced_glow` renderer. Overrides `iced_wgpu`
|
# Enables the `iced_glow` renderer. Overrides `iced_wgpu`
|
||||||
glow = ["iced_glow", "iced_glutin"]
|
glow = ["iced_glow", "iced_glutin"]
|
||||||
# Enables the `Canvas` widget for `iced_glow`
|
# Enables the `Canvas` widget for `iced_glow`
|
||||||
|
|
@ -35,8 +33,6 @@ glow_canvas = ["iced_glow/canvas"]
|
||||||
glow_qr_code = ["iced_glow/qr_code"]
|
glow_qr_code = ["iced_glow/qr_code"]
|
||||||
# Enables using system fonts for `iced_glow`
|
# Enables using system fonts for `iced_glow`
|
||||||
glow_default_system_font = ["iced_glow/default_system_font"]
|
glow_default_system_font = ["iced_glow/default_system_font"]
|
||||||
# Enables draw_cache_multithread for `iced_glow` glyph drawing
|
|
||||||
glow_glyph_draw_cache_multithread = ["iced_glow/glyph_draw_cache_multithread"]
|
|
||||||
# Enables a debug view in native platforms (press F12)
|
# Enables a debug view in native platforms (press F12)
|
||||||
debug = ["iced_winit/debug"]
|
debug = ["iced_winit/debug"]
|
||||||
# Enables `tokio` as the `executor::Default` on native platforms
|
# Enables `tokio` as the `executor::Default` on native platforms
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,6 @@ repository = "https://github.com/hecrj/iced"
|
||||||
canvas = ["iced_graphics/canvas"]
|
canvas = ["iced_graphics/canvas"]
|
||||||
qr_code = ["iced_graphics/qr_code"]
|
qr_code = ["iced_graphics/qr_code"]
|
||||||
default_system_font = ["iced_graphics/font-source"]
|
default_system_font = ["iced_graphics/font-source"]
|
||||||
glyph_draw_cache_multithread = []
|
|
||||||
# Not supported yet!
|
# Not supported yet!
|
||||||
image = []
|
image = []
|
||||||
svg = []
|
svg = []
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,12 @@ pub struct Backend {
|
||||||
impl Backend {
|
impl Backend {
|
||||||
/// Creates a new [`Backend`].
|
/// Creates a new [`Backend`].
|
||||||
pub fn new(gl: &glow::Context, settings: Settings) -> Self {
|
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 quad_pipeline = quad::Pipeline::new(gl);
|
||||||
let triangle_pipeline = triangle::Pipeline::new(gl);
|
let triangle_pipeline = triangle::Pipeline::new(gl);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,10 @@ pub struct Settings {
|
||||||
/// By default, it will be set to 20.
|
/// By default, it will be set to 20.
|
||||||
pub default_text_size: u16,
|
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.
|
/// The antialiasing strategy that will be used for triangle primitives.
|
||||||
pub antialiasing: Option<Antialiasing>,
|
pub antialiasing: Option<Antialiasing>,
|
||||||
}
|
}
|
||||||
|
|
@ -25,6 +29,7 @@ impl Default for Settings {
|
||||||
Settings {
|
Settings {
|
||||||
default_font: None,
|
default_font: None,
|
||||||
default_text_size: 20,
|
default_text_size: 20,
|
||||||
|
text_multithreading: false,
|
||||||
antialiasing: None,
|
antialiasing: None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,11 @@ pub struct Pipeline {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl 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());
|
let default_font = default_font.map(|slice| slice.to_vec());
|
||||||
|
|
||||||
// TODO: Font customization
|
// TODO: Font customization
|
||||||
|
|
@ -41,9 +45,7 @@ impl Pipeline {
|
||||||
let draw_brush =
|
let draw_brush =
|
||||||
glow_glyph::GlyphBrushBuilder::using_font(font.clone())
|
glow_glyph::GlyphBrushBuilder::using_font(font.clone())
|
||||||
.initial_cache_size((2048, 2048))
|
.initial_cache_size((2048, 2048))
|
||||||
.draw_cache_multithread(cfg!(
|
.draw_cache_multithread(multithreading)
|
||||||
feature = "glyph_draw_cache_multithread"
|
|
||||||
))
|
|
||||||
.build(&gl);
|
.build(&gl);
|
||||||
|
|
||||||
let measure_brush =
|
let measure_brush =
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,6 @@ farbfeld = ["image_rs/farbfeld"]
|
||||||
canvas = ["iced_graphics/canvas"]
|
canvas = ["iced_graphics/canvas"]
|
||||||
qr_code = ["iced_graphics/qr_code"]
|
qr_code = ["iced_graphics/qr_code"]
|
||||||
default_system_font = ["iced_graphics/font-source"]
|
default_system_font = ["iced_graphics/font-source"]
|
||||||
glyph_draw_cache_multithread = []
|
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
wgpu = "0.8"
|
wgpu = "0.8"
|
||||||
|
|
|
||||||
|
|
@ -31,8 +31,13 @@ pub struct Backend {
|
||||||
impl Backend {
|
impl Backend {
|
||||||
/// Creates a new [`Backend`].
|
/// Creates a new [`Backend`].
|
||||||
pub fn new(device: &wgpu::Device, settings: Settings) -> Self {
|
pub fn new(device: &wgpu::Device, settings: Settings) -> Self {
|
||||||
let text_pipeline =
|
let text_pipeline = text::Pipeline::new(
|
||||||
text::Pipeline::new(device, settings.format, settings.default_font);
|
device,
|
||||||
|
settings.format,
|
||||||
|
settings.default_font,
|
||||||
|
settings.text_multithreading,
|
||||||
|
);
|
||||||
|
|
||||||
let quad_pipeline = quad::Pipeline::new(device, settings.format);
|
let quad_pipeline = quad::Pipeline::new(device, settings.format);
|
||||||
let triangle_pipeline = triangle::Pipeline::new(
|
let triangle_pipeline = triangle::Pipeline::new(
|
||||||
device,
|
device,
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,10 @@ pub struct Settings {
|
||||||
/// By default, it will be set to 20.
|
/// By default, it will be set to 20.
|
||||||
pub default_text_size: u16,
|
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.
|
/// The antialiasing strategy that will be used for triangle primitives.
|
||||||
pub antialiasing: Option<Antialiasing>,
|
pub antialiasing: Option<Antialiasing>,
|
||||||
}
|
}
|
||||||
|
|
@ -65,6 +69,7 @@ impl Default for Settings {
|
||||||
internal_backend: wgpu::BackendBit::PRIMARY,
|
internal_backend: wgpu::BackendBit::PRIMARY,
|
||||||
default_font: None,
|
default_font: None,
|
||||||
default_text_size: 20,
|
default_text_size: 20,
|
||||||
|
text_multithreading: false,
|
||||||
antialiasing: None,
|
antialiasing: None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,7 @@ impl Pipeline {
|
||||||
device: &wgpu::Device,
|
device: &wgpu::Device,
|
||||||
format: wgpu::TextureFormat,
|
format: wgpu::TextureFormat,
|
||||||
default_font: Option<&[u8]>,
|
default_font: Option<&[u8]>,
|
||||||
|
multithreading: bool,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
let default_font = default_font.map(|slice| slice.to_vec());
|
let default_font = default_font.map(|slice| slice.to_vec());
|
||||||
|
|
||||||
|
|
@ -46,9 +47,7 @@ impl Pipeline {
|
||||||
let draw_brush =
|
let draw_brush =
|
||||||
wgpu_glyph::GlyphBrushBuilder::using_font(font.clone())
|
wgpu_glyph::GlyphBrushBuilder::using_font(font.clone())
|
||||||
.initial_cache_size((2048, 2048))
|
.initial_cache_size((2048, 2048))
|
||||||
.draw_cache_multithread(cfg!(
|
.draw_cache_multithread(multithreading)
|
||||||
feature = "glyph_draw_cache_multithread"
|
|
||||||
))
|
|
||||||
.build(device, format);
|
.build(device, format);
|
||||||
|
|
||||||
let measure_brush =
|
let measure_brush =
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue