35 for (
int c =
' '; c <
'z'; c++) {
38 constexpr size_t glyphCount =
'z' -
' ';
41 for (
int lookups = 0; lookups < 10; lookups++) {
42 (void)
images.glyphs(glyphIDs);
53 fName.
printf(
"SkGlyphCacheBasic%dK", (
int)(fCacheSize >> 10));
66 font.setSubpixel(
true);
69 for (
int work = 0; work < loops; work++) {
77 const size_t fCacheSize;
87 fName.
printf(
"SkGlyphCacheStressTest%dK", (
int)(fCacheSize >> 10));
102 for (
int work = 0; work < loops; work++) {
106 font.setSubpixel(
true);
107 font.setTypeface(typefaces[threadIndex % 2]);
116 const size_t fCacheSize;
137 fLockedHandles.
add(++fNextHandleId);
138 return fNextHandleId;
143 if (
id <= fLastDeletedHandleId)
return false;
144 fLockedHandles.
add(
id);
152 return id <= fLastDeletedHandleId;
158 fCacheMissCount[
type]++;
163 return id <= fLastDeletedHandleId;
169 fLockedHandles.
reset();
174 fLockedHandles.
reset();
175 fLastDeletedHandleId = fNextHandleId;
180 return fLockedHandles;
185 return fNextHandleId;
190 return fCacheMissCount[
type];
195 for (uint32_t
i = 0;
i <= SkStrikeClient::CacheMissType::kLast; ++
i) {
196 if (fCacheMissCount[
i] > 0)
return true;
202 sk_bzero(&fCacheMissCount,
sizeof(fCacheMissCount));
209 mutable SkMutex fMutex;
214 int fCacheMissCount[SkStrikeClient::CacheMissType::kLast + 1u];
217class DiffCanvasBench :
public Benchmark {
219 std::function<std::unique_ptr<SkStreamAsset>()> fDataProvider;
220 std::vector<SkTextBlobTrace::Record> fTrace;
230 if (modelCanvas) { modelCanvas->
getProps(&props); }
231 std::unique_ptr<SkCanvas> canvas = fServer->makeAnalysisCanvas(1024, 1024, props,
232 nullptr,
true,
true);
234 while (loops --> 0) {
235 for (
const auto& record : fTrace) {
236 canvas->drawTextBlob(
237 record.blob.get(), record.offset.x(), record.offset.y(),record.paint);
243 auto stream = fDataProvider();
244 fDiscardableManager = sk_make_sp<DiscardableManager>();
245 fServer.
init(fDiscardableManager.
get());
251 : fBenchName(
std::move(n)), fDataProvider(
std::move(
f)) {}
257 return new DiffCanvasBench(std::move(
name), std::move(dataSrc));
261 SkString(
"SkDiffBench-lorem_ipsum"),
sk_bzero(glyphs, sizeof(glyphs))
std::unique_ptr< SkStreamAsset > GetResourceAsStream(const char *resource, bool useFileStream)
uint32_t SkDiscardableHandleId
static void do_font_stuff(SkFont *font)
Benchmark * CreateDiffCanvasBench(SkString name, std::function< std::unique_ptr< SkStreamAsset >()> dataSrc)
DEF_BENCH(return CreateDiffCanvasBench(SkString("SkDiffBench-lorem_ipsum"), [](){ return GetResourceAsStream("diff_canvas_traces/lorem_ipsum.trace");}))
@ kUnknown_SkPixelGeometry
virtual void onDraw(int loops, SkCanvas *)=0
virtual bool isSuitableFor(Backend backend)
virtual void onDelayedSetup()
virtual const char * onGetName()=0
void resetCacheMissCounts()
const THashSet< SkDiscardableHandleId > & lockedHandles() const
bool isHandleDeleted(SkDiscardableHandleId id) override
void unlockAndDeleteAll()
bool hasCacheMiss() const
bool deleteHandle(SkDiscardableHandleId id) override
void notifyCacheMiss(SkStrikeClient::CacheMissType type, int fontSize) override
int cacheMissCount(uint32_t type)
bool lockHandle(SkDiscardableHandleId id) override
SkDiscardableHandleId handleCount()
SkDiscardableHandleId createHandle() override
bool getProps(SkSurfaceProps *props) const
static constexpr SkFontStyle Italic()
@ kAntiAlias
may have transparent pixels on glyph edges
const char * onGetName() override
void onDraw(int loops, SkCanvas *) override
bool isSuitableFor(Backend backend) override
SkGlyphCacheBasic(size_t cacheSize)
SkGlyphCacheStressTest(int cacheSize)
void onDraw(int loops, SkCanvas *) override
const char * onGetName() override
bool isSuitableFor(Backend backend) override
static size_t GetFontCacheLimit()
static size_t SetFontCacheLimit(size_t bytes)
static const SkMatrix & I()
static SkStrikeSpec MakeMask(const SkFont &font, const SkPaint &paint, const SkSurfaceProps &surfaceProps, SkScalerContextFlags scalerContextFlags, const SkMatrix &deviceMatrix)
void printf(const char format[],...) SK_PRINTF_LIKE(2
const char * c_str() const
T * init(Args &&... args)
void batch(int N, std::function< void(int)> fn)
Dart_NativeFunction function
std::array< MockImage, 3 > images
std::vector< SkTextBlobTrace::Record > CreateBlobTrace(SkStream *stream, sk_sp< SkFontMgr > lastResortMgr)
DEF_SWITCHES_START aot vmservice shared library name
font
Font Metadata and Metrics.