summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar shan <shankern@protonmail.com>2022-10-06 07:28:05 -0700
committerLibravatar shan <shankern@protonmail.com>2022-10-06 07:28:05 -0700
commitcb7c4676543cd508dfae8d4dcbd9cc8b61b1a94e (patch)
treed72191140c2a7a4919a0787431c1c6da60a55964
parent1eb8d972ba60592da7bfc27fe7ec80138e64dd7b (diff)
downloadiced-cb7c4676543cd508dfae8d4dcbd9cc8b61b1a94e.tar.gz
iced-cb7c4676543cd508dfae8d4dcbd9cc8b61b1a94e.tar.bz2
iced-cb7c4676543cd508dfae8d4dcbd9cc8b61b1a94e.zip
Fixed lint issues & cleaned up some documentation.
Diffstat (limited to '')
-rw-r--r--examples/clock/src/main.rs6
-rw-r--r--examples/modern_art/Cargo.toml3
-rw-r--r--examples/modern_art/src/main.rs5
-rw-r--r--examples/solar_system/src/main.rs7
-rw-r--r--glow/src/shader/common/gradient.frag2
-rw-r--r--glow/src/shader/common/triangle.frag2
-rw-r--r--glow/src/shader/common/triangle.vert2
-rw-r--r--glow/src/triangle.rs2
-rw-r--r--glow/src/triangle/solid.rs6
-rw-r--r--graphics/src/gradient.rs1
-rw-r--r--graphics/src/gradient/linear.rs2
-rw-r--r--graphics/src/layer.rs2
-rw-r--r--graphics/src/layer/image.rs2
-rw-r--r--graphics/src/layer/mesh.rs2
-rw-r--r--graphics/src/layer/quad.rs2
-rw-r--r--graphics/src/layer/text.rs2
-rw-r--r--graphics/src/transformation.rs2
-rw-r--r--graphics/src/triangle.rs2
-rw-r--r--wgpu/src/buffers.rs11
-rw-r--r--wgpu/src/lib.rs2
-rw-r--r--wgpu/src/shader/triangle_gradient.wgsl2
-rw-r--r--wgpu/src/shader/triangle_solid.wgsl2
-rw-r--r--wgpu/src/triangle.rs2
-rw-r--r--wgpu/src/triangle/gradient.rs2
24 files changed, 33 insertions, 40 deletions
diff --git a/examples/clock/src/main.rs b/examples/clock/src/main.rs
index 06ed44f0..be614201 100644
--- a/examples/clock/src/main.rs
+++ b/examples/clock/src/main.rs
@@ -1,6 +1,6 @@
use iced::executor;
use iced::widget::canvas::{
- Cache, Cursor, Geometry, LineCap, Path, Stroke, Style,
+ Cache, Cursor, Geometry, LineCap, Path, Stroke, stroke,
};
use iced::widget::{canvas, container};
use iced::{
@@ -111,7 +111,7 @@ impl<Message> canvas::Program<Message> for Clock {
let thin_stroke = || -> Stroke {
Stroke {
width,
- style: Style::Solid(Color::WHITE),
+ style: stroke::Style::Solid(Color::WHITE),
line_cap: LineCap::Round,
..Stroke::default()
}
@@ -120,7 +120,7 @@ impl<Message> canvas::Program<Message> for Clock {
let wide_stroke = || -> Stroke {
Stroke {
width: width * 3.0,
- style: Style::Solid(Color::WHITE),
+ style: stroke::Style::Solid(Color::WHITE),
line_cap: LineCap::Round,
..Stroke::default()
}
diff --git a/examples/modern_art/Cargo.toml b/examples/modern_art/Cargo.toml
index 8242f7e4..a48361ae 100644
--- a/examples/modern_art/Cargo.toml
+++ b/examples/modern_art/Cargo.toml
@@ -7,5 +7,4 @@ publish = false
[dependencies]
iced = { path = "../..", features = ["canvas", "tokio", "debug"] }
-iced_graphics = { path = "../../graphics" }
-rand = "0.8.5" \ No newline at end of file
+rand = "0.8.5"
diff --git a/examples/modern_art/src/main.rs b/examples/modern_art/src/main.rs
index a7aa2d8a..6a22b27f 100644
--- a/examples/modern_art/src/main.rs
+++ b/examples/modern_art/src/main.rs
@@ -1,13 +1,12 @@
use rand::{Rng, thread_rng};
use crate::canvas::{Cursor, Geometry};
-use iced::widget::canvas::{Cache, Fill, Frame, Gradient};
+use iced::widget::canvas::{Cache, Fill, Frame, Gradient, fill};
use iced::widget::{canvas, Canvas};
use iced::Settings;
use iced::{
executor, Application, Color, Command, Element, Length, Point, Rectangle,
Renderer, Size, Theme,
};
-use iced_graphics::widget::canvas::fill;
fn main() -> iced::Result {
ModernArt::run(Settings {
@@ -139,4 +138,4 @@ fn generate_box(frame: &mut Frame, bounds: Size) -> bool {
};
solid
-} \ No newline at end of file
+}
diff --git a/examples/solar_system/src/main.rs b/examples/solar_system/src/main.rs
index 8d713ce0..5f90245c 100644
--- a/examples/solar_system/src/main.rs
+++ b/examples/solar_system/src/main.rs
@@ -11,7 +11,7 @@ use iced::executor;
use iced::theme::{self, Theme};
use iced::time;
use iced::widget::canvas;
-use iced::widget::canvas::{Cursor, Path, Stroke};
+use iced::widget::canvas::{Cursor, Path, Stroke, stroke};
use iced::window;
use iced::{
Application, Color, Command, Element, Length, Point, Rectangle, Settings,
@@ -19,7 +19,6 @@ use iced::{
};
use std::time::Instant;
-use crate::canvas::Style;
pub fn main() -> iced::Result {
SolarSystem::run(Settings {
@@ -85,7 +84,7 @@ impl Application for SolarSystem {
}
fn subscription(&self) -> Subscription<Message> {
- time::every(std::time::Duration::from_millis(10)).map(Message::Tick)
+ time::every(time::Duration::from_millis(10)).map(Message::Tick)
}
}
@@ -179,7 +178,7 @@ impl<Message> canvas::Program<Message> for State {
frame.stroke(
&orbit,
Stroke {
- style: Style::Solid(Color::from_rgba8(0, 153, 255, 0.1)),
+ style: stroke::Style::Solid(Color::from_rgba8(0, 153, 255, 0.1)),
width: 1.0,
line_dash: canvas::LineDash {
offset: 0,
diff --git a/glow/src/shader/common/gradient.frag b/glow/src/shader/common/gradient.frag
index 89d2d398..ade9c4a1 100644
--- a/glow/src/shader/common/gradient.frag
+++ b/glow/src/shader/common/gradient.frag
@@ -47,4 +47,4 @@ void main() {
fragColor = color_stops[color_stops_size - 2];
}
}
-} \ No newline at end of file
+}
diff --git a/glow/src/shader/common/triangle.frag b/glow/src/shader/common/triangle.frag
index 0ee65239..ead40fe5 100644
--- a/glow/src/shader/common/triangle.frag
+++ b/glow/src/shader/common/triangle.frag
@@ -15,4 +15,4 @@ uniform vec4 color;
void main() {
fragColor = color;
-} \ No newline at end of file
+}
diff --git a/glow/src/shader/common/triangle.vert b/glow/src/shader/common/triangle.vert
index 09a4e324..fe505997 100644
--- a/glow/src/shader/common/triangle.vert
+++ b/glow/src/shader/common/triangle.vert
@@ -6,4 +6,4 @@ out vec2 raw_position;
void main() {
gl_Position = u_Transform * vec4(i_Position, 0.0, 1.0);
raw_position = i_Position;
-} \ No newline at end of file
+}
diff --git a/glow/src/triangle.rs b/glow/src/triangle.rs
index 5e58f4e4..f26d1cea 100644
--- a/glow/src/triangle.rs
+++ b/glow/src/triangle.rs
@@ -1,4 +1,4 @@
-//! Draw meshes of triangle.
+//! Draw meshes of triangles.
mod gradient;
mod solid;
diff --git a/glow/src/triangle/solid.rs b/glow/src/triangle/solid.rs
index d5b73eb9..3d4d1968 100644
--- a/glow/src/triangle/solid.rs
+++ b/glow/src/triangle/solid.rs
@@ -11,7 +11,7 @@ pub struct SolidProgram {
}
#[derive(Debug)]
-pub(crate) struct SolidUniformData {
+struct SolidUniformData {
pub color: Color,
pub color_location: <Context as HasContext>::UniformLocation,
pub transform: Transformation,
@@ -74,10 +74,10 @@ impl SolidProgram {
}
}
- pub fn use_program(&mut self, gl: &glow::Context, color: &Color, transform: &Transformation) {
+ pub fn use_program(&mut self, gl: &Context, color: &Color, transform: &Transformation) {
unsafe {
gl.use_program(Some(self.program))
}
self.write_uniforms(gl, color, transform)
}
-} \ No newline at end of file
+}
diff --git a/graphics/src/gradient.rs b/graphics/src/gradient.rs
index 33453c67..13600fb9 100644
--- a/graphics/src/gradient.rs
+++ b/graphics/src/gradient.rs
@@ -29,4 +29,3 @@ impl Gradient {
linear::Builder::new(start, end)
}
}
-
diff --git a/graphics/src/gradient/linear.rs b/graphics/src/gradient/linear.rs
index 00f94adc..1ffe7cf9 100644
--- a/graphics/src/gradient/linear.rs
+++ b/graphics/src/gradient/linear.rs
@@ -68,4 +68,4 @@ impl Builder {
color_stops: stops
}))
}
-} \ No newline at end of file
+}
diff --git a/graphics/src/layer.rs b/graphics/src/layer.rs
index 65e70cb3..08f07c0e 100644
--- a/graphics/src/layer.rs
+++ b/graphics/src/layer.rs
@@ -256,4 +256,4 @@ pub fn attribute_count_of<'a>(meshes: &'a [Mesh<'a>]) -> (usize, usize) {
.fold((0, 0), |(total_v, total_i), (v, i)| {
(total_v + v, total_i + i)
})
-} \ No newline at end of file
+}
diff --git a/graphics/src/layer/image.rs b/graphics/src/layer/image.rs
index 387b60ed..cbba7888 100644
--- a/graphics/src/layer/image.rs
+++ b/graphics/src/layer/image.rs
@@ -20,4 +20,4 @@ pub enum Image {
/// The bounds of the image.
bounds: Rectangle,
},
-} \ No newline at end of file
+}
diff --git a/graphics/src/layer/mesh.rs b/graphics/src/layer/mesh.rs
index a025675a..8a6b1d70 100644
--- a/graphics/src/layer/mesh.rs
+++ b/graphics/src/layer/mesh.rs
@@ -36,4 +36,4 @@ impl <'a> Into<Style> for Gradient {
}
}
}
-} \ No newline at end of file
+}
diff --git a/graphics/src/layer/quad.rs b/graphics/src/layer/quad.rs
index 4380fb6c..4def8427 100644
--- a/graphics/src/layer/quad.rs
+++ b/graphics/src/layer/quad.rs
@@ -27,4 +27,4 @@ pub struct Quad {
unsafe impl bytemuck::Zeroable for Quad {}
#[allow(unsafe_code)]
-unsafe impl bytemuck::Pod for Quad {} \ No newline at end of file
+unsafe impl bytemuck::Pod for Quad {}
diff --git a/graphics/src/layer/text.rs b/graphics/src/layer/text.rs
index b6dd4b7f..74f7a676 100644
--- a/graphics/src/layer/text.rs
+++ b/graphics/src/layer/text.rs
@@ -23,4 +23,4 @@ pub struct Text<'a> {
/// The vertical alignment of the [`Text`].
pub vertical_alignment: alignment::Vertical,
-} \ No newline at end of file
+}
diff --git a/graphics/src/transformation.rs b/graphics/src/transformation.rs
index 03f453db..116b3058 100644
--- a/graphics/src/transformation.rs
+++ b/graphics/src/transformation.rs
@@ -56,4 +56,4 @@ impl Into<Mat4> for Transformation {
fn into(self) -> Mat4 {
self.0
}
-} \ No newline at end of file
+}
diff --git a/graphics/src/triangle.rs b/graphics/src/triangle.rs
index 8f82c5df..f019d55d 100644
--- a/graphics/src/triangle.rs
+++ b/graphics/src/triangle.rs
@@ -16,4 +16,4 @@ pub struct Mesh2D {
pub struct Vertex2D {
/// The vertex position in 2D space.
pub position: [f32; 2],
-} \ No newline at end of file
+}
diff --git a/wgpu/src/buffers.rs b/wgpu/src/buffers.rs
index bf7bb49e..7a15692b 100644
--- a/wgpu/src/buffers.rs
+++ b/wgpu/src/buffers.rs
@@ -9,7 +9,7 @@ use std::mem;
const DEFAULT_STATIC_BUFFER_COUNT: wgpu::BufferAddress = 128;
/// A generic buffer struct useful for items which have no alignment requirements
-/// (e.g. Vertex, Index buffers) and are set once and never changed until destroyed.
+/// (e.g. Vertex, Index buffers) & no dynamic offsets.
#[derive(Debug)]
pub(crate) struct StaticBuffer<T> {
//stored sequentially per mesh iteration; refers to the offset index in the GPU buffer
@@ -17,7 +17,6 @@ pub(crate) struct StaticBuffer<T> {
label: &'static str,
usages: wgpu::BufferUsages,
gpu: wgpu::Buffer,
- //the static size of the buffer
size: wgpu::BufferAddress,
_data: PhantomData<T>,
}
@@ -75,11 +74,9 @@ impl<T: Pod + Zeroable> StaticBuffer<T> {
}
}
- /// Writes the current vertex data to the gpu buffer if it is currently writable with a memcpy &
- /// stores its offset.
+ /// Writes the current vertex data to the gpu buffer with a memcpy & stores its offset.
///
- /// This will return either the offset of the written bytes, or `None` if the GPU buffer is not
- /// currently writable.
+ /// Returns the size of the written bytes.
pub fn write(
&mut self,
device: &wgpu::Device,
@@ -125,4 +122,4 @@ impl<T: Pod + Zeroable> StaticBuffer<T> {
pub fn clear(&mut self) {
self.offsets.clear()
}
-} \ No newline at end of file
+}
diff --git a/wgpu/src/lib.rs b/wgpu/src/lib.rs
index 42cf712e..c76c8c7a 100644
--- a/wgpu/src/lib.rs
+++ b/wgpu/src/lib.rs
@@ -41,8 +41,8 @@
pub mod settings;
pub mod triangle;
pub mod window;
-pub mod buffers;
+mod buffers;
mod backend;
mod quad;
mod text;
diff --git a/wgpu/src/shader/triangle_gradient.wgsl b/wgpu/src/shader/triangle_gradient.wgsl
index df7158af..4efda260 100644
--- a/wgpu/src/shader/triangle_gradient.wgsl
+++ b/wgpu/src/shader/triangle_gradient.wgsl
@@ -85,4 +85,4 @@ fn fs_gradient(input: VertexOutput) -> @location(0) vec4<f32> {
}
return color;
-} \ No newline at end of file
+}
diff --git a/wgpu/src/shader/triangle_solid.wgsl b/wgpu/src/shader/triangle_solid.wgsl
index 126eceaa..be51ebb0 100644
--- a/wgpu/src/shader/triangle_solid.wgsl
+++ b/wgpu/src/shader/triangle_solid.wgsl
@@ -15,4 +15,4 @@ fn vs_main(@location(0) input: vec2<f32>) -> @builtin(position) vec4<f32> {
@fragment
fn fs_solid() -> @location(0) vec4<f32> {
return solid_uniforms.color;
-} \ No newline at end of file
+}
diff --git a/wgpu/src/triangle.rs b/wgpu/src/triangle.rs
index a7ad7b77..6e35be3c 100644
--- a/wgpu/src/triangle.rs
+++ b/wgpu/src/triangle.rs
@@ -26,7 +26,7 @@ pub(crate) struct Pipeline {
pipelines: TrianglePipelines,
}
-/// Supported triangle pipelines for different fills. Both use the same vertex shader.
+/// Supported triangle pipelines for different fills.
pub(crate) struct TrianglePipelines {
solid: SolidPipeline,
gradient: GradientPipeline,
diff --git a/wgpu/src/triangle/gradient.rs b/wgpu/src/triangle/gradient.rs
index b6553708..11c072ca 100644
--- a/wgpu/src/triangle/gradient.rs
+++ b/wgpu/src/triangle/gradient.rs
@@ -9,7 +9,7 @@ use glam::{IVec4, Vec4};
use iced_graphics::gradient::Gradient;
use iced_graphics::Transformation;
-pub(super) struct GradientPipeline {
+pub struct GradientPipeline {
pipeline: wgpu::RenderPipeline,
pub(super) uniform_buffer: DynamicBuffer<GradientUniforms>,
pub(super) storage_buffer: DynamicBuffer<GradientStorage>,