epaint::textures

Struct TextureManager

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

Low-level manager for allocating textures.

Communicates with the painting subsystem using Self::take_delta.

Implementations§

Source§

impl TextureManager

Source

pub fn alloc( &mut self, name: String, image: ImageData, options: TextureOptions, ) -> TextureId

Allocate a new texture.

The given name can be useful for later debugging.

The returned TextureId will be TextureId::Managed, with an index starting from zero and increasing with each call to Self::alloc.

The first texture you allocate will be TextureId::Managed(0) == TextureId::default() and MUST have a white pixel at (0,0) (crate::WHITE_UV).

The texture is given a retain-count of 1, requiring one call to Self::free to free it.

Source

pub fn set(&mut self, id: TextureId, delta: ImageDelta)

Assign a new image to an existing texture, or update a region of it.

Source

pub fn free(&mut self, id: TextureId)

Free an existing texture.

Source

pub fn retain(&mut self, id: TextureId)

Increase the retain-count of the given texture.

For each time you call Self::retain you must call Self::free on additional time.

Source

pub fn take_delta(&mut self) -> TexturesDelta

Take and reset changes since last frame.

These should be applied to the painting subsystem each frame.

Source

pub fn meta(&self, id: TextureId) -> Option<&TextureMeta>

Get meta-data about a specific texture.

Source

pub fn allocated( &self, ) -> impl ExactSizeIterator<Item = (&TextureId, &TextureMeta)>

Get meta-data about all allocated textures in some arbitrary order.

Source

pub fn num_allocated(&self) -> usize

Total number of allocated textures.

Trait Implementations§

Source§

impl Default for TextureManager

Source§

fn default() -> TextureManager

Returns the “default value” for a type. Read more

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.