Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
SkStrikeCacheTest.cpp
Go to the documentation of this file.
1/*
2 * Copyright 2020 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
16#include "src/core/SkStrike.h" // IWYU pragma: keep
19#include "tests/Test.h"
20#include "tools/ToolUtils.h"
22
23DEF_TEST(SkStrikeCache_CachePurge, Reporter) {
24 SkStrikeCache cache;
25
26 sk_sp<SkTypeface> typeface =
28
29 SkFont font;
30 font.setEdging(SkFont::Edging::kAntiAlias);
31 font.setSubpixel(true);
32 font.setTypeface(typeface);
33
34 SkPaint defaultPaint;
36 font, defaultPaint, SkSurfaceProps(0, kUnknown_SkPixelGeometry),
38
39 // Initially empty cache
40 REPORTER_ASSERT(Reporter, cache.getTotalMemoryUsed() == 0);
41
42 {
43 sk_sp<SkStrike> strike = strikeSpec.findOrCreateStrike(&cache);
44 }
45
46 // Stuff in cache.
47 REPORTER_ASSERT(Reporter, cache.getTotalMemoryUsed() > 0);
48
49 cache.purgeAll();
50
51 // Purged cache.
52 REPORTER_ASSERT(Reporter, cache.getTotalMemoryUsed() == 0);
53
54 // Smallest cache.
55 cache.setCacheSizeLimit(0);
56 {
57 sk_sp<SkStrike> strike = strikeSpec.findOrCreateStrike(&cache);
58 REPORTER_ASSERT(Reporter, cache.getTotalMemoryUsed() == 0);
59 }
60 REPORTER_ASSERT(Reporter, cache.getTotalMemoryUsed() == 0);
61
62
63}
@ kUnknown_SkPixelGeometry
#define DEF_TEST(name, reporter)
Definition Test.h:312
#define REPORTER_ASSERT(r, cond,...)
Definition Test.h:286
static constexpr SkFontStyle Italic()
Definition SkFontStyle.h:72
@ kAntiAlias
may have transparent pixels on glyph edges
static const SkMatrix & I()
static SkStrikeSpec MakeMask(const SkFont &font, const SkPaint &paint, const SkSurfaceProps &surfaceProps, SkScalerContextFlags scalerContextFlags, const SkMatrix &deviceMatrix)
sk_sp< SkStrike > findOrCreateStrike() const
sk_sp< SkTypeface > CreatePortableTypeface(const char *name, SkFontStyle style)