Clippy clean

This commit is contained in:
Will Temple
2026-05-16 16:59:09 -04:00
parent ccc3984b01
commit 4347232b98
13 changed files with 134 additions and 99 deletions

View File

@@ -1163,10 +1163,12 @@ fn fs_main(input: VertexOut) -> @location(0) vec4<f32> {
glyph_rect,
atlas_glyph.atlas_rect,
clip_rect,
logical_size,
self.scale_factor,
resolved_color,
active_clip,
GlyphVertexContext {
logical_size,
scale_factor: self.scale_factor,
color: resolved_color,
clip: active_clip,
},
);
}
}
@@ -1888,34 +1890,40 @@ fn build_textured_vertices(
])
}
#[allow(dead_code)]
#[derive(Clone, Copy)]
struct GlyphVertexContext {
logical_size: UiSize,
scale_factor: f32,
color: Color,
clip: ActiveClip,
}
#[allow(dead_code)]
fn push_glyph_vertices(
vertices: &mut Vec<TextVertex>,
glyph_rect: PixelRect,
atlas_rect: AtlasRect,
clip_rect: Option<PixelRect>,
logical_size: UiSize,
scale_factor: f32,
color: Color,
clip: ActiveClip,
context: GlyphVertexContext,
) {
let Some((dest_rect, uv_rect)) = clipped_glyph_quad(glyph_rect, atlas_rect, clip_rect) else {
return;
};
let scale_factor = scale_factor.max(1.0);
let scale_factor = context.scale_factor.max(1.0);
let logical_left = dest_rect.left as f32 / scale_factor;
let logical_top = dest_rect.top as f32 / scale_factor;
let logical_right = dest_rect.right as f32 / scale_factor;
let logical_bottom = dest_rect.bottom as f32 / scale_factor;
let left = to_ndc_x(logical_left, logical_size.width.max(1.0));
let right = to_ndc_x(logical_right, logical_size.width.max(1.0));
let top = to_ndc_y(logical_top, logical_size.height.max(1.0));
let bottom = to_ndc_y(logical_bottom, logical_size.height.max(1.0));
let left = to_ndc_x(logical_left, context.logical_size.width.max(1.0));
let right = to_ndc_x(logical_right, context.logical_size.width.max(1.0));
let top = to_ndc_y(logical_top, context.logical_size.height.max(1.0));
let bottom = to_ndc_y(logical_bottom, context.logical_size.height.max(1.0));
let color = color_to_f32(color);
let clip_rect = clip_rect_array(clip);
let (rounded_clip_rect, clip_params) = rounded_clip_arrays(clip);
let color = color_to_f32(context.color);
let clip_rect = clip_rect_array(context.clip);
let (rounded_clip_rect, clip_params) = rounded_clip_arrays(context.clip);
vertices.extend_from_slice(&[
TextVertex {
position: [left, top],
@@ -2335,9 +2343,7 @@ fn text_raster_clip(
let text_bounds = Rect::new(text.origin.x, text.origin.y, bounds.width, bounds.height);
absolute_clip = intersect_rects(absolute_clip, Some(text_bounds));
}
if absolute_clip.is_none() {
return None;
}
absolute_clip?;
Some(absolute_clip.map(|rect| {
Rect::new(
@@ -2524,8 +2530,8 @@ fn scale_glyph_cache_key(cache_key: CacheKey, scale_factor: f32) -> CacheKey {
#[cfg(test)]
mod tests {
use super::{
ActiveClip, AtlasRect, PixelRect, blend_rgba, build_text_vertices, build_vertices,
clip_rect_array, push_clip_state, push_glyph_vertices, rounded_clip_arrays,
ActiveClip, AtlasRect, GlyphVertexContext, PixelRect, blend_rgba, build_text_vertices,
build_vertices, clip_rect_array, push_clip_state, push_glyph_vertices, rounded_clip_arrays,
scale_glyph_cache_key, text_texture_key,
};
use cosmic_text::{CacheKey, CacheKeyFlags, SubpixelBin, fontdb};
@@ -2648,10 +2654,12 @@ mod tests {
height: 20,
},
None,
UiSize::new(100.0, 100.0),
2.0,
Color::rgb(0xFF, 0xFF, 0xFF),
ActiveClip::default(),
GlyphVertexContext {
logical_size: UiSize::new(100.0, 100.0),
scale_factor: 2.0,
color: Color::rgb(0xFF, 0xFF, 0xFF),
clip: ActiveClip::default(),
},
);
assert_eq!(vertices.len(), 6);