webrender_api

Struct BlobTilePool

Source
pub struct BlobTilePool {
    largest_size_class: usize,
    buckets: [Vec<Arc<Vec<u8>>>; 6],
}
Expand description

A pool of blob tile buffers to mitigate the overhead of allocating and deallocating blob tiles.

The pool keeps a strong reference to each allocated buffers and reuses the ones with a strong count of 1.

Fields§

§largest_size_class: usize§buckets: [Vec<Arc<Vec<u8>>>; 6]

Implementations§

Source§

impl BlobTilePool

Source

pub fn new() -> Self

Source

pub fn get_buffer(&mut self, requested_size: usize) -> MutableTileBuffer

Get or allocate a tile buffer of the requested size.

The returned buffer is zero-inizitalized. The length of the returned buffer is equal to the requested size, however the buffer may be allocated with a larger capacity to conform to the pool’s corresponding bucket tile size.

Source

fn bucket_and_size(&self, size: usize) -> (usize, usize)

Source

pub fn cleanup(&mut self)

Go over all allocated tile buffers. For each bucket, deallocate some buffers until the number of unused buffer is more than half of the buffers for that bucket.

In practice, if called regularly, this gradually lets go of blob tiles when they are not used.

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

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.