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 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 FontFaceCreationParams createByAlternateFamily(alternateName); | 107 FontFaceCreationParams createByAlternateFamily(alternateName); |
108 result = getFontPlatformData(fontDescription, createByAlternateFamil
y, true); | 108 result = getFontPlatformData(fontDescription, createByAlternateFamil
y, true); |
109 } | 109 } |
110 if (result) | 110 if (result) |
111 gFontPlatformDataCache->set(key, adoptPtr(new FontPlatformData(*resu
lt))); // Cache the result under the old name. | 111 gFontPlatformDataCache->set(key, adoptPtr(new FontPlatformData(*resu
lt))); // Cache the result under the old name. |
112 } | 112 } |
113 | 113 |
114 return result; | 114 return result; |
115 } | 115 } |
116 | 116 |
117 typedef HashMap<FontCache::FontFileKey, RefPtr<OpenTypeVerticalData>, IntHash<Fo
ntCache::FontFileKey>, UnsignedWithZeroKeyHashTraits<FontCache::FontFileKey> > F
ontVerticalDataCache; | 117 typedef HashMap<FontCache::FontFileKey, RefPtr<OpenTypeVerticalData>, IntHash<Fo
ntCache::FontFileKey>, UnsignedWithZeroKeyHashTraits<FontCache::FontFileKey>> Fo
ntVerticalDataCache; |
118 | 118 |
119 FontVerticalDataCache& fontVerticalDataCacheInstance() | 119 FontVerticalDataCache& fontVerticalDataCacheInstance() |
120 { | 120 { |
121 DEFINE_STATIC_LOCAL(FontVerticalDataCache, fontVerticalDataCache, ()); | 121 DEFINE_STATIC_LOCAL(FontVerticalDataCache, fontVerticalDataCache, ()); |
122 return fontVerticalDataCache; | 122 return fontVerticalDataCache; |
123 } | 123 } |
124 | 124 |
125 PassRefPtr<OpenTypeVerticalData> FontCache::getVerticalData(const FontFileKey& k
ey, const FontPlatformData& platformData) | 125 PassRefPtr<OpenTypeVerticalData> FontCache::getVerticalData(const FontFileKey& k
ey, const FontPlatformData& platformData) |
126 { | 126 { |
127 FontVerticalDataCache& fontVerticalDataCache = fontVerticalDataCacheInstance
(); | 127 FontVerticalDataCache& fontVerticalDataCache = fontVerticalDataCacheInstance
(); |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
224 | 224 |
225 if (!gFontDataCache || !gFontDataCache->purge(PurgeSeverity)) | 225 if (!gFontDataCache || !gFontDataCache->purge(PurgeSeverity)) |
226 return; | 226 return; |
227 | 227 |
228 purgePlatformFontDataCache(); | 228 purgePlatformFontDataCache(); |
229 purgeFontVerticalDataCache(); | 229 purgeFontVerticalDataCache(); |
230 } | 230 } |
231 | 231 |
232 static bool invalidateFontCache = false; | 232 static bool invalidateFontCache = false; |
233 | 233 |
234 WillBeHeapHashSet<RawPtrWillBeWeakMember<FontCacheClient> >& fontCacheClients() | 234 WillBeHeapHashSet<RawPtrWillBeWeakMember<FontCacheClient>>& fontCacheClients() |
235 { | 235 { |
236 DEFINE_STATIC_LOCAL(OwnPtrWillBePersistent<WillBeHeapHashSet<RawPtrWillBeWea
kMember<FontCacheClient> > >, clients, (adoptPtrWillBeNoop(new WillBeHeapHashSet
<RawPtrWillBeWeakMember<FontCacheClient> >()))); | 236 DEFINE_STATIC_LOCAL(OwnPtrWillBePersistent<WillBeHeapHashSet<RawPtrWillBeWea
kMember<FontCacheClient>> >, clients, (adoptPtrWillBeNoop(new WillBeHeapHashSet<
RawPtrWillBeWeakMember<FontCacheClient>>()))); |
237 invalidateFontCache = true; | 237 invalidateFontCache = true; |
238 return *clients; | 238 return *clients; |
239 } | 239 } |
240 | 240 |
241 void FontCache::addClient(FontCacheClient* client) | 241 void FontCache::addClient(FontCacheClient* client) |
242 { | 242 { |
243 ASSERT(!fontCacheClients().contains(client)); | 243 ASSERT(!fontCacheClients().contains(client)); |
244 fontCacheClients().add(client); | 244 fontCacheClients().add(client); |
245 } | 245 } |
246 | 246 |
(...skipping 19 matching lines...) Expand all Loading... |
266 return; | 266 return; |
267 } | 267 } |
268 | 268 |
269 if (gFontPlatformDataCache) { | 269 if (gFontPlatformDataCache) { |
270 delete gFontPlatformDataCache; | 270 delete gFontPlatformDataCache; |
271 gFontPlatformDataCache = new FontPlatformDataCache; | 271 gFontPlatformDataCache = new FontPlatformDataCache; |
272 } | 272 } |
273 | 273 |
274 gGeneration++; | 274 gGeneration++; |
275 | 275 |
276 WillBeHeapVector<RefPtrWillBeMember<FontCacheClient> > clients; | 276 WillBeHeapVector<RefPtrWillBeMember<FontCacheClient>> clients; |
277 size_t numClients = fontCacheClients().size(); | 277 size_t numClients = fontCacheClients().size(); |
278 clients.reserveInitialCapacity(numClients); | 278 clients.reserveInitialCapacity(numClients); |
279 WillBeHeapHashSet<RawPtrWillBeWeakMember<FontCacheClient> >::iterator end =
fontCacheClients().end(); | 279 WillBeHeapHashSet<RawPtrWillBeWeakMember<FontCacheClient>>::iterator end = f
ontCacheClients().end(); |
280 for (WillBeHeapHashSet<RawPtrWillBeWeakMember<FontCacheClient> >::iterator i
t = fontCacheClients().begin(); it != end; ++it) | 280 for (WillBeHeapHashSet<RawPtrWillBeWeakMember<FontCacheClient>>::iterator it
= fontCacheClients().begin(); it != end; ++it) |
281 clients.append(*it); | 281 clients.append(*it); |
282 | 282 |
283 ASSERT(numClients == clients.size()); | 283 ASSERT(numClients == clients.size()); |
284 for (size_t i = 0; i < numClients; ++i) | 284 for (size_t i = 0; i < numClients; ++i) |
285 clients[i]->fontCacheInvalidated(); | 285 clients[i]->fontCacheInvalidated(); |
286 | 286 |
287 purge(ForcePurge); | 287 purge(ForcePurge); |
288 } | 288 } |
289 | 289 |
290 } // namespace blink | 290 } // namespace blink |
OLD | NEW |