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

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

Issue 1685053002: blink fonts: Load Android SkFontMgr on Linux. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@windows_change
Patch Set: Rebase. Created 4 years, 9 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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
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)
bungeman-chromium 2016/02/29 22:48:50 nit: indentation here is odd
Khushal 2016/03/01 18:52:43 Done.
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 SkFontMgr* FontCache::s_fontManager = nullptr;
78 bool FontCache::s_useSubpixelPositioning = false; 80 bool FontCache::s_useSubpixelPositioning = false;
79 float FontCache::s_deviceScaleFactor = 1.0; 81 float FontCache::s_deviceScaleFactor = 1.0;
80 #endif // OS(WIN) 82 #endif // OS(WIN)
81 83
82 FontCache* FontCache::fontCache() 84 FontCache* FontCache::fontCache()
83 { 85 {
84 DEFINE_STATIC_LOCAL(FontCache, globalFontCache, ()); 86 DEFINE_STATIC_LOCAL(FontCache, globalFontCache, ());
85 return &globalFontCache; 87 return &globalFontCache;
86 } 88 }
87 89
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 } 143 }
142 144
143 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;
144 146
145 FontVerticalDataCache& fontVerticalDataCacheInstance() 147 FontVerticalDataCache& fontVerticalDataCacheInstance()
146 { 148 {
147 DEFINE_STATIC_LOCAL(FontVerticalDataCache, fontVerticalDataCache, ()); 149 DEFINE_STATIC_LOCAL(FontVerticalDataCache, fontVerticalDataCache, ());
148 return fontVerticalDataCache; 150 return fontVerticalDataCache;
149 } 151 }
150 152
151 #if OS(WIN)
152 void FontCache::setFontManager(const RefPtr<SkFontMgr>& fontManager) 153 void FontCache::setFontManager(const RefPtr<SkFontMgr>& fontManager)
153 { 154 {
154 ASSERT(!s_fontManager); 155 ASSERT(!s_fontManager);
155 s_fontManager = fontManager.get(); 156 s_fontManager = fontManager.get();
156 // Explicitly AddRef since we're going to hold on to the object for the life of the program. 157 // Explicitly AddRef since we're going to hold on to the object for the life of the program.
157 s_fontManager->ref(); 158 s_fontManager->ref();
158 } 159 }
159 #endif
160 160
161 PassRefPtr<OpenTypeVerticalData> FontCache::getVerticalData(const FontFileKey& k ey, const FontPlatformData& platformData) 161 PassRefPtr<OpenTypeVerticalData> FontCache::getVerticalData(const FontFileKey& k ey, const FontPlatformData& platformData)
162 { 162 {
163 FontVerticalDataCache& fontVerticalDataCache = fontVerticalDataCacheInstance (); 163 FontVerticalDataCache& fontVerticalDataCache = fontVerticalDataCacheInstance ();
164 FontVerticalDataCache::iterator result = fontVerticalDataCache.find(key); 164 FontVerticalDataCache::iterator result = fontVerticalDataCache.find(key);
165 if (result != fontVerticalDataCache.end()) 165 if (result != fontVerticalDataCache.end())
166 return result.get()->value; 166 return result.get()->value;
167 167
168 RefPtr<OpenTypeVerticalData> verticalData = OpenTypeVerticalData::create(pla tformData); 168 RefPtr<OpenTypeVerticalData> verticalData = OpenTypeVerticalData::create(pla tformData);
169 if (!verticalData->isOpenType()) 169 if (!verticalData->isOpenType())
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after
410 iter != gFallbackListShaperCache->end(); 410 iter != gFallbackListShaperCache->end();
411 ++iter) { 411 ++iter) {
412 shapeResultCacheSize += iter->value->byteSize(); 412 shapeResultCacheSize += iter->value->byteSize();
413 } 413 }
414 dump->addScalar("size", "bytes", shapeResultCacheSize); 414 dump->addScalar("size", "bytes", shapeResultCacheSize);
415 memoryDump->addSuballocation(dump->guid(), String(WTF::Partitions::kAllocate dObjectPoolName)); 415 memoryDump->addSuballocation(dump->guid(), String(WTF::Partitions::kAllocate dObjectPoolName));
416 } 416 }
417 417
418 418
419 } // namespace blink 419 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698