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
pub fn allocated(&self) -> impl ExactSizeIterator
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.
Trait Implementations§
source§impl Default for TextureManager
impl Default for TextureManager
source§fn default() -> TextureManager
fn default() -> TextureManager
Auto Trait Implementations§
impl Freeze for TextureManager
impl RefUnwindSafe for TextureManager
impl Send for TextureManager
impl Sync for TextureManager
impl Unpin for TextureManager
impl UnwindSafe for TextureManager
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CheckedAs for T
impl<T> CheckedAs for T
source§fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
source§impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
source§fn checked_cast_from(src: Src) -> Option<Dst>
fn checked_cast_from(src: Src) -> Option<Dst>
source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.