Skip to content

Commit 97794f1

Browse files
[wgpu-hal]: Reduce std usage in wgpu-hal/gles (#7597)
1 parent 0d569d5 commit 97794f1

File tree

2 files changed

+28
-29
lines changed

2 files changed

+28
-29
lines changed

wgpu-hal/src/gles/egl.rs

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use alloc::{rc::Rc, string::String, sync::Arc, vec::Vec};
22
use core::{ffi, mem::ManuallyDrop, ptr, time::Duration};
3-
use std::{os::raw, sync::LazyLock};
3+
use std::sync::LazyLock;
44

55
use glow::HasContext;
66
use hashbrown::HashMap;
@@ -22,14 +22,14 @@ const EGL_GL_COLORSPACE_KHR: u32 = 0x309D;
2222
const EGL_GL_COLORSPACE_SRGB_KHR: u32 = 0x3089;
2323

2424
type XOpenDisplayFun =
25-
unsafe extern "system" fn(display_name: *const raw::c_char) -> *mut raw::c_void;
25+
unsafe extern "system" fn(display_name: *const ffi::c_char) -> *mut ffi::c_void;
2626

27-
type XCloseDisplayFun = unsafe extern "system" fn(display: *mut raw::c_void) -> raw::c_int;
27+
type XCloseDisplayFun = unsafe extern "system" fn(display: *mut ffi::c_void) -> ffi::c_int;
2828

2929
type WlDisplayConnectFun =
30-
unsafe extern "system" fn(display_name: *const raw::c_char) -> *mut raw::c_void;
30+
unsafe extern "system" fn(display_name: *const ffi::c_char) -> *mut ffi::c_void;
3131

32-
type WlDisplayDisconnectFun = unsafe extern "system" fn(display: *const raw::c_void);
32+
type WlDisplayDisconnectFun = unsafe extern "system" fn(display: *const ffi::c_void);
3333

3434
#[cfg(not(Emscripten))]
3535
type EglInstance = khronos_egl::DynamicInstance<khronos_egl::EGL1_4>;
@@ -38,32 +38,32 @@ type EglInstance = khronos_egl::DynamicInstance<khronos_egl::EGL1_4>;
3838
type EglInstance = khronos_egl::Instance<khronos_egl::Static>;
3939

4040
type WlEglWindowCreateFun = unsafe extern "system" fn(
41-
surface: *const raw::c_void,
42-
width: raw::c_int,
43-
height: raw::c_int,
44-
) -> *mut raw::c_void;
41+
surface: *const ffi::c_void,
42+
width: ffi::c_int,
43+
height: ffi::c_int,
44+
) -> *mut ffi::c_void;
4545

4646
type WlEglWindowResizeFun = unsafe extern "system" fn(
47-
window: *const raw::c_void,
48-
width: raw::c_int,
49-
height: raw::c_int,
50-
dx: raw::c_int,
51-
dy: raw::c_int,
47+
window: *const ffi::c_void,
48+
width: ffi::c_int,
49+
height: ffi::c_int,
50+
dx: ffi::c_int,
51+
dy: ffi::c_int,
5252
);
5353

54-
type WlEglWindowDestroyFun = unsafe extern "system" fn(window: *const raw::c_void);
54+
type WlEglWindowDestroyFun = unsafe extern "system" fn(window: *const ffi::c_void);
5555

56-
type EglLabel = *const raw::c_void;
56+
type EglLabel = *const ffi::c_void;
5757

5858
#[allow(clippy::upper_case_acronyms)]
5959
type EGLDEBUGPROCKHR = Option<
6060
unsafe extern "system" fn(
6161
error: khronos_egl::Enum,
62-
command: *const raw::c_char,
62+
command: *const ffi::c_char,
6363
message_type: u32,
6464
thread_label: EglLabel,
6565
object_label: EglLabel,
66-
message: *const raw::c_char,
66+
message: *const ffi::c_char,
6767
),
6868
>;
6969

@@ -75,15 +75,15 @@ const EGL_DEBUG_MSG_INFO_KHR: u32 = 0x33BC;
7575
type EglDebugMessageControlFun = unsafe extern "system" fn(
7676
proc: EGLDEBUGPROCKHR,
7777
attrib_list: *const khronos_egl::Attrib,
78-
) -> raw::c_int;
78+
) -> ffi::c_int;
7979

8080
unsafe extern "system" fn egl_debug_proc(
8181
error: khronos_egl::Enum,
82-
command_raw: *const raw::c_char,
82+
command_raw: *const ffi::c_char,
8383
message_type: u32,
8484
_thread_label: EglLabel,
8585
_object_label: EglLabel,
86-
message_raw: *const raw::c_char,
86+
message_raw: *const ffi::c_char,
8787
) {
8888
let log_severity = match message_type {
8989
EGL_DEBUG_MSG_CRITICAL_KHR | EGL_DEBUG_MSG_ERROR_KHR => log::Level::Error,
@@ -113,13 +113,13 @@ unsafe extern "system" fn egl_debug_proc(
113113
/// enum variant is the X11 variant
114114
#[derive(Debug)]
115115
enum DisplayRef {
116-
X11(ptr::NonNull<raw::c_void>),
116+
X11(ptr::NonNull<ffi::c_void>),
117117
Wayland,
118118
}
119119

120120
impl DisplayRef {
121121
/// Convenience for getting the underlying pointer
122-
fn as_ptr(&self) -> *mut raw::c_void {
122+
fn as_ptr(&self) -> *mut ffi::c_void {
123123
match *self {
124124
Self::X11(ptr) => ptr.as_ptr(),
125125
Self::Wayland => unreachable!(),
@@ -345,7 +345,7 @@ impl AdapterContext {
345345
self.egl.as_ref().map(|egl| egl.version)
346346
}
347347

348-
pub fn raw_context(&self) -> *mut raw::c_void {
348+
pub fn raw_context(&self) -> *mut ffi::c_void {
349349
match self.egl {
350350
Some(ref egl) => egl.raw.as_ptr(),
351351
None => ptr::null_mut(),
@@ -460,7 +460,7 @@ struct Inner {
460460
supports_native_window: bool,
461461
config: khronos_egl::Config,
462462
#[cfg_attr(Emscripten, allow(dead_code))]
463-
wl_display: Option<*mut raw::c_void>,
463+
wl_display: Option<*mut ffi::c_void>,
464464
#[cfg_attr(Emscripten, allow(dead_code))]
465465
force_gles_minor_version: wgt::Gles3MinorVersion,
466466
/// Method by which the framebuffer should support srgb
@@ -1156,7 +1156,7 @@ impl super::Device {
11561156
#[derive(Debug)]
11571157
pub struct Swapchain {
11581158
surface: khronos_egl::Surface,
1159-
wl_window: Option<*mut raw::c_void>,
1159+
wl_window: Option<*mut ffi::c_void>,
11601160
framebuffer: glow::Framebuffer,
11611161
renderbuffer: glow::Renderbuffer,
11621162
/// Extent because the window lies
@@ -1262,7 +1262,7 @@ impl Surface {
12621262
unsafe fn unconfigure_impl(
12631263
&self,
12641264
device: &super::Device,
1265-
) -> Option<(khronos_egl::Surface, Option<*mut raw::c_void>)> {
1265+
) -> Option<(khronos_egl::Surface, Option<*mut ffi::c_void>)> {
12661266
let gl = &device.shared.context.lock();
12671267
match self.swapchain.write().take() {
12681268
Some(sc) => {

wgpu-hal/src/gles/wgl.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
use alloc::{borrow::ToOwned as _, ffi::CString, string::String, sync::Arc, vec::Vec};
22
use core::{
3-
ffi::{c_void, CStr},
3+
ffi::{c_int, c_void, CStr},
44
mem::{self, ManuallyDrop},
55
ptr,
66
time::Duration,
77
};
88
use std::{
9-
os::raw::c_int,
109
sync::{
1110
mpsc::{sync_channel, SyncSender},
1211
LazyLock,

0 commit comments

Comments
 (0)