42 std::shared_ptr<DlMaskFilter>
filter;
48 const std::string&
text,
49 const std::string_view& font_fixture,
51 const std::optional<SkFont>& font = std::nullopt) {
61 canvas.
DrawCircle(options.position, 5.0, paint);
65 if (!font.has_value()) {
66 auto c_font_fixture = std::string(font_fixture);
73 selected_font = SkFont(font_mgr->makeFromData(mapping), options.font_size);
74 if (options.is_subpixel) {
75 selected_font.setSubpixel(
true);
78 selected_font = font.value();
80 auto blob = SkTextBlob::MakeFromString(
text.c_str(), selected_font);
92 text_paint.
setDrawStyle(options.stroke ? DlDrawStyle::kStroke
95 options.position.y, text_paint);
106 GetContext(), builder,
"the quick brown fox jumped over the lazy dog!.?",
107 "Roboto-Regular.ttf"));
109 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
119 builder.
Scale(-1, 1);
122 GetContext(), builder,
"the quick brown fox jumped over the lazy dog!.?",
123 "Roboto-Regular.ttf"));
125 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
136 GetContext(), builder,
"the quick brown fox jumped over the lazy dog!.?",
137 "Roboto-Regular.ttf",
141 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
157 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
166 builder.
Scale(0.5, 0.5);
169 GetContext(), builder,
"the quick brown fox jumped over the lazy dog!.?",
170 "Roboto-Regular.ttf"));
171 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
180 for (
int i = 0;
i < 6; ++
i) {
183 Scalar scale = 0.445 - (
i / 1000.f);
184 builder.
Scale(scale, scale);
186 GetContext(), builder,
"k",
"Roboto-Regular.ttf",
189 GetContext(), builder,
"k",
"Roboto-Regular.ttf",
193 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
199 auto callback = [&]() -> sk_sp<DisplayList> {
201 ImGuiWindowFlags_AlwaysAutoResize)) {
202 ImGui::SliderFloat(
"Scale", &scale, 4, 20);
211 builder.
Scale(scale, scale);
213 GetContext(), builder,
"HELLO",
"Roboto-Regular.ttf",
218 return builder.
Build();
221 ASSERT_TRUE(OpenPlaygroundHere(
callback));
228 auto callback = [&]() -> sk_sp<DisplayList> {
230 ImGuiWindowFlags_AlwaysAutoResize)) {
231 ImGui::SliderFloat(
"scale", &scale, 1.f, 300.f);
232 ImGui::SliderFloat(
"offsetx", &offsetx, -600.f, 100.f);
233 ImGui::SliderFloat(
"offsety", &offsety, 600.f, 2048.f);
237 builder.
Scale(GetContentScale().
x, GetContentScale().
y);
241 builder.
Scale(scale, scale);
244 GetContext(), builder,
"test",
"Roboto-Regular.ttf",
248 return builder.
Build();
250 ASSERT_TRUE(OpenPlaygroundHere(
callback));
256 auto callback = [&]() -> sk_sp<DisplayList> {
258 ImGuiWindowFlags_AlwaysAutoResize)) {
259 ImGui::SliderFloat(
"Fine Scale", &fine_scale, -1, 1);
268 Scalar scale = 2.625 + fine_scale;
269 builder.
Scale(scale, scale);
271 "the quick brown fox jumped over the lazy dog!.?",
272 "Roboto-Regular.ttf",
274 return builder.
Build();
277 ASSERT_TRUE(OpenPlaygroundHere(
callback));
282 float fpivot[2] = {200 + 30, 200 - 20};
283 float rotation = 180;
284 float foffset[2] = {200, 200};
286 auto callback = [&]() -> sk_sp<DisplayList> {
288 ImGuiWindowFlags_AlwaysAutoResize)) {
289 ImGui::SliderFloat(
"pivotx", &fpivot[0], 0, 300);
290 ImGui::SliderFloat(
"pivoty", &fpivot[1], 0, 300);
291 ImGui::SliderFloat(
"rotation", &rotation, 0, 360);
292 ImGui::SliderFloat(
"foffsetx", &foffset[0], 0, 300);
293 ImGui::SliderFloat(
"foffsety", &foffset[1], 0, 300);
297 builder.
Scale(GetContentScale().
x, GetContentScale().
y);
309 .position =
DlPoint(foffset[0], foffset[1]),
313 return builder.
Build();
315 ASSERT_TRUE(OpenPlaygroundHere(
callback));
320 std::array<Scalar, 20> phase_offsets = {
321 7.82637e-06, 0.131538, 0.755605, 0.45865, 0.532767,
322 0.218959, 0.0470446, 0.678865, 0.679296, 0.934693,
323 0.383502, 0.519416, 0.830965, 0.0345721, 0.0534616,
324 0.5297, 0.671149, 0.00769819, 0.383416, 0.0668422};
325 auto callback = [&]() -> sk_sp<DisplayList> {
327 static float phase_variation = 0.2;
328 static float speed = 0.5;
329 static float magnitude = 100;
331 ImGuiWindowFlags_AlwaysAutoResize)) {
332 ImGui::SliderFloat(
"Font size", &
font_size, 5, 50);
333 ImGui::SliderFloat(
"Phase variation", &phase_variation, 0, 1);
334 ImGui::SliderFloat(
"Oscillation speed", &speed, 0, 2);
335 ImGui::SliderFloat(
"Oscillation magnitude", &magnitude, 0, 300);
340 builder.
Scale(GetContentScale().
x, GetContentScale().
y);
342 for (
size_t i = 0;
i < phase_offsets.size();
i++) {
345 magnitude * std::sin((-phase_offsets[
i] *
k2Pi * phase_variation +
346 GetSecondsElapsed() * speed)),
350 GetContext(), builder,
351 "the quick brown fox jumped over "
353 "Roboto-Regular.ttf",
354 {.font_size =
font_size, .position = position})) {
358 return builder.
Build();
361 ASSERT_TRUE(OpenPlaygroundHere(
callback));
372 GetContext(), builder,
"the quick brown fox jumped over the lazy dog!.?",
373 "HomemadeApple.ttf"));
374 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
379 "Apple Color Emoji.ttc";
381 "NotoColorEmoji.ttf";
392 GetContext(), builder,
"😀 😃 😄 😁 😆 😅 😂 🤣 🥲 😊",
kFontFixture));
393 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
399 builder.
Scale(GetContentScale().
x, GetContentScale().
y);
405 GetContext(), builder,
"😀 😃 😄 😁 😆 😅 😂 🤣 🥲 😊",
kFontFixture,
409 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
420 GetContext(), builder,
"😀 😃 😄 😁 😆 😅 😂 🤣 🥲 😊",
kFontFixture,
422 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
433 builder.
Scale(0.5, 0.5);
439 GetContext(), builder,
"the quick brown fox jumped over the lazy dog!.?",
440 "Roboto-Regular.ttf"));
445 GetContext(), builder,
"the quick brown fox jumped over the lazy dog!.?",
446 "Roboto-Regular.ttf"));
448 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
457 ASSERT_NE(mapping,
nullptr);
461 SkFont sk_font(font_mgr->makeFromData(mapping),
font_size);
474 for (
auto& t :
text) {
479 auto blob = SkTextBlob::MakeFromString(t.text, sk_font);
480 ASSERT_NE(blob,
nullptr);
487 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
493 builder.
Scale(GetContentScale().
x, GetContentScale().
y);
503 GetContext(), builder,
"the quick brown fox jumped over the lazy dog!.?",
504 "Roboto-Regular.ttf"));
506 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
515 0.0, 0.0, 0.0, 1.0) *
521 "Roboto-Regular.ttf"));
522 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
531 0.0, 0.0, 0.0, 1.0) *
538 builder.
SaveLayer(window_bounds, &save_paint);
542 "Roboto-Regular.ttf"));
545 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
555 builder.
SaveLayer(std::nullopt, &save_paint);
563 "Roboto-Regular.ttf"));
564 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
570 "Roboto-Regular.ttf"));
571 auto text_display_list = text_builder.
Build();
578 0.0, 0.002, 0.0, 1.0);
583 builder.
SaveLayer(window_bounds, &save_paint);
588 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
596 ASSERT_NE(mapping,
nullptr);
600 SkFont sk_font(font_mgr->makeFromData(mapping),
font_size);
605 std::vector<DlColor> colors = {
DlColor::RGBA(0.9568, 0.2627, 0.2118, 1.0),
607 std::vector<Scalar> stops = {
624 auto blob = SkTextBlob::MakeFromString(
"Hello", sk_font);
625 ASSERT_NE(blob,
nullptr);
629 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
637 DlColor clear_color(1.0, 0.5, 0.5, 0.5, DlColorSpace::kSRGB);
642 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0,
643 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0,
649 DlColor white(1.0, 1.0, 1.0, 1.0, DlColorSpace::kSRGB);
654 builder.
ClipRect(frame, DlClipOp::kIntersect);
657 0.8241262, 0.56640625, 0.0, 0.0, -0.56640625, 0.8241262, 0.0, 0.0,
658 0.0, 0.0, 1.0, 0.0, 271.1137, 489.4733, 0.0, 1.0,
664 DlColor bluish(1.0, 0.184, 0.501, 0.929, DlColorSpace::kSRGB);
670 builder.
ClipRect(rect, DlClipOp::kIntersect);
676 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0,
677 0.0, 0.0, 1.0, 0.0, 675.0, 279.5, 0.0, 1.0,
688 path_builder.
Close();
691 DlColor fill_color(1.0, 1.0, 0.0, 0.0, DlColorSpace::kSRGB);
692 DlColor stroke_color(1.0, 0.0, 0.0, 0.0, DlColorSpace::kSRGB);
706 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
711 std::make_shared<TypographerContextSkia>());
715 constexpr const char* font_fixture =
"Roboto-Regular.ttf";
718 auto c_font_fixture = std::string(font_fixture);
720 ASSERT_TRUE(mapping);
723 SkFont sk_font(font_mgr->makeFromData(mapping), 16);
725 auto blob = SkTextBlob::MakeFromString(
"Hello World", sk_font);
737 .GetMaxBasisLengthXY());
752 ->CreateOffscreenMSAA(*aiks_context.
GetContext(), {100, 100}, 1);
760 Matrix not_preroll_matrix =
766 std::shared_ptr<CommandBuffer> command_buffer =
767 aiks_context.
GetContext()->CreateCommandBuffer();
768 std::shared_ptr<RenderPass> render_pass =
769 command_buffer->CreateRenderPass(render_target);
777 builder.
Scale(GetContentScale().
x, GetContentScale().
y);
783 std::make_shared<TypographerContextSkia>());
807 builder.
Scale(GetContentScale().
x, GetContentScale().
y);
813 std::make_shared<TypographerContextSkia>());
820 for (
auto i = 0;
i < 5;
i++) {
840 builder.
Scale(GetContentScale().
x, GetContentScale().
y);
846 std::make_shared<TypographerContextSkia>());
857 for (
const auto& color : colors) {
878 builder.
Scale(GetContentScale().
x, GetContentScale().
y);
884 std::make_shared<TypographerContextSkia>());
894 ASSERT_TRUE(mapping);
896 SkFont sk_font(font_mgr->makeFromData(mapping), 50);
898 for (
auto i = 0;
i < 10;
i++) {
921 builder.
Scale(GetContentScale().
x, GetContentScale().
y);
923 std::vector<Scalar> scales = {4, 8, 16, 24, 32};
924 std::vector<Scalar> spacing = {8, 8, 8, 8, 8};
927 for (
auto i = 0u;
i < scales.size();
i++) {
929 builder.
Scale(scales[
i], scales[
i]);
931 GetContext(), builder,
"lo",
"Roboto-Regular.ttf",
940 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
void ClipRect(const DlRect &rect, DlClipOp clip_op=DlClipOp::kIntersect, bool is_aa=false) override
void DrawRoundRect(const DlRoundRect &rrect, const DlPaint &paint) override
void DrawCircle(const DlPoint ¢er, DlScalar radius, const DlPaint &paint) override
void SaveLayer(const std::optional< DlRect > &bounds, const DlPaint *paint=nullptr, const DlImageFilter *backdrop=nullptr, std::optional< int64_t > backdrop_id=std::nullopt) override
void Rotate(DlScalar degrees) override
void DrawText(const std::shared_ptr< DlText > &text, DlScalar x, DlScalar y, const DlPaint &paint) override
void Scale(DlScalar sx, DlScalar sy) override
void DrawDisplayList(const sk_sp< DisplayList > display_list, DlScalar opacity=SK_Scalar1) override
void Translate(DlScalar tx, DlScalar ty) override
void DrawPaint(const DlPaint &paint) override
sk_sp< DisplayList > Build()
void DrawPath(const DlPath &path, const DlPaint &paint) override
void Transform(const DlMatrix &matrix) override
void DrawRect(const DlRect &rect, const DlPaint &paint) override
static std::shared_ptr< DlMaskFilter > Make(DlBlurStyle style, SkScalar sigma, bool respect_ctm=true)
static std::shared_ptr< DlColorSource > MakeLinear(const DlPoint start_point, const DlPoint end_point, uint32_t stop_count, const DlColor *colors, const float *stops, DlTileMode tile_mode, const DlMatrix *matrix=nullptr)
DlPaint & setColor(DlColor color)
DlPaint & setStrokeWidth(float width)
DlPaint & setBlendMode(DlBlendMode mode)
DlPaint & setMaskFilter(std::nullptr_t filter)
DlPaint & setDrawStyle(DlDrawStyle style)
DlPaint & setColorSource(std::nullptr_t source)
DlPathBuilder & LineTo(DlPoint p2)
Draw a line from the current point to the indicated point p2.
DlPathBuilder & MoveTo(DlPoint p2)
Start a new contour that will originate at the indicated point p2.
const DlPath TakePath()
Returns the path constructed by this path builder and resets its internal state to the default state ...
DlPathBuilder & Close()
The path is closed back to the location of the most recent MoveTo call. Contours that are filled are ...
static std::shared_ptr< DlTextImpeller > Make(const std::shared_ptr< impeller::TextFrame > &frame)
ContentContext & GetContentContext() const
std::shared_ptr< Context > GetContext() const
static bool ImGuiBegin(const char *name, bool *p_open, ImGuiWindowFlags flags)
const std::shared_ptr< RenderTargetAllocator > & GetRenderTargetCache() const
const std::shared_ptr< LazyGlyphAtlas > & GetLazyGlyphAtlas() const
TextShadowCache & GetTextShadowCache() const
void SetTransform(const Matrix &transform)
Set the global transform matrix for this Entity.
void SetOffset(Vector2 offset)
bool Render(const ContentContext &renderer, const Entity &entity, RenderPass &pass) const override
void SetTextFrame(const std::shared_ptr< TextFrame > &frame)
void SetScale(Scalar scale)
void SetColor(Color color)
static Rational RoundScaledFontSize(Scalar scale)
size_t GetCacheSizeForTesting() const
FlutterDesktopBinaryReply callback
SkFont CreateTestFontOfSize(DlScalar scalar)
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.
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
@ kFill
fills interior of shapes
bool RenderTextInCanvasSkia(const std::shared_ptr< Context > &context, DisplayListBuilder &canvas, const std::string &text, const std::string_view &font_fixture, const TextRenderOptions &options={}, const std::optional< SkFont > &font=std::nullopt)
TEST_P(AiksTest, DrawAtlasNoColor)
static constexpr std::string_view kFontFixture
std::shared_ptr< Texture > DisplayListToTexture(const sk_sp< flutter::DisplayList > &display_list, ISize size, AiksContext &context, bool reset_host_buffer, bool generate_mips)
Render the provided display list to a texture with the given size.
std::shared_ptr< TextFrame > MakeTextFrameFromTextBlobSkia(const sk_sp< SkTextBlob > &blob)
sk_sp< SkFontMgr > GetDefaultFontManager(uint32_t font_initialization_data)
static constexpr DlColor kWhite()
static constexpr DlColor kBlue()
static constexpr DlColor RGBA(DlScalar r, DlScalar g, DlScalar b, DlScalar a)
Construct a 32 bit color from floating point R, G, B, and A color channels.
static constexpr DlColor kBlack()
static constexpr DlColor ARGB(DlScalar a, DlScalar r, DlScalar g, DlScalar b)
Construct a 32 bit color from floating point A, R, G, and B color channels.
static constexpr DlColor kAqua()
static constexpr DlColor kYellow()
static constexpr DlColor kRed()
static constexpr DlColor kGreen()
static constexpr DlColor kOrange()
constexpr DlColor modulateOpacity(DlScalar opacity) const
static constexpr Color Aqua()
A 4x4 matrix using column-major storage.
static constexpr Matrix MakeTranslation(const Vector3 &t)
static Matrix MakeRotationY(Radians r)
static constexpr Matrix MakeRow(Scalar m0, Scalar m1, Scalar m2, Scalar m3, Scalar m4, Scalar m5, Scalar m6, Scalar m7, Scalar m8, Scalar m9, Scalar m10, Scalar m11, Scalar m12, Scalar m13, Scalar m14, Scalar m15)
static constexpr Matrix MakeTranslateScale(const Vector3 &s, const Vector3 &t)
static RoundRect MakeRectRadius(const Rect &rect, Scalar radius)
static constexpr TRect MakeXYWH(Type x, Type y, Type width, Type height)
static constexpr TRect MakeLTRB(Type left, Type top, Type right, Type bottom)
std::shared_ptr< DlMaskFilter > filter