pub struct RendererResources {
pub currently_registered_images: OrderedMap<ImageRefHash, ResolvedImage>,
pub image_key_map: OrderedMap<ImageKey, ImageRefHash>,
pub image_last_seen_epoch: OrderedMap<ImageRefHash, u32>,
pub currently_registered_fonts: OrderedMap<FontKey, (FontRef, OrderedMap<(Au, DpiScaleFactor), FontInstanceKey>)>,
pub last_frame_registered_fonts: OrderedMap<FontKey, OrderedMap<(Au, DpiScaleFactor), FontInstanceKey>>,
pub font_families_map: OrderedMap<StyleFontFamiliesHash, StyleFontFamilyHash>,
pub font_id_map: OrderedMap<StyleFontFamilyHash, FontKey>,
pub font_hash_map: OrderedMap<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: OrderedMap<ImageRefHash, ResolvedImage>All image keys currently active in the RenderApi
image_key_map: OrderedMap<ImageKey, ImageRefHash>Reverse lookup: ImageKey -> ImageRefHash for display list translation
image_last_seen_epoch: OrderedMap<ImageRefHash, u32>Image GC bookkeeping: last epoch (as u32) each registered image was
seen referenced by a display list. An image absent for more than
IMAGE_GC_KEEP_EPOCHS frames is DeleteImaged and evicted — this is
what stops the unbounded texture growth of a window that swaps images
every frame (video / capture / animated charts). Safe because
ImageRefHash is now a never-reused id, not a freeable pointer.
currently_registered_fonts: OrderedMap<FontKey, (FontRef, OrderedMap<(Au, DpiScaleFactor), FontInstanceKey>)>All font keys currently active in the RenderApi
last_frame_registered_fonts: OrderedMap<FontKey, OrderedMap<(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: OrderedMap<StyleFontFamiliesHash, StyleFontFamilyHash>Map from the calculated families vec (["Arial", "Helvetica"])
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: OrderedMap<StyleFontFamilyHash, FontKey>Same as AzString -> ImageId, but for fonts, i.e. “Roboto” -> FontId(9)
font_hash_map: OrderedMap<u64, FontKey>Direct mapping from font hash (from FontRef) to FontKey
TODO: This should become part of SharedFontRegistry