Skip to content

Commit

Permalink
clippy fix
Browse files Browse the repository at this point in the history
  • Loading branch information
jonmmease committed Feb 10, 2024
1 parent b376001 commit 5fcb9bb
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 9 deletions.
10 changes: 8 additions & 2 deletions avenger-wgpu/src/marks/cosmic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,12 @@ pub struct CosmicTextAtlasBuilder {
allocator: etagere::AtlasAllocator,
}

impl Default for CosmicTextAtlasBuilder {
fn default() -> Self {
Self::new()
}
}

impl CosmicTextAtlasBuilder {
pub fn new() -> Self {
Self {
Expand Down Expand Up @@ -185,7 +191,7 @@ impl TextAtlasBuilder for CosmicTextAtlasBuilder {

buffer.set_text(
&mut font_system,
&text.text,
text.text,
Attrs::new().family(family).weight(weight),
Shaping::Advanced,
);
Expand Down Expand Up @@ -363,7 +369,7 @@ impl TextAtlasBuilder for CosmicTextAtlasBuilder {
let pixel_lum = img.get_pixel(src_x as u32, src_y as u32).0[0];

// Compute pixel color, adjusting alpha by pixel luminance
let mut pixel_color = text_color.clone();
let mut pixel_color = text_color;
pixel_color[3] =
((text_color[3] as f32) * (pixel_lum as f32 / 255.0))
.round() as u8;
Expand Down
6 changes: 6 additions & 0 deletions avenger-wgpu/src/marks/gradient.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ pub struct GradientAtlasBuilder {
initialized: bool,
}

impl Default for GradientAtlasBuilder {
fn default() -> Self {
Self::new()
}
}

impl GradientAtlasBuilder {
pub fn new() -> Self {
// Initialize with single pixel image
Expand Down
6 changes: 6 additions & 0 deletions avenger-wgpu/src/marks/image.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ pub struct ImageAtlasCoords {
pub y1: f32,
}

impl Default for ImageAtlasBuilder {
fn default() -> Self {
Self::new()
}
}

impl ImageAtlasBuilder {
pub fn new() -> Self {
Self {
Expand Down
10 changes: 5 additions & 5 deletions avenger-wgpu/src/marks/multi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,7 @@ impl MultiMarkRenderer {
mark.stroke_width_vec(),
mark.corner_radius_vec(),
).map(|(x, y, width, height, fill, stroke, stroke_width, corner_radius)| -> Result<(Vec<MultiVertex>, Vec<u32>), AvengerWgpuError> {
build_verts_inds(&x, &y, &width, &height, &fill, &stroke, &stroke_width, &corner_radius)
build_verts_inds(x, &y, &width, &height, &fill, &stroke, &stroke_width, &corner_radius)
}).collect::<Result<Vec<_>, AvengerWgpuError>>()?
} else {
izip!(
Expand Down Expand Up @@ -550,7 +550,7 @@ impl MultiMarkRenderer {
mark.stroke_vec(),
mark.transform_vec(),
).map(|(path, fill, stroke, transform)| -> Result<(Vec<MultiVertex>, Vec<u32>), AvengerWgpuError> {
build_verts_inds(&path, &fill, &stroke, &transform)
build_verts_inds(path, &fill, &stroke, &transform)
}).collect::<Result<Vec<_>, AvengerWgpuError>>()?;
} else {
let verts_inds = izip!(
Expand Down Expand Up @@ -675,7 +675,7 @@ impl MultiMarkRenderer {
mark.angle_vec(),
mark.shape_index_vec(),
).map(|(x, y, fill, size, stroke, angle, shape_index)| -> Result<(Vec<MultiVertex>, Vec<u32>), AvengerWgpuError> {
build_verts_inds(&x, &y, &fill, &size, &stroke, &angle, &shape_index)
build_verts_inds(x, &y, &fill, &size, &stroke, &angle, &shape_index)
}).collect::<Result<Vec<_>, AvengerWgpuError>>()?;
} else {
let verts_inds = izip!(
Expand Down Expand Up @@ -1156,8 +1156,8 @@ impl MultiMarkRenderer {
let mut builder = BuffersBuilder::new(
&mut buffers,
VertexPositions {
fill: to_color_or_gradient_coord(&fill, &grad_coords),
stroke: to_color_or_gradient_coord(&stroke, &grad_coords),
fill: to_color_or_gradient_coord(fill, &grad_coords),
stroke: to_color_or_gradient_coord(stroke, &grad_coords),
top_left: bbox.min.to_array(),
bottom_right: bbox.max.to_array(),
},
Expand Down
4 changes: 2 additions & 2 deletions avenger-wgpu/src/marks/text.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ impl TextAtlasBuilder for NullTextAtlasBuilder {
_text: TextInstance,
_dimensions: CanvasDimensions,
) -> Result<Vec<TextAtlasRegistration>, AvengerWgpuError> {
return Err(crate::error::AvengerWgpuError::TextNotEnabled(
Err(crate::error::AvengerWgpuError::TextNotEnabled(
"Text support is not enabled".to_string(),
));
))
}

fn build(&self) -> (Extent3d, Vec<DynamicImage>) {
Expand Down

0 comments on commit 5fcb9bb

Please sign in to comment.