docs: add drm/egl

This commit is contained in:
Victor Brekenfeld 2018-12-03 23:26:16 +01:00
parent 1f8a7e7335
commit 6609754d13
3 changed files with 27 additions and 9 deletions

View File

@ -1,3 +1,13 @@
//!
//! [`Device`](../trait.Device.html) and [`Surface`](../trait.Surface.html)
//! implementations using egl contexts and surfaces for efficient rendering.
//!
//! Usually this implementation's [`EglSurface`](struct.EglSurface.html)s implementation
//! of [`GlGraphicsBackend`](../../graphics/gl/trait.GlGraphicsBackend.html) will be used
//! to let your compositor render.
//! Take a look at `anvil`s source code for an example of this.
//!
use drm::control::{crtc, ResourceHandles, ResourceInfo}; use drm::control::{crtc, ResourceHandles, ResourceInfo};
use nix::libc::dev_t; use nix::libc::dev_t;
use std::os::unix::io::{AsRawFd, RawFd}; use std::os::unix::io::{AsRawFd, RawFd};
@ -21,7 +31,7 @@ pub use self::surface::*;
#[cfg(feature = "backend_session")] #[cfg(feature = "backend_session")]
pub mod session; pub mod session;
/// Representation of an open gbm device to create rendering backends /// Representation of an egl device to create egl rendering surfaces
pub struct EglDevice< pub struct EglDevice<
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,
@ -51,10 +61,10 @@ impl<
where where
<D as Device>::Surface: NativeSurface, <D as Device>::Surface: NativeSurface,
{ {
/// Create a new `EglGbmDrmDevice` from an open drm node /// Try to create a new `EglDevice` from an open device.
/// ///
/// Returns an error if the file is no valid drm node or context creation was not /// Returns an error if the file is no valid device or context
/// successful. /// creation was not successful.
pub fn new<L>(dev: D, logger: L) -> Result<Self> pub fn new<L>(dev: D, logger: L) -> Result<Self>
where where
L: Into<Option<::slog::Logger>>, L: Into<Option<::slog::Logger>>,
@ -71,10 +81,10 @@ where
) )
} }
/// Create a new `EglGbmDrmDevice` from an open `RawDevice` and given `GlAttributes` /// Create a new `EglDevice` from an open device and given `GlAttributes`
/// ///
/// Returns an error if the file is no valid drm node or context creation was not /// Returns an error if the file is no valid device or context
/// successful. /// creation was not successful.
pub fn new_with_gl_attr<L>(mut dev: D, attributes: GlAttributes, logger: L) -> Result<Self> pub fn new_with_gl_attr<L>(mut dev: D, attributes: GlAttributes, logger: L) -> Result<Self>
where where
L: Into<Option<::slog::Logger>>, L: Into<Option<::slog::Logger>>,

View File

@ -1,4 +1,9 @@
use drm::control::{connector, crtc, Mode}; //!
//! Support to register an [`EglDevice`](../struct.EglDevice.html)
//! to an open [`Session`](../../session/trait.Session.html).
//!
use drm::control::crtc;
use std::os::unix::io::RawFd; use std::os::unix::io::RawFd;
use super::EglDevice; use super::EglDevice;
@ -6,7 +11,9 @@ use backend::drm::Device;
use backend::egl::native::{Backend, NativeDisplay, NativeSurface}; use backend::egl::native::{Backend, NativeDisplay, NativeSurface};
use backend::session::{AsSessionObserver, SessionObserver}; use backend::session::{AsSessionObserver, SessionObserver};
/// `SessionObserver` linked to the `DrmDevice` it was created from. /// [`SessionObserver`](../../session/trait.SessionObserver.html)
/// linked to the [`EglDevice`](../struct.EglDevice.html) it was
/// created from.
pub struct EglDeviceObserver<S: SessionObserver + 'static> { pub struct EglDeviceObserver<S: SessionObserver + 'static> {
observer: S, observer: S,
} }

View File

@ -12,6 +12,7 @@ use backend::graphics::gl::GLGraphicsBackend;
use backend::graphics::PixelFormat; use backend::graphics::PixelFormat;
use backend::graphics::{CursorBackend, SwapBuffersError}; use backend::graphics::{CursorBackend, SwapBuffersError};
/// Egl surface for rendering
pub struct EglSurface< pub struct EglSurface<
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,