From adcdca86ce425cf8c28bfad311cef028df756ee8 Mon Sep 17 00:00:00 2001 From: joshualitt Date: Fri, 31 Jul 2015 07:44:11 -0700 Subject: Modifying TextBlobCacheTest to use SkRandomScalerContext BUG=skia: Review URL: https://codereview.chromium.org/1266003002 --- tests/TextBlobCacheTest.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'tests/TextBlobCacheTest.cpp') diff --git a/tests/TextBlobCacheTest.cpp b/tests/TextBlobCacheTest.cpp index 3cbc8a35ad..c42ef89890 100644 --- a/tests/TextBlobCacheTest.cpp +++ b/tests/TextBlobCacheTest.cpp @@ -14,6 +14,8 @@ #include "SkGraphics.h" #include "SkSurface.h" #include "SkTypeface.h" +#include "../src/fonts/SkRandomScalerContext.h" +#include "../src/fonts/SkGScalerContext.h" #ifdef SK_BUILD_FOR_WIN #include "SkTypeface_win.h" @@ -59,7 +61,8 @@ DEF_GPUTEST(TextBlobCache, reporter, factory) { uint32_t flags = 0; SkSurfaceProps props(flags, SkSurfaceProps::kLegacyFontHost_InitType); - GrContext* ctx = factory->get(GrContextFactory::kNative_GLContextType); + // We don't typically actually draw with this unittest + GrContext* ctx = factory->get(GrContextFactory::kNull_GLContextType); SkImageInfo info = SkImageInfo::Make(kWidth, kHeight, kN32_SkColorType, kPremul_SkAlphaType); SkAutoTUnref surface(SkSurface::NewRenderTarget(ctx, SkSurface::kNo_Budgeted, info, 0, &props)); @@ -94,7 +97,10 @@ DEF_GPUTEST(TextBlobCache, reporter, factory) { SkFontStyle fs; set->getStyle(j, &fs, NULL); - SkSafeUnref(paint.setTypeface(set->createTypeface(j))); + // We use a typeface which randomy returns unexpected mask formats to fuzz + SkAutoTUnref orig(set->createTypeface(j)); + SkAutoTUnref typeface(SkNEW_ARGS(SkRandomTypeface, (orig, paint, true))); + paint.setTypeface(typeface); SkTextBlobBuilder builder; for (int aa = 0; aa < 2; aa++) { @@ -103,6 +109,9 @@ DEF_GPUTEST(TextBlobCache, reporter, factory) { paint.setAntiAlias(SkToBool(aa)); paint.setSubpixelText(SkToBool(subpixel)); paint.setLCDRenderText(SkToBool(lcd)); + if (!SkToBool(lcd)) { + paint.setTextSize(160); + } const SkTextBlobBuilder::RunBuffer& run = builder.allocRun(paint, MAX_TOTAL_TEXT, 0, 0, -- cgit v1.2.3