summaryrefslogtreecommitdiffstats
path: root/wgpu/src/backend.rs
diff options
context:
space:
mode:
Diffstat (limited to 'wgpu/src/backend.rs')
-rw-r--r--wgpu/src/backend.rs42
1 files changed, 34 insertions, 8 deletions
diff --git a/wgpu/src/backend.rs b/wgpu/src/backend.rs
index 534c6cb7..b31bf92c 100644
--- a/wgpu/src/backend.rs
+++ b/wgpu/src/backend.rs
@@ -2,6 +2,7 @@ use crate::quad;
use crate::text;
use crate::triangle;
use crate::{Settings, Transformation};
+
use iced_graphics::backend;
use iced_graphics::font;
use iced_graphics::layer::Layer;
@@ -30,18 +31,24 @@ pub struct Backend {
impl Backend {
/// Creates a new [`Backend`].
- pub fn new(device: &wgpu::Device, settings: Settings) -> Self {
- let text_pipeline =
- text::Pipeline::new(device, settings.format, settings.default_font);
- let quad_pipeline = quad::Pipeline::new(device, settings.format);
- let triangle_pipeline = triangle::Pipeline::new(
+ pub fn new(
+ device: &wgpu::Device,
+ settings: Settings,
+ format: wgpu::TextureFormat,
+ ) -> Self {
+ let text_pipeline = text::Pipeline::new(
device,
- settings.format,
- settings.antialiasing,
+ format,
+ settings.default_font,
+ settings.text_multithreading,
);
+ let quad_pipeline = quad::Pipeline::new(device, format);
+ let triangle_pipeline =
+ triangle::Pipeline::new(device, format, settings.antialiasing);
+
#[cfg(any(feature = "image_rs", feature = "svg"))]
- let image_pipeline = image::Pipeline::new(device, settings.format);
+ let image_pipeline = image::Pipeline::new(device, format);
Self {
quad_pipeline,
@@ -268,6 +275,25 @@ impl backend::Text for Backend {
) -> (f32, f32) {
self.text_pipeline.measure(contents, size, font, bounds)
}
+
+ fn hit_test(
+ &self,
+ contents: &str,
+ size: f32,
+ font: Font,
+ bounds: Size,
+ point: iced_native::Point,
+ nearest_only: bool,
+ ) -> text::Hit {
+ self.text_pipeline.hit_test(
+ contents,
+ size,
+ font,
+ bounds,
+ point,
+ nearest_only,
+ )
+ }
}
#[cfg(feature = "image_rs")]