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

Unified Diff: gm/verttext2.cpp

Issue 1933393002: Move SkTypeface to sk_sp. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Make vc++ happy. Created 4 years, 8 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/verttext2.cpp
diff --git a/gm/verttext2.cpp b/gm/verttext2.cpp
index 12576c2699a9e4b0822ab25c1ffb244d39164104..79cbdbcc8baee1d8871282e117056240b505f6b4 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<SkTypeface> 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<SkTypeface> fProp;
+ sk_sp<SkTypeface> fMono;
};
///////////////////////////////////////////////////////////////////////////////

Powered by Google App Engine
This is Rietveld 408576698