| 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 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 if (RuntimeEnabledFeatures::fontCacheScalingEnabled()) | 140 if (RuntimeEnabledFeatures::fontCacheScalingEnabled()) |
| 141 key.clearFontSize(); | 141 key.clearFontSize(); |
| 142 | 142 |
| 143 FontPlatformData* result; | 143 FontPlatformData* result; |
| 144 bool foundResult; | 144 bool foundResult; |
| 145 | 145 |
| 146 { | 146 { |
| 147 // addResult's scope must end before we recurse for alternate family names | 147 // addResult's scope must end before we recurse for alternate family names |
| 148 // below, to avoid trigering its dtor hash-changed asserts. | 148 // below, to avoid trigering its dtor hash-changed asserts. |
| 149 SizedFontPlatformDataSet* sizedFonts = | 149 SizedFontPlatformDataSet* sizedFonts = |
| 150 &gFontPlatformDataCache->add(key, SizedFontPlatformDataSet()) | 150 &gFontPlatformDataCache->insert(key, SizedFontPlatformDataSet()) |
| 151 .storedValue->value; | 151 .storedValue->value; |
| 152 bool wasEmpty = sizedFonts->isEmpty(); | 152 bool wasEmpty = sizedFonts->isEmpty(); |
| 153 | 153 |
| 154 // Take a different size instance of the same font before adding an entry to | 154 // Take a different size instance of the same font before adding an entry to |
| 155 // |sizedFont|. | 155 // |sizedFont|. |
| 156 FontPlatformData* anotherSize = | 156 FontPlatformData* anotherSize = |
| 157 wasEmpty ? nullptr : sizedFonts->begin()->value.get(); | 157 wasEmpty ? nullptr : sizedFonts->begin()->value.get(); |
| 158 auto addResult = sizedFonts->add(roundedSize, nullptr); | 158 auto addResult = sizedFonts->insert(roundedSize, nullptr); |
| 159 std::unique_ptr<FontPlatformData>* found = &addResult.storedValue->value; | 159 std::unique_ptr<FontPlatformData>* found = &addResult.storedValue->value; |
| 160 if (addResult.isNewEntry) { | 160 if (addResult.isNewEntry) { |
| 161 if (wasEmpty) | 161 if (wasEmpty) |
| 162 *found = createFontPlatformData(fontDescription, creationParams, size); | 162 *found = createFontPlatformData(fontDescription, creationParams, size); |
| 163 else if (anotherSize) | 163 else if (anotherSize) |
| 164 *found = scaleFontPlatformData(*anotherSize, fontDescription, | 164 *found = scaleFontPlatformData(*anotherSize, fontDescription, |
| 165 creationParams, size); | 165 creationParams, size); |
| 166 } | 166 } |
| 167 | 167 |
| 168 result = found->get(); | 168 result = found->get(); |
| 169 foundResult = result || !addResult.isNewEntry; | 169 foundResult = result || !addResult.isNewEntry; |
| 170 } | 170 } |
| 171 | 171 |
| 172 if (!foundResult && !checkingAlternateName && | 172 if (!foundResult && !checkingAlternateName && |
| 173 creationParams.creationType() == CreateFontByFamily) { | 173 creationParams.creationType() == CreateFontByFamily) { |
| 174 // We were unable to find a font. We have a small set of fonts that we alias | 174 // We were unable to find a font. We have a small set of fonts that we alias |
| 175 // to other names, e.g., Arial/Helvetica, Courier/Courier New, etc. Try | 175 // to other names, e.g., Arial/Helvetica, Courier/Courier New, etc. Try |
| 176 // looking up the font under the aliased name. | 176 // looking up the font under the aliased name. |
| 177 const AtomicString& alternateName = | 177 const AtomicString& alternateName = |
| 178 alternateFamilyName(creationParams.family()); | 178 alternateFamilyName(creationParams.family()); |
| 179 if (!alternateName.isEmpty()) { | 179 if (!alternateName.isEmpty()) { |
| 180 FontFaceCreationParams createByAlternateFamily(alternateName); | 180 FontFaceCreationParams createByAlternateFamily(alternateName); |
| 181 result = | 181 result = |
| 182 getFontPlatformData(fontDescription, createByAlternateFamily, true); | 182 getFontPlatformData(fontDescription, createByAlternateFamily, true); |
| 183 } | 183 } |
| 184 if (result) { | 184 if (result) { |
| 185 // Cache the result under the old name. | 185 // Cache the result under the old name. |
| 186 auto adding = | 186 auto adding = |
| 187 &gFontPlatformDataCache->add(key, SizedFontPlatformDataSet()) | 187 &gFontPlatformDataCache->insert(key, SizedFontPlatformDataSet()) |
| 188 .storedValue->value; | 188 .storedValue->value; |
| 189 adding->set(roundedSize, WTF::wrapUnique(new FontPlatformData(*result))); | 189 adding->set(roundedSize, WTF::wrapUnique(new FontPlatformData(*result))); |
| 190 } | 190 } |
| 191 } | 191 } |
| 192 | 192 |
| 193 return result; | 193 return result; |
| 194 } | 194 } |
| 195 | 195 |
| 196 std::unique_ptr<FontPlatformData> FontCache::scaleFontPlatformData( | 196 std::unique_ptr<FontPlatformData> FontCache::scaleFontPlatformData( |
| 197 const FontPlatformData& fontPlatformData, | 197 const FontPlatformData& fontPlatformData, |
| (...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 482 for (iter = gFallbackListShaperCache->begin(); | 482 for (iter = gFallbackListShaperCache->begin(); |
| 483 iter != gFallbackListShaperCache->end(); ++iter) { | 483 iter != gFallbackListShaperCache->end(); ++iter) { |
| 484 shapeResultCacheSize += iter->value->byteSize(); | 484 shapeResultCacheSize += iter->value->byteSize(); |
| 485 } | 485 } |
| 486 dump->AddScalar("size", "bytes", shapeResultCacheSize); | 486 dump->AddScalar("size", "bytes", shapeResultCacheSize); |
| 487 memoryDump->AddSuballocation(dump->guid(), | 487 memoryDump->AddSuballocation(dump->guid(), |
| 488 WTF::Partitions::kAllocatedObjectPoolName); | 488 WTF::Partitions::kAllocatedObjectPoolName); |
| 489 } | 489 } |
| 490 | 490 |
| 491 } // namespace blink | 491 } // namespace blink |
| OLD | NEW |