Chromium Code Reviews| 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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 46 #include "public/platform/Platform.h" | 46 #include "public/platform/Platform.h" |
| 47 #include "public/platform/WebMemoryAllocatorDump.h" | 47 #include "public/platform/WebMemoryAllocatorDump.h" |
| 48 #include "public/platform/WebProcessMemoryDump.h" | 48 #include "public/platform/WebProcessMemoryDump.h" |
| 49 #include "wtf/HashMap.h" | 49 #include "wtf/HashMap.h" |
| 50 #include "wtf/ListHashSet.h" | 50 #include "wtf/ListHashSet.h" |
| 51 #include "wtf/StdLibExtras.h" | 51 #include "wtf/StdLibExtras.h" |
| 52 #include "wtf/Vector.h" | 52 #include "wtf/Vector.h" |
| 53 #include "wtf/text/AtomicStringHash.h" | 53 #include "wtf/text/AtomicStringHash.h" |
| 54 #include "wtf/text/StringHash.h" | 54 #include "wtf/text/StringHash.h" |
| 55 | 55 |
| 56 #if OS(WIN) | |
|
bungeman-chromium
2016/01/21 22:25:09
This doesn't seem to be needed anymore.
Ilya Kulshin
2016/01/27 22:07:25
Done.
| |
| 57 #include <dwrite.h> | |
| 58 #endif | |
| 59 | |
| 56 using namespace WTF; | 60 using namespace WTF; |
| 57 | 61 |
| 58 namespace blink { | 62 namespace blink { |
| 59 | 63 |
| 60 #if !OS(WIN) | 64 #if !OS(WIN) |
| 61 FontCache::FontCache() | 65 FontCache::FontCache() |
| 62 : m_purgePreventCount(0) | 66 : m_purgePreventCount(0) |
| 63 { | 67 { |
| 64 } | 68 } |
| 65 #endif // !OS(WIN) | 69 #endif // !OS(WIN) |
| 66 | 70 |
| 67 typedef HashMap<FontCacheKey, OwnPtr<FontPlatformData>, FontCacheKeyHash, FontCa cheKeyTraits> FontPlatformDataCache; | 71 typedef HashMap<FontCacheKey, OwnPtr<FontPlatformData>, FontCacheKeyHash, FontCa cheKeyTraits> FontPlatformDataCache; |
| 68 typedef HashMap<FallbackListCompositeKey, OwnPtr<ShapeCache>, FallbackListCompos iteKeyHash, FallbackListCompositeKeyTraits> FallbackListShaperCache; | 72 typedef HashMap<FallbackListCompositeKey, OwnPtr<ShapeCache>, FallbackListCompos iteKeyHash, FallbackListCompositeKeyTraits> FallbackListShaperCache; |
| 69 | 73 |
| 70 static FontPlatformDataCache* gFontPlatformDataCache = nullptr; | 74 static FontPlatformDataCache* gFontPlatformDataCache = nullptr; |
| 71 static FallbackListShaperCache* gFallbackListShaperCache = nullptr; | 75 static FallbackListShaperCache* gFallbackListShaperCache = nullptr; |
| 72 | 76 |
| 73 #if OS(WIN) | 77 #if OS(WIN) |
| 74 bool FontCache::s_useDirectWrite = false; | 78 bool FontCache::s_useDirectWrite = false; |
| 75 IDWriteFactory* FontCache::s_directWriteFactory = 0; | 79 SkFontMgr* FontCache::s_fontManager = nullptr; |
| 76 bool FontCache::s_useSubpixelPositioning = false; | 80 bool FontCache::s_useSubpixelPositioning = false; |
| 77 float FontCache::s_deviceScaleFactor = 1.0; | 81 float FontCache::s_deviceScaleFactor = 1.0; |
| 78 #endif // OS(WIN) | 82 #endif // OS(WIN) |
| 79 | 83 |
| 80 FontCache* FontCache::fontCache() | 84 FontCache* FontCache::fontCache() |
| 81 { | 85 { |
| 82 DEFINE_STATIC_LOCAL(FontCache, globalFontCache, ()); | 86 DEFINE_STATIC_LOCAL(FontCache, globalFontCache, ()); |
| 83 return &globalFontCache; | 87 return &globalFontCache; |
| 84 } | 88 } |
| 85 | 89 |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 139 } | 143 } |
| 140 | 144 |
| 141 typedef HashMap<FontCache::FontFileKey, RefPtr<OpenTypeVerticalData>, IntHash<Fo ntCache::FontFileKey>, UnsignedWithZeroKeyHashTraits<FontCache::FontFileKey>> Fo ntVerticalDataCache; | 145 typedef HashMap<FontCache::FontFileKey, RefPtr<OpenTypeVerticalData>, IntHash<Fo ntCache::FontFileKey>, UnsignedWithZeroKeyHashTraits<FontCache::FontFileKey>> Fo ntVerticalDataCache; |
| 142 | 146 |
| 143 FontVerticalDataCache& fontVerticalDataCacheInstance() | 147 FontVerticalDataCache& fontVerticalDataCacheInstance() |
| 144 { | 148 { |
| 145 DEFINE_STATIC_LOCAL(FontVerticalDataCache, fontVerticalDataCache, ()); | 149 DEFINE_STATIC_LOCAL(FontVerticalDataCache, fontVerticalDataCache, ()); |
| 146 return fontVerticalDataCache; | 150 return fontVerticalDataCache; |
| 147 } | 151 } |
| 148 | 152 |
| 153 #if OS(WIN) | |
| 154 void FontCache::setFontManager(SkFontMgr* fontManager) | |
| 155 { | |
| 156 s_fontManager = fontManager; | |
| 157 // Explicitly AddRef since we're going to hold on to the object for the life of the program. | |
| 158 s_fontManager->ref(); | |
| 159 } | |
| 160 #endif | |
| 161 | |
| 149 PassRefPtr<OpenTypeVerticalData> FontCache::getVerticalData(const FontFileKey& k ey, const FontPlatformData& platformData) | 162 PassRefPtr<OpenTypeVerticalData> FontCache::getVerticalData(const FontFileKey& k ey, const FontPlatformData& platformData) |
| 150 { | 163 { |
| 151 FontVerticalDataCache& fontVerticalDataCache = fontVerticalDataCacheInstance (); | 164 FontVerticalDataCache& fontVerticalDataCache = fontVerticalDataCacheInstance (); |
| 152 FontVerticalDataCache::iterator result = fontVerticalDataCache.find(key); | 165 FontVerticalDataCache::iterator result = fontVerticalDataCache.find(key); |
| 153 if (result != fontVerticalDataCache.end()) | 166 if (result != fontVerticalDataCache.end()) |
| 154 return result.get()->value; | 167 return result.get()->value; |
| 155 | 168 |
| 156 RefPtr<OpenTypeVerticalData> verticalData = OpenTypeVerticalData::create(pla tformData); | 169 RefPtr<OpenTypeVerticalData> verticalData = OpenTypeVerticalData::create(pla tformData); |
| 157 if (!verticalData->isOpenType()) | 170 if (!verticalData->isOpenType()) |
| 158 verticalData.clear(); | 171 verticalData.clear(); |
| (...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 357 iter != gFallbackListShaperCache->end(); | 370 iter != gFallbackListShaperCache->end(); |
| 358 ++iter) { | 371 ++iter) { |
| 359 shapeResultCacheSize += iter->value->byteSize(); | 372 shapeResultCacheSize += iter->value->byteSize(); |
| 360 } | 373 } |
| 361 dump->addScalar("size", "bytes", shapeResultCacheSize); | 374 dump->addScalar("size", "bytes", shapeResultCacheSize); |
| 362 memoryDump->addSuballocation(dump->guid(), String(WTF::Partitions::kAllocate dObjectPoolName)); | 375 memoryDump->addSuballocation(dump->guid(), String(WTF::Partitions::kAllocate dObjectPoolName)); |
| 363 } | 376 } |
| 364 | 377 |
| 365 | 378 |
| 366 } // namespace blink | 379 } // namespace blink |
| OLD | NEW |