12#include "flutter/display_list/testing/dl_test_snippets.h"
14#include "gtest/gtest.h"
59#include "third_party/imgui/imgui.h"
93 std::shared_ptr<Texture>
target,
101 const Matrix& effect_transform)
const override {
106 const std::optional<Rect> coverage_;
107 const bool collapse_;
112 std::optional<Rect> bounds_hint,
114 bool collapse =
false) {
115 auto subpass = std::make_unique<EntityPass>();
119 subpass->AddEntity(std::move(entity));
120 subpass->SetDelegate(std::make_unique<TestPassDelegate>(collapse));
121 subpass->SetBoundsLimit(bounds_hint, bounds_promise);
133 auto subpass0_coverage =
135 ASSERT_TRUE(subpass0_coverage.has_value());
138 auto subpass1_coverage =
140 ASSERT_TRUE(subpass1_coverage.has_value());
164 auto subpass0_coverage =
171 auto subpass1_coverage =
200 auto contents = std::make_unique<SolidColorContents>();
207 ASSERT_TRUE(OpenPlaygroundHere(pass));
217 auto pass_coverage = pass->GetElementsCoverage(std::nullopt);
218 ASSERT_TRUE(pass_coverage.has_value());
227 ASSERT_FALSE(pass_coverage.has_value());
234 ASSERT_TRUE(pass_coverage.has_value());
241 auto image = CreateTextureForFixture(
"boston.jpg");
247 auto actual = filter->GetCoverage({});
250 ASSERT_TRUE(actual.has_value());
257 filter->SetCoverageHint(expected);
258 auto actual = filter->GetCoverage({});
260 ASSERT_TRUE(actual.has_value());
266 auto contents = std::make_shared<SolidColorContents>();
274 ASSERT_TRUE(OpenPlaygroundHere(std::move(entity)));
278 auto contents = std::make_shared<SolidColorContents>();
290 ASSERT_TRUE(OpenPlaygroundHere(std::move(entity)));
313 auto contents = std::make_unique<SolidColorContents>();
317 ASSERT_TRUE(OpenPlaygroundHere(std::move(entity)));
321 auto bridge = CreateTextureForFixture(
"bay_bridge.jpg");
333 auto contents = std::make_unique<TiledTextureContents>();
335 contents->SetTexture(bridge);
338 ASSERT_TRUE(OpenPlaygroundHere(std::move(entity)));
374 auto contents = std::make_unique<SolidColorContents>();
379 return entity.
Render(context, pass);
381 ASSERT_TRUE(OpenPlaygroundHere(
callback));
385 const Point padding(300, 250);
386 const Point margin(140, 180);
392 static Scalar miter_limit = 1.41421357;
395 ImGui::Begin(
"Controls",
nullptr, ImGuiWindowFlags_AlwaysAutoResize);
397 ImGui::SliderFloat(
"Miter limit", &miter_limit, 0, 30);
398 ImGui::SliderFloat(
"Stroke width", &
width, 0, 100);
399 if (ImGui::Button(
"Reset")) {
400 miter_limit = 1.41421357;
407 auto render_path = [
width =
width, &context, &pass, &world_matrix](
409 auto contents = std::make_unique<SolidColorContents>();
410 contents->SetGeometry(
420 auto bounds_contents = std::make_unique<SolidColorContents>();
423 bounds_contents->SetColor(
Color::Green().WithAlpha(0.5));
425 bounds_entity.
SetContents(std::move(bounds_contents));
426 bounds_entity.
Render(context, pass);
429 entity.
Render(context, pass);
432 const Point a_def(0, 0), b_def(0, 100), c_def(150, 0), d_def(150, -100),
521 ASSERT_TRUE(OpenPlaygroundHere(
callback));
528 .
MoveTo({237.164, 125.003})
529 .CubicCurveTo({236.709, 125.184}, {236.262, 125.358},
531 .CubicCurveTo({235.413, 125.68}, {234.994, 125.832},
533 .CubicCurveTo({234.592, 125.977}, {234.591, 125.977},
535 .CubicCurveTo({222.206, 130.435}, {207.708, 135.753},
537 .CubicCurveTo({162.77, 151.336}, {122.17, 156.894}, {84.1123, 160})
543 ASSERT_TRUE(OpenPlaygroundHere(std::move(entity)));
548 const char* input_axis[] = {
"X",
"Y",
"Z"};
549 static int rotation_axis_index = 0;
550 static float rotation = 0;
551 ImGui::Begin(
"Controls",
nullptr, ImGuiWindowFlags_AlwaysAutoResize);
552 ImGui::SliderFloat(
"Rotation", &rotation, -
kPi,
kPi);
553 ImGui::Combo(
"Rotation Axis", &rotation_axis_index, input_axis,
554 sizeof(input_axis) /
sizeof(
char*));
556 switch (rotation_axis_index) {
567 rotation_matrix =
Matrix{};
571 if (ImGui::Button(
"Reset")) {
575 Matrix current_transform =
579 pass.GetRenderTargetSize().height / 2.0)));
580 Matrix result_transform = current_transform * rotation_matrix;
587 return entity.
Render(context, pass);
589 ASSERT_TRUE(OpenPlaygroundHere(
callback));
596 .
MoveTo({359.934, 96.6335})
597 .CubicCurveTo({358.189, 96.7055}, {356.436, 96.7908},
599 .CubicCurveTo({354.571, 96.8953}, {354.469, 96.9016},
601 .CubicCurveTo({352.672, 97.0038}, {350.969, 97.113},
603 .CubicCurveTo({349.048, 97.2506}, {348.836, 97.2678},
605 .CubicCurveTo({347.019, 97.4014}, {345.407, 97.5299},
607 .CubicCurveTo({343.428, 97.704}, {343.065, 97.7402},
609 .CubicCurveTo({341.221, 97.9086}, {339.736, 98.0505},
611 .CubicCurveTo({337.702, 98.2642}, {337.156, 98.3292},
613 .CubicCurveTo({335.284, 98.5356}, {333.956, 98.6837},
615 .CubicCurveTo({332.495, 98.8635}, {332.366, 98.8818},
617 .
LineTo({332.237, 102.601})
618 .
LineTo({321.778, 102.601})
619 .
LineTo({321.778, 100.382})
620 .CubicCurveTo({321.572, 100.413}, {321.367, 100.442},
622 .CubicCurveTo({319.22, 100.79}, {317.277, 101.123},
624 .CubicCurveTo({315.322, 101.481}, {315.311, 101.482},
626 .
LineTo({310.017, 105.94})
627 .
LineTo({309.779, 105.427})
628 .
LineTo({314.403, 101.651})
629 .CubicCurveTo({314.391, 101.653}, {314.379, 101.656},
631 .CubicCurveTo({312.528, 102.001}, {310.687, 102.366},
633 .CubicCurveTo({307.85, 102.955}, {306.855, 103.182}, {305.859, 103.4})
634 .CubicCurveTo({305.048, 103.579}, {304.236, 103.75},
636 .
LineTo({299.105, 107.578})
637 .
LineTo({298.867, 107.065})
638 .
LineTo({302.394, 104.185})
639 .
LineTo({302.412, 104.171})
640 .CubicCurveTo({301.388, 104.409}, {300.366, 104.67},
642 .CubicCurveTo({298.618, 105.1}, {297.89, 105.269}, {297.165, 105.455})
643 .CubicCurveTo({295.262, 105.94}, {293.36, 106.445},
645 .CubicCurveTo({291.132, 107.072}, {290.802, 107.163},
647 .CubicCurveTo({289.463, 107.544}, {288.455, 107.839},
649 .CubicCurveTo({286.476, 108.431}, {285.506, 108.73},
651 .CubicCurveTo({283.674, 109.304}, {282.812, 109.579},
653 .CubicCurveTo({281.177, 110.112}, {280.406, 110.377},
655 .CubicCurveTo({278.458, 111.037}, {277.256, 111.449},
657 .CubicCurveTo({276.76, 111.622}, {276.716, 111.637},
659 .CubicCurveTo({275.017, 112.239}, {273.365, 112.836},
661 .
LineTo({271.717, 113.449})
662 .CubicCurveTo({271.496, 113.496}, {271.238, 113.559},
664 .CubicCurveTo({270.893, 113.645}, {270.822, 113.663},
666 .CubicCurveTo({270.468, 113.755}, {270.169, 113.834},
668 .CubicCurveTo({269.789, 113.94}, {269.732, 113.957},
670 .CubicCurveTo({269.391, 114.053}, {269.081, 114.143},
672 .CubicCurveTo({268.628, 114.276}, {268.5, 114.314},
674 .CubicCurveTo({268.172, 114.412}, {267.959, 114.478},
676 .CubicCurveTo({263.349, 115.964}, {258.058, 117.695},
678 .CubicCurveTo({253.556, 119.255}, {253.547, 119.258},
680 .CubicCurveTo({251.844, 119.849}, {250.056, 120.474},
682 .CubicCurveTo({248, 121.197}, {247.812, 121.264}, {247.621, 121.331})
683 .CubicCurveTo({247.079, 121.522}, {246.531, 121.715},
685 .CubicCurveTo({245.554, 122.06}, {245.126, 122.212},
687 .CubicCurveTo({244.071, 122.586}, {243.437, 122.811},
689 .CubicCurveTo({242.189, 123.255}, {241.58, 123.472},
691 .CubicCurveTo({240.659, 123.801}, {240.357, 123.909},
693 .CubicCurveTo({239.12, 124.351}, {238.18, 124.687}, {237.22, 125.032})
694 .
LineTo({237.164, 125.003})
695 .CubicCurveTo({236.709, 125.184}, {236.262, 125.358},
697 .CubicCurveTo({235.413, 125.68}, {234.994, 125.832},
699 .CubicCurveTo({234.592, 125.977}, {234.591, 125.977},
701 .CubicCurveTo({222.206, 130.435}, {207.708, 135.753},
703 .CubicCurveTo({162.77, 151.336}, {122.17, 156.894}, {84.1123, 160})
708 .CubicCurveTo({359.978, 96.6317}, {359.956, 96.6326},
711 .MoveTo({337.336, 124.143})
712 .CubicCurveTo({337.274, 122.359}, {338.903, 121.511},
714 .CubicCurveTo({338.903, 121.511}, {338.96, 123.303},
717 .MoveTo({340.082, 121.849})
718 .CubicCurveTo({340.074, 121.917}, {340.062, 121.992},
720 .CubicCurveTo({340.039, 122.109}, {340.031, 122.142},
722 .CubicCurveTo({340.005, 122.26}, {339.98, 122.346},
724 .CubicCurveTo({339.941, 122.473}, {339.931, 122.507},
726 .CubicCurveTo({339.873, 122.672}, {339.819, 122.804},
728 .CubicCurveTo({339.747, 122.944}, {339.743, 122.949},
730 .CubicCurveTo({339.674, 123.08}, {339.593, 123.205},
732 .CubicCurveTo({339.473, 123.366}, {339.441, 123.401},
734 .CubicCurveTo({339.332, 123.534}, {339.243, 123.625},
736 .CubicCurveTo({339.105, 123.75}, {339.068, 123.786},
738 .CubicCurveTo({338.881, 123.937}, {338.724, 124.048},
740 .CubicCurveTo({338.532, 123.959}, {338.554, 123.79},
742 .CubicCurveTo({338.58, 123.625}, {338.58, 123.625}, {338.58, 123.625})
743 .CubicCurveTo({338.607, 123.455}, {338.65, 123.299},
745 .CubicCurveTo({338.708, 123.14}, {338.71, 123.127},
747 .CubicCurveTo({338.769, 122.971}, {338.833, 122.838},
749 .CubicCurveTo({338.911, 122.702}, {338.916, 122.69200000000001},
751 .CubicCurveTo({338.996, 122.557}, {339.072, 122.444},
753 .CubicCurveTo({339.161, 122.333}, {339.166, 122.326},
755 .CubicCurveTo({339.256, 122.215}, {339.339, 122.12},
757 .CubicCurveTo({339.428, 122.033}, {339.431, 122.03},
759 .CubicCurveTo({339.785, 121.687}, {340.106, 121.511},
761 .CubicCurveTo({340.106, 121.511}, {340.107, 121.645},
764 .MoveTo({340.678, 113.245})
765 .CubicCurveTo({340.594, 113.488}, {340.356, 113.655},
767 .CubicCurveTo({339.817, 113.948}, {339.465, 114.059},
769 .CubicCurveTo({338.251, 114.379}, {337.34, 114.516},
771 .CubicCurveTo({335.761, 114.516}, {335.072, 114.527},
773 .CubicCurveTo({334.125, 114.508}, {333.862, 114.462},
775 .CubicCurveTo({332.865, 114.318}, {332.096, 114.184},
777 .CubicCurveTo({330.979, 113.695}, {330.442, 113.34},
779 .CubicCurveTo({331.135, 111.755}, {333.219, 112.946},
781 .CubicCurveTo({334.54, 113.816}, {334.554, 113.8}, {334.569, 113.784})
782 .CubicCurveTo({333.38, 112.708}, {331.749, 110.985},
784 .CubicCurveTo({333.769, 109.82}, {334.713, 111.93},
786 .CubicCurveTo({334.915, 111.889}, {334.59, 109.636},
788 .CubicCurveTo({336.733, 109.636}, {336.408, 111.889},
790 .CubicCurveTo({336.609, 111.93}, {337.553, 109.82},
792 .CubicCurveTo({339.574, 110.984}, {337.942, 112.708},
794 .CubicCurveTo({336.768, 113.8}, {336.782, 113.816},
796 .CubicCurveTo({338.104, 112.946}, {340.187, 111.755},
798 .CubicCurveTo({340.71, 112.95}, {340.728, 113.102},
801 .MoveTo({346.357, 106.771})
802 .CubicCurveTo({346.295, 104.987}, {347.924, 104.139},
804 .CubicCurveTo({347.924, 104.139}, {347.982, 105.931},
807 .MoveTo({347.56, 106.771})
808 .CubicCurveTo({347.498, 104.987}, {349.127, 104.139},
810 .CubicCurveTo({349.127, 104.139}, {349.185, 105.931},
817 ASSERT_TRUE(OpenPlaygroundHere(std::move(entity)));
825 ASSERT_EQ(path_geometry->GetStrokeCap(),
Cap::kButt);
826 ASSERT_EQ(path_geometry->GetStrokeJoin(),
Join::kMiter);
838 ASSERT_EQ(path_geometry->GetStrokeCap(),
Cap::kRound);
846 ASSERT_FLOAT_EQ(path_geometry->GetMiterLimit(), 4);
852 ASSERT_FLOAT_EQ(path_geometry->GetMiterLimit(), 8);
858 ASSERT_FLOAT_EQ(path_geometry->GetMiterLimit(), 4);
863 std::vector<const char*> blend_mode_names;
864 std::vector<BlendMode> blend_mode_values;
877 blend_mode_names.push_back(
"Clear");
880 blend_mode_names.push_back(
"Source");
883 blend_mode_names.push_back(
"Destination");
886 blend_mode_names.push_back(
"SourceOver");
889 blend_mode_names.push_back(
"DestinationOver");
892 blend_mode_names.push_back(
"SourceIn");
895 blend_mode_names.push_back(
"DestinationIn");
898 blend_mode_names.push_back(
"SourceOut");
901 blend_mode_names.push_back(
"DestinationOut");
904 blend_mode_names.push_back(
"SourceATop");
907 blend_mode_names.push_back(
"DestinationATop");
910 blend_mode_names.push_back(
"Xor");
913 blend_mode_names.push_back(
"Plus");
916 blend_mode_names.push_back(
"Modulate");
923 auto draw_rect = [&context, &pass, &world_matrix](
930 auto r =
rect.GetLTRB();
941 pass.SetCommandLabel(
"Blended Rectangle");
943 options.blend_mode = blend_mode;
946 pass.SetVertexBuffer(
949 VS::FrameInfo frame_info;
950 frame_info.mvp = pass.GetOrthographicTransform() * world_matrix;
953 FS::FragInfo frag_info;
954 frag_info.color =
color.Premultiply();
957 return pass.Draw().ok();
960 ImGui::Begin(
"Controls",
nullptr, ImGuiWindowFlags_AlwaysAutoResize);
961 static Color color1(1, 0, 0, 0.5), color2(0, 1, 0, 0.5);
962 ImGui::ColorEdit4(
"Color 1",
reinterpret_cast<float*
>(&color1));
963 ImGui::ColorEdit4(
"Color 2",
reinterpret_cast<float*
>(&color2));
964 static int current_blend_index = 3;
965 ImGui::ListBox(
"Blending mode", ¤t_blend_index,
966 blend_mode_names.data(), blend_mode_names.size());
969 BlendMode selected_mode = blend_mode_values[current_blend_index];
982 pass.GetRenderTargetSize().height),
990 ASSERT_TRUE(OpenPlaygroundHere(
callback));
995 static float scale = 20;
997 ImGui::Begin(
"Controls",
nullptr, ImGuiWindowFlags_AlwaysAutoResize);
998 ImGui::SliderFloat(
"Scale", &
scale, 1, 100);
1004 .
MoveTo({97.325, 34.818})
1005 .CubicCurveTo({98.50862885295136, 34.81812293973836},
1006 {99.46822048142015, 33.85863261475589},
1007 {99.46822048142015, 32.67499810206613})
1008 .CubicCurveTo({99.46822048142015, 31.491363589376355},
1009 {98.50862885295136, 30.53187326439389},
1010 {97.32499434685802, 30.531998226542708})
1011 .CubicCurveTo({96.14153655073771, 30.532123170035373},
1012 {95.18222070648729, 31.491540299350355},
1013 {95.18222070648729, 32.67499810206613})
1014 .CubicCurveTo({95.18222070648729, 33.85845590478189},
1015 {96.14153655073771, 34.81787303409686},
1016 {97.32499434685802, 34.81799797758954})
1022 return entity.
Render(context, pass);
1024 ASSERT_TRUE(OpenPlaygroundHere(
callback));
1028 auto bridge = CreateTextureForFixture(
"bay_bridge.jpg");
1029 auto boston = CreateTextureForFixture(
"boston.jpg");
1030 auto kalimba = CreateTextureForFixture(
"kalimba.jpg");
1031 ASSERT_TRUE(bridge && boston && kalimba);
1049 entity.SetContents(blend1);
1050 return entity.Render(context, pass);
1052 ASSERT_TRUE(OpenPlaygroundHere(
callback));
1057 CreateTextureForFixture(
"boston.jpg",
true);
1058 ASSERT_TRUE(boston);
1061 const char* input_type_names[] = {
"Texture",
"Solid Color"};
1062 const char* blur_type_names[] = {
"Image blur",
"Mask blur"};
1063 const char* pass_variation_names[] = {
"New"};
1064 const char* blur_style_names[] = {
"Normal",
"Solid",
"Outer",
"Inner"};
1065 const char* tile_mode_names[] = {
"Clamp",
"Repeat",
"Mirror",
"Decal"};
1074 static int selected_input_type = 0;
1076 static int selected_blur_type = 0;
1077 static int selected_pass_variation = 0;
1078 static bool combined_sigma =
false;
1079 static float blur_amount_coarse[2] = {0, 0};
1080 static float blur_amount_fine[2] = {10, 10};
1081 static int selected_blur_style = 0;
1082 static int selected_tile_mode = 3;
1083 static Color cover_color(1, 0, 0, 0.2);
1084 static Color bounds_color(0, 1, 0, 0.1);
1085 static float offset[2] = {500, 400};
1086 static float rotation = 0;
1087 static float scale[2] = {0.65, 0.65};
1088 static float skew[2] = {0, 0};
1089 static float path_rect[4] = {0, 0,
1090 static_cast<float>(boston->GetSize().width),
1091 static_cast<float>(boston->GetSize().height)};
1093 ImGui::Begin(
"Controls",
nullptr, ImGuiWindowFlags_AlwaysAutoResize);
1095 ImGui::Combo(
"Input type", &selected_input_type, input_type_names,
1096 sizeof(input_type_names) /
sizeof(
char*));
1097 if (selected_input_type == 0) {
1098 ImGui::SliderFloat(
"Input opacity", &input_color.
alpha, 0, 1);
1100 ImGui::ColorEdit4(
"Input color",
1101 reinterpret_cast<float*
>(&input_color));
1103 ImGui::Combo(
"Blur type", &selected_blur_type, blur_type_names,
1104 sizeof(blur_type_names) /
sizeof(
char*));
1105 if (selected_blur_type == 0) {
1106 ImGui::Combo(
"Pass variation", &selected_pass_variation,
1107 pass_variation_names,
1108 sizeof(pass_variation_names) /
sizeof(
char*));
1110 ImGui::Checkbox(
"Combined sigma", &combined_sigma);
1111 if (combined_sigma) {
1112 ImGui::SliderFloat(
"Sigma (coarse)", blur_amount_coarse, 0, 1000);
1113 ImGui::SliderFloat(
"Sigma (fine)", blur_amount_fine, 0, 10);
1114 blur_amount_coarse[1] = blur_amount_coarse[0];
1115 blur_amount_fine[1] = blur_amount_fine[0];
1117 ImGui::SliderFloat2(
"Sigma (coarse)", blur_amount_coarse, 0, 1000);
1118 ImGui::SliderFloat2(
"Sigma (fine)", blur_amount_fine, 0, 10);
1120 ImGui::Combo(
"Blur style", &selected_blur_style, blur_style_names,
1121 sizeof(blur_style_names) /
sizeof(
char*));
1122 ImGui::Combo(
"Tile mode", &selected_tile_mode, tile_mode_names,
1123 sizeof(tile_mode_names) /
sizeof(
char*));
1124 ImGui::ColorEdit4(
"Cover color",
reinterpret_cast<float*
>(&cover_color));
1125 ImGui::ColorEdit4(
"Bounds color",
1126 reinterpret_cast<float*
>(&bounds_color));
1127 ImGui::SliderFloat2(
"Translation",
offset, 0,
1128 pass.GetRenderTargetSize().width);
1129 ImGui::SliderFloat(
"Rotation", &rotation, 0,
kPi * 2);
1130 ImGui::SliderFloat2(
"Scale",
scale, 0, 3);
1131 ImGui::SliderFloat2(
"Skew", skew, -3, 3);
1132 ImGui::SliderFloat4(
"Path XYWH", path_rect, -1000, 1000);
1136 auto blur_sigma_x =
Sigma{blur_amount_coarse[0] + blur_amount_fine[0]};
1137 auto blur_sigma_y =
Sigma{blur_amount_coarse[1] + blur_amount_fine[1]};
1139 std::shared_ptr<Contents> input;
1143 Rect::MakeXYWH(path_rect[0], path_rect[1], path_rect[2], path_rect[3]);
1144 if (selected_input_type == 0) {
1145 auto texture = std::make_shared<TextureContents>();
1147 texture->SetDestinationRect(input_rect);
1152 input_size = input_rect.GetSize();
1154 auto fill = std::make_shared<SolidColorContents>();
1155 fill->SetColor(input_color);
1160 input_size = input_rect.GetSize();
1163 std::shared_ptr<FilterContents> blur;
1164 switch (selected_pass_variation) {
1166 blur = std::make_shared<GaussianBlurFilterContents>(
1167 blur_sigma_x.sigma, blur_sigma_y.sigma,
1168 tile_modes[selected_tile_mode], blur_styles[selected_blur_style],
1175 tile_modes[selected_tile_mode], blur_styles[selected_blur_style]);
1182 blur_styles[selected_blur_style]);
1191 auto target_contents = selected_blur_type == 0 ? blur : mask_blur;
1197 entity.
Render(context, pass);
1206 cover_entity.
Render(context, pass);
1210 std::optional<Rect> target_contents_coverage =
1212 if (target_contents_coverage.has_value()) {
1215 .
AddRect(target_contents->GetCoverage(entity).value())
1220 bounds_entity.
Render(context, pass);
1225 ASSERT_TRUE(OpenPlaygroundHere(
callback));
1229 auto boston = CreateTextureForFixture(
"boston.jpg");
1230 ASSERT_TRUE(boston);
1233 const char* morphology_type_names[] = {
"Dilate",
"Erode"};
1238 static int selected_morphology_type = 0;
1239 static float radius[2] = {20, 20};
1240 static Color cover_color(1, 0, 0, 0.2);
1241 static Color bounds_color(0, 1, 0, 0.1);
1242 static float offset[2] = {500, 400};
1243 static float rotation = 0;
1244 static float scale[2] = {0.65, 0.65};
1245 static float skew[2] = {0, 0};
1246 static float path_rect[4] = {0, 0,
1247 static_cast<float>(boston->GetSize().width),
1248 static_cast<float>(boston->GetSize().height)};
1249 static float effect_transform_scale = 1;
1251 ImGui::Begin(
"Controls",
nullptr, ImGuiWindowFlags_AlwaysAutoResize);
1253 ImGui::Combo(
"Morphology type", &selected_morphology_type,
1254 morphology_type_names,
1255 sizeof(morphology_type_names) /
sizeof(
char*));
1256 ImGui::SliderFloat2(
"Radius", radius, 0, 200);
1257 ImGui::SliderFloat(
"Input opacity", &input_color.
alpha, 0, 1);
1258 ImGui::ColorEdit4(
"Cover color",
reinterpret_cast<float*
>(&cover_color));
1259 ImGui::ColorEdit4(
"Bounds color",
1260 reinterpret_cast<float*
>(&bounds_color));
1261 ImGui::SliderFloat2(
"Translation",
offset, 0,
1262 pass.GetRenderTargetSize().width);
1263 ImGui::SliderFloat(
"Rotation", &rotation, 0,
kPi * 2);
1264 ImGui::SliderFloat2(
"Scale",
scale, 0, 3);
1265 ImGui::SliderFloat2(
"Skew", skew, -3, 3);
1266 ImGui::SliderFloat4(
"Path XYWH", path_rect, -1000, 1000);
1267 ImGui::SliderFloat(
"Effect transform scale", &effect_transform_scale, 0,
1272 std::shared_ptr<Contents> input;
1276 Rect::MakeXYWH(path_rect[0], path_rect[1], path_rect[2], path_rect[3]);
1277 auto texture = std::make_shared<TextureContents>();
1279 texture->SetDestinationRect(input_rect);
1284 input_size = input_rect.GetSize();
1288 morphology_types[selected_morphology_type]);
1290 Vector2{effect_transform_scale, effect_transform_scale}));
1303 entity.
Render(context, pass);
1312 cover_entity.
Render(context, pass);
1321 bounds_entity.
Render(context, pass);
1325 ASSERT_TRUE(OpenPlaygroundHere(
callback));
1337 entity.
SetContents(std::make_shared<SolidColorContents>());
1348 auto contents = std::make_unique<SolidColorContents>();
1349 contents->SetGeometry(std::move(geometry));
1354 ASSERT_TRUE(actual.has_value());
1365 auto contents = std::make_unique<SolidColorContents>();
1366 contents->SetGeometry(std::move(geometry));
1372 ASSERT_TRUE(actual.has_value());
1383 auto contents = std::make_unique<SolidColorContents>();
1384 contents->SetGeometry(std::move(geometry));
1389 ASSERT_TRUE(actual.has_value());
1395 auto fill = std::make_shared<SolidColorContents>();
1405 auto actual = border_mask_blur->GetCoverage(
e);
1407 ASSERT_TRUE(actual.has_value());
1414 auto actual = border_mask_blur->GetCoverage(
e);
1415 auto expected =
Rect::MakeXYWH(-287.792, -4.94975, 504.874, 504.874);
1416 ASSERT_TRUE(actual.has_value());
1424 auto fill = std::make_shared<SolidColorContents>();
1430 auto coverage = fill->GetCoverage({});
1437 auto fill = std::make_shared<SolidColorContents>();
1454 auto fill = std::make_shared<SolidColorContents>();
1459 auto coverage = fill->GetCoverage({});
1460 ASSERT_FALSE(
coverage.has_value());
1467 auto fill = std::make_shared<SolidColorContents>();
1476 auto fill = std::make_shared<SolidColorContents>();
1487 auto fill = std::make_shared<SolidColorContents>();
1497 auto fill = std::make_shared<SolidColorContents>();
1515 auto clip = std::make_shared<ClipContents>();
1526 auto restore = std::make_shared<ClipRestoreContents>();
1537 auto clip = std::make_shared<ClipContents>();
1541 ASSERT_FALSE(
result.coverage.has_value());
1546 auto clip = std::make_shared<ClipContents>();
1552 ASSERT_FALSE(
result.coverage.has_value());
1557 auto clip = std::make_shared<ClipContents>();
1562 ASSERT_FALSE(
result.coverage.has_value());
1567 auto clip = std::make_shared<ClipContents>();
1574 ASSERT_TRUE(
result.coverage.has_value());
1581 auto clip = std::make_shared<ClipContents>();
1588 ASSERT_TRUE(
result.coverage.has_value());
1597 static float corner_radius = 100;
1598 static float blur_radius = 100;
1599 static bool show_coverage =
false;
1602 ImGui::Begin(
"Controls",
nullptr, ImGuiWindowFlags_AlwaysAutoResize);
1603 ImGui::SliderFloat(
"Corner radius", &corner_radius, 0, 300);
1604 ImGui::SliderFloat(
"Blur radius", &blur_radius, 0, 300);
1605 ImGui::ColorEdit4(
"Color",
reinterpret_cast<Scalar*
>(&
color));
1606 ImGui::Checkbox(
"Show coverage", &show_coverage);
1607 if (show_coverage) {
1608 ImGui::ColorEdit4(
"Coverage color",
1609 reinterpret_cast<Scalar*
>(&coverage_color));
1616 auto [top_left, bottom_right] =
1619 Rect::MakeLTRB(top_left.x, top_left.y, bottom_right.x, bottom_right.y);
1621 auto contents = std::make_unique<SolidRRectBlurContents>();
1622 contents->SetRRect(
rect, {corner_radius, corner_radius});
1623 contents->SetColor(
color);
1624 contents->SetSigma(
Radius(blur_radius));
1629 entity.
Render(context, pass);
1632 if (show_coverage &&
coverage.has_value()) {
1633 auto bounds_contents = std::make_unique<SolidColorContents>();
1636 bounds_contents->SetColor(coverage_color.
Premultiply());
1638 bounds_entity.
SetContents(std::move(bounds_contents));
1639 bounds_entity.
Render(context, pass);
1644 ASSERT_TRUE(OpenPlaygroundHere(
callback));
1649 auto fill = std::make_shared<SolidColorContents>();
1669 auto actual = filter->GetCoverage(
e);
1672 ASSERT_TRUE(actual.has_value());
1677 auto bay_bridge = CreateTextureForFixture(
"bay_bridge.jpg");
1678 ASSERT_TRUE(bay_bridge);
1688 static float offset[2] = {500, 400};
1689 static float rotation = 0;
1690 static float scale[2] = {0.65, 0.65};
1691 static float skew[2] = {0, 0};
1694 ImGui::Begin(
"Color Matrix",
nullptr, ImGuiWindowFlags_AlwaysAutoResize);
1696 std::string label =
"##1";
1697 for (
int i = 0;
i < 20;
i += 5) {
1698 ImGui::InputScalarN(label.c_str(), ImGuiDataType_Float,
1699 &(color_matrix.
array[
i]), 5,
nullptr,
nullptr,
1704 ImGui::SliderFloat2(
"Translation", &
offset[0], 0,
1705 pass.GetRenderTargetSize().width);
1706 ImGui::SliderFloat(
"Rotation", &rotation, 0,
kPi * 2);
1707 ImGui::SliderFloat2(
"Scale", &
scale[0], 0, 3);
1708 ImGui::SliderFloat2(
"Skew", &skew[0], -3, 3);
1726 entity.
Render(context, pass);
1731 ASSERT_TRUE(OpenPlaygroundHere(
callback));
1736 auto fill = std::make_shared<SolidColorContents>();
1748 auto actual = filter->GetCoverage(
e);
1751 ASSERT_TRUE(actual.has_value());
1756 auto image = CreateTextureForFixture(
"kalimba.jpg");
1779 return entity_left.
Render(context, pass) &&
1780 entity_right.
Render(context, pass);
1783 ASSERT_TRUE(OpenPlaygroundHere(
callback));
1788 auto fill = std::make_shared<SolidColorContents>();
1800 auto actual = filter->GetCoverage(
e);
1803 ASSERT_TRUE(actual.has_value());
1808 auto image = CreateTextureForFixture(
"embarcadero.jpg");
1831 return entity_left.
Render(context, pass) &&
1832 entity_right.
Render(context, pass);
1835 ASSERT_TRUE(OpenPlaygroundHere(
callback));
1840 switch (yuv_color_space) {
1842 yuv.
x = rgb.
x * 0.299 + rgb.
y * 0.587 + rgb.
z * 0.114;
1843 yuv.
y = rgb.
x * -0.169 + rgb.
y * -0.331 + rgb.
z * 0.5 + 0.5;
1844 yuv.
z = rgb.
x * 0.5 + rgb.
y * -0.419 + rgb.
z * -0.081 + 0.5;
1847 yuv.
x = rgb.
x * 0.257 + rgb.
y * 0.516 + rgb.
z * 0.100 + 0.063;
1848 yuv.
y = rgb.
x * -0.145 + rgb.
y * -0.291 + rgb.
z * 0.439 + 0.5;
1849 yuv.
z = rgb.
x * 0.429 + rgb.
y * -0.368 + rgb.
z * -0.071 + 0.5;
1858 Vector3 red = {244.0 / 255.0, 67.0 / 255.0, 54.0 / 255.0};
1859 Vector3 green = {76.0 / 255.0, 175.0 / 255.0, 80.0 / 255.0};
1860 Vector3 blue = {33.0 / 255.0, 150.0 / 255.0, 243.0 / 255.0};
1861 Vector3 white = {1.0, 1.0, 1.0};
1866 std::vector<Vector3> yuvs{red_yuv, green_yuv, blue_yuv, white_yuv};
1867 std::vector<uint8_t> y_data;
1868 std::vector<uint8_t> uv_data;
1869 for (
int i = 0;
i < 4;
i++) {
1874 for (
int j = 0; j < 16; j++) {
1875 y_data.push_back(
y);
1877 for (
int j = 0; j < 8; j++) {
1878 uv_data.push_back(j % 2 == 0 ? u : v);
1882 auto blit_pass = cmd_buffer->CreateBlitPass();
1887 y_texture_descriptor.
size = {8, 8};
1890 auto y_mapping = std::make_shared<fml::DataMapping>(y_data);
1891 auto y_mapping_buffer =
1899 uv_texture_descriptor.
size = {4, 4};
1902 auto uv_mapping = std::make_shared<fml::DataMapping>(uv_data);
1903 auto uv_mapping_buffer =
1910 FML_DLOG(
ERROR) <<
"Could not copy contents into Y/UV texture.";
1913 return {y_texture, uv_texture};
1919 GTEST_SKIP_(
"YUV to RGB filter is not supported on OpenGLES backend yet.");
1925 for (
int i = 0;
i < 2;
i++) {
1926 auto yuv_color_space = yuv_color_space_array[
i];
1930 textures[0], textures[1], yuv_color_space);
1933 auto snapshot = filter_contents->RenderToSnapshot(context, filter_entity);
1937 contents->SetTexture(snapshot->texture);
1938 contents->SetSourceRect(
Rect::MakeSize(snapshot->texture->GetSize()));
1942 entity.
Render(context, pass);
1946 ASSERT_TRUE(OpenPlaygroundHere(
callback));
1950 auto runtime_stages =
1951 OpenAssetAsRuntimeStage(
"runtime_stage_example.frag.iplr");
1952 auto runtime_stage =
1954 ASSERT_TRUE(runtime_stage);
1955 ASSERT_TRUE(runtime_stage->IsDirty());
1957 bool expect_dirty =
true;
1960 EXPECT_EQ(runtime_stage->IsDirty(), expect_dirty);
1962 auto contents = std::make_shared<RuntimeEffectContents>();
1964 contents->SetRuntimeStage(runtime_stage);
1966 struct FragUniforms {
1971 .iTime =
static_cast<Scalar>(GetSecondsElapsed()),
1973 auto uniform_data = std::make_shared<std::vector<uint8_t>>();
1974 uniform_data->resize(
sizeof(FragUniforms));
1975 memcpy(uniform_data->data(), &frag_uniforms,
sizeof(FragUniforms));
1976 contents->SetUniformData(uniform_data);
1980 bool result = contents->Render(context, entity, pass);
1983 EXPECT_NE(first_pipeline, pass.GetCommands().back().pipeline.get());
1984 first_pipeline = pass.GetCommands().back().pipeline.get();
1986 EXPECT_EQ(pass.GetCommands().back().pipeline.get(), first_pipeline);
1989 expect_dirty =
false;
1994 auto content_context = GetContentContext();
1997 content_context->GetRenderTargetCache()->CreateOffscreen(
1998 *content_context->GetContext(), {1, 1}, 1u);
2001 callback(*content_context, mock_pass);
2002 callback(*content_context, mock_pass);
2005 runtime_stages = OpenAssetAsRuntimeStage(
"runtime_stage_example.frag.iplr");
2009 ASSERT_TRUE(runtime_stage->IsDirty());
2010 expect_dirty =
true;
2012 callback(*content_context, mock_pass);
2017 auto runtime_stages =
2018 OpenAssetAsRuntimeStage(
"runtime_stage_example.frag.iplr");
2019 auto runtime_stage =
2021 ASSERT_TRUE(runtime_stage);
2022 ASSERT_TRUE(runtime_stage->IsDirty());
2024 auto contents = std::make_shared<RuntimeEffectContents>();
2027 contents->SetRuntimeStage(runtime_stage);
2029 struct FragUniforms {
2034 .iTime =
static_cast<Scalar>(GetSecondsElapsed()),
2036 auto uniform_data = std::make_shared<std::vector<uint8_t>>();
2037 uniform_data->resize(
sizeof(FragUniforms));
2038 memcpy(uniform_data->data(), &frag_uniforms,
sizeof(FragUniforms));
2039 contents->SetUniformData(uniform_data);
2047 GetContentContext()->GetRenderTargetCache()->CreateOffscreenMSAA(
2048 *
GetContext(), {GetWindowSize().width, GetWindowSize().height}, 1,
2049 "RuntimeEffect Texture");
2052 ASSERT_TRUE(contents->Render(*GetContentContext(), entity, pass));
2055 ASSERT_TRUE(
command.pipeline->GetDescriptor()
2056 .GetDepthStencilAttachmentDescriptor()
2058 ASSERT_TRUE(
command.pipeline->GetDescriptor()
2059 .GetFrontStencilAttachmentDescriptor()
2064 auto runtime_stages =
2065 OpenAssetAsRuntimeStage(
"runtime_stage_example.frag.iplr");
2066 auto runtime_stage =
2068 ASSERT_TRUE(runtime_stage);
2069 ASSERT_TRUE(runtime_stage->IsDirty());
2071 auto contents = std::make_shared<RuntimeEffectContents>();
2072 contents->SetRuntimeStage(runtime_stage);
2074 EXPECT_TRUE(contents->BootstrapShader(*GetContentContext()));
2079 GTEST_SKIP() <<
"Test only applies to Vulkan";
2082 auto runtime_stages =
2083 OpenAssetAsRuntimeStage(
"runtime_stage_example.frag.iplr");
2084 auto runtime_stage =
2086 ASSERT_TRUE(runtime_stage);
2087 ASSERT_TRUE(runtime_stage->IsDirty());
2089 auto contents = std::make_shared<RuntimeEffectContents>();
2091 contents->SetRuntimeStage(runtime_stage);
2093 struct FragUniforms {
2098 .iTime =
static_cast<Scalar>(GetSecondsElapsed()),
2100 auto uniform_data = std::make_shared<std::vector<uint8_t>>();
2101 uniform_data->resize(
sizeof(FragUniforms));
2102 memcpy(uniform_data->data(), &frag_uniforms,
sizeof(FragUniforms));
2103 contents->SetUniformData(uniform_data);
2108 auto context = GetContentContext();
2110 *context->GetContext(), {1, 1}, 1u);
2113 ASSERT_TRUE(contents->Render(*context, entity, pass));
2116 ASSERT_EQ(
command.fragment_bindings.buffers.size(), 1u);
2121 EXPECT_EQ(
command.fragment_bindings.buffers[0].view.resource.range.length,
2129 auto texture_contents = std::make_shared<TextureContents>();
2130 texture_contents->SetOpacity(0.5);
2131 ASSERT_TRUE(texture_contents->CanInheritOpacity(entity));
2133 texture_contents->SetInheritedOpacity(0.5);
2134 ASSERT_EQ(texture_contents->GetOpacity(), 0.25);
2135 texture_contents->SetInheritedOpacity(0.5);
2136 ASSERT_EQ(texture_contents->GetOpacity(), 0.25);
2140 auto solid_color = std::make_shared<SolidColorContents>();
2141 solid_color->SetGeometry(
2143 solid_color->SetColor(
Color::Blue().WithAlpha(0.5));
2145 ASSERT_TRUE(solid_color->CanInheritOpacity(entity));
2147 solid_color->SetInheritedOpacity(0.5);
2148 ASSERT_EQ(solid_color->GetColor().alpha, 0.25);
2149 solid_color->SetInheritedOpacity(0.5);
2150 ASSERT_EQ(solid_color->GetColor().alpha, 0.25);
2154 auto tiled_texture = std::make_shared<TiledTextureContents>();
2155 tiled_texture->SetGeometry(
2157 tiled_texture->SetOpacityFactor(0.5);
2159 ASSERT_TRUE(tiled_texture->CanInheritOpacity(entity));
2161 tiled_texture->SetInheritedOpacity(0.5);
2162 ASSERT_EQ(tiled_texture->GetOpacityFactor(), 0.25);
2163 tiled_texture->SetInheritedOpacity(0.5);
2164 ASSERT_EQ(tiled_texture->GetOpacityFactor(), 0.25);
2171 auto runtime_effect = std::make_shared<RuntimeEffectContents>();
2172 ASSERT_FALSE(runtime_effect->CanInheritOpacity(entity));
2176 auto image = CreateTextureForFixture(
"boston.jpg");
2186 return entity.
Render(context, pass);
2188 ASSERT_TRUE(OpenPlaygroundHere(
callback));
2192 auto image = CreateTextureForFixture(
"boston.jpg");
2202 return entity.
Render(context, pass);
2204 ASSERT_TRUE(OpenPlaygroundHere(
callback));
2208 auto image = CreateTextureForFixture(
"boston.jpg");
2218 return entity.
Render(context, pass);
2220 ASSERT_TRUE(OpenPlaygroundHere(
callback));
2224 auto image = CreateTextureForFixture(
"boston.jpg");
2234 return entity.
Render(context, pass);
2236 ASSERT_TRUE(OpenPlaygroundHere(
callback));
2240 auto image = CreateTextureForFixture(
"boston.jpg");
2250 return entity.
Render(context, pass);
2252 ASSERT_TRUE(OpenPlaygroundHere(
callback));
2325 auto bay_bridge = CreateTextureForFixture(
"bay_bridge.jpg");
2335 std::vector<Point>
points = {{10, 20}, {100, 200}};
2345 auto src_contents = std::make_shared<SolidColorContents>();
2346 src_contents->SetGeometry(
2350 auto dst_contents = std::make_shared<SolidColorContents>();
2351 dst_contents->SetGeometry(
2359 ASSERT_TRUE(OpenPlaygroundHere(std::move(entity)));
2371 if (
GetContext()->GetCapabilities()->SupportsFramebufferFetch()) {
2372 GTEST_SKIP() <<
"Backends that support framebuffer fetch dont use coverage "
2373 "for advanced blends.";
2376 auto contents = std::make_shared<SolidColorContents>();
2388 auto pass = std::make_unique<EntityPass>();
2389 std::shared_ptr<RenderTargetCache> render_target_allocator =
2390 std::make_shared<RenderTargetCache>(
GetContext()->GetResourceAllocator());
2396 auto rt = render_target_allocator->CreateOffscreen(
2402 pass->AddEntity(std::move(entity));
2406 auto contains_size = [&render_target_allocator](
ISize size) ->
bool {
2407 return std::find_if(render_target_allocator->GetRenderTargetDataBegin(),
2408 render_target_allocator->GetRenderTargetDataEnd(),
2410 return data.config.size == size;
2411 }) != render_target_allocator->GetRenderTargetDataEnd();
2415 <<
"The root texture wasn't allocated";
2417 <<
"The ColorBurned texture wasn't allocated (100x100 scales up 2x)";
2421 auto content_context = GetContentContext();
2423 auto default_gyph = content_context->GetGlyphAtlasPipeline({
2425 .has_depth_stencil_attachments =
false,
2427 auto alt_gyph = content_context->GetGlyphAtlasPipeline(
2429 .has_depth_stencil_attachments =
true});
2431 EXPECT_NE(default_gyph, alt_gyph);
2432 EXPECT_EQ(default_gyph->GetDescriptor().GetSpecializationConstants(),
2433 alt_gyph->GetDescriptor().GetSpecializationConstants());
2435 auto use_a8 =
GetContext()->GetCapabilities()->GetDefaultGlyphAtlasFormat() ==
2438 std::vector<Scalar> expected_constants = {
static_cast<Scalar>(use_a8)};
2439 EXPECT_EQ(default_gyph->GetDescriptor().GetSpecializationConstants(),
2440 expected_constants);
2444 auto content_context = GetContentContext();
2445 auto default_color_burn = content_context->GetMorphologyFilterPipeline({
2449 auto decal_supported =
static_cast<Scalar>(
2450 GetContext()->GetCapabilities()->SupportsDecalSamplerAddressMode());
2451 std::vector<Scalar> expected_constants = {decal_supported};
2452 ASSERT_EQ(default_color_burn->GetDescriptor().GetSpecializationConstants(),
2453 expected_constants);
2472 EXPECT_NE(hash_a, hash_b);
2473 EXPECT_NE(hash_b, hash_c);
2474 EXPECT_NE(hash_c, hash_d);
2489 bool expected_layout =
false;
2491 FragmentShader::kDescriptorSetLayouts) {
2492 if (layout.binding == 64 &&
2494 expected_layout =
true;
2505 auto get_result = [
this, &mock_pass](
const Path&
path) {
2508 return geometry->GetPositionBuffer(*GetContentContext(), {}, mock_pass);
2537 GTEST_SKIP() <<
"Validation is only fatal on Vulkan backend.";
2542 GetContentContext()->GetBlendColorBurnPipeline({
2544 .has_depth_stencil_attachments =
false,
2560 GetContentContext()->GetRenderTargetCache()->CreateOffscreen(
2563 auto position_result =
2564 geom->GetPositionBuffer(*GetContentContext(), entity, render_pass);
2566 EXPECT_EQ(position_result.vertex_buffer.vertex_count, 0u);
2578 auto contents = std::make_shared<SolidColorContents>();
2586 ASSERT_TRUE(OpenPlaygroundHere(std::move(entity)));
static void round(SkPoint *p)
static const int points[]
static SkPath clip(const SkPath &path, const SkHalfPlane &plane)
static std::shared_ptr< ColorFilterContents > MakeColorMatrix(FilterInput::Ref input, const ColorMatrix &color_matrix)
static std::shared_ptr< ColorFilterContents > MakeSrgbToLinearFilter(FilterInput::Ref input)
static std::shared_ptr< ColorFilterContents > MakeLinearToSrgbFilter(FilterInput::Ref input)
static std::shared_ptr< ColorFilterContents > MakeBlend(BlendMode blend_mode, FilterInput::Vector inputs, std::optional< Color > foreground_color=std::nullopt)
the [inputs] are expected to be in the order of dst, src.
void SetColors(std::vector< Color > colors)
HostBuffer & GetTransientsBuffer() const
Retrieve the currnent host buffer for transient storage.
std::shared_ptr< Pipeline< PipelineDescriptor > > GetSolidFillPipeline(ContentContextOptions opts) const
virtual bool IsOpaque() const
Whether this Contents only emits opaque source colors from the fragment stage. This value does not ac...
To do anything rendering related with Impeller, you need a context.
virtual std::shared_ptr< CommandQueue > GetCommandQueue() const =0
Return the graphics queue for submitting command buffers.
virtual std::shared_ptr< CommandBuffer > CreateCommandBuffer() const =0
Create a new command buffer. Command buffers can be used to encode graphics, blit,...
virtual std::shared_ptr< Allocator > GetResourceAllocator() const =0
Returns the allocator used to create textures and buffers on the device.
static BufferView AsBufferView(std::shared_ptr< DeviceBuffer > buffer)
Create a buffer view of this entire buffer.
void AddEntity(Entity entity)
Add an entity to the current entity pass.
std::optional< Rect > GetSubpassCoverage(const EntityPass &subpass, std::optional< Rect > coverage_limit) const
Computes the coverage of a given subpass. This is used to determine the texture size of a given subpa...
EntityPass * AddSubpass(std::unique_ptr< EntityPass > pass)
Appends a given pass as a subpass.
std::optional< Rect > GetElementsCoverage(std::optional< Rect > coverage_limit) const
void SetTransform(const Matrix &transform)
Set the global transform matrix for this Entity.
std::optional< Rect > GetCoverage() const
BlendMode GetBlendMode() const
void SetContents(std::shared_ptr< Contents > contents)
void SetBlendMode(BlendMode blend_mode)
bool Render(const ContentContext &renderer, RenderPass &parent_pass) const
const Matrix & GetTransform() const
Get the global transform matrix for this Entity.
static constexpr BlendMode kLastPipelineBlendMode
bool ShouldRender(const std::optional< Rect > &clip_coverage) const
static std::shared_ptr< FilterContents > MakeGaussianBlur(const FilterInput::Ref &input, Sigma sigma_x, Sigma sigma_y, Entity::TileMode tile_mode=Entity::TileMode::kDecal, BlurStyle mask_blur_style=BlurStyle::kNormal, const std::shared_ptr< Geometry > &mask_geometry=nullptr)
@ kNormal
Blurred inside and outside.
@ kOuter
Nothing inside, blurred outside.
@ kInner
Blurred inside, nothing outside.
@ kSolid
Solid inside, blurred outside.
static std::shared_ptr< FilterContents > MakeMorphology(FilterInput::Ref input, Radius radius_x, Radius radius_y, MorphType morph_type)
static std::shared_ptr< FilterContents > MakeBorderMaskBlur(FilterInput::Ref input, Sigma sigma_x, Sigma sigma_y, BlurStyle blur_style=BlurStyle::kNormal)
static std::shared_ptr< FilterContents > MakeYUVToRGBFilter(std::shared_ptr< Texture > y_texture, std::shared_ptr< Texture > uv_texture, YUVColorSpace yuv_color_space)
static std::shared_ptr< Geometry > MakeCover()
static std::shared_ptr< Geometry > MakeRect(const Rect &rect)
static std::shared_ptr< Geometry > MakePointField(std::vector< Point > points, Scalar radius, bool round)
static std::shared_ptr< Geometry > MakeStrokePath(const Path &path, Scalar stroke_width=0.0, Scalar miter_limit=4.0, Cap stroke_cap=Cap::kButt, Join stroke_join=Join::kMiter)
static std::shared_ptr< Geometry > MakeFillPath(const Path &path, std::optional< Rect > inner_rect=std::nullopt)
BufferView EmplaceUniform(const UniformType &uniform)
Emplace uniform data onto the host buffer. Ensure that backend specific uniform alignment requirement...
bool IsOpaque() const override
Whether this Contents only emits opaque source colors from the fragment stage. This value does not ac...
void SetTileMode(Entity::TileMode tile_mode)
void SetColors(std::vector< Color > colors)
PathBuilder & AddRect(Rect rect)
Path TakePath(FillType fill=FillType::kNonZero)
PathBuilder & LineTo(Point point, bool relative=false)
Insert a line from the current position to point.
PathBuilder & MoveTo(Point point, bool relative=false)
PathBuilder & AddLine(const Point &p1, const Point &p2)
Move to point p1, then insert a line from p1 to p2.
PathBuilder & AddRoundedRect(Rect rect, RoundingRadii radii)
PathBuilder & AddCubicCurve(Point p1, Point cp1, Point cp2, Point p2)
Move to point p1, then insert a cubic curve from p1 to p2 with control points cp1 and cp2.
PathBuilder & SetConvexity(Convexity value)
void SetTileMode(Entity::TileMode tile_mode)
bool IsOpaque() const override
Whether this Contents only emits opaque source colors from the fragment stage. This value does not ac...
void SetColors(std::vector< Color > colors)
Render passes encode render commands directed as one specific render target into an underlying comman...
virtual const std::vector< Command > & GetCommands() const
Accessor for the current Commands.
VertexShader_ VertexShader
FragmentShader_ FragmentShader
static constexpr AttachmentConfig kDefaultColorAttachmentConfig
bool IsOpaque() const override
Whether this Contents only emits opaque source colors from the fragment stage. This value does not ac...
void SetColor(Color color)
static std::unique_ptr< SolidColorContents > Make(const Path &path, Color color)
A geometry that is created from a stroked path object.
static Scalar RoundScaledFontSize(Scalar scale, Scalar point_size)
static std::shared_ptr< TextureContents > MakeRect(Rect destination)
A common case factory that marks the texture contents as having a destination rectangle....
bool IsOpaque() const override
Whether this Contents only emits opaque source colors from the fragment stage. This value does not ac...
void SetTexture(std::shared_ptr< Texture > texture)
static std::shared_ptr< TypographerContext > Make()
VertexBuffer CreateVertexBuffer(HostBuffer &host_buffer) const
VertexBufferBuilder & AddVertices(std::initializer_list< VertexType_ > vertices)
~TestPassDelegate() override=default
bool CanCollapseIntoParentPass(EntityPass *entity_pass) override
Whether or not this entity pass can be collapsed into the parent. If true, this method may modify the...
std::shared_ptr< FilterContents > WithImageFilter(const FilterInput::Variant &input, const Matrix &effect_transform) const override
std::shared_ptr< Contents > CreateContentsForSubpassTarget(std::shared_ptr< Texture > target, const Matrix &transform) override
TestPassDelegate(bool collapse=false)
VULKAN_HPP_DEFAULT_DISPATCH_LOADER_DYNAMIC_STORAGE auto & d
FlKeyEvent uint64_t FlKeyResponderAsyncCallback callback
#define FML_DLOG(severity)
#define FML_CHECK(condition)
#define ASSERT_RECT_NEAR(a, b)
#define EXPECT_RECT_NEAR(a, b)
SK_API GrDirectContext * GetContext(const SkImage *src)
unsigned useCenter Optional< SkMatrix > matrix
sk_sp< const SkImage > image
sk_sp< SkBlender > blender SkRect rect
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
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
auto CreatePassWithRectPath(Rect rect, std::optional< Rect > bounds_hint, ContentBoundsPromise bounds_promise=ContentBoundsPromise::kUnknown, bool collapse=false)
EntityPlayground EntityTest
static std::vector< std::shared_ptr< Texture > > CreateTestYUVTextures(Context *context, YUVColorSpace yuv_color_space)
INSTANTIATE_PLAYGROUND_SUITE(AiksTest)
TEST_P(AiksTest, CanRenderAdvancedBlendColorFilterWithSaveLayer)
static Vector3 RGBToYUV(Vector3 rgb, YUVColorSpace yuv_color_space)
@ kPoint
Draws a point at each input vertex.
Point DrawPlaygroundPoint(PlaygroundPoint &point)
std::tuple< Point, Point > DrawPlaygroundLine(PlaygroundPoint &point_a, PlaygroundPoint &point_b)
constexpr RuntimeStageBackend PlaygroundBackendToRuntimeStageBackend(PlaygroundBackend backend)
@ kUnknown
The caller makes no claims related to the size of the bounds.
@ kContainsContents
The caller claims the bounds are a reasonably tight estimate of the coverage of the contents and shou...
void MoveTo(PathBuilder *builder, Scalar x, Scalar y)
void LineTo(PathBuilder *builder, Scalar x, Scalar y)
ContentContextOptions OptionsFromPass(const RenderPass &pass)
void Close(PathBuilder *builder)
const myers::Point & get(const myers::Segment &)
SK_API sk_sp< PrecompileColorFilter > Matrix()
static void draw_rect(SkCanvas *canvas, const SkRect &r, const SkPaint &p)
SIN Vec< N, float > sqrt(const Vec< N, float > &x)
def filtered(names, to_skip)
static SkColor4f transform(SkColor4f c, SkColorSpace *src, SkColorSpace *dst)
static SkString join(const CommandLineFlags::StringArray &)
static constexpr Color BlackTransparent()
static constexpr Color MintCream()
static constexpr Color DeepPink()
static constexpr Color Black()
static constexpr Color CornflowerBlue()
static constexpr Color White()
constexpr Color WithAlpha(Scalar new_alpha) const
static constexpr Color WhiteTransparent()
static constexpr Color Coral()
static constexpr Color Red()
constexpr Color Premultiply() const
static constexpr Color Blue()
static constexpr Color Green()
PrimitiveType primitive_type
bool has_depth_stencil_attachments
@ kNormal
The geometry has no overlapping triangles.
A 4x4 matrix using column-major storage.
static constexpr Matrix MakeTranslation(const Vector3 &t)
constexpr bool IsIdentity() const
static Matrix MakeRotationY(Radians r)
static constexpr Matrix MakeSkew(Scalar sx, Scalar sy)
static Matrix MakeRotationZ(Radians r)
static constexpr Matrix MakeScale(const Vector3 &s)
static Matrix MakeRotationX(Radians r)
For convolution filters, the "radius" is the size of the convolution kernel to use on the local space...
In filters that use Gaussian distributions, "sigma" is a size of one standard deviation in terms of t...
static constexpr TRect MakeXYWH(Type x, Type y, Type width, Type height)
static constexpr TRect MakeSize(const TSize< U > &size)
static constexpr TRect MakeLTRB(Type left, Type top, Type right, Type bottom)
static constexpr TSize MakeWH(Type width, Type height)
A lightweight object that describes the attributes of a texture that can then used an allocator to cr...
std::shared_ptr< const fml::Mapping > data
#define EXPECT_TRUE(handle)