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

Unified Diff: tests/TextBlobCacheTest.cpp

Issue 1266003002: Modifying TextBlobCacheTest to use SkRandomScalerContext (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: tweaks Created 5 years, 5 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/gpu/GrBatchFontCache.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/TextBlobCacheTest.cpp
diff --git a/tests/TextBlobCacheTest.cpp b/tests/TextBlobCacheTest.cpp
index 3cbc8a35ad8cd1d80d6fe595ed3aa0c3adeb4253..60a6a8a24b777d65df078dd874526036bb8a3415 100644
--- a/tests/TextBlobCacheTest.cpp
+++ b/tests/TextBlobCacheTest.cpp
@@ -14,6 +14,7 @@
#include "SkGraphics.h"
#include "SkSurface.h"
#include "SkTypeface.h"
+#include "../src/fonts/SkRandomScalerContext.h"
#ifdef SK_BUILD_FOR_WIN
#include "SkTypeface_win.h"
@@ -45,21 +46,18 @@ static void draw(SkCanvas* canvas, int redraw, const SkTArray<TextBlobWrapper>&
}
}
-// limit this just so we don't take too long to draw
-#define MAX_TOTAL_TEXT 4096
-#define MAX_CHAR 256
-#define MAX_FAMILIES 30
-
static const int kWidth = 1024;
static const int kHeight = 768;
// This test hammers the GPU textblobcache and font atlas
-DEF_GPUTEST(TextBlobCache, reporter, factory) {
+static void text_blob_cache_inner(skiatest::Reporter* reporter, GrContextFactory* factory,
+ int maxTotalText, int maxGlyphID, int maxFamilies, bool normal) {
// setup surface
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<SkSurface> surface(SkSurface::NewRenderTarget(ctx, SkSurface::kNo_Budgeted, info,
0, &props));
@@ -72,12 +70,12 @@ DEF_GPUTEST(TextBlobCache, reporter, factory) {
SkAutoTUnref<SkFontMgr> fm(SkFontMgr::RefDefault());
- int count = SkMin32(fm->countFamilies(), MAX_FAMILIES);
+ int count = SkMin32(fm->countFamilies(), maxFamilies);
// make a ton of text
- uint16_t text[MAX_TOTAL_TEXT];
- for (int i = 0; i < MAX_TOTAL_TEXT; i++) {
- text[i] = i % MAX_CHAR;
+ SkAutoTArray<uint16_t> text(maxTotalText);
+ for (int i = 0; i < maxTotalText; i++) {
+ text[i] = i % maxGlyphID;
}
// generate textblobs
@@ -94,7 +92,14 @@ 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<SkTypeface> orig(set->createTypeface(j));
+ if (normal) {
+ paint.setTypeface(orig);
+ } else {
+ SkAutoTUnref<SkTypeface> typeface(SkNEW_ARGS(SkRandomTypeface, (orig, paint, true)));
+ paint.setTypeface(typeface);
+ }
SkTextBlobBuilder builder;
for (int aa = 0; aa < 2; aa++) {
@@ -103,11 +108,14 @@ 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,
+ maxTotalText,
0, 0,
NULL);
- memcpy(run.glyphs, text, MAX_TOTAL_TEXT * sizeof(uint16_t));
+ memcpy(run.glyphs, text.get(), maxTotalText * sizeof(uint16_t));
}
}
}
@@ -141,4 +149,16 @@ DEF_GPUTEST(TextBlobCache, reporter, factory) {
ctx->abandonContext();
draw(canvas, 1, blobs);
}
+
+DEF_GPUTEST(TextBlobCache, reporter, factory) {
+ text_blob_cache_inner(reporter, factory, 4096, 256, 30, true);
+}
+
+DEF_GPUTEST(TextBlobAbnormal, reporter, factory) {
+#ifdef SK_BUILD_FOR_ANDROID
+ text_blob_cache_inner(reporter, factory, 32, 32, 1, false);
+#else
+ text_blob_cache_inner(reporter, factory, 256, 256, 1, false);
+#endif
+}
#endif
« no previous file with comments | « src/gpu/GrBatchFontCache.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698