Store style system options in the global style data and shared style context.

I wanted to add an environmental variable to disable the style sharing
cache for gecko, but the current pattern involves lazy_static!, which
involves an atomic operation on lookup, which is a bit hot to do each
time we try to share styles. This makes that work happen once per
process.
This commit is contained in:
Bobby Holley 2017-04-12 14:19:06 +08:00
parent 3c5a21ebf3
commit dc5dbd5542
7 changed files with 66 additions and 50 deletions

View file

@ -4,6 +4,7 @@
//! Global style data
use context::StyleSystemOptions;
use num_cpus;
use rayon;
use shared_lock::SharedRwLock;
@ -20,6 +21,9 @@ pub struct GlobalStyleData {
/// Shared RWLock for CSSOM objects
pub shared_lock: SharedRwLock,
/// Global style system options determined by env vars.
pub options: StyleSystemOptions,
}
lazy_static! {
@ -45,6 +49,7 @@ lazy_static! {
num_threads: num_threads,
style_thread_pool: pool,
shared_lock: SharedRwLock::new(),
options: StyleSystemOptions::default(),
}
};
}