Skip to main content

RetainedFramebuffer

Struct RetainedFramebuffer 

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

Pixel memory that outlives the frames drawn into it.

A platform without a native surface to lock (a script-driven canvas, a test harness) keeps one of these per render target: each frame locks it, the renderer draws, and unlocking hands the pixels to blit.

Implementations§

Source§

impl RetainedFramebuffer

Source

pub fn new( size: PixelSize, format: PixelFormat, alpha_format: AlphaFormat, ) -> Rc<Self>

Creates a framebuffer whose rows are exactly as long as their pixels.

§Panics

Panics when a pixel of format does not occupy whole bytes or when size is empty.

Source

pub fn with_row_bytes( size: PixelSize, format: PixelFormat, alpha_format: AlphaFormat, row_bytes: i32, ) -> Rc<Self>

Creates a framebuffer with the given row length.

§Panics

Panics when size is empty or row_bytes is too small for a row of pixels.

Source

pub fn size(&self) -> PixelSize

The size in device pixels.

Source

pub fn row_bytes(&self) -> i32

The number of bytes per row.

Source

pub fn format(&self) -> PixelFormat

The pixel format.

Source

pub fn alpha_format(&self) -> AlphaFormat

The alpha format.

Source

pub fn address(&self) -> *mut u8

The address of the first pixel.

§Panics

Panics when the framebuffer has been disposed.

Source

pub fn lock( self: &Rc<Self>, dpi: Vector, blit: impl Fn(&Rc<RetainedFramebuffer>) + 'static, ) -> Rc<dyn ILockedFramebuffer>

Locks the framebuffer for one frame. blit runs whenever the returned framebuffer is disposed and receives this framebuffer.

§Panics

Panics when the framebuffer has been disposed.

Source

pub fn dispose(&self)

Releases the pixel memory. Further calls do nothing.

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> ClassDefaults for T
where T: ?Sized,

Source§

fn static_constructor()

The static constructor of a type: work done once per thread, after the properties of the type are registered and before its first instance exists (class handlers, affects_render, metadata overrides). 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>,

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.