aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/FontHostStreamTest.cpp
diff options
context:
space:
mode:
authorGravatar bungeman <bungeman@google.com>2016-05-11 12:38:18 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2016-05-11 12:38:18 -0700
commit6296da736fbf40aae881650c239420f64e576c3f (patch)
tree5121ecf46ff7099d8eb66d2b2a4671d5ad94db89 /tests/FontHostStreamTest.cpp
parentc8699321b924c1f284df93cb29b86000c1d73c0a (diff)
Move SkTypeface to sk_sp.
Diffstat (limited to 'tests/FontHostStreamTest.cpp')
-rw-r--r--tests/FontHostStreamTest.cpp19
1 files changed, 6 insertions, 13 deletions
diff --git a/tests/FontHostStreamTest.cpp b/tests/FontHostStreamTest.cpp
index 0b436552a3..ec32d9f031 100644
--- a/tests/FontHostStreamTest.cpp
+++ b/tests/FontHostStreamTest.cpp
@@ -69,9 +69,7 @@ DEF_TEST(FontHostStream, reporter) {
paint.setColor(SK_ColorGRAY);
paint.setTextSize(SkIntToScalar(30));
- SkTypeface* fTypeface = SkTypeface::CreateFromName("Georgia",
- SkTypeface::kNormal);
- SkSafeUnref(paint.setTypeface(fTypeface));
+ paint.setTypeface(SkTypeface::MakeFromName("Georgia", SkTypeface::kNormal));
SkIRect origRect = SkIRect::MakeWH(64, 64);
SkBitmap origBitmap;
@@ -89,23 +87,18 @@ DEF_TEST(FontHostStream, reporter) {
drawBG(&origCanvas);
origCanvas.drawText("A", 1, point.fX, point.fY, paint);
- SkTypeface* origTypeface = paint.getTypeface();
- SkAutoTUnref<SkTypeface> aur;
- if (nullptr == origTypeface) {
- aur.reset(SkTypeface::RefDefault());
- origTypeface = aur.get();
- }
-
+ sk_sp<SkTypeface> typeface(SkToBool(paint.getTypeface()) ? sk_ref_sp(paint.getTypeface())
+ : SkTypeface::MakeDefault());
int ttcIndex;
- SkAutoTDelete<SkStreamAsset> fontData(origTypeface->openStream(&ttcIndex));
- SkTypeface* streamTypeface = SkTypeface::CreateFromStream(fontData.release());
+ SkAutoTDelete<SkStreamAsset> fontData(typeface->openStream(&ttcIndex));
+ sk_sp<SkTypeface> streamTypeface(SkTypeface::MakeFromStream(fontData.release()));
SkFontDescriptor desc;
bool isLocalStream = false;
streamTypeface->getFontDescriptor(&desc, &isLocalStream);
REPORTER_ASSERT(reporter, isLocalStream);
- SkSafeUnref(paint.setTypeface(streamTypeface));
+ paint.setTypeface(streamTypeface);
drawBG(&streamCanvas);
streamCanvas.drawPosText("A", 1, &point, paint);