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) |
| 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 IDWriteFactory* FontCache::s_directWriteFactory = 0; |
| 80 SkFontMgr* FontCache::s_fontManager = nullptr; |
76 bool FontCache::s_useSubpixelPositioning = false; | 81 bool FontCache::s_useSubpixelPositioning = false; |
77 float FontCache::s_deviceScaleFactor = 1.0; | 82 float FontCache::s_deviceScaleFactor = 1.0; |
78 #endif // OS(WIN) | 83 #endif // OS(WIN) |
79 | 84 |
80 FontCache* FontCache::fontCache() | 85 FontCache* FontCache::fontCache() |
81 { | 86 { |
82 DEFINE_STATIC_LOCAL(FontCache, globalFontCache, ()); | 87 DEFINE_STATIC_LOCAL(FontCache, globalFontCache, ()); |
83 return &globalFontCache; | 88 return &globalFontCache; |
84 } | 89 } |
85 | 90 |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
139 } | 144 } |
140 | 145 |
141 typedef HashMap<FontCache::FontFileKey, RefPtr<OpenTypeVerticalData>, IntHash<Fo
ntCache::FontFileKey>, UnsignedWithZeroKeyHashTraits<FontCache::FontFileKey>> Fo
ntVerticalDataCache; | 146 typedef HashMap<FontCache::FontFileKey, RefPtr<OpenTypeVerticalData>, IntHash<Fo
ntCache::FontFileKey>, UnsignedWithZeroKeyHashTraits<FontCache::FontFileKey>> Fo
ntVerticalDataCache; |
142 | 147 |
143 FontVerticalDataCache& fontVerticalDataCacheInstance() | 148 FontVerticalDataCache& fontVerticalDataCacheInstance() |
144 { | 149 { |
145 DEFINE_STATIC_LOCAL(FontVerticalDataCache, fontVerticalDataCache, ()); | 150 DEFINE_STATIC_LOCAL(FontVerticalDataCache, fontVerticalDataCache, ()); |
146 return fontVerticalDataCache; | 151 return fontVerticalDataCache; |
147 } | 152 } |
148 | 153 |
| 154 #if OS(WIN) |
| 155 void FontCache::setDirectWriteFactory(IDWriteFactory* factory) |
| 156 { |
| 157 s_directWriteFactory = factory; |
| 158 // Explicitly AddRef since we're going to hold on to the object for the life
of the program. |
| 159 s_directWriteFactory->AddRef(); |
| 160 } |
| 161 |
| 162 void FontCache::setFontManager(const skia::RefPtr<SkFontMgr>& fontManager) |
| 163 { |
| 164 s_fontManager = fontManager.get(); |
| 165 // Explicitly AddRef since we're going to hold on to the object for the life
of the program. |
| 166 s_fontManager->ref(); |
| 167 } |
| 168 #endif |
| 169 |
149 PassRefPtr<OpenTypeVerticalData> FontCache::getVerticalData(const FontFileKey& k
ey, const FontPlatformData& platformData) | 170 PassRefPtr<OpenTypeVerticalData> FontCache::getVerticalData(const FontFileKey& k
ey, const FontPlatformData& platformData) |
150 { | 171 { |
151 FontVerticalDataCache& fontVerticalDataCache = fontVerticalDataCacheInstance
(); | 172 FontVerticalDataCache& fontVerticalDataCache = fontVerticalDataCacheInstance
(); |
152 FontVerticalDataCache::iterator result = fontVerticalDataCache.find(key); | 173 FontVerticalDataCache::iterator result = fontVerticalDataCache.find(key); |
153 if (result != fontVerticalDataCache.end()) | 174 if (result != fontVerticalDataCache.end()) |
154 return result.get()->value; | 175 return result.get()->value; |
155 | 176 |
156 RefPtr<OpenTypeVerticalData> verticalData = OpenTypeVerticalData::create(pla
tformData); | 177 RefPtr<OpenTypeVerticalData> verticalData = OpenTypeVerticalData::create(pla
tformData); |
157 if (!verticalData->isOpenType()) | 178 if (!verticalData->isOpenType()) |
158 verticalData.clear(); | 179 verticalData.clear(); |
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
357 iter != gFallbackListShaperCache->end(); | 378 iter != gFallbackListShaperCache->end(); |
358 ++iter) { | 379 ++iter) { |
359 shapeResultCacheSize += iter->value->byteSize(); | 380 shapeResultCacheSize += iter->value->byteSize(); |
360 } | 381 } |
361 dump->addScalar("size", "bytes", shapeResultCacheSize); | 382 dump->addScalar("size", "bytes", shapeResultCacheSize); |
362 memoryDump->addSuballocation(dump->guid(), String(WTF::Partitions::kAllocate
dObjectPoolName)); | 383 memoryDump->addSuballocation(dump->guid(), String(WTF::Partitions::kAllocate
dObjectPoolName)); |
363 } | 384 } |
364 | 385 |
365 | 386 |
366 } // namespace blink | 387 } // namespace blink |
OLD | NEW |