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

Unified Diff: gm/fontcache.cpp

Issue 933313004: Update fontcache gm to actually stress font atlas (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 10 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gm/fontcache.cpp
diff --git a/gm/fontcache.cpp b/gm/fontcache.cpp
index 2aa70115dd67b8d7fc7f1010609687f246c0ce22..d5ead8c1215d789b69f134389a9ace637c732196 100644
--- a/gm/fontcache.cpp
+++ b/gm/fontcache.cpp
@@ -12,20 +12,6 @@
// GM to stress the GPU font cache
-const char* gFamilyNames[] = {
- "sans-serif", "serif"
-};
-
-const SkTypeface::Style gStyles[] = {
- SkTypeface::kNormal, SkTypeface::kItalic, SkTypeface::kBold
-};
-
-const SkScalar gTextSizes[] = {
- 192, 194, 196, 198, 200, 202, 204, 206
-};
-
-#define TYPEFACE_COUNT (SK_ARRAY_COUNT(gFamilyNames)*SK_ARRAY_COUNT(gStyles))
-
static SkScalar draw_string(SkCanvas* canvas, const SkString& text, SkScalar x,
SkScalar y, const SkPaint& paint) {
canvas->drawText(text.c_str(), text.size(), x, y, paint);
@@ -35,15 +21,13 @@ static SkScalar draw_string(SkCanvas* canvas, const SkString& text, SkScalar x,
class FontCacheGM : public skiagm::GM {
public:
FontCacheGM() {
- for (size_t i = 0; i < TYPEFACE_COUNT; ++i) {
- fTypefaces[i] = NULL;
- }
+ fTypefaces[0] = NULL;
+ fTypefaces[1] = NULL;
}
virtual ~FontCacheGM() {
- for (size_t i = 0; i < TYPEFACE_COUNT; ++i) {
- SkSafeUnref(fTypefaces[i]);
- }
+ SkSafeUnref(fTypefaces[0]);
+ SkSafeUnref(fTypefaces[1]);
}
protected:
@@ -56,40 +40,40 @@ protected:
}
void onOnceBeforeDraw() SK_OVERRIDE {
- int typefaceCount = 0;
- for (size_t i = 0; i < SK_ARRAY_COUNT(gFamilyNames); ++i) {
- for (size_t j = 0; j < SK_ARRAY_COUNT(gStyles); ++j) {
- fTypefaces[typefaceCount++] = sk_tool_utils::create_portable_typeface(gFamilyNames[i],
- gStyles[j]);
- }
- }
+ fTypefaces[0] = sk_tool_utils::create_portable_typeface("serif", SkTypeface::kItalic);
+ fTypefaces[1] = sk_tool_utils::create_portable_typeface("sans-serif", SkTypeface::kItalic);
}
void onDraw(SkCanvas* canvas) SK_OVERRIDE {
- SkScalar y = 32;
SkPaint paint;
paint.setAntiAlias(true);
paint.setLCDRenderText(true);
paint.setSubpixelText(true);
-
- SkString text("H");
-
- // draw enough to overflow the cache
- for (size_t i = 0; i < TYPEFACE_COUNT; ++i) {
- paint.setTypeface(fTypefaces[i]);
- SkScalar x = 20;
-
- for (size_t j = 0; j < SK_ARRAY_COUNT(gTextSizes); ++j) {
- paint.setTextSize(gTextSizes[j]);
- x = draw_string(canvas, text, x, y, paint) + 10;
- }
- y += 128;
- }
-
+ paint.setTypeface(fTypefaces[0]);
+ paint.setTextSize(192);
+
+ SkScalar x = 20;
+ SkScalar y = 128;
+ SkString text("ABCDEFGHIJ");
+ draw_string(canvas, text, x, y, paint);
+ y += 100;
+ SkString text2("KLMNOPQRS");
+ draw_string(canvas, text2, x, y, paint);
+ y += 100;
+ SkString text3("TUVWXYZ012");
+ draw_string(canvas, text3, x, y, paint);
+ y += 100;
+ paint.setTypeface(fTypefaces[1]);
+ draw_string(canvas, text, x, y, paint);
+ y += 100;
+ draw_string(canvas, text2, x, y, paint);
+ y += 100;
+ draw_string(canvas, text3, x, y, paint);
+ y += 100;
}
private:
- SkTypeface* fTypefaces[TYPEFACE_COUNT];
+ SkTypeface* fTypefaces[2];
typedef GM INHERITED;
};
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698