Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1173)

Side by Side Diff: Source/platform/fonts/FontCache.cpp

Issue 140913011: Trim FontSelector interface a bit. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 16 matching lines...) Expand all
27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 */ 28 */
29 29
30 #include "config.h" 30 #include "config.h"
31 #include "platform/fonts/FontCache.h" 31 #include "platform/fonts/FontCache.h"
32 32
33 #include "FontFamilyNames.h" 33 #include "FontFamilyNames.h"
34 34
35 #include "RuntimeEnabledFeatures.h" 35 #include "RuntimeEnabledFeatures.h"
36 #include "platform/fonts/AlternateFontFamily.h" 36 #include "platform/fonts/AlternateFontFamily.h"
37 #include "platform/fonts/FontCacheClient.h"
37 #include "platform/fonts/FontCacheKey.h" 38 #include "platform/fonts/FontCacheKey.h"
38 #include "platform/fonts/FontDataCache.h" 39 #include "platform/fonts/FontDataCache.h"
39 #include "platform/fonts/FontDescription.h" 40 #include "platform/fonts/FontDescription.h"
40 #include "platform/fonts/FontFallbackList.h" 41 #include "platform/fonts/FontFallbackList.h"
41 #include "platform/fonts/FontPlatformData.h" 42 #include "platform/fonts/FontPlatformData.h"
42 #include "platform/fonts/FontSelector.h"
43 #include "platform/fonts/FontSmoothingMode.h" 43 #include "platform/fonts/FontSmoothingMode.h"
44 #include "platform/fonts/TextRenderingMode.h" 44 #include "platform/fonts/TextRenderingMode.h"
45 #include "platform/fonts/opentype/OpenTypeVerticalData.h" 45 #include "platform/fonts/opentype/OpenTypeVerticalData.h"
46 #include "wtf/HashMap.h" 46 #include "wtf/HashMap.h"
47 #include "wtf/ListHashSet.h" 47 #include "wtf/ListHashSet.h"
48 #include "wtf/StdLibExtras.h" 48 #include "wtf/StdLibExtras.h"
49 #include "wtf/text/AtomicStringHash.h" 49 #include "wtf/text/AtomicStringHash.h"
50 #include "wtf/text/StringHash.h" 50 #include "wtf/text/StringHash.h"
51 51
52 using namespace WTF; 52 using namespace WTF;
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 if (m_purgePreventCount) 230 if (m_purgePreventCount)
231 return; 231 return;
232 232
233 if (!gFontDataCache || !gFontDataCache->purge(PurgeSeverity)) 233 if (!gFontDataCache || !gFontDataCache->purge(PurgeSeverity))
234 return; 234 return;
235 235
236 purgePlatformFontDataCache(); 236 purgePlatformFontDataCache();
237 purgeFontVerticalDataCache(); 237 purgeFontVerticalDataCache();
238 } 238 }
239 239
240 static HashSet<FontSelector*>* gClients; 240 static HashSet<FontCacheClient*>* gClients;
241 241
242 void FontCache::addClient(FontSelector* client) 242 void FontCache::addClient(FontCacheClient* client)
243 { 243 {
244 if (!gClients) 244 if (!gClients)
245 gClients = new HashSet<FontSelector*>; 245 gClients = new HashSet<FontCacheClient*>;
246 246
247 ASSERT(!gClients->contains(client)); 247 ASSERT(!gClients->contains(client));
248 gClients->add(client); 248 gClients->add(client);
249 } 249 }
250 250
251 void FontCache::removeClient(FontSelector* client) 251 void FontCache::removeClient(FontCacheClient* client)
252 { 252 {
253 ASSERT(gClients); 253 ASSERT(gClients);
254 ASSERT(gClients->contains(client)); 254 ASSERT(gClients->contains(client));
255 255
256 gClients->remove(client); 256 gClients->remove(client);
257 } 257 }
258 258
259 static unsigned short gGeneration = 0; 259 static unsigned short gGeneration = 0;
260 260
261 unsigned short FontCache::generation() 261 unsigned short FontCache::generation()
262 { 262 {
263 return gGeneration; 263 return gGeneration;
264 } 264 }
265 265
266 void FontCache::invalidate() 266 void FontCache::invalidate()
267 { 267 {
268 if (!gClients) { 268 if (!gClients) {
269 ASSERT(!gFontPlatformDataCache); 269 ASSERT(!gFontPlatformDataCache);
270 return; 270 return;
271 } 271 }
272 272
273 if (gFontPlatformDataCache) { 273 if (gFontPlatformDataCache) {
274 delete gFontPlatformDataCache; 274 delete gFontPlatformDataCache;
275 gFontPlatformDataCache = new FontPlatformDataCache; 275 gFontPlatformDataCache = new FontPlatformDataCache;
276 } 276 }
277 277
278 gGeneration++; 278 gGeneration++;
279 279
280 Vector<RefPtr<FontSelector> > clients; 280 Vector<RefPtr<FontCacheClient> > clients;
281 size_t numClients = gClients->size(); 281 size_t numClients = gClients->size();
282 clients.reserveInitialCapacity(numClients); 282 clients.reserveInitialCapacity(numClients);
283 HashSet<FontSelector*>::iterator end = gClients->end(); 283 HashSet<FontCacheClient*>::iterator end = gClients->end();
284 for (HashSet<FontSelector*>::iterator it = gClients->begin(); it != end; ++i t) 284 for (HashSet<FontCacheClient*>::iterator it = gClients->begin(); it != end; ++it)
285 clients.append(*it); 285 clients.append(*it);
286 286
287 ASSERT(numClients == clients.size()); 287 ASSERT(numClients == clients.size());
288 for (size_t i = 0; i < numClients; ++i) 288 for (size_t i = 0; i < numClients; ++i)
289 clients[i]->fontCacheInvalidated(); 289 clients[i]->fontCacheInvalidated();
290 290
291 purge(ForcePurge); 291 purge(ForcePurge);
292 } 292 }
293 293
294 } // namespace WebCore 294 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698