aboutsummaryrefslogtreecommitdiffstats
path: root/components/gfx/font_cache_task.rs
diff options
context:
space:
mode:
Diffstat (limited to 'components/gfx/font_cache_task.rs')
-rw-r--r--components/gfx/font_cache_task.rs21
1 files changed, 13 insertions, 8 deletions
diff --git a/components/gfx/font_cache_task.rs b/components/gfx/font_cache_task.rs
index 5bb3a209d68..ac7648e1821 100644
--- a/components/gfx/font_cache_task.rs
+++ b/components/gfx/font_cache_task.rs
@@ -12,6 +12,7 @@ use collections::str::Str;
use std::borrow::ToOwned;
use std::collections::HashMap;
use std::sync::Arc;
+use std::sync::mpsc::{Sender, Receiver, channel};
use font_template::{FontTemplate, FontTemplateDescriptor};
use platform::font_template::FontTemplateData;
use servo_net::resource_task::{ResourceTask, load_whole_resource};
@@ -80,11 +81,15 @@ pub enum Command {
Exit(Sender<()>),
}
+unsafe impl Send for Command {}
+
/// Reply messages sent from the font cache task to the FontContext caller.
pub enum Reply {
GetFontTemplateReply(Option<Arc<FontTemplateData>>),
}
+unsafe impl Send for Reply {}
+
/// The font cache task itself. It maintains a list of reference counted
/// font templates that are currently in use.
struct FontCache {
@@ -109,7 +114,7 @@ fn add_generic_font(generic_fonts: &mut HashMap<LowercaseString, LowercaseString
impl FontCache {
fn run(&mut self) {
loop {
- let msg = self.port.recv();
+ let msg = self.port.recv().unwrap();
match msg {
Command::GetFontTemplate(family, descriptor, result) => {
@@ -138,13 +143,13 @@ impl FontCache {
family.add_template(url.to_string().as_slice(), Some(bytes));
},
Err(_) => {
- debug!("Failed to load web font: family={} url={}", family_name, url);
+ debug!("Failed to load web font: family={:?} url={}", family_name, url);
}
}
}
Source::Local(ref local_family_name) => {
let family = &mut self.web_families[family_name];
- get_variations_for_family(local_family_name.as_slice(), |path| {
+ get_variations_for_family(local_family_name.as_slice(), |&mut:path| {
family.add_template(path.as_slice(), None);
});
}
@@ -186,7 +191,7 @@ impl FontCache {
let s = &mut self.local_families[*family_name];
if s.templates.len() == 0 {
- get_variations_for_family(family_name.as_slice(), |path| {
+ get_variations_for_family(family_name.as_slice(), |&mut:path| {
s.add_template(path.as_slice(), None);
});
}
@@ -244,7 +249,7 @@ impl FontCache {
/// The public interface to the font cache task, used exclusively by
/// the per-thread/task FontContext structures.
-#[deriving(Clone)]
+#[derive(Clone)]
pub struct FontCacheTask {
chan: Sender<Command>,
}
@@ -253,7 +258,7 @@ impl FontCacheTask {
pub fn new(resource_task: ResourceTask) -> FontCacheTask {
let (chan, port) = channel();
- spawn_named("FontCacheTask".to_owned(), proc() {
+ spawn_named("FontCacheTask".to_owned(), move || {
// TODO: Allow users to specify these.
let mut generic_fonts = HashMap::with_capacity(5);
add_generic_font(&mut generic_fonts, "serif", "Times New Roman");
@@ -286,7 +291,7 @@ impl FontCacheTask {
let (response_chan, response_port) = channel();
self.chan.send(Command::GetFontTemplate(family, desc, response_chan));
- let reply = response_port.recv();
+ let reply = response_port.recv().unwrap();
match reply {
Reply::GetFontTemplateReply(data) => {
@@ -301,7 +306,7 @@ impl FontCacheTask {
let (response_chan, response_port) = channel();
self.chan.send(Command::GetLastResortFontTemplate(desc, response_chan));
- let reply = response_port.recv();
+ let reply = response_port.recv().unwrap();
match reply {
Reply::GetFontTemplateReply(data) => {