mirror of
https://github.com/servo/servo.git
synced 2025-08-05 21:50:18 +01:00
Remove most usage of ReentrantMutex in font code (#33746)
* Remove unnecessary ReentrantMutex usage for senders. Signed-off-by: Josh Matthews <josh@joshmatthews.net> * Remove double lock for freetype face. Signed-off-by: Josh Matthews <josh@joshmatthews.net> --------- Signed-off-by: Josh Matthews <josh@joshmatthews.net>
This commit is contained in:
parent
a591778a25
commit
6b3a316e1b
3 changed files with 8 additions and 9 deletions
|
@ -17,7 +17,7 @@ use malloc_size_of::{MallocSizeOf, MallocSizeOfOps};
|
||||||
use malloc_size_of_derive::MallocSizeOf;
|
use malloc_size_of_derive::MallocSizeOf;
|
||||||
use net_traits::request::{Destination, Referrer, RequestBuilder};
|
use net_traits::request::{Destination, Referrer, RequestBuilder};
|
||||||
use net_traits::{fetch_async, CoreResourceThread, FetchResponseMsg, ResourceThreads};
|
use net_traits::{fetch_async, CoreResourceThread, FetchResponseMsg, ResourceThreads};
|
||||||
use parking_lot::{Mutex, ReentrantMutex, RwLock};
|
use parking_lot::{Mutex, RwLock};
|
||||||
use servo_arc::Arc as ServoArc;
|
use servo_arc::Arc as ServoArc;
|
||||||
use servo_url::ServoUrl;
|
use servo_url::ServoUrl;
|
||||||
use style::computed_values::font_variant_caps::T as FontVariantCaps;
|
use style::computed_values::font_variant_caps::T as FontVariantCaps;
|
||||||
|
@ -49,10 +49,10 @@ static SMALL_CAPS_SCALE_FACTOR: f32 = 0.8; // Matches FireFox (see gfxFont.h)
|
||||||
/// required.
|
/// required.
|
||||||
pub struct FontContext {
|
pub struct FontContext {
|
||||||
system_font_service_proxy: Arc<SystemFontServiceProxy>,
|
system_font_service_proxy: Arc<SystemFontServiceProxy>,
|
||||||
resource_threads: ReentrantMutex<CoreResourceThread>,
|
resource_threads: Mutex<CoreResourceThread>,
|
||||||
|
|
||||||
/// A sender that can send messages and receive replies from the compositor.
|
/// A sender that can send messages and receive replies from the compositor.
|
||||||
compositor_api: ReentrantMutex<CrossProcessCompositorApi>,
|
compositor_api: Mutex<CrossProcessCompositorApi>,
|
||||||
|
|
||||||
/// The actual instances of fonts ie a [`FontTemplate`] combined with a size and
|
/// The actual instances of fonts ie a [`FontTemplate`] combined with a size and
|
||||||
/// other font properties, along with the font data and a platform font instance.
|
/// other font properties, along with the font data and a platform font instance.
|
||||||
|
@ -106,8 +106,8 @@ impl FontContext {
|
||||||
#[allow(clippy::default_constructed_unit_structs)]
|
#[allow(clippy::default_constructed_unit_structs)]
|
||||||
Self {
|
Self {
|
||||||
system_font_service_proxy,
|
system_font_service_proxy,
|
||||||
resource_threads: ReentrantMutex::new(resource_threads.core_thread),
|
resource_threads: Mutex::new(resource_threads.core_thread),
|
||||||
compositor_api: ReentrantMutex::new(compositor_api),
|
compositor_api: Mutex::new(compositor_api),
|
||||||
fonts: Default::default(),
|
fonts: Default::default(),
|
||||||
resolved_font_groups: Default::default(),
|
resolved_font_groups: Default::default(),
|
||||||
web_fonts: Arc::new(RwLock::default()),
|
web_fonts: Arc::new(RwLock::default()),
|
||||||
|
|
|
@ -150,7 +150,6 @@ impl PlatformFontMethods for PlatformFont {
|
||||||
FontStyle::NORMAL
|
FontStyle::NORMAL
|
||||||
};
|
};
|
||||||
|
|
||||||
let face = self.face.lock();
|
|
||||||
let os2_table = face.os2_table();
|
let os2_table = face.os2_table();
|
||||||
let weight = os2_table
|
let weight = os2_table
|
||||||
.as_ref()
|
.as_ref()
|
||||||
|
|
|
@ -14,7 +14,7 @@ use atomic_refcell::AtomicRefCell;
|
||||||
use ipc_channel::ipc::{self, IpcReceiver, IpcSender};
|
use ipc_channel::ipc::{self, IpcReceiver, IpcSender};
|
||||||
use log::debug;
|
use log::debug;
|
||||||
use malloc_size_of_derive::MallocSizeOf;
|
use malloc_size_of_derive::MallocSizeOf;
|
||||||
use parking_lot::{ReentrantMutex, RwLock};
|
use parking_lot::{Mutex, RwLock};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use servo_config::pref;
|
use servo_config::pref;
|
||||||
use servo_url::ServoUrl;
|
use servo_url::ServoUrl;
|
||||||
|
@ -121,7 +121,7 @@ pub struct SystemFontServiceProxySender(pub IpcSender<SystemFontServiceMessage>)
|
||||||
impl SystemFontServiceProxySender {
|
impl SystemFontServiceProxySender {
|
||||||
pub fn to_proxy(&self) -> SystemFontServiceProxy {
|
pub fn to_proxy(&self) -> SystemFontServiceProxy {
|
||||||
SystemFontServiceProxy {
|
SystemFontServiceProxy {
|
||||||
sender: ReentrantMutex::new(self.0.clone()),
|
sender: Mutex::new(self.0.clone()),
|
||||||
templates: Default::default(),
|
templates: Default::default(),
|
||||||
data_cache: Default::default(),
|
data_cache: Default::default(),
|
||||||
}
|
}
|
||||||
|
@ -384,7 +384,7 @@ struct FontTemplateCacheKey {
|
||||||
/// `FontContext` instances.
|
/// `FontContext` instances.
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct SystemFontServiceProxy {
|
pub struct SystemFontServiceProxy {
|
||||||
sender: ReentrantMutex<IpcSender<SystemFontServiceMessage>>,
|
sender: Mutex<IpcSender<SystemFontServiceMessage>>,
|
||||||
templates: RwLock<HashMap<FontTemplateCacheKey, Vec<FontTemplateRef>>>,
|
templates: RwLock<HashMap<FontTemplateCacheKey, Vec<FontTemplateRef>>>,
|
||||||
data_cache: RwLock<HashMap<FontIdentifier, Arc<FontData>>>,
|
data_cache: RwLock<HashMap<FontIdentifier, Arc<FontData>>>,
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue