Skip to content

Commit

Permalink
egl: style: move constraints into where clause
Browse files Browse the repository at this point in the history
  • Loading branch information
Drakulix committed Dec 8, 2018
1 parent 7dc3d64 commit fb4efe9
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 37 deletions.
43 changes: 19 additions & 24 deletions src/backend/drm/egl/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,33 +32,31 @@ pub use self::surface::*;
pub mod session;

/// Representation of an egl device to create egl rendering surfaces
pub struct EglDevice<
pub struct EglDevice<B, D>
where
B: Backend<Surface = <D as Device>::Surface> + 'static,
D: Device + NativeDisplay<B, Arguments = crtc::Handle> + 'static,
> where
<D as Device>::Surface: NativeSurface,
{
dev: Rc<EGLContext<B, D>>,
logger: ::slog::Logger,
}

impl<
B: Backend<Surface = <D as Device>::Surface> + 'static,
D: Device + NativeDisplay<B, Arguments = crtc::Handle> + 'static,
> AsRawFd for EglDevice<B, D>
impl<B, D> AsRawFd for EglDevice<B, D>
where
B: Backend<Surface = <D as Device>::Surface> + 'static,
D: Device + NativeDisplay<B, Arguments = crtc::Handle> + 'static,
<D as Device>::Surface: NativeSurface,
{
fn as_raw_fd(&self) -> RawFd {
self.dev.borrow().as_raw_fd()
}
}

impl<
B: Backend<Surface = <D as Device>::Surface> + 'static,
D: Device + NativeDisplay<B, Arguments = crtc::Handle> + 'static,
> EglDevice<B, D>
impl<B, D> EglDevice<B, D>
where
B: Backend<Surface = <D as Device>::Surface> + 'static,
D: Device + NativeDisplay<B, Arguments = crtc::Handle> + 'static,
<D as Device>::Surface: NativeSurface,
{
/// Try to create a new `EglDevice` from an open device.
Expand Down Expand Up @@ -104,20 +102,19 @@ where
}
}

struct InternalDeviceHandler<
struct InternalDeviceHandler<B, D>
where
B: Backend<Surface = <D as Device>::Surface> + 'static,
D: Device + NativeDisplay<B, Arguments = crtc::Handle> + 'static,
> where
<D as Device>::Surface: NativeSurface,
{
handler: Box<DeviceHandler<Device = EglDevice<B, D>> + 'static>,
}

impl<
B: Backend<Surface = <D as Device>::Surface> + 'static,
D: Device + NativeDisplay<B, Arguments = crtc::Handle> + 'static,
> DeviceHandler for InternalDeviceHandler<B, D>
impl<B, D> DeviceHandler for InternalDeviceHandler<B, D>
where
B: Backend<Surface = <D as Device>::Surface> + 'static,
D: Device + NativeDisplay<B, Arguments = crtc::Handle> + 'static,
<D as Device>::Surface: NativeSurface,
{
type Device = D;
Expand All @@ -131,11 +128,10 @@ where
}
}

impl<
B: Backend<Surface = <D as Device>::Surface> + 'static,
D: Device + NativeDisplay<B, Arguments = crtc::Handle> + 'static,
> Device for EglDevice<B, D>
impl<B, D> Device for EglDevice<B, D>
where
B: Backend<Surface = <D as Device>::Surface> + 'static,
D: Device + NativeDisplay<B, Arguments = crtc::Handle> + 'static,
<D as Device>::Surface: NativeSurface,
{
type Surface = EglSurface<B, D>;
Expand Down Expand Up @@ -185,11 +181,10 @@ where
}

#[cfg(feature = "native_lib")]
impl<
B: Backend<Surface = <D as Device>::Surface> + 'static,
D: Device + NativeDisplay<B, Arguments = crtc::Handle> + 'static,
> EGLGraphicsBackend for EglDevice<B, D>
impl<B, D> EGLGraphicsBackend for EglDevice<B, D>
where
B: Backend<Surface = <D as Device>::Surface> + 'static,
D: Device + NativeDisplay<B, Arguments = crtc::Handle> + 'static,
<D as Device>::Surface: NativeSurface,
{
fn bind_wl_display(&self, display: &Display) -> EGLResult<EGLDisplay> {
Expand Down
9 changes: 4 additions & 5 deletions src/backend/drm/egl/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,11 @@ pub struct EglDeviceObserver<S: SessionObserver + 'static> {
observer: S,
}

impl<
S: SessionObserver + 'static,
B: Backend<Surface = <D as Device>::Surface> + 'static,
D: Device + NativeDisplay<B, Arguments = crtc::Handle> + AsSessionObserver<S> + 'static,
> AsSessionObserver<EglDeviceObserver<S>> for EglDevice<B, D>
impl<S, B, D> AsSessionObserver<EglDeviceObserver<S>> for EglDevice<B, D>
where
S: SessionObserver + 'static,
B: Backend<Surface = <D as Device>::Surface> + 'static,
D: Device + NativeDisplay<B, Arguments = crtc::Handle> + AsSessionObserver<S> + 'static,
<D as Device>::Surface: NativeSurface,
{
fn observer(&mut self) -> EglDeviceObserver<S> {
Expand Down
19 changes: 11 additions & 8 deletions src/backend/drm/egl/surface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,20 @@ use backend::graphics::PixelFormat;
use backend::graphics::{CursorBackend, SwapBuffersError};

/// Egl surface for rendering
pub struct EglSurface<
pub struct EglSurface<B, D>
where
B: Backend<Surface = <D as Device>::Surface> + 'static,
D: Device + NativeDisplay<B> + 'static,
> where
<D as Device>::Surface: NativeSurface,
{
pub(super) dev: Rc<EGLContext<B, D>>,
pub(super) surface: EGLSurface<B::Surface>,
}

impl<B: Backend<Surface = <D as Device>::Surface> + 'static, D: Device + NativeDisplay<B> + 'static> Surface
for EglSurface<B, D>
impl<B, D> Surface for EglSurface<B, D>
where
B: Backend<Surface = <D as Device>::Surface> + 'static,
D: Device + NativeDisplay<B> + 'static,
<D as Device>::Surface: NativeSurface,
{
type Error = Error;
Expand Down Expand Up @@ -70,9 +71,10 @@ where
}
}

impl<'a, B: Backend<Surface = <D as Device>::Surface> + 'static, D: Device + NativeDisplay<B> + 'static>
CursorBackend<'a> for EglSurface<B, D>
impl<'a, B, D> CursorBackend<'a> for EglSurface<B, D>
where
B: Backend<Surface = <D as Device>::Surface> + 'static,
D: Device + NativeDisplay<B> + 'static,
<D as Device>::Surface: NativeSurface + CursorBackend<'a>,
{
type CursorFormat = <D::Surface as CursorBackend<'a>>::CursorFormat;
Expand All @@ -95,9 +97,10 @@ where
}

#[cfg(feature = "renderer_gl")]
impl<B: Backend<Surface = <D as Device>::Surface> + 'static, D: Device + NativeDisplay<B> + 'static>
GLGraphicsBackend for EglSurface<B, D>
impl<B, D> GLGraphicsBackend for EglSurface<B, D>
where
B: Backend<Surface = <D as Device>::Surface> + 'static,
D: Device + NativeDisplay<B> + 'static,
<D as Device>::Surface: NativeSurface,
{
fn swap_buffers(&self) -> ::std::result::Result<(), SwapBuffersError> {
Expand Down

0 comments on commit fb4efe9

Please sign in to comment.