Force clients to specify font when requesting strikecache
Bug: skia:
Change-Id: If56222039239df085d6c40e835060e91fe70940b
Reviewed-on: https://skia-review.googlesource.com/c/173166
Reviewed-by: Herb Derby <herb@google.com>
Commit-Queue: Mike Reed <reed@google.com>
diff --git a/bench/SkGlyphCacheBench.cpp b/bench/SkGlyphCacheBench.cpp
index be99c9c..bb1f493 100644
--- a/bench/SkGlyphCacheBench.cpp
+++ b/bench/SkGlyphCacheBench.cpp
@@ -17,11 +17,12 @@
#include "sk_tool_utils.h"
-static void do_font_stuff(SkPaint* paint) {
+static void do_font_stuff(SkFont* font) {
+ SkPaint defaultPaint;
for (SkScalar i = 8; i < 64; i++) {
- paint->setTextSize(i);
+ font->setSize(i);
auto cache = SkStrikeCache::FindOrCreateStrikeExclusive(
- *paint, SkSurfaceProps(0, kUnknown_SkPixelGeometry),
+ *font, defaultPaint, SkSurfaceProps(0, kUnknown_SkPixelGeometry),
SkScalerContextFlags::kNone, SkMatrix::I());
uint16_t glyphs['z'];
for (int c = ' '; c < 'z'; c++) {
@@ -54,13 +55,13 @@
void onDraw(int loops, SkCanvas*) override {
size_t oldCacheLimitSize = SkGraphics::GetFontCacheLimit();
SkGraphics::SetFontCacheLimit(fCacheSize);
- SkPaint paint;
- paint.setAntiAlias(true);
- paint.setSubpixelText(true);
- paint.setTypeface(sk_tool_utils::create_portable_typeface("serif", SkFontStyle::Italic()));
+ SkFont font;
+ font.setEdging(SkFont::Edging::kAntiAlias);
+ font.setSubpixel(true);
+ font.setTypeface(sk_tool_utils::create_portable_typeface("serif", SkFontStyle::Italic()));
for (int work = 0; work < loops; work++) {
- do_font_stuff(&paint);
+ do_font_stuff(&font);
}
SkGraphics::SetFontCacheLimit(oldCacheLimitSize);
}
@@ -94,11 +95,11 @@
for (int work = 0; work < loops; work++) {
SkTaskGroup().batch(16, [&](int threadIndex) {
- SkPaint paint;
- paint.setAntiAlias(true);
- paint.setSubpixelText(true);
- paint.setTypeface(typefaces[threadIndex % 2]);
- do_font_stuff(&paint);
+ SkFont font;
+ font.setEdging(SkFont::Edging::kAntiAlias);
+ font.setSubpixel(true);
+ font.setTypeface(typefaces[threadIndex % 2]);
+ do_font_stuff(&font);
});
}
SkGraphics::SetFontCacheLimit(oldCacheLimitSize);