pub struct SharedResources(/* private fields */);Expand description
A window’s handle to the session’s resource registry — Core’s
resources field. A font, image or sound registered through one is
registered for every window in the session, and draws in all of them.
Implementations§
Sourcepub fn add_image(&self, width: u32, height: u32, rgba: Vec<u8>) -> ImageId
pub fn add_image(&self, width: u32, height: u32, rgba: Vec<u8>) -> ImageId
Registers an RGBA image (width * height * 4 bytes).
Sourcepub fn remove_image(&self, id: ImageId) -> bool
pub fn remove_image(&self, id: ImageId) -> bool
Drops an image from the registry. Every window’s atlas forgets its blit at that window’s next frame, and a texture-backed one is dropped from the device by the next frame any window draws.
Sourcepub fn image_size(&self, id: ImageId) -> Option<(u32, u32)>
pub fn image_size(&self, id: ImageId) -> Option<(u32, u32)>
The pixel dimensions behind an image handle, if it is live.
Sourcepub fn add_sound(&self, bytes: Vec<u8>) -> SoundId
pub fn add_sound(&self, bytes: Vec<u8>) -> SoundId
Registers a sound from its encoded file bytes.
Sourcepub fn has_sounds(&self) -> bool
pub fn has_sounds(&self) -> bool
Whether any sound is registered (see Resources::has_sounds).
Sourcepub fn sound(&self, id: SoundId) -> Option<Arc<[u8]>>
pub fn sound(&self, id: SoundId) -> Option<Arc<[u8]>>
The encoded bytes behind a sound handle, if it is live. Cloning the
Arc rather than lending it is what lets the registry be shared:
the caller (an audio backend) holds the bytes, not the borrow.
Sourcepub fn font_family(&self, id: FontId) -> Option<String>
pub fn font_family(&self, id: FontId) -> Option<String>
The registered family name behind a font handle, if it is live.