diff options
author | Matt Brubeck <mbrubeck@limpet.net> | 2016-05-13 16:33:20 -0700 |
---|---|---|
committer | Matt Brubeck <mbrubeck@limpet.net> | 2016-05-13 16:33:20 -0700 |
commit | 1c5ec6f3ec0081b576a12b89fb6ae97c65c56799 (patch) | |
tree | 1b4194d88e3f6f04d7cd5847b398891950227009 | |
parent | 4361f92067d7c77ff09c391dc7ad68f0e6e09b8c (diff) | |
download | servo-1c5ec6f3ec0081b576a12b89fb6ae97c65c56799.tar.gz servo-1c5ec6f3ec0081b576a12b89fb6ae97c65c56799.zip |
Make some Font fields private
-rw-r--r-- | components/gfx/font.rs | 31 | ||||
-rw-r--r-- | components/gfx/font_context.rs | 19 |
2 files changed, 29 insertions, 21 deletions
diff --git a/components/gfx/font.rs b/components/gfx/font.rs index 1abfe692cc0..6011112219b 100644 --- a/components/gfx/font.rs +++ b/components/gfx/font.rs @@ -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, } diff --git a/components/gfx/font_context.rs b/components/gfx/font_context.rs index 184b0924961..cb572909b38 100644 --- a/components/gfx/font_context.rs +++ b/components/gfx/font_context.rs @@ -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) { |