2023-08-30 04:31:21 +02:00
|
|
|
use crate::core::{Color, Size};
|
2023-03-04 05:37:11 +01:00
|
|
|
use crate::graphics::backend;
|
2023-05-31 21:31:58 +02:00
|
|
|
use crate::graphics::color;
|
2023-06-22 00:38:36 +02:00
|
|
|
use crate::graphics::{Transformation, Viewport};
|
2023-11-14 12:49:49 +01:00
|
|
|
use crate::primitive::pipeline;
|
2023-06-22 00:38:36 +02:00
|
|
|
use crate::primitive::{self, Primitive};
|
2023-11-14 12:49:49 +01:00
|
|
|
use crate::quad;
|
|
|
|
|
use crate::text;
|
|
|
|
|
use crate::triangle;
|
2023-03-04 05:37:11 +01:00
|
|
|
use crate::{Layer, Settings};
|
2020-02-28 14:38:42 +01:00
|
|
|
|
2022-12-20 20:41:09 -08:00
|
|
|
#[cfg(feature = "tracing")]
|
|
|
|
|
use tracing::info_span;
|
2022-11-29 19:50:58 -08:00
|
|
|
|
2022-11-05 03:26:19 +01:00
|
|
|
#[cfg(any(feature = "image", feature = "svg"))]
|
2020-05-19 22:55:12 +02:00
|
|
|
use crate::image;
|
2020-02-28 14:38:42 +01:00
|
|
|
|
2023-02-04 11:12:15 +01:00
|
|
|
use std::borrow::Cow;
|
|
|
|
|
|
2020-05-28 01:37:59 +02:00
|
|
|
/// A [`wgpu`] graphics backend for [`iced`].
|
2019-11-22 22:14:24 +01:00
|
|
|
///
|
|
|
|
|
/// [`wgpu`]: https://github.com/gfx-rs/wgpu-rs
|
2021-12-23 09:34:37 +02:00
|
|
|
/// [`iced`]: https://github.com/iced-rs/iced
|
2023-01-31 06:29:21 +01:00
|
|
|
#[allow(missing_debug_implementations)]
|
2020-05-19 17:15:44 +02:00
|
|
|
pub struct Backend {
|
2019-10-07 03:56:16 +02:00
|
|
|
quad_pipeline: quad::Pipeline,
|
2019-11-13 03:54:36 +01:00
|
|
|
text_pipeline: text::Pipeline,
|
2020-02-28 14:38:42 +01:00
|
|
|
triangle_pipeline: triangle::Pipeline,
|
2023-11-14 12:49:49 +01:00
|
|
|
pipeline_storage: pipeline::Storage,
|
2020-02-28 14:38:42 +01:00
|
|
|
|
2022-11-05 03:26:19 +01:00
|
|
|
#[cfg(any(feature = "image", feature = "svg"))]
|
2020-02-28 14:38:42 +01:00
|
|
|
image_pipeline: image::Pipeline,
|
2019-10-05 19:22:51 +02:00
|
|
|
}
|
|
|
|
|
|
2020-05-19 17:15:44 +02:00
|
|
|
impl Backend {
|
2020-05-30 03:03:59 +02:00
|
|
|
/// Creates a new [`Backend`].
|
2021-08-01 20:38:34 +02:00
|
|
|
pub fn new(
|
|
|
|
|
device: &wgpu::Device,
|
2023-01-31 06:29:21 +01:00
|
|
|
queue: &wgpu::Queue,
|
2021-08-01 20:38:34 +02:00
|
|
|
settings: Settings,
|
|
|
|
|
format: wgpu::TextureFormat,
|
|
|
|
|
) -> Self {
|
2023-02-04 07:33:33 +01:00
|
|
|
let text_pipeline = text::Pipeline::new(device, queue, format);
|
2021-08-01 20:38:34 +02:00
|
|
|
let quad_pipeline = quad::Pipeline::new(device, format);
|
|
|
|
|
let triangle_pipeline =
|
|
|
|
|
triangle::Pipeline::new(device, format, settings.antialiasing);
|
2019-10-07 03:56:16 +02:00
|
|
|
|
2022-11-05 03:26:19 +01:00
|
|
|
#[cfg(any(feature = "image", feature = "svg"))]
|
2021-08-01 20:38:34 +02:00
|
|
|
let image_pipeline = image::Pipeline::new(device, format);
|
2020-02-28 14:38:42 +01:00
|
|
|
|
2019-10-05 19:22:51 +02:00
|
|
|
Self {
|
2019-10-07 03:56:16 +02:00
|
|
|
quad_pipeline,
|
2019-11-11 06:07:31 +01:00
|
|
|
text_pipeline,
|
2020-01-02 19:25:00 +01:00
|
|
|
triangle_pipeline,
|
2023-11-14 12:49:49 +01:00
|
|
|
pipeline_storage: pipeline::Storage::default(),
|
2020-02-28 14:38:42 +01:00
|
|
|
|
2022-11-05 03:26:19 +01:00
|
|
|
#[cfg(any(feature = "image", feature = "svg"))]
|
2020-02-28 14:38:42 +01:00
|
|
|
image_pipeline,
|
2019-10-05 19:22:51 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-05-30 03:03:59 +02:00
|
|
|
/// Draws the provided primitives in the given `TextureView`.
|
2020-02-09 03:25:13 +01:00
|
|
|
///
|
2020-05-30 03:03:59 +02:00
|
|
|
/// The text provided as overlay will be rendered on top of the primitives.
|
2020-02-09 03:25:13 +01:00
|
|
|
/// This is useful for rendering debug information.
|
2021-10-14 16:07:22 +07:00
|
|
|
pub fn present<T: AsRef<str>>(
|
2019-10-09 05:36:49 +02:00
|
|
|
&mut self,
|
2020-04-16 09:06:05 +03:00
|
|
|
device: &wgpu::Device,
|
2023-01-31 06:29:21 +01:00
|
|
|
queue: &wgpu::Queue,
|
2020-02-09 03:25:13 +01:00
|
|
|
encoder: &mut wgpu::CommandEncoder,
|
2023-02-08 00:47:16 +01:00
|
|
|
clear_color: Option<Color>,
|
2023-09-14 13:58:36 -07:00
|
|
|
format: wgpu::TextureFormat,
|
2020-05-20 20:28:35 +02:00
|
|
|
frame: &wgpu::TextureView,
|
2021-10-14 16:59:19 +07:00
|
|
|
primitives: &[Primitive],
|
2020-05-20 20:28:35 +02:00
|
|
|
viewport: &Viewport,
|
2020-05-19 22:55:12 +02:00
|
|
|
overlay_text: &[T],
|
2021-10-14 16:07:22 +07:00
|
|
|
) {
|
2019-10-07 04:05:40 +02:00
|
|
|
log::debug!("Drawing");
|
2022-12-20 20:41:09 -08:00
|
|
|
#[cfg(feature = "tracing")]
|
2022-11-29 19:50:58 -08:00
|
|
|
let _ = info_span!("Wgpu::Backend", "PRESENT").entered();
|
2019-10-07 04:05:40 +02:00
|
|
|
|
2020-05-20 20:28:35 +02:00
|
|
|
let target_size = viewport.physical_size();
|
|
|
|
|
let scale_factor = viewport.scale_factor() as f32;
|
|
|
|
|
let transformation = viewport.projection();
|
2019-10-05 19:22:51 +02:00
|
|
|
|
2021-10-14 16:59:19 +07:00
|
|
|
let mut layers = Layer::generate(primitives, viewport);
|
2023-08-02 22:08:14 +02:00
|
|
|
|
|
|
|
|
if !overlay_text.is_empty() {
|
|
|
|
|
layers.push(Layer::overlay(overlay_text, viewport));
|
|
|
|
|
}
|
2019-10-29 02:00:17 +01:00
|
|
|
|
2023-02-08 00:47:16 +01:00
|
|
|
self.prepare(
|
|
|
|
|
device,
|
|
|
|
|
queue,
|
2023-09-14 13:58:36 -07:00
|
|
|
format,
|
2023-02-08 00:47:16 +01:00
|
|
|
encoder,
|
|
|
|
|
scale_factor,
|
2023-07-07 07:12:37 +02:00
|
|
|
target_size,
|
2023-02-08 00:47:16 +01:00
|
|
|
transformation,
|
|
|
|
|
&layers,
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
self.render(
|
|
|
|
|
device,
|
|
|
|
|
encoder,
|
|
|
|
|
frame,
|
|
|
|
|
clear_color,
|
|
|
|
|
scale_factor,
|
|
|
|
|
target_size,
|
|
|
|
|
&layers,
|
|
|
|
|
);
|
2019-10-23 01:21:23 +02:00
|
|
|
|
2023-02-06 22:21:27 +01:00
|
|
|
self.quad_pipeline.end_frame();
|
2023-02-01 03:24:14 +01:00
|
|
|
self.text_pipeline.end_frame();
|
2023-02-07 23:55:16 +01:00
|
|
|
self.triangle_pipeline.end_frame();
|
2023-02-01 03:24:14 +01:00
|
|
|
|
2022-11-05 03:26:19 +01:00
|
|
|
#[cfg(any(feature = "image", feature = "svg"))]
|
2023-03-07 03:47:49 +01:00
|
|
|
self.image_pipeline.end_frame();
|
2019-10-09 05:36:49 +02:00
|
|
|
}
|
2019-10-11 22:15:39 +02:00
|
|
|
|
2023-02-08 00:47:16 +01:00
|
|
|
fn prepare(
|
2019-10-25 03:47:34 +02:00
|
|
|
&mut self,
|
2020-04-16 09:06:05 +03:00
|
|
|
device: &wgpu::Device,
|
2023-01-31 06:29:21 +01:00
|
|
|
queue: &wgpu::Queue,
|
2023-09-14 13:58:36 -07:00
|
|
|
format: wgpu::TextureFormat,
|
2023-02-08 00:47:16 +01:00
|
|
|
_encoder: &mut wgpu::CommandEncoder,
|
2020-01-09 03:56:13 +01:00
|
|
|
scale_factor: f32,
|
2023-07-07 07:12:37 +02:00
|
|
|
target_size: Size<u32>,
|
2019-10-25 03:47:34 +02:00
|
|
|
transformation: Transformation,
|
2023-02-08 00:47:16 +01:00
|
|
|
layers: &[Layer<'_>],
|
2019-10-25 03:47:34 +02:00
|
|
|
) {
|
2023-02-08 00:47:16 +01:00
|
|
|
for layer in layers {
|
|
|
|
|
let bounds = (layer.bounds * scale_factor).snap();
|
2019-10-25 03:47:34 +02:00
|
|
|
|
2023-02-08 00:47:16 +01:00
|
|
|
if bounds.width < 1 || bounds.height < 1 {
|
2023-02-08 23:21:04 +01:00
|
|
|
continue;
|
2023-02-08 00:47:16 +01:00
|
|
|
}
|
2021-10-25 16:24:26 +07:00
|
|
|
|
2023-02-08 00:47:16 +01:00
|
|
|
if !layer.quads.is_empty() {
|
|
|
|
|
self.quad_pipeline.prepare(
|
|
|
|
|
device,
|
|
|
|
|
queue,
|
|
|
|
|
&layer.quads,
|
|
|
|
|
transformation,
|
|
|
|
|
scale_factor,
|
|
|
|
|
);
|
|
|
|
|
}
|
2023-02-06 22:21:27 +01:00
|
|
|
|
2023-02-08 00:47:16 +01:00
|
|
|
if !layer.meshes.is_empty() {
|
|
|
|
|
let scaled = transformation
|
|
|
|
|
* Transformation::scale(scale_factor, scale_factor);
|
|
|
|
|
|
|
|
|
|
self.triangle_pipeline.prepare(
|
|
|
|
|
device,
|
|
|
|
|
queue,
|
|
|
|
|
&layer.meshes,
|
|
|
|
|
scaled,
|
|
|
|
|
);
|
|
|
|
|
}
|
2020-04-26 17:09:03 +02:00
|
|
|
|
2023-02-08 00:47:16 +01:00
|
|
|
#[cfg(any(feature = "image", feature = "svg"))]
|
|
|
|
|
{
|
|
|
|
|
if !layer.images.is_empty() {
|
|
|
|
|
let scaled = transformation
|
|
|
|
|
* Transformation::scale(scale_factor, scale_factor);
|
|
|
|
|
|
|
|
|
|
self.image_pipeline.prepare(
|
|
|
|
|
device,
|
|
|
|
|
queue,
|
|
|
|
|
_encoder,
|
|
|
|
|
&layer.images,
|
|
|
|
|
scaled,
|
|
|
|
|
scale_factor,
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-07-07 07:12:37 +02:00
|
|
|
|
|
|
|
|
if !layer.text.is_empty() {
|
|
|
|
|
self.text_pipeline.prepare(
|
|
|
|
|
device,
|
|
|
|
|
queue,
|
|
|
|
|
&layer.text,
|
|
|
|
|
layer.bounds,
|
|
|
|
|
scale_factor,
|
|
|
|
|
target_size,
|
|
|
|
|
);
|
|
|
|
|
}
|
2023-09-14 13:58:36 -07:00
|
|
|
|
2023-11-14 12:49:49 +01:00
|
|
|
if !layer.pipelines.is_empty() {
|
|
|
|
|
for pipeline in &layer.pipelines {
|
|
|
|
|
pipeline.primitive.prepare(
|
2023-09-14 13:58:36 -07:00
|
|
|
format,
|
|
|
|
|
device,
|
|
|
|
|
queue,
|
2023-11-28 23:13:38 +01:00
|
|
|
pipeline.bounds,
|
2023-09-14 13:58:36 -07:00
|
|
|
target_size,
|
|
|
|
|
scale_factor,
|
|
|
|
|
&mut self.pipeline_storage,
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-10-29 01:21:28 +01:00
|
|
|
}
|
2023-02-08 00:47:16 +01:00
|
|
|
}
|
2019-10-25 03:47:34 +02:00
|
|
|
|
2023-02-08 00:47:16 +01:00
|
|
|
fn render(
|
|
|
|
|
&mut self,
|
|
|
|
|
device: &wgpu::Device,
|
|
|
|
|
encoder: &mut wgpu::CommandEncoder,
|
|
|
|
|
target: &wgpu::TextureView,
|
|
|
|
|
clear_color: Option<Color>,
|
|
|
|
|
scale_factor: f32,
|
|
|
|
|
target_size: Size<u32>,
|
|
|
|
|
layers: &[Layer<'_>],
|
|
|
|
|
) {
|
|
|
|
|
use std::mem::ManuallyDrop;
|
|
|
|
|
|
|
|
|
|
let mut quad_layer = 0;
|
|
|
|
|
let mut triangle_layer = 0;
|
2022-11-05 03:26:19 +01:00
|
|
|
#[cfg(any(feature = "image", feature = "svg"))]
|
2023-02-08 00:47:16 +01:00
|
|
|
let mut image_layer = 0;
|
|
|
|
|
let mut text_layer = 0;
|
|
|
|
|
|
|
|
|
|
let mut render_pass = ManuallyDrop::new(encoder.begin_render_pass(
|
|
|
|
|
&wgpu::RenderPassDescriptor {
|
2023-11-14 14:50:57 +01:00
|
|
|
label: Some("iced_wgpu render pass"),
|
2023-02-08 00:47:16 +01:00
|
|
|
color_attachments: &[Some(wgpu::RenderPassColorAttachment {
|
|
|
|
|
view: target,
|
|
|
|
|
resolve_target: None,
|
|
|
|
|
ops: wgpu::Operations {
|
|
|
|
|
load: match clear_color {
|
|
|
|
|
Some(background_color) => wgpu::LoadOp::Clear({
|
|
|
|
|
let [r, g, b, a] =
|
2023-05-31 21:31:58 +02:00
|
|
|
color::pack(background_color).components();
|
2023-02-08 00:47:16 +01:00
|
|
|
|
|
|
|
|
wgpu::Color {
|
|
|
|
|
r: f64::from(r),
|
|
|
|
|
g: f64::from(g),
|
|
|
|
|
b: f64::from(b),
|
|
|
|
|
a: f64::from(a),
|
|
|
|
|
}
|
|
|
|
|
}),
|
|
|
|
|
None => wgpu::LoadOp::Load,
|
|
|
|
|
},
|
2023-10-27 03:21:40 +02:00
|
|
|
store: wgpu::StoreOp::Store,
|
2023-02-08 00:47:16 +01:00
|
|
|
},
|
|
|
|
|
})],
|
|
|
|
|
depth_stencil_attachment: None,
|
2023-10-27 03:21:40 +02:00
|
|
|
timestamp_writes: None,
|
|
|
|
|
occlusion_query_set: None,
|
2023-02-08 00:47:16 +01:00
|
|
|
},
|
|
|
|
|
));
|
|
|
|
|
|
|
|
|
|
for layer in layers {
|
|
|
|
|
let bounds = (layer.bounds * scale_factor).snap();
|
2020-02-28 14:38:42 +01:00
|
|
|
|
2023-02-08 00:47:16 +01:00
|
|
|
if bounds.width < 1 || bounds.height < 1 {
|
2023-08-02 22:05:11 +02:00
|
|
|
continue;
|
2023-02-08 00:47:16 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if !layer.quads.is_empty() {
|
2023-05-25 10:27:27 -07:00
|
|
|
self.quad_pipeline.render(
|
|
|
|
|
quad_layer,
|
|
|
|
|
bounds,
|
2023-05-26 09:55:49 -07:00
|
|
|
&layer.quads,
|
2023-05-25 10:27:27 -07:00
|
|
|
&mut render_pass,
|
|
|
|
|
);
|
2023-02-08 00:47:16 +01:00
|
|
|
|
|
|
|
|
quad_layer += 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if !layer.meshes.is_empty() {
|
|
|
|
|
let _ = ManuallyDrop::into_inner(render_pass);
|
|
|
|
|
|
|
|
|
|
self.triangle_pipeline.render(
|
2020-02-28 14:38:42 +01:00
|
|
|
device,
|
|
|
|
|
encoder,
|
2023-02-08 00:47:16 +01:00
|
|
|
target,
|
|
|
|
|
triangle_layer,
|
|
|
|
|
target_size,
|
|
|
|
|
&layer.meshes,
|
2020-02-28 14:38:42 +01:00
|
|
|
scale_factor,
|
2019-11-05 05:26:20 +01:00
|
|
|
);
|
2023-02-07 22:53:08 +01:00
|
|
|
|
2023-02-08 00:47:16 +01:00
|
|
|
triangle_layer += 1;
|
|
|
|
|
|
|
|
|
|
render_pass = ManuallyDrop::new(encoder.begin_render_pass(
|
|
|
|
|
&wgpu::RenderPassDescriptor {
|
2023-11-14 14:50:57 +01:00
|
|
|
label: Some("iced_wgpu render pass"),
|
2023-02-07 22:53:08 +01:00
|
|
|
color_attachments: &[Some(
|
|
|
|
|
wgpu::RenderPassColorAttachment {
|
|
|
|
|
view: target,
|
|
|
|
|
resolve_target: None,
|
|
|
|
|
ops: wgpu::Operations {
|
|
|
|
|
load: wgpu::LoadOp::Load,
|
2023-10-27 03:21:40 +02:00
|
|
|
store: wgpu::StoreOp::Store,
|
2023-02-07 22:53:08 +01:00
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
)],
|
|
|
|
|
depth_stencil_attachment: None,
|
2023-10-27 03:21:40 +02:00
|
|
|
timestamp_writes: None,
|
|
|
|
|
occlusion_query_set: None,
|
2023-02-08 00:47:16 +01:00
|
|
|
},
|
|
|
|
|
));
|
|
|
|
|
}
|
2023-02-07 22:53:08 +01:00
|
|
|
|
2023-02-08 00:47:16 +01:00
|
|
|
#[cfg(any(feature = "image", feature = "svg"))]
|
|
|
|
|
{
|
|
|
|
|
if !layer.images.is_empty() {
|
|
|
|
|
self.image_pipeline.render(
|
|
|
|
|
image_layer,
|
|
|
|
|
bounds,
|
|
|
|
|
&mut render_pass,
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
image_layer += 1;
|
|
|
|
|
}
|
2020-02-28 14:38:42 +01:00
|
|
|
}
|
2019-12-06 16:47:40 +01:00
|
|
|
|
2023-02-08 00:47:16 +01:00
|
|
|
if !layer.text.is_empty() {
|
2023-02-08 01:23:40 +01:00
|
|
|
self.text_pipeline
|
|
|
|
|
.render(text_layer, bounds, &mut render_pass);
|
2023-02-08 00:47:16 +01:00
|
|
|
|
|
|
|
|
text_layer += 1;
|
|
|
|
|
}
|
2023-09-14 13:58:36 -07:00
|
|
|
|
2023-11-14 12:49:49 +01:00
|
|
|
if !layer.pipelines.is_empty() {
|
2023-11-14 14:47:29 +01:00
|
|
|
let _ = ManuallyDrop::into_inner(render_pass);
|
|
|
|
|
|
2023-11-14 12:49:49 +01:00
|
|
|
for pipeline in &layer.pipelines {
|
2023-11-28 23:13:38 +01:00
|
|
|
let viewport = (pipeline.viewport * scale_factor).snap();
|
2023-09-14 13:58:36 -07:00
|
|
|
|
2023-11-28 23:13:38 +01:00
|
|
|
if viewport.width < 1 || viewport.height < 1 {
|
2023-09-14 13:58:36 -07:00
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
2023-11-14 12:49:49 +01:00
|
|
|
pipeline.primitive.render(
|
2023-09-14 13:58:36 -07:00
|
|
|
&self.pipeline_storage,
|
|
|
|
|
target,
|
|
|
|
|
target_size,
|
2023-11-28 23:13:38 +01:00
|
|
|
viewport,
|
2023-09-14 13:58:36 -07:00
|
|
|
encoder,
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2023-11-14 14:47:29 +01:00
|
|
|
render_pass = ManuallyDrop::new(encoder.begin_render_pass(
|
|
|
|
|
&wgpu::RenderPassDescriptor {
|
2023-11-14 14:50:57 +01:00
|
|
|
label: Some("iced_wgpu render pass"),
|
2023-11-14 14:47:29 +01:00
|
|
|
color_attachments: &[Some(
|
|
|
|
|
wgpu::RenderPassColorAttachment {
|
|
|
|
|
view: target,
|
|
|
|
|
resolve_target: None,
|
|
|
|
|
ops: wgpu::Operations {
|
|
|
|
|
load: wgpu::LoadOp::Load,
|
|
|
|
|
store: wgpu::StoreOp::Store,
|
|
|
|
|
},
|
2023-09-14 13:58:36 -07:00
|
|
|
},
|
2023-11-14 14:47:29 +01:00
|
|
|
)],
|
|
|
|
|
depth_stencil_attachment: None,
|
|
|
|
|
timestamp_writes: None,
|
|
|
|
|
occlusion_query_set: None,
|
|
|
|
|
},
|
|
|
|
|
));
|
|
|
|
|
}
|
2019-10-27 03:11:54 +01:00
|
|
|
}
|
2023-02-08 00:47:16 +01:00
|
|
|
|
|
|
|
|
let _ = ManuallyDrop::into_inner(render_pass);
|
2019-10-05 19:22:51 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-06-22 00:38:36 +02:00
|
|
|
impl crate::graphics::Backend for Backend {
|
|
|
|
|
type Primitive = primitive::Custom;
|
|
|
|
|
}
|
|
|
|
|
|
2020-05-19 17:15:44 +02:00
|
|
|
impl backend::Text for Backend {
|
2023-02-04 11:12:15 +01:00
|
|
|
fn load_font(&mut self, font: Cow<'static, [u8]>) {
|
|
|
|
|
self.text_pipeline.load_font(font);
|
|
|
|
|
}
|
2019-10-05 19:22:51 +02:00
|
|
|
}
|
|
|
|
|
|
2022-11-05 03:26:19 +01:00
|
|
|
#[cfg(feature = "image")]
|
2020-05-19 17:15:44 +02:00
|
|
|
impl backend::Image for Backend {
|
2023-08-30 04:31:21 +02:00
|
|
|
fn dimensions(&self, handle: &crate::core::image::Handle) -> Size<u32> {
|
2020-05-19 17:15:44 +02:00
|
|
|
self.image_pipeline.dimensions(handle)
|
2019-10-13 18:22:26 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-05-19 17:15:44 +02:00
|
|
|
#[cfg(feature = "svg")]
|
|
|
|
|
impl backend::Svg for Backend {
|
2023-08-30 04:31:21 +02:00
|
|
|
fn viewport_dimensions(
|
|
|
|
|
&self,
|
|
|
|
|
handle: &crate::core::svg::Handle,
|
|
|
|
|
) -> Size<u32> {
|
2020-05-19 17:15:44 +02:00
|
|
|
self.image_pipeline.viewport_dimensions(handle)
|
2019-10-05 19:22:51 +02:00
|
|
|
}
|
|
|
|
|
}
|