Chromium Code Reviews| 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 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 236 if (m_purgePreventCount) | 236 if (m_purgePreventCount) |
| 237 return; | 237 return; |
| 238 | 238 |
| 239 if (!gFontDataCache || !gFontDataCache->purge(PurgeSeverity)) | 239 if (!gFontDataCache || !gFontDataCache->purge(PurgeSeverity)) |
| 240 return; | 240 return; |
| 241 | 241 |
| 242 purgePlatformFontDataCache(); | 242 purgePlatformFontDataCache(); |
| 243 purgeFontVerticalDataCache(); | 243 purgeFontVerticalDataCache(); |
| 244 } | 244 } |
| 245 | 245 |
| 246 static HashSet<FontCacheClient*>* gClients; | 246 static bool invalidateFontCache = false; |
|
haraken
2014/04/07 14:10:12
invalidateFontCache => fontCacheMapIsInitialized ?
wibling-chromium
2014/04/08 09:35:59
It guards whether we need to invalidate the cache,
| |
| 247 | |
| 248 WillBeHeapHashSet<RawPtrWillBeMember<FontCacheClient> >& fontCacheClients() | |
| 249 { | |
| 250 #if ENABLE(OILPAN) | |
| 251 DEFINE_STATIC_LOCAL(Persistent<HeapHashSet<Member<FontCacheClient> > >, clie nts, (new HeapHashSet<Member<FontCacheClient> >())); | |
|
haraken
2014/04/07 14:10:12
Shouldn't this be a hash set of weak members? I gu
wibling-chromium
2014/04/08 09:35:59
It is not strictly needed since removeClient is al
| |
| 252 #else | |
| 253 DEFINE_STATIC_LOCAL(HashSet<RawPtr<FontCacheClient> >*, clients, (new HashSe t<RawPtr<FontCacheClient> >())); | |
| 254 #endif | |
| 255 invalidateFontCache = true; | |
| 256 return *clients; | |
| 257 } | |
| 247 | 258 |
| 248 void FontCache::addClient(FontCacheClient* client) | 259 void FontCache::addClient(FontCacheClient* client) |
| 249 { | 260 { |
| 250 if (!gClients) | 261 ASSERT(!fontCacheClients().contains(client)); |
| 251 gClients = new HashSet<FontCacheClient*>; | 262 fontCacheClients().add(client); |
| 252 | |
| 253 ASSERT(!gClients->contains(client)); | |
| 254 gClients->add(client); | |
| 255 } | 263 } |
| 256 | 264 |
| 257 void FontCache::removeClient(FontCacheClient* client) | 265 void FontCache::removeClient(FontCacheClient* client) |
|
haraken
2014/04/07 14:10:12
If the FontCacheClients are weak, this method shou
wibling-chromium
2014/04/08 09:35:59
Done.
| |
| 258 { | 266 { |
| 259 ASSERT(gClients); | 267 ASSERT(fontCacheClients().contains(client)); |
| 260 ASSERT(gClients->contains(client)); | 268 fontCacheClients().remove(client); |
| 261 | |
| 262 gClients->remove(client); | |
| 263 } | 269 } |
| 264 | 270 |
| 265 static unsigned short gGeneration = 0; | 271 static unsigned short gGeneration = 0; |
| 266 | 272 |
| 267 unsigned short FontCache::generation() | 273 unsigned short FontCache::generation() |
| 268 { | 274 { |
| 269 return gGeneration; | 275 return gGeneration; |
| 270 } | 276 } |
| 271 | 277 |
| 272 void FontCache::invalidate() | 278 void FontCache::invalidate() |
| 273 { | 279 { |
| 274 if (!gClients) { | 280 if (!invalidateFontCache) { |
| 275 ASSERT(!gFontPlatformDataCache); | 281 ASSERT(!gFontPlatformDataCache); |
| 276 return; | 282 return; |
| 277 } | 283 } |
| 278 | 284 |
| 279 if (gFontPlatformDataCache) { | 285 if (gFontPlatformDataCache) { |
| 280 delete gFontPlatformDataCache; | 286 delete gFontPlatformDataCache; |
| 281 gFontPlatformDataCache = new FontPlatformDataCache; | 287 gFontPlatformDataCache = new FontPlatformDataCache; |
| 282 } | 288 } |
| 283 | 289 |
| 284 gGeneration++; | 290 gGeneration++; |
| 285 | 291 |
| 286 Vector<RefPtr<FontCacheClient> > clients; | 292 WillBeHeapVector<RefPtrWillBeMember<FontCacheClient> > clients; |
| 287 size_t numClients = gClients->size(); | 293 size_t numClients = fontCacheClients().size(); |
| 288 clients.reserveInitialCapacity(numClients); | 294 clients.reserveInitialCapacity(numClients); |
| 289 HashSet<FontCacheClient*>::iterator end = gClients->end(); | 295 WillBeHeapHashSet<RawPtrWillBeMember<FontCacheClient> >::iterator end = font CacheClients().end(); |
| 290 for (HashSet<FontCacheClient*>::iterator it = gClients->begin(); it != end; ++it) | 296 for (WillBeHeapHashSet<RawPtrWillBeMember<FontCacheClient> >::iterator it = fontCacheClients().begin(); it != end; ++it) |
| 291 clients.append(*it); | 297 clients.append(*it); |
| 292 | 298 |
| 293 ASSERT(numClients == clients.size()); | 299 ASSERT(numClients == clients.size()); |
| 294 for (size_t i = 0; i < numClients; ++i) | 300 for (size_t i = 0; i < numClients; ++i) |
| 295 clients[i]->fontCacheInvalidated(); | 301 clients[i]->fontCacheInvalidated(); |
| 296 | 302 |
| 297 purge(ForcePurge); | 303 purge(ForcePurge); |
| 298 } | 304 } |
| 299 | 305 |
| 300 } // namespace WebCore | 306 } // namespace WebCore |
| OLD | NEW |