pub struct RendererResources {
pub currently_registered_images: FastHashMap<ImageRefHash, ResolvedImage>,
pub image_key_map: FastHashMap<ImageKey, ImageRefHash>,
pub currently_registered_fonts: FastHashMap<FontKey, (FontRef, FastHashMap<(Au, DpiScaleFactor), FontInstanceKey>)>,
pub last_frame_registered_fonts: FastHashMap<FontKey, FastHashMap<(Au, DpiScaleFactor), FontInstanceKey>>,
pub font_families_map: FastHashMap<StyleFontFamiliesHash, StyleFontFamilyHash>,
pub font_id_map: FastHashMap<StyleFontFamilyHash, FontKey>,
pub font_hash_map: FastHashMap<u64, FontKey>,
}Expand description
Renderer resources that manage font, image and font instance keys. RendererResources are local to each renderer / window, since the keys are not shared across renderers
The resources are automatically managed, meaning that they each new frame (signified by start_frame_gc and end_frame_gc)
Fields§
§currently_registered_images: FastHashMap<ImageRefHash, ResolvedImage>All image keys currently active in the RenderApi
image_key_map: FastHashMap<ImageKey, ImageRefHash>Reverse lookup: ImageKey -> ImageRefHash for display list translation
currently_registered_fonts: FastHashMap<FontKey, (FontRef, FastHashMap<(Au, DpiScaleFactor), FontInstanceKey>)>All font keys currently active in the RenderApi
last_frame_registered_fonts: FastHashMap<FontKey, FastHashMap<(Au, DpiScaleFactor), FontInstanceKey>>Fonts registered on the last frame
Fonts differ from images in that regard that we can’t immediately delete them on a new frame, instead we have to delete them on “current frame + 1” This is because when the frame is being built, we do not know whether the font will actually be successfully loaded
font_families_map: FastHashMap<StyleFontFamiliesHash, StyleFontFamilyHash>Map from the calculated families vec ([“Arial”, “Helvectia”]) to the final loaded font that could be loaded (in this case “Arial” on Windows and “Helvetica” on Mac, because the fonts are loaded in fallback-order)
font_id_map: FastHashMap<StyleFontFamilyHash, FontKey>Same as AzString -> ImageId, but for fonts, i.e. “Roboto” -> FontId(9)
font_hash_map: FastHashMap<u64, FontKey>Direct mapping from font hash (from FontRef) to FontKey TODO: This should become part of SharedFontRegistry
Implementations§
Source§impl RendererResources
impl RendererResources
pub fn get_renderable_font_data( &self, font_instance_key: &FontInstanceKey, ) -> Option<(&FontRef, Au, DpiScaleFactor)>
pub fn get_image(&self, hash: &ImageRefHash) -> Option<&ResolvedImage>
pub fn get_font_family( &self, style_font_families_hash: &StyleFontFamiliesHash, ) -> Option<&StyleFontFamilyHash>
pub fn get_font_key( &self, style_font_family_hash: &StyleFontFamilyHash, ) -> Option<&FontKey>
pub fn get_registered_font( &self, font_key: &FontKey, ) -> Option<&(FontRef, FastHashMap<(Au, DpiScaleFactor), FontInstanceKey>)>
pub fn update_image( &mut self, image_ref_hash: &ImageRefHash, descriptor: ImageDescriptor, )
pub fn get_font_instance_key_for_text( &self, font_size_px: f32, css_property_cache: &CssPropertyCache, node_data: &NodeData, node_id: &NodeId, styled_node_state: &StyledNodeState, dpi_scale: f32, ) -> Option<FontInstanceKey>
pub fn get_font_instance_key( &self, font_families_hash: &StyleFontFamiliesHash, font_size_au: Au, dpi_scale: DpiScaleFactor, ) -> Option<FontInstanceKey>
Trait Implementations§
Source§impl Debug for RendererResources
impl Debug for RendererResources
Source§impl Default for RendererResources
impl Default for RendererResources
Source§impl RendererResourcesTrait for RendererResources
impl RendererResourcesTrait for RendererResources
Source§fn get_font_family(
&self,
style_font_families_hash: &StyleFontFamiliesHash,
) -> Option<&StyleFontFamilyHash>
fn get_font_family( &self, style_font_families_hash: &StyleFontFamiliesHash, ) -> Option<&StyleFontFamilyHash>
Source§fn get_font_key(
&self,
style_font_family_hash: &StyleFontFamilyHash,
) -> Option<&FontKey>
fn get_font_key( &self, style_font_family_hash: &StyleFontFamilyHash, ) -> Option<&FontKey>
Source§fn get_registered_font(
&self,
font_key: &FontKey,
) -> Option<&(FontRef, FastHashMap<(Au, DpiScaleFactor), FontInstanceKey>)>
fn get_registered_font( &self, font_key: &FontKey, ) -> Option<&(FontRef, FastHashMap<(Au, DpiScaleFactor), FontInstanceKey>)>
Source§fn get_image(&self, hash: &ImageRefHash) -> Option<&ResolvedImage>
fn get_image(&self, hash: &ImageRefHash) -> Option<&ResolvedImage>
Source§fn update_image(
&mut self,
image_ref_hash: &ImageRefHash,
descriptor: ImageDescriptor,
)
fn update_image( &mut self, image_ref_hash: &ImageRefHash, descriptor: ImageDescriptor, )
Auto Trait Implementations§
impl Freeze for RendererResources
impl RefUnwindSafe for RendererResources
impl Send for RendererResources
impl Sync for RendererResources
impl Unpin for RendererResources
impl UnsafeUnpin for RendererResources
impl UnwindSafe for RendererResources
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> 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