From 9629535b7d62bbd4b9a630732b07c4c42896bf83 Mon Sep 17 00:00:00 2001 From: Christopher Addison Date: Sat, 26 Sep 2026 17:20:50 -0700 Subject: [PATCH] Trim unused dependencies: image AVIF encoder, bindgen, postage, windows 0.61 - image: disable default features and enable only the formats gpui's ImageFormat maps (bmp, gif, ico, jpeg, png, pnm, tiff, webp) plus rayon. The default set pulled the ravif/rav1e AVIF encoder (~28 crates) that nothing calls, and the exr/dds/hdr/qoi/tga/ff decoders. - bindgen: drop gpui's macOS build-dependency, which build.rs never used, and gate gpui_media's to macOS, the only target its build.rs generates bindings for. - postage: optional behind test-support (and a dev-dependency). Only app/test_context.rs uses it, and that module is test-support-only. - windows-capture 1.5 -> 2.0.1, which moves it to windows 0.62, so the windows-061 alias goes and gpui, gpui_wgpu and gpui_windows use the workspace windows crate. Frame::timestamp() now returns a Result and as_raw_texture() is safe. Co-Authored-By: Claude Opus 5.5 --- Cargo.lock | 23 ++++--------------- Cargo.toml | 20 +++++++++++++--- crates/gpui/Cargo.toml | 10 ++++---- .../src/platform/screen_capture/windows.rs | 4 ++-- .../src/platform/windows_screen_capture.rs | 2 +- crates/gpui_media/Cargo.toml | 3 ++- crates/gpui_wgpu/Cargo.toml | 3 --- .../src/wgpu_renderer/surfaces/windows.rs | 4 ++-- .../wgpu_renderer/surfaces/windows/shared.rs | 8 +++---- .../wgpu_renderer/surfaces/windows/upload.rs | 16 ++++++------- crates/gpui_windows/Cargo.toml | 3 +-- crates/gpui_windows/src/directx_renderer.rs | 1 - 12 files changed, 44 insertions(+), 53 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index eed52b1db66..118bc99fbf9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2290,7 +2290,6 @@ dependencies = [ "async-channel", "async-task", "backtrace", - "bindgen", "bitflags 2.13.1", "chrono", "core-text", @@ -2359,7 +2358,6 @@ dependencies = [ "wasm-bindgen", "web-sys", "web-time", - "windows 0.61.3", "windows 0.62.2", "windows-capture", "zed-font-kit", @@ -2695,7 +2693,6 @@ dependencies = [ "web-sys", "wgpu", "wgsl-rs", - "windows 0.61.3", "windows 0.62.2", "zed-font-kit", ] @@ -2723,7 +2720,6 @@ dependencies = [ "smallvec", "uuid", "wgsl-rs", - "windows 0.61.3", "windows 0.62.2", "windows-core 0.62.2", "windows-numerics 0.3.1", @@ -3087,10 +3083,8 @@ dependencies = [ "moxcms", "num-traits", "png", - "qoi", "ravif", "rayon", - "rgb", "tiff", "zune-core", "zune-jpeg", @@ -4843,15 +4837,6 @@ version = "0.1.30" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d55d956fa96f5ec02be2e13af0e20391a5aa83d6a074e3ad368959d0fab299ea" -[[package]] -name = "qoi" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f6d64c71eb498fe9eae14ce4ec935c555749aef511cca85b5568910d6e48001" -dependencies = [ - "bytemuck", -] - [[package]] name = "quick-error" version = "1.2.3" @@ -7008,15 +6993,15 @@ dependencies = [ [[package]] name = "windows-capture" -version = "1.5.0" +version = "2.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3a4df73e95feddb9ec1a7e9c2ca6323b8c97d5eeeff78d28f1eccdf19c882b24" +checksum = "09046acbe9b6d039cde50e8c8178d95bb0f9b33ed7feccc4465dadc5404b31b4" dependencies = [ "parking_lot", "rayon", "thiserror 2.0.20", - "windows 0.61.3", - "windows-future 0.2.1", + "windows 0.62.2", + "windows-future 0.3.2", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index 643966cc86f..5e161e51ba7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -73,7 +73,22 @@ futures = "0.3.32" futures-concurrency = "7.7.1" flume = "0.11" http = "1.3" -image = "0.25.1" +# Only the formats gpui's `ImageFormat` maps, plus `rayon` for the parallel +# JPEG decoder. The crate's default set also enables `avif`, an AVIF *encoder* +# (ravif/rav1e, ~28 crates) that nothing here calls (decoding AVIF needs +# `avif-native`), and `exr`/`dds`/`hdr`/`qoi`/`tga`/`ff`, which no +# `ImageFormat` variant reaches. +image = { version = "0.25.1", default-features = false, features = [ + "rayon", + "bmp", + "gif", + "ico", + "jpeg", + "png", + "pnm", + "tiff", + "webp", +] } inventory = "0.3.19" itertools = "0.14.0" log = { version = "0.4.16", features = ["kv_unstable_serde", "serde"] } @@ -148,8 +163,7 @@ objc2-foundation = { version = "=0.3.2", default-features = false, features = [ objc2-user-notifications = "0.3" mach2 = "0.5" metal = "0.33" -windows-capture = "1.5.0" -windows-061 = { package = "windows", version = "0.61.3" } +windows-capture = "2.0.1" env_logger = "0.11" unicode-segmentation = "1.10" diff --git a/crates/gpui/Cargo.toml b/crates/gpui/Cargo.toml index 7f0b9754889..f77df474cb0 100644 --- a/crates/gpui/Cargo.toml +++ b/crates/gpui/Cargo.toml @@ -28,6 +28,7 @@ test-support = [ "wayland", "x11", "proptest", + "dep:postage", ] # Exposes `Window::render_to_image` without the rest of `test-support`, which # also changes how windows schedule and draw frames. @@ -75,7 +76,7 @@ num_cpus = "1.13" parking = "2.0.0" parking_lot.workspace = true palette.workspace = true -postage.workspace = true +postage = { workspace = true, optional = true } proptest = { workspace = true, optional = true } chrono.workspace = true profiling.workspace = true @@ -139,10 +140,10 @@ objc2-metal = { version = "0.3", optional = true } [target.'cfg(target_os = "windows")'.dependencies] windows = { workspace = true, features = [ "Win32_Foundation", + "Win32_Graphics_Direct3D11", "Win32_System_Power", ] } windows-capture = { workspace = true, optional = true } -windows-061 = { workspace = true, features = ["Win32_Graphics_Direct3D11"] } [dev-dependencies] @@ -154,6 +155,7 @@ env_logger.workspace = true gpui_platform = { workspace = true, features = ["font-kit", "wayland", "x11"] } gpui_util = { workspace = true } lyon = { version = "1.0", features = ["extra"] } +postage.workspace = true rand.workspace = true scheduler = { workspace = true, features = ["test-support"] } @@ -167,12 +169,8 @@ web-sys = { version = "0.3", features = ["console"] } [build-dependencies] embed-resource = { version = "3.0", optional = true } -[target.'cfg(target_os = "macos")'.build-dependencies] -bindgen = "0.72" - [package.metadata.cargo-shear] ignored = [ - "bindgen", "font-kit", "getrandom", "objc2", diff --git a/crates/gpui/src/platform/screen_capture/windows.rs b/crates/gpui/src/platform/screen_capture/windows.rs index 0fcc273e321..c3980952b34 100644 --- a/crates/gpui/src/platform/screen_capture/windows.rs +++ b/crates/gpui/src/platform/screen_capture/windows.rs @@ -135,14 +135,14 @@ impl windows_capture::capture::GraphicsCaptureApiHandler for CaptureHandler { frame: &mut windows_capture::frame::Frame, _control: windows_capture::graphics_capture_api::InternalCaptureControl, ) -> std::result::Result<(), Self::Error> { - let texture = unsafe { frame.as_raw_texture() }.clone(); + let texture = frame.as_raw_texture().clone(); let frame = WindowsScreenCaptureFrame::new( texture, crate::size( DevicePixels(frame.width() as i32), DevicePixels(frame.height() as i32), ), - frame.timestamp().Duration.max(0) as u64, + frame.timestamp()?.Duration.max(0) as u64, ); (self.frame_callback)(ScreenCaptureFrame(frame)); Ok(()) diff --git a/crates/gpui/src/platform/windows_screen_capture.rs b/crates/gpui/src/platform/windows_screen_capture.rs index b7f3f60c80f..636848d2c9f 100644 --- a/crates/gpui/src/platform/windows_screen_capture.rs +++ b/crates/gpui/src/platform/windows_screen_capture.rs @@ -1,6 +1,6 @@ use crate::{DevicePixels, Size}; use std::sync::Arc; -use windows_061::Win32::Graphics::Direct3D11::ID3D11Texture2D; +use windows::Win32::Graphics::Direct3D11::ID3D11Texture2D; /// A Windows Graphics Capture frame backed by its native D3D11 texture. #[derive(Clone)] diff --git a/crates/gpui_media/Cargo.toml b/crates/gpui_media/Cargo.toml index 780172fb2cd..ce404c6e2e4 100644 --- a/crates/gpui_media/Cargo.toml +++ b/crates/gpui_media/Cargo.toml @@ -21,5 +21,6 @@ metal.workspace = true core-video.workspace = true objc.workspace = true -[build-dependencies] +# build.rs only generates bindings on macOS. +[target.'cfg(target_os = "macos")'.build-dependencies] bindgen = "0.72" diff --git a/crates/gpui_wgpu/Cargo.toml b/crates/gpui_wgpu/Cargo.toml index c826590e2a6..ffe59f2e92c 100644 --- a/crates/gpui_wgpu/Cargo.toml +++ b/crates/gpui_wgpu/Cargo.toml @@ -57,9 +57,6 @@ objc2-metal = "0.3" windows = { workspace = true, features = [ "Win32_Foundation", "Win32_Graphics_Direct3D12", -] } -windows-061 = { workspace = true, features = [ - "Win32_Foundation", "Win32_Graphics_Direct3D", "Win32_Graphics_Direct3D11", "Win32_Graphics_Dxgi", diff --git a/crates/gpui_wgpu/src/wgpu_renderer/surfaces/windows.rs b/crates/gpui_wgpu/src/wgpu_renderer/surfaces/windows.rs index 19f058f7d85..2c05f00940e 100644 --- a/crates/gpui_wgpu/src/wgpu_renderer/surfaces/windows.rs +++ b/crates/gpui_wgpu/src/wgpu_renderer/surfaces/windows.rs @@ -1,7 +1,7 @@ use super::*; use anyhow::Result; use collections::FxHashMap; -use windows_061::{ +use windows::{ Win32::Graphics::Direct3D11::{D3D11_TEXTURE2D_DESC, ID3D11Texture2D}, core::Interface as _, }; @@ -221,7 +221,7 @@ fn source_size(source: &ID3D11Texture2D) -> wgpu::Extent3d { } fn validate_capture_descriptor(descriptor: &D3D11_TEXTURE2D_DESC) -> Result<()> { - use windows_061::Win32::Graphics::Dxgi::Common::{ + use windows::Win32::Graphics::Dxgi::Common::{ DXGI_FORMAT_B8G8R8A8_UNORM, DXGI_FORMAT_B8G8R8A8_UNORM_SRGB, }; diff --git a/crates/gpui_wgpu/src/wgpu_renderer/surfaces/windows/shared.rs b/crates/gpui_wgpu/src/wgpu_renderer/surfaces/windows/shared.rs index 2a8c60dbd79..e6f3217f009 100644 --- a/crates/gpui_wgpu/src/wgpu_renderer/surfaces/windows/shared.rs +++ b/crates/gpui_wgpu/src/wgpu_renderer/surfaces/windows/shared.rs @@ -2,7 +2,7 @@ use super::{ capture_size, capture_texture_descriptor, source_descriptor, validate_capture_descriptor, }; use anyhow::{Context as _, Result}; -use windows_061::{ +use windows::{ Win32::Graphics::Direct3D11::{ID3D11DeviceContext4, ID3D11Fence, ID3D11Texture2D}, core::Interface as _, }; @@ -23,7 +23,7 @@ impl SharedTexture { hal_device: &wgpu::hal::dx12::Device, source: &ID3D11Texture2D, ) -> Result<(Self, wgpu::Texture)> { - use windows_061::Win32::{ + use windows::Win32::{ Foundation::GENERIC_ALL, Graphics::{ Direct3D11::{ @@ -172,7 +172,7 @@ fn open_shared_resources( )) } -struct OwnedHandle(windows_061::Win32::Foundation::HANDLE); +struct OwnedHandle(windows::Win32::Foundation::HANDLE); impl OwnedHandle { fn raw(&self) -> *mut std::ffi::c_void { @@ -182,7 +182,7 @@ impl OwnedHandle { impl Drop for OwnedHandle { fn drop(&mut self) { - if let Err(error) = unsafe { windows_061::Win32::Foundation::CloseHandle(self.0) } { + if let Err(error) = unsafe { windows::Win32::Foundation::CloseHandle(self.0) } { log::error!("failed to close shared capture handle: {error}"); } } diff --git a/crates/gpui_wgpu/src/wgpu_renderer/surfaces/windows/upload.rs b/crates/gpui_wgpu/src/wgpu_renderer/surfaces/windows/upload.rs index 5876e8cb141..50f0b30fec1 100644 --- a/crates/gpui_wgpu/src/wgpu_renderer/surfaces/windows/upload.rs +++ b/crates/gpui_wgpu/src/wgpu_renderer/surfaces/windows/upload.rs @@ -2,11 +2,11 @@ use super::{ capture_size, capture_texture_descriptor, source_descriptor, validate_capture_descriptor, }; use anyhow::{Context as _, Result}; -use windows_061::Win32::Graphics::Direct3D11::ID3D11Texture2D; +use windows::Win32::Graphics::Direct3D11::ID3D11Texture2D; pub(super) struct UploadedTexture { pub(super) size: wgpu::Extent3d, - context: windows_061::Win32::Graphics::Direct3D11::ID3D11DeviceContext, + context: windows::Win32::Graphics::Direct3D11::ID3D11DeviceContext, staging: ID3D11Texture2D, pixels: Vec, texture: wgpu::Texture, @@ -17,9 +17,7 @@ impl UploadedTexture { device: &wgpu::Device, source: &ID3D11Texture2D, ) -> Result<(Self, wgpu::Texture)> { - use windows_061::Win32::Graphics::Direct3D11::{ - D3D11_CPU_ACCESS_READ, D3D11_USAGE_STAGING, - }; + use windows::Win32::Graphics::Direct3D11::{D3D11_CPU_ACCESS_READ, D3D11_USAGE_STAGING}; let mut descriptor = source_descriptor(source); validate_capture_descriptor(&descriptor)?; @@ -80,17 +78,17 @@ impl UploadedTexture { } struct MappedTexture<'a> { - context: &'a windows_061::Win32::Graphics::Direct3D11::ID3D11DeviceContext, + context: &'a windows::Win32::Graphics::Direct3D11::ID3D11DeviceContext, texture: &'a ID3D11Texture2D, - mapped: windows_061::Win32::Graphics::Direct3D11::D3D11_MAPPED_SUBRESOURCE, + mapped: windows::Win32::Graphics::Direct3D11::D3D11_MAPPED_SUBRESOURCE, } impl<'a> MappedTexture<'a> { fn new( - context: &'a windows_061::Win32::Graphics::Direct3D11::ID3D11DeviceContext, + context: &'a windows::Win32::Graphics::Direct3D11::ID3D11DeviceContext, texture: &'a ID3D11Texture2D, ) -> Result { - use windows_061::Win32::Graphics::Direct3D11::{D3D11_MAP_READ, D3D11_MAPPED_SUBRESOURCE}; + use windows::Win32::Graphics::Direct3D11::{D3D11_MAP_READ, D3D11_MAPPED_SUBRESOURCE}; let mut mapped = D3D11_MAPPED_SUBRESOURCE::default(); unsafe { context.Map(texture, 0, D3D11_MAP_READ, 0, Some(&mut mapped)) } diff --git a/crates/gpui_windows/Cargo.toml b/crates/gpui_windows/Cargo.toml index 96efd5c6919..073a16ce083 100644 --- a/crates/gpui_windows/Cargo.toml +++ b/crates/gpui_windows/Cargo.toml @@ -40,8 +40,7 @@ rand.workspace = true raw-window-handle.workspace = true smallvec.workspace = true uuid.workspace = true -windows.workspace = true -windows-061 = { workspace = true, features = ["Win32_Graphics_Direct3D11"] } +windows = { workspace = true, features = ["Win32_Graphics_Direct3D11"] } windows-core.workspace = true windows-numerics = "0.3" windows-registry = "0.6.1" diff --git a/crates/gpui_windows/src/directx_renderer.rs b/crates/gpui_windows/src/directx_renderer.rs index 3667211323e..590580f4470 100644 --- a/crates/gpui_windows/src/directx_renderer.rs +++ b/crates/gpui_windows/src/directx_renderer.rs @@ -36,7 +36,6 @@ use windows::{ }, core::{HSTRING, Interface, PCSTR}, }; -use windows_061::core::Interface as _; use crate::directx_renderer::shader_resources::ShaderModule; use crate::*;