Struct ul_next::surface::Surface

source ·
pub struct Surface { /* private fields */ }
Expand description

Offscreen pixel buffer surface. (Premultiplied BGRA 32-bit format)

When using the CPU renderer, each View is painted to its own Surface.

NOTE: Custom Surface is currently not support in this Rust wrapper

Implementations§

source§

impl Surface

source

pub fn width(&self) -> u32

Get the width (in pixels).

source

pub fn height(&self) -> u32

Get the height (in pixels).

source

pub fn row_bytes(&self) -> u32

Get the number of bytes between each row of pixels.

usually width * 4

source

pub fn bytes_size(&self) -> usize

Get the size in bytes of the pixel buffer.

bytes_size is calculated as row_bytes() * height().

source

pub fn lock_pixels(&mut self) -> Option<PixelsGuard<'_>>

Lock the pixel buffer for reading/writing.

An RAII guard is returned that will unlock the buffer when dropped.

source

pub fn resize(&self, width: u32, height: u32)

Resize the pixel buffer to a certain width and height (both in pixels).

source

pub fn set_dirty_bounds(&self, bounds: Rect<i32>)

Set the dirty bounds to a certain value.

This is called after the Renderer paints to an area of the pixel buffer. (The new value will be joined with the existing dirty_bounds())

source

pub fn dirty_bounds(&self) -> Rect<i32>

Get the dirty bounds.

This value can be used to determine which portion of the pixel buffer has been updated since the last call to clear_dirty_bounds.

The general algorithm to determine if a Surface needs display is:

if !surface.dirty_bounds().is_empty() {
    // Surface pixels are dirty and needs display.
    // Cast Surface to native Surface and use it here (pseudo code)
    display_surface(surface);

    // Once you're done, clear the dirty bounds:
    surface.clear_dirty_bounds();
}
source

pub fn clear_dirty_bounds(&self)

Clear the dirty bounds.

You should call this after you’re done displaying the Surface.

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, U> TryFrom<U> for T
where U: Into<T>,

§

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>,

§

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.