| 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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 #endif // !OS(WIN) | 66 #endif // !OS(WIN) |
| 67 | 67 |
| 68 typedef HashMap<FontCacheKey, OwnPtr<FontPlatformData>, FontCacheKeyHash, FontCa
cheKeyTraits> FontPlatformDataCache; | 68 typedef HashMap<FontCacheKey, OwnPtr<FontPlatformData>, FontCacheKeyHash, FontCa
cheKeyTraits> FontPlatformDataCache; |
| 69 typedef HashMap<FallbackListCompositeKey, OwnPtr<ShapeCache>, FallbackListCompos
iteKeyHash, FallbackListCompositeKeyTraits> FallbackListShaperCache; | 69 typedef HashMap<FallbackListCompositeKey, OwnPtr<ShapeCache>, FallbackListCompos
iteKeyHash, FallbackListCompositeKeyTraits> FallbackListShaperCache; |
| 70 | 70 |
| 71 static FontPlatformDataCache* gFontPlatformDataCache = nullptr; | 71 static FontPlatformDataCache* gFontPlatformDataCache = nullptr; |
| 72 static FallbackListShaperCache* gFallbackListShaperCache = nullptr; | 72 static FallbackListShaperCache* gFallbackListShaperCache = nullptr; |
| 73 | 73 |
| 74 #if OS(WIN) | 74 #if OS(WIN) |
| 75 bool FontCache::s_useDirectWrite = false; | 75 bool FontCache::s_useDirectWrite = false; |
| 76 IDWriteFactory* FontCache::s_directWriteFactory = 0; | 76 SkFontMgr* FontCache::s_fontManager = nullptr; |
| 77 bool FontCache::s_useSubpixelPositioning = false; | 77 bool FontCache::s_useSubpixelPositioning = false; |
| 78 float FontCache::s_deviceScaleFactor = 1.0; | 78 float FontCache::s_deviceScaleFactor = 1.0; |
| 79 #endif // OS(WIN) | 79 #endif // OS(WIN) |
| 80 | 80 |
| 81 FontCache* FontCache::fontCache() | 81 FontCache* FontCache::fontCache() |
| 82 { | 82 { |
| 83 DEFINE_STATIC_LOCAL(FontCache, globalFontCache, ()); | 83 DEFINE_STATIC_LOCAL(FontCache, globalFontCache, ()); |
| 84 return &globalFontCache; | 84 return &globalFontCache; |
| 85 } | 85 } |
| 86 | 86 |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 } | 140 } |
| 141 | 141 |
| 142 typedef HashMap<FontCache::FontFileKey, RefPtr<OpenTypeVerticalData>, IntHash<Fo
ntCache::FontFileKey>, UnsignedWithZeroKeyHashTraits<FontCache::FontFileKey>> Fo
ntVerticalDataCache; | 142 typedef HashMap<FontCache::FontFileKey, RefPtr<OpenTypeVerticalData>, IntHash<Fo
ntCache::FontFileKey>, UnsignedWithZeroKeyHashTraits<FontCache::FontFileKey>> Fo
ntVerticalDataCache; |
| 143 | 143 |
| 144 FontVerticalDataCache& fontVerticalDataCacheInstance() | 144 FontVerticalDataCache& fontVerticalDataCacheInstance() |
| 145 { | 145 { |
| 146 DEFINE_STATIC_LOCAL(FontVerticalDataCache, fontVerticalDataCache, ()); | 146 DEFINE_STATIC_LOCAL(FontVerticalDataCache, fontVerticalDataCache, ()); |
| 147 return fontVerticalDataCache; | 147 return fontVerticalDataCache; |
| 148 } | 148 } |
| 149 | 149 |
| 150 #if OS(WIN) |
| 151 void FontCache::setFontManager(const RefPtr<SkFontMgr>& fontManager) |
| 152 { |
| 153 ASSERT(!s_fontManager); |
| 154 s_fontManager = fontManager.get(); |
| 155 // Explicitly AddRef since we're going to hold on to the object for the life
of the program. |
| 156 s_fontManager->ref(); |
| 157 } |
| 158 #endif |
| 159 |
| 150 PassRefPtr<OpenTypeVerticalData> FontCache::getVerticalData(const FontFileKey& k
ey, const FontPlatformData& platformData) | 160 PassRefPtr<OpenTypeVerticalData> FontCache::getVerticalData(const FontFileKey& k
ey, const FontPlatformData& platformData) |
| 151 { | 161 { |
| 152 FontVerticalDataCache& fontVerticalDataCache = fontVerticalDataCacheInstance
(); | 162 FontVerticalDataCache& fontVerticalDataCache = fontVerticalDataCacheInstance
(); |
| 153 FontVerticalDataCache::iterator result = fontVerticalDataCache.find(key); | 163 FontVerticalDataCache::iterator result = fontVerticalDataCache.find(key); |
| 154 if (result != fontVerticalDataCache.end()) | 164 if (result != fontVerticalDataCache.end()) |
| 155 return result.get()->value; | 165 return result.get()->value; |
| 156 | 166 |
| 157 RefPtr<OpenTypeVerticalData> verticalData = OpenTypeVerticalData::create(pla
tformData); | 167 RefPtr<OpenTypeVerticalData> verticalData = OpenTypeVerticalData::create(pla
tformData); |
| 158 if (!verticalData->isOpenType()) | 168 if (!verticalData->isOpenType()) |
| 159 verticalData.clear(); | 169 verticalData.clear(); |
| (...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 394 iter != gFallbackListShaperCache->end(); | 404 iter != gFallbackListShaperCache->end(); |
| 395 ++iter) { | 405 ++iter) { |
| 396 shapeResultCacheSize += iter->value->byteSize(); | 406 shapeResultCacheSize += iter->value->byteSize(); |
| 397 } | 407 } |
| 398 dump->addScalar("size", "bytes", shapeResultCacheSize); | 408 dump->addScalar("size", "bytes", shapeResultCacheSize); |
| 399 memoryDump->addSuballocation(dump->guid(), String(WTF::Partitions::kAllocate
dObjectPoolName)); | 409 memoryDump->addSuballocation(dump->guid(), String(WTF::Partitions::kAllocate
dObjectPoolName)); |
| 400 } | 410 } |
| 401 | 411 |
| 402 | 412 |
| 403 } // namespace blink | 413 } // namespace blink |
| OLD | NEW |