mirror of
https://github.com/servo/servo.git
synced 2025-07-23 07:13:52 +01:00
deps: Switch from winapi
to windows_sys
in Servo code (#32516)
This is part of the switch from `winapi` to `windows-sys`. `windows-sys` is maintained by Microsoft, so is more "official." More and more crates are switching to it.
This commit is contained in:
parent
8b35c4094a
commit
e902d63732
7 changed files with 20 additions and 20 deletions
10
Cargo.lock
generated
10
Cargo.lock
generated
|
@ -1175,7 +1175,7 @@ version = "0.20.0"
|
||||||
source = "git+https://github.com/gfx-rs/wgpu?rev=d0a5e48aa7e84683114c3870051cc414ae92ac03#d0a5e48aa7e84683114c3870051cc414ae92ac03"
|
source = "git+https://github.com/gfx-rs/wgpu?rev=d0a5e48aa7e84683114c3870051cc414ae92ac03#d0a5e48aa7e84683114c3870051cc414ae92ac03"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags 2.5.0",
|
"bitflags 2.5.0",
|
||||||
"libloading 0.7.4",
|
"libloading 0.8.3",
|
||||||
"winapi",
|
"winapi",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -1382,7 +1382,7 @@ version = "0.5.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "330c60081dcc4c72131f8eb70510f1ac07223e5d4163db481a04a0befcffa412"
|
checksum = "330c60081dcc4c72131f8eb70510f1ac07223e5d4163db481a04a0befcffa412"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"libloading 0.7.4",
|
"libloading 0.8.3",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -5582,7 +5582,7 @@ dependencies = [
|
||||||
"jemalloc-sys",
|
"jemalloc-sys",
|
||||||
"jemallocator",
|
"jemallocator",
|
||||||
"libc",
|
"libc",
|
||||||
"winapi",
|
"windows-sys 0.52.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -5704,7 +5704,7 @@ dependencies = [
|
||||||
"url",
|
"url",
|
||||||
"vergen",
|
"vergen",
|
||||||
"webxr",
|
"webxr",
|
||||||
"winapi",
|
"windows-sys 0.52.0",
|
||||||
"winit",
|
"winit",
|
||||||
"winres",
|
"winres",
|
||||||
]
|
]
|
||||||
|
@ -7337,7 +7337,7 @@ dependencies = [
|
||||||
"js-sys",
|
"js-sys",
|
||||||
"khronos-egl",
|
"khronos-egl",
|
||||||
"libc",
|
"libc",
|
||||||
"libloading 0.7.4",
|
"libloading 0.8.3",
|
||||||
"log",
|
"log",
|
||||||
"metal 0.28.0",
|
"metal 0.28.0",
|
||||||
"naga",
|
"naga",
|
||||||
|
|
|
@ -131,7 +131,7 @@ webrender_api = { git = "https://github.com/servo/webrender", branch = "0.64" }
|
||||||
webrender_traits = { path = "components/shared/webrender" }
|
webrender_traits = { path = "components/shared/webrender" }
|
||||||
wgpu-core = { git = "https://github.com/gfx-rs/wgpu", rev = "d0a5e48aa7e84683114c3870051cc414ae92ac03" }
|
wgpu-core = { git = "https://github.com/gfx-rs/wgpu", rev = "d0a5e48aa7e84683114c3870051cc414ae92ac03" }
|
||||||
wgpu-types = { git = "https://github.com/gfx-rs/wgpu", rev = "d0a5e48aa7e84683114c3870051cc414ae92ac03" }
|
wgpu-types = { git = "https://github.com/gfx-rs/wgpu", rev = "d0a5e48aa7e84683114c3870051cc414ae92ac03" }
|
||||||
winapi = "0.3"
|
windows-sys = "0.52"
|
||||||
xi-unicode = "0.1.0"
|
xi-unicode = "0.1.0"
|
||||||
xml5ever = "0.18"
|
xml5ever = "0.18"
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,7 @@ jemalloc-sys = { workspace = true }
|
||||||
libc = { workspace = true, optional = true }
|
libc = { workspace = true, optional = true }
|
||||||
|
|
||||||
[target.'cfg(windows)'.dependencies]
|
[target.'cfg(windows)'.dependencies]
|
||||||
winapi = { workspace = true, features = ["heapapi"] }
|
windows-sys = { workspace = true, features = ["Win32_System_Memory"] }
|
||||||
|
|
||||||
[target.'cfg(target_env = "ohos")'.dependencies]
|
[target.'cfg(target_env = "ohos")'.dependencies]
|
||||||
libc = { workspace = true }
|
libc = { workspace = true }
|
||||||
|
|
|
@ -61,7 +61,8 @@ mod platform {
|
||||||
pub use std::alloc::System as Allocator;
|
pub use std::alloc::System as Allocator;
|
||||||
use std::os::raw::c_void;
|
use std::os::raw::c_void;
|
||||||
|
|
||||||
use winapi::um::heapapi::{GetProcessHeap, HeapSize, HeapValidate};
|
use windows_sys::Win32::Foundation::FALSE;
|
||||||
|
use windows_sys::Win32::System::Memory::{GetProcessHeap, HeapSize, HeapValidate};
|
||||||
|
|
||||||
/// Get the size of a heap block.
|
/// Get the size of a heap block.
|
||||||
///
|
///
|
||||||
|
@ -71,8 +72,8 @@ mod platform {
|
||||||
pub unsafe extern "C" fn usable_size(mut ptr: *const c_void) -> usize {
|
pub unsafe extern "C" fn usable_size(mut ptr: *const c_void) -> usize {
|
||||||
let heap = GetProcessHeap();
|
let heap = GetProcessHeap();
|
||||||
|
|
||||||
if HeapValidate(heap, 0, ptr) == 0 {
|
if HeapValidate(heap, 0, ptr) == FALSE {
|
||||||
ptr = *(ptr as *const *const c_void).offset(-1);
|
ptr = *(ptr as *const *const c_void).offset(-1)
|
||||||
}
|
}
|
||||||
|
|
||||||
HeapSize(heap, 0, ptr) as usize
|
HeapSize(heap, 0, ptr) as usize
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
use crate::sampler::{NativeStack, Sampler};
|
use crate::sampler::{NativeStack, Sampler};
|
||||||
|
|
||||||
type MonitoredThreadId = usize; // TODO: use winapi
|
type MonitoredThreadId = usize; // TODO: use the `windows` crate to do this.
|
||||||
|
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
pub struct WindowsSampler {
|
pub struct WindowsSampler {
|
||||||
|
@ -14,7 +14,7 @@ pub struct WindowsSampler {
|
||||||
impl WindowsSampler {
|
impl WindowsSampler {
|
||||||
#[allow(unsafe_code, dead_code)]
|
#[allow(unsafe_code, dead_code)]
|
||||||
pub fn new_boxed() -> Box<dyn Sampler> {
|
pub fn new_boxed() -> Box<dyn Sampler> {
|
||||||
let thread_id = 0; // TODO: use winapi::um::processthreadsapi::GetThreadId
|
let thread_id = 0; // TODO: use windows::Win32::System::Threading::GetThreadId
|
||||||
Box::new(WindowsSampler { thread_id })
|
Box::new(WindowsSampler { thread_id })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -28,11 +28,11 @@ impl Sampler for WindowsSampler {
|
||||||
// or any other unshareable resource.
|
// or any other unshareable resource.
|
||||||
|
|
||||||
// TODO:
|
// TODO:
|
||||||
// 1: use winapi::um::processthreadsapi::SuspendThread
|
// 1: use windows::Win32::Threading::SuspendThread
|
||||||
// 2: use winapi::um::processthreadsapi::GetThreadContext
|
// 2: use windows::Win32::Threading::GetThreadContext
|
||||||
// 3: populate registers using the context, see
|
// 3: populate registers using the context, see
|
||||||
// https://dxr.mozilla.org/mozilla-central/source/tools/profiler/core/platform-win32.cpp#129
|
// https://dxr.mozilla.org/mozilla-central/source/tools/profiler/core/platform-win32.cpp#129
|
||||||
// 4: use winapi::um::processthreadsapi::ResumeThread
|
// 4: use windows::Win32::Threading::ResumeThread
|
||||||
|
|
||||||
// NOTE: End of "critical section".
|
// NOTE: End of "critical section".
|
||||||
Err(())
|
Err(())
|
||||||
|
|
|
@ -92,4 +92,4 @@ image = { workspace = true }
|
||||||
sig = "1.0"
|
sig = "1.0"
|
||||||
|
|
||||||
[target.'cfg(target_os = "windows")'.dependencies]
|
[target.'cfg(target_os = "windows")'.dependencies]
|
||||||
winapi = { workspace = true, features = ["wingdi", "winuser", "winnt", "winbase", "processenv", "namedpipeapi", "ntdef", "minwindef", "handleapi", "debugapi"] }
|
windows-sys = { workspace = true, features = ["Win32_Graphics_Gdi"] }
|
||||||
|
|
|
@ -24,8 +24,6 @@ use servo::webrender_api::units::{DeviceIntPoint, DeviceIntRect, DeviceIntSize};
|
||||||
use servo::webrender_api::ScrollLocation;
|
use servo::webrender_api::ScrollLocation;
|
||||||
use servo::webrender_traits::RenderingContext;
|
use servo::webrender_traits::RenderingContext;
|
||||||
use surfman::{Connection, Context, Device, SurfaceType};
|
use surfman::{Connection, Context, Device, SurfaceType};
|
||||||
#[cfg(target_os = "windows")]
|
|
||||||
use winapi;
|
|
||||||
use winit::dpi::{LogicalPosition, PhysicalPosition, PhysicalSize};
|
use winit::dpi::{LogicalPosition, PhysicalPosition, PhysicalSize};
|
||||||
use winit::event::{ElementState, KeyEvent, MouseButton, MouseScrollDelta, TouchPhase};
|
use winit::event::{ElementState, KeyEvent, MouseButton, MouseScrollDelta, TouchPhase};
|
||||||
use winit::keyboard::{Key as LogicalKey, ModifiersState, NamedKey};
|
use winit::keyboard::{Key as LogicalKey, ModifiersState, NamedKey};
|
||||||
|
@ -66,8 +64,9 @@ fn window_creation_scale_factor() -> Scale<f32, DeviceIndependentPixel, DevicePi
|
||||||
|
|
||||||
#[cfg(target_os = "windows")]
|
#[cfg(target_os = "windows")]
|
||||||
fn window_creation_scale_factor() -> Scale<f32, DeviceIndependentPixel, DevicePixel> {
|
fn window_creation_scale_factor() -> Scale<f32, DeviceIndependentPixel, DevicePixel> {
|
||||||
let hdc = unsafe { winapi::um::winuser::GetDC(::std::ptr::null_mut()) };
|
use windows_sys::Win32::Graphics::Gdi::{GetDC, GetDeviceCaps, LOGPIXELSY};
|
||||||
let ppi = unsafe { winapi::um::wingdi::GetDeviceCaps(hdc, winapi::um::wingdi::LOGPIXELSY) };
|
|
||||||
|
let ppi = unsafe { GetDeviceCaps(GetDC(0), LOGPIXELSY as i32) };
|
||||||
Scale::new(ppi as f32 / 96.0)
|
Scale::new(ppi as f32 / 96.0)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue