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

Unified Diff: src/core/SkFont.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/SkFont.cpp
diff --git a/src/core/SkFont.cpp b/src/core/SkFont.cpp
index 1300011ec450f29326c2f47d7ea0a1dc64a572be..c39cc185d3d5d74c7ed20af2a40aacbdeea090d6 100644
--- a/src/core/SkFont.cpp
+++ b/src/core/SkFont.cpp
@@ -9,9 +9,13 @@
#include "SkTypeface.h"
#include "SkUtils.h"
-SkFont::SkFont(sk_sp<SkTypeface> face, SkScalar size, SkScalar scaleX, SkScalar skewX, MaskType mt,
+static SkTypeface* ref_or_default(SkTypeface* face) {
+ return face ? SkRef(face) : SkTypeface::RefDefault();
+}
+
+SkFont::SkFont(SkTypeface* face, SkScalar size, SkScalar scaleX, SkScalar skewX, MaskType mt,
uint32_t flags)
- : fTypeface(face ? std::move(face) : SkTypeface::MakeDefault())
+ : fTypeface(ref_or_default(face))
, fSize(size)
, fScaleX(scaleX)
, fSkewX(skewX)
@@ -24,8 +28,8 @@
SkASSERT(0 == (flags & ~kAllFlags));
}
-sk_sp<SkFont> SkFont::Make(sk_sp<SkTypeface> face, SkScalar size, SkScalar scaleX, SkScalar skewX,
- MaskType mt, uint32_t flags) {
+SkFont* SkFont::Create(SkTypeface* face, SkScalar size, SkScalar scaleX, SkScalar skewX,
+ MaskType mt, uint32_t flags) {
if (size <= 0 || !SkScalarIsFinite(size)) {
return nullptr;
}
@@ -36,19 +40,23 @@
return nullptr;
}
flags &= kAllFlags;
- return sk_sp<SkFont>(new SkFont(std::move(face), size, scaleX, skewX, mt, flags));
+ return new SkFont(face, size, scaleX, skewX, mt, flags);
}
-sk_sp<SkFont> SkFont::Make(sk_sp<SkTypeface> face, SkScalar size, MaskType mt, uint32_t flags) {
- return SkFont::Make(std::move(face), size, 1, 0, mt, flags);
+SkFont* SkFont::Create(SkTypeface* face, SkScalar size, MaskType mt, uint32_t flags) {
+ return SkFont::Create(face, size, 1, 0, mt, flags);
}
-sk_sp<SkFont> SkFont::makeWithSize(SkScalar newSize) const {
- return SkFont::Make(sk_ref_sp(this->getTypeface()), newSize, this->getScaleX(),
- this->getSkewX(), this->getMaskType(), this->getFlags());
+SkFont* SkFont::cloneWithSize(SkScalar newSize) const {
+ return SkFont::Create(this->getTypeface(), newSize, this->getScaleX(), this->getSkewX(),
+ this->getMaskType(), this->getFlags());
}
///////////////////////////////////////////////////////////////////////////////////////////////////
+
+SkFont::~SkFont() {
+ SkSafeUnref(fTypeface);
+}
int SkFont::textToGlyphs(const void* text, size_t byteLength, SkTextEncoding encoding,
uint16_t glyphs[], int maxGlyphCount) const {
@@ -110,7 +118,7 @@
#include "SkPaint.h"
-sk_sp<SkFont> SkFont::Testing_CreateFromPaint(const SkPaint& paint) {
+SkFont* SkFont::Testing_CreateFromPaint(const SkPaint& paint) {
uint32_t flags = 0;
if (paint.isVerticalText()) {
flags |= kVertical_Flag;
@@ -142,6 +150,7 @@
maskType = paint.isLCDRenderText() ? kLCD_MaskType : kA8_MaskType;
}
- return Make(sk_ref_sp(paint.getTypeface()), paint.getTextSize(), paint.getTextScaleX(),
- paint.getTextSkewX(), maskType, flags);
+ return Create(paint.getTypeface(),
+ paint.getTextSize(), paint.getTextScaleX(), paint.getTextSkewX(),
+ maskType, flags);
}

Powered by Google App Engine
This is Rietveld 408576698