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 bool invalidateFontCache = false; | 246 static HashSet<FontCacheClient*>* gClients; |
247 | |
248 WillBeHeapHashSet<RawPtrWillBeWeakMember<FontCacheClient> >& fontCacheClients() | |
249 { | |
250 #if ENABLE(OILPAN) | |
251 DEFINE_STATIC_LOCAL(Persistent<HeapHashSet<WeakMember<FontCacheClient> > >,
clients, (new HeapHashSet<WeakMember<FontCacheClient> >())); | |
252 #else | |
253 DEFINE_STATIC_LOCAL(HashSet<RawPtr<FontCacheClient> >*, clients, (new HashSe
t<RawPtr<FontCacheClient> >())); | |
254 #endif | |
255 invalidateFontCache = true; | |
256 return *clients; | |
257 } | |
258 | 247 |
259 void FontCache::addClient(FontCacheClient* client) | 248 void FontCache::addClient(FontCacheClient* client) |
260 { | 249 { |
261 ASSERT(!fontCacheClients().contains(client)); | 250 if (!gClients) |
262 fontCacheClients().add(client); | 251 gClients = new HashSet<FontCacheClient*>; |
| 252 |
| 253 ASSERT(!gClients->contains(client)); |
| 254 gClients->add(client); |
263 } | 255 } |
264 | 256 |
265 #if !ENABLE(OILPAN) | |
266 void FontCache::removeClient(FontCacheClient* client) | 257 void FontCache::removeClient(FontCacheClient* client) |
267 { | 258 { |
268 ASSERT(fontCacheClients().contains(client)); | 259 ASSERT(gClients); |
269 fontCacheClients().remove(client); | 260 ASSERT(gClients->contains(client)); |
| 261 |
| 262 gClients->remove(client); |
270 } | 263 } |
271 #endif | |
272 | 264 |
273 static unsigned short gGeneration = 0; | 265 static unsigned short gGeneration = 0; |
274 | 266 |
275 unsigned short FontCache::generation() | 267 unsigned short FontCache::generation() |
276 { | 268 { |
277 return gGeneration; | 269 return gGeneration; |
278 } | 270 } |
279 | 271 |
280 void FontCache::invalidate() | 272 void FontCache::invalidate() |
281 { | 273 { |
282 if (!invalidateFontCache) { | 274 if (!gClients) { |
283 ASSERT(!gFontPlatformDataCache); | 275 ASSERT(!gFontPlatformDataCache); |
284 return; | 276 return; |
285 } | 277 } |
286 | 278 |
287 if (gFontPlatformDataCache) { | 279 if (gFontPlatformDataCache) { |
288 delete gFontPlatformDataCache; | 280 delete gFontPlatformDataCache; |
289 gFontPlatformDataCache = new FontPlatformDataCache; | 281 gFontPlatformDataCache = new FontPlatformDataCache; |
290 } | 282 } |
291 | 283 |
292 gGeneration++; | 284 gGeneration++; |
293 | 285 |
294 WillBeHeapVector<RefPtrWillBeMember<FontCacheClient> > clients; | 286 Vector<RefPtr<FontCacheClient> > clients; |
295 size_t numClients = fontCacheClients().size(); | 287 size_t numClients = gClients->size(); |
296 clients.reserveInitialCapacity(numClients); | 288 clients.reserveInitialCapacity(numClients); |
297 WillBeHeapHashSet<RawPtrWillBeWeakMember<FontCacheClient> >::iterator end =
fontCacheClients().end(); | 289 HashSet<FontCacheClient*>::iterator end = gClients->end(); |
298 for (WillBeHeapHashSet<RawPtrWillBeWeakMember<FontCacheClient> >::iterator i
t = fontCacheClients().begin(); it != end; ++it) | 290 for (HashSet<FontCacheClient*>::iterator it = gClients->begin(); it != end;
++it) |
299 clients.append(*it); | 291 clients.append(*it); |
300 | 292 |
301 ASSERT(numClients == clients.size()); | 293 ASSERT(numClients == clients.size()); |
302 for (size_t i = 0; i < numClients; ++i) | 294 for (size_t i = 0; i < numClients; ++i) |
303 clients[i]->fontCacheInvalidated(); | 295 clients[i]->fontCacheInvalidated(); |
304 | 296 |
305 purge(ForcePurge); | 297 purge(ForcePurge); |
306 } | 298 } |
307 | 299 |
308 } // namespace WebCore | 300 } // namespace WebCore |
OLD | NEW |