From 0ad723a71bdc60ac3ac42393775716912510dc15 Mon Sep 17 00:00:00 2001 From: Drakulix Date: Sun, 18 Feb 2018 14:15:08 +0100 Subject: [PATCH] Allow `DrmBackend` to act as `drm::control::Device` --- src/backend/drm/backend.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/backend/drm/backend.rs b/src/backend/drm/backend.rs index 72b537c..0f8b3ca 100644 --- a/src/backend/drm/backend.rs +++ b/src/backend/drm/backend.rs @@ -5,6 +5,7 @@ use backend::graphics::egl::{EGLContext, EGLGraphicsBackend, EGLSurface, PixelFo use backend::graphics::egl::error::Result as EGLResult; use backend::graphics::egl::native::{Gbm, GbmSurfaceArguments}; use backend::graphics::egl::wayland::{EGLDisplay, EGLWaylandExtensions}; +use drm::Device as BasicDevice; use drm::control::{Device, ResourceInfo}; use drm::control::{connector, crtc, encoder, framebuffer, Mode}; 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 nix::libc::c_void; use std::cell::Cell; +use std::os::unix::io::{AsRawFd, RawFd}; use std::rc::{Rc, Weak}; use wayland_server::Display; @@ -531,6 +533,16 @@ impl EGLGraphicsBackend for DrmBackend { } } +// for users convenience +impl AsRawFd for DrmBackend { + fn as_raw_fd(&self) -> RawFd { + self.backend.context.as_raw_fd() + } +} + +impl BasicDevice for DrmBackend {} +impl Device for DrmBackend {} + impl EGLWaylandExtensions for DrmBackend { fn bind_wl_display(&self, display: &Display) -> EGLResult { self.backend.context.bind_wl_display(display)