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

@ -1,14 +1,14 @@
[package]
name = "iced_tiny_skia"
version = "0.1.0"
authors = ["Héctor Ramón Jiménez <hector0193@gmail.com>"]
edition = "2021"
description = "A software renderer for Iced"
license = "MIT"
repository = "https://github.com/iced-rs/iced"
documentation = "https://docs.rs/iced_tiny_skia"
keywords = ["gui", "ui", "graphics", "interface", "widgets"]
categories = ["gui"]
description = "A software renderer for iced on top of tiny-skia"
version.workspace = true
edition.workspace = true
authors.workspace = true
license.workspace = true
repository.workspace = true
homepage.workspace = true
categories.workspace = true
keywords.workspace = true
[features]
image = ["iced_graphics/image"]
@ -16,27 +16,21 @@ svg = ["resvg"]
geometry = ["iced_graphics/geometry"]
[dependencies]
raw-window-handle = "0.5"
softbuffer = "0.2"
tiny-skia = "0.10"
cosmic-text = "0.9"
bytemuck = "1"
rustc-hash = "1.1"
kurbo = "0.9"
log = "0.4"
iced_graphics.workspace = true
[dependencies.iced_graphics]
version = "0.9"
path = "../graphics"
bytemuck.workspace = true
cosmic-text.workspace = true
kurbo.workspace = true
log.workspace = true
raw-window-handle.workspace = true
rustc-hash.workspace = true
softbuffer.workspace = true
tiny-skia.workspace = true
twox-hash.workspace = true
[dependencies.twox-hash]
version = "1.6"
default-features = false
resvg.workspace = true
resvg.optional = true
[target.'cfg(not(target_arch = "wasm32"))'.dependencies.twox-hash]
version = "1.6.1"
features = ["std"]
[dependencies.resvg]
version = "0.35"
optional = true
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
twox-hash.workspace = true
twox-hash.features = ["std"]

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");