Skip to main content

SoftBackend

Struct SoftBackend 

Source
pub struct SoftBackend { /* private fields */ }
Expand description

CPU framebuffer backend implementing oxiui_core::paint::RenderBackend.

Replays a oxiui_core::paint::DrawList onto a Framebuffer via a Canvas (clip-correct). All commands share one clip stack for the duration of the oxiui_core::paint::RenderBackend::execute call.

When the text feature is enabled, a cached oxiui_text::TextPipeline is held on the backend so that DrawText commands are fully shaped and rasterised rather than silently ignored.

Implementations§

Source§

impl SoftBackend

Source

pub fn new(width: u32, height: u32) -> Self

Create a backend with a transparent framebuffer.

Source

pub fn with_background(width: u32, height: u32, bg: Color) -> Self

Create a backend pre-filled with a solid background colour.

Source

pub fn set_quality(&mut self, quality: SoftRenderQuality)

Set the quality preset, influencing AA mode and shadow strategy.

Source

pub fn quality(&self) -> &SoftRenderQuality

Return the current quality preset.

Source

pub fn frame(&self) -> &Framebuffer

Borrow the underlying framebuffer.

Source

pub fn into_framebuffer(self) -> Framebuffer

Consume the backend, returning the underlying framebuffer.

Source

pub fn clear(&mut self, color: Color)

Fill the entire framebuffer with color.

Source

pub fn width(&self) -> u32

Return the framebuffer width in pixels.

Source

pub fn height(&self) -> u32

Return the framebuffer height in pixels.

Source

pub fn to_bytes(&self, format: PixelFormat) -> Vec<u8>

Export the framebuffer as a flat byte vector in the requested pixel format.

The native internal format is 0xAARRGGBB (one u32 per pixel). This method reinterprets and reorders channels for the target format.

FormatBytes/pixelChannel order
Argb324A, R, G, B
Bgra84B, G, R, A
Rgb56525R·6G·5B, big-endian
Source§

impl SoftBackend

Source

pub fn with_quality(width: u32, height: u32, quality: SoftRenderQuality) -> Self

Create a backend pre-configured with a SoftRenderQuality preset.

The quality is stored and used to drive AA mode selection during subsequent execute calls.

AaMode::Supersampling / AaMode::Msaa4x enables the vertical- supersample coverage path in the scanline polygon rasterizer. AaMode::None disables AA (faster, aliased edges).

ShadowQuality::Off skips Gaussian convolution for box-shadow commands. ShadowQuality::Low and ShadowQuality::High use the existing GaussianCache with a small or full kernel radius respectively.

Trait Implementations§

Source§

impl RenderBackend for SoftBackend

Source§

fn surface_size(&self) -> Size

Return the target surface dimensions in physical pixels.
Source§

fn supports_blur(&self) -> bool

Return true if this backend can render blur effects (e.g. box shadows).
Source§

fn supports_gradients(&self) -> bool

Return true if this backend can render gradient fills.
Source§

fn supports_paths(&self) -> bool

Return true if this backend can render arbitrary vector paths.
Source§

fn supports_images(&self) -> bool

Return true if this backend can blit ImageData.
Source§

fn supports_text(&self) -> bool

Return true if this backend can render text via DrawCommand::DrawText.
Source§

fn execute(&mut self, list: &DrawList) -> Result<(), UiError>

Replay an entire DrawList onto the backend’s surface. Read more
Source§

fn supports_blend_modes(&self) -> bool

Return true if this backend honours DrawCommand::SetBlendMode commands (non-Normal blend modes). Read more
Source§

fn supports_backdrop_blur(&self) -> bool

Return true if this backend can apply a backdrop blur via DrawCommand::BackdropBlur.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.