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

Side by Side Diff: src/core/SkTypefaceCache.cpp

Issue 23067003: expose instance methods on SkTypefaceCache (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 years, 4 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
« no previous file with comments | « src/core/SkTypefaceCache.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 1
2 /* 2 /*
3 * Copyright 2011 Google Inc. 3 * Copyright 2011 Google Inc.
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 9
10 10
11 #include "SkTypefaceCache.h" 11 #include "SkTypefaceCache.h"
12 #include "SkThread.h" 12 #include "SkThread.h"
13 13
14 #define TYPEFACE_CACHE_LIMIT 1024 14 #define TYPEFACE_CACHE_LIMIT 1024
15 15
16 SkTypefaceCache::SkTypefaceCache() {}
17
18 SkTypefaceCache::~SkTypefaceCache() {
19 const Rec* curr = fArray.begin();
20 const Rec* stop = fArray.end();
21 while (curr < stop) {
22 if (curr->fStrong) {
23 curr->fFace->unref();
24 } else {
25 curr->fFace->weak_unref();
26 }
27 curr += 1;
28 }
29 }
30
16 void SkTypefaceCache::add(SkTypeface* face, 31 void SkTypefaceCache::add(SkTypeface* face,
17 SkTypeface::Style requestedStyle, 32 SkTypeface::Style requestedStyle,
18 bool strong) { 33 bool strong) {
19 if (fArray.count() >= TYPEFACE_CACHE_LIMIT) { 34 if (fArray.count() >= TYPEFACE_CACHE_LIMIT) {
20 this->purge(TYPEFACE_CACHE_LIMIT >> 2); 35 this->purge(TYPEFACE_CACHE_LIMIT >> 2);
21 } 36 }
22 37
23 Rec* rec = fArray.append(); 38 Rec* rec = fArray.append();
24 rec->fFace = face; 39 rec->fFace = face;
25 rec->fRequestedStyle = requestedStyle; 40 rec->fRequestedStyle = requestedStyle;
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 return false; 151 return false;
137 } 152 }
138 #endif 153 #endif
139 154
140 void SkTypefaceCache::Dump() { 155 void SkTypefaceCache::Dump() {
141 #ifdef SK_DEBUG 156 #ifdef SK_DEBUG
142 SkAutoMutexAcquire ama(gMutex); 157 SkAutoMutexAcquire ama(gMutex);
143 (void)Get().findByProcAndRef(DumpProc, NULL); 158 (void)Get().findByProcAndRef(DumpProc, NULL);
144 #endif 159 #endif
145 } 160 }
OLDNEW
« no previous file with comments | « src/core/SkTypefaceCache.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698