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

Unified Diff: src/core/SkTypeface.cpp

Issue 1974783002: Revert of Move SkTypeface to sk_sp. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 7 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
Index: src/core/SkTypeface.cpp
diff --git a/src/core/SkTypeface.cpp b/src/core/SkTypeface.cpp
index 3c15878f737bc5c10a1d38b9d0377487300e8e38..75bb05c2b13cbfac283b36281850603e0206f3c0 100644
--- a/src/core/SkTypeface.cpp
+++ b/src/core/SkTypeface.cpp
@@ -27,9 +27,9 @@
#define SK_TYPEFACE_DELEGATE nullptr
#endif
-sk_sp<SkTypeface> (*gCreateTypefaceDelegate)(const char [], SkTypeface::Style ) = nullptr;
+SkTypeface* (*gCreateTypefaceDelegate)(const char [], SkTypeface::Style ) = nullptr;
void (*gSerializeTypefaceDelegate)(const SkTypeface*, SkWStream* ) = SK_TYPEFACE_DELEGATE;
-sk_sp<SkTypeface> (*gDeserializeTypefaceDelegate)(SkStream* ) = nullptr;
+SkTypeface* (*gDeserializeTypefaceDelegate)(SkStream* ) = nullptr;
///////////////////////////////////////////////////////////////////////////////
@@ -98,8 +98,8 @@
return defaults[style];
}
-sk_sp<SkTypeface> SkTypeface::MakeDefault(Style style) {
- return sk_ref_sp(GetDefaultTypeface(style));
+SkTypeface* SkTypeface::RefDefault(Style style) {
+ return SkRef(GetDefaultTypeface(style));
}
uint32_t SkTypeface::UniqueID(const SkTypeface* face) {
@@ -115,46 +115,47 @@
///////////////////////////////////////////////////////////////////////////////
-sk_sp<SkTypeface> SkTypeface::MakeFromName(const char name[], Style style) {
+SkTypeface* SkTypeface::CreateFromName(const char name[], Style style) {
if (gCreateTypefaceDelegate) {
- sk_sp<SkTypeface> result = (*gCreateTypefaceDelegate)(name, style);
+ SkTypeface* result = (*gCreateTypefaceDelegate)(name, style);
if (result) {
return result;
}
}
if (nullptr == name) {
- return MakeDefault(style);
- }
- SkAutoTUnref<SkFontMgr> fm(SkFontMgr::RefDefault());
- return sk_sp<SkTypeface>(fm->legacyCreateTypeface(name, SkFontStyle::FromOldStyle(style)));
-}
-
-sk_sp<SkTypeface> SkTypeface::MakeFromTypeface(SkTypeface* family, Style s) {
+ return RefDefault(style);
+ }
+ SkAutoTUnref<SkFontMgr> fm(SkFontMgr::RefDefault());
+ return fm->legacyCreateTypeface(name, SkFontStyle::FromOldStyle(style));
+}
+
+SkTypeface* SkTypeface::CreateFromTypeface(const SkTypeface* family, Style s) {
if (!family) {
- return SkTypeface::MakeDefault(s);
+ return SkTypeface::RefDefault(s);
}
if (family->style() == s) {
- return sk_ref_sp(family);
- }
-
- SkAutoTUnref<SkFontMgr> fm(SkFontMgr::RefDefault());
- return sk_sp<SkTypeface>(fm->matchFaceStyle(family, SkFontStyle::FromOldStyle(s)));
-}
-
-sk_sp<SkTypeface> SkTypeface::MakeFromStream(SkStreamAsset* stream, int index) {
- SkAutoTUnref<SkFontMgr> fm(SkFontMgr::RefDefault());
- return sk_sp<SkTypeface>(fm->createFromStream(stream, index));
-}
-
-sk_sp<SkTypeface> SkTypeface::MakeFromFontData(SkFontData* data) {
- SkAutoTUnref<SkFontMgr> fm(SkFontMgr::RefDefault());
- return sk_sp<SkTypeface>(fm->createFromFontData(data));
-}
-
-sk_sp<SkTypeface> SkTypeface::MakeFromFile(const char path[], int index) {
- SkAutoTUnref<SkFontMgr> fm(SkFontMgr::RefDefault());
- return sk_sp<SkTypeface>(fm->createFromFile(path, index));
+ family->ref();
+ return const_cast<SkTypeface*>(family);
+ }
+
+ SkAutoTUnref<SkFontMgr> fm(SkFontMgr::RefDefault());
+ return fm->matchFaceStyle(family, SkFontStyle::FromOldStyle(s));
+}
+
+SkTypeface* SkTypeface::CreateFromStream(SkStreamAsset* stream, int index) {
+ SkAutoTUnref<SkFontMgr> fm(SkFontMgr::RefDefault());
+ return fm->createFromStream(stream, index);
+}
+
+SkTypeface* SkTypeface::CreateFromFontData(SkFontData* data) {
+ SkAutoTUnref<SkFontMgr> fm(SkFontMgr::RefDefault());
+ return fm->createFromFontData(data);
+}
+
+SkTypeface* SkTypeface::CreateFromFile(const char path[], int index) {
+ SkAutoTUnref<SkFontMgr> fm(SkFontMgr::RefDefault());
+ return fm->createFromFile(path, index);
}
///////////////////////////////////////////////////////////////////////////////
@@ -175,7 +176,7 @@
desc.serialize(wstream);
}
-sk_sp<SkTypeface> SkTypeface::MakeDeserialize(SkStream* stream) {
+SkTypeface* SkTypeface::Deserialize(SkStream* stream) {
if (gDeserializeTypefaceDelegate) {
return (*gDeserializeTypefaceDelegate)(stream);
}
@@ -187,12 +188,12 @@
SkFontData* data = desc.detachFontData();
if (data) {
- sk_sp<SkTypeface> typeface(SkTypeface::MakeFromFontData(data));
+ SkTypeface* typeface = SkTypeface::CreateFromFontData(data);
if (typeface) {
return typeface;
}
}
- return SkTypeface::MakeFromName(desc.getFamilyName(), desc.getStyle());
+ return SkTypeface::CreateFromName(desc.getFamilyName(), desc.getStyle());
}
///////////////////////////////////////////////////////////////////////////////
@@ -334,7 +335,7 @@
const SkScalar invTextSize = 1 / textSize;
SkPaint paint;
- paint.setTypeface(sk_ref_sp(const_cast<SkTypeface*>(this)));
+ paint.setTypeface(const_cast<SkTypeface*>(this));
paint.setTextSize(textSize);
paint.setLinearText(true);

Powered by Google App Engine
This is Rietveld 408576698