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/verttext2.cpp | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) (limited to 'gm/verttext2.cpp') diff --git a/gm/verttext2.cpp b/gm/verttext2.cpp index 12576c2699..79cbdbcc8b 100644 --- a/gm/verttext2.cpp +++ b/gm/verttext2.cpp @@ -17,23 +17,15 @@ namespace skiagm { class VertText2GM : public GM { public: - VertText2GM() - : fProp(nullptr) - , fMono(nullptr) { - } - - virtual ~VertText2GM() { - SkSafeUnref(fProp); - SkSafeUnref(fMono); - } + VertText2GM() {} protected: void onOnceBeforeDraw() override { const int pointSize = 24; textHeight = SkIntToScalar(pointSize); - fProp = SkTypeface::CreateFromName(sk_tool_utils::platform_font_name("sans-serif"), + fProp = SkTypeface::MakeFromName(sk_tool_utils::platform_font_name("sans-serif"), SkTypeface::kNormal); - fMono = SkTypeface::CreateFromName(sk_tool_utils::platform_font_name("monospace"), + fMono = SkTypeface::MakeFromName(sk_tool_utils::platform_font_name("monospace"), SkTypeface::kNormal); } @@ -74,13 +66,13 @@ protected: } void drawText(SkCanvas* canvas, const SkString& string, - SkTypeface* family, SkPaint::Align alignment) { + sk_sp family, SkPaint::Align alignment) { SkPaint paint; paint.setColor(SK_ColorBLACK); paint.setAntiAlias(true); paint.setVerticalText(true); paint.setTextAlign(alignment); - paint.setTypeface(family); + paint.setTypeface(std::move(family)); paint.setTextSize(textHeight); canvas->drawText(string.c_str(), string.size(), y, @@ -92,8 +84,8 @@ protected: private: typedef GM INHERITED; SkScalar y, textHeight; - SkTypeface* fProp; - SkTypeface* fMono; + sk_sp fProp; + sk_sp fMono; }; /////////////////////////////////////////////////////////////////////////////// -- cgit v1.2.3