diff options
author | bors-servo <metajack+bors@gmail.com> | 2015-07-31 09:43:40 -0600 |
---|---|---|
committer | bors-servo <metajack+bors@gmail.com> | 2015-07-31 09:43:40 -0600 |
commit | c4480b5d0309acc7f154166b91992f73a85de57f (patch) | |
tree | 494001ef3527c23854439ddca953a7443025712c /components/gfx/platform/macos | |
parent | 33bc16fe353be237855d006b34e96fbe59f24846 (diff) | |
parent | 17ead8716b53715086c990dc16e20e1cf6462c16 (diff) | |
download | servo-c4480b5d0309acc7f154166b91992f73a85de57f.tar.gz servo-c4480b5d0309acc7f154166b91992f73a85de57f.zip |
Auto merge of #6795 - pcwalton:display-list-e10s-fixes, r=glennw
Send display lists over IPC in multiprocess mode.
This patch set introduces the `--multiprocess` (`-M`) switch. Right now, all it does it cause display lists to be serialized, but eventually it will cause actual processes to be spawned.
r? @metajack
<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/6795)
<!-- Reviewable:end -->
Diffstat (limited to 'components/gfx/platform/macos')
-rw-r--r-- | components/gfx/platform/macos/font.rs | 2 | ||||
-rw-r--r-- | components/gfx/platform/macos/font_template.rs | 22 |
2 files changed, 17 insertions, 7 deletions
diff --git a/components/gfx/platform/macos/font.rs b/components/gfx/platform/macos/font.rs index a6e431407e1..b8474aa6da9 100644 --- a/components/gfx/platform/macos/font.rs +++ b/components/gfx/platform/macos/font.rs @@ -64,7 +64,7 @@ impl FontHandleMethods for FontHandle { Some(s) => s.to_f64_px(), None => 0.0 }; - match *template.ctfont { + match template.ctfont() { Some(ref ctfont) => { Ok(FontHandle { font_data: template.clone(), diff --git a/components/gfx/platform/macos/font_template.rs b/components/gfx/platform/macos/font_template.rs index e5c0c9c194b..e84691971ac 100644 --- a/components/gfx/platform/macos/font_template.rs +++ b/components/gfx/platform/macos/font_template.rs @@ -11,6 +11,7 @@ use serde::de::{Error, Visitor}; use serde::{Deserialize, Deserializer, Serialize, Serializer}; use std::borrow::ToOwned; use std::ops::Deref; +use std::sync::Mutex; use string_cache::Atom; /// Platform specific font representation for mac. @@ -26,7 +27,7 @@ pub struct FontTemplateData { /// When sending a `FontTemplateData` instance across processes, this will be set to `None` on /// the other side, because `CTFont` instances cannot be sent across processes. This is /// harmless, however, because it can always be recreated. - pub ctfont: CachedCTFont, + ctfont: CachedCTFont, pub identifier: Atom, pub font_data: Option<Vec<u8>> @@ -52,18 +53,27 @@ impl FontTemplateData { }; FontTemplateData { - ctfont: CachedCTFont(ctfont), + ctfont: CachedCTFont(Mutex::new(ctfont)), identifier: identifier.to_owned(), font_data: font_data } } + + /// Retrieves the Core Text font instance, instantiating it if necessary. + pub fn ctfont(&self) -> Option<CTFont> { + let mut ctfont = self.ctfont.lock().unwrap(); + if ctfont.is_none() { + *ctfont = core_text::font::new_from_name(self.identifier.as_slice(), 0.0).ok() + } + ctfont.as_ref().map(|ctfont| (*ctfont).clone()) + } } -pub struct CachedCTFont(Option<CTFont>); +pub struct CachedCTFont(Mutex<Option<CTFont>>); impl Deref for CachedCTFont { - type Target = Option<CTFont>; - fn deref(&self) -> &Option<CTFont> { + type Target = Mutex<Option<CTFont>>; + fn deref(&self) -> &Mutex<Option<CTFont>> { &self.0 } } @@ -84,7 +94,7 @@ impl Deserialize for CachedCTFont { #[inline] fn visit_none<E>(&mut self) -> Result<CachedCTFont,E> where E: Error { - Ok(CachedCTFont(None)) + Ok(CachedCTFont(Mutex::new(None))) } } |