summaryrefslogtreecommitdiffstats
path: root/wgpu
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón <hector0193@gmail.com>2020-03-29 15:42:17 +0200
committerLibravatar GitHub <noreply@github.com>2020-03-29 15:42:17 +0200
commit5b2c71a708f907f2b3c73bcdf56fbca5cd80adde (patch)
treea2189119225605bbecce4b983da9e95fc5e2415a /wgpu
parent57b2daa57e7312b3015817d8f400b3523f2e42a7 (diff)
parent01bc95c2a3dcaf0c2916a2d2891094e1dc1e11e5 (diff)
downloadiced-5b2c71a708f907f2b3c73bcdf56fbca5cd80adde.tar.gz
iced-5b2c71a708f907f2b3c73bcdf56fbca5cd80adde.tar.bz2
iced-5b2c71a708f907f2b3c73bcdf56fbca5cd80adde.zip
Merge pull request #242 from kaimast/master
Some more code cleanups.
Diffstat (limited to '')
-rw-r--r--wgpu/src/renderer.rs12
-rw-r--r--wgpu/src/renderer/widget/button.rs3
-rw-r--r--wgpu/src/renderer/widget/checkbox.rs2
-rw-r--r--wgpu/src/renderer/widget/container.rs1
-rw-r--r--wgpu/src/renderer/widget/text_input.rs3
-rw-r--r--wgpu/src/settings.rs2
-rw-r--r--wgpu/src/transformation.rs2
-rw-r--r--wgpu/src/triangle/msaa.rs2
8 files changed, 12 insertions, 15 deletions
diff --git a/wgpu/src/renderer.rs b/wgpu/src/renderer.rs
index c06af339..e847cb64 100644
--- a/wgpu/src/renderer.rs
+++ b/wgpu/src/renderer.rs
@@ -103,8 +103,8 @@ impl Renderer {
layers.push(Layer::new(Rectangle {
x: 0,
y: 0,
- width: u32::from(width),
- height: u32::from(height),
+ width,
+ height,
}));
self.draw_primitive(Vector::new(0.0, 0.0), primitive, &mut layers);
@@ -356,7 +356,7 @@ impl Renderer {
) {
let bounds = layer.bounds * scale_factor;
- if layer.meshes.len() > 0 {
+ if !layer.meshes.is_empty() {
let scaled = transformation
* Transformation::scale(scale_factor, scale_factor);
@@ -372,7 +372,7 @@ impl Renderer {
);
}
- if layer.quads.len() > 0 {
+ if !layer.quads.is_empty() {
self.quad_pipeline.draw(
device,
encoder,
@@ -386,7 +386,7 @@ impl Renderer {
#[cfg(any(feature = "image", feature = "svg"))]
{
- if layer.images.len() > 0 {
+ if !layer.images.is_empty() {
let scaled = transformation
* Transformation::scale(scale_factor, scale_factor);
@@ -402,7 +402,7 @@ impl Renderer {
}
}
- if layer.text.len() > 0 {
+ if !layer.text.is_empty() {
for text in layer.text.iter() {
// Target physical coordinates directly to avoid blurry text
let text = wgpu_glyph::Section {
diff --git a/wgpu/src/renderer/widget/button.rs b/wgpu/src/renderer/widget/button.rs
index 0de5bf5c..359b4866 100644
--- a/wgpu/src/renderer/widget/button.rs
+++ b/wgpu/src/renderer/widget/button.rs
@@ -10,7 +10,7 @@ impl iced_native::button::Renderer for Renderer {
fn draw<Message>(
&mut self,
- defaults: &Defaults,
+ _defaults: &Defaults,
bounds: Rectangle,
cursor_position: Point,
is_disabled: bool,
@@ -39,7 +39,6 @@ impl iced_native::button::Renderer for Renderer {
text: defaults::Text {
color: styling.text_color,
},
- ..*defaults
},
content_layout,
cursor_position,
diff --git a/wgpu/src/renderer/widget/checkbox.rs b/wgpu/src/renderer/widget/checkbox.rs
index 1a0585d3..ecacf1de 100644
--- a/wgpu/src/renderer/widget/checkbox.rs
+++ b/wgpu/src/renderer/widget/checkbox.rs
@@ -38,7 +38,7 @@ impl checkbox::Renderer for Renderer {
content: crate::text::CHECKMARK_ICON.to_string(),
font: crate::text::BUILTIN_ICONS,
size: bounds.height * 0.7,
- bounds: bounds,
+ bounds,
color: style.checkmark_color,
horizontal_alignment: HorizontalAlignment::Center,
vertical_alignment: VerticalAlignment::Center,
diff --git a/wgpu/src/renderer/widget/container.rs b/wgpu/src/renderer/widget/container.rs
index 2d4d1db8..dda7dc8a 100644
--- a/wgpu/src/renderer/widget/container.rs
+++ b/wgpu/src/renderer/widget/container.rs
@@ -19,7 +19,6 @@ impl iced_native::container::Renderer for Renderer {
text: defaults::Text {
color: style.text_color.unwrap_or(defaults.text.color),
},
- ..*defaults
};
let (content, mouse_cursor) =
diff --git a/wgpu/src/renderer/widget/text_input.rs b/wgpu/src/renderer/widget/text_input.rs
index 170ac3c5..9093b0c6 100644
--- a/wgpu/src/renderer/widget/text_input.rs
+++ b/wgpu/src/renderer/widget/text_input.rs
@@ -106,8 +106,7 @@ impl text_input::Renderer for Renderer {
style_sheet.placeholder_color()
} else {
style_sheet.value_color()
- }
- .into(),
+ },
font,
bounds: Rectangle {
width: f32::INFINITY,
diff --git a/wgpu/src/settings.rs b/wgpu/src/settings.rs
index f946ce0d..5ee245b6 100644
--- a/wgpu/src/settings.rs
+++ b/wgpu/src/settings.rs
@@ -45,7 +45,7 @@ pub enum Antialiasing {
}
impl Antialiasing {
- pub(crate) fn sample_count(&self) -> u32 {
+ pub(crate) fn sample_count(self) -> u32 {
match self {
Antialiasing::MSAAx2 => 2,
Antialiasing::MSAAx4 => 4,
diff --git a/wgpu/src/transformation.rs b/wgpu/src/transformation.rs
index 666696f3..c991f330 100644
--- a/wgpu/src/transformation.rs
+++ b/wgpu/src/transformation.rs
@@ -49,6 +49,6 @@ impl AsRef<[f32; 16]> for Transformation {
impl From<Transformation> for [f32; 16] {
fn from(t: Transformation) -> [f32; 16] {
- t.as_ref().clone()
+ *t.as_ref()
}
}
diff --git a/wgpu/src/triangle/msaa.rs b/wgpu/src/triangle/msaa.rs
index 7ccfb062..f65f0a00 100644
--- a/wgpu/src/triangle/msaa.rs
+++ b/wgpu/src/triangle/msaa.rs
@@ -120,7 +120,7 @@ impl Blit {
format,
pipeline,
constants: constant_bind_group,
- texture_layout: texture_layout,
+ texture_layout,
sample_count: antialiasing.sample_count(),
targets: None,
}