Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(480)

Side by Side Diff: third_party/WebKit/Source/platform/fonts/FontCache.cpp

Issue 1682813004: Revert of Add plumbing in blink to allow overriding the default font collection. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 #endif // !OS(WIN) 65 #endif // !OS(WIN)
66 66
67 typedef HashMap<FontCacheKey, OwnPtr<FontPlatformData>, FontCacheKeyHash, FontCa cheKeyTraits> FontPlatformDataCache; 67 typedef HashMap<FontCacheKey, OwnPtr<FontPlatformData>, FontCacheKeyHash, FontCa cheKeyTraits> FontPlatformDataCache;
68 typedef HashMap<FallbackListCompositeKey, OwnPtr<ShapeCache>, FallbackListCompos iteKeyHash, FallbackListCompositeKeyTraits> FallbackListShaperCache; 68 typedef HashMap<FallbackListCompositeKey, OwnPtr<ShapeCache>, FallbackListCompos iteKeyHash, FallbackListCompositeKeyTraits> FallbackListShaperCache;
69 69
70 static FontPlatformDataCache* gFontPlatformDataCache = nullptr; 70 static FontPlatformDataCache* gFontPlatformDataCache = nullptr;
71 static FallbackListShaperCache* gFallbackListShaperCache = nullptr; 71 static FallbackListShaperCache* gFallbackListShaperCache = nullptr;
72 72
73 #if OS(WIN) 73 #if OS(WIN)
74 bool FontCache::s_useDirectWrite = false; 74 bool FontCache::s_useDirectWrite = false;
75 SkFontMgr* FontCache::s_fontManager = nullptr; 75 IDWriteFactory* FontCache::s_directWriteFactory = 0;
76 bool FontCache::s_useSubpixelPositioning = false; 76 bool FontCache::s_useSubpixelPositioning = false;
77 float FontCache::s_deviceScaleFactor = 1.0; 77 float FontCache::s_deviceScaleFactor = 1.0;
78 #endif // OS(WIN) 78 #endif // OS(WIN)
79 79
80 FontCache* FontCache::fontCache() 80 FontCache* FontCache::fontCache()
81 { 81 {
82 DEFINE_STATIC_LOCAL(FontCache, globalFontCache, ()); 82 DEFINE_STATIC_LOCAL(FontCache, globalFontCache, ());
83 return &globalFontCache; 83 return &globalFontCache;
84 } 84 }
85 85
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 } 139 }
140 140
141 typedef HashMap<FontCache::FontFileKey, RefPtr<OpenTypeVerticalData>, IntHash<Fo ntCache::FontFileKey>, UnsignedWithZeroKeyHashTraits<FontCache::FontFileKey>> Fo ntVerticalDataCache; 141 typedef HashMap<FontCache::FontFileKey, RefPtr<OpenTypeVerticalData>, IntHash<Fo ntCache::FontFileKey>, UnsignedWithZeroKeyHashTraits<FontCache::FontFileKey>> Fo ntVerticalDataCache;
142 142
143 FontVerticalDataCache& fontVerticalDataCacheInstance() 143 FontVerticalDataCache& fontVerticalDataCacheInstance()
144 { 144 {
145 DEFINE_STATIC_LOCAL(FontVerticalDataCache, fontVerticalDataCache, ()); 145 DEFINE_STATIC_LOCAL(FontVerticalDataCache, fontVerticalDataCache, ());
146 return fontVerticalDataCache; 146 return fontVerticalDataCache;
147 } 147 }
148 148
149 #if OS(WIN)
150 void FontCache::setFontManager(const RefPtr<SkFontMgr>& fontManager)
151 {
152 ASSERT(!s_fontManager);
153 s_fontManager = fontManager.get();
154 // Explicitly AddRef since we're going to hold on to the object for the life of the program.
155 s_fontManager->ref();
156 }
157 #endif
158
159 PassRefPtr<OpenTypeVerticalData> FontCache::getVerticalData(const FontFileKey& k ey, const FontPlatformData& platformData) 149 PassRefPtr<OpenTypeVerticalData> FontCache::getVerticalData(const FontFileKey& k ey, const FontPlatformData& platformData)
160 { 150 {
161 FontVerticalDataCache& fontVerticalDataCache = fontVerticalDataCacheInstance (); 151 FontVerticalDataCache& fontVerticalDataCache = fontVerticalDataCacheInstance ();
162 FontVerticalDataCache::iterator result = fontVerticalDataCache.find(key); 152 FontVerticalDataCache::iterator result = fontVerticalDataCache.find(key);
163 if (result != fontVerticalDataCache.end()) 153 if (result != fontVerticalDataCache.end())
164 return result.get()->value; 154 return result.get()->value;
165 155
166 RefPtr<OpenTypeVerticalData> verticalData = OpenTypeVerticalData::create(pla tformData); 156 RefPtr<OpenTypeVerticalData> verticalData = OpenTypeVerticalData::create(pla tformData);
167 if (!verticalData->isOpenType()) 157 if (!verticalData->isOpenType())
168 verticalData.clear(); 158 verticalData.clear();
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
367 iter != gFallbackListShaperCache->end(); 357 iter != gFallbackListShaperCache->end();
368 ++iter) { 358 ++iter) {
369 shapeResultCacheSize += iter->value->byteSize(); 359 shapeResultCacheSize += iter->value->byteSize();
370 } 360 }
371 dump->addScalar("size", "bytes", shapeResultCacheSize); 361 dump->addScalar("size", "bytes", shapeResultCacheSize);
372 memoryDump->addSuballocation(dump->guid(), String(WTF::Partitions::kAllocate dObjectPoolName)); 362 memoryDump->addSuballocation(dump->guid(), String(WTF::Partitions::kAllocate dObjectPoolName));
373 } 363 }
374 364
375 365
376 } // namespace blink 366 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698