pub struct TextureManager {
next_id: u64,
metas: HashMap<TextureId, TextureMeta, RandomState>,
delta: TexturesDelta,
}
Expand description
Low-level manager for allocating textures.
Communicates with the painting subsystem using Self::take_delta
.
Fields§
§next_id: u64
§metas: HashMap<TextureId, TextureMeta, RandomState>
§delta: TexturesDelta
Implementations§
§impl TextureManager
impl TextureManager
pub 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.
pub 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.
pub 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.
pub 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.
pub fn meta(&self, id: TextureId) -> Option<&TextureMeta>
pub fn meta(&self, id: TextureId) -> Option<&TextureMeta>
Get meta-data about a specific texture.
pub fn allocated(&self) -> impl ExactSizeIterator
pub fn allocated(&self) -> impl ExactSizeIterator
Get meta-data about all allocated textures in some arbitrary order.
pub fn num_allocated(&self) -> usize
pub fn num_allocated(&self) -> usize
Total number of allocated textures.
Trait Implementations§
§impl Default for TextureManager
impl Default for TextureManager
§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>
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§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
.§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
.§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.§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.§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T
in a tonic::Request