gfx: Remove FontTemplateData (#32034)

Now that `FontTemplateData` is more or less the same on all platforms,
it can be removed. This is a preparatory change for a full refactor of
the font system on Servo. The major changes here are:

 - Remove `FontTemplateData` and move its members into `FontTemplate`
 - Make `FontTemplate` have full interior mutability instead of only
   the `FontTemplateData` member. This is preparation for having these
   data types `Send` and `Sync` with locking.
 - Remove the strong/weak reference concept for font data. In practice,
   all font data references were strong, so this was never fully
   complete. Instead of using this approach, the new font system will
   use a central font data cache with references associated to layouts.
 - The `CTFont` cache is now a global cache, so `CTFont`s can be shared
   between threads. The cache is cleared when clearing font caches.

A benefit of this change (apart from `CTFont` sharing) is that font data
loading is platform-independent now.
This commit is contained in:
Martin Robinson 2024-04-16 19:50:50 +02:00 committed by GitHub
parent 689c144714
commit 6b2fa91357
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
19 changed files with 394 additions and 600 deletions

View file

@ -21,6 +21,8 @@ use crate::font::{
Font, FontDescriptor, FontFamilyDescriptor, FontGroup, FontHandleMethods, FontRef,
};
use crate::font_cache_thread::FontTemplateInfo;
#[cfg(target_os = "macos")]
use crate::font_template::FontTemplate;
use crate::font_template::FontTemplateDescriptor;
use crate::platform::font::FontHandle;
@ -264,4 +266,7 @@ impl Hash for FontGroupCacheKey {
#[inline]
pub fn invalidate_font_caches() {
FONT_CACHE_EPOCH.fetch_add(1, Ordering::SeqCst);
#[cfg(target_os = "macos")]
FontTemplate::clear_core_text_font_cache();
}