Changeset 286634 in webkit
- Timestamp:
- Dec 7, 2021, 5:35:15 PM (5 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 3 edited
-
ChangeLog (modified) (1 diff)
-
platform/graphics/FontCache.h (modified) (2 diffs)
-
platform/graphics/cocoa/FontCacheCoreText.cpp (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r286632 r286634 1 2021-12-07 Cameron McCormack <heycam@apple.com> 2 3 Move shouldAutoActivateFontIfNeeded knownFamilies cache to FontCache 4 https://bugs.webkit.org/show_bug.cgi?id=233749 5 6 Reviewed by Myles Maxfield. 7 8 With OffscreenCanvas, we can call shouldAutoActivateFontIfNeeded on a 9 worker thread, and the knownFamilies HashSet is not thread safe. Also, 10 the AtomStrings it stores are thread-specific. Move it to FontCache, so 11 each thread has its own set. 12 13 * platform/graphics/FontCache.h: 14 * platform/graphics/cocoa/FontCacheCoreText.cpp: 15 (WebCore::FontCache::shouldAutoActivateFontIfNeeded): 16 (WebCore::shouldAutoActivateFontIfNeeded): Deleted. 17 1 18 2021-12-07 Devin Rousso <drousso@apple.com> 2 19 -
trunk/Source/WebCore/platform/graphics/FontCache.h
r286625 r286634 375 375 static std::optional<ASCIILiteral> platformAlternateFamilyName(const String&); 376 376 377 #if PLATFORM(MAC) 378 bool shouldAutoActivateFontIfNeeded(const AtomString& family); 379 #endif 380 377 381 Timer m_purgeTimer; 378 382 … … 388 392 #if PLATFORM(IOS_FAMILY) 389 393 RecursiveLock m_fontLock; 394 #endif 395 396 #if PLATFORM(MAC) 397 HashSet<AtomString> m_knownFamilies; 390 398 #endif 391 399 -
trunk/Source/WebCore/platform/graphics/cocoa/FontCacheCoreText.cpp
r286625 r286634 1339 1339 1340 1340 #if PLATFORM(MAC) 1341 static bool shouldAutoActivateFontIfNeeded(const AtomString& family) 1342 { 1343 #ifndef NDEBUG 1344 // This cache is not thread safe so the following assertion is there to 1345 // make sure this function is always called from the same thread. 1346 static Thread* initThread = &Thread::current(); 1347 ASSERT(initThread == &Thread::current()); 1348 #endif 1349 1350 static NeverDestroyed<HashSet<AtomString>> knownFamilies; 1341 bool FontCache::shouldAutoActivateFontIfNeeded(const AtomString& family) 1342 { 1351 1343 static const unsigned maxCacheSize = 128; 1352 ASSERT( knownFamilies.get().size() <= maxCacheSize);1353 if ( knownFamilies.get().size() == maxCacheSize)1354 knownFamilies.get().remove(knownFamilies.get().random());1344 ASSERT(m_knownFamilies.size() <= maxCacheSize); 1345 if (m_knownFamilies.size() == maxCacheSize) 1346 m_knownFamilies.remove(m_knownFamilies.random()); 1355 1347 1356 1348 // Only attempt to auto-activate fonts once for performance reasons. 1357 return knownFamilies.get().add(family).isNewEntry;1349 return m_knownFamilies.add(family).isNewEntry; 1358 1350 } 1359 1351
Note:
See TracChangeset
for help on using the changeset viewer.