Skip to content

Commit

Permalink
chore: format code
Browse files Browse the repository at this point in the history
  • Loading branch information
richerfu committed Sep 21, 2024
1 parent bf8c0f9 commit 6fbfe1c
Show file tree
Hide file tree
Showing 4 changed files with 125 additions and 107 deletions.
92 changes: 46 additions & 46 deletions glutin/src/api/egl/display.rs
Original file line number Diff line number Diff line change
Expand Up @@ -259,38 +259,37 @@ impl Display {
let extensions = CLIENT_EXTENSIONS.get().unwrap();

let mut attrs = Vec::<EGLAttrib>::with_capacity(5);
let (platform, display) = match display {
RawDisplayHandle::Wayland(handle)
if extensions.contains("EGL_KHR_platform_wayland") =>
{
(egl::PLATFORM_WAYLAND_KHR, handle.display.as_ptr())
},
RawDisplayHandle::Xlib(handle) if extensions.contains("EGL_KHR_platform_x11") => {
attrs.push(egl::PLATFORM_X11_SCREEN_KHR as EGLAttrib);
attrs.push(handle.screen as EGLAttrib);
(
egl::PLATFORM_X11_KHR,
handle.display.map_or(egl::DEFAULT_DISPLAY as *mut _, |d| d.as_ptr()),
)
},
RawDisplayHandle::Gbm(handle) if extensions.contains("EGL_KHR_platform_gbm") => {
(egl::PLATFORM_GBM_KHR, handle.gbm_device.as_ptr())
},
RawDisplayHandle::Drm(_) => {
return Err(ErrorKind::NotSupported(
let (platform, display) =
match display {
RawDisplayHandle::Wayland(handle)
if extensions.contains("EGL_KHR_platform_wayland") =>
{
(egl::PLATFORM_WAYLAND_KHR, handle.display.as_ptr())
},
RawDisplayHandle::Xlib(handle) if extensions.contains("EGL_KHR_platform_x11") => {
attrs.push(egl::PLATFORM_X11_SCREEN_KHR as EGLAttrib);
attrs.push(handle.screen as EGLAttrib);
(
egl::PLATFORM_X11_KHR,
handle.display.map_or(egl::DEFAULT_DISPLAY as *mut _, |d| d.as_ptr()),
)
},
RawDisplayHandle::Gbm(handle) if extensions.contains("EGL_KHR_platform_gbm") => {
(egl::PLATFORM_GBM_KHR, handle.gbm_device.as_ptr())
},
RawDisplayHandle::Drm(_) => return Err(ErrorKind::NotSupported(
"`DrmDisplayHandle` must be used with `egl::display::Display::with_device()`",
)
.into())
},
RawDisplayHandle::Android(_) if extensions.contains("EGL_KHR_platform_android") => {
(egl::PLATFORM_ANDROID_KHR, egl::DEFAULT_DISPLAY as *mut _)
},
_ => {
return Err(
ErrorKind::NotSupported("provided display handle is not supported").into()
)
},
};
.into()),
RawDisplayHandle::Android(_) if extensions.contains("EGL_KHR_platform_android") => {
(egl::PLATFORM_ANDROID_KHR, egl::DEFAULT_DISPLAY as *mut _)
},
_ => {
return Err(
ErrorKind::NotSupported("provided display handle is not supported").into()
)
},
};

// Push at the end so we can pop it on failure
let mut has_display_reference = extensions.contains("EGL_KHR_display_reference");
Expand Down Expand Up @@ -430,24 +429,25 @@ impl Display {
}

fn get_display(egl: &Egl, display: RawDisplayHandle) -> Result<EglDisplay> {
let display = match display {
RawDisplayHandle::Gbm(handle) => handle.gbm_device.as_ptr(),
RawDisplayHandle::Drm(_) => {
return Err(ErrorKind::NotSupported(
let display =
match display {
RawDisplayHandle::Gbm(handle) => handle.gbm_device.as_ptr(),
RawDisplayHandle::Drm(_) => return Err(ErrorKind::NotSupported(
"`DrmDisplayHandle` must be used with `egl::display::Display::with_device()`",
)
.into())
},
RawDisplayHandle::Xlib(XlibDisplayHandle { display, .. }) => {
display.map_or(egl::DEFAULT_DISPLAY as *mut _, |d| d.as_ptr())
},
RawDisplayHandle::Android(_) | RawDisplayHandle::Ohos(_) => egl::DEFAULT_DISPLAY as *mut _,
_ => {
return Err(
ErrorKind::NotSupported("provided display handle is not supported").into()
)
},
};
.into()),
RawDisplayHandle::Xlib(XlibDisplayHandle { display, .. }) => {
display.map_or(egl::DEFAULT_DISPLAY as *mut _, |d| d.as_ptr())
},
RawDisplayHandle::Android(_) | RawDisplayHandle::Ohos(_) => {
egl::DEFAULT_DISPLAY as *mut _
},
_ => {
return Err(
ErrorKind::NotSupported("provided display handle is not supported").into()
)
},
};

let display = unsafe { egl.GetDisplay(display) };
Self::check_display_error(display).map(EglDisplay::Legacy)
Expand Down
64 changes: 35 additions & 29 deletions glutin_egl_sys/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,35 +19,41 @@ fn main() {
|| target.contains("ios")
{
let mut file = File::create(dest.join("egl_bindings.rs")).unwrap();
let reg = Registry::new(Api::Egl, (1, 5), Profile::Core, Fallbacks::All, [
"EGL_ANDROID_native_fence_sync",
"EGL_EXT_buffer_age",
"EGL_EXT_create_context_robustness",
"EGL_EXT_device_base",
"EGL_EXT_device_drm",
"EGL_EXT_device_drm_render_node",
"EGL_EXT_device_enumeration",
"EGL_EXT_device_query",
"EGL_EXT_device_query_name",
"EGL_EXT_pixel_format_float",
"EGL_EXT_platform_base",
"EGL_EXT_platform_device",
"EGL_EXT_platform_wayland",
"EGL_EXT_platform_x11",
"EGL_EXT_swap_buffers_with_damage",
"EGL_KHR_create_context",
"EGL_KHR_create_context_no_error",
"EGL_KHR_display_reference",
"EGL_KHR_fence_sync",
"EGL_KHR_image_base",
"EGL_KHR_platform_android",
"EGL_KHR_platform_gbm",
"EGL_KHR_platform_wayland",
"EGL_KHR_platform_x11",
"EGL_KHR_swap_buffers_with_damage",
"EGL_KHR_wait_sync",
"EGL_MESA_platform_gbm",
]);
let reg = Registry::new(
Api::Egl,
(1, 5),
Profile::Core,
Fallbacks::All,
[
"EGL_ANDROID_native_fence_sync",
"EGL_EXT_buffer_age",
"EGL_EXT_create_context_robustness",
"EGL_EXT_device_base",
"EGL_EXT_device_drm",
"EGL_EXT_device_drm_render_node",
"EGL_EXT_device_enumeration",
"EGL_EXT_device_query",
"EGL_EXT_device_query_name",
"EGL_EXT_pixel_format_float",
"EGL_EXT_platform_base",
"EGL_EXT_platform_device",
"EGL_EXT_platform_wayland",
"EGL_EXT_platform_x11",
"EGL_EXT_swap_buffers_with_damage",
"EGL_KHR_create_context",
"EGL_KHR_create_context_no_error",
"EGL_KHR_display_reference",
"EGL_KHR_fence_sync",
"EGL_KHR_image_base",
"EGL_KHR_platform_android",
"EGL_KHR_platform_gbm",
"EGL_KHR_platform_wayland",
"EGL_KHR_platform_x11",
"EGL_KHR_swap_buffers_with_damage",
"EGL_KHR_wait_sync",
"EGL_MESA_platform_gbm",
],
);

if target.contains("ios") {
reg.write_bindings(gl_generator::StaticStructGenerator, &mut file)
Expand Down
38 changes: 22 additions & 16 deletions glutin_glx_sys/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,28 @@ fn main() {
.unwrap();

let mut file = File::create(dest.join("glx_extra_bindings.rs")).unwrap();
Registry::new(Api::Glx, (1, 4), Profile::Core, Fallbacks::All, [
"GLX_ARB_context_flush_control",
"GLX_ARB_create_context",
"GLX_ARB_create_context_no_error",
"GLX_ARB_create_context_profile",
"GLX_ARB_create_context_robustness",
"GLX_ARB_fbconfig_float",
"GLX_ARB_framebuffer_sRGB",
"GLX_ARB_multisample",
"GLX_EXT_buffer_age",
"GLX_EXT_create_context_es2_profile",
"GLX_EXT_framebuffer_sRGB",
"GLX_EXT_swap_control",
"GLX_MESA_swap_control",
"GLX_SGI_swap_control",
])
Registry::new(
Api::Glx,
(1, 4),
Profile::Core,
Fallbacks::All,
[
"GLX_ARB_context_flush_control",
"GLX_ARB_create_context",
"GLX_ARB_create_context_no_error",
"GLX_ARB_create_context_profile",
"GLX_ARB_create_context_robustness",
"GLX_ARB_fbconfig_float",
"GLX_ARB_framebuffer_sRGB",
"GLX_ARB_multisample",
"GLX_EXT_buffer_age",
"GLX_EXT_create_context_es2_profile",
"GLX_EXT_framebuffer_sRGB",
"GLX_EXT_swap_control",
"GLX_MESA_swap_control",
"GLX_SGI_swap_control",
],
)
.write_bindings(gl_generator::StructGenerator, &mut file)
.unwrap();
}
Expand Down
38 changes: 22 additions & 16 deletions glutin_wgl_sys/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,28 @@ fn main() {
.unwrap();

let mut file = File::create(dest.join("wgl_extra_bindings.rs")).unwrap();
Registry::new(Api::Wgl, (1, 0), Profile::Core, Fallbacks::All, [
"WGL_ARB_context_flush_control",
"WGL_ARB_create_context",
"WGL_ARB_create_context_no_error",
"WGL_ARB_create_context_profile",
"WGL_ARB_create_context_robustness",
"WGL_ARB_extensions_string",
"WGL_ARB_framebuffer_sRGB",
"WGL_ARB_multisample",
"WGL_ARB_pixel_format",
"WGL_ARB_pixel_format_float",
"WGL_EXT_create_context_es2_profile",
"WGL_EXT_extensions_string",
"WGL_EXT_framebuffer_sRGB",
"WGL_EXT_swap_control",
])
Registry::new(
Api::Wgl,
(1, 0),
Profile::Core,
Fallbacks::All,
[
"WGL_ARB_context_flush_control",
"WGL_ARB_create_context",
"WGL_ARB_create_context_no_error",
"WGL_ARB_create_context_profile",
"WGL_ARB_create_context_robustness",
"WGL_ARB_extensions_string",
"WGL_ARB_framebuffer_sRGB",
"WGL_ARB_multisample",
"WGL_ARB_pixel_format",
"WGL_ARB_pixel_format_float",
"WGL_EXT_create_context_es2_profile",
"WGL_EXT_extensions_string",
"WGL_EXT_framebuffer_sRGB",
"WGL_EXT_swap_control",
],
)
.write_bindings(gl_generator::StructGenerator, &mut file)
.unwrap();
}
Expand Down

0 comments on commit 6fbfe1c

Please sign in to comment.