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

Unified Diff: src/core/SkTypefaceCache.cpp

Issue 664173003: Remove a pointless use of SkWeakRefCnt. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: missed also Created 6 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/core/SkTypefaceCache.h ('k') | src/ports/SkFontHost_win.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkTypefaceCache.cpp
diff --git a/src/core/SkTypefaceCache.cpp b/src/core/SkTypefaceCache.cpp
index cfa301ef39def299aa2abb801cec433daa3f2307..8adffe6a3a5cc6fa7c90ea8139cc1ab2d1537d3e 100644
--- a/src/core/SkTypefaceCache.cpp
+++ b/src/core/SkTypefaceCache.cpp
@@ -19,31 +19,19 @@ SkTypefaceCache::~SkTypefaceCache() {
const Rec* curr = fArray.begin();
const Rec* stop = fArray.end();
while (curr < stop) {
- if (curr->fStrong) {
- curr->fFace->unref();
- } else {
- curr->fFace->weak_unref();
- }
+ curr->fFace->unref();
curr += 1;
}
}
-void SkTypefaceCache::add(SkTypeface* face,
- const SkFontStyle& requestedStyle,
- bool strong) {
+void SkTypefaceCache::add(SkTypeface* face, const SkFontStyle& requestedStyle) {
if (fArray.count() >= TYPEFACE_CACHE_LIMIT) {
this->purge(TYPEFACE_CACHE_LIMIT >> 2);
}
Rec* rec = fArray.append();
- rec->fFace = face;
+ rec->fFace = SkRef(face);
rec->fRequestedStyle = requestedStyle;
- rec->fStrong = strong;
- if (strong) {
- face->ref();
- } else {
- face->weak_ref();
- }
}
SkTypeface* SkTypefaceCache::findByID(SkFontID fontID) const {
@@ -64,14 +52,7 @@ SkTypeface* SkTypefaceCache::findByProcAndRef(FindProc proc, void* ctx) const {
while (curr < stop) {
SkTypeface* currFace = curr->fFace;
if (proc(currFace, curr->fRequestedStyle, ctx)) {
- if (curr->fStrong) {
- currFace->ref();
- return currFace;
- } else if (currFace->try_ref()) {
- return currFace;
- } else {
- //remove currFace from fArray?
- }
+ return SkRef(currFace);
}
curr += 1;
}
@@ -83,13 +64,8 @@ void SkTypefaceCache::purge(int numToPurge) {
int i = 0;
while (i < count) {
SkTypeface* face = fArray[i].fFace;
- bool strong = fArray[i].fStrong;
- if ((strong && face->unique()) || (!strong && face->weak_expired())) {
- if (strong) {
- face->unref();
- } else {
- face->weak_unref();
- }
+ if (face->unique()) {
+ face->unref();
fArray.remove(i);
--count;
if (--numToPurge == 0) {
@@ -119,11 +95,9 @@ SkFontID SkTypefaceCache::NewFontID() {
SK_DECLARE_STATIC_MUTEX(gMutex);
-void SkTypefaceCache::Add(SkTypeface* face,
- const SkFontStyle& requestedStyle,
- bool strong) {
+void SkTypefaceCache::Add(SkTypeface* face, const SkFontStyle& requestedStyle) {
SkAutoMutexAcquire ama(gMutex);
- Get().add(face, requestedStyle, strong);
+ Get().add(face, requestedStyle);
}
SkTypeface* SkTypefaceCache::FindByID(SkFontID fontID) {
« no previous file with comments | « src/core/SkTypefaceCache.h ('k') | src/ports/SkFontHost_win.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698