pub struct SoftRenderer { /* private fields */ }Expand description
CPU-based software renderer using a raw pixel framebuffer.
In the full implementation this would wrap a softbuffer::Surface.
For M1 it is a pure-Rust pixel-buffer helper that does not require
a display at build time.
Implementations§
Source§impl SoftRenderer
impl SoftRenderer
Sourcepub fn new() -> Self
pub fn new() -> Self
Construct a new SoftRenderer.
Sourcepub fn clear_frame(
&self,
width: u32,
height: u32,
color: Color,
) -> Result<Vec<u32>, UiError>
pub fn clear_frame( &self, width: u32, height: u32, color: Color, ) -> Result<Vec<u32>, UiError>
Fill a framebuffer with a solid colour.
Returns a Vec<u32> of length width * height in 0xAARRGGBB format,
every pixel set to color.
§Errors
Currently infallible; returns Err only if a future implementation
encounters a resource constraint.
Sourcepub fn render<F>(
&self,
width: u32,
height: u32,
background: Color,
draw_fn: F,
) -> Framebuffer
pub fn render<F>( &self, width: u32, height: u32, background: Color, draw_fn: F, ) -> Framebuffer
Render a scene into a fresh Framebuffer of the given size.
The framebuffer is pre-filled with background; draw_fn receives a
clipped Canvas to paint the scene. Returns the finished framebuffer.
Source§impl SoftRenderer
impl SoftRenderer
Sourcepub fn with_size(_width: u32, _height: u32) -> Self
pub fn with_size(_width: u32, _height: u32) -> Self
Pre-allocate the framebuffer for the given pixel dimensions.
Equivalent to SoftRenderer::new() — the renderer itself is stateless;
the framebuffer is created on demand inside SoftRenderer::render.
Provided for API parity with SoftBackend::with_quality.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for SoftRenderer
impl RefUnwindSafe for SoftRenderer
impl Send for SoftRenderer
impl Sync for SoftRenderer
impl Unpin for SoftRenderer
impl UnsafeUnpin for SoftRenderer
impl UnwindSafe for SoftRenderer
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more