2017-03-07 10:53:57 +00:00
|
|
|
//! Common traits and types used for software rendering on graphics backends
|
|
|
|
|
2017-04-18 19:20:08 +00:00
|
|
|
use super::GraphicsBackend;
|
2017-04-26 18:10:22 +00:00
|
|
|
use std::error::Error;
|
|
|
|
use wayland_server::protocol::wl_shm::Format;
|
2017-04-18 19:20:08 +00:00
|
|
|
|
2017-03-07 10:53:57 +00:00
|
|
|
/// Trait that describes objects providing a software rendering implementation
|
2017-04-18 19:20:08 +00:00
|
|
|
pub trait CpuGraphicsBackend<E: Error>: GraphicsBackend {
|
2017-03-07 10:53:57 +00:00
|
|
|
/// Render a given buffer of a given format at a specified place in the framebuffer
|
|
|
|
///
|
|
|
|
/// # Error
|
|
|
|
/// Returns an error if the buffer size does not match the required amount of pixels
|
|
|
|
/// for the given size or if the position and size is out of scope of the framebuffer.
|
|
|
|
fn render(&mut self, buffer: &[u8], format: Format, at: (u32, u32), size: (u32, u32)) -> Result<(), E>;
|
|
|
|
|
2018-10-30 12:56:30 +00:00
|
|
|
/// Returns the dimensions of the framebuffer
|
2017-03-07 10:53:57 +00:00
|
|
|
fn get_framebuffer_dimensions(&self) -> (u32, u32);
|
|
|
|
}
|