5#include "flutter/impeller/aiks/aiks_unittests.h"
10#include "third_party/imgui/imgui.h"
24 paint.stroke_width = 20.0;
28 ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
35 paint.stroke_width = 25.0;
38 ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
45 paint.stroke_width = 100.0;
48 ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
57 paint.stroke_width = 0.01;
60 ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
69 paint.stroke_width = 200;
76 ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
85 paint.stroke_width = 20;
88 builder.AddCubicCurve({0, 200}, {50, 400}, {350, 0}, {400, 200});
91 ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
101 paint.stroke_width = 50;
107 builder.QuadraticCurveTo({100, 100}, {250, 250});
110 ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
128 builder.AddCircle({200, 200}, 50);
132 std::make_shared<Image>(CreateTextureForFixture(
"boston.jpg")), {10, 10},
136 ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
158 paint.stroke_width = 10;
162 ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
180 paint.stroke_width = 10;
184 ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
191 static float scale = 3;
192 static bool add_circle_clip =
true;
195 ImGuiWindowFlags_AlwaysAutoResize)) {
196 ImGui::ColorEdit4(
"Color",
reinterpret_cast<float*
>(&
color));
197 ImGui::SliderFloat(
"Scale", &
scale, 0, 6);
198 ImGui::Checkbox(
"Circle clip", &add_circle_clip);
203 canvas.Scale(GetContentScale());
207 canvas.DrawPaint(
paint);
211 paint.stroke_width = 10;
215 .QuadraticCurveTo({60, 20}, {60, 60})
218 .QuadraticCurveTo({60, 60}, {20, 60})
223 if (add_circle_clip) {
228 auto [handle_a, handle_b] =
231 auto screen_to_canvas = canvas.GetCurrentTransform().Invert();
232 Point point_a = screen_to_canvas * handle_a * GetContentScale();
233 Point point_b = screen_to_canvas * handle_b * GetContentScale();
235 Point middle = (point_a + point_b) / 2;
236 auto radius = point_a.GetDistance(middle);
243 paint.stroke_cap = cap;
245 canvas.Translate({80, 0});
247 canvas.Translate({-240, 60});
250 return canvas.EndRecordingAsPicture();
253 ASSERT_TRUE(OpenPlaygroundHere(
callback));
258 canvas.Scale(GetContentScale());
261 paint.stroke_width = 10;
265 paint.stroke_cap = cap;
266 Point origin = {100, 100};
269 canvas.DrawLine({150, 100}, {250, 100},
paint);
270 for (
int d = 15;
d < 90;
d += 15) {
272 canvas.DrawLine(origin +
m * p0, origin +
m * p1,
paint);
274 canvas.DrawLine({100, 150}, {100, 250},
paint);
275 canvas.DrawCircle({origin}, 35,
paint);
277 canvas.DrawLine({250, 250}, {250, 250},
paint);
279 canvas.Translate({250, 0});
281 canvas.Translate({-750, 250});
284 std::vector<Color>
colors = {
285 Color{0x1f / 255.0, 0.0, 0x5c / 255.0, 1.0},
286 Color{0x5b / 255.0, 0.0, 0x60 / 255.0, 1.0},
287 Color{0x87 / 255.0, 0x01 / 255.0, 0x60 / 255.0, 1.0},
288 Color{0xac / 255.0, 0x25 / 255.0, 0x53 / 255.0, 1.0},
289 Color{0xe1 / 255.0, 0x6b / 255.0, 0x5c / 255.0, 1.0},
290 Color{0xf3 / 255.0, 0x90 / 255.0, 0x60 / 255.0, 1.0},
291 Color{0xff / 255.0, 0xb5 / 255.0, 0x6b / 250.0, 1.0}};
292 std::vector<Scalar> stops = {
302 auto texture = CreateTextureForFixture(
"airplane.jpg",
308 {100, 100}, 200, std::move(
colors), std::move(stops),
317 ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
325 paint.stroke_width = 10;
327 canvas.Translate({100, 100});
332 ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
340 paint.stroke_width = 10;
343 canvas.Translate({100, 100});
348 ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
353 for (
auto i = 0;
i < 10;
i++) {
357 builder.MoveTo({100.f + 50.f *
i - 100, 100.f + 50.f *
i});
358 builder.LineTo({100.f + 50.f *
i, 100.f + 50.f *
i - 100});
359 builder.LineTo({100.f + 50.f *
i - 100, 100.f + 50.f *
i - 100});
366 canvas.DrawPath(
builder.TakePath(), {.color = Color::Red().WithAlpha(0.4)});
368 ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
373 canvas.Scale(GetContentScale());
377 std::vector<Color>
colors = {
Color{1.0, 0.0, 0.0, 1.0},
378 Color{0.0, 0.0, 0.0, 1.0}};
379 std::vector<Scalar> stops = {0.0, 1.0};
394 canvas.EndRecordingAsPicture();
404 ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
419 const Scalar kTriangleHeight = 100;
420 canvas.Translate(
Vector2(200, 200));
426 .
MoveTo({0, kTriangleHeight})
427 .
LineTo({-kTriangleHeight / 2.0f, 0})
428 .
LineTo({kTriangleHeight / 2.0f, 0})
432 kTriangleHeight, kTriangleHeight),
438 canvas.Translate(
Vector2(100, 0));
442 .
MoveTo({0, kTriangleHeight})
443 .
LineTo({-kTriangleHeight / 2.0f, 0})
445 .
LineTo({kTriangleHeight / 2.0f, 0})
449 kTriangleHeight, kTriangleHeight),
456 ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
static void draw(SkCanvas *canvas, SkRect &target, int x, int y)
static bool ImGuiBegin(const char *name, bool *p_open, ImGuiWindowFlags flags)
static ColorSource MakeRadialGradient(Point center, Scalar radius, std::vector< Color > colors, std::vector< Scalar > stops, Entity::TileMode tile_mode, Matrix effect_transform)
static ColorSource MakeImage(std::shared_ptr< Texture > texture, Entity::TileMode x_tile_mode, Entity::TileMode y_tile_mode, SamplerDescriptor sampler_descriptor, Matrix effect_transform)
static ColorSource MakeSweepGradient(Point center, Degrees start_angle, Degrees end_angle, std::vector< Color > colors, std::vector< Scalar > stops, Entity::TileMode tile_mode, Matrix effect_transform)
@ kNormal
Blurred inside and outside.
PathBuilder & AddRect(Rect rect)
Path TakePath(FillType fill=FillType::kNonZero)
PathBuilder & MoveTo(Point point, bool relative=false)
PathBuilder & AddCircle(const Point ¢er, Scalar radius)
PathBuilder & AddLine(const Point &p1, const Point &p2)
Move to point p1, then insert a line from p1 to p2.
VULKAN_HPP_DEFAULT_DISPATCH_LOADER_DYNAMIC_STORAGE auto & d
FlKeyEvent uint64_t FlKeyResponderAsyncCallback callback
sk_sp< SkBlender > blender SkRect rect
PODArray< SkColor > colors
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
TEST_P(AiksTest, CanRenderAdvancedBlendColorFilterWithSaveLayer)
std::tuple< Point, Point > DrawPlaygroundLine(PlaygroundPoint &point_a, PlaygroundPoint &point_b)
void LineTo(PathBuilder *builder, Scalar x, Scalar y)
void Close(PathBuilder *builder)
static SkString join(const CommandLineFlags::StringArray &)
static constexpr Color Fuchsia()
static constexpr Color Black()
static constexpr Color White()
constexpr Color WithAlpha(Scalar new_alpha) const
static constexpr Color Red()
static constexpr Color Blue()
A 4x4 matrix using column-major storage.
static constexpr Matrix MakeTranslation(const Vector3 &t)
static Matrix MakeRotationZ(Radians r)
FilterContents::BlurStyle style
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)