mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Rename FontTemplateInfo
to FontTemplateAndWebRenderFontKey
(#32100)
This clarifies what this type does a bit. Based on a suggestion by @mukilan.
This commit is contained in:
parent
ab2b001265
commit
83dec920dd
3 changed files with 16 additions and 16 deletions
|
@ -42,13 +42,13 @@ pub struct FontTemplates {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
pub struct FontTemplateInfo {
|
pub struct FontTemplateAndWebRenderFontKey {
|
||||||
pub font_template: FontTemplateRef,
|
pub font_template: FontTemplateRef,
|
||||||
pub font_key: FontKey,
|
pub font_key: FontKey,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Deserialize, Serialize)]
|
#[derive(Debug, Deserialize, Serialize)]
|
||||||
pub struct SerializedFontTemplateInfo {
|
pub struct SerializedFontTemplateAndWebRenderFontKey {
|
||||||
pub serialized_font_template: SerializedFontTemplate,
|
pub serialized_font_template: SerializedFontTemplate,
|
||||||
pub font_key: FontKey,
|
pub font_key: FontKey,
|
||||||
}
|
}
|
||||||
|
@ -151,7 +151,7 @@ pub enum Command {
|
||||||
/// Reply messages sent from the font cache thread to the FontContext caller.
|
/// Reply messages sent from the font cache thread to the FontContext caller.
|
||||||
#[derive(Debug, Deserialize, Serialize)]
|
#[derive(Debug, Deserialize, Serialize)]
|
||||||
pub enum Reply {
|
pub enum Reply {
|
||||||
GetFontTemplateReply(Option<SerializedFontTemplateInfo>),
|
GetFontTemplateReply(Option<SerializedFontTemplateAndWebRenderFontKey>),
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The font cache thread itself. It maintains a list of reference counted
|
/// The font cache thread itself. It maintains a list of reference counted
|
||||||
|
@ -218,7 +218,7 @@ impl FontCache {
|
||||||
};
|
};
|
||||||
|
|
||||||
let _ = result.send(Reply::GetFontTemplateReply(Some(
|
let _ = result.send(Reply::GetFontTemplateReply(Some(
|
||||||
SerializedFontTemplateInfo {
|
SerializedFontTemplateAndWebRenderFontKey {
|
||||||
serialized_font_template,
|
serialized_font_template,
|
||||||
font_key: font_template_info.font_key,
|
font_key: font_template_info.font_key,
|
||||||
},
|
},
|
||||||
|
@ -452,7 +452,7 @@ impl FontCache {
|
||||||
&mut self,
|
&mut self,
|
||||||
template_descriptor: &FontTemplateDescriptor,
|
template_descriptor: &FontTemplateDescriptor,
|
||||||
family_descriptor: &FontFamilyDescriptor,
|
family_descriptor: &FontFamilyDescriptor,
|
||||||
) -> Option<FontTemplateInfo> {
|
) -> Option<FontTemplateAndWebRenderFontKey> {
|
||||||
match family_descriptor.scope {
|
match family_descriptor.scope {
|
||||||
FontSearchScope::Any => self
|
FontSearchScope::Any => self
|
||||||
.find_font_in_web_family(template_descriptor, &family_descriptor.name)
|
.find_font_in_web_family(template_descriptor, &family_descriptor.name)
|
||||||
|
@ -464,7 +464,7 @@ impl FontCache {
|
||||||
self.find_font_in_local_family(template_descriptor, &family_descriptor.name)
|
self.find_font_in_local_family(template_descriptor, &family_descriptor.name)
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
.map(|font_template| FontTemplateInfo {
|
.map(|font_template| FontTemplateAndWebRenderFontKey {
|
||||||
font_key: self.get_font_key_for_template(&font_template),
|
font_key: self.get_font_key_for_template(&font_template),
|
||||||
font_template,
|
font_template,
|
||||||
})
|
})
|
||||||
|
@ -600,7 +600,7 @@ impl FontSource for FontCacheThread {
|
||||||
&mut self,
|
&mut self,
|
||||||
template_descriptor: FontTemplateDescriptor,
|
template_descriptor: FontTemplateDescriptor,
|
||||||
family_descriptor: FontFamilyDescriptor,
|
family_descriptor: FontFamilyDescriptor,
|
||||||
) -> Option<FontTemplateInfo> {
|
) -> Option<FontTemplateAndWebRenderFontKey> {
|
||||||
let (response_chan, response_port) = ipc::channel().expect("failed to create IPC channel");
|
let (response_chan, response_port) = ipc::channel().expect("failed to create IPC channel");
|
||||||
self.chan
|
self.chan
|
||||||
.send(Command::GetFontTemplate(
|
.send(Command::GetFontTemplate(
|
||||||
|
@ -629,7 +629,7 @@ impl FontSource for FontCacheThread {
|
||||||
.serialized_font_template
|
.serialized_font_template
|
||||||
.to_font_template(),
|
.to_font_template(),
|
||||||
));
|
));
|
||||||
FontTemplateInfo {
|
FontTemplateAndWebRenderFontKey {
|
||||||
font_template,
|
font_template,
|
||||||
font_key: serialized_font_template_info.font_key,
|
font_key: serialized_font_template_info.font_key,
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,7 @@ use webrender_api::{FontInstanceKey, FontKey};
|
||||||
use crate::font::{
|
use crate::font::{
|
||||||
Font, FontDescriptor, FontFamilyDescriptor, FontGroup, FontHandleMethods, FontRef,
|
Font, FontDescriptor, FontFamilyDescriptor, FontGroup, FontHandleMethods, FontRef,
|
||||||
};
|
};
|
||||||
use crate::font_cache_thread::FontTemplateInfo;
|
use crate::font_cache_thread::FontTemplateAndWebRenderFontKey;
|
||||||
#[cfg(target_os = "macos")]
|
#[cfg(target_os = "macos")]
|
||||||
use crate::font_template::FontTemplate;
|
use crate::font_template::FontTemplate;
|
||||||
use crate::font_template::FontTemplateDescriptor;
|
use crate::font_template::FontTemplateDescriptor;
|
||||||
|
@ -39,7 +39,7 @@ pub trait FontSource {
|
||||||
&mut self,
|
&mut self,
|
||||||
template_descriptor: FontTemplateDescriptor,
|
template_descriptor: FontTemplateDescriptor,
|
||||||
family_descriptor: FontFamilyDescriptor,
|
family_descriptor: FontFamilyDescriptor,
|
||||||
) -> Option<FontTemplateInfo>;
|
) -> Option<FontTemplateAndWebRenderFontKey>;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The FontContext represents the per-thread/thread state necessary for
|
/// The FontContext represents the per-thread/thread state necessary for
|
||||||
|
@ -54,7 +54,7 @@ pub struct FontContext<S: FontSource> {
|
||||||
// so they will never be released. Find out a good time to drop them.
|
// so they will never be released. Find out a good time to drop them.
|
||||||
// See bug https://github.com/servo/servo/issues/3300
|
// See bug https://github.com/servo/servo/issues/3300
|
||||||
font_cache: HashMap<FontCacheKey, Option<FontRef>>,
|
font_cache: HashMap<FontCacheKey, Option<FontRef>>,
|
||||||
font_template_cache: HashMap<FontTemplateCacheKey, Option<FontTemplateInfo>>,
|
font_template_cache: HashMap<FontTemplateCacheKey, Option<FontTemplateAndWebRenderFontKey>>,
|
||||||
|
|
||||||
font_group_cache:
|
font_group_cache:
|
||||||
HashMap<FontGroupCacheKey, Rc<RefCell<FontGroup>>, BuildHasherDefault<FnvHasher>>,
|
HashMap<FontGroupCacheKey, Rc<RefCell<FontGroup>>, BuildHasherDefault<FnvHasher>>,
|
||||||
|
@ -183,7 +183,7 @@ impl<S: FontSource> FontContext<S> {
|
||||||
&mut self,
|
&mut self,
|
||||||
template_descriptor: &FontTemplateDescriptor,
|
template_descriptor: &FontTemplateDescriptor,
|
||||||
family_descriptor: &FontFamilyDescriptor,
|
family_descriptor: &FontFamilyDescriptor,
|
||||||
) -> Option<FontTemplateInfo> {
|
) -> Option<FontTemplateAndWebRenderFontKey> {
|
||||||
let cache_key = FontTemplateCacheKey {
|
let cache_key = FontTemplateCacheKey {
|
||||||
template_descriptor: *template_descriptor,
|
template_descriptor: *template_descriptor,
|
||||||
family_descriptor: family_descriptor.clone(),
|
family_descriptor: family_descriptor.clone(),
|
||||||
|
@ -210,7 +210,7 @@ impl<S: FontSource> FontContext<S> {
|
||||||
/// cache thread and a `FontDescriptor` which contains the styling parameters.
|
/// cache thread and a `FontDescriptor` which contains the styling parameters.
|
||||||
fn create_font(
|
fn create_font(
|
||||||
&mut self,
|
&mut self,
|
||||||
info: FontTemplateInfo,
|
info: FontTemplateAndWebRenderFontKey,
|
||||||
descriptor: FontDescriptor,
|
descriptor: FontDescriptor,
|
||||||
synthesized_small_caps: Option<FontRef>,
|
synthesized_small_caps: Option<FontRef>,
|
||||||
) -> Result<Font, &'static str> {
|
) -> Result<Font, &'static str> {
|
||||||
|
|
|
@ -14,7 +14,7 @@ use gfx::font::{
|
||||||
fallback_font_families, FontDescriptor, FontFamilyDescriptor, FontFamilyName,
|
fallback_font_families, FontDescriptor, FontFamilyDescriptor, FontFamilyName,
|
||||||
FontHandleMethods, FontSearchScope,
|
FontHandleMethods, FontSearchScope,
|
||||||
};
|
};
|
||||||
use gfx::font_cache_thread::{FontIdentifier, FontTemplateInfo, FontTemplates};
|
use gfx::font_cache_thread::{FontIdentifier, FontTemplateAndWebRenderFontKey, FontTemplates};
|
||||||
use gfx::font_context::{FontContext, FontSource};
|
use gfx::font_context::{FontContext, FontSource};
|
||||||
use gfx::font_template::FontTemplateDescriptor;
|
use gfx::font_template::FontTemplateDescriptor;
|
||||||
use servo_arc::Arc;
|
use servo_arc::Arc;
|
||||||
|
@ -88,12 +88,12 @@ impl FontSource for TestFontSource {
|
||||||
&mut self,
|
&mut self,
|
||||||
template_descriptor: FontTemplateDescriptor,
|
template_descriptor: FontTemplateDescriptor,
|
||||||
family_descriptor: FontFamilyDescriptor,
|
family_descriptor: FontFamilyDescriptor,
|
||||||
) -> Option<FontTemplateInfo> {
|
) -> Option<FontTemplateAndWebRenderFontKey> {
|
||||||
self.find_font_count.set(self.find_font_count.get() + 1);
|
self.find_font_count.set(self.find_font_count.get() + 1);
|
||||||
self.families
|
self.families
|
||||||
.get_mut(family_descriptor.name())
|
.get_mut(family_descriptor.name())
|
||||||
.and_then(|family| family.find_font_for_style(&template_descriptor))
|
.and_then(|family| family.find_font_for_style(&template_descriptor))
|
||||||
.map(|template| FontTemplateInfo {
|
.map(|template| FontTemplateAndWebRenderFontKey {
|
||||||
font_template: template,
|
font_template: template,
|
||||||
font_key: FontKey(IdNamespace(0), 0),
|
font_key: FontKey(IdNamespace(0), 0),
|
||||||
})
|
})
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue