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

Unified Diff: src/core/SkTypeface.cpp

Issue 227693003: Factory methods for heap-allocated SkTypeface objects. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: comment Created 6 years, 8 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 | « no previous file | src/fonts/SkFontMgr_fontconfig.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkTypeface.cpp
diff --git a/src/core/SkTypeface.cpp b/src/core/SkTypeface.cpp
index d15caeb86f594493b3a743f947bec985ece9c286..cd3953ba98bdfda0b923ca88faafd136be0eb7a9 100644
--- a/src/core/SkTypeface.cpp
+++ b/src/core/SkTypeface.cpp
@@ -37,8 +37,12 @@ SkTypeface::~SkTypeface() {
class SkEmptyTypeface : public SkTypeface {
public:
- SkEmptyTypeface() : SkTypeface(SkTypeface::kNormal, 0, true) { }
+ static SkEmptyTypeface* Create() {
+ return SkNEW(SkEmptyTypeface);
+ }
protected:
+ SkEmptyTypeface() : SkTypeface(SkTypeface::kNormal, 0, true) { }
+
virtual SkStream* onOpenStream(int* ttcIndex) const SK_OVERRIDE { return NULL; }
virtual SkScalerContext* onCreateScalerContext(const SkDescriptor*) const SK_OVERRIDE {
return NULL;
@@ -85,7 +89,8 @@ void SkTypeface::create_default_typeface(Style style) {
gDefaultTypefaces[style] = SkFontHost::CreateTypeface(NULL, NULL, style);
}
if (NULL == gDefaultTypefaces[style]) {
- gDefaultTypefaces[style] = SkNEW(SkEmptyTypeface);
+ // FIXME: Use a singleton for SkEmptyTypeface.
+ gDefaultTypefaces[style] = SkEmptyTypeface::Create();
}
}
« no previous file with comments | « no previous file | src/fonts/SkFontMgr_fontconfig.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698