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

Unified Diff: gm/fontmgr.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: gm/fontmgr.cpp
diff --git a/gm/fontmgr.cpp b/gm/fontmgr.cpp
index a4dc2631ec6a214385c776b12ec8d33fb376f0f2..1975f998cdc9fa99e8ce5e5ae39b8396b2c6a073 100644
--- a/gm/fontmgr.cpp
+++ b/gm/fontmgr.cpp
@@ -31,9 +31,9 @@
// find typeface containing the requested character and draw it
SkString ch;
ch.appendUnichar(character);
- sk_sp<SkTypeface> typeface(fm->matchFamilyStyleCharacter(fontName, fontStyle,
- bcp47, bcp47Count, character));
- paint.setTypeface(typeface);
+ SkTypeface* typeface = fm->matchFamilyStyleCharacter(fontName, fontStyle,
+ bcp47, bcp47Count, character);
+ SkSafeUnref(paint.setTypeface(typeface));
x = drawString(canvas, ch, x, y, paint) + 20;
if (nullptr == typeface) {
@@ -45,8 +45,8 @@
// it expects to get the same glyph when following this pattern.
SkString familyName;
typeface->getFamilyName(&familyName);
- paint.setTypeface(sk_sp<SkTypeface>(fm->legacyCreateTypeface(familyName.c_str(),
- typeface->fontStyle())));
+ SkTypeface* typefaceCopy = fm->legacyCreateTypeface(familyName.c_str(), typeface->fontStyle());
+ SkSafeUnref(paint.setTypeface(typefaceCopy));
return drawString(canvas, ch, x, y, paint) + 20;
}
@@ -104,7 +104,7 @@
set->getStyle(j, &fs, &sname);
sname.appendf(" [%d %d %d]", fs.weight(), fs.width(), fs.slant());
- paint.setTypeface(sk_sp<SkTypeface>(set->createTypeface(j)));
+ SkSafeUnref(paint.setTypeface(set->createTypeface(j)));
x = drawString(canvas, sname, x, y, paint) + 20;
// check to see that we get different glyphs in japanese and chinese
@@ -155,7 +155,7 @@
sname.appendf(" [%d %d]", fs.weight(), fs.width());
- p.setTypeface(sk_sp<SkTypeface>(fset->createTypeface(j)));
+ SkSafeUnref(p.setTypeface(fset->createTypeface(j)));
(void)drawString(canvas, sname, 0, y, p);
y += 24;
}
@@ -169,11 +169,11 @@
for (int weight = 100; weight <= 900; weight += 200) {
for (int width = 1; width <= 9; width += 2) {
SkFontStyle fs(weight, width, SkFontStyle::kUpright_Slant);
- sk_sp<SkTypeface> face(fset->matchStyle(fs));
+ SkTypeface* face = fset->matchStyle(fs);
if (face) {
SkString str;
str.printf("request [%d %d]", fs.weight(), fs.width());
- p.setTypeface(std::move(face));
+ p.setTypeface(face)->unref();
(void)drawString(canvas, str, 0, y, p);
y += 24;
}
@@ -274,7 +274,7 @@
for (int i = 0; i < count; ++i) {
SkAutoTUnref<SkFontStyleSet> set(fm->createStyleSet(i));
for (int j = 0; j < set->count(); ++j) {
- paint.setTypeface(sk_sp<SkTypeface>(set->createTypeface(j)));
+ SkSafeUnref(paint.setTypeface(set->createTypeface(j)));
if (paint.getTypeface()) {
show_bounds(canvas, paint, x, y, boundsColors[index & 1]);
index += 1;
« no previous file with comments | « gm/fontcache.cpp ('k') | gm/fontscalerdistortable.cpp » ('j') | src/ports/SkFontMgr_android.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698