11#include "gtest/gtest.h"
37 lines_.emplace_back(p0, p1);
40 void drawTextFrame(
const std::shared_ptr<impeller::TextFrame>& text_frame,
43 text_frames_.push_back(text_frame);
49 blobs_.push_back(blob);
57 path_effect_ = effect;
60 std::vector<std::shared_ptr<impeller::TextFrame>> text_frames_;
61 std::vector<sk_sp<SkTextBlob>> blobs_;
62 std::vector<std::pair<SkPoint, SkPoint>> lines_;
63 std::vector<SkRect> rects_;
64 std::vector<SkPath> paths_;
80 t_style.font_size = 14;
82 t_style.decoration_style = style;
84 t_style.font_families.push_back(
"ahem");
92 t_style.font_size = 14;
93 t_style.font_families.push_back(
"ahem");
98 auto pb_skia = makeParagraphBuilder();
99 pb_skia.PushStyle(style);
100 pb_skia.AddText(u
"Hello World!");
104 auto paragraph = pb_skia.Build();
105 paragraph->Layout(10000);
106 paragraph->Paint(&builder, 0, 0);
108 return builder.Build();
112 std::shared_ptr<txt::FontCollection> makeFontCollection()
const {
113 auto f_collection = std::make_shared<txt::FontCollection>();
114 auto font_provider = std::make_unique<txt::TypefaceFontAssetProvider>();
116 font_provider->RegisterTypeface(font);
118 auto manager = sk_make_sp<txt::AssetFontManager>(std::move(font_provider));
119 f_collection->SetAssetFontManager(
manager);
125 auto f_collection = makeFontCollection();
129 bool impeller_ =
false;
135 PretendImpellerIsEnabled(
false);
139 ->Dispatch(recorder);
143 EXPECT_EQ(recorder.rectCount(), 1);
144 EXPECT_FALSE(recorder.hasPathEffect());
148 PretendImpellerIsEnabled(
false);
152 ->Dispatch(recorder);
155 EXPECT_EQ(recorder.lineCount(), 1);
159#ifdef IMPELLER_SUPPORTS_RENDERING
161 PretendImpellerIsEnabled(
true);
163 auto recorder = DlOpRecorder();
165 ->Dispatch(recorder);
169 EXPECT_EQ(recorder.rectCount(), 1);
170 EXPECT_FALSE(recorder.hasPathEffect());
174 PretendImpellerIsEnabled(
true);
176 auto recorder = DlOpRecorder();
178 ->Dispatch(recorder);
181 EXPECT_EQ(recorder.pathCount(), 1);
182 EXPECT_FALSE(recorder.hasPathEffect());
186 PretendImpellerIsEnabled(
true);
188 auto recorder = DlOpRecorder();
189 draw(makeStyle())->Dispatch(recorder);
191 EXPECT_EQ(recorder.textFrameCount(), 1);
192 EXPECT_EQ(recorder.blobCount(), 0);
196 PretendImpellerIsEnabled(
true);
198 auto style = makeStyle();
202 style.foreground = foreground;
204 auto recorder = DlOpRecorder();
205 draw(style)->Dispatch(recorder);
207 EXPECT_EQ(recorder.textFrameCount(), 0);
208 EXPECT_EQ(recorder.blobCount(), 0);
209 EXPECT_EQ(recorder.pathCount(), 1);
213 PretendImpellerIsEnabled(
true);
215 auto style = makeStyle();
219 std::vector<float> stops = {0.0, 1.0};
223 style.foreground = foreground;
225 auto recorder = DlOpRecorder();
226 draw(style)->Dispatch(recorder);
228 EXPECT_EQ(recorder.textFrameCount(), 0);
229 EXPECT_EQ(recorder.blobCount(), 0);
230 EXPECT_EQ(recorder.pathCount(), 1);
234 PretendImpellerIsEnabled(
false);
236 auto recorder = DlOpRecorder();
237 draw(makeStyle())->Dispatch(recorder);
239 EXPECT_EQ(recorder.textFrameCount(), 0);
240 EXPECT_EQ(recorder.blobCount(), 1);
constexpr SkColor SK_ColorBLACK
static void draw(SkCanvas *canvas, SkRect &target, int x, int y)
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.
A custom |DlOpReceiver| that records some |DlOps| it receives.
void drawTextFrame(const std::shared_ptr< impeller::TextFrame > &text_frame, SkScalar x, SkScalar y) override
bool hasPathEffect() const
void drawTextBlob(const sk_sp< SkTextBlob > blob, SkScalar x, SkScalar y) override
void drawLine(const SkPoint &p0, const SkPoint &p1) override
void drawRect(const SkRect &rect) override
void setPathEffect(const DlPathEffect *effect) override
void drawPath(const SkPath &path) override
int textFrameCount() const
txt::TextStyle makeStyle()
PainterTestBase()=default
txt::TextStyle makeDecoratedStyle(txt::TextDecorationStyle style)
sk_sp< DisplayList > draw(txt::TextStyle style) const
void PretendImpellerIsEnabled(bool impeller)
ParagraphBuilder implementation using Skia's text layout module.
PODArray< SkColor > colors
TEST_F(DisplayListTest, Defaults)
PainterTestBase<::testing::Test > PainterTest
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
static constexpr SkPoint Make(float x, float y)
static constexpr DlColor kRed()
static constexpr DlColor kCyan()
#define EXPECT_TRUE(handle)