egl: style: move constraints into where clause
This commit is contained in:
parent
7dc3d64b6e
commit
c24619861e
|
@ -32,21 +32,20 @@ pub use self::surface::*;
|
||||||
pub mod session;
|
pub mod session;
|
||||||
|
|
||||||
/// Representation of an egl device to create egl rendering surfaces
|
/// 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,
|
B: Backend<Surface = <D as Device>::Surface> + 'static,
|
||||||
D: Device + NativeDisplay<B, Arguments = crtc::Handle> + 'static,
|
D: Device + NativeDisplay<B, Arguments = crtc::Handle> + 'static,
|
||||||
> where
|
|
||||||
<D as Device>::Surface: NativeSurface,
|
<D as Device>::Surface: NativeSurface,
|
||||||
{
|
{
|
||||||
dev: Rc<EGLContext<B, D>>,
|
dev: Rc<EGLContext<B, D>>,
|
||||||
logger: ::slog::Logger,
|
logger: ::slog::Logger,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<
|
impl<B, D> AsRawFd for EglDevice<B, D>
|
||||||
|
where
|
||||||
B: Backend<Surface = <D as Device>::Surface> + 'static,
|
B: Backend<Surface = <D as Device>::Surface> + 'static,
|
||||||
D: Device + NativeDisplay<B, Arguments = crtc::Handle> + 'static,
|
D: Device + NativeDisplay<B, Arguments = crtc::Handle> + 'static,
|
||||||
> AsRawFd for EglDevice<B, D>
|
|
||||||
where
|
|
||||||
<D as Device>::Surface: NativeSurface,
|
<D as Device>::Surface: NativeSurface,
|
||||||
{
|
{
|
||||||
fn as_raw_fd(&self) -> RawFd {
|
fn as_raw_fd(&self) -> RawFd {
|
||||||
|
@ -54,11 +53,10 @@ where
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<
|
impl<B, D> EglDevice<B, D>
|
||||||
|
where
|
||||||
B: Backend<Surface = <D as Device>::Surface> + 'static,
|
B: Backend<Surface = <D as Device>::Surface> + 'static,
|
||||||
D: Device + NativeDisplay<B, Arguments = crtc::Handle> + 'static,
|
D: Device + NativeDisplay<B, Arguments = crtc::Handle> + 'static,
|
||||||
> EglDevice<B, D>
|
|
||||||
where
|
|
||||||
<D as Device>::Surface: NativeSurface,
|
<D as Device>::Surface: NativeSurface,
|
||||||
{
|
{
|
||||||
/// Try to create a new `EglDevice` from an open device.
|
/// Try to create a new `EglDevice` from an open device.
|
||||||
|
@ -104,20 +102,19 @@ where
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
struct InternalDeviceHandler<
|
struct InternalDeviceHandler<B, D>
|
||||||
|
where
|
||||||
B: Backend<Surface = <D as Device>::Surface> + 'static,
|
B: Backend<Surface = <D as Device>::Surface> + 'static,
|
||||||
D: Device + NativeDisplay<B, Arguments = crtc::Handle> + 'static,
|
D: Device + NativeDisplay<B, Arguments = crtc::Handle> + 'static,
|
||||||
> where
|
|
||||||
<D as Device>::Surface: NativeSurface,
|
<D as Device>::Surface: NativeSurface,
|
||||||
{
|
{
|
||||||
handler: Box<DeviceHandler<Device = EglDevice<B, D>> + 'static>,
|
handler: Box<DeviceHandler<Device = EglDevice<B, D>> + 'static>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<
|
impl<B, D> DeviceHandler for InternalDeviceHandler<B, D>
|
||||||
|
where
|
||||||
B: Backend<Surface = <D as Device>::Surface> + 'static,
|
B: Backend<Surface = <D as Device>::Surface> + 'static,
|
||||||
D: Device + NativeDisplay<B, Arguments = crtc::Handle> + 'static,
|
D: Device + NativeDisplay<B, Arguments = crtc::Handle> + 'static,
|
||||||
> DeviceHandler for InternalDeviceHandler<B, D>
|
|
||||||
where
|
|
||||||
<D as Device>::Surface: NativeSurface,
|
<D as Device>::Surface: NativeSurface,
|
||||||
{
|
{
|
||||||
type Device = D;
|
type Device = D;
|
||||||
|
@ -131,11 +128,10 @@ where
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<
|
impl<B, D> Device for EglDevice<B, D>
|
||||||
|
where
|
||||||
B: Backend<Surface = <D as Device>::Surface> + 'static,
|
B: Backend<Surface = <D as Device>::Surface> + 'static,
|
||||||
D: Device + NativeDisplay<B, Arguments = crtc::Handle> + 'static,
|
D: Device + NativeDisplay<B, Arguments = crtc::Handle> + 'static,
|
||||||
> Device for EglDevice<B, D>
|
|
||||||
where
|
|
||||||
<D as Device>::Surface: NativeSurface,
|
<D as Device>::Surface: NativeSurface,
|
||||||
{
|
{
|
||||||
type Surface = EglSurface<B, D>;
|
type Surface = EglSurface<B, D>;
|
||||||
|
@ -185,11 +181,10 @@ where
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "native_lib")]
|
#[cfg(feature = "native_lib")]
|
||||||
impl<
|
impl<B, D> EGLGraphicsBackend for EglDevice<B, D>
|
||||||
|
where
|
||||||
B: Backend<Surface = <D as Device>::Surface> + 'static,
|
B: Backend<Surface = <D as Device>::Surface> + 'static,
|
||||||
D: Device + NativeDisplay<B, Arguments = crtc::Handle> + 'static,
|
D: Device + NativeDisplay<B, Arguments = crtc::Handle> + 'static,
|
||||||
> EGLGraphicsBackend for EglDevice<B, D>
|
|
||||||
where
|
|
||||||
<D as Device>::Surface: NativeSurface,
|
<D as Device>::Surface: NativeSurface,
|
||||||
{
|
{
|
||||||
fn bind_wl_display(&self, display: &Display) -> EGLResult<EGLDisplay> {
|
fn bind_wl_display(&self, display: &Display) -> EGLResult<EGLDisplay> {
|
||||||
|
@ -197,11 +192,10 @@ where
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<
|
impl<B, D> Drop for EglDevice<B, D>
|
||||||
|
where
|
||||||
B: Backend<Surface = <D as Device>::Surface> + 'static,
|
B: Backend<Surface = <D as Device>::Surface> + 'static,
|
||||||
D: Device + NativeDisplay<B, Arguments = crtc::Handle> + 'static,
|
D: Device + NativeDisplay<B, Arguments = crtc::Handle> + 'static,
|
||||||
> Drop for EglDevice<B, D>
|
|
||||||
where
|
|
||||||
<D as Device>::Surface: NativeSurface,
|
<D as Device>::Surface: NativeSurface,
|
||||||
{
|
{
|
||||||
fn drop(&mut self) {
|
fn drop(&mut self) {
|
||||||
|
|
|
@ -18,12 +18,11 @@ pub struct EglDeviceObserver<S: SessionObserver + 'static> {
|
||||||
observer: S,
|
observer: S,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<
|
impl<S, B, D> AsSessionObserver<EglDeviceObserver<S>> for EglDevice<B, D>
|
||||||
|
where
|
||||||
S: SessionObserver + 'static,
|
S: SessionObserver + 'static,
|
||||||
B: Backend<Surface = <D as Device>::Surface> + 'static,
|
B: Backend<Surface = <D as Device>::Surface> + 'static,
|
||||||
D: Device + NativeDisplay<B, Arguments = crtc::Handle> + AsSessionObserver<S> + 'static,
|
D: Device + NativeDisplay<B, Arguments = crtc::Handle> + AsSessionObserver<S> + 'static,
|
||||||
> AsSessionObserver<EglDeviceObserver<S>> for EglDevice<B, D>
|
|
||||||
where
|
|
||||||
<D as Device>::Surface: NativeSurface,
|
<D as Device>::Surface: NativeSurface,
|
||||||
{
|
{
|
||||||
fn observer(&mut self) -> EglDeviceObserver<S> {
|
fn observer(&mut self) -> EglDeviceObserver<S> {
|
||||||
|
|
|
@ -13,19 +13,20 @@ use backend::graphics::PixelFormat;
|
||||||
use backend::graphics::{CursorBackend, SwapBuffersError};
|
use backend::graphics::{CursorBackend, SwapBuffersError};
|
||||||
|
|
||||||
/// Egl surface for rendering
|
/// Egl surface for rendering
|
||||||
pub struct EglSurface<
|
pub struct EglSurface<B, D>
|
||||||
|
where
|
||||||
B: Backend<Surface = <D as Device>::Surface> + 'static,
|
B: Backend<Surface = <D as Device>::Surface> + 'static,
|
||||||
D: Device + NativeDisplay<B> + 'static,
|
D: Device + NativeDisplay<B> + 'static,
|
||||||
> where
|
|
||||||
<D as Device>::Surface: NativeSurface,
|
<D as Device>::Surface: NativeSurface,
|
||||||
{
|
{
|
||||||
pub(super) dev: Rc<EGLContext<B, D>>,
|
pub(super) dev: Rc<EGLContext<B, D>>,
|
||||||
pub(super) surface: EGLSurface<B::Surface>,
|
pub(super) surface: EGLSurface<B::Surface>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<B: Backend<Surface = <D as Device>::Surface> + 'static, D: Device + NativeDisplay<B> + 'static> Surface
|
impl<B, D> Surface for EglSurface<B, D>
|
||||||
for EglSurface<B, D>
|
|
||||||
where
|
where
|
||||||
|
B: Backend<Surface = <D as Device>::Surface> + 'static,
|
||||||
|
D: Device + NativeDisplay<B> + 'static,
|
||||||
<D as Device>::Surface: NativeSurface,
|
<D as Device>::Surface: NativeSurface,
|
||||||
{
|
{
|
||||||
type Error = Error;
|
type Error = Error;
|
||||||
|
@ -70,9 +71,10 @@ where
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, B: Backend<Surface = <D as Device>::Surface> + 'static, D: Device + NativeDisplay<B> + 'static>
|
impl<'a, B, D> CursorBackend<'a> for EglSurface<B, D>
|
||||||
CursorBackend<'a> for EglSurface<B, D>
|
|
||||||
where
|
where
|
||||||
|
B: Backend<Surface = <D as Device>::Surface> + 'static,
|
||||||
|
D: Device + NativeDisplay<B> + 'static,
|
||||||
<D as Device>::Surface: NativeSurface + CursorBackend<'a>,
|
<D as Device>::Surface: NativeSurface + CursorBackend<'a>,
|
||||||
{
|
{
|
||||||
type CursorFormat = <D::Surface as CursorBackend<'a>>::CursorFormat;
|
type CursorFormat = <D::Surface as CursorBackend<'a>>::CursorFormat;
|
||||||
|
@ -95,9 +97,10 @@ where
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "renderer_gl")]
|
#[cfg(feature = "renderer_gl")]
|
||||||
impl<B: Backend<Surface = <D as Device>::Surface> + 'static, D: Device + NativeDisplay<B> + 'static>
|
impl<B, D> GLGraphicsBackend for EglSurface<B, D>
|
||||||
GLGraphicsBackend for EglSurface<B, D>
|
|
||||||
where
|
where
|
||||||
|
B: Backend<Surface = <D as Device>::Surface> + 'static,
|
||||||
|
D: Device + NativeDisplay<B> + 'static,
|
||||||
<D as Device>::Surface: NativeSurface,
|
<D as Device>::Surface: NativeSurface,
|
||||||
{
|
{
|
||||||
fn swap_buffers(&self) -> ::std::result::Result<(), SwapBuffersError> {
|
fn swap_buffers(&self) -> ::std::result::Result<(), SwapBuffersError> {
|
||||||
|
|
Loading…
Reference in New Issue