From 6263f57cbb76a3ec5c763c637c3df83056ac1108 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A2ris=20DOUADY?= Date: Sat, 16 Mar 2024 05:50:35 +0100 Subject: [PATCH] Update dependencies and remove palette (2x improvement in compile time) (#143) update dependencies and remove palette --- crates/yakui-core/Cargo.toml | 8 ++++---- crates/yakui-core/src/event.rs | 4 ++-- crates/yakui-core/src/geometry/color.rs | 17 +++++++++-------- crates/yakui-wgpu/Cargo.toml | 2 +- 4 files changed, 16 insertions(+), 15 deletions(-) diff --git a/crates/yakui-core/Cargo.toml b/crates/yakui-core/Cargo.toml index be8b21f4..25f0474e 100644 --- a/crates/yakui-core/Cargo.toml +++ b/crates/yakui-core/Cargo.toml @@ -10,11 +10,11 @@ edition = "2021" [dependencies] anymap = "0.12.1" -bitflags = "1.3.2" -glam = "0.24.2" -keyboard-types = { version = "0.6.2", default-features = false } +bitflags = "2.4.2" +glam = "0.25.0" +keyboard-types = { version = "0.7.0", default-features = false } log = "0.4.17" -palette = "0.7.4" +fast-srgb8 = "1.0.0" profiling = "1.0.6" smallvec = "1.9.0" thunderdome = "0.6.0" diff --git a/crates/yakui-core/src/event.rs b/crates/yakui-core/src/event.rs index 20682750..b039466d 100644 --- a/crates/yakui-core/src/event.rs +++ b/crates/yakui-core/src/event.rs @@ -120,7 +120,7 @@ pub enum EventResponse { bitflags::bitflags! { /// A bitfield of events that a widget can register to be notified about. - #[derive(Default)] + #[derive(PartialEq, Eq, PartialOrd, Ord, Hash, Debug, Clone, Copy, Default)] pub struct EventInterest: u8 { /// Notify this widget of mouse events occuring within its layout /// rectangle. @@ -140,6 +140,6 @@ bitflags::bitflags! { const FOCUSED_KEYBOARD = 16; /// Notify this widget of all mouse events. - const MOUSE_ALL = Self::MOUSE_INSIDE.bits | Self::MOUSE_OUTSIDE.bits | Self::MOUSE_MOVE.bits; + const MOUSE_ALL = Self::MOUSE_INSIDE.bits() | Self::MOUSE_OUTSIDE.bits() | Self::MOUSE_MOVE.bits(); } } diff --git a/crates/yakui-core/src/geometry/color.rs b/crates/yakui-core/src/geometry/color.rs index 98236037..0b279012 100644 --- a/crates/yakui-core/src/geometry/color.rs +++ b/crates/yakui-core/src/geometry/color.rs @@ -48,9 +48,10 @@ impl Color { /// Create a new `Color` from a linear RGB color. pub fn from_linear(value: Vec4) -> Self { - let linear = palette::LinSrgba::new(value.x, value.y, value.z, value.w); - let (r, g, b, a) = palette::Srgba::::from_linear(linear).into_components(); - + let r = fast_srgb8::f32_to_srgb8(value.x); + let g = fast_srgb8::f32_to_srgb8(value.y); + let b = fast_srgb8::f32_to_srgb8(value.z); + let a = (value.w * 255.0).round() as u8; Self::rgba(r, g, b, a) } @@ -70,11 +71,11 @@ impl Color { /// Convert this color to a linear RGB color. pub fn to_linear(&self) -> Vec4 { - palette::Srgba::new(self.r, self.g, self.b, self.a) - .into_format::() - .into_linear() - .into_components() - .into() + let r = fast_srgb8::srgb8_to_f32(self.r); + let g = fast_srgb8::srgb8_to_f32(self.g); + let b = fast_srgb8::srgb8_to_f32(self.b); + let a = self.a as f32 / 255.0; + Vec4::new(r, g, b, a) } /// Blend with `other` in linear space diff --git a/crates/yakui-wgpu/Cargo.toml b/crates/yakui-wgpu/Cargo.toml index bbe75eda..a0431610 100644 --- a/crates/yakui-wgpu/Cargo.toml +++ b/crates/yakui-wgpu/Cargo.toml @@ -12,7 +12,7 @@ edition = "2021" yakui-core = { path = "../yakui-core", version = "0.2.0" } wgpu = "0.19.0" -glam = { version = "0.24.2", features = ["bytemuck"] } +glam = { version = "0.25.0", features = ["bytemuck"] } bytemuck = { version = "1.12.1", features = ["derive"] } thunderdome = "0.6.0" profiling = "1.0.6"