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

Unified Diff: tests/FontHostStreamTest.cpp

Issue 1974783002: Revert of Move SkTypeface to sk_sp. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 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
Index: tests/FontHostStreamTest.cpp
diff --git a/tests/FontHostStreamTest.cpp b/tests/FontHostStreamTest.cpp
index ec32d9f031ed83861b11801e9b8ebb4647d6adea..0b436552a3c9a232bea50626ea26cb21edb87989 100644
--- a/tests/FontHostStreamTest.cpp
+++ b/tests/FontHostStreamTest.cpp
@@ -69,7 +69,9 @@
paint.setColor(SK_ColorGRAY);
paint.setTextSize(SkIntToScalar(30));
- paint.setTypeface(SkTypeface::MakeFromName("Georgia", SkTypeface::kNormal));
+ SkTypeface* fTypeface = SkTypeface::CreateFromName("Georgia",
+ SkTypeface::kNormal);
+ SkSafeUnref(paint.setTypeface(fTypeface));
SkIRect origRect = SkIRect::MakeWH(64, 64);
SkBitmap origBitmap;
@@ -87,18 +89,23 @@
drawBG(&origCanvas);
origCanvas.drawText("A", 1, point.fX, point.fY, paint);
- sk_sp<SkTypeface> typeface(SkToBool(paint.getTypeface()) ? sk_ref_sp(paint.getTypeface())
- : SkTypeface::MakeDefault());
+ SkTypeface* origTypeface = paint.getTypeface();
+ SkAutoTUnref<SkTypeface> aur;
+ if (nullptr == origTypeface) {
+ aur.reset(SkTypeface::RefDefault());
+ origTypeface = aur.get();
+ }
+
int ttcIndex;
- SkAutoTDelete<SkStreamAsset> fontData(typeface->openStream(&ttcIndex));
- sk_sp<SkTypeface> streamTypeface(SkTypeface::MakeFromStream(fontData.release()));
+ SkAutoTDelete<SkStreamAsset> fontData(origTypeface->openStream(&ttcIndex));
+ SkTypeface* streamTypeface = SkTypeface::CreateFromStream(fontData.release());
SkFontDescriptor desc;
bool isLocalStream = false;
streamTypeface->getFontDescriptor(&desc, &isLocalStream);
REPORTER_ASSERT(reporter, isLocalStream);
- paint.setTypeface(streamTypeface);
+ SkSafeUnref(paint.setTypeface(streamTypeface));
drawBG(&streamCanvas);
streamCanvas.drawPosText("A", 1, &point, paint);

Powered by Google App Engine
This is Rietveld 408576698