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

Unified Diff: src/ports/SkFontHost_fontconfig.cpp

Issue 488143002: Replace SkTypeface::Style with SkFontStyle. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Add expectations, remove whitespace. 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/ports/SkFontHost_FreeType_common.h ('k') | src/ports/SkFontHost_linux.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/ports/SkFontHost_fontconfig.cpp
diff --git a/src/ports/SkFontHost_fontconfig.cpp b/src/ports/SkFontHost_fontconfig.cpp
index b3a893e53687a1c8597a542406414b2c1131ef2a..32e9f80560cefe0ad6c31cee45ae44a3184b564a 100644
--- a/src/ports/SkFontHost_fontconfig.cpp
+++ b/src/ports/SkFontHost_fontconfig.cpp
@@ -60,19 +60,20 @@ SkFontConfigInterface* SkFontHost_fontconfig_ref_global() {
///////////////////////////////////////////////////////////////////////////////
struct FindRec {
- FindRec(const char* name, SkTypeface::Style style)
+ FindRec(const char* name, const SkFontStyle& style)
: fFamilyName(name) // don't need to make a deep copy
, fStyle(style) {}
const char* fFamilyName;
- SkTypeface::Style fStyle;
+ SkFontStyle fStyle;
};
-static bool find_proc(SkTypeface* face, SkTypeface::Style style, void* ctx) {
- FontConfigTypeface* fci = (FontConfigTypeface*)face;
- const FindRec* rec = (const FindRec*)ctx;
+static bool find_proc(SkTypeface* cachedTypeface, const SkFontStyle& cachedStyle, void* ctx) {
+ FontConfigTypeface* cachedFCTypeface = (FontConfigTypeface*)cachedTypeface;
+ const FindRec* rec = static_cast<const FindRec*>(ctx);
- return rec->fStyle == style && fci->isFamilyName(rec->fFamilyName);
+ return rec->fStyle == cachedStyle &&
+ cachedFCTypeface->isFamilyName(rec->fFamilyName);
}
SkTypeface* FontConfigTypeface::LegacyCreateTypeface(
@@ -89,34 +90,37 @@ SkTypeface* FontConfigTypeface::LegacyCreateTypeface(
familyName = fct->getFamilyName();
}
- FindRec rec(familyName, style);
+ SkFontStyle requestedStyle(style);
+ FindRec rec(familyName, requestedStyle);
SkTypeface* face = SkTypefaceCache::FindByProcAndRef(find_proc, &rec);
if (face) {
-// SkDebugf("found cached face <%s> <%s> %p [%d]\n", familyName, ((FontConfigTypeface*)face)->getFamilyName(), face, face->getRefCnt());
+ //SkDebugf("found cached face <%s> <%s> %p [%d]\n",
+ // familyName, ((FontConfigTypeface*)face)->getFamilyName(),
+ // face, face->getRefCnt());
return face;
}
SkFontConfigInterface::FontIdentity indentity;
- SkString outFamilyName;
- SkTypeface::Style outStyle;
-
- if (!fci->matchFamilyName(familyName, style,
- &indentity, &outFamilyName, &outStyle)) {
+ SkString outFamilyName;
+ SkTypeface::Style outStyle;
+ if (!fci->matchFamilyName(familyName, style, &indentity, &outFamilyName, &outStyle)) {
return NULL;
}
// check if we, in fact, already have this. perhaps fontconfig aliased the
// requested name to some other name we actually have...
rec.fFamilyName = outFamilyName.c_str();
- rec.fStyle = outStyle;
+ rec.fStyle = SkFontStyle(outStyle);
face = SkTypefaceCache::FindByProcAndRef(find_proc, &rec);
if (face) {
return face;
}
- face = FontConfigTypeface::Create(outStyle, indentity, outFamilyName);
- SkTypefaceCache::Add(face, style);
-// SkDebugf("add face <%s> <%s> %p [%d]\n", familyName, outFamilyName.c_str(), face, face->getRefCnt());
+ face = FontConfigTypeface::Create(SkFontStyle(outStyle), indentity, outFamilyName);
+ SkTypefaceCache::Add(face, requestedStyle);
+ //SkDebugf("add face <%s> <%s> %p [%d]\n",
+ // familyName, outFamilyName.c_str(),
+ // face, face->getRefCnt());
return face;
}
« no previous file with comments | « src/ports/SkFontHost_FreeType_common.h ('k') | src/ports/SkFontHost_linux.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698