aboutsummaryrefslogtreecommitdiffstats
path: root/components/gfx/tests/font_template.rs
diff options
context:
space:
mode:
authorMartin Robinson <mrobinson@igalia.com>2024-04-12 12:39:32 +0200
committerGitHub <noreply@github.com>2024-04-12 10:39:32 +0000
commitefa0d457574f02dfbe2403f501a4626acdcb64db (patch)
treef114f9a1233a111863170b6eea10f02d11d57b37 /components/gfx/tests/font_template.rs
parente9591ce62f210d374463bdf1a6d956e19cca81f0 (diff)
downloadservo-efa0d457574f02dfbe2403f501a4626acdcb64db.tar.gz
servo-efa0d457574f02dfbe2403f501a4626acdcb64db.zip
Remove `FontContextHandle` (#32038)
The `FontContextHandle` was really only used on FreeType platforms to store the `FT_Library` handle to use for creating faces. Each `FontContext` and `FontCacheThread` would create its own `FontContextHandle`. This change removes this data structure in favor of a mutex-protected shared `FontContextHandle` for an entire Servo process. The handle is initialized using a `OnceLock` to ensure that it only happens once and also that it stays alive for the entire process lifetime. In addition to greatly simplifying the code, this will make it possible for different threads to share platform-specific `FontHandle`s, avoiding multiple allocations for a single font. The only downside to all of this is that memory usage of FreeType fonts isn't measured (though the mechanism is still there). This is because the `FontCacheThread` currently doesn't do any memory measurement. Eventually this *will* happen though, during the font system redesign. In exchange, this should reduce the memory usage since there is only a single FreeType library loaded into memory now. This is part of #32033.
Diffstat (limited to 'components/gfx/tests/font_template.rs')
-rw-r--r--components/gfx/tests/font_template.rs5
1 files changed, 1 insertions, 4 deletions
diff --git a/components/gfx/tests/font_template.rs b/components/gfx/tests/font_template.rs
index 1c8420bc45c..d35c3607497 100644
--- a/components/gfx/tests/font_template.rs
+++ b/components/gfx/tests/font_template.rs
@@ -11,7 +11,6 @@ fn test_font_template_descriptor() {
use std::path::PathBuf;
use gfx::font_cache_thread::FontIdentifier;
- use gfx::font_context::FontContextHandle;
use gfx::font_template::{FontTemplate, FontTemplateDescriptor};
use servo_url::ServoUrl;
use style::values::computed::font::{FontStretch, FontStyle, FontWeight};
@@ -35,9 +34,7 @@ fn test_font_template_descriptor() {
)
.unwrap();
- let context = FontContextHandle::default();
-
- template.descriptor(&context).unwrap()
+ template.descriptor().unwrap()
}
assert_eq!(