Changeset 236383 in webkit


Ignore:
Timestamp:
Sep 22, 2018 12:56:20 AM (6 years ago)
Author:
Chris Dumez
Message:

FontDataCache should use Ref<Font> instead of a RefPtr<Font>
https://bugs.webkit.org/show_bug.cgi?id=189861

Reviewed by Antti Koivisto.

  • platform/graphics/FontCache.cpp:

(WebCore::FontCache::fontForPlatformData):
(WebCore::FontCache::purgeInactiveFontData):

Location:
trunk/Source/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r236379 r236383  
     12018-09-22  Chris Dumez  <cdumez@apple.com>
     2
     3        FontDataCache should use Ref<Font> instead of a RefPtr<Font>
     4        https://bugs.webkit.org/show_bug.cgi?id=189861
     5
     6        Reviewed by Antti Koivisto.
     7
     8        * platform/graphics/FontCache.cpp:
     9        (WebCore::FontCache::fontForPlatformData):
     10        (WebCore::FontCache::purgeInactiveFontData):
     11
    1122018-09-21  Justin Michaud  <justin_michaud@apple.com>
    213
  • trunk/Source/WebCore/platform/graphics/FontCache.cpp

    r236254 r236383  
    284284};
    285285
    286 typedef HashMap<FontPlatformData, RefPtr<Font>, FontDataCacheKeyHash, FontDataCacheKeyTraits> FontDataCache;
     286typedef HashMap<FontPlatformData, Ref<Font>, FontDataCacheKeyHash, FontDataCacheKeyTraits> FontDataCache;
    287287
    288288static FontDataCache& cachedFonts()
     
    338338#endif
    339339   
    340     auto addResult = cachedFonts().add(platformData, nullptr);
    341     if (addResult.isNewEntry)
    342         addResult.iterator->value = Font::create(platformData);
     340    auto addResult = cachedFonts().ensure(platformData, [&] {
     341        return Font::create(platformData);
     342    });
    343343
    344344    ASSERT(addResult.iterator->value->platformData() == platformData);
    345345
    346     return *addResult.iterator->value;
     346    return addResult.iterator->value.copyRef();
    347347}
    348348
     
    376376
    377377    while (purgeCount) {
    378         Vector<RefPtr<Font>, 20> fontsToDelete;
    379         for (auto font : cachedFonts().values()) {
     378        Vector<Ref<Font>, 20> fontsToDelete;
     379        for (auto& font : cachedFonts().values()) {
    380380            LOG(Fonts, " trying to purge font %s (has one ref %d)", font->platformData().description().utf8().data(), font->hasOneRef());
    381381            if (!font->hasOneRef())
    382382                continue;
    383             fontsToDelete.append(WTFMove(font));
     383            fontsToDelete.append(font.copyRef());
    384384            if (!--purgeCount)
    385385                break;
Note: See TracChangeset for help on using the changeset viewer.