Allow `DrmBackend` to act as `drm::control::Device`

This commit is contained in:
Drakulix 2018-02-18 14:15:08 +01:00 committed by Victor Berger
parent cbee540013
commit 0ad723a71b
1 changed files with 12 additions and 0 deletions

View File

@ -5,6 +5,7 @@ use backend::graphics::egl::{EGLContext, EGLGraphicsBackend, EGLSurface, PixelFo
use backend::graphics::egl::error::Result as EGLResult; use backend::graphics::egl::error::Result as EGLResult;
use backend::graphics::egl::native::{Gbm, GbmSurfaceArguments}; use backend::graphics::egl::native::{Gbm, GbmSurfaceArguments};
use backend::graphics::egl::wayland::{EGLDisplay, EGLWaylandExtensions}; use backend::graphics::egl::wayland::{EGLDisplay, EGLWaylandExtensions};
use drm::Device as BasicDevice;
use drm::control::{Device, ResourceInfo}; use drm::control::{Device, ResourceInfo};
use drm::control::{connector, crtc, encoder, framebuffer, Mode}; use drm::control::{connector, crtc, encoder, framebuffer, Mode};
use gbm::{BufferObject, BufferObjectFlags, Device as GbmDevice, Format as GbmFormat, Surface as GbmSurface, use gbm::{BufferObject, BufferObjectFlags, Device as GbmDevice, Format as GbmFormat, Surface as GbmSurface,
@ -12,6 +13,7 @@ use gbm::{BufferObject, BufferObjectFlags, Device as GbmDevice, Format as GbmFor
use image::{ImageBuffer, Rgba}; use image::{ImageBuffer, Rgba};
use nix::libc::c_void; use nix::libc::c_void;
use std::cell::Cell; use std::cell::Cell;
use std::os::unix::io::{AsRawFd, RawFd};
use std::rc::{Rc, Weak}; use std::rc::{Rc, Weak};
use wayland_server::Display; use wayland_server::Display;
@ -531,6 +533,16 @@ impl<A: Device + 'static> EGLGraphicsBackend for DrmBackend<A> {
} }
} }
// for users convenience
impl<A: Device + 'static> AsRawFd for DrmBackend<A> {
fn as_raw_fd(&self) -> RawFd {
self.backend.context.as_raw_fd()
}
}
impl<A: Device + 'static> BasicDevice for DrmBackend<A> {}
impl<A: Device + 'static> Device for DrmBackend<A> {}
impl<A: Device + 'static> EGLWaylandExtensions for DrmBackend<A> { impl<A: Device + 'static> EGLWaylandExtensions for DrmBackend<A> {
fn bind_wl_display(&self, display: &Display) -> EGLResult<EGLDisplay> { fn bind_wl_display(&self, display: &Display) -> EGLResult<EGLDisplay> {
self.backend.context.bind_wl_display(display) self.backend.context.bind_wl_display(display)