From 6296da736fbf40aae881650c239420f64e576c3f Mon Sep 17 00:00:00 2001 From: bungeman Date: Wed, 11 May 2016 12:38:18 -0700 Subject: Move SkTypeface to sk_sp. Review-Url: https://codereview.chromium.org/1933393002 --- gm/fontmgr.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'gm/fontmgr.cpp') diff --git a/gm/fontmgr.cpp b/gm/fontmgr.cpp index 1975f998cd..a4dc2631ec 100644 --- a/gm/fontmgr.cpp +++ b/gm/fontmgr.cpp @@ -31,9 +31,9 @@ static SkScalar drawCharacter(SkCanvas* canvas, uint32_t character, SkScalar x, // find typeface containing the requested character and draw it SkString ch; ch.appendUnichar(character); - SkTypeface* typeface = fm->matchFamilyStyleCharacter(fontName, fontStyle, - bcp47, bcp47Count, character); - SkSafeUnref(paint.setTypeface(typeface)); + sk_sp typeface(fm->matchFamilyStyleCharacter(fontName, fontStyle, + bcp47, bcp47Count, character)); + paint.setTypeface(typeface); x = drawString(canvas, ch, x, y, paint) + 20; if (nullptr == typeface) { @@ -45,8 +45,8 @@ static SkScalar drawCharacter(SkCanvas* canvas, uint32_t character, SkScalar x, // it expects to get the same glyph when following this pattern. SkString familyName; typeface->getFamilyName(&familyName); - SkTypeface* typefaceCopy = fm->legacyCreateTypeface(familyName.c_str(), typeface->fontStyle()); - SkSafeUnref(paint.setTypeface(typefaceCopy)); + paint.setTypeface(sk_sp(fm->legacyCreateTypeface(familyName.c_str(), + typeface->fontStyle()))); return drawString(canvas, ch, x, y, paint) + 20; } @@ -104,7 +104,7 @@ protected: set->getStyle(j, &fs, &sname); sname.appendf(" [%d %d %d]", fs.weight(), fs.width(), fs.slant()); - SkSafeUnref(paint.setTypeface(set->createTypeface(j))); + paint.setTypeface(sk_sp(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 @@ protected: sname.appendf(" [%d %d]", fs.weight(), fs.width()); - SkSafeUnref(p.setTypeface(fset->createTypeface(j))); + p.setTypeface(sk_sp(fset->createTypeface(j))); (void)drawString(canvas, sname, 0, y, p); y += 24; } @@ -169,11 +169,11 @@ protected: for (int weight = 100; weight <= 900; weight += 200) { for (int width = 1; width <= 9; width += 2) { SkFontStyle fs(weight, width, SkFontStyle::kUpright_Slant); - SkTypeface* face = fset->matchStyle(fs); + sk_sp face(fset->matchStyle(fs)); if (face) { SkString str; str.printf("request [%d %d]", fs.weight(), fs.width()); - p.setTypeface(face)->unref(); + p.setTypeface(std::move(face)); (void)drawString(canvas, str, 0, y, p); y += 24; } @@ -274,7 +274,7 @@ protected: for (int i = 0; i < count; ++i) { SkAutoTUnref set(fm->createStyleSet(i)); for (int j = 0; j < set->count(); ++j) { - SkSafeUnref(paint.setTypeface(set->createTypeface(j))); + paint.setTypeface(sk_sp(set->createTypeface(j))); if (paint.getTypeface()) { show_bounds(canvas, paint, x, y, boundsColors[index & 1]); index += 1; -- cgit v1.2.3