From f5bcfec8211c04c4b05f63d01d52d3e5d2cc123e Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Mon, 1 Apr 2024 11:59:46 +0200 Subject: Use `rustc-hash` for most of our `HashMap` and `HashSet` instances --- winit/Cargo.toml | 1 + winit/src/multi_window.rs | 16 ++++++++-------- 2 files changed, 9 insertions(+), 8 deletions(-) (limited to 'winit') diff --git a/winit/Cargo.toml b/winit/Cargo.toml index 9d65cc1b..29e744b2 100644 --- a/winit/Cargo.toml +++ b/winit/Cargo.toml @@ -26,6 +26,7 @@ iced_graphics.workspace = true iced_runtime.workspace = true log.workspace = true +rustc-hash.workspace = true thiserror.workspace = true tracing.workspace = true window_clipboard.workspace = true diff --git a/winit/src/multi_window.rs b/winit/src/multi_window.rs index b4c25411..e17cc180 100644 --- a/winit/src/multi_window.rs +++ b/winit/src/multi_window.rs @@ -27,7 +27,7 @@ use crate::{Clipboard, Error, Proxy, Settings}; pub use crate::application::{default, Appearance, DefaultStyle}; -use std::collections::HashMap; +use rustc_hash::FxHashMap; use std::mem::ManuallyDrop; use std::sync::Arc; use std::time::Instant; @@ -381,12 +381,12 @@ async fn run_instance( )] }; - let mut ui_caches = HashMap::new(); + let mut ui_caches = FxHashMap::default(); let mut user_interfaces = ManuallyDrop::new(build_user_interfaces( &application, &mut debug, &mut window_manager, - HashMap::from_iter([( + FxHashMap::from_iter([( window::Id::MAIN, user_interface::Cache::default(), )]), @@ -759,7 +759,7 @@ async fn run_instance( // TODO mw application update returns which window IDs to update if !messages.is_empty() || uis_stale { - let mut cached_interfaces: HashMap< + let mut cached_interfaces: FxHashMap< window::Id, user_interface::Cache, > = ManuallyDrop::into_inner(user_interfaces) @@ -849,7 +849,7 @@ fn update( debug: &mut Debug, messages: &mut Vec, window_manager: &mut WindowManager, - ui_caches: &mut HashMap, + ui_caches: &mut FxHashMap, ) where C: Compositor + 'static, A::Theme: DefaultStyle, @@ -890,7 +890,7 @@ fn run_command( proxy: &mut winit::event_loop::EventLoopProxy, debug: &mut Debug, window_manager: &mut WindowManager, - ui_caches: &mut HashMap, + ui_caches: &mut FxHashMap, ) where A: Application, E: Executor, @@ -1218,8 +1218,8 @@ pub fn build_user_interfaces<'a, A: Application, C: Compositor>( application: &'a A, debug: &mut Debug, window_manager: &mut WindowManager, - mut cached_user_interfaces: HashMap, -) -> HashMap> + mut cached_user_interfaces: FxHashMap, +) -> FxHashMap> where C: Compositor, A::Theme: DefaultStyle, -- cgit From 5cd98f069dea8720bca7748d6c12fa410cbe79b5 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Sun, 7 Apr 2024 12:42:12 +0200 Subject: Use built-in `[lints]` table in `Cargo.toml` --- winit/Cargo.toml | 4 ++++ winit/src/lib.rs | 8 -------- 2 files changed, 4 insertions(+), 8 deletions(-) (limited to 'winit') diff --git a/winit/Cargo.toml b/winit/Cargo.toml index 29e744b2..dccb7c07 100644 --- a/winit/Cargo.toml +++ b/winit/Cargo.toml @@ -10,6 +10,9 @@ homepage.workspace = true categories.workspace = true keywords.workspace = true +[lints] +workspace = true + [features] default = ["x11", "wayland", "wayland-dlopen", "wayland-csd-adwaita"] debug = ["iced_runtime/debug"] @@ -41,3 +44,4 @@ winapi.workspace = true [target.'cfg(target_arch = "wasm32")'.dependencies] web-sys.workspace = true web-sys.features = ["Document", "Window"] + diff --git a/winit/src/lib.rs b/winit/src/lib.rs index 64912b3f..3619cde8 100644 --- a/winit/src/lib.rs +++ b/winit/src/lib.rs @@ -17,14 +17,6 @@ #![doc( html_logo_url = "https://raw.githubusercontent.com/iced-rs/iced/9ab6923e943f784985e9ef9ca28b10278297225d/docs/logo.svg" )] -#![forbid(rust_2018_idioms)] -#![deny( - missing_debug_implementations, - missing_docs, - unused_results, - unsafe_code, - rustdoc::broken_intra_doc_links -)] #![cfg_attr(docsrs, feature(doc_auto_cfg))] pub use iced_graphics as graphics; pub use iced_runtime as runtime; -- cgit From 6ad5bb3597f640ac329801adf735d633bf0a512f Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Tue, 9 Apr 2024 22:25:16 +0200 Subject: Port `iced_tiny_skia` to new layering architecture --- winit/src/application.rs | 12 ++++-------- winit/src/multi_window.rs | 7 +------ 2 files changed, 5 insertions(+), 14 deletions(-) (limited to 'winit') diff --git a/winit/src/application.rs b/winit/src/application.rs index d68523fa..1ca80609 100644 --- a/winit/src/application.rs +++ b/winit/src/application.rs @@ -220,13 +220,11 @@ where }; } - let compositor = C::new(graphics_settings, window.clone()).await?; - let mut renderer = compositor.create_renderer(); + let mut compositor = C::new(graphics_settings, window.clone()).await?; + let renderer = compositor.create_renderer(); for font in settings.fonts { - use crate::core::text::Renderer; - - renderer.load_font(font); + compositor.load_font(font); } let (mut event_sender, event_receiver) = mpsc::unbounded(); @@ -950,10 +948,8 @@ pub fn run_command( *cache = current_cache; } command::Action::LoadFont { bytes, tagger } => { - use crate::core::text::Renderer; - // TODO: Error handling (?) - renderer.load_font(bytes); + compositor.load_font(bytes); proxy .send_event(tagger(Ok(()))) diff --git a/winit/src/multi_window.rs b/winit/src/multi_window.rs index e17cc180..3537ac18 100644 --- a/winit/src/multi_window.rs +++ b/winit/src/multi_window.rs @@ -1194,13 +1194,8 @@ fn run_command( uis.drain().map(|(id, ui)| (id, ui.into_cache())).collect(); } command::Action::LoadFont { bytes, tagger } => { - use crate::core::text::Renderer; - - // TODO change this once we change each renderer to having a single backend reference.. :pain: // TODO: Error handling (?) - for (_, window) in window_manager.iter_mut() { - window.renderer.load_font(bytes.clone()); - } + compositor.load_font(bytes.clone()); proxy .send_event(tagger(Ok(()))) -- cgit