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 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 bool FontCache::s_lcdTextEnabled = false; | 91 bool FontCache::s_lcdTextEnabled = false; |
92 float FontCache::s_deviceScaleFactor = 1.0; | 92 float FontCache::s_deviceScaleFactor = 1.0; |
93 bool FontCache::s_useSkiaFontFallback = false; | 93 bool FontCache::s_useSkiaFontFallback = false; |
94 #endif // OS(WIN) | 94 #endif // OS(WIN) |
95 | 95 |
96 FontCache* FontCache::fontCache() { | 96 FontCache* FontCache::fontCache() { |
97 DEFINE_STATIC_LOCAL(FontCache, globalFontCache, ()); | 97 DEFINE_STATIC_LOCAL(FontCache, globalFontCache, ()); |
98 return &globalFontCache; | 98 return &globalFontCache; |
99 } | 99 } |
100 | 100 |
| 101 static bool isSystemFontFamily(const FontFaceCreationParams& creationParams) { |
| 102 #if OS(MACOSX) |
| 103 return creationParams.creationType() == CreateFontByFamily && |
| 104 (creationParams.family() == FontFamilyNames::system_ui || |
| 105 creationParams.family() == FontCache::legacySystemFontFamily()); |
| 106 #else |
| 107 return creationParams.creationType() == CreateFontByFamily && |
| 108 creationParams.family() == FontFamilyNames::system_ui; |
| 109 #endif |
| 110 } |
| 111 |
101 FontPlatformData* FontCache::getFontPlatformData( | 112 FontPlatformData* FontCache::getFontPlatformData( |
102 const FontDescription& fontDescription, | 113 const FontDescription& fontDescription, |
103 const FontFaceCreationParams& creationParams, | 114 const FontFaceCreationParams& originalCreationParams, |
104 bool checkingAlternateName) { | 115 bool checkingAlternateName) { |
105 if (!gFontPlatformDataCache) { | 116 if (!gFontPlatformDataCache) { |
106 gFontPlatformDataCache = new FontPlatformDataCache; | 117 gFontPlatformDataCache = new FontPlatformDataCache; |
107 platformInit(); | 118 platformInit(); |
108 } | 119 } |
109 | 120 |
110 float size = fontDescription.effectiveFontSize(); | 121 float size = fontDescription.effectiveFontSize(); |
| 122 const FontFaceCreationParams& creationParams = |
| 123 isSystemFontFamily(originalCreationParams) |
| 124 ? FontFaceCreationParams(systemFontFamily(size)) |
| 125 : originalCreationParams; |
111 unsigned roundedSize = size * FontCacheKey::precisionMultiplier(); | 126 unsigned roundedSize = size * FontCacheKey::precisionMultiplier(); |
112 FontCacheKey key = fontDescription.cacheKey(creationParams); | 127 FontCacheKey key = fontDescription.cacheKey(creationParams); |
113 | 128 |
114 // Remove the font size from the cache key, and handle the font size | 129 // Remove the font size from the cache key, and handle the font size |
115 // separately in the inner HashMap. So that different size of FontPlatformData | 130 // separately in the inner HashMap. So that different size of FontPlatformData |
116 // can share underlying SkTypeface. | 131 // can share underlying SkTypeface. |
117 if (RuntimeEnabledFeatures::fontCacheScalingEnabled()) | 132 if (RuntimeEnabledFeatures::fontCacheScalingEnabled()) |
118 key.clearFontSize(); | 133 key.clearFontSize(); |
119 | 134 |
120 FontPlatformData* result; | 135 FontPlatformData* result; |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
264 #if ENABLE(ASSERT) | 279 #if ENABLE(ASSERT) |
265 if (shouldRetain == DoNotRetain) | 280 if (shouldRetain == DoNotRetain) |
266 ASSERT(m_purgePreventCount); | 281 ASSERT(m_purgePreventCount); |
267 #endif | 282 #endif |
268 | 283 |
269 return gFontDataCache->get(platformData, shouldRetain); | 284 return gFontDataCache->get(platformData, shouldRetain); |
270 } | 285 } |
271 | 286 |
272 bool FontCache::isPlatformFontAvailable(const FontDescription& fontDescription, | 287 bool FontCache::isPlatformFontAvailable(const FontDescription& fontDescription, |
273 const AtomicString& family) { | 288 const AtomicString& family) { |
| 289 if (family == FontFamilyNames::system_ui) |
| 290 return true; |
| 291 #if OS(MACOSX) |
| 292 if (family == FontCache::legacySystemFontFamily()) |
| 293 return true; |
| 294 #endif |
274 bool checkingAlternateName = true; | 295 bool checkingAlternateName = true; |
275 return getFontPlatformData( | 296 return getFontPlatformData( |
276 fontDescription, | 297 fontDescription, |
277 FontFaceCreationParams(adjustFamilyNameToAvoidUnsupportedFonts(family)), | 298 FontFaceCreationParams(adjustFamilyNameToAvoidUnsupportedFonts(family)), |
278 checkingAlternateName); | 299 checkingAlternateName); |
279 } | 300 } |
280 | 301 |
281 SimpleFontData* FontCache::getNonRetainedLastResortFallbackFont( | 302 SimpleFontData* FontCache::getNonRetainedLastResortFallbackFont( |
282 const FontDescription& fontDescription) { | 303 const FontDescription& fontDescription) { |
283 return getLastResortFallbackFont(fontDescription, DoNotRetain).leakRef(); | 304 return getLastResortFallbackFont(fontDescription, DoNotRetain).leakRef(); |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
449 for (iter = gFallbackListShaperCache->begin(); | 470 for (iter = gFallbackListShaperCache->begin(); |
450 iter != gFallbackListShaperCache->end(); ++iter) { | 471 iter != gFallbackListShaperCache->end(); ++iter) { |
451 shapeResultCacheSize += iter->value->byteSize(); | 472 shapeResultCacheSize += iter->value->byteSize(); |
452 } | 473 } |
453 dump->AddScalar("size", "bytes", shapeResultCacheSize); | 474 dump->AddScalar("size", "bytes", shapeResultCacheSize); |
454 memoryDump->AddSuballocation(dump->guid(), | 475 memoryDump->AddSuballocation(dump->guid(), |
455 WTF::Partitions::kAllocatedObjectPoolName); | 476 WTF::Partitions::kAllocatedObjectPoolName); |
456 } | 477 } |
457 | 478 |
458 } // namespace blink | 479 } // namespace blink |
OLD | NEW |