Make some Font fields private

This commit is contained in:
Matt Brubeck 2016-05-13 16:33:20 -07:00
parent 4361f92067
commit 1c5ec6f3ec
2 changed files with 29 additions and 21 deletions

View file

@ -95,12 +95,35 @@ pub struct Font {
pub descriptor: FontTemplateDescriptor,
pub requested_pt_size: Au,
pub actual_pt_size: Au,
pub shaper: Option<Shaper>,
pub shape_cache: HashCache<ShapeCacheEntry, Arc<GlyphStore>>,
pub glyph_advance_cache: HashCache<u32, FractionalPixel>,
shaper: Option<Shaper>,
shape_cache: HashCache<ShapeCacheEntry, Arc<GlyphStore>>,
glyph_advance_cache: HashCache<u32, FractionalPixel>,
pub font_key: Option<webrender_traits::FontKey>,
}
impl Font {
pub fn new(handle: FontHandle,
variant: font_variant::T,
descriptor: FontTemplateDescriptor,
requested_pt_size: Au,
actual_pt_size: Au,
font_key: Option<webrender_traits::FontKey>) -> Font {
let metrics = handle.metrics();
Font {
handle: handle,
shaper: None,
variant: variant,
descriptor: descriptor,
requested_pt_size: requested_pt_size,
actual_pt_size: actual_pt_size,
metrics: metrics,
shape_cache: HashCache::new(),
glyph_advance_cache: HashCache::new(),
font_key: font_key,
}
}
}
bitflags! {
pub flags ShapingFlags: u8 {
#[doc = "Set if the text is entirely whitespace."]
@ -130,7 +153,7 @@ pub struct ShapingOptions {
/// An entry in the shape cache.
#[derive(Clone, Eq, PartialEq, Hash, Debug)]
pub struct ShapeCacheEntry {
struct ShapeCacheEntry {
text: String,
options: ShapingOptions,
}

View file

@ -26,7 +26,6 @@ use std::sync::atomic::{AtomicUsize, Ordering, ATOMIC_USIZE_INIT};
use string_cache::Atom;
use style::computed_values::{font_style, font_variant};
use style::properties::style_structs::ServoFont;
use util::cache::HashCache;
use webrender_traits;
#[cfg(any(target_os = "linux", target_os = "android", target_os = "windows"))]
@ -123,22 +122,8 @@ impl FontContext {
FontHandleMethods::new_from_template(&self.platform_handle, template,
Some(actual_pt_size));
handle.map(|handle| {
let metrics = handle.metrics();
Font {
handle: handle,
shaper: None,
variant: variant,
descriptor: descriptor,
requested_pt_size: pt_size,
actual_pt_size: actual_pt_size,
metrics: metrics,
shape_cache: HashCache::new(),
glyph_advance_cache: HashCache::new(),
font_key: font_key,
}
})
handle.map(|handle|
Font::new(handle, variant, descriptor, pt_size, actual_pt_size, font_key))
}
fn expire_font_caches_if_necessary(&mut self) {