diff --git a/src/backend/graphics/cursor.rs b/src/backend/graphics/cursor.rs deleted file mode 100644 index c0550dc..0000000 --- a/src/backend/graphics/cursor.rs +++ /dev/null @@ -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>; -} diff --git a/src/backend/graphics/format.rs b/src/backend/graphics/format.rs deleted file mode 100644 index 5262cba..0000000 --- a/src/backend/graphics/format.rs +++ /dev/null @@ -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, - /// is srgb enabled - pub srgb: bool, -} diff --git a/src/backend/graphics/mod.rs b/src/backend/graphics/mod.rs deleted file mode 100644 index 3b5308d..0000000 --- a/src/backend/graphics/mod.rs +++ /dev/null @@ -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), - /// 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), -} diff --git a/src/backend/mod.rs b/src/backend/mod.rs index ba94a50..577ce07 100644 --- a/src/backend/mod.rs +++ b/src/backend/mod.rs @@ -14,8 +14,13 @@ //! - winit //! - libinput -pub mod graphics; +// TODO TEMPORARY +#![allow(missing_docs)] + +//pub mod graphics; pub mod input; +pub mod allocator; +pub mod renderer; #[cfg(feature = "backend_drm")] pub mod drm; @@ -27,5 +32,38 @@ pub mod libinput; pub mod session; #[cfg(feature = "backend_udev")] pub mod udev; + #[cfg(feature = "backend_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), + /// 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), +} \ No newline at end of file