11#include "gtest/gtest.h"
24 "Apple Color Emoji.ttc";
54 lines_.emplace_back(p0, p1);
57 void drawDashedLine(
const DlPoint& p0,
61 dashed_lines_.emplace_back(p0, p1,
DlPoint(on_length, off_length));
64 void drawTextFrame(
const std::shared_ptr<impeller::TextFrame>& text_frame,
67 text_frames_.push_back(text_frame);
73 blobs_.push_back(blob);
76 void drawRect(
const SkRect&
rect)
override { rects_.push_back(
rect); }
78 void drawPath(
const SkPath&
path)
override { paths_.push_back(
path); }
80 std::vector<std::shared_ptr<impeller::TextFrame>> text_frames_;
81 std::vector<sk_sp<SkTextBlob>> blobs_;
82 std::vector<std::pair<SkPoint, SkPoint>> lines_;
83 std::vector<std::tuple<DlPoint, DlPoint, DlPoint>> dashed_lines_;
84 std::vector<SkRect> rects_;
85 std::vector<SkPath> paths_;
100 t_style.font_size = 14;
102 t_style.decoration_style = style;
104 t_style.font_families.push_back(
"ahem");
112 t_style.font_size = 14;
121 t_style.font_size = 14;
122 t_style.font_families.push_back(
"ahem");
127 auto pb_skia = makeParagraphBuilder();
128 pb_skia.PushStyle(style);
129 pb_skia.AddText(
text);
133 auto paragraph = pb_skia.Build();
134 paragraph->Layout(10000);
135 paragraph->Paint(&
builder, 0, 0);
141 auto pb_skia = makeParagraphBuilder();
142 pb_skia.PushStyle(style);
143 pb_skia.AddText(u
"Hello World!");
147 auto paragraph = pb_skia.Build();
148 paragraph->Layout(10000);
149 paragraph->Paint(&
builder, 0, 0);
155 std::shared_ptr<txt::FontCollection> makeFontCollection()
const {
156 auto f_collection = std::make_shared<txt::FontCollection>();
157 auto font_provider = std::make_unique<txt::TypefaceFontAssetProvider>();
159 font_provider->RegisterTypeface(
font);
167 font_provider->RegisterTypeface(typeface);
170 auto manager = sk_make_sp<txt::AssetFontManager>(std::move(font_provider));
171 f_collection->SetAssetFontManager(
manager);
177 auto f_collection = makeFontCollection();
181 bool impeller_ =
false;
187 PretendImpellerIsEnabled(
false);
191 ->Dispatch(recorder);
195 EXPECT_EQ(recorder.rectCount(), 1);
199 PretendImpellerIsEnabled(
false);
203 ->Dispatch(recorder);
206 EXPECT_EQ(recorder.lineCount(), 0);
207 EXPECT_EQ(recorder.dashedLineCount(), 1);
210#ifdef IMPELLER_SUPPORTS_RENDERING
212 PretendImpellerIsEnabled(
true);
214 auto recorder = DlOpRecorder();
216 ->Dispatch(recorder);
220 EXPECT_EQ(recorder.rectCount(), 1);
224 PretendImpellerIsEnabled(
true);
226 auto recorder = DlOpRecorder();
228 ->Dispatch(recorder);
231 EXPECT_EQ(recorder.pathCount(), 0);
232 EXPECT_EQ(recorder.dashedLineCount(), 1);
236 PretendImpellerIsEnabled(
true);
238 auto recorder = DlOpRecorder();
239 draw(makeStyle())->Dispatch(recorder);
241 EXPECT_EQ(recorder.textFrameCount(), 1);
242 EXPECT_EQ(recorder.blobCount(), 0);
246 PretendImpellerIsEnabled(
true);
248 auto style = makeStyle();
252 style.foreground = foreground;
254 auto recorder = DlOpRecorder();
255 draw(style)->Dispatch(recorder);
257 EXPECT_EQ(recorder.textFrameCount(), 1);
258 EXPECT_EQ(recorder.blobCount(), 0);
259 EXPECT_EQ(recorder.pathCount(), 0);
263 PretendImpellerIsEnabled(
true);
265 auto style = makeStyle();
269 std::vector<float> stops = {0.0, 1.0};
273 style.foreground = foreground;
275 auto recorder = DlOpRecorder();
276 draw(style)->Dispatch(recorder);
278 EXPECT_EQ(recorder.textFrameCount(), 0);
279 EXPECT_EQ(recorder.blobCount(), 0);
280 EXPECT_EQ(recorder.pathCount(), 1);
284 PretendImpellerIsEnabled(
true);
286 auto style = makeEmoji();
290 std::vector<float> stops = {0.0, 1.0};
294 style.foreground = foreground;
296 auto recorder = DlOpRecorder();
297 drawText(style, u
"😀 😃 😄 😁 😆 😅 😂 🤣 🥲 😊")->Dispatch(recorder);
299 EXPECT_EQ(recorder.textFrameCount(), 1);
300 EXPECT_EQ(recorder.blobCount(), 0);
301 EXPECT_EQ(recorder.pathCount(), 0);
305 PretendImpellerIsEnabled(
false);
307 auto recorder = DlOpRecorder();
308 draw(makeStyle())->Dispatch(recorder);
310 EXPECT_EQ(recorder.textFrameCount(), 0);
311 EXPECT_EQ(recorder.blobCount(), 1);
constexpr SkColor SK_ColorBLACK
static void draw(SkCanvas *canvas, SkRect &target, int x, int y)
sk_sp< SkTypeface > makeFromData(sk_sp< SkData >, int ttcIndex=0) const
static std::shared_ptr< DlLinearGradientColorSource > MakeLinear(const SkPoint start_point, const SkPoint end_point, uint32_t stop_count, const DlColor *colors, const float *stops, DlTileMode tile_mode, const SkMatrix *matrix=nullptr)
Internal API for rendering recorded display lists to backends.
DlPaint & setDrawStyle(DlDrawStyle style)
A custom |DlOpReceiver| that records some |DlOps| it receives.
int dashedLineCount() const
int textFrameCount() const
txt::TextStyle makeStyle()
txt::TextStyle makeEmoji()
PainterTestBase()=default
txt::TextStyle makeDecoratedStyle(txt::TextDecorationStyle style)
sk_sp< DisplayList > draw(txt::TextStyle style) const
void PretendImpellerIsEnabled(bool impeller)
sk_sp< DisplayList > drawText(txt::TextStyle style, std::u16string text) const
ParagraphBuilder implementation using Skia's text layout module.
sk_sp< SkBlender > blender SkRect rect
PODArray< SkColor > colors
static const std::string kEmojiFontName
TEST_F(DisplayListTest, Defaults)
sk_sp< SkData > OpenFixtureAsSkData(const std::string &fixture_name)
Opens a fixture of the given file name and returns a Skia SkData holding its contents.
PainterTestBase<::testing::Test > PainterTest
static const std::string kEmojiFontFile
impeller::Scalar DlScalar
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 manager
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
@ kStroke
strokes boundary of shapes
std::vector< sk_sp< SkTypeface > > GetTestFontData()
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 The size limit in megabytes for the Dart VM old gen heap space enable impeller
font
Font Metadata and Metrics.
sk_sp< SkFontMgr > GetDefaultFontManager(uint32_t font_initialization_data)
static constexpr SkPoint Make(float x, float y)
static constexpr DlColor kRed()
static constexpr DlColor kCyan()