[−][src]Struct azul_core::app_resources::AppResources
Stores the resources for the application, souch as fonts, images and cached texts, also clipboard strings
Images and fonts can be references across window contexts (not yet tested, but should work).
Fields
css_ids_to_image_ids: FastHashMap<CssImageId, ImageId>
The CssImageId is the string used in the CSS, i.e. "my_image" -> ImageId(4)
css_ids_to_font_ids: FastHashMap<CssFontId, FontId>
Same as CssImageId -> ImageId, but for fonts, i.e. "Roboto" -> FontId(9)
image_sources: FastHashMap<ImageId, ImageSource>
Stores where the images were loaded from
font_sources: FastHashMap<FontId, FontSource>
Stores where the fonts were loaded from
currently_registered_images: FastHashMap<PipelineId, FastHashMap<ImageId, ImageInfo>>
All image keys currently active in the RenderApi
currently_registered_fonts: FastHashMap<PipelineId, FastHashMap<ImmediateFontId, LoadedFont>>
All font keys currently active in the RenderApi
last_frame_image_keys: FastHashMap<PipelineId, FastHashSet<ImageId>>
If an image isn't displayed, it is deleted from memory, only
the ImageSource
(i.e. the path / source where the image was loaded from) remains.
This way the image can be re-loaded if necessary but doesn't have to reside in memory at all times.
last_frame_font_keys: FastHashMap<PipelineId, FastHashMap<ImmediateFontId, FastHashSet<Au>>>
If a font does not get used for one frame, the corresponding instance key gets deleted. If a FontId has no FontInstanceKeys anymore, the font key gets deleted.
The only thing remaining in memory permanently is the FontSource (which is only the string of the file path where the font was loaded from, so no huge memory pressure). The reason for this agressive strategy is that the
text_cache: TextCache
Stores long texts across frames
Implementations
impl AppResources
[src]
pub fn add_pipeline(&mut self, pipeline_id: PipelineId)
[src]
Add a new pipeline to the app resources
pub fn delete_pipeline<T: FontImageApi>(
&mut self,
pipeline_id: &PipelineId,
render_api: &mut T
)
[src]
&mut self,
pipeline_id: &PipelineId,
render_api: &mut T
)
Delete and remove all fonts & font instance keys from a given pipeline
impl AppResources
[src]
pub fn new() -> Self
[src]
pub fn get_loaded_font_ids(&self) -> Vec<FontId>
[src]
Returns the IDs of all currently loaded fonts in self.font_data
pub fn get_loaded_image_ids(&self) -> Vec<ImageId>
[src]
pub fn get_loaded_css_image_ids(&self) -> Vec<CssImageId>
[src]
pub fn get_loaded_css_font_ids(&self) -> Vec<CssFontId>
[src]
pub fn get_loaded_text_ids(&self) -> Vec<TextId>
[src]
pub fn add_image_source(&mut self, image_id: ImageId, image_source: ImageSource)
[src]
Add an image from a PNG, JPEG or other source.
Note: For specialized image formats, you'll have to enable them as features in the Cargo.toml file.
pub fn has_image_source(&self, image_id: &ImageId) -> bool
[src]
Returns whether the AppResources has currently a certain image ID registered
pub fn get_image_source(&self, image_id: &ImageId) -> Option<&ImageSource>
[src]
Given an ImageId
, returns the decoded bytes of that image or None
, if the ImageId
is invalid.
Returns an error on IO failure / image decoding failure or image
pub fn delete_image_source(&mut self, image_id: &ImageId)
[src]
pub fn add_css_image_id<S: Into<String>>(&mut self, css_id: S) -> ImageId
[src]
pub fn has_css_image_id(&self, css_id: &str) -> bool
[src]
pub fn get_css_image_id(&self, css_id: &str) -> Option<&ImageId>
[src]
pub fn delete_css_image_id(&mut self, css_id: &str) -> Option<ImageId>
[src]
pub fn get_image_info(
&self,
pipeline_id: &PipelineId,
image_key: &ImageId
) -> Option<&ImageInfo>
[src]
&self,
pipeline_id: &PipelineId,
image_key: &ImageId
) -> Option<&ImageInfo>
pub fn add_css_font_id<S: Into<String>>(&mut self, css_id: S) -> FontId
[src]
pub fn has_css_font_id(&self, css_id: &str) -> bool
[src]
pub fn get_css_font_id(&self, css_id: &str) -> Option<&FontId>
[src]
pub fn delete_css_font_id(&mut self, css_id: &str) -> Option<FontId>
[src]
pub fn add_font_source(&mut self, font_id: FontId, font_source: FontSource)
[src]
pub fn get_font_source(&self, font_id: &FontId) -> Option<&FontSource>
[src]
Given a FontId
, returns the bytes for that font or None
, if the FontId
is invalid.
pub fn has_font_source(&self, id: &FontId) -> bool
[src]
Checks if a FontId
is valid, i.e. if a font is currently ready-to-use
pub fn delete_font_source(&mut self, id: &FontId)
[src]
pub fn get_loaded_font(
&self,
pipeline_id: &PipelineId,
font_id: &ImmediateFontId
) -> Option<&LoadedFont>
[src]
&self,
pipeline_id: &PipelineId,
font_id: &ImmediateFontId
) -> Option<&LoadedFont>
pub fn add_text(&mut self, words: Words) -> TextId
[src]
Adds a string to the internal text cache, but only store it as a string, without caching the layout of the string.
pub fn get_text(&self, id: &TextId) -> Option<&Words>
[src]
pub fn delete_text(&mut self, id: TextId)
[src]
Removes a string from both the string cache and the layouted text cache
pub fn clear_all_texts(&mut self)
[src]
Empties the entire internal text cache, invalidating all TextId
s. Use with care.
Trait Implementations
impl Default for AppResources
[src]
fn default() -> AppResources
[src]
Auto Trait Implementations
impl RefUnwindSafe for AppResources
impl Send for AppResources
impl Sync for AppResources
impl Unpin for AppResources
impl UnwindSafe for AppResources
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,