Struct epaint::textures::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
impl TextureManager
sourcepub fn alloc(
&mut self,
name: String,
image: ImageData,
options: TextureOptions
) -> TextureId
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.
sourcepub fn set(&mut self, id: TextureId, delta: ImageDelta)
pub fn set(&mut self, id: TextureId, delta: ImageDelta)
Assign a new image to an existing texture, or update a region of it.
sourcepub fn retain(&mut self, id: TextureId)
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.
sourcepub fn take_delta(&mut self) -> TexturesDelta
pub fn take_delta(&mut self) -> TexturesDelta
Take and reset changes since last frame.
These should be applied to the painting subsystem each frame.
sourcepub fn meta(&self, id: TextureId) -> Option<&TextureMeta>
pub fn meta(&self, id: TextureId) -> Option<&TextureMeta>
Get meta-data about a specific texture.
sourcepub fn allocated(
&self
) -> impl ExactSizeIterator<Item = (&TextureId, &TextureMeta)>
pub fn allocated( &self ) -> impl ExactSizeIterator<Item = (&TextureId, &TextureMeta)>
Get meta-data about all allocated textures in some arbitrary order.
sourcepub fn num_allocated(&self) -> usize
pub fn num_allocated(&self) -> usize
Total number of allocated textures.