Skip to main content

RendererResources

Struct RendererResources 

Source
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

Source

pub fn get_renderable_font_data( &self, font_instance_key: &FontInstanceKey, ) -> Option<(&FontRef, Au, DpiScaleFactor)>

Source

pub fn get_image(&self, hash: &ImageRefHash) -> Option<&ResolvedImage>

Source

pub fn get_font_family( &self, style_font_families_hash: &StyleFontFamiliesHash, ) -> Option<&StyleFontFamilyHash>

Source

pub fn get_font_key( &self, style_font_family_hash: &StyleFontFamilyHash, ) -> Option<&FontKey>

Source

pub fn get_registered_font( &self, font_key: &FontKey, ) -> Option<&(FontRef, FastHashMap<(Au, DpiScaleFactor), FontInstanceKey>)>

Source

pub fn update_image( &mut self, image_ref_hash: &ImageRefHash, descriptor: ImageDescriptor, )

Source

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>

Source

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

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for RendererResources

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl RendererResourcesTrait for RendererResources

Source§

fn get_font_family( &self, style_font_families_hash: &StyleFontFamiliesHash, ) -> Option<&StyleFontFamilyHash>

Get a font family hash from a font families hash
Source§

fn get_font_key( &self, style_font_family_hash: &StyleFontFamilyHash, ) -> Option<&FontKey>

Get a font key from a font family hash
Source§

fn get_registered_font( &self, font_key: &FontKey, ) -> Option<&(FontRef, FastHashMap<(Au, DpiScaleFactor), FontInstanceKey>)>

Get a registered font and its instances from a font key
Source§

fn get_image(&self, hash: &ImageRefHash) -> Option<&ResolvedImage>

Get image information from an image hash
Source§

fn update_image( &mut self, image_ref_hash: &ImageRefHash, descriptor: ImageDescriptor, )

Update an image descriptor for an existing image hash

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.