Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 4 additions & 19 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 17 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"] }
Expand Down Expand Up @@ -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"

Expand Down
10 changes: 4 additions & 6 deletions crates/gpui/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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]
Expand All @@ -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"] }

Expand All @@ -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",
Expand Down
4 changes: 2 additions & 2 deletions crates/gpui/src/platform/screen_capture/windows.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(())
Expand Down
2 changes: 1 addition & 1 deletion crates/gpui/src/platform/windows_screen_capture.rs
Original file line number Diff line number Diff line change
@@ -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)]
Expand Down
3 changes: 2 additions & 1 deletion crates/gpui_media/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
3 changes: 0 additions & 3 deletions crates/gpui_wgpu/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
4 changes: 2 additions & 2 deletions crates/gpui_wgpu/src/wgpu_renderer/surfaces/windows.rs
Original file line number Diff line number Diff line change
@@ -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 _,
};
Expand Down Expand Up @@ -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,
};

Expand Down
8 changes: 4 additions & 4 deletions crates/gpui_wgpu/src/wgpu_renderer/surfaces/windows/shared.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 _,
};
Expand All @@ -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::{
Expand Down Expand Up @@ -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 {
Expand All @@ -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}");
}
}
Expand Down
16 changes: 7 additions & 9 deletions crates/gpui_wgpu/src/wgpu_renderer/surfaces/windows/upload.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<u8>,
texture: wgpu::Texture,
Expand All @@ -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)?;
Expand Down Expand Up @@ -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<Self> {
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)) }
Expand Down
3 changes: 1 addition & 2 deletions crates/gpui_windows/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
1 change: 0 additions & 1 deletion crates/gpui_windows/src/directx_renderer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::*;
Expand Down
Loading