10#include "flutter/display_list/dl_blend_mode.h"
11#include "flutter/display_list/dl_builder.h"
12#include "flutter/display_list/dl_color.h"
13#include "flutter/display_list/dl_paint.h"
14#include "flutter/display_list/dl_tile_mode.h"
15#include "flutter/display_list/effects/dl_color_filter.h"
16#include "flutter/display_list/effects/dl_color_source.h"
17#include "flutter/display_list/effects/dl_image_filter.h"
18#include "flutter/display_list/effects/dl_mask_filter.h"
19#include "flutter/testing/testing.h"
20#include "gtest/gtest.h"
32#include "third_party/imgui/imgui.h"
43 Color(components[0], components[1], components[2], components[3])));
53 ASSERT_TRUE(OpenPlaygroundHere(
builder.Build()));
60 ASSERT_TRUE(OpenPlaygroundHere(
builder.Build()));
68 const float stops[2] = {0.0, 1.0};
79 ASSERT_TRUE(OpenPlaygroundHere(
builder.Build()));
89 save_paint.
setAlpha(
static_cast<uint8_t
>(255 * alpha));
90 builder.SaveLayer(
nullptr, &save_paint);
95 ASSERT_TRUE(OpenPlaygroundHere(
builder.Build()));
99 auto texture = CreateTextureForFixture(
"embarcadero.jpg");
103 ASSERT_TRUE(OpenPlaygroundHere(
builder.Build()));
111 paint.setStrokeWidth(30);
121 paint.setStrokeMiter(4);
130 paint.setStrokeMiter(1);
149 ASSERT_TRUE(OpenPlaygroundHere(
builder.Build()));
154 static float start_angle = 45;
155 static float sweep_angle = 270;
157 static bool use_center =
true;
159 static int selected_cap = 0;
160 const char* cap_names[] = {
"Butt",
"Round",
"Square"};
163 ImGui::Begin(
"Controls",
nullptr, ImGuiWindowFlags_AlwaysAutoResize);
164 ImGui::SliderFloat(
"Start angle", &start_angle, -360, 360);
165 ImGui::SliderFloat(
"Sweep angle", &sweep_angle, -360, 360);
166 ImGui::SliderFloat(
"Stroke width", &
stroke_width, 0, 300);
167 ImGui::Combo(
"Cap", &selected_cap, cap_names,
168 sizeof(cap_names) /
sizeof(
char*));
169 ImGui::Checkbox(
"Use center", &use_center);
172 switch (selected_cap) {
197 paint.setStrokeCap(cap);
199 paint.setStrokeMiter(10);
202 paint.setStrokeWidth(2);
210 ASSERT_TRUE(OpenPlaygroundHere(
callback));
222 static int selected_stroke_type = 0;
223 static int selected_join_type = 0;
224 const char* stroke_types[] = {
"Butte",
"Round",
"Square"};
225 const char* join_type[] = {
"kMiter",
"Round",
"kBevel"};
227 ImGui::Begin(
"Controls",
nullptr, ImGuiWindowFlags_AlwaysAutoResize);
228 ImGui::Combo(
"Cap", &selected_stroke_type, stroke_types,
229 sizeof(stroke_types) /
sizeof(
char*));
230 ImGui::Combo(
"Join", &selected_join_type, join_type,
231 sizeof(join_type) /
sizeof(
char*));
232 ImGui::SliderFloat(
"Stroke Width", &
stroke_width, 10.0f, 50.0f);
237 switch (selected_stroke_type) {
251 switch (selected_join_type) {
265 paint.setStrokeCap(cap);
293 path.lineTo({100, 0});
294 path.lineTo({100, 0});
295 path.lineTo({100, 100});
311 line_path.
lineTo({50, 50});
312 line_path.
lineTo({50, 50});
313 line_path.
lineTo({100, 0});
314 line_path.
lineTo({100, 0});
342 cubic_path2.
moveTo({0, 0});
343 cubic_path2.
cubicTo(0, 0, 0, 0, 150, 150);
348 cubic_path3.
moveTo({0, 0});
349 cubic_path3.
cubicTo(0, 0, 0, 0, 0, 0);
370 quad_path2.
quadTo({0, 0}, {100, 100});
376 quad_path3.
quadTo({0, 0}, {0, 0});
383 ASSERT_TRUE(OpenPlaygroundHere(
callback));
396 path.addCircle(0, 0, 100);
397 path.addCircle(0, 0, 50);
400 ASSERT_TRUE(OpenPlaygroundHere(
builder.Build()));
412 paint.setStrokeWidth(10);
422 path.lineTo(50, 100);
423 path.lineTo(100, 100);
424 path.lineTo(100, 50);
427 ASSERT_TRUE(OpenPlaygroundHere(
builder.Build()));
431 auto texture = CreateTextureForFixture(
"embarcadero.jpg");
439 paint.setMaskFilter(&filter);
449 paint.setMaskFilter(&filter);
457 paint.setMaskFilter(&filter);
463 ASSERT_TRUE(OpenPlaygroundHere(
builder.Build()));
476 ASSERT_TRUE(OpenPlaygroundHere(
builder.Build()));
490 paint.setColor(mat_blue);
502 ASSERT_TRUE(OpenPlaygroundHere(
builder.Build()));
506 auto texture = CreateTextureForFixture(
"embarcadero.jpg");
510 paint.setMaskFilter(&filter);
515 ASSERT_TRUE(OpenPlaygroundHere(
builder.Build()));
519 auto texture = CreateTextureForFixture(
"embarcadero.jpg");
527 paint.setColorFilter(&filter);
536 paint.setColorFilter(&filter);
541 ASSERT_TRUE(OpenPlaygroundHere(
builder.Build()));
545 const float invert_color_matrix[20] = {
551 auto texture = CreateTextureForFixture(
"boston.jpg");
556 std::make_shared<flutter::DlMatrixColorFilter>(invert_color_matrix);
558 std::make_shared<flutter::DlColorFilterImageFilter>(
color_filter);
560 paint.setImageFilter(image_filter.get());
568 ASSERT_TRUE(OpenPlaygroundHere(
builder.Build()));
572 auto texture = CreateTextureForFixture(
"embarcadero.jpg");
575 static float sigma[] = {10, 10};
577 ImGui::Begin(
"Controls",
nullptr, ImGuiWindowFlags_AlwaysAutoResize);
578 ImGui::SliderFloat2(
"Sigma", sigma, 0, 100);
586 paint.setImageFilter(&filter);
593 ASSERT_TRUE(OpenPlaygroundHere(
callback));
597 auto texture = CreateTextureForFixture(
"boston.jpg");
601 auto dilate = std::make_shared<flutter::DlDilateImageFilter>(10.0, 10.0);
602 auto erode = std::make_shared<flutter::DlErodeImageFilter>(10.0, 10.0);
603 auto open = std::make_shared<flutter::DlComposeImageFilter>(dilate, erode);
604 auto close = std::make_shared<flutter::DlComposeImageFilter>(erode, dilate);
606 paint.setImageFilter(open.get());
610 paint.setImageFilter(close.get());
613 ASSERT_TRUE(OpenPlaygroundHere(
builder.Build()));
617 auto texture = CreateTextureForFixture(
"boston.jpg");
618 const float inner_color_matrix[20] = {
624 const float outer_color_matrix[20] = {
630 auto inner_color_filter =
631 std::make_shared<flutter::DlMatrixColorFilter>(inner_color_matrix);
632 auto outer_color_filter =
633 std::make_shared<flutter::DlMatrixColorFilter>(outer_color_matrix);
635 std::make_shared<flutter::DlColorFilterImageFilter>(inner_color_filter);
637 std::make_shared<flutter::DlColorFilterImageFilter>(outer_color_filter);
638 auto compose = std::make_shared<flutter::DlComposeImageFilter>(outer, inner);
642 paint.setImageFilter(compose.get());
645 ASSERT_TRUE(OpenPlaygroundHere(
builder.Build()));
649 auto texture = CreateTextureForFixture(
"embarcadero.jpg");
652 static float sigma[] = {10, 10};
653 static float ctm_scale = 1;
654 static bool use_bounds =
true;
655 static bool draw_circle =
true;
656 static bool add_clip =
true;
658 ImGui::Begin(
"Controls",
nullptr, ImGuiWindowFlags_AlwaysAutoResize);
659 ImGui::SliderFloat2(
"Sigma", sigma, 0, 100);
660 ImGui::SliderFloat(
"Scale", &ctm_scale, 0, 10);
663 "If everything is working correctly, none of the options below should "
664 "impact the filter's appearance.");
665 ImGui::Checkbox(
"Use SaveLayer bounds", &use_bounds);
666 ImGui::Checkbox(
"Draw child element", &draw_circle);
667 ImGui::Checkbox(
"Add pre-clip", &add_clip);
678 std::optional<SkRect>
bounds;
706 paint.setStrokeWidth(10);
708 builder.DrawCircle({circle_center.x, circle_center.y}, 100,
paint);
714 ASSERT_TRUE(OpenPlaygroundHere(
callback));
719 auto texture = CreateTextureForFixture(
"embarcadero.jpg");
725 size.height * 3 / 4),
728 ASSERT_TRUE(OpenPlaygroundHere(
builder.Build()));
735 auto texture = CreateTextureForFixture(
"embarcadero.jpg");
741 size.height * 3 / 4),
744 ASSERT_TRUE(OpenPlaygroundHere(
builder.Build()));
751 auto texture = CreateTextureForFixture(
"embarcadero.jpg");
757 size.height * 3 / 4),
760 ASSERT_TRUE(OpenPlaygroundHere(
builder.Build()));
766 auto texture = CreateTextureForFixture(
"embarcadero.jpg");
772 size.height * 3 / 4),
775 ASSERT_TRUE(OpenPlaygroundHere(
builder.Build()));
781 auto texture = CreateTextureForFixture(
"embarcadero.jpg");
787 size.height * 3 / 4),
790 ASSERT_TRUE(OpenPlaygroundHere(
builder.Build()));
796 auto texture = CreateTextureForFixture(
"nine_patch_corners.png");
802 ASSERT_TRUE(OpenPlaygroundHere(
builder.Build()));
816 std::vector<flutter::DlStrokeCap> caps = {
826 for (
auto cap : caps) {
827 paint.setStrokeCap(cap);
838 ASSERT_TRUE(OpenPlaygroundHere(
builder.Build()));
843 std::vector<flutter::DlStrokeCap> caps = {
855 for (
auto cap : caps) {
856 paint.setStrokeCap(cap);
861 ASSERT_TRUE(OpenPlaygroundHere(
builder.Build()));
868 auto content_scale = GetContentScale() * 0.8;
869 builder.Scale(content_scale.x, content_scale.y);
871 constexpr size_t star_spikes = 5;
872 constexpr SkScalar half_spike_rotation =
kPi / star_spikes;
875 constexpr SkScalar outer_radius = radius + spike_size;
876 constexpr SkScalar inner_radius = radius - spike_size;
877 std::array<SkPoint, star_spikes * 2> star;
878 for (
size_t i = 0;
i < star_spikes;
i++) {
879 const SkScalar rotation = half_spike_rotation *
i * 2;
880 star[
i * 2] =
SkPoint::Make(50 + std::sin(rotation) * outer_radius,
881 50 - std::cos(rotation) * outer_radius);
883 50 + std::sin(rotation + half_spike_rotation) * inner_radius,
884 50 - std::cos(rotation + half_spike_rotation) * inner_radius);
887 std::array<SkPath, 4> paths = {
898 for (
size_t x = 0;
x < paths.size();
x++) {
900 for (
size_t y = 0;
y < 6;
y++) {
910 ASSERT_TRUE(OpenPlaygroundHere(
builder.Build()));
914 DispatcherDoesNotCullPerspectiveTransformedChildDisplayLists) {
919 auto display_list = sub_builder.
Build();
922 dispatcher.
scale(2.0, 2.0);
926 0.8, -0.2, -0.1, -0.0,
929 63.2, 65.3, 48.6, 1.1
938 if (std::static_pointer_cast<SolidColorContents>(entity.
GetContents())
952 dispatcher.
scale(1.618, 1.618);
959 std::shared_ptr<SolidRRectBlurContents> rrect_blur;
960 picture.pass->IterateAllEntities([&rrect_blur](
Entity& entity) {
962 rrect_blur = std::static_pointer_cast<SolidRRectBlurContents>(
963 entity.GetContents());
969 ASSERT_NE(rrect_blur,
nullptr);
970 ASSERT_EQ(rrect_blur->GetColor().red, 0);
971 ASSERT_EQ(rrect_blur->GetColor().green, 0);
972 ASSERT_EQ(rrect_blur->GetColor().blue, 0);
973 ASSERT_EQ(rrect_blur->GetColor().alpha, 0);
978 std::vector<flutter::DlStrokeCap> caps = {
995 for (
auto cap : caps) {
996 paint.setStrokeCap(cap);
998 builder.DrawRect({45, 45, 65, 55}, outline_paint);
1001 builder.DrawRect({95, 45, 105, 55}, outline_paint);
1004 builder.DrawRect(
path.getBounds().makeOutset(5, 5), outline_paint);
1007 ASSERT_TRUE(OpenPlaygroundHere(
builder.Build()));
1011 auto boston = CreateTextureForFixture(
"boston.jpg");
1014 static int selected_matrix_type = 0;
1015 const char* matrix_type_names[] = {
"Matrix",
"Local Matrix"};
1017 static float ctm_translation[2] = {200, 200};
1018 static float ctm_scale[2] = {0.65, 0.65};
1019 static float ctm_skew[2] = {0, 0};
1021 static bool enable =
true;
1022 static float translation[2] = {100, 100};
1023 static float scale[2] = {0.8, 0.8};
1024 static float skew[2] = {0.2, 0.2};
1026 static bool enable_savelayer =
true;
1028 ImGui::Begin(
"Controls",
nullptr, ImGuiWindowFlags_AlwaysAutoResize);
1030 ImGui::Combo(
"Filter type", &selected_matrix_type, matrix_type_names,
1031 sizeof(matrix_type_names) /
sizeof(
char*));
1033 ImGui::TextWrapped(
"Current Transform");
1034 ImGui::SliderFloat2(
"CTM Translation", ctm_translation, 0, 1000);
1035 ImGui::SliderFloat2(
"CTM Scale", ctm_scale, 0, 3);
1036 ImGui::SliderFloat2(
"CTM Skew", ctm_skew, -3, 3);
1039 "MatrixFilter and LocalMatrixFilter modify the CTM in the same way. "
1040 "The only difference is that MatrixFilter doesn't affect the effect "
1041 "transform, whereas LocalMatrixFilter does.");
1044 ImGui::Checkbox(
"Enable", &enable);
1045 ImGui::SliderFloat2(
"Filter Translation", translation, 0, 1000);
1046 ImGui::SliderFloat2(
"Filter Scale",
scale, 0, 3);
1047 ImGui::SliderFloat2(
"Filter Skew", skew, -3, 3);
1050 "Rendering the filtered image within a layer can expose bounds "
1051 "issues. If the rendered image gets cut off when this setting is "
1052 "enabled, there's a coverage bug in the filter.");
1053 ImGui::Checkbox(
"Render in layer", &enable_savelayer);
1060 if (enable_savelayer) {
1061 builder.SaveLayer(
nullptr,
nullptr);
1064 auto content_scale = GetContentScale();
1065 builder.Scale(content_scale.x, content_scale.y);
1070 ctm_skew[1], ctm_scale[1], ctm_translation[1],
1072 builder.Transform(ctm_matrix);
1075 auto filter_matrix =
1077 skew[1],
scale[1], translation[1],
1081 switch (selected_matrix_type) {
1085 paint.setImageFilter(&filter);
1089 auto internal_filter =
1094 paint.setImageFilter(&filter);
1103 if (enable_savelayer) {
1110 ASSERT_TRUE(OpenPlaygroundHere(
callback));
1115 static float translation[2] = {0, 0};
1116 static bool enable_save_layer =
true;
1118 ImGui::Begin(
"Controls",
nullptr, ImGuiWindowFlags_AlwaysAutoResize);
1119 ImGui::SliderFloat2(
"Translation", translation, -130, 130);
1120 ImGui::Checkbox(
"Enable save layer", &enable_save_layer);
1129 paint.setStrokeWidth(1.0);
1139 if (enable_save_layer) {
1146 builder.Transform(translate_matrix);
1167 ASSERT_TRUE(OpenPlaygroundHere(
callback));
1174 paint.setColorFilter(
1179 paint.setColorFilter(
1183 ASSERT_TRUE(OpenPlaygroundHere(
builder.Build()));
1191 const float stops[2] = {0.0, 1.0};
1210 paint.setColorSource(radial);
1220 paint.setColorSource(sweep);
1227 auto texture = CreateTextureForFixture(
"table_mountain_nx.png");
1228 auto image = std::make_shared<flutter::DlImageColorSource>(
1235 ASSERT_TRUE(OpenPlaygroundHere(
builder.Build()));
1242 builder.SaveLayer(
nullptr,
nullptr);
1253 builder.SaveLayer(
nullptr,
nullptr);
1264 builder.SaveLayer(
nullptr,
nullptr);
1275 builder.SaveLayer(
nullptr,
nullptr);
1286 ASSERT_TRUE(OpenPlaygroundHere(
builder.Build()));
1291 const float green_color_matrix[20] = {
1297 const float blue_color_matrix[20] = {
1303 auto green_color_filter =
1304 std::make_shared<flutter::DlMatrixColorFilter>(green_color_matrix);
1305 auto blue_color_filter =
1306 std::make_shared<flutter::DlMatrixColorFilter>(blue_color_matrix);
1307 auto blue_image_filter =
1308 std::make_shared<flutter::DlColorFilterImageFilter>(blue_color_filter);
1312 paint.setColorFilter(green_color_filter);
1313 paint.setImageFilter(blue_image_filter);
1315 ASSERT_TRUE(OpenPlaygroundHere(
builder.Build()));
1319 auto blur_filter = std::make_shared<flutter::DlBlurMaskFilter>(
1326 std::array<float, 2> stops = {0, 1};
1327 std::array<std::shared_ptr<flutter::DlColorSource>, 2> color_sources = {
1334 for (
const auto& color_source : color_sources) {
1336 paint.setColorSource(color_source);
1337 paint.setMaskFilter(blur_filter);
1344 paint.setStrokeWidth(10);
1352 ASSERT_TRUE(OpenPlaygroundHere(
builder.Build()));
1357 std::vector<flutter::DlStrokeJoin> joins = {
1376 for (
auto join : joins) {
1387 builder.DrawCircle({350, 200}, 50, stroke_paint);
1390 ASSERT_TRUE(OpenPlaygroundHere(
builder.Build()));
1443 builder.DrawPaint(clip_fill_paint);
1449 builder.DrawPaint(clip_fill_paint);
1452 ASSERT_TRUE(OpenPlaygroundHere(
builder.Build()));
1456 std::vector<const char*> blend_mode_names;
1457 std::vector<flutter::DlBlendMode> blend_mode_values;
1459 const std::vector<std::tuple<const char*, flutter::DlBlendMode>> blends = {
1492 assert(blends.size() ==
1494 for (
const auto& [
name,
mode] : blends) {
1495 blend_mode_names.push_back(
name);
1496 blend_mode_values.push_back(
mode);
1501 static int current_blend_index = 3;
1502 static float dst_alpha = 1;
1503 static float src_alpha = 1;
1504 static float color0[4] = {1.0f, 0.0f, 0.0f, 1.0f};
1505 static float color1[4] = {0.0f, 1.0f, 0.0f, 1.0f};
1506 static float color2[4] = {0.0f, 0.0f, 1.0f, 1.0f};
1507 static float src_color[4] = {1.0f, 1.0f, 1.0f, 1.0f};
1509 ImGui::Begin(
"Controls",
nullptr, ImGuiWindowFlags_AlwaysAutoResize);
1511 ImGui::ListBox(
"Blending mode", ¤t_blend_index,
1512 blend_mode_names.data(), blend_mode_names.size());
1513 ImGui::SliderFloat(
"Source alpha", &src_alpha, 0, 1);
1514 ImGui::ColorEdit4(
"Color A", color0);
1515 ImGui::ColorEdit4(
"Color B", color1);
1516 ImGui::ColorEdit4(
"Color C", color2);
1517 ImGui::ColorEdit4(
"Source Color", src_color);
1518 ImGui::SliderFloat(
"Destination alpha", &dst_alpha, 0, 1);
1525 std::vector<flutter::DlColor>
colors = {
1537 paint.setColor(
toColor(src_color).modulateOpacity(src_alpha));
1538 builder.DrawVertices(vertices, blend_mode_values[current_blend_index],
1543 ASSERT_TRUE(OpenPlaygroundHere(
callback));
1546template <
typename Contents>
1550 if (std::static_pointer_cast<Contents>(entity.
GetContents())) {
1551 auto contents = std::static_pointer_cast<Contents>(entity.GetContents());
1553 coverage = contents->GetCoverage(entity);
1569 auto display_list =
builder.Build();
1572 display_list->Dispatch(dispatcher);
1576 GetCoverageOfFirstEntity<SolidColorContents>(
picture);
1591 auto display_list =
builder.Build();
1594 display_list->Dispatch(dispatcher);
1598 GetCoverageOfFirstEntity<SolidColorContents>(
picture);
1605#ifdef IMPELLER_ENABLE_3D
1610 ASSERT_NE(mapping,
nullptr);
1612 std::shared_ptr<scene::Node> gltf_scene =
1614 *mapping, *
GetContext()->GetResourceAllocator());
1615 ASSERT_NE(gltf_scene,
nullptr);
1619 auto color_source = std::make_shared<flutter::DlSceneColorSource>(
1628 ASSERT_TRUE(OpenPlaygroundHere(
builder.Build()));
1637 builder.DrawCircle({300, 300}, 200,
1642 const float stops[2] = {0.0, 1.0};
1644 {100.0, 100.0}, {300.0, 300.0}, 2,
colors.data(), stops,
1650 builder.DrawPaint(blend_paint);
1652 ASSERT_TRUE(OpenPlaygroundHere(
builder.Build()));
1663 builder.Translate(1.0f, 1.0f);
1671 for (
int x = 1;
x <= 4;
x++) {
1672 for (
int y = 1;
y <= 4;
y++) {
1680 builder.Translate(500.0f, 0.0f);
1681 auto normal_filter =
1691 for (
int x = 1;
x <= 4;
x++) {
1692 for (
int y = 1;
y <= 4;
y++) {
1699 ASSERT_TRUE(OpenPlaygroundHere(
builder.Build()));
static const int points[]
static sk_sp< SkImage > color_filter(const SkImage *image, SkColorFilter *colorFilter)
SkMatrix & postTranslate(SkScalar dx, SkScalar dy)
static SkMatrix RotateDeg(SkScalar deg)
SkMatrix & postScale(SkScalar sx, SkScalar sy, SkScalar px, SkScalar py)
static SkMatrix Translate(SkScalar dx, SkScalar dy)
static SkMatrix MakeAll(SkScalar scaleX, SkScalar skewX, SkScalar transX, SkScalar skewY, SkScalar scaleY, SkScalar transY, SkScalar pers0, SkScalar pers1, SkScalar pers2)
static const SkMatrix & I()
SkPathBuilder & lineTo(SkPoint pt)
SkPathBuilder & moveTo(SkPoint pt)
SkPath & addCircle(SkScalar x, SkScalar y, SkScalar radius, SkPathDirection dir=SkPathDirection::kCW)
SkPath & moveTo(SkScalar x, SkScalar y)
SkPath & addPoly(const SkPoint pts[], int count, bool close)
SkPath & lineTo(SkScalar x, SkScalar y)
SkPath & addRRect(const SkRRect &rrect, SkPathDirection dir=SkPathDirection::kCW)
SkPath & quadTo(SkScalar x1, SkScalar y1, SkScalar x2, SkScalar y2)
SkPath & cubicTo(SkScalar x1, SkScalar y1, SkScalar x2, SkScalar y2, SkScalar x3, SkScalar y3)
SkPath & addRect(const SkRect &rect, SkPathDirection dir, unsigned start)
static SkRRect MakeRectXY(const SkRect &rect, SkScalar xRad, SkScalar yRad)
static sk_sp< SkTextBlob > MakeFromString(const char *string, const SkFont &font, SkTextEncoding encoding=SkTextEncoding::kUTF8)
void DrawRect(const SkRect &rect, const DlPaint &paint) override
sk_sp< DisplayList > Build()
std::shared_ptr< DlImageFilter > shared() const override
static std::shared_ptr< DlMaskFilter > Make(DlBlurStyle style, SkScalar sigma, bool respect_ctm=true)
@ kLines
draw each separate pair of points as a line segment
@ kPolygon
draw each pair of overlapping points as a line segment
@ kPoints
draw each point separately
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)
static std::shared_ptr< DlSweepGradientColorSource > MakeSweep(SkPoint center, SkScalar start, SkScalar end, uint32_t stop_count, const DlColor *colors, const float *stops, DlTileMode tile_mode, const SkMatrix *matrix=nullptr)
static std::shared_ptr< DlRadialGradientColorSource > MakeRadial(SkPoint center, SkScalar radius, uint32_t stop_count, const DlColor *colors, const float *stops, DlTileMode tile_mode, const SkMatrix *matrix=nullptr)
static const std::shared_ptr< DlLinearToSrgbGammaColorFilter > kInstance
static std::shared_ptr< DlImageFilter > Make(const SkMatrix &matrix, DlImageSampling sampling)
DlPaint & setColor(DlColor color)
DlPaint & setMaskFilter(const std::shared_ptr< DlMaskFilter > &filter)
DlPaint & setStrokeCap(DlStrokeCap cap)
DlPaint & setStrokeWidth(float width)
DlPaint & setAlpha(uint8_t alpha)
DlPaint & setBlendMode(DlBlendMode mode)
DlPaint & setImageFilter(const std::shared_ptr< const DlImageFilter > &filter)
DlPaint & setDrawStyle(DlDrawStyle style)
DlPaint & setStrokeJoin(DlStrokeJoin join)
DlPaint & setColorSource(std::shared_ptr< const DlColorSource > source)
static const std::shared_ptr< DlSrgbToLinearGammaColorFilter > kInstance
static std::shared_ptr< DlVertices > Make(DlVertexMode mode, int vertex_count, const SkPoint vertices[], const SkPoint texture_coordinates[], const DlColor colors[], int index_count=0, const uint16_t indices[]=nullptr)
Constructs a DlVector with compact inline storage for all of its required and optional lists of data.
void transformFullPerspective(SkScalar mxx, SkScalar mxy, SkScalar mxz, SkScalar mxt, SkScalar myx, SkScalar myy, SkScalar myz, SkScalar myt, SkScalar mzx, SkScalar mzy, SkScalar mzz, SkScalar mzt, SkScalar mwx, SkScalar mwy, SkScalar mwz, SkScalar mwt) override
Picture EndRecordingAsPicture()
void translate(SkScalar tx, SkScalar ty) override
void drawShadow(const SkPath &path, const flutter::DlColor color, const SkScalar elevation, bool transparent_occluder, SkScalar dpr) override
void scale(SkScalar sx, SkScalar sy) override
void drawDisplayList(const sk_sp< flutter::DisplayList > display_list, SkScalar opacity) override
static sk_sp< DlImageImpeller > Make(std::shared_ptr< Texture > texture, OwningContext owning_context=OwningContext::kIO)
const std::shared_ptr< Contents > & GetContents() const
const Matrix & GetTransform() const
Get the global transform matrix for this Entity.
static std::shared_ptr< Node > MakeFromFlatbuffer(const fml::Mapping &ipscene_mapping, Allocator &allocator)
FlKeyEvent uint64_t FlKeyResponderAsyncCallback callback
SK_API GrDirectContext * GetContext(const SkImage *src)
Optional< SkRect > bounds
sk_sp< const SkImage > image
sk_sp< const SkPicture > picture
sk_sp< SkBlender > blender SkRect rect
PODArray< SkColor > colors
SK_API sk_sp< SkShader > Color(SkColor)
SkFont CreateTestFontOfSize(SkScalar scalar)
std::unique_ptr< fml::Mapping > OpenFixtureAsMapping(const std::string &fixture_name)
Opens a fixture of the given file name and returns a mapping to its contents.
@ kMiter
extends to miter limit
@ kBevel
connects outside edges
@ kButt
no stroke extension
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 Enable an endless trace buffer The default is a ring buffer This is useful when very old events need to viewed For during application launch Memory usage will continue to grow indefinitely however Start app with an specific route defined on the framework flutter assets Path to the Flutter assets directory enable service port Allow the VM service to fallback to automatic port selection if binding to a specified port fails trace Trace early application lifecycle Automatically switches to an endless trace buffer trace skia Filters out all Skia trace event categories except those that are specified in this comma separated list dump skp on shader Automatically dump the skp that triggers new shader compilations This is useful for writing custom ShaderWarmUp to reduce jank By this is not enabled to reduce the overhead purge persistent cache
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
DEF_SWITCHES_START aot vmservice shared library name
@ kTriangles
The vertices are taken 3 at a time to form a triangle.
@ kStroke
strokes boundary of shapes
@ kFill
fills interior of shapes
@ kNormal
fuzzy inside and outside
@ kOuter
nothing inside, fuzzy outside
@ kSolid
solid inside, fuzzy outside
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 mode
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
@ kExclusion
rc = s + d - two(s*d), ra = kSrcOver
@ kSaturation
saturation of source with hue and luminosity of destination
@ kColorBurn
darken destination to reflect source
@ kLighten
rc = s + d - min(s*da, d*sa), ra = kSrcOver
@ kHue
hue of source with saturation and luminosity of destination
@ kMultiply
r = s*(1-da) + d*(1-sa) + s*d
@ kColorDodge
brighten destination to reflect source
@ kSrcOver
r = s + (1-sa)*d
@ kXor
r = s*(1-da) + d*(1-sa)
@ kLuminosity
luminosity of source with hue and saturation of destination
@ kSoftLight
lighten or darken, depending on source
@ kDifference
rc = s + d - 2*(min(s*da, d*sa)), ra = kSrcOver
@ kOverlay
multiply or screen, depending on destination
@ kSrcATop
r = s*da + d*(1-sa)
@ kDstATop
r = d*sa + s*(1-da)
@ kDstOver
r = d + (1-da)*s
@ kLastMode
last valid value
@ kColor
hue and saturation of source with luminosity of destination
@ kHardLight
multiply or screen, depending on source
@ kDarken
rc = s + d - max(s*da, d*sa), ra = kSrcOver
TEST(AiksCanvasTest, EmptyCullRect)
DlPlayground DisplayListTest
flutter::DlColor toColor(const float *components)
INSTANTIATE_PLAYGROUND_SUITE(AiksTest)
TEST_P(AiksTest, CanRenderAdvancedBlendColorFilterWithSaveLayer)
static std::optional< Rect > GetCoverageOfFirstEntity(const Picture &picture)
Point DrawPlaygroundPoint(PlaygroundPoint &point)
std::tuple< Point, Point > DrawPlaygroundLine(PlaygroundPoint &point_a, PlaygroundPoint &point_b)
constexpr bool ScalarNearlyEqual(Scalar x, Scalar y, Scalar tolerance=kEhCloseEnough)
const myers::Point & get(const myers::Segment &)
static SkString join(const CommandLineFlags::StringArray &)
const Scalar stroke_width
static constexpr SkIRect MakeLTRB(int32_t l, int32_t t, int32_t r, int32_t b)
static constexpr SkIRect MakeXYWH(int32_t x, int32_t y, int32_t w, int32_t h)
static constexpr SkPoint Make(float x, float y)
static constexpr SkRect MakeXYWH(float x, float y, float w, float h)
static constexpr SkRect MakeSize(const SkSize &size)
static constexpr SkRect MakeWH(float w, float h)
static constexpr SkRect MakeLTRB(float l, float t, float r, float b)
constexpr DlColor modulateOpacity(float opacity) const
static constexpr DlColor kWhite()
static constexpr DlColor kBlue()
static constexpr DlColor kBlack()
static constexpr DlColor kYellow()
static constexpr DlColor kMidGrey()
static constexpr DlColor kTransparent()
static constexpr DlColor kRed()
static constexpr DlColor kGreen()
static constexpr DlColor kCyan()
static constexpr uint32_t ToIColor(Color color)
Convert this color to a 32-bit representation.
static constexpr Color White()
static constexpr Color Red()
static constexpr Matrix MakePerspective(Radians fov_y, Scalar aspect_ratio, Scalar z_near, Scalar z_far)
constexpr Vector3 GetScale() const
static constexpr Matrix MakeLookAt(Vector3 position, Vector3 target, Vector3 up)
static constexpr TRect MakeMaximum()
static constexpr TRect MakeLTRB(Type left, Type top, Type right, Type bottom)
#define EXPECT_TRUE(handle)
static sk_sp< SkShader > linear(sk_sp< SkShader > shader)