| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2006, 2008 Apple Inc. All rights reserved. | 2 * Copyright (C) 2006, 2008 Apple Inc. All rights reserved. |
| 3 * Copyright (C) 2007 Nicholas Shanks <webkit@nickshanks.com> | 3 * Copyright (C) 2007 Nicholas Shanks <webkit@nickshanks.com> |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
| 7 * are met: | 7 * are met: |
| 8 * | 8 * |
| 9 * 1. Redistributions of source code must retain the above copyright | 9 * 1. Redistributions of source code must retain the above copyright |
| 10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 #include "wtf/ListHashSet.h" | 52 #include "wtf/ListHashSet.h" |
| 53 #include "wtf/StdLibExtras.h" | 53 #include "wtf/StdLibExtras.h" |
| 54 #include "wtf/Vector.h" | 54 #include "wtf/Vector.h" |
| 55 #include "wtf/text/AtomicStringHash.h" | 55 #include "wtf/text/AtomicStringHash.h" |
| 56 #include "wtf/text/StringHash.h" | 56 #include "wtf/text/StringHash.h" |
| 57 | 57 |
| 58 using namespace WTF; | 58 using namespace WTF; |
| 59 | 59 |
| 60 namespace blink { | 60 namespace blink { |
| 61 | 61 |
| 62 #if !OS(WIN) | 62 #if !OS(WIN) && !OS(LINUX) |
| 63 FontCache::FontCache() | 63 FontCache::FontCache() |
| 64 : m_purgePreventCount(0) | 64 : m_purgePreventCount(0) |
| 65 , m_fontManager(nullptr) |
| 65 { | 66 { |
| 66 } | 67 } |
| 67 #endif // !OS(WIN) | 68 #endif // !OS(WIN) && !OS(LINUX) |
| 68 | 69 |
| 69 typedef HashMap<FontCacheKey, OwnPtr<FontPlatformData>, FontCacheKeyHash, FontCa
cheKeyTraits> FontPlatformDataCache; | 70 typedef HashMap<FontCacheKey, OwnPtr<FontPlatformData>, FontCacheKeyHash, FontCa
cheKeyTraits> FontPlatformDataCache; |
| 70 typedef HashMap<FallbackListCompositeKey, OwnPtr<ShapeCache>, FallbackListCompos
iteKeyHash, FallbackListCompositeKeyTraits> FallbackListShaperCache; | 71 typedef HashMap<FallbackListCompositeKey, OwnPtr<ShapeCache>, FallbackListCompos
iteKeyHash, FallbackListCompositeKeyTraits> FallbackListShaperCache; |
| 71 | 72 |
| 72 static FontPlatformDataCache* gFontPlatformDataCache = nullptr; | 73 static FontPlatformDataCache* gFontPlatformDataCache = nullptr; |
| 73 static FallbackListShaperCache* gFallbackListShaperCache = nullptr; | 74 static FallbackListShaperCache* gFallbackListShaperCache = nullptr; |
| 74 | 75 |
| 76 SkFontMgr* FontCache::s_fontManager = nullptr; |
| 77 |
| 75 #if OS(WIN) | 78 #if OS(WIN) |
| 76 bool FontCache::s_useDirectWrite = false; | 79 bool FontCache::s_useDirectWrite = false; |
| 77 bool FontCache::s_antialiasedTextEnabled = false; | 80 bool FontCache::s_antialiasedTextEnabled = false; |
| 78 bool FontCache::s_lcdTextEnabled = false; | 81 bool FontCache::s_lcdTextEnabled = false; |
| 79 SkFontMgr* FontCache::s_fontManager = nullptr; | |
| 80 bool FontCache::s_useSubpixelPositioning = false; | 82 bool FontCache::s_useSubpixelPositioning = false; |
| 81 float FontCache::s_deviceScaleFactor = 1.0; | 83 float FontCache::s_deviceScaleFactor = 1.0; |
| 82 #endif // OS(WIN) | 84 #endif // OS(WIN) |
| 83 | 85 |
| 84 FontCache* FontCache::fontCache() | 86 FontCache* FontCache::fontCache() |
| 85 { | 87 { |
| 86 DEFINE_STATIC_LOCAL(FontCache, globalFontCache, ()); | 88 DEFINE_STATIC_LOCAL(FontCache, globalFontCache, ()); |
| 87 return &globalFontCache; | 89 return &globalFontCache; |
| 88 } | 90 } |
| 89 | 91 |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 } | 145 } |
| 144 | 146 |
| 145 typedef HashMap<FontCache::FontFileKey, RefPtr<OpenTypeVerticalData>, IntHash<Fo
ntCache::FontFileKey>, UnsignedWithZeroKeyHashTraits<FontCache::FontFileKey>> Fo
ntVerticalDataCache; | 147 typedef HashMap<FontCache::FontFileKey, RefPtr<OpenTypeVerticalData>, IntHash<Fo
ntCache::FontFileKey>, UnsignedWithZeroKeyHashTraits<FontCache::FontFileKey>> Fo
ntVerticalDataCache; |
| 146 | 148 |
| 147 FontVerticalDataCache& fontVerticalDataCacheInstance() | 149 FontVerticalDataCache& fontVerticalDataCacheInstance() |
| 148 { | 150 { |
| 149 DEFINE_STATIC_LOCAL(FontVerticalDataCache, fontVerticalDataCache, ()); | 151 DEFINE_STATIC_LOCAL(FontVerticalDataCache, fontVerticalDataCache, ()); |
| 150 return fontVerticalDataCache; | 152 return fontVerticalDataCache; |
| 151 } | 153 } |
| 152 | 154 |
| 153 #if OS(WIN) | |
| 154 void FontCache::setFontManager(const RefPtr<SkFontMgr>& fontManager) | 155 void FontCache::setFontManager(const RefPtr<SkFontMgr>& fontManager) |
| 155 { | 156 { |
| 156 ASSERT(!s_fontManager); | 157 ASSERT(!s_fontManager); |
| 157 s_fontManager = fontManager.get(); | 158 s_fontManager = fontManager.get(); |
| 158 // Explicitly AddRef since we're going to hold on to the object for the life
of the program. | 159 // Explicitly AddRef since we're going to hold on to the object for the life
of the program. |
| 159 s_fontManager->ref(); | 160 s_fontManager->ref(); |
| 160 } | 161 } |
| 161 #endif | |
| 162 | 162 |
| 163 PassRefPtr<OpenTypeVerticalData> FontCache::getVerticalData(const FontFileKey& k
ey, const FontPlatformData& platformData) | 163 PassRefPtr<OpenTypeVerticalData> FontCache::getVerticalData(const FontFileKey& k
ey, const FontPlatformData& platformData) |
| 164 { | 164 { |
| 165 FontVerticalDataCache& fontVerticalDataCache = fontVerticalDataCacheInstance
(); | 165 FontVerticalDataCache& fontVerticalDataCache = fontVerticalDataCacheInstance
(); |
| 166 FontVerticalDataCache::iterator result = fontVerticalDataCache.find(key); | 166 FontVerticalDataCache::iterator result = fontVerticalDataCache.find(key); |
| 167 if (result != fontVerticalDataCache.end()) | 167 if (result != fontVerticalDataCache.end()) |
| 168 return result.get()->value; | 168 return result.get()->value; |
| 169 | 169 |
| 170 RefPtr<OpenTypeVerticalData> verticalData = OpenTypeVerticalData::create(pla
tformData); | 170 RefPtr<OpenTypeVerticalData> verticalData = OpenTypeVerticalData::create(pla
tformData); |
| 171 if (!verticalData->isOpenType()) | 171 if (!verticalData->isOpenType()) |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 377 iter != gFallbackListShaperCache->end(); | 377 iter != gFallbackListShaperCache->end(); |
| 378 ++iter) { | 378 ++iter) { |
| 379 shapeResultCacheSize += iter->value->byteSize(); | 379 shapeResultCacheSize += iter->value->byteSize(); |
| 380 } | 380 } |
| 381 dump->addScalar("size", "bytes", shapeResultCacheSize); | 381 dump->addScalar("size", "bytes", shapeResultCacheSize); |
| 382 memoryDump->addSuballocation(dump->guid(), String(WTF::Partitions::kAllocate
dObjectPoolName)); | 382 memoryDump->addSuballocation(dump->guid(), String(WTF::Partitions::kAllocate
dObjectPoolName)); |
| 383 } | 383 } |
| 384 | 384 |
| 385 | 385 |
| 386 } // namespace blink | 386 } // namespace blink |
| OLD | NEW |