summaryrefslogtreecommitdiffstats
path: root/wgpu/src/renderer.rs
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón <hector0193@gmail.com>2019-11-24 11:34:30 +0100
committerLibravatar GitHub <noreply@github.com>2019-11-24 11:34:30 +0100
commit149fd2aa1fa86858c7c1dcec8fd844caa78cec94 (patch)
treea199cf8d2caaf6aa60e48e93d6dd0688969d43b0 /wgpu/src/renderer.rs
parent9712b319bb7a32848001b96bd84977430f14b623 (diff)
parent47196c9007d12d3b3e0036ffabe3bf6d14ff4523 (diff)
downloadiced-149fd2aa1fa86858c7c1dcec8fd844caa78cec94.tar.gz
iced-149fd2aa1fa86858c7c1dcec8fd844caa78cec94.tar.bz2
iced-149fd2aa1fa86858c7c1dcec8fd844caa78cec94.zip
Merge pull request #65 from hecrj/improvement/docs
Documentation
Diffstat (limited to 'wgpu/src/renderer.rs')
-rw-r--r--wgpu/src/renderer.rs36
1 files changed, 20 insertions, 16 deletions
diff --git a/wgpu/src/renderer.rs b/wgpu/src/renderer.rs
index 52764248..f27a4b8a 100644
--- a/wgpu/src/renderer.rs
+++ b/wgpu/src/renderer.rs
@@ -1,7 +1,7 @@
use crate::{quad, text, Image, Primitive, Quad, Transformation};
use iced_native::{
- renderer::Debugger, renderer::Windowed, Background, Color, Layout,
- MouseCursor, Point, Rectangle, Vector, Widget,
+ renderer::{Debugger, Windowed},
+ Background, Color, Layout, MouseCursor, Point, Rectangle, Vector, Widget,
};
use wgpu::{
@@ -14,6 +14,10 @@ mod widget;
pub use target::Target;
+/// A [`wgpu`] renderer.
+///
+/// [`wgpu`]: https://github.com/gfx-rs/wgpu-rs
+#[derive(Debug)]
pub struct Renderer {
device: Device,
queue: Queue,
@@ -22,7 +26,7 @@ pub struct Renderer {
text_pipeline: text::Pipeline,
}
-pub struct Layer<'a> {
+struct Layer<'a> {
bounds: Rectangle<u32>,
offset: Vector<u32>,
quads: Vec<Quad>,
@@ -152,21 +156,21 @@ impl Renderer {
vertical_alignment,
} => {
let x = match horizontal_alignment {
- iced_native::text::HorizontalAlignment::Left => bounds.x,
- iced_native::text::HorizontalAlignment::Center => {
+ iced_native::HorizontalAlignment::Left => bounds.x,
+ iced_native::HorizontalAlignment::Center => {
bounds.x + bounds.width / 2.0
}
- iced_native::text::HorizontalAlignment::Right => {
+ iced_native::HorizontalAlignment::Right => {
bounds.x + bounds.width
}
};
let y = match vertical_alignment {
- iced_native::text::VerticalAlignment::Top => bounds.y,
- iced_native::text::VerticalAlignment::Center => {
+ iced_native::VerticalAlignment::Top => bounds.y,
+ iced_native::VerticalAlignment::Center => {
bounds.y + bounds.height / 2.0
}
- iced_native::text::VerticalAlignment::Bottom => {
+ iced_native::VerticalAlignment::Bottom => {
bounds.y + bounds.height
}
};
@@ -183,24 +187,24 @@ impl Renderer {
font_id: self.text_pipeline.find_font(*font),
layout: wgpu_glyph::Layout::default()
.h_align(match horizontal_alignment {
- iced_native::text::HorizontalAlignment::Left => {
+ iced_native::HorizontalAlignment::Left => {
wgpu_glyph::HorizontalAlign::Left
}
- iced_native::text::HorizontalAlignment::Center => {
+ iced_native::HorizontalAlignment::Center => {
wgpu_glyph::HorizontalAlign::Center
}
- iced_native::text::HorizontalAlignment::Right => {
+ iced_native::HorizontalAlignment::Right => {
wgpu_glyph::HorizontalAlign::Right
}
})
.v_align(match vertical_alignment {
- iced_native::text::VerticalAlignment::Top => {
+ iced_native::VerticalAlignment::Top => {
wgpu_glyph::VerticalAlign::Top
}
- iced_native::text::VerticalAlignment::Center => {
+ iced_native::VerticalAlignment::Center => {
wgpu_glyph::VerticalAlign::Center
}
- iced_native::text::VerticalAlignment::Bottom => {
+ iced_native::VerticalAlignment::Bottom => {
wgpu_glyph::VerticalAlign::Bottom
}
}),
@@ -304,7 +308,7 @@ impl Renderer {
&mut self,
dpi: f32,
transformation: Transformation,
- layer: &Layer,
+ layer: &Layer<'_>,
encoder: &mut wgpu::CommandEncoder,
target: &wgpu::TextureView,
) {