aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/FontHostTest.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/FontHostTest.cpp
parentc8699321b924c1f284df93cb29b86000c1d73c0a (diff)
Move SkTypeface to sk_sp.
Diffstat (limited to 'tests/FontHostTest.cpp')
-rw-r--r--tests/FontHostTest.cpp27
1 files changed, 13 insertions, 14 deletions
diff --git a/tests/FontHostTest.cpp b/tests/FontHostTest.cpp
index d9a3df414a..ebcc4ab2ae 100644
--- a/tests/FontHostTest.cpp
+++ b/tests/FontHostTest.cpp
@@ -31,7 +31,7 @@ static const struct TagSize {
// Test that getUnitsPerEm() agrees with a direct lookup in the 'head' table
// (if that table is available).
-static void test_unitsPerEm(skiatest::Reporter* reporter, SkTypeface* face) {
+static void test_unitsPerEm(skiatest::Reporter* reporter, const sk_sp<SkTypeface>& face) {
int nativeUPEM = face->getUnitsPerEm();
int tableUPEM = -1;
@@ -50,7 +50,7 @@ static void test_unitsPerEm(skiatest::Reporter* reporter, SkTypeface* face) {
// Test that countGlyphs() agrees with a direct lookup in the 'maxp' table
// (if that table is available).
-static void test_countGlyphs(skiatest::Reporter* reporter, SkTypeface* face) {
+static void test_countGlyphs(skiatest::Reporter* reporter, const sk_sp<SkTypeface>& face) {
int nativeGlyphs = face->countGlyphs();
int tableGlyphs = -1;
@@ -86,7 +86,7 @@ struct CharsToGlyphs_TestData {
};
// Test that SkPaint::textToGlyphs agrees with SkTypeface::charsToGlyphs.
-static void test_charsToGlyphs(skiatest::Reporter* reporter, SkTypeface* face) {
+static void test_charsToGlyphs(skiatest::Reporter* reporter, const sk_sp<SkTypeface>& face) {
uint16_t paintGlyphIds[256];
uint16_t faceGlyphIds[256];
@@ -154,22 +154,22 @@ static void test_fontstream(skiatest::Reporter* reporter) {
}
static void test_symbolfont(skiatest::Reporter* reporter) {
- SkAutoTUnref<SkTypeface> typeface(GetResourceAsTypeface("/fonts/SpiderSymbol.ttf"));
- if (!typeface) {
- SkDebugf("Skipping FontHostTest::test_symbolfont\n");
- return;
- }
-
SkUnichar c = 0xf021;
uint16_t g;
SkPaint paint;
- paint.setTypeface(typeface);
+ paint.setTypeface(MakeResourceAsTypeface("/fonts/SpiderSymbol.ttf"));
paint.setTextEncoding(SkPaint::kUTF32_TextEncoding);
paint.textToGlyphs(&c, 4, &g);
+
+ if (!paint.getTypeface()) {
+ SkDebugf("Skipping FontHostTest::test_symbolfont\n");
+ return;
+ }
+
REPORTER_ASSERT(reporter, g == 3);
}
-static void test_tables(skiatest::Reporter* reporter, SkTypeface* face) {
+static void test_tables(skiatest::Reporter* reporter, const sk_sp<SkTypeface>& face) {
if (false) { // avoid bit rot, suppress warning
SkFontID fontID = face->uniqueID();
REPORTER_ASSERT(reporter, fontID);
@@ -223,7 +223,7 @@ static void test_tables(skiatest::Reporter* reporter) {
};
for (size_t i = 0; i < SK_ARRAY_COUNT(gNames); ++i) {
- SkAutoTUnref<SkTypeface> face(SkTypeface::CreateFromName(gNames[i], SkTypeface::kNormal));
+ sk_sp<SkTypeface> face(SkTypeface::MakeFromName(gNames[i], SkTypeface::kNormal));
if (face) {
#ifdef DUMP_TABLES
SkDebugf("%s\n", gNames[i]);
@@ -277,8 +277,7 @@ static void test_advances(skiatest::Reporter* reporter) {
char txt[] = "long.text.with.lots.of.dots.";
for (size_t i = 0; i < SK_ARRAY_COUNT(faces); i++) {
- SkAutoTUnref<SkTypeface> face(SkTypeface::CreateFromName(faces[i], SkTypeface::kNormal));
- paint.setTypeface(face);
+ paint.setTypeface(SkTypeface::MakeFromName(faces[i], SkTypeface::kNormal));
for (size_t j = 0; j < SK_ARRAY_COUNT(settings); j++) {
paint.setHinting(settings[j].hinting);