rustfmt
This commit is contained in:
parent
2d255fd48d
commit
eef617258e
|
@ -17,8 +17,8 @@ use std::ffi::{CStr, CString};
|
|||
use std::fmt;
|
||||
use std::io;
|
||||
use std::mem;
|
||||
use std::ptr;
|
||||
use std::ops::Deref;
|
||||
use std::ptr;
|
||||
|
||||
#[allow(non_camel_case_types, dead_code)]
|
||||
mod ffi {
|
||||
|
@ -155,8 +155,8 @@ impl EGLContext {
|
|||
///
|
||||
/// This method is marked unsafe, because the contents of `NativeDisplay` cannot be verified and msy
|
||||
/// contain dangeling pointers are similar unsafe content
|
||||
pub unsafe fn new<L>(native: NativeDisplay, mut attributes: GlAttributes, reqs: PixelFormatRequirements,
|
||||
logger: L)
|
||||
pub unsafe fn new<L>(native: NativeDisplay, mut attributes: GlAttributes,
|
||||
reqs: PixelFormatRequirements, logger: L)
|
||||
-> Result<EGLContext, CreationError>
|
||||
where L: Into<Option<::slog::Logger>>
|
||||
{
|
||||
|
@ -545,14 +545,21 @@ impl EGLContext {
|
|||
///
|
||||
/// This method is marked unsafe, because the contents of `NativeSurface` cannot be verified and msy
|
||||
/// contain dangeling pointers are similar unsafe content
|
||||
pub unsafe fn create_surface<'a>(&'a self, native: NativeSurface) -> Result<EGLSurface<'a>, CreationError> {
|
||||
pub unsafe fn create_surface<'a>(&'a self, native: NativeSurface)
|
||||
-> Result<EGLSurface<'a>, CreationError> {
|
||||
trace!(self.logger, "Creating EGL window surface...");
|
||||
|
||||
let surface = {
|
||||
let surface = match native {
|
||||
NativeSurface::X11(window) |
|
||||
NativeSurface::Wayland(window) |
|
||||
NativeSurface::Gbm(window) => self.egl.CreateWindowSurface(self.display, self.config_id, window, self.surface_attributes.as_ptr()),
|
||||
NativeSurface::Gbm(window) => {
|
||||
self.egl
|
||||
.CreateWindowSurface(self.display,
|
||||
self.config_id,
|
||||
window,
|
||||
self.surface_attributes.as_ptr())
|
||||
}
|
||||
};
|
||||
|
||||
if surface.is_null() {
|
||||
|
@ -594,7 +601,8 @@ impl<'a> EGLSurface<'a> {
|
|||
/// Swaps buffers at the end of a frame.
|
||||
pub fn swap_buffers(&self) -> Result<(), SwapBuffersError> {
|
||||
let ret = unsafe {
|
||||
self.context.egl
|
||||
self.context
|
||||
.egl
|
||||
.SwapBuffers(self.context.display as *const _, self.surface as *const _)
|
||||
};
|
||||
|
||||
|
@ -615,7 +623,8 @@ impl<'a> EGLSurface<'a> {
|
|||
/// This function is marked unsafe, because the context cannot be made current
|
||||
/// on multiple threads.
|
||||
pub unsafe fn make_current(&self) -> Result<(), SwapBuffersError> {
|
||||
let ret = self.context.egl
|
||||
let ret = self.context
|
||||
.egl
|
||||
.MakeCurrent(self.context.display as *const _,
|
||||
self.surface as *const _,
|
||||
self.surface as *const _,
|
||||
|
@ -652,7 +661,8 @@ impl Drop for EGLContext {
|
|||
impl<'a> Drop for EGLSurface<'a> {
|
||||
fn drop(&mut self) {
|
||||
unsafe {
|
||||
self.context.egl
|
||||
self.context
|
||||
.egl
|
||||
.DestroySurface(self.context.display as *const _, self.surface as *const _);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
|
||||
use backend::{SeatInternal, TouchSlotInternal};
|
||||
use backend::graphics::GraphicsBackend;
|
||||
use backend::graphics::egl::{CreationError, EGLContext, EGLGraphicsBackend, GlAttributes, NativeDisplay, NativeSurface,
|
||||
PixelFormat, PixelFormatRequirements, SwapBuffersError};
|
||||
use backend::graphics::egl::{CreationError, EGLContext, EGLGraphicsBackend, GlAttributes, NativeDisplay,
|
||||
NativeSurface, PixelFormat, PixelFormatRequirements, SwapBuffersError};
|
||||
use backend::input::{Axis, AxisSource, Event as BackendEvent, InputBackend, InputHandler, KeyState,
|
||||
KeyboardKeyEvent, MouseButton, MouseButtonState, PointerAxisEvent, PointerButtonEvent,
|
||||
PointerMotionAbsoluteEvent, Seat, SeatCapabilities, TouchCancelEvent, TouchDownEvent,
|
||||
|
@ -103,18 +103,21 @@ pub fn init_from_builder_with_gl_attr<L>
|
|||
let window = Rc::new(builder.build(&events_loop)?);
|
||||
debug!(log, "Window created");
|
||||
|
||||
let (native_display, native_surface, surface) =
|
||||
if let (Some(conn), Some(window)) = (get_x11_xconnection(), window.get_xlib_window()) {
|
||||
let (native_display, native_surface, surface) = if let (Some(conn), Some(window)) =
|
||||
(get_x11_xconnection(), window.get_xlib_window()) {
|
||||
debug!(log, "Window is backed by X11");
|
||||
(NativeDisplay::X11(conn.display as *const _), NativeSurface::X11(window), None)
|
||||
} else if let (Some(display), Some(surface)) = (window.get_wayland_display(), window.get_wayland_client_surface()) {
|
||||
} else if let (Some(display), Some(surface)) =
|
||||
(window.get_wayland_display(), window.get_wayland_client_surface()) {
|
||||
debug!(log, "Window is backed by Wayland");
|
||||
let (w, h) = window.get_inner_size().unwrap();
|
||||
let egl_surface = wegl::WlEglSurface::new(surface, w as i32, h as i32);
|
||||
(NativeDisplay::Wayland(display), NativeSurface::Wayland(egl_surface.ptr() as *const _), Some(egl_surface))
|
||||
(NativeDisplay::Wayland(display),
|
||||
NativeSurface::Wayland(egl_surface.ptr() as *const _),
|
||||
Some(egl_surface))
|
||||
} else {
|
||||
error!(log, "Window is backed by an unsupported graphics framework");
|
||||
return Err(CreationError::NotSupported)
|
||||
return Err(CreationError::NotSupported);
|
||||
};
|
||||
|
||||
let context = unsafe {
|
||||
|
@ -137,7 +140,9 @@ pub fn init_from_builder_with_gl_attr<L>
|
|||
|
||||
Ok((WinitGraphicsBackend {
|
||||
window: window.clone(),
|
||||
context: match egl::RentEGL::try_new(Box::new(context), move |context| unsafe { context.create_surface(native_surface) }) {
|
||||
context: match egl::RentEGL::try_new(Box::new(context), move |context| unsafe {
|
||||
context.create_surface(native_surface)
|
||||
}) {
|
||||
Ok(x) => x,
|
||||
Err(::rental::TryNewError(err, _)) => return Err(err),
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue