Merge branch 'master' into explicit-text-caching

This commit is contained in:
Héctor Ramón Jiménez 2023-09-10 00:34:21 +02:00
commit b8e5693a30
No known key found for this signature in database
GPG key ID: 7CC46565708259A7
178 changed files with 1768 additions and 1388 deletions

View file

@ -154,8 +154,16 @@ impl Frame {
.pre_concat(tiny_skia::Transform::from_rotate(angle.to_degrees()));
}
pub fn scale(&mut self, scale: f32) {
self.transform = self.transform.pre_scale(scale, scale);
pub fn scale(&mut self, scale: impl Into<f32>) {
let scale = scale.into();
self.scale_nonuniform(Vector { x: scale, y: scale });
}
pub fn scale_nonuniform(&mut self, scale: impl Into<Vector>) {
let scale = scale.into();
self.transform = self.transform.pre_scale(scale.x, scale.y);
}
pub fn into_primitive(self) -> Primitive {
@ -295,7 +303,7 @@ pub fn into_fill_rule(rule: fill::Rule) -> tiny_skia::FillRule {
}
}
pub fn into_stroke(stroke: &Stroke) -> tiny_skia::Stroke {
pub fn into_stroke(stroke: &Stroke<'_>) -> tiny_skia::Stroke {
tiny_skia::Stroke {
width: stroke.width,
line_cap: match stroke.line_cap {

View file

@ -1,3 +1,16 @@
#![forbid(rust_2018_idioms)]
#![deny(
unsafe_code,
unused_results,
clippy::extra_unused_lifetimes,
clippy::from_over_into,
clippy::needless_borrow,
clippy::new_without_default,
clippy::useless_conversion,
rustdoc::broken_intra_doc_links
)]
#![allow(clippy::inherent_to_string, clippy::type_complexity)]
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
pub mod window;
mod backend;

View file

@ -85,14 +85,14 @@ impl Cache {
);
}
entry.insert(Some(Entry {
let _ = entry.insert(Some(Entry {
width: image.width(),
height: image.height(),
pixels: buffer,
}));
}
self.hits.insert(id);
let _ = self.hits.insert(id);
self.entries.get(&id).unwrap().as_ref().map(|entry| {
tiny_skia::PixmapRef::from_bytes(
bytemuck::cast_slice(&entry.pixels),

View file

@ -267,10 +267,10 @@ impl GlyphCache {
}
}
entry.insert((buffer, image.placement));
let _ = entry.insert((buffer, image.placement));
}
self.recently_used.insert(key);
let _ = self.recently_used.insert(key);
self.entries.get(&key).map(|(buffer, placement)| {
(bytemuck::cast_slice(buffer.as_slice()), *placement)

View file

@ -92,10 +92,10 @@ impl Cache {
}
};
entry.insert(svg);
let _ = entry.insert(svg);
}
self.tree_hits.insert(id);
let _ = self.tree_hits.insert(id);
self.trees.get(&id).unwrap().as_ref()
}
@ -178,10 +178,10 @@ impl Cache {
}
}
self.rasters.insert(key, image);
let _ = self.rasters.insert(key, image);
}
self.raster_hits.insert(key);
let _ = self.raster_hits.insert(key);
self.rasters.get(&key).map(tiny_skia::Pixmap::as_ref)
}

View file

@ -46,6 +46,7 @@ impl<Theme> crate::graphics::Compositor for Compositor<Theme> {
width: u32,
height: u32,
) -> Surface {
#[allow(unsafe_code)]
let window =
unsafe { softbuffer::GraphicsContext::new(window, window) }
.expect("Create softbuffer for window");