Skip to content

Commit 9744dc1

Browse files
authored
Usa stable version of rustfmt for formatting
This changes the way rustfmt runs, since right now it uses nightly versions and it's not properly checked on CI, while we can use nightly on CI, the stable rustfmt should work fine. Also the 'small' heuristics was changed to 'Max' to make code more compact.
1 parent 2eb0a19 commit 9744dc1

File tree

37 files changed

+601
-1632
lines changed

37 files changed

+601
-1632
lines changed

glutin/src/api/android/mod.rs

Lines changed: 10 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,8 @@
11
#![cfg(target_os = "android")]
22

3-
use crate::api::egl::{
4-
Context as EglContext, NativeDisplay, SurfaceType as EglSurfaceType,
5-
};
3+
use crate::api::egl::{Context as EglContext, NativeDisplay, SurfaceType as EglSurfaceType};
64
use crate::CreationError::{self, OsError};
7-
use crate::{
8-
Api, ContextError, GlAttributes, PixelFormat, PixelFormatRequirements, Rect,
9-
};
5+
use crate::{Api, ContextError, GlAttributes, PixelFormat, PixelFormatRequirements, Rect};
106

117
use crate::platform::android::EventLoopExtAndroid;
128
use glutin_egl_sys as ffi;
@@ -66,18 +62,12 @@ impl Context {
6662
return Err(OsError("Android's native window is null".to_string()));
6763
}
6864
let native_display = NativeDisplay::Android;
69-
let egl_context = EglContext::new(
70-
pf_reqs,
71-
&gl_attr,
72-
native_display,
73-
EglSurfaceType::Window,
74-
|c, _| Ok(c[0]),
75-
)
76-
.and_then(|p| p.finish(nwin as *const _))?;
77-
let ctx = Arc::new(AndroidContext {
78-
egl_context,
79-
stopped: Some(Mutex::new(false)),
80-
});
65+
let egl_context =
66+
EglContext::new(pf_reqs, &gl_attr, native_display, EglSurfaceType::Window, |c, _| {
67+
Ok(c[0])
68+
})
69+
.and_then(|p| p.finish(nwin as *const _))?;
70+
let ctx = Arc::new(AndroidContext { egl_context, stopped: Some(Mutex::new(false)) });
8171

8272
let handler = Box::new(AndroidSyncEventHandler(ctx.clone()));
8373
android_glue::add_sync_event_handler(handler);
@@ -121,10 +111,7 @@ impl Context {
121111
|c, _| Ok(c[0]),
122112
)?;
123113
let egl_context = context.finish_pbuffer(size)?;
124-
let ctx = Arc::new(AndroidContext {
125-
egl_context,
126-
stopped: None,
127-
});
114+
let ctx = Arc::new(AndroidContext { egl_context, stopped: None });
128115
Ok(Context(ctx))
129116
}
130117

@@ -177,10 +164,7 @@ impl Context {
177164
}
178165

179166
#[inline]
180-
pub fn swap_buffers_with_damage(
181-
&self,
182-
rects: &[Rect],
183-
) -> Result<(), ContextError> {
167+
pub fn swap_buffers_with_damage(&self, rects: &[Rect]) -> Result<(), ContextError> {
184168
if let Some(ref stopped) = self.0.stopped {
185169
let stopped = stopped.lock();
186170
if *stopped {

glutin/src/api/dlloader.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,8 @@ impl<T: SymTrait> SymWrapper<T> {
3333
for path in lib_paths {
3434
// Avoid loading from PATH
3535
#[cfg(target_os = "windows")]
36-
let lib = windows::Library::load_with_flags(
37-
path,
38-
LOAD_LIBRARY_SEARCH_DEFAULT_DIRS,
39-
)
40-
.map(From::from);
36+
let lib = windows::Library::load_with_flags(path, LOAD_LIBRARY_SEARCH_DEFAULT_DIRS)
37+
.map(From::from);
4138

4239
#[cfg(not(target_os = "windows"))]
4340
let lib = Library::new(path);

glutin/src/api/egl/make_current_guard.rs

Lines changed: 10 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,8 @@ impl MakeCurrentGuard {
3030
display,
3131
old_display: egl.GetCurrentDisplay(),
3232
possibly_invalid: Some(MakeCurrentGuardInner {
33-
old_draw_surface: egl
34-
.GetCurrentSurface(ffi::egl::DRAW as i32),
35-
old_read_surface: egl
36-
.GetCurrentSurface(ffi::egl::READ as i32),
33+
old_draw_surface: egl.GetCurrentSurface(ffi::egl::DRAW as i32),
34+
old_read_surface: egl.GetCurrentSurface(ffi::egl::READ as i32),
3735
old_context: egl.GetCurrentContext(),
3836
}),
3937
};
@@ -42,8 +40,7 @@ impl MakeCurrentGuard {
4240
ret.invalidate();
4341
}
4442

45-
let res =
46-
egl.MakeCurrent(display, draw_surface, read_surface, context);
43+
let res = egl.MakeCurrent(display, draw_surface, read_surface, context);
4744

4845
if res == 0 {
4946
let err = egl.GetError();
@@ -62,10 +59,8 @@ impl MakeCurrentGuard {
6259
) {
6360
if self.possibly_invalid.is_some() {
6461
let pi = self.possibly_invalid.as_ref().unwrap();
65-
if pi.old_draw_surface == draw_surface
66-
&& draw_surface != ffi::egl::NO_SURFACE
67-
|| pi.old_read_surface == read_surface
68-
&& read_surface != ffi::egl::NO_SURFACE
62+
if pi.old_draw_surface == draw_surface && draw_surface != ffi::egl::NO_SURFACE
63+
|| pi.old_read_surface == read_surface && read_surface != ffi::egl::NO_SURFACE
6964
|| pi.old_context == context
7065
{
7166
self.invalidate();
@@ -81,28 +76,18 @@ impl MakeCurrentGuard {
8176
impl Drop for MakeCurrentGuard {
8277
fn drop(&mut self) {
8378
let egl = super::EGL.as_ref().unwrap();
84-
let (draw_surface, read_surface, context) =
85-
match self.possibly_invalid.take() {
86-
Some(inner) => (
87-
inner.old_draw_surface,
88-
inner.old_read_surface,
89-
inner.old_context,
90-
),
91-
None => (
92-
ffi::egl::NO_SURFACE,
93-
ffi::egl::NO_SURFACE,
94-
ffi::egl::NO_CONTEXT,
95-
),
96-
};
79+
let (draw_surface, read_surface, context) = match self.possibly_invalid.take() {
80+
Some(inner) => (inner.old_draw_surface, inner.old_read_surface, inner.old_context),
81+
None => (ffi::egl::NO_SURFACE, ffi::egl::NO_SURFACE, ffi::egl::NO_CONTEXT),
82+
};
9783

9884
let display = match self.old_display {
9985
ffi::egl::NO_DISPLAY => self.display,
10086
old_display => old_display,
10187
};
10288

10389
unsafe {
104-
let res =
105-
egl.MakeCurrent(display, draw_surface, read_surface, context);
90+
let res = egl.MakeCurrent(display, draw_surface, read_surface, context);
10691

10792
if res == 0 {
10893
let err = egl.GetError();

0 commit comments

Comments
 (0)