| Flutter Impeller |

aiks_dl_vertices_unittests.cc
Go to the documentation of this file.
1 // Copyright 2013 The Flutter Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "display_list/dl_sampling_options.h"
6 #include "display_list/dl_tile_mode.h"
7 #include "display_list/dl_vertices.h"
8 #include "display_list/effects/dl_mask_filter.h"
9 #include "flutter/impeller/display_list/aiks_unittests.h"
10
11 #include "flutter/display_list/dl_blend_mode.h"
12 #include "flutter/display_list/dl_builder.h"
13 #include "flutter/display_list/dl_color.h"
14 #include "flutter/display_list/dl_paint.h"
15 #include "flutter/testing/testing.h"
16 #include "impeller/display_list/dl_dispatcher.h"
17 #include "impeller/display_list/dl_image_impeller.h"
18 #include "impeller/display_list/dl_runtime_effect_impeller.h"
19 #include "third_party/abseil-cpp/absl/status/status_matchers.h"
20
21 namespace impeller {
22 namespace testing {
23
24 using namespace flutter;
25
26 namespace {
27 std::shared_ptr<DlVertices> MakeVertices(
28 DlVertexMode mode,
29 std::vector<DlPoint> vertices,
30 std::vector<uint16_t> indices,
31 std::vector<DlPoint> texture_coordinates,
32 std::vector<DlColor> colors) {
33 DlVertices::Builder::Flags flags(
34 {{texture_coordinates.size() > 0, colors.size() > 0}});
35 DlVertices::Builder builder(mode, vertices.size(), flags, indices.size());
36 if (colors.size() > 0) {
37 builder.store_colors(colors.data());
38 }
39 if (texture_coordinates.size() > 0) {
40 builder.store_texture_coordinates(texture_coordinates.data());
41 }
42 if (indices.size() > 0) {
43 builder.store_indices(indices.data());
44 }
45 builder.store_vertices(vertices.data());
46 return builder.build();
47 }
48 }; // namespace
49
50 // Regression test for https://github.com/flutter/flutter/issues/135441 .
51 TEST_P(AiksTest, VerticesGeometryUVPositionData) {
52 DisplayListBuilder builder;
53 DlPaint paint;
54 auto image =
55 DlImageImpeller::Make(CreateTextureForFixture("table_mountain_nx.png"));
56 auto size = image->impeller_texture()->GetSize();
57
58 paint.setColorSource(
59 DlColorSource::MakeImage(image, DlTileMode::kClamp, DlTileMode::kClamp));
60
61 std::vector<DlPoint> vertex_coordinates = {
62 DlPoint(0, 0),
63 DlPoint(size.width, 0),
64 DlPoint(0, size.height),
65 };
66 auto vertices = MakeVertices(DlVertexMode::kTriangleStrip, vertex_coordinates,
67 {0, 1, 2}, {}, {});
68
69 builder.DrawVertices(vertices, DlBlendMode::kSrcOver, paint);
70 ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
71 }
72
73 // Regression test for https://github.com/flutter/flutter/issues/135441 .
74 TEST_P(AiksTest, VerticesGeometryUVPositionDataWithTranslate) {
75 DisplayListBuilder builder;
76 DlPaint paint;
77 auto image =
78 DlImageImpeller::Make(CreateTextureForFixture("table_mountain_nx.png"));
79 auto size = image->impeller_texture()->GetSize();
80
81 DlMatrix matrix = DlMatrix::MakeTranslation({100, 100});
82 paint.setColorSource(
83 DlColorSource::MakeImage(image, DlTileMode::kClamp, DlTileMode::kClamp,
84 DlImageSampling::kLinear, &matrix));
85
86 std::vector<DlPoint> positions = {
87 DlPoint(0, 0),
88 DlPoint(size.width, 0),
89 DlPoint(0, size.height),
90 };
91 auto vertices =
92 MakeVertices(DlVertexMode::kTriangleStrip, positions, {0, 1, 2}, {}, {});
93
94 builder.DrawVertices(vertices, DlBlendMode::kSrcOver, paint);
95 ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
96 }
97
98 // Regression test for https://github.com/flutter/flutter/issues/145707
99 TEST_P(AiksTest, VerticesGeometryColorUVPositionData) {
100 DisplayListBuilder builder;
101 DlPaint paint;
102 auto image =
103 DlImageImpeller::Make(CreateTextureForFixture("table_mountain_nx.png"));
104 auto size = image->impeller_texture()->GetSize();
105
106 paint.setColorSource(
107 DlColorSource::MakeImage(image, DlTileMode::kClamp, DlTileMode::kClamp));
108
109 std::vector<DlPoint> positions = {
110 DlPoint(0, 0), DlPoint(size.width, 0),
111 DlPoint(0, size.height), DlPoint(size.width, 0),
112 DlPoint(0, 0), DlPoint(size.width, size.height),
113 };
114 std::vector<DlColor> colors = {
115 DlColor::kRed().withAlpha(128), DlColor::kBlue().withAlpha(128),
116 DlColor::kGreen().withAlpha(128), DlColor::kRed().withAlpha(128),
117 DlColor::kBlue().withAlpha(128), DlColor::kGreen().withAlpha(128),
118 };
119
120 auto vertices =
121 MakeVertices(DlVertexMode::kTriangles, positions, {}, {}, colors);
122
123 builder.DrawVertices(vertices, DlBlendMode::kDstOver, paint);
124 ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
125 }
126
127 TEST_P(AiksTest, VerticesGeometryColorUVPositionDataAdvancedBlend) {
128 DisplayListBuilder builder;
129 DlPaint paint;
130 auto image =
131 DlImageImpeller::Make(CreateTextureForFixture("table_mountain_nx.png"));
132 auto size = image->impeller_texture()->GetSize();
133
134 paint.setColorSource(
135 DlColorSource::MakeImage(image, DlTileMode::kClamp, DlTileMode::kClamp));
136
137 std::vector<DlPoint> positions = {
138 DlPoint(0, 0), DlPoint(size.width, 0),
139 DlPoint(0, size.height), DlPoint(size.width, 0),
140 DlPoint(0, 0), DlPoint(size.width, size.height),
141 };
142 std::vector<DlColor> colors = {
143 DlColor::kRed().modulateOpacity(0.5),
144 DlColor::kBlue().modulateOpacity(0.5),
145 DlColor::kGreen().modulateOpacity(0.5),
146 DlColor::kRed().modulateOpacity(0.5),
147 DlColor::kBlue().modulateOpacity(0.5),
148 DlColor::kGreen().modulateOpacity(0.5),
149 };
150
151 auto vertices =
152 MakeVertices(DlVertexMode::kTriangles, positions, {}, {}, colors);
153
154 builder.DrawVertices(vertices, DlBlendMode::kColorBurn, paint);
155 ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
156 }
157
158 // Draw a hexagon using triangle fan
159 TEST_P(AiksTest, CanConvertTriangleFanToTriangles) {
160 constexpr Scalar hexagon_radius = 125;
161 auto hex_start = Point(200.0, -hexagon_radius + 200.0);
162 auto center_to_flat = 1.73 / 2 * hexagon_radius;
163
164 // clang-format off
165 std::vector<DlPoint> vertices = {
166 DlPoint(hex_start.x, hex_start.y),
167 DlPoint(hex_start.x + center_to_flat, hex_start.y + 0.5 * hexagon_radius),
168 DlPoint(hex_start.x + center_to_flat, hex_start.y + 1.5 * hexagon_radius),
169 DlPoint(hex_start.x + center_to_flat, hex_start.y + 1.5 * hexagon_radius),
170 DlPoint(hex_start.x, hex_start.y + 2 * hexagon_radius),
171 DlPoint(hex_start.x, hex_start.y + 2 * hexagon_radius),
172 DlPoint(hex_start.x - center_to_flat, hex_start.y + 1.5 * hexagon_radius),
173 DlPoint(hex_start.x - center_to_flat, hex_start.y + 1.5 * hexagon_radius),
174 DlPoint(hex_start.x - center_to_flat, hex_start.y + 0.5 * hexagon_radius)
175 };
176 // clang-format on
177 auto paint = flutter::DlPaint(flutter::DlColor::kDarkGrey());
178 auto dl_vertices = flutter::DlVertices::Make(
179 flutter::DlVertexMode::kTriangleFan, vertices.size(), vertices.data(),
180 nullptr, nullptr);
181 flutter::DisplayListBuilder builder;
182 builder.DrawVertices(dl_vertices, flutter::DlBlendMode::kSrcOver, paint);
183 ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
184 }
185
186 TEST_P(AiksTest, DrawVerticesSolidColorTrianglesWithoutIndices) {
187 // Use negative coordinates and then scale the transform by -1, -1 to make
188 // sure coverage is taking the transform into account.
189 std::vector<DlPoint> positions = {
190 DlPoint(-100, -300),
191 DlPoint(-200, -100),
192 DlPoint(-300, -300),
193 };
194 std::vector<flutter::DlColor> colors = {flutter::DlColor::kWhite(),
195 flutter::DlColor::kGreen(),
196 flutter::DlColor::kWhite()};
197
198 auto vertices = flutter::DlVertices::Make(
199 flutter::DlVertexMode::kTriangles, 3, positions.data(),
200 /*texture_coordinates=*/nullptr, colors.data());
201
202 flutter::DisplayListBuilder builder;
203 flutter::DlPaint paint;
204
205 paint.setColor(flutter::DlColor::kRed().modulateOpacity(0.5));
206 builder.Scale(-1, -1);
207 builder.DrawVertices(vertices, flutter::DlBlendMode::kSrcOver, paint);
208
209 ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
210 }
211
212 TEST_P(AiksTest, DrawVerticesLinearGradientWithoutIndices) {
213 std::vector<DlPoint> positions = {
214 DlPoint(100, 300),
215 DlPoint(200, 100),
216 DlPoint(300, 300),
217 };
218
219 auto vertices = flutter::DlVertices::Make(
220 flutter::DlVertexMode::kTriangles, 3, positions.data(),
221 /*texture_coordinates=*/nullptr, /*colors=*/nullptr);
222
223 std::vector<flutter::DlColor> colors = {flutter::DlColor::kBlue(),
224 flutter::DlColor::kRed()};
225 const float stops[2] = {0.0, 1.0};
226
227 auto linear = flutter::DlColorSource::MakeLinear(
228 {100.0, 100.0}, {300.0, 300.0}, 2, colors.data(), stops,
229 flutter::DlTileMode::kRepeat);
230
231 flutter::DisplayListBuilder builder;
232 flutter::DlPaint paint;
233
234 paint.setColorSource(linear);
235 builder.DrawVertices(vertices, flutter::DlBlendMode::kSrcOver, paint);
236
237 ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
238 }
239
240 TEST_P(AiksTest, DrawVerticesLinearGradientWithTextureCoordinates) {
241 std::vector<DlPoint> positions = {
242 DlPoint(100, 300),
243 DlPoint(200, 100),
244 DlPoint(300, 300),
245 };
246 std::vector<DlPoint> texture_coordinates = {
247 DlPoint(300, 100),
248 DlPoint(100, 200),
249 DlPoint(300, 300),
250 };
251
252 auto vertices = flutter::DlVertices::Make(
253 flutter::DlVertexMode::kTriangles, 3, positions.data(),
254 texture_coordinates.data(), /*colors=*/nullptr);
255
256 std::vector<flutter::DlColor> colors = {flutter::DlColor::kBlue(),
257 flutter::DlColor::kRed()};
258 const float stops[2] = {0.0, 1.0};
259
260 auto linear = flutter::DlColorSource::MakeLinear(
261 {100.0, 100.0}, {300.0, 300.0}, 2, colors.data(), stops,
262 flutter::DlTileMode::kRepeat);
263
264 flutter::DisplayListBuilder builder;
265 flutter::DlPaint paint;
266
267 paint.setColorSource(linear);
268 builder.DrawVertices(vertices, flutter::DlBlendMode::kSrcOver, paint);
269
270 ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
271 }
272
273 TEST_P(AiksTest, DrawVerticesImageSourceWithTextureCoordinates) {
274 auto texture = CreateTextureForFixture("embarcadero.jpg");
275 auto dl_image = DlImageImpeller::Make(texture);
276 std::vector<DlPoint> positions = {
277 DlPoint(100, 300),
278 DlPoint(200, 100),
279 DlPoint(300, 300),
280 };
281 std::vector<DlPoint> texture_coordinates = {
282 DlPoint(0, 0),
283 DlPoint(100, 200),
284 DlPoint(200, 100),
285 };
286
287 auto vertices = flutter::DlVertices::Make(
288 flutter::DlVertexMode::kTriangles, 3, positions.data(),
289 texture_coordinates.data(), /*colors=*/nullptr);
290
291 flutter::DisplayListBuilder builder;
292 flutter::DlPaint paint;
293
294 auto image_source = flutter::DlColorSource::MakeImage(
295 dl_image, flutter::DlTileMode::kRepeat, flutter::DlTileMode::kRepeat);
296
297 paint.setColorSource(image_source);
298 builder.DrawVertices(vertices, flutter::DlBlendMode::kSrcOver, paint);
299
300 ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
301 }
302
303 TEST_P(AiksTest,
304 DrawVerticesImageSourceWithTextureCoordinatesAndColorBlending) {
305 auto texture = CreateTextureForFixture("embarcadero.jpg");
306 auto dl_image = DlImageImpeller::Make(texture);
307 std::vector<DlPoint> positions = {
308 DlPoint(100, 300),
309 DlPoint(200, 100),
310 DlPoint(300, 300),
311 };
312 std::vector<flutter::DlColor> colors = {flutter::DlColor::kWhite(),
313 flutter::DlColor::kGreen(),
314 flutter::DlColor::kWhite()};
315 std::vector<DlPoint> texture_coordinates = {
316 DlPoint(0, 0),
317 DlPoint(100, 200),
318 DlPoint(200, 100),
319 };
320
321 auto vertices = flutter::DlVertices::Make(
322 flutter::DlVertexMode::kTriangles, 3, positions.data(),
323 texture_coordinates.data(), colors.data());
324
325 flutter::DisplayListBuilder builder;
326 flutter::DlPaint paint;
327
328 auto image_source = flutter::DlColorSource::MakeImage(
329 dl_image, flutter::DlTileMode::kRepeat, flutter::DlTileMode::kRepeat);
330
331 paint.setColorSource(image_source);
332 builder.DrawVertices(vertices, flutter::DlBlendMode::kModulate, paint);
333
334 ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
335 }
336
337 TEST_P(AiksTest, DrawVerticesSolidColorTrianglesWithIndices) {
338 std::vector<DlPoint> positions = {
339 DlPoint(100, 300),
340 DlPoint(200, 100),
341 DlPoint(300, 300),
342 DlPoint(200, 500),
343 };
344 std::vector<uint16_t> indices = {0, 1, 2, 0, 2, 3};
345
346 auto vertices = flutter::DlVertices::Make(
347 flutter::DlVertexMode::kTriangles, positions.size(), positions.data(),
348 /*texture_coordinates=*/nullptr, /*colors=*/nullptr, indices.size(),
349 indices.data());
350
351 flutter::DisplayListBuilder builder;
352 flutter::DlPaint paint;
353
354 paint.setColor(flutter::DlColor::kRed());
355 builder.DrawVertices(vertices, flutter::DlBlendMode::kSrcOver, paint);
356
357 ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
358 }
359
360 TEST_P(AiksTest, DrawVerticesPremultipliesColors) {
361 std::vector<DlPoint> positions = {
362 DlPoint(100, 300),
363 DlPoint(200, 100),
364 DlPoint(300, 300),
365 DlPoint(200, 500),
366 };
367 auto color = flutter::DlColor::kBlue().withAlpha(0x99);
368 std::vector<uint16_t> indices = {0, 1, 2, 0, 2, 3};
369 std::vector<flutter::DlColor> colors = {color, color, color, color};
370
371 auto vertices = flutter::DlVertices::Make(
372 flutter::DlVertexMode::kTriangles, positions.size(), positions.data(),
373 /*texture_coordinates=*/nullptr, colors.data(), indices.size(),
374 indices.data());
375
376 flutter::DisplayListBuilder builder;
377 flutter::DlPaint paint;
378 paint.setBlendMode(flutter::DlBlendMode::kSrcOver);
379 paint.setColor(flutter::DlColor::kRed());
380
381 builder.DrawRect(DlRect::MakeLTRB(0, 0, 400, 400), paint);
382 builder.DrawVertices(vertices, flutter::DlBlendMode::kDst, paint);
383
384 ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
385 }
386
387 TEST_P(AiksTest, DrawVerticesWithInvalidIndices) {
388 std::vector<DlPoint> positions = {
389 DlPoint(100, 300),
390 DlPoint(200, 100),
391 DlPoint(300, 300),
392 DlPoint(200, 500),
393 };
394 std::vector<uint16_t> indices = {0, 1, 2, 0, 2, 3, 99, 100, 101};
395
396 auto vertices = flutter::DlVertices::Make(
397 flutter::DlVertexMode::kTriangles, positions.size(), positions.data(),
398 /*texture_coordinates=*/nullptr, /*colors=*/nullptr, indices.size(),
399 indices.data());
400
401 EXPECT_EQ(vertices->GetBounds(), DlRect::MakeLTRB(100, 100, 300, 500));
402
403 flutter::DisplayListBuilder builder;
404 flutter::DlPaint paint;
405 paint.setBlendMode(flutter::DlBlendMode::kSrcOver);
406 paint.setColor(flutter::DlColor::kRed());
407
408 builder.DrawRect(DlRect::MakeLTRB(0, 0, 400, 400), paint);
409 builder.DrawVertices(vertices, flutter::DlBlendMode::kSrc, paint);
410
411 AiksContext renderer(GetContext(), nullptr);
412 std::shared_ptr<Texture> image =
413 DisplayListToTexture(builder.Build(), {1024, 768}, renderer);
414 EXPECT_TRUE(image);
415 }
416
417 // All four vertices should form a solid red rectangle with no gaps.
418 // The blue rectangle drawn under them should not be visible.
419 TEST_P(AiksTest, DrawVerticesTextureCoordinatesWithFragmentShader) {
420 std::vector<DlPoint> positions_lt = {
421 DlPoint(0, 0), //
422 DlPoint(50, 0), //
423 DlPoint(0, 50), //
424 DlPoint(50, 50), //
425 };
426
427 auto vertices_lt = flutter::DlVertices::Make(
428 flutter::DlVertexMode::kTriangleStrip, positions_lt.size(),
429 positions_lt.data(),
430 /*texture_coordinates=*/positions_lt.data(), /*colors=*/nullptr,
431 /*index_count=*/0,
432 /*indices=*/nullptr);
433
434 std::vector<DlPoint> positions_rt = {
435 DlPoint(50, 0), //
436 DlPoint(100, 0), //
437 DlPoint(50, 50), //
438 DlPoint(100, 50), //
439 };
440
441 auto vertices_rt = flutter::DlVertices::Make(
442 flutter::DlVertexMode::kTriangleStrip, positions_rt.size(),
443 positions_rt.data(),
444 /*texture_coordinates=*/positions_rt.data(), /*colors=*/nullptr,
445 /*index_count=*/0,
446 /*indices=*/nullptr);
447
448 std::vector<DlPoint> positions_lb = {
449 DlPoint(0, 50), //
450 DlPoint(50, 50), //
451 DlPoint(0, 100), //
452 DlPoint(50, 100), //
453 };
454
455 auto vertices_lb = flutter::DlVertices::Make(
456 flutter::DlVertexMode::kTriangleStrip, positions_lb.size(),
457 positions_lb.data(),
458 /*texture_coordinates=*/positions_lb.data(), /*colors=*/nullptr,
459 /*index_count=*/0,
460 /*indices=*/nullptr);
461
462 std::vector<DlPoint> positions_rb = {
463 DlPoint(50, 50), //
464 DlPoint(100, 50), //
465 DlPoint(50, 100), //
466 DlPoint(100, 100), //
467 };
468
469 auto vertices_rb = flutter::DlVertices::Make(
470 flutter::DlVertexMode::kTriangleStrip, positions_rb.size(),
471 positions_rb.data(),
472 /*texture_coordinates=*/positions_rb.data(), /*colors=*/nullptr,
473 /*index_count=*/0,
474 /*indices=*/nullptr);
475
476 flutter::DisplayListBuilder builder;
477 flutter::DlPaint paint;
478 flutter::DlPaint rect_paint;
479 rect_paint.setColor(DlColor::kBlue());
480
481 auto runtime_stages_result =
482 OpenAssetAsRuntimeStage("runtime_stage_simple.frag.iplr");
483 ABSL_ASSERT_OK(runtime_stages_result);
484 std::shared_ptr<RuntimeStage> runtime_stage =
485 runtime_stages_result
486 .value()[PlaygroundBackendToRuntimeStageBackend(GetBackend())];
487 ASSERT_TRUE(runtime_stage);
488
489 auto runtime_effect = DlRuntimeEffectImpeller::Make(runtime_stage);
490 auto uniform_data = std::make_shared<std::vector<uint8_t>>();
491 auto color_source = flutter::DlColorSource::MakeRuntimeEffect(
492 runtime_effect, {}, uniform_data);
493
494 paint.setColorSource(color_source);
495
496 builder.Scale(GetContentScale().x, GetContentScale().y);
497 builder.Save();
498 builder.DrawRect(DlRect::MakeLTRB(0, 0, 100, 100), rect_paint);
499 builder.DrawVertices(vertices_lt, flutter::DlBlendMode::kSrcOver, paint);
500 builder.DrawVertices(vertices_rt, flutter::DlBlendMode::kSrcOver, paint);
501 builder.DrawVertices(vertices_lb, flutter::DlBlendMode::kSrcOver, paint);
502 builder.DrawVertices(vertices_rb, flutter::DlBlendMode::kSrcOver, paint);
503 builder.Restore();
504
505 ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
506 }
507
508 // The vertices should form a solid red rectangle with no gaps.
509 // The blue rectangle drawn under them should not be visible.
510 TEST_P(AiksTest,
511 DrawVerticesTextureCoordinatesWithFragmentShaderNonZeroOrigin) {
512 std::vector<DlPoint> positions_lt = {
513 DlPoint(200, 200), //
514 DlPoint(250, 200), //
515 DlPoint(200, 250), //
516 DlPoint(250, 250), //
517 };
518
519 auto vertices = flutter::DlVertices::Make(
520 flutter::DlVertexMode::kTriangleStrip, positions_lt.size(),
521 positions_lt.data(),
522 /*texture_coordinates=*/positions_lt.data(), /*colors=*/nullptr,
523 /*index_count=*/0,
524 /*indices=*/nullptr);
525
526 flutter::DisplayListBuilder builder;
527 flutter::DlPaint paint;
528 flutter::DlPaint rect_paint;
529 rect_paint.setColor(DlColor::kBlue());
530
531 auto runtime_stages_result =
532 OpenAssetAsRuntimeStage("runtime_stage_position.frag.iplr");
533 ABSL_ASSERT_OK(runtime_stages_result);
534 std::shared_ptr<RuntimeStage> runtime_stage =
535 runtime_stages_result
536 .value()[PlaygroundBackendToRuntimeStageBackend(GetBackend())];
537 ASSERT_TRUE(runtime_stage);
538
539 auto runtime_effect = DlRuntimeEffectImpeller::Make(runtime_stage);
540 auto rect_data = std::vector<Rect>{Rect::MakeLTRB(200, 200, 250, 250)};
541
542 auto uniform_data = std::make_shared<std::vector<uint8_t>>();
543 uniform_data->resize(rect_data.size() * sizeof(Rect));
544 memcpy(uniform_data->data(), rect_data.data(), uniform_data->size());
545
546 auto color_source = flutter::DlColorSource::MakeRuntimeEffect(
547 runtime_effect, {}, uniform_data);
548
549 paint.setColorSource(color_source);
550
551 builder.Scale(GetContentScale().x, GetContentScale().y);
552 builder.DrawRect(DlRect::MakeLTRB(200, 200, 250, 250), rect_paint);
553 builder.DrawVertices(vertices, flutter::DlBlendMode::kSrcOver, paint);
554
555 ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
556 }
557
558 // Regression test for https://github.com/flutter/flutter/issues/170480 .
559 TEST_P(AiksTest, VerticesGeometryWithMaskFilter) {
560 DisplayListBuilder builder;
561 DlPaint paint;
562 paint.setMaskFilter(DlBlurMaskFilter::Make(DlBlurStyle::kNormal, 10));
563
564 std::vector<DlPoint> vertex_coordinates = {
565 DlPoint(0, 0),
566 DlPoint(400, 0),
567 DlPoint(0, 400),
568 };
569 auto vertices = MakeVertices(DlVertexMode::kTriangleStrip, vertex_coordinates,
570 {0, 1, 2}, {}, {});
571
572 builder.DrawVertices(vertices, DlBlendMode::kSrcOver, paint);
573 ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
574 }
575
576 } // namespace testing
577 } // namespace impeller
aiks_unittests.h
flutter::DlRuntimeEffectImpeller::Make
static sk_sp< DlRuntimeEffect > Make(std::shared_ptr< impeller::RuntimeStage > runtime_stage)
Definition: dl_runtime_effect_impeller.cc:14
impeller::AiksContext
Definition: aiks_context.h:20
impeller::AiksPlayground
Definition: aiks_playground.h:16
impeller::DlImageImpeller::Make
static sk_sp< DlImageImpeller > Make(std::shared_ptr< Texture > texture, OwningContext owning_context=OwningContext::kIO)
Definition: dl_image_impeller.cc:23
dl_dispatcher.h
x
int32_t x
Definition: dl_golden_unittests.cc:458
dl_image_impeller.h
dl_runtime_effect_impeller.h
flutter
Definition: dl_golden_blur_unittests.cc:16
impeller::testing::TEST_P
TEST_P(AiksTest, DrawAtlasNoColor)
Definition: aiks_dl_atlas_unittests.cc:59
impeller
Definition: allocation.cc:12
impeller::Scalar
float Scalar
Definition: scalar.h:19
impeller::DisplayListToTexture
std::shared_ptr< Texture > DisplayListToTexture(const sk_sp< flutter::DisplayList > &display_list, ISize size, AiksContext &context, bool reset_host_buffer, bool generate_mips, std::optional< PixelFormat > target_pixel_format)
Render the provided display list to a texture with the given size.
Definition: dl_dispatcher.cc:1220
impeller::PlaygroundBackendToRuntimeStageBackend
constexpr RuntimeStageBackend PlaygroundBackendToRuntimeStageBackend(PlaygroundBackend backend)
Definition: playground.h:33
impeller::Rect
TRect< Scalar > Rect
Definition: rect.h:788
impeller::Point
TPoint< Scalar > Point
Definition: point.h:425
impeller::DlPoint
flutter::DlPoint DlPoint
Definition: dl_dispatcher.h:24
impeller::TRect< Scalar >::MakeLTRB
constexpr static TRect MakeLTRB(Type left, Type top, Type right, Type bottom)
Definition: rect.h:129