pub struct TextureManager { /* private fields */ }egui only.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
Source§impl Drop for TextureManager
impl Drop for TextureManager
Auto Trait Implementations§
impl Forget for TextureManager
impl Freeze for TextureManagerwhere
*const u8 is !null: Freeze,
PhantomData<(TextureId, TextureMeta)>: Freeze,
PhantomData<(TextureId, SmallVec<[ImageDelta; 1]>)>: Freeze,
PhantomData<(TextureId, ())>: Freeze,
impl Move for TextureManager
impl RefUnwindSafe for TextureManager
impl Send for TextureManager
impl Sync for TextureManager
impl Unpin for TextureManagerwhere
*const u8 is !null: Unpin,
Arc<ColorImage>: Unpin,
*const ImageDelta is !null: Unpin,
ImageDelta: Unpin,
impl UnsafeUnpin for TextureManagerwhere
*const u8 is !null: UnsafeUnpin,
PhantomData<(TextureId, TextureMeta)>: UnsafeUnpin,
PhantomData<(TextureId, SmallVec<[ImageDelta; 1]>)>: UnsafeUnpin,
PhantomData<(TextureId, ())>: UnsafeUnpin,
impl UnwindSafe for TextureManagerwhere
HashMap<TextureId, TextureMeta, RandomState>: UnwindSafe,
HashMap<TextureId, SmallVec<[ImageDelta; 1]>, RandomState>: UnwindSafe,
NonNull<u8>: UnwindSafe,
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§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 more