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

Unified Diff: tests/FontHostStreamTest.cpp

Issue 1933393002: Move SkTypeface to sk_sp. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Restore deleted Android code. Created 4 years, 7 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
« no previous file with comments | « src/utils/SkWhitelistTypefaces.cpp ('k') | tests/FontHostTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/FontHostStreamTest.cpp
diff --git a/tests/FontHostStreamTest.cpp b/tests/FontHostStreamTest.cpp
index 0b436552a3c9a232bea50626ea26cb21edb87989..ec32d9f031ed83861b11801e9b8ebb4647d6adea 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);
« no previous file with comments | « src/utils/SkWhitelistTypefaces.cpp ('k') | tests/FontHostTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698