Flutter Engine
The Flutter Engine
Classes | Static Public Member Functions | List of all members
TextBlobTester Class Reference

Static Public Member Functions

static void TestBuilder (skiatest::Reporter *reporter)
 
static void TestBounds (skiatest::Reporter *reporter)
 
static void TestPaintProps (skiatest::Reporter *reporter)
 

Detailed Description

Definition at line 42 of file TextBlobTest.cpp.

Member Function Documentation

◆ TestBounds()

static void TextBlobTester::TestBounds ( skiatest::Reporter reporter)
inlinestatic

Definition at line 127 of file TextBlobTest.cpp.

127 {
130
131 // Explicit bounds.
132 {
133 sk_sp<SkTextBlob> blob(builder.make());
135 }
136
137 {
138 SkRect r1 = SkRect::MakeXYWH(10, 10, 20, 20);
139 builder.allocRun(font, 16, 0, 0, &r1);
140 sk_sp<SkTextBlob> blob(builder.make());
141 REPORTER_ASSERT(reporter, blob->bounds() == r1);
142 }
143
144 {
145 SkRect r1 = SkRect::MakeXYWH(10, 10, 20, 20);
146 builder.allocRunPosH(font, 16, 0, &r1);
147 sk_sp<SkTextBlob> blob(builder.make());
148 REPORTER_ASSERT(reporter, blob->bounds() == r1);
149 }
150
151 {
152 SkRect r1 = SkRect::MakeXYWH(10, 10, 20, 20);
153 builder.allocRunPos(font, 16, &r1);
154 sk_sp<SkTextBlob> blob(builder.make());
155 REPORTER_ASSERT(reporter, blob->bounds() == r1);
156 }
157
158 {
159 SkRect r1 = SkRect::MakeXYWH(10, 10, 20, 20);
160 SkRect r2 = SkRect::MakeXYWH(15, 20, 50, 50);
161 SkRect r3 = SkRect::MakeXYWH(0, 5, 10, 5);
162
163 builder.allocRun(font, 16, 0, 0, &r1);
164 builder.allocRunPosH(font, 16, 0, &r2);
165 builder.allocRunPos(font, 16, &r3);
166
167 sk_sp<SkTextBlob> blob(builder.make());
168 REPORTER_ASSERT(reporter, blob->bounds() == SkRect::MakeXYWH(0, 5, 65, 65));
169 }
170
171 {
172 sk_sp<SkTextBlob> blob(builder.make());
174 }
175
176 // Implicit bounds
177
178 {
179 // Exercise the empty bounds path, and ensure that RunRecord-aligned pos buffers
180 // don't trigger asserts (http://crbug.com/542643).
181 font.setSize(0);
182
183 const char* txt = "BOOO";
184 const size_t txtLen = strlen(txt);
185 const int glyphCount = font.countText(txt, txtLen, SkTextEncoding::kUTF8);
186 const SkTextBlobBuilder::RunBuffer& buffer = builder.allocRunPos(font, glyphCount);
187
188 font.textToGlyphs(txt, txtLen, SkTextEncoding::kUTF8, buffer.glyphs, glyphCount);
189
190 memset(buffer.pos, 0, sizeof(SkScalar) * glyphCount * 2);
191 sk_sp<SkTextBlob> blob(builder.make());
192 REPORTER_ASSERT(reporter, blob->bounds().isEmpty());
193 }
194 }
reporter
Definition: FontMgrTest.cpp:39
@ kUTF8
uses bytes to represent UTF-8 or ASCII
#define REPORTER_ASSERT(r, cond,...)
Definition: Test.h:286
Definition: SkFont.h:35
float SkScalar
Definition: extension.cpp:12
SkFont DefaultFont()
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir Path to the cache directory This is different from the persistent_cache_path in embedder which is used for Skia shader cache icu native lib Path to the library file that exports the ICU data vm service The hostname IP address on which the Dart VM Service should be served If not defaults to or::depending on whether ipv6 is specified vm service A custom Dart VM Service port The default is to pick a randomly available open port disable vm Disable the Dart VM Service The Dart VM Service is never available in release mode disable vm service Disable mDNS Dart VM Service publication Bind to the IPv6 localhost address for the Dart VM Service Ignored if vm service host is set endless trace buffer
Definition: switches.h:126
font
Font Metadata and Metrics.
static constexpr SkRect MakeXYWH(float x, float y, float w, float h)
Definition: SkRect.h:659

◆ TestBuilder()

static void TextBlobTester::TestBuilder ( skiatest::Reporter reporter)
inlinestatic

Definition at line 46 of file TextBlobTest.cpp.

46 {
48
49 // empty run set
50 RunBuilderTest(reporter, builder, nullptr, 0, nullptr, 0);
51
52 RunDef set1[] = {
54 };
55 RunBuilderTest(reporter, builder, set1, std::size(set1), set1, std::size(set1));
56
57 RunDef set2[] = {
59 };
60 RunBuilderTest(reporter, builder, set2, std::size(set2), set2, std::size(set2));
61
62 RunDef set3[] = {
64 };
65 RunBuilderTest(reporter, builder, set3, std::size(set3), set3, std::size(set3));
66
67 RunDef set4[] = {
71 };
72 RunBuilderTest(reporter, builder, set4, std::size(set4), set4, std::size(set4));
73
74 RunDef set5[] = {
78 };
79 RunDef mergedSet5[] = {
82 };
83 RunBuilderTest(reporter, builder, set5, std::size(set5), mergedSet5,
84 std::size(mergedSet5));
85
86 RunDef set6[] = {
90 };
91 RunDef mergedSet6[] = {
93 };
94 RunBuilderTest(reporter, builder, set6, std::size(set6), mergedSet6,
95 std::size(mergedSet6));
96
97 RunDef set7[] = {
110 };
111 RunDef mergedSet7[] = {
121 };
122 RunBuilderTest(reporter, builder, set7, std::size(set7), mergedSet7,
123 std::size(mergedSet7));
124 }
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size
Definition: switches.h:259

◆ TestPaintProps()

static void TextBlobTester::TestPaintProps ( skiatest::Reporter reporter)
inlinestatic

Definition at line 197 of file TextBlobTest.cpp.

197 {
198 SkFont font;
199 // Kitchen sink font.
200 font.setSize(42);
201 font.setScaleX(4.2f);
203 font.setSkewX(0.42f);
204 font.setHinting(SkFontHinting::kFull);
206 font.setEmbolden(true);
207 font.setLinearMetrics(true);
208 font.setSubpixel(true);
209 font.setEmbeddedBitmaps(true);
210 font.setForceAutoHinting(true);
211
212 // Ensure we didn't pick default values by mistake.
213 SkFont defaultFont = ToolUtils::DefaultFont();
214 REPORTER_ASSERT(reporter, defaultFont.getSize() != font.getSize());
215 REPORTER_ASSERT(reporter, defaultFont.getScaleX() != font.getScaleX());
216 REPORTER_ASSERT(reporter, defaultFont.getTypeface() != font.getTypeface());
217 REPORTER_ASSERT(reporter, defaultFont.getSkewX() != font.getSkewX());
218 REPORTER_ASSERT(reporter, defaultFont.getHinting() != font.getHinting());
219 REPORTER_ASSERT(reporter, defaultFont.getEdging() != font.getEdging());
220 REPORTER_ASSERT(reporter, defaultFont.isEmbolden() != font.isEmbolden());
221 REPORTER_ASSERT(reporter, defaultFont.isLinearMetrics() != font.isLinearMetrics());
222 REPORTER_ASSERT(reporter, defaultFont.isSubpixel() != font.isSubpixel());
224 defaultFont.isEmbeddedBitmaps() != font.isEmbeddedBitmaps());
225 REPORTER_ASSERT(reporter, defaultFont.isForceAutoHinting() != font.isForceAutoHinting());
226
230 builder);
232 sk_sp<SkTextBlob> blob(builder.make());
233
234 SkTextBlobRunIterator it(blob.get());
235 while (!it.done()) {
236 REPORTER_ASSERT(reporter, it.font() == font);
237 it.next();
238 }
239
240 }
@ kFull
modifies glyph outlines for maximum constrast
static constexpr SkFontStyle Bold()
Definition: SkFontStyle.h:69
bool isEmbolden() const
Definition: SkFont.h:126
Edging getEdging() const
Definition: SkFont.h:180
SkTypeface * getTypeface() const
Definition: SkFont.h:208
SkScalar getSize() const
Definition: SkFont.h:217
SkFontHinting getHinting() const
Definition: SkFont.h:194
bool isForceAutoHinting() const
Definition: SkFont.h:101
bool isLinearMetrics() const
Definition: SkFont.h:119
bool isEmbeddedBitmaps() const
Definition: SkFont.h:107
SkScalar getScaleX() const
Definition: SkFont.h:224
SkScalar getSkewX() const
Definition: SkFont.h:231
bool isSubpixel() const
Definition: SkFont.h:113
@ kSubpixelAntiAlias
glyph positioned in pixel using transparency
sk_sp< SkTypeface > CreatePortableTypeface(const char *name, SkFontStyle style)
static constexpr SkPoint Make(float x, float y)
Definition: SkPoint_impl.h:173

The documentation for this class was generated from the following file: