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 #if !OS(MACOSX) |
| 102 FontPlatformData* FontCache::systemFontPlatformData( |
| 103 const FontDescription& fontDescription) { |
| 104 const AtomicString& family = FontCache::systemFontFamily(); |
| 105 #if OS(LINUX) |
| 106 if (family.isEmpty() || family == FontFamilyNames::system_ui) |
| 107 return nullptr; |
| 108 #else |
| 109 DCHECK(!family.isEmpty() && family != FontFamilyNames::system_ui); |
| 110 #endif |
| 111 return getFontPlatformData(fontDescription, FontFaceCreationParams(family), |
| 112 true); |
| 113 } |
| 114 #endif |
| 115 |
101 FontPlatformData* FontCache::getFontPlatformData( | 116 FontPlatformData* FontCache::getFontPlatformData( |
102 const FontDescription& fontDescription, | 117 const FontDescription& fontDescription, |
103 const FontFaceCreationParams& creationParams, | 118 const FontFaceCreationParams& creationParams, |
104 bool checkingAlternateName) { | 119 bool checkingAlternateName) { |
105 if (!gFontPlatformDataCache) { | 120 if (!gFontPlatformDataCache) { |
106 gFontPlatformDataCache = new FontPlatformDataCache; | 121 gFontPlatformDataCache = new FontPlatformDataCache; |
107 platformInit(); | 122 platformInit(); |
108 } | 123 } |
109 | 124 |
110 if (creationParams.creationType() == CreateFontByFamily) { | 125 #if !OS(MACOSX) |
111 #if OS(MACOSX) | 126 if (creationParams.creationType() == CreateFontByFamily && |
112 if (creationParams.family() == FontCache::legacySystemFontFamily()) { | 127 creationParams.family() == FontFamilyNames::system_ui) { |
113 return getFontPlatformData( | 128 return systemFontPlatformData(fontDescription); |
114 fontDescription, FontFaceCreationParams(FontFamilyNames::system_ui), | 129 } |
115 true); | |
116 } | |
117 #else | |
118 if (creationParams.family() == FontFamilyNames::system_ui) { | |
119 const AtomicString& actualFamily = FontCache::systemFontFamily(); | |
120 #if OS(LINUX) | |
121 if (actualFamily.isEmpty() || actualFamily == FontFamilyNames::system_ui) | |
122 return nullptr; | |
123 #else | |
124 DCHECK(!actualFamily.isEmpty() && | |
125 actualFamily != FontFamilyNames::system_ui); | |
126 #endif | 130 #endif |
127 return getFontPlatformData(fontDescription, | |
128 FontFaceCreationParams(actualFamily), true); | |
129 } | |
130 #endif | |
131 } | |
132 | 131 |
133 float size = fontDescription.effectiveFontSize(); | 132 float size = fontDescription.effectiveFontSize(); |
134 unsigned roundedSize = size * FontCacheKey::precisionMultiplier(); | 133 unsigned roundedSize = size * FontCacheKey::precisionMultiplier(); |
135 FontCacheKey key = fontDescription.cacheKey(creationParams); | 134 FontCacheKey key = fontDescription.cacheKey(creationParams); |
136 | 135 |
137 // Remove the font size from the cache key, and handle the font size | 136 // Remove the font size from the cache key, and handle the font size |
138 // separately in the inner HashMap. So that different size of FontPlatformData | 137 // separately in the inner HashMap. So that different size of FontPlatformData |
139 // can share underlying SkTypeface. | 138 // can share underlying SkTypeface. |
140 if (RuntimeEnabledFeatures::fontCacheScalingEnabled()) | 139 if (RuntimeEnabledFeatures::fontCacheScalingEnabled()) |
141 key.clearFontSize(); | 140 key.clearFontSize(); |
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
475 for (iter = gFallbackListShaperCache->begin(); | 474 for (iter = gFallbackListShaperCache->begin(); |
476 iter != gFallbackListShaperCache->end(); ++iter) { | 475 iter != gFallbackListShaperCache->end(); ++iter) { |
477 shapeResultCacheSize += iter->value->byteSize(); | 476 shapeResultCacheSize += iter->value->byteSize(); |
478 } | 477 } |
479 dump->AddScalar("size", "bytes", shapeResultCacheSize); | 478 dump->AddScalar("size", "bytes", shapeResultCacheSize); |
480 memoryDump->AddSuballocation(dump->guid(), | 479 memoryDump->AddSuballocation(dump->guid(), |
481 WTF::Partitions::kAllocatedObjectPoolName); | 480 WTF::Partitions::kAllocatedObjectPoolName); |
482 } | 481 } |
483 | 482 |
484 } // namespace blink | 483 } // namespace blink |
OLD | NEW |