Remove the generic "graphics" module.
- Cursor is not necessary anymore as rendering hardware vs software cursors just depends on "where" you render the cursor. - Format is replaced by drm-fourcc and more related to buffers and therefor the allocator module anyway. - GL/Glium are replaced by the renderer module. - Software was unused and very small anyway and can be implemented with the new renderer api. - SwapBuffersError is (for now) just moved into the top-level backend module.
This commit is contained in:
parent
0628a83ea4
commit
f3f10242e9
|
@ -1,40 +0,0 @@
|
||||||
/// Functions to render cursors on graphics backend independently from it's rendering techique.
|
|
||||||
///
|
|
||||||
/// In the most cases this will be the fastest available implementation utilizing hardware composing
|
|
||||||
/// where possible. This may however be quite restrictive in terms of supported formats.
|
|
||||||
///
|
|
||||||
/// For those reasons you may always choose to render your cursor(s) (partially) in software instead.
|
|
||||||
pub trait CursorBackend {
|
|
||||||
/// Format representing the image drawn for the cursor.
|
|
||||||
type CursorFormat: ?Sized;
|
|
||||||
|
|
||||||
/// Error the underlying backend throws if operations fail
|
|
||||||
type Error: 'static;
|
|
||||||
|
|
||||||
/// Sets the cursor position and therefore updates the drawn cursors position.
|
|
||||||
/// Useful as well for e.g. pointer wrapping.
|
|
||||||
///
|
|
||||||
/// Not guaranteed to be supported on every backend. The result usually
|
|
||||||
/// depends on the backend, the cursor might be "owned" by another more privileged
|
|
||||||
/// compositor (running nested).
|
|
||||||
///
|
|
||||||
/// In these cases setting the position is actually not required, as movement is done
|
|
||||||
/// by the higher compositor and not by the backend. It is still good practice to update
|
|
||||||
/// the position after every recieved event, but don't rely on pointer wrapping working.
|
|
||||||
///
|
|
||||||
fn set_cursor_position(&self, x: u32, y: u32) -> Result<(), Self::Error>;
|
|
||||||
|
|
||||||
/// Set the cursor drawn on the [`CursorBackend`].
|
|
||||||
///
|
|
||||||
/// The format is entirely dictated by the concrete implementation and might range
|
|
||||||
/// from raw image buffers over a fixed list of possible cursor types to simply the
|
|
||||||
/// void type () to represent no possible customization of the cursor itself.
|
|
||||||
fn set_cursor_representation(
|
|
||||||
&self,
|
|
||||||
cursor: &Self::CursorFormat,
|
|
||||||
hotspot: (u32, u32),
|
|
||||||
) -> Result<(), Self::Error>;
|
|
||||||
|
|
||||||
/// Clear the current cursor image drawn on the [`CursorBackend`].
|
|
||||||
fn clear_cursor_representation(&self) -> Result<(), Self::Error>;
|
|
||||||
}
|
|
|
@ -1,20 +0,0 @@
|
||||||
/// Describes the pixel format of a framebuffer
|
|
||||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
|
||||||
pub struct PixelFormat {
|
|
||||||
/// is the format hardware accelerated
|
|
||||||
pub hardware_accelerated: bool,
|
|
||||||
/// number of bits used for colors
|
|
||||||
pub color_bits: u8,
|
|
||||||
/// number of bits used for alpha channel
|
|
||||||
pub alpha_bits: u8,
|
|
||||||
/// number of bits used for depth channel
|
|
||||||
pub depth_bits: u8,
|
|
||||||
/// number of bits used for stencil buffer
|
|
||||||
pub stencil_bits: u8,
|
|
||||||
/// is stereoscopy enabled
|
|
||||||
pub stereoscopy: bool,
|
|
||||||
/// number of samples used for multisampling if enabled
|
|
||||||
pub multisampling: Option<u16>,
|
|
||||||
/// is srgb enabled
|
|
||||||
pub srgb: bool,
|
|
||||||
}
|
|
|
@ -1,48 +0,0 @@
|
||||||
//! Common traits for various ways to renderer on a given graphics backend.
|
|
||||||
//!
|
|
||||||
//! Note: Not every API may be supported by every backend
|
|
||||||
|
|
||||||
mod cursor;
|
|
||||||
pub use self::cursor::*;
|
|
||||||
|
|
||||||
mod format;
|
|
||||||
pub use self::format::*;
|
|
||||||
|
|
||||||
#[cfg(feature = "renderer_gl")]
|
|
||||||
pub mod gl;
|
|
||||||
#[cfg(feature = "renderer_glium")]
|
|
||||||
pub mod glium;
|
|
||||||
#[cfg(feature = "renderer_software")]
|
|
||||||
pub mod software;
|
|
||||||
|
|
||||||
/// Error that can happen when swapping buffers.
|
|
||||||
#[derive(Debug, thiserror::Error)]
|
|
||||||
pub enum SwapBuffersError {
|
|
||||||
/// The buffers have already been swapped.
|
|
||||||
///
|
|
||||||
/// This error can be returned when `swap_buffers` has been called multiple times
|
|
||||||
/// without any modification in between.
|
|
||||||
#[error("Buffers are already swapped, swap_buffers was called too many times")]
|
|
||||||
AlreadySwapped,
|
|
||||||
/// The corresponding context has been lost and needs to be recreated.
|
|
||||||
///
|
|
||||||
/// All the objects associated to it (textures, buffers, programs, etc.)
|
|
||||||
/// need to be recreated from scratch. Underlying resources like native surfaces
|
|
||||||
/// might also need to be recreated.
|
|
||||||
///
|
|
||||||
/// Operations will have no effect. Functions that read textures, buffers, etc.
|
|
||||||
/// will return uninitialized data instead.
|
|
||||||
#[error("The context has been lost, it needs to be recreated: {0}")]
|
|
||||||
ContextLost(Box<dyn std::error::Error>),
|
|
||||||
/// A temporary condition caused to rendering to fail.
|
|
||||||
///
|
|
||||||
/// Depending on the underlying error this *might* require fixing internal state of the rendering backend,
|
|
||||||
/// but failures mapped to `TemporaryFailure` are always recoverable without re-creating the entire stack,
|
|
||||||
/// as is represented by `ContextLost`.
|
|
||||||
///
|
|
||||||
/// Proceed after investigating the source to reschedule another full rendering step or just this page_flip at a later time.
|
|
||||||
/// If the root cause cannot be discovered and subsequent renderings also fail, it is advised to fallback to
|
|
||||||
/// recreation.
|
|
||||||
#[error("A temporary condition caused the page flip to fail: {0}")]
|
|
||||||
TemporaryFailure(Box<dyn std::error::Error>),
|
|
||||||
}
|
|
|
@ -14,8 +14,13 @@
|
||||||
//! - winit
|
//! - winit
|
||||||
//! - libinput
|
//! - libinput
|
||||||
|
|
||||||
pub mod graphics;
|
// TODO TEMPORARY
|
||||||
|
#![allow(missing_docs)]
|
||||||
|
|
||||||
|
//pub mod graphics;
|
||||||
pub mod input;
|
pub mod input;
|
||||||
|
pub mod allocator;
|
||||||
|
pub mod renderer;
|
||||||
|
|
||||||
#[cfg(feature = "backend_drm")]
|
#[cfg(feature = "backend_drm")]
|
||||||
pub mod drm;
|
pub mod drm;
|
||||||
|
@ -27,5 +32,38 @@ pub mod libinput;
|
||||||
pub mod session;
|
pub mod session;
|
||||||
#[cfg(feature = "backend_udev")]
|
#[cfg(feature = "backend_udev")]
|
||||||
pub mod udev;
|
pub mod udev;
|
||||||
|
|
||||||
#[cfg(feature = "backend_winit")]
|
#[cfg(feature = "backend_winit")]
|
||||||
pub mod winit;
|
pub mod winit;
|
||||||
|
|
||||||
|
/// Error that can happen when swapping buffers.
|
||||||
|
#[derive(Debug, thiserror::Error)]
|
||||||
|
pub enum SwapBuffersError {
|
||||||
|
/// The buffers have already been swapped.
|
||||||
|
///
|
||||||
|
/// This error can be returned when `swap_buffers` has been called multiple times
|
||||||
|
/// without any modification in between.
|
||||||
|
#[error("Buffers are already swapped, swap_buffers was called too many times")]
|
||||||
|
AlreadySwapped,
|
||||||
|
/// The corresponding context has been lost and needs to be recreated.
|
||||||
|
///
|
||||||
|
/// All the objects associated to it (textures, buffers, programs, etc.)
|
||||||
|
/// need to be recreated from scratch. Underlying resources like native surfaces
|
||||||
|
/// might also need to be recreated.
|
||||||
|
///
|
||||||
|
/// Operations will have no effect. Functions that read textures, buffers, etc.
|
||||||
|
/// will return uninitialized data instead.
|
||||||
|
#[error("The context has been lost, it needs to be recreated: {0}")]
|
||||||
|
ContextLost(Box<dyn std::error::Error>),
|
||||||
|
/// A temporary condition caused to rendering to fail.
|
||||||
|
///
|
||||||
|
/// Depending on the underlying error this *might* require fixing internal state of the rendering backend,
|
||||||
|
/// but failures mapped to `TemporaryFailure` are always recoverable without re-creating the entire stack,
|
||||||
|
/// as is represented by `ContextLost`.
|
||||||
|
///
|
||||||
|
/// Proceed after investigating the source to reschedule another full rendering step or just this page_flip at a later time.
|
||||||
|
/// If the root cause cannot be discovered and subsequent renderings also fail, it is advised to fallback to
|
||||||
|
/// recreation.
|
||||||
|
#[error("A temporary condition caused the page flip to fail: {0}")]
|
||||||
|
TemporaryFailure(Box<dyn std::error::Error>),
|
||||||
|
}
|
Loading…
Reference in New Issue