SkScalerContext to use smart pointers.
CQ_INCLUDE_TRYBOTS=master.client.skia:Test-Ubuntu-Clang-GCE-CPU-AVX2-x86_64-Debug-ASAN-Trybot;master.client.skia:Test-Ubuntu-Clang-GCE-CPU-AVX2-x86_64-Debug-MSAN-Trybot
Change-Id: I27a714388b8ded7dfc968e322b0a587205f575f1
Reviewed-on: https://skia-review.googlesource.com/3731
Reviewed-by: Mike Klein <mtklein@chromium.org>
Commit-Queue: Ben Wagner <bungeman@google.com>
diff --git a/tools/sk_tool_utils_font.cpp b/tools/sk_tool_utils_font.cpp
index 402402f..a1d50dd 100644
--- a/tools/sk_tool_utils_font.cpp
+++ b/tools/sk_tool_utils_font.cpp
@@ -23,7 +23,7 @@
void release_portable_typefaces() {
for (int index = 0; index < gTestFontsCount; ++index) {
SkTestFontData& fontData = gTestFonts[index];
- SkSafeUnref(fontData.fFontCache);
+ fontData.fCachedFont.reset();
}
}
@@ -54,19 +54,19 @@
sub = &gSubFonts[gDefaultFontIndex];
fontData = &sub->fFont;
}
- SkTestFont* font;
+ sk_sp<SkTestFont> font;
{
SkAutoMutexAcquire ac(gTestFontMutex);
- if (fontData->fFontCache) {
- font = SkSafeRef(fontData->fFontCache);
+ if (fontData->fCachedFont) {
+ font = fontData->fCachedFont;
} else {
- font = new SkTestFont(*fontData);
+ font = sk_make_sp<SkTestFont>(*fontData);
SkDEBUGCODE(font->fDebugName = sub->fName);
SkDEBUGCODE(font->fDebugStyle = sub->fStyle);
- fontData->fFontCache = SkSafeRef(font);
+ fontData->fCachedFont = font;
}
}
- return sk_make_sp<SkTestTypeface>(font, style);
+ return sk_make_sp<SkTestTypeface>(std::move(font), style);
}
}