mirror of
https://github.com/servo/servo.git
synced 2025-08-11 08:25:32 +01:00
gfx: Perform more aggressive caching in
`FontContext::get_layout_font_group_for_style()`. There are several optimizations here: * We make font families atoms, to allow for quicker comparisons. * We precalculate an FNV hash of the relevant fields of the font style structure. * When obtaining a platform font group, we first check pointer equality for the font style. If there's no match, we go to the FNV hash. Only if both caches miss do we construct and cache a font group. Note that individual fonts are *also* cached; thus there are two layers of caching here. 15% improvement in total layout thread time for Facebook Timeline.
This commit is contained in:
parent
6824bc9324
commit
750bbed2cb
14 changed files with 144 additions and 62 deletions
|
@ -11,11 +11,11 @@ use std::borrow::ToOwned;
|
|||
use std::sync::{Arc, Weak};
|
||||
use style::computed_values::{font_stretch, font_weight};
|
||||
|
||||
/// Describes how to select a font from a given family.
|
||||
/// This is very basic at the moment and needs to be
|
||||
/// expanded or refactored when we support more of the
|
||||
/// font styling parameters.
|
||||
#[derive(Clone, Copy)]
|
||||
/// Describes how to select a font from a given family. This is very basic at the moment and needs
|
||||
/// to be expanded or refactored when we support more of the font styling parameters.
|
||||
///
|
||||
/// NB: If you change this, you will need to update `style::properties::compute_font_hash()`.
|
||||
#[derive(Clone, Copy, Eq, Hash)]
|
||||
pub struct FontTemplateDescriptor {
|
||||
pub weight: font_weight::T,
|
||||
pub stretch: font_stretch::T,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue